fltk::StringList Class Reference

Inherits fltk::StringHierarchy.

Inherited by fltk::StringArray.

List of all members.

Public Member Functions

virtual int children (const Menu *)=0
virtual int children (const Menu *, const int *indexes, int level)
virtual const char * label (const Menu *, int index)=0
virtual const char * label (const Menu *, const int *indexes, int level)


Detailed Description

This is a simplification of StringHierarchy where there are no subitems. It makes the virtual functions easier to write.

Typically you will create a subclass with the children() and label() functions overridden, and make a single static instance of this class. It can be used by several menus, but the Menu* argument to children() and label() is used to differentiate them.

class MyList : public StringList {
  int children(const Menu* menu) {
    return ((MyClass*)(menu->user_data()))->number_of_items();
  }
  const char* label(const Menu* menu, int index) {
    return ((MyClass*)(menu->user_data()))->label(index);
  }
};
static MyList myList;

Menu themenu;
MyClass myobject;
themenu->list(&mylist);
themenu->callback(mycallback, &myobject);

Wed Jun 17 08:53:25 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.