Scheme_Object* spark_fltk_button::fl_button(int argc, Scheme_Object** argv) { DEFAULT_RET_INIT; int x = 0; int y = 0; int w = 0; int h = 0; spark::Utils::int_from_scheme_long(argv[0], x); spark::Utils::int_from_scheme_long(argv[1], y); spark::Utils::int_from_scheme_long(argv[2], w); spark::Utils::int_from_scheme_long(argv[3], h); std::string title; if (argv[4] != scheme_null) { Scheme_Object* str = scheme_char_string_to_byte_string(argv[4]); title = SCHEME_BYTE_STR_VAL(str); } Fl_Button* button = 0; if (argc == 5) button = new Fl_Button(x, y, w, h); else { if (!SCHEME_SYMBOLP(argv[5])) scheme_wrong_type("fl-button", "symbol", 5, argc, argv); std::string s = SCHEME_SYM_VAL(argv[5]); if (s == "check") button = new Fl_Check_Button(x, y, w, h); else if (s == "light") button = new Fl_Light_Button(x, y, w, h); else if (s == "repeat") button = new Fl_Repeat_Button(x, y, w, h); else if (s == "return") button = new Fl_Return_Button(x, y, w, h); else if (s == "radio" || s == "round") button = new Fl_Round_Button(x, y, w, h); else if (s == "toggle") button = new Fl_Toggle_Button(x, y, w, h); else { DEFAULT_RET_FINISH; } } if (title.length() > 0) button->copy_label(title.c_str()); Fltk_tag t = FL_WIDGET_TAG; spark_fltk::Widget* widget = new spark_fltk::Widget; button->argument(reinterpret_cast<long>(widget)); { Scheme_Object* tag = 0; MZ_GC_DECL_REG(1); MZ_GC_VAR_IN_REG(0, tag); MZ_GC_REG(); tag = scheme_make_integer(t); MZ_GC_UNREG(); _ret_ = scheme_make_cptr(button, tag); } DEFAULT_RET_FINISH; }
void Fl_Combo_Box::buttons(int buttons_set) { // Browse button is always shown for (int i = 1; i < 5; i++) { Fl_Button *b = m_buttons[i]; if (buttons_set & b->argument()) b->show(); else b->hide(); } relayout(); }
// ctor initializer - used in both ctors void Fl_Combo_Box::ctor_init() { align(FL_ALIGN_LEFT); style(default_style); layout_spacing(0); end(); m_popup = new Fl_Popup_ListView(this); Fl_Group::begin(); for (int i = 0; i < 5; i++) { Fl_Button *b = new Fl_Combo_Box_Button(this); m_buttons[i] = b; b->layout_align(FL_ALIGN_RIGHT); b->callback(cb_button); b->argument(1 << i); switch (i) { case 0: b->image(browse_pixmap); b->callback(cb_browse); break; case 1: b->image(add_pixmap); break; case 2: b->image(edit_pixmap); break; case 3: b->image(delete_pixmap); break; case 4: b->image(refresh_pixmap); break; } if (i == 0) b->show(); else b->hide(); } m_panel = new Fl_Combo_Box_Panel(this); m_panel->layout_align(FL_ALIGN_CLIENT); Fl_Group::end(); }