ManageTextureScreen::ManageTextureScreen( ScreenMgr * mgr ) : VspScreen( mgr ) { m_TextureMgrUI = new TextureMgrUI(); m_FLTK_Window = m_TextureMgrUI->UIWindow; m_TextureMgrUI->UIWindow->position( 775, 50 ); m_UPosSlider.Init( this, m_TextureMgrUI->uPosSlider, m_TextureMgrUI->uPosInput, 1, "%6.5f", (VspButton*) m_TextureMgrUI->uPosButton ); m_WPosSlider.Init( this, m_TextureMgrUI->wPosSlider, m_TextureMgrUI->wPosInput, 1, "%6.5f", (VspButton*) m_TextureMgrUI->wPosButton ); m_UScaleSlider.Init( this, m_TextureMgrUI->uScaleSlider, m_TextureMgrUI->uScaleInput, 1, "%6.5f", (VspButton*) m_TextureMgrUI->uScaleButton ); m_WScaleSlider.Init( this, m_TextureMgrUI->wScaleSlider, m_TextureMgrUI->wScaleInput, 1, "%6.5f", (VspButton*) m_TextureMgrUI->wScaleButton ); m_TransparencySlider.Init( this, m_TextureMgrUI->alphaSlider, m_TextureMgrUI->alphaInput, 1, "%6.5f", (VspButton*) m_TextureMgrUI->alphaButton ); m_FlipUButton.Init( this, m_TextureMgrUI->flipUButton ); m_FlipWButton.Init( this, m_TextureMgrUI->flipWButton ); m_TextureMgrUI->compChoice->callback( staticCB, this ); m_TextureMgrUI->textureChoice->callback( staticCB, this ); m_TextureMgrUI->textureNameInput->callback( staticCB, this ); m_TextureMgrUI->addTextureButton->callback( staticCB, this ); m_TextureMgrUI->delTextureButton->callback( staticCB, this ); // Add GL 2D Window. Fl_Widget * w = m_TextureMgrUI->texGLGroup; m_TextureMgrUI->texGLGroup->begin(); m_GlWin = new VSPGUI::VspSubGlWindow( w->x(), w->y(), w->w(), w->h(), DrawObj::VSP_TEX_PREVIEW ); m_TextureMgrUI->texGLGroup->end(); ResetCurrentSelected(); }
void Track::draw ( void ) { fl_push_clip( x(), y(), w(), h() ); Fl_Color saved_color = color(); if ( ! Track::colored_tracks ) color( FL_GRAY ); if ( _selected ) { Fl_Color c = color(); color( FL_RED ); Fl_Group::draw(); color( c ); } else Fl_Group::draw(); if ( ((Track_Header*)child(0))->input_connector_handle == receptive_to_drop ) { Fl_Widget *o = ((Track_Header*)child(0))->input_connector_handle; fl_draw_box( FL_OVAL_BOX, o->x(), o->y(), o->w(), o->h(), fl_color_add_alpha( FL_GREEN, 127 ) ); } if ( ! Track::colored_tracks ) color( saved_color ); fl_pop_clip(); }
void cairo_box::draw(void) { // using fltk functions, set up white background with thin black frame //fl_color(FL_WHITE); //fl_rectf(x(), y(), w(), h()); draw_box(); // Rahmen außenrum? #if 0 fl_color(FL_BLACK); fl_rect(x(), y(), w(), h()); #endif //fl_push_clip(100,100,100,100); //fl_color(FL_BLACK); //fl_line(1,1,parent()->w(),parent()->h()); // set up cairo structures Fl_Widget *p = this; while (p->parent ()) p = p->parent (); //printf ("p=%p\n", p); surface = set_surface(p->w(), p->h()); cr = cairo_create(surface); cairo_set_source_rgb (cr, 0.0, 0.0, 0.0); // set drawing color to black cairo_new_path(cr); //printf ("x()=%i, y()=%i, w()=%i, h()=%i\n", x(), y(), w(), h()); cairo_draw (); // release the cairo context cairo_destroy(cr); cairo_surface_destroy(surface); }
int main(int argc, char **argv) { if (argc > 1) srand(atoi(argv[1])); Fl_Window window(WIDTH,HEIGHT,argv[0]); window.end(); // don't auto-add children for (int i = 0; i<10000; i++) { // make up a random size of widget: int x = rand()%(WIDTH/GRID+1) * GRID; int y = rand()%(HEIGHT/GRID+1) * GRID; int w = rand()%(WIDTH/GRID+1) * GRID; if (w < x) {w = x-w; x-=w;} else {w = w-x;} int h = rand()%(HEIGHT/GRID+1) * GRID; if (h < y) {h = y-h; y-=h;} else {h = h-y;} if (w < GRID || h < GRID || w < h) continue; // find where to insert it and see if it intersects something: Fl_Widget *j = 0; int n; for (n=0; n < window.children(); n++) { Fl_Widget *o = window.child(n); if (x<o->x()+o->w() && x+w>o->x() && y<o->y()+o->h() && y+h>o->y()) break; if (!j && (y < o->y() || y == o->y() && x < o->x())) j = o; } // skip if intersection: if (n < window.children()) continue; window.insert(*(new Fl_Input(x,y,w,h)),j); } window.resizable(window); window.show(); return Fl::run(); }
static Fl_Widget* append( Fl_Group* g, const char *text, int flags ) { Fl_Group* saved = Fl_Group::current(); Fl_Group::current(0); Fl_Widget* o; if (flags & FL_SUBMENU) { o = new Fl_Item_Group(); if(flags&FL_MENU_RIGHTLAYOUT) ((Fl_Menu_Bar *)g)->right_layout(o); Fl_Group::current(0); } else { o = new Fl_Item(); } o->copy_label(text); if (flags & FL_MENU_RADIO) o->type(Fl_Item::RADIO); else if (flags & FL_MENU_TOGGLE) o->type(Fl_Item::TOGGLE); // these flags have been cleverly assigned so this shift and mask // converts from the old values to the new ones: o->set_flag((flags<<12)&(FL_INACTIVE|FL_VALUE|FL_INVISIBLE)); if (insert_here) {g->insert(*o, insert_here-1); insert_here = 0;} else g->add(o); if (flags & FL_MENU_DIVIDER) g->add(new Fl_Divider()); Fl_Group::current(saved); return o; }
static void add_from_list(WidgetList &lst, Panel *self, int &X, bool inc) { WidgetListIt it = lst.begin(), ite = lst.end(); Fl_Widget *o; while(it != ite) { o = *it; /* 'inc == false' means we are going from right to left */ if(!inc) X -= o->w(); /* place it correctly */ o->position(X, o->y()); self->add(o); if(inc) { X += DEFAULT_SPACING; X += o->w(); } else { X -= DEFAULT_SPACING; } it = lst.erase(it); } }
void Abstract_Widget::del() { //if (_del) // return; //_del = true; //DJV_DEBUG(String_Format("Abstract_Widget::del(%%)"). // arg(layout_item::debug_path(this))); Callback::del(); _layout.reset(); Fl_Widget * widget = dynamic_cast<Fl_Widget *>(this); DJV_ASSERT(widget); if (widget->parent()) { //DJV_DEBUG_PRINT("fltk remove"); widget->parent()->remove(widget); widget->parent(0); } Fl::delete_widget(widget); DJV_APP->widget_del(this); }
void Taskbar::layout_children(void) { if(!children()) return; Fl_Widget *o; int X = x() + Fl::box_dx(box()); int Y = y() + Fl::box_dy(box()); int W = w() - Fl::box_dw(box()); int child_w = DEFAULT_CHILD_W; int sz = children(); int all_buttons_w = 0; /* figure out the bounds */ for(int i = 0; i < sz; i++) all_buttons_w += child(i)->w() + DEFAULT_SPACING; if(all_buttons_w > W) { int reduce = (all_buttons_w - W) / sz; child_w -= reduce; } /* now, position each child and resize it if needed */ for(int i = 0; i < sz; i++) { o = child(i); o->resize(X, Y, child_w, o->h()); X += o->w() + DEFAULT_SPACING; } }
void update() { int rot_val = (int)rot->value(); int scale_val = (int)scale->value(); for (int i = window->children(); i--; ) { // all window children Fl_Widget *wc = window->child(i); if(wc==scale||wc==rot) continue; Fl_String str("@"); if(scale_val>0) { str+="+"+Fl_String(scale_val); } else if(scale_val<0) { str+=Fl_String(scale_val); } if(rot_val>0) { str+=Fl_String(rot_val); } str+=(char*)wc->user_data(); wc->copy_label(str.c_str()); } window->redraw(); }
void Fl_TooltipBox::layout() { fl_font(label_font(), label_size()); int ww, hh; ww = MAX_WIDTH; fl_measure(tip, ww, hh, FL_ALIGN_LEFT|FL_ALIGN_WRAP|FL_ALIGN_INSIDE); ww += 6; hh += 6; // find position on the screen of the widget: int ox = Fl::event_x_root(); //int ox = X+W/2; int oy = Y + H+2; for (Fl_Widget* p = widget; p; p = p->parent()) { //ox += p->x(); oy += p->y(); } if (ox+ww > Fl::w()) ox = Fl::w() - ww; if (ox < 0) ox = 0; if (H > 30) { oy = Fl::event_y_root()+13; if (oy+hh > Fl::h()) oy -= 23+hh; } else { if (oy+hh > Fl::h()) oy -= (4+hh+H); } if (oy < 0) oy = 0; resize(ox, oy, ww, hh); Fl_Menu_Window::layout(); }
void onelabGroup::addParameter(onelab::parameter &p) { if(!p.getVisible() || CTX::instance()->solver.showInvisibleParameters) return; bool highlight = false; Fl_Color c; if(getFlColor(p.getAttribute("Highlight"), c)) highlight = true; Fl_Tree_Item *n = _tree->add(p.getName().c_str()); if(!n) return; n->labelsize(FL_NORMAL_SIZE + 4); _tree->begin(); int ww = _baseWidth - (n->depth() + 1) * _indent; ww *= _widgetLabelRatio; // FIXME CHANGE THIS int hh = n->labelsize() + 4; Fl_Group *grp = new Fl_Group(1, 1, ww, hh); Fl_Widget *widget = _addParameterWidget(p, ww, hh, n, highlight, c); grp->end(); if(!_enableTreeWidgetResize) grp->resizable(0); _treeWidgets.push_back(grp); widget->copy_label(p.getShortName().c_str()); std::string help = p.getLabel().size() ? p.getLabel() : p.getShortName(); if(p.getHelp().size()) help += ":\n" + p.getHelp(); widget->copy_tooltip(help.c_str()); n->widget(grp); _tree->end(); if(p.getAttribute("Closed") == "1" && p.getPath().size()) _tree->close(p.getPath().c_str(), 0); _tree->redraw(); }
void TaskBar::update_active(Window active) { for(int n=0; n<children(); n++) { Fl_Widget *w = child(n); Window win = w->argument(); if(GetState(win) == IconicState) w->label_color(fl_inactive(FL_BLACK)); else w->label_color(Fl_Button::default_style->label_color); if(active==win) { TaskBar::active = win; w->set_value(); w->color(fl_lighter(Fl_Button::default_style->color)); w->highlight_color(fl_lighter(Fl_Button::default_style->color)); } else { w->clear_value(); w->color(Fl_Button::default_style->color); w->highlight_color(Fl_Button::default_style->highlight_color); } } redraw(); }
//---------------------------------------------------- // Constructor. Creates all of the widgets. // Add new widgets here //---------------------------------------------------- JetpackUI::JetpackUI() { // Initialize sprites = new Sprites(); animating = false; level_cache = NULL; // Create the main window m_mainWindow = new Fl_Double_Window(DEFAULT_WIDTH, DEFAULT_HEIGHT, "Jetpack"); m_mainWindow->user_data((void*)(this)); // record self to be used by static callback functions // install menu bar m_menubar_editor = new Fl_Menu_Bar(0, 0, DEFAULT_WIDTH, DEFAULT_MARGIN); m_menubar_editor->menu(menuitems_e); m_menubar_gamePlay = new Fl_Menu_Bar(0, 0, DEFAULT_WIDTH, DEFAULT_MARGIN); m_menubar_gamePlay->menu(menuitems_g); m_menubar_gamePlay->hide(); m_menubar_editor->show(); Fl_Group* group_f = new Fl_Group(0, DEFAULT_MARGIN, DEFAULT_WIDTH, DEFAULT_HEIGHT); LoadingMenu *loader = new LoadingMenu(0, 0, DEFAULT_WIDTH, DEFAULT_HEIGHT, "Load Level", this); group_f->end(); group_f->hide(); Fl_Group* group_h = new Fl_Group(0, DEFAULT_MARGIN, DEFAULT_WIDTH, DEFAULT_HEIGHT); SavingMenu *saver = new SavingMenu(0, 0, DEFAULT_WIDTH, DEFAULT_HEIGHT, "Save Level", this); group_h->end(); group_h->hide(); Fl_Group* group_g = new Fl_Group(0, DEFAULT_MARGIN, DEFAULT_WIDTH, DEFAULT_HEIGHT); // install editor view window Maestro *game = new Maestro(0, DEFAULT_MARGIN, DEFAULT_WIDTH, DEFAULT_HEIGHT - DEFAULT_MARGIN, this, ""); group_g->end(); group_g->hide(); Fl_Group* group_e = new Fl_Group(0, DEFAULT_MARGIN, DEFAULT_WIDTH, DEFAULT_HEIGHT); // install gameplay view window Editor *editor = new Editor(0, DEFAULT_MARGIN, DEFAULT_WIDTH, DEFAULT_HEIGHT - DEFAULT_MARGIN, ""); editor->m_UI = this; group_e->end(); //group_e->hide(); m_mainWindow->end(); //// Set dimensions m_nPaintWidth = m_nWidth = DEFAULT_WIDTH; m_nPaintHeight = m_nHeight = DEFAULT_HEIGHT - DEFAULT_MARGIN; m_editor_group = group_e; m_gamePlay_group = group_g; m_load_group = group_f; m_save_group = group_h; m_editor = editor; m_gamePlay = game; m_loader = loader; m_saver = saver; m_current = editor; m_mainWindow->iconize(); // IMPORTANT startAnimating(); Fl_Widget * icon = fl_message_icon(); icon->hide(); }
void gLiquidScroll::resize(int X, int Y, int W, int H) { int nc = children()-2; // skip hscrollbar and vscrollbar for ( int t=0; t<nc; t++) { // tell children to resize to our new width Fl_Widget *c = child(t); c->resize(c->x(), c->y(), W-24, c->h()); // W-24: leave room for scrollbar } init_sizes(); // tell scroll children changed in size Fl_Scroll::resize(X,Y,W,H); }
void JACK_Module::draw ( void ) { Module::draw(); if ( this == receptive_to_drop ) { Fl_Widget *o = input_connection_handle; fl_draw_box( FL_OVAL_BOX, o->x(), o->y(), o->w(), o->h(), fl_color_add_alpha( FL_GREEN, 127 ) ); } }
void Fl_Button::setonly() // set this radio button on, turn others off { set(); for (int i = parent()->children(); i--;) { Fl_Widget* o = parent()->child(i); if (o != this && o->type() == RADIO) ((Fl_Button*)o)->clear(); } }
int global_y( Fl_Widget *w ) { int y = Fl::y()+w->y(); Fl_Widget *o = w->parent(); while( o ) { if( o->type() >= FL_WINDOW ) y += o->y(); o = o->parent(); } return y; }
int global_x( Fl_Widget *w ) { int x = Fl::x()+w->x(); Fl_Widget *o = w->parent(); while( o ) { if( o->type() >= FL_WINDOW ) x += o->x(); o = o->parent(); } return x; }
// Callback for when horizontal/vertical are changed: void type_cb(Fl_Light_Button*, long v) { pack->type(uchar(v)); // Resize the widgets to small squares so the pack will resize them // to strips that are 25 wide: for (int i = 0; i < pack->children(); i++) { Fl_Widget* o = pack->child(i); o->resize(0,0,25,25); } // Resize the pack to fit into the scroll box: pack->resize(0, 0, scroll->w()-scroll->scrollbar.w(), scroll->h()-scroll->hscrollbar.h()); }
void OnRenameCommunity(Fl_Widget* pWidget,void * pParam) { Fl_Tabs* pTab = (Fl_Tabs*)(pParam); const char * scName=fl_input("Enter a new name", ""); if(scName==NULL) return ; char * sName = new char[strlen(scName)*2]; strcpy(sName,scName); Fl_Widget* pW = (Fl_Widget*)pTab->value(); pW->label(scName); }
void PanelMenu::calculate_height() { Fl_Style *s = Fl_Style::find("Menu"); Height = s->box->dh(); for(int n=0; n<children(); n++) { Fl_Widget *i = child(n); if(!i) break; if(!i->visible()) continue; fl_font(i->label_font(), i->label_size()); Height += i->height()+s->leading; } }
void MenuTooltip::current(Fl_Widget* w) { MenuTooltip::exit_(0); // find the enclosing group with a tooltip: Fl_Widget* tw = w; for (;;) { if (!tw) return; if (tw->tooltip()) break; tw = tw->parent(); } // act just like Fl_Tooltip::enter_() except we can remember a zero: widget_ = w; }
int calculate_height(Fl_Menu_ *m) { Fl_Style *s = Fl_Style::find("Menu"); int Height = s->box->dh(); for(int n=0; n<m->children(); n++) { Fl_Widget *i = m->child(n); if(!i) break; if(!i->visible()) continue; fl_font(i->label_font(), i->label_size()); Height += i->height()+s->leading; } return Height; }
void Put_Loaded_Bank () { int k = 0; for (int t = 0; t < gui.ob->children (); t++) { Fl_Widget *w = gui.ob->child (t); w->copy_label (Banco[k].Name); k++; } }
inline void Fl_Canvas::cb_OnDrag_i (Fl_Widget* widget, int xoffset, int yoffset) { if ((widget) && (widget->parent())) { int moved_device_id = ((Fl_DeviceGUI*)(widget->parent()))->GetID(); if (m_HaveSelection) { if (m_Selection.m_DeviceIds.size() <= 0) m_HaveSelection = false; for (unsigned int i=0; i<m_Selection.m_DeviceIds.size(); i++) { int ID = Selection().m_DeviceIds[i]; Fl_Widget *o = FindDevice(ID); if ((o) && (m_Selection.m_DeviceIds[i] != moved_device_id)) { o->position (o->x() + xoffset, o->y() + yoffset); } } } } return; }
void preset_click (Fl_Button * o, void *) { int ok; char temp2[128]; long long kk = (long long) o->user_data (); int num = (int) kk; int tecla = Fl::event_key (); if (Fl::event_button () == 3) { Fl_Widget *w = gui.ob->child (num); if (strlen (Banco[num].Name) > 0) { Fl_Widget *m = fl_message_icon (); m->parent ()->copy_label ("goomf"); sprintf (temp2, "Overwrite? \"%s\"", w->label ()); ok = fl_choice (temp2, "No", "Yes", NULL); if (!ok) return; } strcpy (Name, gui.Pname->value ()); preset_to_bank (num); w->copy_label (gui.Pname->value ()); Haz_laristra (); Send_laristra (); } if ((Fl::event_button () == 1) || tecla == 32) { gui.PresetSelect->value (num); Put_Combi (num); gui.ready = 2; } }
void Fl_Tool_Bar::cb_menu(Fl_Widget *w, void *data) { Fl_Menu_Button *m = (Fl_Menu_Button *)w; Fl_Widget *item = m->item(); if (item && item->user_data()) { Fl_Widget *toolw = (Fl_Widget *)item->user_data(); if(item->value()) toolw->set_value(); else toolw->clear_value(); toolw->do_callback(); } }
static void tt_enter(Fl_Widget* widget) { // find the enclosing group with a tooltip: Fl_Widget* w = widget; while (w && !w->tooltip()) { //if (w == window) return; // don't do anything if pointed at tooltip w = w->parent(); } if (!w) { Fl_Tooltip::enter_area(0, 0, 0, 0, 0, 0); } else { Fl_Tooltip::enter_area(widget,0,0,widget->w(), widget->h(), w->tooltip()); } }
void Fl_Tool_Bar::preferred_size(int &w, int &h) const { if(opened()) { int H=0; for(int n=0; n<children(); n++) { Fl_Widget *w = child(n); if(w==m_menu || w==m_menubut || w==m_right) continue; int ww = w->w(); int wh = 0; w->preferred_size(ww, wh); if(wh > H) H = wh; } H += layout_spacing()*2 + box()->dh(); h = H; } else { h = glyph_size(); } }
void ComboBrowser::browser_cb(Fl_Widget *w, void *data) { // we get callbacks for all keys? if(Fl::event_key() != FL_Enter && Fl::event_key() != ' ') return; ComboBrowser *br = (ComboBrowser *)w; Fl_Input_Browser *combo = (Fl_Input_Browser *)data; Fl_Widget *item = br->item(); if(!item) return; if (item->is_group()) return; // can't select a group! combo->item(item); combo->value(item->label().c_str()); combo->redraw(FL_DAMAGE_VALUE); combo->hide_popup(); combo->do_callback(); }