fltk
1.3.5-source
About: FLTK (Fast Light Tool Kit) is a cross-platform C++ GUI toolkit for UNIX/Linux (X11), Microsoft Windows, and MacOS X.
![]() ![]() |
A button that is used to pop up a menu. More...
#include <Fl_Choice.H>
Protected Member Functions | |
void | draw () |
![]() | |
int | item_pathname_ (char *name, int namelen, const Fl_Menu_Item *finditem, const Fl_Menu_Item *menu=0) const |
![]() | |
Fl_Widget (int x, int y, int w, int h, const char *label=0L) | |
void | x (int v) |
void | y (int v) |
void | w (int v) |
void | h (int v) |
unsigned int | flags () const |
void | set_flag (unsigned int c) |
void | clear_flag (unsigned int c) |
void | draw_box () const |
void | draw_box (Fl_Boxtype t, Fl_Color c) const |
void | draw_box (Fl_Boxtype t, int x, int y, int w, int h, Fl_Color c) const |
void | draw_backdrop () const |
void | draw_focus () |
void | draw_focus (Fl_Boxtype t, int x, int y, int w, int h) const |
void | draw_label () const |
void | draw_label (int, int, int, int) const |
Additional Inherited Members | |
![]() | |
static void | default_callback (Fl_Widget *cb, void *d) |
static unsigned int | label_shortcut (const char *t) |
static int | test_shortcut (const char *, const bool require_alt=false) |
![]() | |
enum | { INACTIVE = 1<<0, INVISIBLE = 1<<1, OUTPUT = 1<<2, NOBORDER = 1<<3, FORCE_POSITION = 1<<4, NON_MODAL = 1<<5, SHORTCUT_LABEL = 1<<6, CHANGED = 1<<7, OVERRIDE = 1<<8, VISIBLE_FOCUS = 1<<9, COPIED_LABEL = 1<<10, CLIP_CHILDREN = 1<<11, MENU_WINDOW = 1<<12, TOOLTIP_WINDOW = 1<<13, MODAL = 1<<14, NO_OVERLAY = 1<<15, GROUP_RELATIVE = 1<<16, COPIED_TOOLTIP = 1<<17, FULLSCREEN = 1<<18, MAC_USE_ACCENTS_MENU = 1<<19, USERFLAG3 = 1<<29, USERFLAG2 = 1<<30, USERFLAG1 = 1<<31 } |
![]() | |
uchar | alloc |
uchar | down_box_ |
Fl_Font | textfont_ |
Fl_Fontsize | textsize_ |
Fl_Color | textcolor_ |
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 clicks a menu item, value() is set to that item and then:
- The item's callback is done if one has been set; the Fl_Choice is passed as the Fl_Widget* argument, along with any userdata configured for the callback. - If the item does not have a callback, the Fl_Choice widget's callback is done instead, along with any userdata configured for it. The callback can determine which item was picked using value(), mvalue(), item_pathname(), etc.
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 83 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 138 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().
|
protectedvirtual |
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:
Implements Fl_Widget.
Definition at line 28 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_Label::draw(), Fl_Menu_Item::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, H, Fl_Widget::h(), Fl_Label::image, Fl::is_scheme(), Fl_Widget::labelcolor(), Fl_Menu_Item::labelcolor_, Fl_Menu_Item::labelfont_, Fl_Menu_Item::labelsize_, Fl_Menu_Item::labeltype_, 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(), Y, and Fl_Widget::y().
|
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 173 of file Fl_Choice.cxx.
References Fl_Widget::color(), Fl_Widget_Tracker::deleted(), 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().
|
inline |
Gets the index of the last item chosen by the user. The index is zero initially.
Definition at line 95 of file Fl_Choice.H.
References Fl_Menu_::value().
Referenced by align_position_cb(), align_text_image_cb(), box_cb(), cb_Save(), cb_wArrowFocus(), cb_wDNDText(), cb_wGTKText(), cb_wShowTooltips(), cb_wVisibleFocus(), 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_Function_Type::open(), Fl_Decl_Type::open(), Fl_Data_Type::open(), Fl_DeclBlock_Type::open(), print_load(), print_update_status(), refreshUI(), scheme_cb(), show_project_cb(), Fl_File_Chooser::showChoiceCB(), 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. |
Definition at line 153 of file Fl_Choice.cxx.
References Fl_Widget::redraw(), and Fl_Menu_::value().
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. |
Definition at line 165 of file Fl_Choice.cxx.
References Fl_Widget::redraw(), Fl_Menu_::size(), value(), and Fl_Menu_::value().