/*--------------------------------------------------------------------*/ int MessageBox (char* message) { int w=320, h=200; Fl_Window window (w,h); Fl_Box box(FL_BORDER_BOX, 30,20, w-60,h-10-60, message); box.color(FL_CYAN); /* Fl_Button cancel( 60, h-40, 80, 25, "cancel"); */ Fl_Return_Button ok (w/2-40, h-40, 80, 25, "OK"); ok.color (FL_CYAN); window.color (FL_BLUE); window.hotspot(&/* cancel */ok); // you must position modal windows window.end(); window.set_modal(); window.label("MessageBox"); window.show(); for (;;) { Fl::wait(); Fl_Widget *o; while ((o = Fl::readqueue())) { if (o == &ok) return 1; else return 0; } } }
double numberOrStringOptionChooser(const std::string &category, int index, const std::string &name, bool isNumber, const std::string &title, bool isInteractive, double minimum, double maximum, double step) { double valn = 0.; std::string vals = ""; if(isNumber) NumberOption(GMSH_GET, category.c_str(), index, name.c_str(), valn); else StringOption(GMSH_GET, category.c_str(), index, name.c_str(), vals); int nn = (isInteractive ? 2 : 3); int width = nn * BB + (nn + 1) * WB, height = 2 * BH + 3 * WB; std::string t = title; if(t.empty()) t = (isNumber ? "Number Chooser" : "String Chooser"); Fl_Window *win = new paletteWindow(width, height, false, t.c_str()); win->set_modal(); win->hotspot(win); inputValueFloat *number = 0; Fl_Input *string = 0; if(isNumber){ number = new inputValueFloat(WB, WB, width - 2 * WB, BH); number->value(valn); if(isInteractive){ static opt_data d; d.category = category; d.index = index; d.name = name; number->minimum(minimum); number->maximum(maximum); number->step(step, 1); number->callback(interactive_cb, (void*)&d); number->when(FL_WHEN_RELEASE); } } else{ string = new Fl_Input(WB, WB, width - 2 * WB, BH); string->value(vals.c_str()); } Fl_Button *ok = new Fl_Return_Button (width - nn * BB - nn * WB, 2 * WB + BH, BB, BH, "OK"); Fl_Button *def = new Fl_Button (width - (nn - 1) * BB - (nn - 1) * WB, 2 * WB + BH, BB, BH, "Default"); Fl_Button *cancel = 0; if(!isInteractive) cancel = new Fl_Button (width - BB - WB, 2 * WB + BH, BB, BH, "Cancel"); win->end(); win->show(); if(number) number->take_focus(); if(string) string->take_focus(); bool done = false; while(win->shown()){ if(done) break; Fl::wait(); for (;;) { Fl_Widget* o = Fl::readqueue(); if (!o) break; if (o == win || o == cancel) { done = true; break; } if(o == ok){ if(isNumber){ valn = number->value(); NumberOption(GMSH_SET|GMSH_GUI, category.c_str(), index, name.c_str(), valn); } else{ vals = string->value(); StringOption(GMSH_SET|GMSH_GUI, category.c_str(), index, name.c_str(), vals); } done = true; break; } if(o == def){ if(isNumber){ NumberOption(GMSH_GET_DEFAULT, category.c_str(), index, name.c_str(), valn); number->value(valn); if(isInteractive) number->do_callback(); } else{ StringOption(GMSH_GET_DEFAULT, category.c_str(), index, name.c_str(), vals); string->value(vals.c_str()); } break; } } } delete win; if(isNumber){ NumberOption(GMSH_GET, category.c_str(), index, name.c_str(), valn); return valn; } else return 0.; }