void onelabGroup::updateParameter(onelab::string &p) { Fl_Tree_Item *n = _tree->find_item(p.getName().c_str()); if(!n) { addParameter(p); return; } Fl_Group *grp = (Fl_Group *)n->widget(); // macro button if(p.getAttribute("Macro") == "Gmsh"){ return; } // non-editable value FIXME if(p.getReadOnly()){ Fl_Output *but = (Fl_Output *)grp->child(0); but->value(p.getValue().c_str()); return; } // simple string (no menu) if(p.getChoices().empty() && p.getKind() != "file"){ Fl_Input *but = (Fl_Input *)grp->child(0); but->value(p.getValue().c_str()); return; } // general string input TODO Fl_Input_Choice *but = (Fl_Input_Choice *)grp->child(0); but->value(p.getValue().c_str()); }
void onelabGroup::updateParameter(onelab::number &p) { Fl_Tree_Item *n = _tree->find_item(p.getName().c_str()); if(!n) { addParameter(p); return; } Fl_Group *grp = (Fl_Group *)n->widget(); // enumeration (display choices as value labels, not numbers) if(p.getChoices().size() && p.getChoices().size() == p.getValueLabels().size()){ Fl_Choice *but = (Fl_Choice *)grp->child(0); //std::vector<Fl_Menu_Item> menu; //std::map<double, std::string> labels(p.getValueLabels()); //for(std::map<double, std::string>::iterator it = labels.begin(); // it != labels.end(); it++){ // char *str = strdup(it->second.c_str()); // _treeStrings.push_back(str); // Fl_Menu_Item menuItem = {str, 0, 0, 0, 0}; // if(highlight) menuItem.labelcolor(c); // menu.push_back(menuItem); //} //Fl_Menu_Item it = {0}; //menu.push_back(it); //but->copy(&menu[0]); for(unsigned int i = 0; i < p.getChoices().size(); i++){ if(p.getValue() == p.getChoices()[i]){ but->value(i); break; } } return; } // check box (boolean choice) if(p.getChoices().size() == 2 && p.getChoices()[0] == 0 && p.getChoices()[1] == 1){ Fl_Check_Button *but = (Fl_Check_Button *)grp->child(0); but->value(p.getValue()); return; } // non-editable value FIXME if(p.getReadOnly()){ outputRange *but = (outputRange *)grp->child(0);; but->value(p.getValue()); but->graph(p.getAttribute("Graph")); return; } // general number input inputRange *but = (inputRange *)grp->child(0); but->value(p.getValue()); but->minimum(p.getMin()); but->maximum(p.getMax()); but->step(p.getStep()); but->choices(p.getChoices()); but->loop(p.getAttribute("Loop")); but->graph(p.getAttribute("Graph")); }
void Keyboard::updateChannels(char side) { Fl_Group *group; gClick *add; if (side == 0) { group = gChannelsL; add = addChannelL; } else { group = gChannelsR; add = addChannelR; } //printf("[keyboard::updateChannels] side %d has %d widgets\n", side, group->children()); for (int i=0; i<group->children(); i++) { gChannel *gch = (gChannel*) group->child(i); gch->position(gch->x(), group->y()+(i*24)); } group->size(group->w(), group->children()*24); add->position(add->x(), group->y()+group->h()); redraw(); }
Scheme_Object* spark_fltk_group::child(int argc, Scheme_Object** argv) { DEFAULT_RET_INIT; Fl_Group* group = _get_fl_group(argc, argv, 0); if (group) { int i = 0; if (spark::Utils::int_from_scheme_long(argv[1], i)) { if (i < 0 || i >= group->children()) { DEFAULT_RET_FINISH; } Fl_Widget* w = group->child(i); if (w) { Scheme_Object* tag = 0; MZ_GC_DECL_REG(1); MZ_GC_VAR_IN_REG(0, tag); MZ_GC_REG(); tag = scheme_make_integer(FL_WIDGET_TAG); _ret_ = scheme_make_cptr(w, tag); MZ_GC_UNREG(); } } } DEFAULT_RET_FINISH; }
viewButton *onelabGroup::getViewButton(int num) { char tmp[256]; sprintf(tmp, "0Post-processing/View%d", num); Fl_Tree_Item *n = _tree->find_item(tmp); if(n){ Fl_Group *grp = (Fl_Group*)n->widget(); return (viewButton*)grp->child(0); } return 0; }
void FolderWindow::RemoveCallback(Fl_Widget* widget, void* userData) { FolderWindow* fwindow = (FolderWindow*)(widget->parent()->parent()->parent()->parent()); Fl_Pack* pack = fwindow->folderPack; for(int i = 0; i < pack->children(); ++i) { Fl_Group* tempGroup = (Fl_Group*)pack->child(i); Fl_Button* childButton = (Fl_Button*)tempGroup->child(1); // <--- here if (childButton == widget) { RNAStructViz* appInstance = RNAStructViz::GetInstance(); const std::vector<DiagramWindow*>& diagrams = appInstance->GetDiagramWindows(); for (unsigned int ui = 0; ui < diagrams.size(); ++ui) { if(diagrams[ui]->GetFolderIndex() == fwindow->m_folderIndex) { diagrams[ui]->RemoveStructure((intptr_t)userData); break; } } const std::vector<StatsWindow*>& stats = appInstance->GetStatsWindows(); for (unsigned int ui = 0; ui < stats.size(); ++ui) { if(stats[ui]->GetFolderIndex() == fwindow->m_folderIndex) { stats[ui]->RemoveStructure((intptr_t)userData); break; } } Fl_Group* toRemove = (Fl_Group*)pack->child(i); // <--- here pack->remove(toRemove); fwindow->folderScroll->redraw(); Fl::delete_widget(toRemove); appInstance->GetStructureManager()->DecreaseStructCount( fwindow->m_folderIndex); appInstance->GetStructureManager()->RemoveStructure((intptr_t)userData); break; } } }
// callback for header buttons void header_callback(Fl_Widget*w, void*) { Fl_Group* heading = (Fl_Group*)w->parent(); EDE_Browser* browser = (EDE_Browser*)w->parent()->parent(); for (int i=heading->children(); i--; ) if (w == heading->child(i)) { browser->sort(i); break; } }
static void joy_handler( void * UNUSED( user_arg ) ) { MMRESULT result; JOYINFOEX joyinfo; int i; signed int joy[4]; signed int rollA, pitchA, collA, yawA; joyinfo.dwSize=sizeof(joyinfo); joyinfo.dwFlags=JOY_RETURNALL; result=joyGetPosEx(joystickID, &joyinfo); if( result != JOYERR_NOERROR ) { gui->joy_status->value( 0 ); return; } /* need WIN32 equivalent for this log statement */ /* if(0) cout << ( e.type & JS_EVENT_AXIS ? "axis: " : e.type & JS_EVENT_BUTTON ? "button: " : "UNKNOWN" ) << int(e.number) << "=" << e.value << endl; */ if(0) { cout<< "axis: "<< "X"<< "="<< joyinfo.dwXpos<< endl; cout<<"axis: Y="<<joyinfo.dwYpos<<endl; cout<<"axis: Z="<<joyinfo.dwZpos<<endl; cout<<"axis: R="<<joyinfo.dwRpos<<endl; } joy[0]=(signed int) joyinfo.dwXpos - 32000; joy[1]=(signed int) joyinfo.dwYpos - 32000; joy[2]=(signed int) joyinfo.dwZpos - 32000; joy[3]=(signed int) joyinfo.dwRpos - 32000; rollA=(int)gui->rollAxes->value(); pitchA=(int)gui->pitchAxes->value(); collA=(int)gui->collAxes->value(); yawA=(int)gui->yawAxes->value(); joy_roll=joy[rollA]; joy_pitch=joy[pitchA]; joy_yaw=joy[yawA]; joy_throttle=joy[collA]; handle_axis(0,joy_roll); // roll handle_axis(1,joy_pitch); // pitch handle_axis(2,joy_throttle); // coll handle_axis(3,joy_yaw); // yaw gui->rollSlider->value(joy[0]); gui->pitchSlider->value(joy[1]); gui->collSlider->value(joy[2]); gui->yawSlider->value(joy[3]); if( joyinfo.dwFlags & JOY_RETURNBUTTONS ) { for (i=0; i <= 6; ++i) { Fl_Group *g = gui->buttons; Fl_Button *b = (Fl_Button*) g->child( i ); if (joyinfo.dwButtons & JOY_BUTTON_FLAG(i) ) b->value( 1 ); else b->value( 0 ); joy_button[i] = joyinfo.dwButtons & JOY_BUTTON_FLAG(i) ; } } Fl::add_timeout(.01,joy_handler); return; }
static void joy_handler( int fd, void * UNUSED( user_arg ) ) { struct js_event e; int rc; rc = joydev_event( fd, &e, 0 ); if( rc < 0 ) { Fl::remove_fd( fd ); close( fd ); gui->joy_status->value( 0 ); return; } if( rc == 0 ) return; if(0) cout << ( e.type & JS_EVENT_AXIS ? "axis: " : e.type & JS_EVENT_BUTTON ? "button: " : "UNKNOWN" ) << int(e.number) << "=" << e.value << endl; const int num = e.number; const int value = e.value; if( e.type & JS_EVENT_AXIS ) { if(0) cout << "axis: " << num << "=" << value << endl; Fl_Group *g = gui->axes; if( num >= g->children() ) return; Fl_Valuator *a = (Fl_Valuator*) g->child( num ); a->value( value ); /* * This should have a config file of some sort. * Convert to the right hand rule. */ switch( num ) { case 0: joy_roll = value; break; case 1: joy_pitch = value; break; case 2: joy_yaw = value; break; case 3: joy_throttle = 16890 - value; break; default: /* Do nothing */ break; } return; } if( e.type & JS_EVENT_BUTTON ) { Fl_Group *g = gui->buttons; if( e.number >= g->children() ) return; Fl_Button *b = (Fl_Button*) g->child( e.number ); b->value( e.value ); joy_button[e.number] = e.value; return; } }
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; }