fltk::Item Class Reference

Inherits fltk::Widget.

Inherited by FileItem, fltk::RadioItem, and fltk::ToggleItem.

List of all members.

Public Member Functions

void draw ()
int handle (int)
 Item (const char *label, int shortcut, Callback *callback=0, void *user_data_=0, int flags=0)
 Item (const char *label, const Symbol *)
 Item (const char *label=0)
void layout ()

Static Public Member Functions

static void clear_style ()
static void set_style (const Widget *w, bool f)
static void set_style (const Style *, bool menubar)

Static Public Attributes

static NamedStyledefault_style


Detailed Description

This widget is designed to be put into fltk::Menu and fltk::Browser widgets and draw plain-text items. All events are ignored, thus causing the menu and browser to set/clear the SELECTED flag on these widgets. If they are selected they draw in the selection_color(), otherwise in the color().

Constructor & Destructor Documentation

Item::Item ( const char *  l = 0  ) 

Unlike other widgets the constructor does not take any dimensions, since it is assummed the container widget will size this correctly.

Item::Item ( const char *  l,
const Symbol i 
)

This constructor also sets the image(), useful for a browser item.

Item::Item ( const char *  l,
int  s,
Callback *  cb = 0,
void *  ud = 0,
int  f = 0 
)

This constructor is provided to match the Menu::add() function arguments. See Menu::add() for more details.

References fltk::Widget::set_flag(), and fltk::Widget::shortcut().


Member Function Documentation

void Item::draw ( void   )  [virtual]

void Item::layout (  )  [virtual]

Measure the space the draw() will take and set w() and h(). Maybe this should be the default layout() function for Widget?

Reimplemented from fltk::Widget.

References fltk::ALIGN_LEFT, fltk::ALIGN_RIGHT, fltk::Widget::flag(), fltk::Rectangle::h(), fltk::Symbol::measure(), fltk::measure(), fltk::setfont(), fltk::Widget::type(), and fltk::Rectangle::w().

int Item::handle ( int  event  )  [virtual]

Returns 0 always. Items do not accept any events. Any results of clicking on them is handled by the parent Menu or Browser.

Reimplemented from fltk::Widget.

References fltk::Group::child(), fltk::Group::children(), fltk::event_clicks(), fltk::Widget::parent(), fltk::PUSH, fltk::Widget::state(), and fltk::Widget::type().

void Item::set_style ( const Style style,
bool  menubar 
) [static]

Modify the parent of the Item::default_style to this style. If no style settings have been done to an Item, it will use the textfont, textsize, textcolor, and possibly other settings inherited from this style to draw itself. This is used by menus and browsers to cause all the elements inside them to draw using their settings.

The menubar flag causes it to mangle the style so that the buttonbox of style is used as the box, and the highlight_color is used as the selection_color. This is done to replicate the rather inconsistent appearance on Windows of menubars.

Use Item::clear_style() to put this back so that style can be deleted. This is the same as setting it to Widget::default_style.

References fltk::Style::buttonbox(), fltk::Style::color(), fltk::Style::highlight_color(), fltk::Style::parent_, fltk::Style::selection_color_, and fltk::Style::textcolor().

Referenced by fltk::Choice::draw(), fltk::Menu::draw_in(), fltk::Menu::find_selected(), fltk::Menu::get_location(), and fltk::Menu::layout_in().


Member Data Documentation

The default style sets FLAT_BOX. Changing this will mess up the appearance of both menus and browsers. All the rest of the style is blank, and normally it inherits from the current browser or menu, which should call set_style() before drawing any items.

Reimplemented from fltk::Widget.


Wed Jun 17 08:49:30 2009. FLTK ©2007 Bill Spitzak and others.
Permission is granted to reproduce this manual or any portion for any purpose, provided this copyright and permission notice are preserved.