Exemple #1
0
void initialize_settings (void)
{
  _fgcolor = colortrans(WHITE);	//Default drawing color = white
  _bgcolor = colortrans(BLACK);	//default background = black
  _fontcolor = WHITE;				/* Default font color */
  putenv("LIBGRAPHICS_ACTIVE=1");  /*This is used by text funtions to 
				     determine whether to use stdout or 
				     drawing screen */
  setfontcolor(_fontcolor); //Loads the default font -- white
  _internal_linestyle.linestyle = SOLID_LINE;
  _internal_linestyle.thickness = NORM_WIDTH;
  _internal_linestyle.upattern = 0xffff;
}
void displaygraphics(int n, struct process *pr1) {
  int gd = DETECT, gm = 100800;
  int x, y, i, j;
  struct process *base = pr1;

  char m[] = "FCFS";
  char p[100];
  char id[50];
  initgraph(&gd, &gm, 0);
  moveto(0, 0);
  x = getmaxx();
  y = getmaxy();
  setcolor(BLUE);
  rectangle(0, 0, x, y);
  line(0, y / 3, x, y / 3);
  setfontcolor(RED);

  for (i = 0; i < n; ++i, ++base) {
    sprintf(p, "Process %d", i + 1);
    outtextxy(x / n * i, 20, p);
    sprintf(p, "ID %5u", base->pid);
    outtextxy(x / n * i, 50, p);
    sprintf(p, "AT%5u", base->at);
    outtextxy(x / n * i, 60, p);
    sprintf(p, "BT %5u", base->bt);
    outtextxy(x / n * i, 70, p);
    line(x / n * i, 0, x / n * i, y / 3);
  }
  outtextxy(x / 3, 5 + y / 3, m);
  setcolor(BLUE);
  bar(x / 3 + 20, y / 3 + 30, x / 3 + 100, y / 3 + 100);
  sorting(n, pr1, 20);
  for (i = 0; i < n; i++) {
    for (j = 0; j < n; j++) {
      if ((pr1[i].at) == (pr2[j].at)) {
        setcolor(BLUE);
        bar(x / 3 + 20, y / 3 + 30, x / 3 + 100, y / 3 + 100);
        sprintf(id, "pid%d", pr2[j].pid);
        outtextxy(x / 3 + 30, y / 3 + 55, id);
        delay(2000);
        setfontcolor(BLUE);
      }
    }
    setfontcolor(RED);
  }

  setcolor(BLUE);
  line(0, 2 * y / 3, x, 2 * y / 3);
  for (i = 0; i < n; i++) {
    for (j = 0; j < n; j++) {
      if ((pr1[i].at) == (pr2[j].at)) {
        sprintf(id, "pid%d", pr2[j].pid);
        outtextxy(x / n * i, 2 * (y / 3) + 50, id);
        delay(2000);
      }
    }
    line(x / n * i, 2 * y / 3, x / n * i, y);
  }
  delay(2000);
  outtextxy(x - 150, y - 20, "Tapasweni Pathak");
  while (!kbhit())
    ;
  closegraph();
}
void TxtReader::createActions()
{
    openAct = new QAction(QIcon(":/images/open.png"),"", this);
    //openAct->setShortcut(tr("Ctrl+O"));
    connect(openAct, SIGNAL(triggered()), this, SLOT(open()));

    jumpAct = new QAction(QIcon(":/images/jump.png"),"", this);
    //openAct->setShortcut(tr("Ctrl+O"));
    connect(jumpAct, SIGNAL(triggered()), this, SLOT(jumptoindex()));

    addBookmarkAct = new QAction(QIcon(":/images/addbookmark.png"),"", this);
    //openAct->setShortcut(tr("Ctrl+O"));
    connect(addBookmarkAct, SIGNAL(triggered()), this, SLOT(addBookmark()));

    delBookmarkAct = new QAction(QIcon(":/images/delbookmark.png"),"", this);
    //openAct->setShortcut(tr("Ctrl+O"));
    connect(delBookmarkAct, SIGNAL(triggered()), this, SLOT(delBookmark()));

    addTxtSizeAct = new QAction(QIcon(":/images/zoom-in.png"),"", this);
    //openAct->setShortcut(tr("Ctrl+O"));
    connect(addTxtSizeAct, SIGNAL(triggered()), this, SLOT(addTxtSize()));

    subTxtSizeAct = new QAction(QIcon(":/images/zoom-out.png"),"", this);
    //openAct->setShortcut(tr("Ctrl+O"));
    connect(subTxtSizeAct, SIGNAL(triggered()), this, SLOT(subTxtSize()));

    setfontAct = new QAction(QIcon(":/images/setfont.png"),"", this);
    connect(setfontAct, SIGNAL(triggered()), this, SLOT(setfont()));

    setfontcolorAct = new QAction(QIcon(":/images/bgcolor.png"),"", this);
    connect(setfontcolorAct, SIGNAL(triggered()), this, SLOT(setfontcolor()));

    setbgcolorAct = new QAction(QIcon(":/images/bgcolor.png"),"", this);
    connect(setbgcolorAct, SIGNAL(triggered()), this, SLOT(setbgcolor()));

    setbgimageAct = new QAction(QIcon(":/images/bgimage.png"),"", this);
    connect(setbgimageAct, SIGNAL(triggered()), this, SLOT(setbgimage()));
    
    delbgimageAct = new QAction(QIcon(":/images/resetbg.png"),"", this);
    connect(delbgimageAct, SIGNAL(triggered()), this, SLOT(delbgimage()));

    codecActionGroup = new QActionGroup(this);
    connect(codecActionGroup, SIGNAL(triggered(QAction *)),
            this, SLOT(setcodecstr(QAction *)));
    GB2312Act = new QAction(tr("&GB2312"), this);
    GB2312Act->setData("GB2312");
    GB2312Act->setCheckable(true);
	codecActionGroup->addAction(GB2312Act);
	if (codecstr == "GB2312") GB2312Act->setChecked(true);

    UTF8Act = new QAction(tr("&UTF-8"), this);
    UTF8Act->setData("UTF-8");
    UTF8Act->setCheckable(true);
	codecActionGroup->addAction(UTF8Act);
	if (codecstr == "UTF-8") UTF8Act->setChecked(true);

    for (int i = 0; i < MaxRecentFiles; ++i) {
        recentFileActs[i] = new QAction(this);
        recentFileActs[i]->setVisible(false);
        connect(recentFileActs[i], SIGNAL(triggered()),
                this, SLOT(openRecentFile()));
    }

    //maximizeAction = new QAction(tr("Ma&ximize"), this);
    //connect(maximizeAction, SIGNAL(triggered()), this, SLOT(showMaximized()));
    
    viewfullscreenAction = new QAction(QIcon(":/images/fullscreen.png"),"", this);
    connect(viewfullscreenAction, SIGNAL(triggered()), this, SLOT(myshowfullscreen()));
    
    nofullscreenAction = new QAction(QIcon(":/images/nofullscreen.png"),"", this);
    connect(nofullscreenAction, SIGNAL(triggered()), this, SLOT(myexitfullscreen()));
    
    hiddenAction = new QAction(QIcon(":/images/min.png"),"", this);
    connect(hiddenAction, SIGNAL(triggered()), this, SLOT(myhide()));

    restoreAction = new QAction(QIcon(":/images/restore.png"),"", this);
    connect(restoreAction, SIGNAL(triggered()), this, SLOT(myrestore()));

    quitAction = new QAction(QIcon(":/images/exit.png"),"", this);
    //quitAction->setShortcut(tr("Ctrl+Q"));
    connect(quitAction, SIGNAL(triggered()), this, SLOT(quitaction()));

    aboutAct = new QAction(QIcon(":/images/about.png"),"", this);
    //aboutAct->setShortcut(tr("Ctrl+A"));
    //aboutAct->setStatusTip(tr("Show the application's About box"));
    connect(aboutAct, SIGNAL(triggered()), this, SLOT(about()));

    instructionAct = new QAction(QIcon(":/images/instruction.png"),"", this);
    //instructionAct->setShortcut(tr("Ctrl+A"));
    //instructionAct->setStatusTip(tr("Show the application's About box"));
    connect(instructionAct, SIGNAL(triggered()), this, SLOT(readOrInstruction()));
	return ;
}