|
fltk 1.3.0rc3
About: FLTK (Fast Light Tool Kit) is a cross-platform C++ GUI toolkit for UNIX/Linux (X11), Microsoft Windows, and MacOS X. Release candidate.
SfR Fresh Dox: fltk-1.3.0rc3-source.tar.gz ("inofficial" and yet experimental doxygen-generated source code documentation) ![]() |
A button that is used to pop up a menu. More...
#include <Fl_Choice.H>


Public Member Functions | |
| int | handle (int) |
| Fl_Choice (int X, int Y, int W, int H, const char *L=0) | |
| int | value () const |
| int | value (int v) |
| int | value (const Fl_Menu_Item *v) |
Protected Member Functions | |
| void | draw () |
A button that is used to pop up a menu.
This is a button that, when pushed, pops up a menu (or hierarchy of menus) defined by an array of Fl_Menu_Item objects. Motif calls this an OptionButton.
The only difference between this and a Fl_Menu_Button is that the name of the most recent chosen menu item is displayed inside the box, while the label is displayed outside the box. However, since the use of this is most often to control a single variable rather than do individual callbacks, some of the Fl_Menu_Button methods are redescribed here in those terms.
When the user picks an item off the menu the value() is set to that item and then the item's callback is done with the menu_button as the Fl_Widget* argument. If the item does not have a callback the menu_button's callback is done instead.
All three mouse buttons pop up the menu. The Forms behavior of the first two buttons to increment/decrement the choice is not implemented. This could be added with a subclass, however.
The menu will also pop up in response to shortcuts indicated by putting a '&' character in the label(). See Fl_Button::shortcut(int s) for a description of this.
Typing the shortcut() of any of the items will do exactly the same as when you pick the item with the mouse. The '&' character in item names are only looked at when the menu is popped up, however.
int Fl_Widget::changed() const This value is true the user picks a different value. It is turned off by value() and just before doing a callback (the callback can turn it back on if desired). void Fl_Widget::set_changed() This method sets the changed() flag. void Fl_Widget::clear_changed() This method clears the changed() flag. Fl_Boxtype Fl_Choice::down_box() const Gets the current down box, which is used when the menu is popped up. The default down box type is FL_DOWN_BOX. void Fl_Choice::down_box(Fl_Boxtype b) Sets the current down box type to b. Definition at line 85 of file Fl_Choice.H.
| Fl_Choice::Fl_Choice | ( | int | X, |
| int | Y, | ||
| int | W, | ||
| int | H, | ||
| const char * | L = 0 |
||
| ) |
Create a new Fl_Choice widget using the given position, size and label string. The default boxtype is FL_UP_BOX.
The constructor sets menu() to NULL. See Fl_Menu_ for the methods to set or change the menu.
| [in] | X,Y,W,H | position and size of the widget |
| [in] | L | widget label, default is no label |
Definition at line 129 of file Fl_Choice.cxx.
References Fl_Widget::align(), Fl_Widget::box(), Fl_Menu_::down_box(), FL_ALIGN_LEFT, FL_BORDER_BOX, FL_FLAT_BOX, FL_HELVETICA, FL_WHEN_RELEASE, Fl_Menu_::textfont(), and Fl_Widget::when().
| void Fl_Choice::draw | ( | ) | [protected, virtual] |
Draws the widget. Never call this function directly. FLTK will schedule redrawing whenever needed. If your widget must be redrawn as soon as possible, call redraw() instead.
Override this function to draw your own widgets.
If you ever need to call another widget's draw method from within your own draw() method, e.g. for an embedded scrollbar, you can do it (because draw() is virtual) like this:
Fl_Widget *s = &scroll; // scroll is an embedded Fl_Scrollbar s->draw(); // calls Fl_Scrollbar::draw()
Implements Fl_Widget.
Definition at line 37 of file Fl_Choice.cxx.
References Fl_Menu_Item::activate(), Fl_Menu_Item::active(), Fl_Widget::active_r(), Fl_Widget::box(), Fl::box_dx(), Fl::box_dy(), Fl_Label::color, Fl_Widget::color(), Fl_Menu_Item::deactivate(), Fl_Label::deimage, Fl_Menu_Item::draw(), Fl_Label::draw(), Fl_Widget::draw_box(), Fl_Widget::draw_focus(), Fl_Widget::draw_label(), dx, dy, FL_ALIGN_LEFT, FL_BACKGROUND2_COLOR, fl_color(), fl_contrast(), fl_darker(), FL_DOWN_BOX, fl_draw_shortcut, fl_inactive(), fl_lighter(), fl_polygon(), fl_pop_clip(), fl_push_clip(), FL_UP_BOX, fl_yxline(), Fl::focus(), Fl_Label::font, Fl_Widget::h(), H, Fl_Label::image, Fl_Widget::labelcolor(), Fl_Menu_Item::labelcolor_, Fl_Menu_Item::labelfont_, Fl_Menu_Item::labelsize_, Fl_Menu_Item::labeltype_, m, Fl_Menu_::mvalue(), Fl::scheme(), Fl_Label::size, Fl_Menu_Item::text, Fl_Menu_::textcolor(), Fl_Menu_::textfont(), Fl_Menu_::textsize(), Fl_Label::type, Fl_Label::value, Fl_Widget::w(), Fl_Widget::x(), and Fl_Widget::y().
| int Fl_Choice::handle | ( | int | event | ) | [virtual] |
Handles the specified event. You normally don't call this method directly, but instead let FLTK do it when the user interacts with the widget.
When implemented in a widget, this function must return 0 if the widget does not use the event or 1 otherwise.
Most of the time, you want to call the inherited handle() method in your overridden method so that you don't short-circuit events that you don't handle. In this last case you should return the callee retval.
| [in] | event | the kind of event received |
| 0 | if the event was not used or understood |
| 1 | if the event was used and can be deleted |
Reimplemented from Fl_Widget.
Definition at line 164 of file Fl_Choice.cxx.
References Fl_Widget::color(), Fl::event_key(), Fl::event_state(), FL_ALT, FL_BACKGROUND2_COLOR, fl_contrast(), FL_CTRL, FL_ENTER, FL_FOCUS, FL_KEYBOARD, FL_LEAVE, FL_META, FL_PUSH, FL_SHIFT, FL_SHORTCUT, FL_UNFOCUS, Fl::focus(), Fl_Widget::h(), Fl_Menu_::menu(), Fl_Menu_::mvalue(), Fl_Menu_::picked(), Fl_Menu_Item::pulldown(), Fl_Widget::redraw(), Fl::scheme(), Fl_Menu_Item::submenu(), Fl_Menu_Item::test_shortcut(), Fl_Widget::test_shortcut(), Fl_Menu_::text(), Fl_Menu_::textcolor(), Fl::visible_focus(), Fl_Widget::w(), Fl_Widget::x(), and Fl_Widget::y().
| int Fl_Choice::value | ( | int | v | ) |
Sets the currently selected value using the index into the menu item array. Changing the selected value causes a redraw().
| [in] | v | index of value in the menu item array. |
Reimplemented from Fl_Menu_.
Definition at line 156 of file Fl_Choice.cxx.
References Fl_Widget::redraw(), Fl_Menu_::size(), Fl_Menu_::value(), and value().
| int Fl_Choice::value | ( | ) | const [inline] |
Gets the index of the last item chosen by the user. The index is zero initially.
Reimplemented from Fl_Menu_.
Definition at line 97 of file Fl_Choice.H.
References value.
Referenced by align_position_cb(), align_text_image_cb(), box_cb(), down_box_cb(), Fl_File_Chooser::filter(), Fl_File_Chooser::filter_value(), i18n_type_cb(), labelfont_cb(), labeltype_cb(), make_settings_window(), Fl_Color_Chooser::mode(), name_public_cb(), name_public_member_cb(), Fl_DeclBlock_Type::open(), Fl_Data_Type::open(), Fl_Decl_Type::open(), Fl_Function_Type::open(), print_cb(), print_load(), print_update_status(), Fl_File_Chooser::rescan_keep_filename(), scheme_cb(), show_project_cb(), Fl_PostScript_Printer::start_job(), subtype_cb(), textfont_cb(), value(), and when_cb().
| int Fl_Choice::value | ( | const Fl_Menu_Item * | v | ) |
Sets the currently selected value using a pointer to menu item. Changing the selected value causes a redraw().
| [in] | v | pointer to menu item in the menu item array. |
Reimplemented from Fl_Menu_.
Definition at line 144 of file Fl_Choice.cxx.
References Fl_Widget::redraw(), and Fl_Menu_::value().