Laxkit  0.0.7.1
Public Member Functions | Public Attributes | Protected Member Functions | Protected Attributes
Laxkit::MenuItem Class Reference

Node type for MenuInfo. More...

Inheritance diagram for Laxkit::MenuItem:
Inheritance graph
[legend]

List of all members.

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 MenuInfoGetSubmenu (int create=0)
 Return the submenu, if it exists.
virtual MenuInfoCreateSubmenu (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 charGetString (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 charwhattype ()
 Returns the type of anObject.
virtual anObjectduplicate (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

charname
LaxImageimage
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
MenuItemnextdetail
MenuInfoparent
- Public Attributes inherited from Laxkit::anObject
int suppress_debug
DeleteRefCountedFunc deleteMe
 Called when the count is decremented to 0.
unsigned long object_id
charobject_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

MenuInfosubmenu
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.

Detailed Description

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):

#define LAX_HIDDEN (0)
#define LAX_OFF (1<<0)
#define LAX_ON (1<<1)
#define LAX_GRAY (1<<2)
#define LAX_SEPARATOR (1<<3)
#define LAX_MSTATE_MASK (0xff)
// note to programmer: make sure this can be combined with above state
#define LAX_OPEN (1<<8)
#define LAX_CCUR (1<<9)
#define MENU_HAS_SUBMENU (1<<12)
#define LAX_ISTOGGLE (1<<13)
#define LAX_CHECKED (1<<14)

Constructor & Destructor Documentation

Laxkit::MenuItem::MenuItem ( LaxImage img = NULL)

img's count is incremented.

References Laxkit::anObject::inc_count().


Member Function Documentation

MenuInfo * Laxkit::MenuItem::CreateSubmenu ( const char ntitle)
virtual

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.

MenuInfo * Laxkit::MenuItem::GetSubmenu ( int  create = 0)
virtual

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().


Member Data Documentation

unsigned int Laxkit::MenuItem::state

The documentation for this class was generated from the following files:

Mon Feb 17 2014 11:52:59, Laxkit