void visit() { int pop_up(); LISTPTR Pnode; push_down(&Pstack, v1); val[v1] = IN_STACK; while ((v1 = pop_up(&Pstack)) != 0) { Pnode = garray[v1]->first; garray[v1]->set = numcomps; while (Pnode) { v2 = Pnode->t_vertex; if (garray[v2]->status == LABEL && val[v2] == UNVISITED) { if (earray[Pnode->edge]->intree) { push_down(&Pstack, v2); val[v2] = IN_STACK; } } Pnode = Pnode->next; } } } /* end of visit */
main() {clrscr(); int choice; char ch; set_mod(); start(); //set_mod(); while(1) { cleardevice(); //bh_devil(); mainscrean(menu,5); ch=getche(); switch(ch) {case 'g': choice=pop_up(file,20,40,count[1]); gserver(choice); break; case 'o': choice=pop_up(dir,80,40,count[2]); // dserver(choice); break; case 'd': choice=pop_up(stud,150,40,count[3]); // sserver(choice); break; case 'e': choice=pop_up(emp_r,240,40,count[4]); // eserver(choice); break; case 'q': return 0; // getch(); }; // last(); } }
void run() { char ch; while(1) { menu(); ch=getch(); switch(ch) { case '1': push_down(); break; case '2': pop_down(); break; case '3': push_up(); break; case '4': pop_up(); break; case '5': printall(); break; case '6': return; } system("pause"); } }
int main(int argc, char *argv[]) { int i,j,k; char c; int res=0; int x,y; char buttons; struct termios t_new,t_old; FILE *fsc; char buf[100]; progname=argv[0]; screen_gamma=1.5; #ifdef DEBUG log=fopen("/png/view.log","w"); #endif while((c=getopt(argc,argv,"r:g:"))!=-1) { switch(c) { case 'r': res=atoi(optarg); if(res>0) max_screen_colors=256; break; case 'g': screen_gamma=atof(optarg); break; case '?': default: usage(); exit(0); } } switch(res) { case 0: VGLInit(SW_CG640x480); break; case 1: VGLInit(SW_VGA_CG320); break; case 2: VGLInit(SW_VGA_MODEX); break; default: fprintf(stderr,"No such resolution!\n"); usage(); exit(-1); } #ifdef DEBUG fprintf(log,"VGL initialised\n"); #endif VGLSavePalette(); if(argc>optind) { res=png_load(argv[optind]); } else { VGLEnd(); usage(); exit(0); } if(res) { /* Hmm... Script? */ fsc=fopen(argv[optind],"r"); #ifdef DEBUG fprintf(log,"Trying script %s\n",argv[optind]); #endif fgets(buf,99,fsc); buf[strlen(buf)-1]='\0'; if(strncmp("VIEW SCRIPT",buf,11)!=NULL) { VGLEnd(); usage(); } if(strlen(buf)>12) { auto_chg=atoi(buf+12); } fgets(buf,99,fsc); buf[strlen(buf)-1]='\0'; nimg=atoi(buf); if(nimg==0) { VGLEnd(); usage(); } pres=(char **)calloc(nimg,sizeof(char *)); for(i=0;i<nimg;i++) { fgets(buf,99,fsc); buf[strlen(buf)-1]='\0'; pres[i]=strdup(buf); } fclose(fsc); cur_img=0; #ifdef DEBUG fprintf(log,"Script with %d entries\n",nimg); #endif png_load(pres[cur_img]); } VGLMouseInit(VGL_MOUSEHIDE); /* Prepare the keyboard */ tcgetattr(0,&t_old); memcpy(&t_new,&t_old,sizeof(struct termios)); cfmakeraw(&t_new); tcsetattr(0,TCSAFLUSH,&t_new); fcntl(0,F_SETFL,O_ASYNC); /* XXX VGLClear doesn't work.. :-(( Prepare a blank background */ bkg.Bitmap=(byte *)calloc(VGLDisplay->Xsize*VGLDisplay->Ysize,1); bkg.Xsize=VGLDisplay->Xsize; bkg.Ysize=VGLDisplay->Ysize; bkg.Type=VGLDisplay->Type; signal(SIGIO,kbd_handler); a.zoom=1; a.Xshift=(VGLDisplay->Xsize-pic.Xsize)/2; a.Yshift=(VGLDisplay->Ysize-pic.Ysize)/2; a.rotate=0; quit=0; changed=0; display(&pic,pal_red,pal_green,pal_blue,&a); while(!quit) { if(act) { #ifdef DEBUG fprintf(log,"kbd_action(%c)\n",act); #endif kbd_action(x,y,act); } if(quit) break; if(changed) { #ifdef DEBUG fprintf(log,"changed, redisplaying\n"); #endif display(&pic,pal_red,pal_green,pal_blue,&a); changed=0; } if(auto_chg) { sleep(auto_chg); kbd_action(x,y,'n'); } else { pause(); } VGLMouseStatus(&x,&y,&buttons); if(buttons & MOUSE_BUTTON3DOWN) { #ifdef DEBUG fprintf(log,"pop_up called\n"); #endif pop_up("View",x,y); } } VGLEnd(); #ifdef DEBUG fclose(log); #endif exit(0); }
void MainWindow::initial() { my_sync_widget->setWindowModality(Qt::WindowModal); my_sync_widget->hide(); connect(my_sync_widget, SIGNAL(getSaveFile(QString&)), this, SLOT(syncSaveFile(QString&))); connect(my_sync_widget, SIGNAL(enableServiceButton(QString&)), this, SLOT(serviceAdded(QString&))); connect(this, SIGNAL(syncClickEmit()), my_sync_widget, SLOT(syncFiles())); connect(my_sync_widget, SIGNAL(openXml(QString&)), this, SLOT(openXmlRecv(QString&))); connect(my_sync_widget, SIGNAL(dboxAuthResult(bool)), this, SLOT(dboxAuthStatus(bool))); connect(my_sync_widget, SIGNAL(dboxRecvResult(bool)), this, SLOT(dboxRecvStatus(bool))); connect(my_sync_widget, SIGNAL(dboxSendResult(bool)), this, SLOT(dboxSendStatus(bool))); connect(my_sync_widget, SIGNAL(googleAuthResult(bool)), this, SLOT(googleAuthStatus(bool))); connect(my_sync_widget, SIGNAL(googleRecvResult(bool)), this, SLOT(googleRecvStatus(bool))); connect(my_sync_widget, SIGNAL(googleSendResult(bool)), this, SLOT(googleSendStatus(bool))); fileMenu = menuBar()->addMenu(tr("&File")); newList = new QAction( tr("&New lists..."), this ); newList->setShortcuts(QKeySequence::New); fileMenu->addAction(newList); connect(newList, SIGNAL(triggered()), this->my_task_list,SLOT(new_list())); fileMenu->addSeparator(); loadAction = new QAction(tr("&Open XML..."), this); loadAction->setShortcuts(QKeySequence::Open); fileMenu->addAction(loadAction); connect(loadAction, SIGNAL(triggered()), this, SLOT(loadFile())); saveAction = new QAction( tr("&Save..."), this ); saveAction->setShortcuts(QKeySequence::Save); fileMenu->addAction(saveAction); connect(saveAction, SIGNAL(triggered()), this, SLOT(saveFile())); saveAsAction = new QAction( tr("&Save as..."), this ); //saveAsAction->setShortcuts(QKeySequence::SaveAs); fileMenu->addAction(saveAsAction); connect(saveAsAction, SIGNAL(triggered()), this, SLOT(saveasFile())); fileMenu->addSeparator(); printAction = new QAction(tr("&Print"),this); printAction->setShortcuts(QKeySequence::Print); fileMenu->addAction(printAction); connect(printAction, SIGNAL(triggered()), this,SLOT(print())); fileMenu->addSeparator(); exitAction = new QAction(tr("&Exit"), this); fileMenu->addAction(exitAction); connect(exitAction, SIGNAL(triggered()), this, SLOT(close())); OptMenu = menuBar()->addMenu(tr("&Options")); change_font = new QAction(tr("&Change Font"),this); OptMenu->addAction(change_font); display_note = new QAction(tr("&Display/Hide Note"), this); OptMenu->addAction(display_note); search_for= new QAction(tr("&Search"),this); search_for->setShortcut(QKeySequence::Find); OptMenu->addAction(search_for); connect(search_for,SIGNAL(triggered()),this,SLOT(search_start())); Template = menuBar()->addMenu(tr("&Template")); new_grocery = new QAction(tr("&Groceries"),this); Template->addAction(new_grocery); new_week_task = new QAction(tr("&Weekly Task"),this); Template->addAction(new_week_task); Sync = menuBar()->addMenu(tr("&Sync Menu")); new_service = new QAction(tr("&Add Service"), this); Sync->addAction(new_service); sync_service = new QAction(tr("&Sync Services (On)"), this); Sync->addAction(sync_service); sync_service_off = new QAction(tr("&Sync Services Off"), this); Sync->addAction(sync_service_off); send_service = new QAction(tr("&Send Current File"), this); Sync->addAction(send_service); get_service = new QAction(tr("&Get Dropbox Files"), this); Sync->addAction(get_service); send_service_gtask = new QAction(tr("&Send Current File (GTask)"), this); Sync->addAction(send_service_gtask); get_service_gtask = new QAction(tr("&Get GTask Files"), this); Sync->addAction(get_service_gtask); sync_service->setDisabled(true); send_service->setDisabled(true); sync_service_off->setDisabled(true); get_service->setDisabled(true); send_service_gtask->setDisabled(true); get_service_gtask->setDisabled(true); addTask = new QPushButton( tr("Add Task") ); delTask = new QPushButton( tr("Delete") ); editTask = new QPushButton( tr("Edit Task") ); pop_up = new QPushButton(tr("Pop Task Up")); move_down = new QPushButton(tr("Move Task Down")); search_button = new QPushButton(tr("Search")); QWidget *main_widget = new QWidget; QVBoxLayout *main_layout = new QVBoxLayout; QHBoxLayout *button_layout1 = new QHBoxLayout; QHBoxLayout *button_layout2 = new QHBoxLayout; //here is the list name area //main_layout->addWidget( new QLabel(tr("Lists name")),0,Qt::AlignCenter ); //main_layout->addWidget(my_task_list->lists_name); this->my_task_list->setColumnCount(5); QStringList tmp_l; tmp_l << "Name" << "Note" << "Tag" << "Due Date" << "Status"; this->my_task_list->setHeaderLabels(tmp_l ); this->my_task_list->setEditTriggers(QAbstractItemView::DoubleClicked); this->my_task_list->setSelectionMode(QAbstractItemView::SingleSelection); this->my_task_list->setSelectionBehavior(QAbstractItemView::SelectRows); //here is the table content /*QStandardItemModel *tmp_mod = my_task_list->mod; tmp_mod->setColumnCount(4); tmp_mod->setHeaderData(0, Qt::Horizontal, tr("Name")); tmp_mod->setHeaderData(1,Qt::Horizontal, tr("Note")); tmp_mod->setHeaderData(2,Qt::Horizontal, tr("Due date")); tmp_mod->setHeaderData(3,Qt::Horizontal, tr("Status")); my_task_list->table->setModel(tmp_mod); my_task_list->table->setEditTriggers(QAbstractItemView::DoubleClicked); my_task_list->table->setSelectionMode(QAbstractItemView::SingleSelection); my_task_list->table->setSelectionBehavior(QAbstractItemView::SelectRows);*/ /*QTreeWidgetItem* task_child = new QTreeWidgetItem(this->my_task_list,0); task_child->setText(0,"a"); this->my_task_list->addTopLevelItem(task_child); QTreeWidgetItem* task_child1 = new QTreeWidgetItem(task_child,1); task_child1->setText(0,"1"); QTreeWidgetItem* task_child2 = new QTreeWidgetItem(task_child,1); task_child2->setText(0,"2"); QTreeWidgetItem* task_child3 = new QTreeWidgetItem(task_child,1); task_child3->setText(0,"3"); task_child->addChild(task_child1); task_child->addChild(task_child2); task_child->addChild(task_child3); QTreeWidgetItem* task_child4 = new QTreeWidgetItem(task_child,1); task_child4->setText(0,"0"); task_child->insertChild(-2,task_child4); */ main_layout->addWidget( new QLabel(tr("Current Lists")),0,Qt::AlignCenter ); main_layout->addWidget(this->my_task_list); button_layout1->addWidget(addTask); button_layout1->addWidget(delTask); button_layout1->addWidget(editTask); button_layout2->addWidget(pop_up); button_layout2->addWidget(move_down); button_layout2->addWidget(search_button); main_layout->addLayout(button_layout1); main_layout->addLayout(button_layout2); main_widget->setLayout(main_layout); main_widget->setMinimumSize(520,500); this->setCentralWidget(main_widget); //connection connect(addTask, SIGNAL(clicked()), this->my_task_list,SLOT(addTask())); connect(delTask, SIGNAL(clicked()), this->my_task_list,SLOT(delTask())); connect(editTask, SIGNAL(clicked()), this->my_task_list, SLOT(editTask())); connect(display_note, SIGNAL(triggered()), this->my_task_list, SLOT(show_hide_Note()));//the action one in the menu connect(change_font, SIGNAL(triggered()), this->my_task_list, SLOT(changeFont())); connect(pop_up, SIGNAL(clicked()), this->my_task_list, SLOT(pop_up())); connect(move_down, SIGNAL(clicked()), this->my_task_list, SLOT(move_down())); connect(new_grocery, SIGNAL(triggered()), this->my_task_list, SLOT(grocery())); connect(new_week_task, SIGNAL(triggered()), this->my_task_list, SLOT(week_task())); connect(new_service, SIGNAL(triggered()), this, SLOT(newServiceClick())); connect(sync_service, SIGNAL(triggered()), this, SLOT(syncClick())); connect(sync_service_off, SIGNAL(triggered()), this, SLOT(syncClickOff())); connect(send_service, SIGNAL(triggered()), this->my_sync_widget, SLOT(sendFiles())); connect(get_service, SIGNAL(triggered()), this->my_sync_widget, SLOT(getFiles())); connect(send_service_gtask, SIGNAL(triggered()), this->my_sync_widget, SLOT(sendFilesGTask())); connect(get_service_gtask, SIGNAL(triggered()), this->my_sync_widget, SLOT(getFilesGTask())); connect(search_button, SIGNAL(clicked()), this, SLOT(search_start())); }