Laxkit
0.0.7.1
|
Node type for MenuInfo. More...
Public Member Functions | |
MenuItem (const char *newitem, int nid, unsigned int nstate, int ninfo, MenuInfo *nsub, int sublocal) | |
Item constructor, straight copy of all fields. | |
MenuItem (LaxImage *img=NULL) | |
MenuItem (const char *newitem, const char *img, int nid, unsigned int nstate, int ninfo, MenuInfo *nsub, int sublocal) | |
Image file img is loaded, so it has a count of 1 after the constructor. | |
MenuItem (const char *newitem, LaxImage *img, int nid, unsigned int nstate, int ninfo, MenuInfo *nsub, int sublocal) | |
img pointer is transfered. Its count is not incremented. | |
virtual | ~MenuItem () |
Destructor, deletes name and if subislocal!=0, also deletes submenu. | |
virtual MenuInfo * | GetSubmenu (int create=0) |
Return the submenu, if it exists. | |
virtual MenuInfo * | CreateSubmenu (const char *ntitle) |
Create a new submenu if one does not exist already. | |
virtual int | AddDetail (MenuItem *detail) |
Install detail to end of nextdetail list. | |
virtual void | SetState (unsigned newstate, int on) |
virtual const char * | GetString (int detail) |
virtual int | isSelected (int oron=1) |
virtual int | hasSub () const |
virtual int | isOpen () const |
virtual int | hidden () |
Return 1 for definitely hidden. 2 for hidden, except a child is a search hit. | |
virtual int | hasParent (MenuInfo *menuinfo) |
virtual int | hasParent (MenuItem *menuitem) |
Public Member Functions inherited from Laxkit::anObject | |
anObject () | |
Set object_id=getUniqueNumber(). | |
virtual | ~anObject () |
Empty virtual destructor. | |
virtual const char * | whattype () |
Returns the type of anObject. | |
virtual anObject * | duplicate (anObject *ref=NULL) |
virtual int | inc_count () |
Increment the data's count by 1. Returns count. | |
virtual int | dec_count () |
Decrement the count of the data, deleting if count is less than or equal to 0. | |
virtual int | the_count () |
Public Attributes | |
char * | name |
LaxImage * | image |
int | formathint |
int | id |
int | info |
Extra info, which is unused by either MenuItem or MenuInfo themselves. | |
unsigned int | state |
Holds various state of the item, like if a menu is open, etc. | |
int | x |
int | y |
int | w |
int | h |
MenuItem * | nextdetail |
MenuInfo * | parent |
Public Attributes inherited from Laxkit::anObject | |
int | suppress_debug |
DeleteRefCountedFunc | deleteMe |
Called when the count is decremented to 0. | |
unsigned long | object_id |
char * | object_idstr |
Protected Member Functions | |
void | base_init () |
void | base_init (const char *newitem, int nid, unsigned int nstate, int ninfo, MenuInfo *nsub, int sublocal) |
Protected Attributes | |
MenuInfo * | submenu |
int | subislocal |
Nonzero if submenu should be deleted from the destructor. | |
Protected Attributes inherited from Laxkit::anObject | |
int | _count |
The reference count of the object. |
Node type for MenuInfo.
Holds an item name, an id, extra info, state, and sub MenuInfo.
The state variable is some combination of the following (defined in lax/laxdefs.h):
Laxkit::MenuItem::MenuItem | ( | LaxImage * | img = NULL | ) |
img's count is incremented.
References Laxkit::anObject::inc_count().
Create a new submenu if one does not exist already.
Return the current submenu if it does exist. If it does exist already, ntitle is ignored.
The state variable is or'd with MENU_HAS_SUBMENU.
The default here is to create a new submenu that is local, that is, it will be deleted in the destructor. FileMenuItem, for instance, creates a submenu with that directory's contents only when it really needs to.
Reimplemented in Laxkit::FileMenuItem.
Return the submenu, if it exists.
Default is to call CreateSubmenu(NULL) if the item is tagged as having a submenu and create!=0.
Derived classes would redefine CreateSubmenu() so that if an item is tagged as having a submenu, but the submenu is not yet defined, then it is created here only if create!=0. It should not have to always create, since that might slow down various searching mechanisms in MenuInfo, for instance ***.
If there is a potential submenu available, then state must have MENU_HAS_SUBMENU set.
Reimplemented in Laxkit::FileMenuItem.
Referenced by Laxkit::PopupMenu::addselect(), Laxkit::TreeSelector::addToCache(), Laxkit::TreeSelector::DrawItems(), Laxkit::MenuInfo::findFromLine(), Laxkit::MenuInfo::findid(), Laxkit::MenuInfo::findLine(), Laxkit::MenuInfo::findparent(), Laxkit::MenuInfo::howmany(), Laxkit::MenuInfo::idexists(), Laxkit::MenuInfo::Search(), Laxkit::MenuInfo::SetRecursively(), Laxkit::MenuInfo::SubMenu(), and Laxkit::ShortcutTreeSelector::UpdateSearch().
unsigned int Laxkit::MenuItem::state |
Holds various state of the item, like if a menu is open, etc.
This is used by various control mechanisms to keep track of what to highlight, and what is currently selected (***check this last point!).
If an item is a leaf, then it does not have MENU_HAS_SUBMENU set. A toggle item is a leaf that is allowed to be checked. This is to distinguish items that are leaves, but which provoke some action by themselves, and items that are things that are either on or off.
Referenced by Laxkit::PopupMenu::addselect(), Laxkit::TreeSelector::addselect(), Laxkit::MenuSelector::addselect(), Laxkit::MenuSelector::CharInput(), Laxkit::TreeSelector::CharInput(), Laxkit::TreeSelector::Collapse(), Laxkit::FileMenuItem::CreateSubmenu(), Laxkit::TreeSelector::Deselect(), Laxkit::TreeSelector::drawitem(), Laxkit::MenuSelector::drawitem(), Laxkit::TreeSelector::drawitemname(), Laxkit::MenuSelector::drawitemname(), Laxkit::MenuSelector::drawsubindicator(), Laxkit::FileDialog::Event(), Laxkit::TreeSelector::Expand(), Laxkit::FileMenuItem::FileMenuItem(), Laxkit::SliderPopup::GetState(), Laxkit::FileMenuItem::GetSubmenu(), Laxkit::MenuInfo::idexists(), Laxkit::MenuInfo::Search(), Laxkit::MenuSelector::Select(), Laxkit::TreeSelector::Select(), Laxkit::SliderPopup::SelectNext(), Laxkit::SliderPopup::SelectPrevious(), Laxkit::MenuSelector::send(), Laxkit::SliderPopup::SetState(), and Laxkit::SliderPopup::WrapToExtent().