void butt_cb(Fl_Widget *butt, void *data) { // Deactivate the button butt->deactivate(); // prevent button from being pressed again Fl::check(); // give fltk some cpu to gray out button // Make the progress bar Fl_Window *w = (Fl_Window*)data; // access parent window w->begin(); // add progress bar to it.. Fl_Progress *progress = new Fl_Progress(10,50,200,30); progress->minimum(0); // set progress range to be 0.0 ~ 1.0 progress->maximum(1); progress->color(0x88888800); // background color progress->selection_color(0x4444ff00); // progress bar color progress->labelcolor(FL_WHITE); // percent text color w->end(); // end adding to window // Computation loop.. for ( int t=1; t<=500; t++ ) { progress->value(t/500.0); // update progress bar with 0.0 ~ 1.0 value char percent[10]; sprintf(percent, "%d%%", int((t/500.0)*100.0)); progress->label(percent); // update progress bar's label Fl::check(); // give fltk some cpu to update the screen Sleep(1000); // 'your stuff' that's compute intensive } // Cleanup w->remove(progress); // remove progress bar from window delete(progress); // deallocate it butt->activate(); // reactivate button w->redraw(); // tell window to redraw now that progress removed }
int gdConfirmWin(const char *title, const char *msg) { Fl_Window *win = new Fl_Window( (Fl::w() / 2) - 150, (Fl::h() / 2) - 47, 300, 90, title); win->set_modal(); win->begin(); new gBox(10, 10, 280, 40, msg); gClick *ok = new gClick(212, 62, 80, 20, "Ok"); gClick *ko = new gClick(124, 62, 80, 20, "Cancel"); win->end(); ok->shortcut(FL_Enter); gu_setFavicon(win); win->show(); /* no callbacks here. readqueue() check the event stack. */ int r = 0; while (true) { Fl_Widget *o = Fl::readqueue(); if (!o) Fl::wait(); else if (o == ok) {r = 1; break;} else if (o == ko) {r = 0; break;} } //delete win; win->hide(); return r; }
int main() { Fl_Window* w = new Fl_Window(width,height); Widgets widgets; w->begin(); widgets.img[0] = new Fl_JPEG_Image("f1.jpg"); widgets.img[1] = new Fl_JPEG_Image("f2.jpg"); widgets.img[2] = new Fl_JPEG_Image("f3.jpg"); widgets.box = new Fl_Box(100,100,100,100); Fl_Button* button = new Fl_Button(300,400,50,30,"CHANGE"); w->end(); button->callback(button_clicked,&widgets); w->show(); return(Fl::run()); }
int main() { Fl_Window* win = new Fl_Window(290, 180, "Icon chooser test"); win->begin(); Fl_Box* ibox = image_box = new Fl_Box(80, 10, 135, 110); ibox->box(FL_THIN_DOWN_BOX); Fl_Button* run = new Fl_Button(95, 145, 90, 25, "&Run"); run->callback(run_cb); Fl_Button* close = new Fl_Button(190, 145, 90, 25, "&Close"); close->callback(close_cb, win); win->end(); win->show(); return Fl::run(); }
void gdAlert(const char *c) { Fl_Window *modal = new Fl_Window( (Fl::w() / 2) - 150, (Fl::h() / 2) - 47, 300, 90, "Alert"); modal->set_modal(); modal->begin(); gBox *box = new gBox(10, 10, 280, 40, c); gClick *b = new gClick(210, 60, 80, 20, "Close"); modal->end(); box->labelsize(GUI_FONT_SIZE_BASE); b->callback(__cb_window_closer, (void *)modal); b->shortcut(FL_Enter); gu_setFavicon(modal); modal->show(); }
int main(int argc, char **argv) { Fl_Window *window = new Fl_Window(20,20,300,180); //Set type to DIALOG window->window_type(Fl_WM::DIALOG); window->begin(); Fl_Box *box = new Fl_Box(20,40,260,100,"Hello World"); box->box(FL_UP_BOX); box->label_font(FL_HELVETICA_BOLD_ITALIC); box->label_size(36); box->label_type(FL_SHADOW_LABEL); window->end(); window->show(argc, argv); return Fl::run(); }
int main(int argc, char **argv) { Fl_Window *window = new Fl_Window(340,180,"世界へようこそ!"); Fl_Box *box = new Fl_Box(20,40,300,100,"ようこそ、世界!"); Fl::set_font(FL_HELVETICA, "Kochi Mincho"); window->begin(); // Fl_Widget(x, y, width, height, label) //box->box(FL_UP_BOX); box->box(FL_NO_BOX); box->labelsize(36); box->labeltype(FL_SHADOW_LABEL); window->end(); window->show(argc, argv); return Fl::run(); }
Elements(){ window = new Fl_Window(WINDOW_W,WINDOW_H,WINDOW_TITLE); window->begin(); button = new Fl_Button (LABEL_SPACE,MARGIN,BUTTON_W,ELEMENT_H,"OK"); input = new Fl_Input (LABEL_SPACE,2*MARGIN+ELEMENT_H,TEXT_W,ELEMENT_H,"In:"); output = new Fl_Output (LABEL_SPACE,3*MARGIN+2*ELEMENT_H,TEXT_W,ELEMENT_H,"Out:"); window->end(); button ->labelfont(FL_HELVETICA); input ->labelfont(FL_HELVETICA); output ->labelfont(FL_HELVETICA); button ->labelsize(TEXT_S); input ->labelsize(TEXT_S); output ->labelsize(TEXT_S); button ->box(FL_UP_BOX); input ->box(FL_DOWN_BOX); output ->box(FL_DOWN_BOX); }
int main(int argc, char** argv) { // Check config option, if showing is disabled, exit Fl_Config conf("EDE Team", "etip"); if(argc == 2 && (!strcmp(argv[1], "-f") || !strcmp(argv[1], "--force"))) { // nothing, to simplify omiting those '!' } else { bool show = true; conf.set_section("Tips"); conf.read("Show", show, true); if (!show) return 0; } conf_global = &conf; srand(time(NULL)); fl_init_locale_support("etip", PREFIX"/share/locale"); Fl_Window* win = new Fl_Window(420, 169, _("Tips...")); win->shortcut(0xff1b); win->begin(); Fl_Group* gr = new Fl_Group(5, 5, 410, 130); gr->box(FL_DOWN_BOX); Fl_Box* img = new Fl_Box(5, 5, 70, 65); Fl_Image pix(hint_xpm); img->image(pix); Fl_Box* title = new Fl_Box(80, 10, 320, 25, random_txt(title_tips, TITLE_TIPS_NUM)); title->label_font(fl_fonts+1); title->align(FL_ALIGN_LEFT|FL_ALIGN_INSIDE); title->box(FL_FLAT_BOX); Fl_Box* tiptxt = new Fl_Box(80, 45, 320, 75, random_txt(tiplist, TIPS_NUM)); tiptxt->align(FL_ALIGN_LEFT|FL_ALIGN_TOP|FL_ALIGN_INSIDE|FL_ALIGN_WRAP); tiptxt->box(FL_FLAT_BOX); gr->end(); Fl_Check_Button* ch = new Fl_Check_Button(5, 140, 150, 25, _(" Do not bother me")); show_check = ch; Fl_Button* prev = new Fl_Button(160, 140, 80, 25, "<-"); prev->label_font(fl_fonts+1); prev->callback(prev_cb, tiptxt); Fl_Button* next = new Fl_Button(245, 140, 80, 25, "->"); next->label_font(fl_fonts+1); next->callback(next_cb, tiptxt); Fl_Button* close = new Fl_Button(335, 140, 80, 25, _("&Close")); close->callback(close_cb, win); win->end(); win->set_modal(); win->show(); return Fl::run(); }