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; }
gChannel *Keyboard::addChannel(char side, Channel *ch) { Fl_Group *group; gClick *add; if (side == 0) { group = gChannelsL; add = addChannelL; } else { group = gChannelsR; add = addChannelR; } gChannel *gch = NULL; if (ch->type == CHANNEL_SAMPLE) gch = (gSampleChannel*) new gSampleChannel( group->x(), group->y() + group->children() * 24, group->w(), 20, (SampleChannel*) ch); else gch = (gMidiChannel*) new gMidiChannel( group->x(), group->y() + group->children() * 24, group->w(), 20, (MidiChannel*) ch); group->add(gch); group->size(group->w(), group->children() * 24); add->position(group->x(), group->y()+group->h()); fixRightColumn(); redraw(); return gch; }
// 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( 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; }