void create_the_forms() { Fl_Widget *obj; form = new Fl_Window(370, 450); obj = new Fl_Box(20,20,330,40,"eFLTK Demonstration"); obj->box(FL_ENGRAVED_BOX); obj->color(FL_GRAY-4); obj->label_size(26); obj->label_font(FL_HELVETICA_BOLD); obj->label_type(FL_SHADOW_LABEL); obj = new Fl_Box(20,70,330,330,0); obj->box(FL_ENGRAVED_BOX); obj->color(FL_GRAY-6); obj = new Fl_Button(20,20,330,380); obj->type(Fl_Button::HIDDEN); obj->callback(doback); obj = but[0] = new Fl_Button(40,90,90,90); obj = but[1] = new Fl_Button(140,90,90,90); obj = but[2] = new Fl_Button(240,90,90,90); obj = but[3] = new Fl_Button(40,190,90,90); obj = but[4] = new Fl_Button(140,190,90,90); obj = but[5] = new Fl_Button(240,190,90,90); obj = but[6] = new Fl_Button(40,290,90,90); obj = but[7] = new Fl_Button(140,290,90,90); obj = but[8] = new Fl_Button(240,290,90,90); for (int i=0; i<9; i++) { but[i]->set_flag(FL_ALIGN_WRAP); but[i]->callback(dobut, i); } obj = new Fl_Button(130,410,110,30,"Exit"); obj->callback(doexit); form->end(); }
void Controller_Module::connect_to ( Port *p ) { control_output[0].connect_to( p ); clear(); Fl_Widget *w; if ( p->hints.type == Module::Port::Hints::BOOLEAN ) { Fl_Light_Button *o = new Fl_Light_Button( 0, 0, 40, 40, p->name() ); w = o; o->value( p->control_value() ); _type = TOGGLE; /* FIXME: hack */ control = (Fl_Valuator*)o; } else if ( p->hints.type == Module::Port::Hints::INTEGER ) { Fl_Counter *o = new Fl_Counter(0, 0, 58, 24, p->name() ); control = o; w = o; o->type(1); o->step(1); if ( p->hints.ranged ) { o->minimum( p->hints.minimum ); o->maximum( p->hints.maximum ); } _type = SPINNER; o->value( p->control_value() ); } else if ( p->hints.type == Module::Port::Hints::LOGARITHMIC ) { Fl_Value_SliderX *o = new Fl_Value_SliderX(0, 0, 30, 250, p->name() ); control = o; w = o; o->type(4); o->color( FL_DARK1 ); o->selection_color( fl_color_average( FL_GRAY, FL_CYAN, 0.5 ) ); o->minimum(1.5); o->maximum(0); o->value(1); o->textsize(9); if ( p->hints.ranged ) { o->minimum( p->hints.maximum ); o->maximum( p->hints.minimum ); } o->value( p->control_value() ); _type = SLIDER; } else { { Fl_DialX *o = new Fl_DialX( 0, 0, 50, 50, p->name() ); w = o; control = o; if ( p->hints.ranged ) { DMESSAGE( "Min: %f, max: %f", p->hints.minimum, p->hints.maximum ); o->minimum( p->hints.minimum ); o->maximum( p->hints.maximum ); } o->color( fl_darker( FL_GRAY ) ); o->selection_color( FL_WHITE ); o->value( p->control_value() ); } _type = KNOB; } control_value = p->control_value(); w->set_visible_focus(); w->align(FL_ALIGN_TOP); w->labelsize( 10 ); w->callback( cb_handle, this ); if ( _pad ) { Fl_Labelpad_Group *flg = new Fl_Labelpad_Group( w ); flg->set_visible_focus(); size( flg->w(), flg->h() ); flg->position( x(), y() ); add( flg ); } else { /* HACK: hide label */ w->labeltype( FL_NO_LABEL ); w->resize( x(), y(), this->w(), h() ); add( w ); resizable( w ); // init_sizes(); } }
void Controller_Module::connect_to ( Port *p ) { control_output[0].connect_to( p ); clear(); Fl_Widget *w; if ( p->hints.type == Module::Port::Hints::BOOLEAN ) { Fl_Button *o = new Fl_Button( 0, 0, 40, 40, p->name() ); w = o; o->type( FL_TOGGLE_BUTTON ); o->value( p->control_value() ); o->selection_color( fl_color_average( FL_GRAY, FL_CYAN, 0.5 ) ); _type = TOGGLE; /* FIXME: hack */ control = (Fl_Valuator*)o; } else if ( p->hints.type == Module::Port::Hints::INTEGER ) { Fl_Counter *o = new Fl_Counter(0, 0, 58, 24, p->name() ); control = o; w = o; o->type(1); o->step(1); if ( p->hints.ranged ) { o->minimum( p->hints.minimum ); o->maximum( p->hints.maximum ); } _type = SPINNER; o->value( p->control_value() ); } // else if ( p->hints.type == Module::Port::Hints::LOGARITHMIC ) else { Fl_Value_SliderX *o = new Fl_Value_SliderX(0, 0, 30, 250, p->name() ); control = o; w = o; if ( ! _horizontal ) { o->size( 30, 250 ); o->type(FL_VERT_NICE_SLIDER); } else { o->size(250,20); o->type(FL_HOR_NICE_SLIDER); } // o->type(4); o->color( FL_BACKGROUND2_COLOR ); o->selection_color( fl_color_average( FL_GRAY, FL_CYAN, 0.5 ) ); o->minimum(1.5); o->maximum(0); o->value(1); // o->textsize(9); if ( p->hints.ranged ) { if ( ! _horizontal ) { o->minimum( p->hints.maximum ); o->maximum( p->hints.minimum ); } else { o->minimum( p->hints.minimum ); o->maximum( p->hints.maximum ); } } o->precision(2); o->value( p->control_value() ); _type = SLIDER; } /* else */ /* { */ /* { Fl_DialX *o = new Fl_DialX( 0, 0, 50, 50, p->name() ); */ /* w = o; */ /* control = o; */ /* if ( p->hints.ranged ) */ /* { */ /* DMESSAGE( "Min: %f, max: %f", p->hints.minimum, p->hints.maximum ); */ /* o->minimum( p->hints.minimum ); */ /* o->maximum( p->hints.maximum ); */ /* } */ /* o->color( fl_darker( FL_GRAY ) ); */ /* o->selection_color( FL_WHITE ); */ /* o->value( p->control_value() ); */ /* } */ /* _type = KNOB; */ /* } */ control_value = p->control_value(); w->clear_visible_focus(); w->align(FL_ALIGN_TOP); w->labelsize( 10 ); w->callback( cb_handle, this ); if ( _pad ) { Fl_Labelpad_Group *flg = new Fl_Labelpad_Group( w ); flg->set_visible_focus(); size( flg->w(), flg->h() ); flg->position( x(), y() ); add( flg ); resizable(flg); // init_sizes(); } else { /* HACK: hide label */ if ( _type == TOGGLE ) { w->align( FL_ALIGN_INSIDE ); } else { w->labeltype( FL_NO_LABEL ); } w->resize( x(), y(), this->w(), h() ); add( w ); resizable( w ); init_sizes(); } }
void fieldWindow::editField(Field *f) { editor_group->user_data(f); put_on_view_btn->deactivate(); delete_btn->deactivate(); if(f == NULL){ selected_id = -1; editor_group->hide(); empty_message->show(); loadFieldList(); return; } FL_NORMAL_SIZE -= _deltaFontSize; selected_id = f->id; empty_message->hide(); editor_group->show(); editor_group->user_data(f); title->label(f->getName()); options_scroll->clear(); options_widget.clear(); options_scroll->begin(); int xx = options_scroll->x(); int yy = options_scroll->y(); std::string help = f->getDescription(); ConvertToHTML(help); if (! f->options.empty()) help += std::string("<p><center><b>Options</b></center>"); for(std::map<std::string, FieldOption*>::iterator it = f->options.begin(); it != f->options.end(); it++){ Fl_Widget *input; help += std::string("<p><b>") + it->first + "</b>"; help += " (<em>" + it->second->getTypeName() + "</em>): "; help += it->second->getDescription(); switch(it->second->getType()){ case FIELD_OPTION_INT: case FIELD_OPTION_DOUBLE: input = new Fl_Value_Input(xx, yy, IW, BH, it->first.c_str()); input->align(FL_ALIGN_RIGHT); break; case FIELD_OPTION_BOOL: input = new Fl_Check_Button(xx, yy, 2 * BB, BH, it->first.c_str()); input->type(FL_TOGGLE_BUTTON); break; case FIELD_OPTION_PATH: { input = new Fl_Input(xx, yy, IW, BH, it->first.c_str()); input->align(FL_ALIGN_RIGHT); int tw = (int)fl_width(it->first.c_str()); Fl_Button *b = new Fl_Button(xx + IW + tw + 2 * WB, yy, BB, BH, "Choose"); b->callback(field_select_file_cb, input); } break; case FIELD_OPTION_STRING: input = new Fl_Input(xx, yy, IW, BH, it->first.c_str()); input->align(FL_ALIGN_RIGHT); break; case FIELD_OPTION_LIST: default: input = new Fl_Input(xx, yy, IW, BH, it->first.c_str()); input->align(FL_ALIGN_RIGHT); break; } options_widget.push_back(input); yy += BH; } if (! f->callbacks.empty()) help += std::string("<p><center><b>Actions</b></center>"); for(std::map<std::string, FieldCallback*>::iterator it = f->callbacks.begin(); it != f->callbacks.end(); it++){ Fl_Widget *btn; help += std::string("<p><b>") + it->first + "</b>: "; help += it->second->getDescription(); btn = new Fl_Button(xx, yy, IW, BH, it->first.c_str()); btn->callback(field_callback_cb, it->second); yy += BH; } help_display->value(help.c_str()); options_scroll->end(); FL_NORMAL_SIZE += _deltaFontSize; loadFieldOptions(); options_scroll->damage(1); put_on_view_btn->activate(); delete_btn->activate(); loadFieldList(); }
void PulseAnalysisDisplay::setup () { Fl_Widget* w; int bigx = 1000; int bigy = 400; int xbuffer=5, ybuffer=5; int xsize0,xsize1,xsize2, xsize3; int ysize0,ysize1; int x[5]; int y[INDEPENDENT_TRACES + 3]; window = new Fl_Double_Window(bigx,bigy, "Pulse Analysis Window"); // set the current user data (void *) argument to the instance pointer window->user_data((void*)(this)); // position the window on screen window->resizable(window); // begin the main window group window->begin(); { xsize0 = 50; // channel selector xsize1 = 100; // color selector xsize2 = xsize1 + xsize0 + xbuffer; // plot selector ysize0 = 25; // standard size ysize1 = (bigy - 2*ybuffer); // plotWindow height x[0] = xbuffer+xbuffer; // channel x[1] = x[0] + xsize0 + xbuffer; // color x[2] = x[0]; // plot type x[3] = x[1] + xsize1 + xbuffer; // plot itself // plotWindow width xsize3 = bigx - (x[1] + xsize1 + xbuffer) - xbuffer; y[0] = ybuffer; // plot selector y[1] = y[1] + ysize0 + ybuffer; // analysis enable y[2] = y[1] + 2*ysize0 + ybuffer; // label for (unsigned int i=0; i<INDEPENDENT_TRACES; i++) { y[3+i] = y[2+i] + ysize0 + ybuffer; // top of top plot choice } // what kind of plot the user wants to see Fl_Menu_Item plotPopup[] = { {"Pulse Height", 0, (Fl_Callback*) handleEvent, (void*) this}, {"Baseline", 0, (Fl_Callback*) handleEvent, (void*) this}, {0} }; w = plotSelector = new Fl_Choice (x[0],y[1],xsize2,ysize0,""); plotSelector->copy(plotPopup,NULL); w->align(FL_ALIGN_RIGHT); // enable analysis button w = performAnalysisFlagButton = new Fl_Light_Button(x[0],y[0],xsize2,ysize0,"Enable Analysis"); w->callback((Fl_Callback*) handleEvent, (void*) this); // the channel selectors w = new Fl_Box (x[0],y[2],xsize0,0,"Channel"); w->align(FL_ALIGN_TOP); w = new Fl_Box (x[1],y[2],xsize0,0,"Color"); w->align(FL_ALIGN_TOP); Fl_Menu_Item topChanPopup[] = { {"-", 0,(Fl_Callback*) handleEvent, (void*) this}, {0} }; for (unsigned int i=0; i< INDEPENDENT_TRACES; i++) { w = channelSelector[i] = new Fl_Choice (x[0],y[i+2],xsize0,ysize0); channelSelector[i]->copy(topChanPopup,NULL); w->align(FL_ALIGN_TOP); } // color selector Fl_Menu_Item colorPopup[] = { {"Black", 0, NULL, (void*) this}, {"Red", 0, NULL, (void*) this}, {"Blue", 0, NULL, (void*) this}, {"Green", 0, NULL, (void*) this}, {"Dark Red", 0, NULL, (void*) this}, {"Dark Blue", 0, NULL, (void*) this}, {"Dark Green", 0, NULL, (void*) this}, {"Dark Cyan", 0, NULL, (void*) this}, {0} }; for (unsigned int i=0; i< INDEPENDENT_TRACES; i++) { w = traceColorSelector[i] = new Fl_Choice (x[1],y[i+2],xsize1, ysize0); traceColorSelector[i]->copy(colorPopup,NULL); w->align(FL_ALIGN_TOP); } // the actual plotter widget plot = new plotWindow (x[3],y[0],xsize3,ysize1); // set some flags plot->connectedLineFlag(false); plot->xDisplayMethod (3); // set x to auto scroll plot->yDisplayMethod (1); // set y to maximum } window->end(); // end main window grouping // now that we are out of the group, init the plot plot->init(); }
Fl_Widget* Fl_Menu_::add( const char *text, int shortcut, Fl_Callback *cb, void *data, int flags ) { Fl_Group* group = this; int bufsize = strlen(text)+1; ARRAY(char, buf, bufsize); int flags1 = 0; const char* item; for (;;) /* do all the supermenus: */ { // leading slash makes us assumme it is a filename: if (*text == '/') {item = text; break;} // leading underscore causes divider line: if (*text == '_') {text++; flags1 = FL_MENU_DIVIDER;} // copy to buf, changing \x to x: char *q = buf; const char *p; for (p=text; *p && *p != '/'; *q++ = *p++) if (p[0]=='\\' && p[1]) p++; *q = 0; item = buf; // if not followed by slash it is not a menu title: if (*p != '/') break; // point at the next text: text = p+1; // find a matching menu title: for (int n = group->children();;) { if (!n) // create a new menu { if (find_flag) return 0; group = (Fl_Group*)append(group,item,FL_SUBMENU|flags1); break; } Fl_Widget* w = group->child(--n); if(w->is_group() && !w->label().empty() && !compare(w->label().c_str(), item)) { group = (Fl_Group*)w; break; } } flags1 = 0; } // find a matching menu item: Fl_Widget* o = 0; if (replace_flag | find_flag) for (int n = group->children(); n--;) { Fl_Widget* w = group->child(n); if(!w->label().empty() && !compare(w->label().c_str(), item) )// && !w->is_group()) //Finding groups are also allowed! { if (find_flag) return w; o = w; fl_menu_replaced = true; goto REPLACED; } } if (find_flag) return 0; o = append(group, item, flags|flags1); fl_menu_replaced = false; REPLACED: /* fill it in */ o->shortcut(shortcut); if (cb) o->callback(cb); o->user_data(data); relayout(); return o; }