Laxkit
0.0.7.1
|
General container for menu types of lists. More...
Public Member Functions | |
MenuInfo (const char *ntitle=NULL) | |
Constructor, just make empty menu with title set to ntitle. | |
virtual | ~MenuInfo () |
Destructor, just frees the title. The stack is flushed automatically. | |
virtual void | SetCompareFunc (CompareFunc func) |
Set the compare function to some "int (*func)(const char *,const char *). | |
virtual void | SetCompareFunc (int newsortstyle) |
Set Compare to the appropriate function for newsortstyle. | |
virtual void | Sort (int detail=0, int newsortstyle=0) |
Sort the items according to sortstyle. | |
virtual void | sort (int start, int end, int detail) |
Recursive quick sort routine. | |
virtual MenuInfo * | findparent (MenuInfo *m, int *index=NULL) |
Find the parent menu (MenuInfo that has the item, not the MenuItem that has m) of m. | |
virtual MenuItem * | findFromLine (int i) |
Get the element at line number i, including all open submenus and separators. | |
virtual int | findLine (MenuItem *mi) |
Find the line number of mi (starting at 0), counting all open submenus, thus as it would appear onscreen in a tree. | |
virtual int | findIndex (MenuItem *mi) |
returns index in menuitems.e of mi only if mi is in this menu, not a submenu. | |
virtual int | findIndex (const char *name, int start_at=0) |
virtual int | findIndex (int checkid) |
Returns index in menuitems.e of element with id==checkid in this menu, not a submenu. | |
virtual MenuItem * | findid (int checkid) |
Find the MenuItem anywhere that has checkid as its id. | |
virtual int | idexists (int check, MenuInfo *look) |
Check to see if an id==check exists somewhere in the menu hierarchy. | |
virtual int | getuniqueid (int trythis=-1) |
Return a unique id number, starting with trythis. | |
virtual int | howmany (int maxn, int all=0) |
Counts how many items are visible (including separators, but not hidden). | |
virtual int | AddItem (const char *newitem, int nid=0) |
Add item at position where, or to end of menu if where<0. | |
virtual int | AddDelimited (const char *newitem, char delimiter='/', int nid=0) |
virtual int | AddItem (const char *newitem, LaxImage *img, int nid=0) |
Add item at position where, or to end of menu if where<0. | |
virtual int | AddItem (const char *newitem, int nid, unsigned int nstate, int ninfo=0, MenuInfo *nsub=NULL, int where=-1, char subislocal=1) |
Add item at position where, or to end of menu if where<0. | |
virtual int | AddItem (const char *newitem, LaxImage *img, int nid, unsigned int nstate, int ninfo=0, MenuInfo *nsub=NULL, int where=-1, char subislocal=1) |
Add item at position where, or to end of menu if where<0. | |
virtual int | AddItem (MenuItem *mi, char islocal, int where=-1) |
Add an already made MenuItem. | |
virtual int | AddItemAsIs (MenuItem *mi, char islocal, int where=-1) |
Add an already made MenuItem, but DO NOT reparent. This is for temporary lists refering to the main one. | |
virtual int | AddItems (const char **i, int n, int startid) |
Add a whole bunch of items at the same time. | |
virtual int | AddDetail (const char *newitem, LaxImage *img, int nid=0, int ninfo=0, int towhich=-1) |
Add item detail to the item at the top of menuitems, or to towhich. | |
virtual int | AddSep (const char *name=NULL, int where=-1) |
Currently adds a grayed separator with name="", id=0, no submenu, (but it is still legal to add a submenu!!) | |
virtual int | SubMenu (const char *ntitle=NULL, int which=-1) |
Future Add*() go on a new submenu for item which, or top of the stack. | |
virtual void | EndSubMenu () |
Stop adding to a submenu, revert curmenu to the parent of that submenu. | |
virtual void | DoneSubMenus () |
Just resets curmenu to this. | |
virtual void | NewTitle (const char *ntitle) |
Set the title if the curmenu to ntitle. | |
virtual void | Flush () |
Flush menuitems and set curmenu=this. | |
virtual int | SetRecursively (unsigned long nstate, int on, int ignoreunmade=0) |
virtual int | Search (const char *search, int isprogressive, int ignoreunmade=0) |
Progressively search for items, caseless+partial. search==NULL matches all. | |
virtual void | ClearSearch () |
virtual int | n () |
virtual MenuItem * | e (int i) |
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 | |
int | sortstyle |
Indicates how to sort. | |
MenuInfo * | curmenu |
Holds a temporary pointer to the (sub)menu that should be added to or modified. | |
char * | title |
The title of the menu. | |
MenuItem * | parent |
RefPtrStack< MenuItem > | menuitems |
Holds the individual menu items. | |
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 Attributes | |
CompareFunc | Compare |
Protected Attributes inherited from Laxkit::anObject | |
int | _count |
The reference count of the object. |
General container for menu types of lists.
This class stores lists that are used by MenuSelector, StrSliderPopup, and PopupMenu. It is basically a stack of MenuItem objects, and an optional title.
*** RemoveItem
hot keys
|
virtual |
A shortcut to add something like "group 1/subgroup/item" to submenu. Adds any non-existing intermediate groups (with id==0). Afterwards, curmenu is unchanged.
References newnstr().
|
virtual |
Add item detail to the item at the top of menuitems, or to towhich.
If there is no recent item, then return 1. On success, return 0.
Add item at position where, or to end of menu if where<0.
Please note that the MenuItem that is created is local to the menuitems stack (it will be deleted when the item stack is flushed), while the passed in submenu is local according to subislocal.
References menuitems, and Laxkit::PtrStack< T >::n.
Referenced by Laxkit::SliderPopup::AddItem(), Laxkit::MenuSelector::AddItem(), Laxkit::TreeSelector::AddItem(), Laxkit::FileDialog::BuildBookmarks(), Laxkit::FileMenuItem::CreateSubmenu(), Laxkit::FileDialog::getDirectory(), Laxkit::SplitWindow::GetMenu(), Laxkit::FileDialog::init(), and Laxkit::RulerWindow::RBUp().
Add item at position where, or to end of menu if where<0.
Please note that the MenuItem that is created is local to the menuitems stack (it will be deleted when the item stack is flushed), while the passed in submenu is local according to subislocal.
References menuitems, and Laxkit::PtrStack< T >::n.
|
virtual |
Add item at position where, or to end of menu if where<0.
Please note that the MenuItem that is created is local to the menuitems stack (it will be deleted when the item stack is flushed), while the passed in submenu is local according to subislocal.
References menuitems, and Laxkit::PtrStack< T >::n.
|
virtual |
Add item at position where, or to end of menu if where<0.
Please note that the MenuItem that is created is local to the menuitems stack (it will be deleted when the item stack is flushed), while the passed in submenu is local according to subislocal.
References menuitems, and Laxkit::PtrStack< T >::n.
Add an already made MenuItem.
Note that mi->parent is set to curmenu. Returns the number of menuitems.
If islocal is nonzero then this menuitem is not deleted when the menuitems stack is flushed.
References menuitems, and Laxkit::PtrStack< T >::n.
Add an already made MenuItem, but DO NOT reparent. This is for temporary lists refering to the main one.
Returns the number of menuitems.
If islocal is nonzero then this menuitem is not deleted when the menuitems stack is flushed.
Referenced by Laxkit::TreeSelector::addToCache().
Add a whole bunch of items at the same time.
Assigns ids sequentially starting with startid. Does not check for multiple occurences of the ids used.
Returns number of items added. ***this is cheap, should be optimized for large arrays?? add in one lump, then sort??
References isblank().
Referenced by Laxkit::SliderPopup::AddItems(), and Laxkit::FileDialog::BuildBookmarks().
Currently adds a grayed separator with name="", id=0, no submenu, (but it is still legal to add a submenu!!)
Returns whatever AddItem returns.
Referenced by Laxkit::SliderPopup::AddSep(), and Laxkit::FileDialog::BuildBookmarks().
Find the MenuItem anywhere that has checkid as its id.
Searches recursively through all submenus. When changing states, labels, ordering, etc. from the outside, this is handy.
Any potential submenus that do not currently exist are skipped.
References findid(), and Laxkit::MenuItem::GetSubmenu().
Referenced by findid().
Return index if name is in this menu, not a submenu. Note that name is not necessarily unique. If start_at>0, then start the search at that item.
Return -1 if not found.
Find the line number of mi (starting at 0), counting all open submenus, thus as it would appear onscreen in a tree.
This includes separators but not hidden items, thus if mi is in the tree but hidden, then no valid index is returned for it.
If mi is not found, then -1 is returned.
References findLine(), Laxkit::MenuItem::GetSubmenu(), and howmany().
Referenced by findLine().
Find the parent menu (MenuInfo that has the item, not the MenuItem that has m) of m.
If index is not null, then also put the index of the item within the found parent menu whose submenu is equal to m. If there is no such m, then -1 is put in index. If m==this, index is set to -2 and NULL is returned.
If no parent menu is found, which should only happen when m is nowhere in the tree, then index is set to -1, and NULL is returned.
Please note that this basically assumes that all the relevant submenus are already defined. That is, any potential submenus that are not currently defined do not get defined in the process of searching.
References findparent(), and Laxkit::MenuItem::GetSubmenu().
Referenced by findparent().
Return a unique id number, starting with trythis.
Cheap, inefficient function to simply return a number 1 larger than the current largest id.
If trythis<=0, then start looking with 1.
Counts how many items are visible (including separators, but not hidden).
If all is 1, then include all the items from submenus, whether they are open or not. If all is 0, then include all items from only the submenus that are open. If all is -1, then include only the items from this menu.
Any potential menus that do not currently exist are skipped.
Only include items whose stack indices i in this top menu where i<maxn. If maxn is out of bounds, then consider all the items in this menu.
***TODO: Should decide whether to include a submenu title as a line for open menus!! right now it does not. note the title of a submenu is not the same as the name of the item that has the submenu.
References Laxkit::MenuItem::GetSubmenu(), and howmany().
Referenced by Laxkit::TreeSelector::Collapse(), Laxkit::TreeSelector::Deselect(), Laxkit::TreeSelector::Expand(), findFromLine(), findLine(), howmany(), and Laxkit::TreeSelector::SetFirst().
Check to see if an id==check exists somewhere in the menu hierarchy.
if look is NULL, then default is to start checking in this->menu.
References Laxkit::PtrStack< T >::e, Laxkit::MenuItem::GetSubmenu(), menuitems, Laxkit::PtrStack< T >::n, and Laxkit::MenuItem::state.
|
virtual |
Progressively search for items, caseless+partial. search==NULL matches all.
Sets MENU_SEARCH_HIT on matching items. Sets MENU_SEARCH_PARENT on items that don't match, but who has descendents.
If isprogressive, then assume that search is a string that contains the previous search.
Return number of hits.
References Laxkit::MenuItem::GetSubmenu(), Search(), and Laxkit::MenuItem::state.
Referenced by Search().
|
virtual |
Set the compare function to some "int (*func)(const char *,const char *).
If func==NULL, then reset Compare to strcmp.
If ignoreunmade!=0, then do not use GetSubmenu(), which will generate unmade submenus. You would want to do this, for instance, to avoid FileMenuItem generation of the entire harddrive.
Returns number of items affected.
References Laxkit::MenuItem::GetSubmenu(), and SetRecursively().
Referenced by SetRecursively().
Sort the items according to sortstyle.
*** should be able to sort only a subset, for instance all items between separators.
Referenced by Laxkit::FileDialog::getDirectory().
Recursive quick sort routine.
This can be called to only sort a subset of the menu. If end<0, then sort all from start to the final item.
Currently only sorts in a,b,c order. Only the top is sorted, not submenus.
Referenced by Laxkit::MenuSelector::Sort(), and Laxkit::TreeSelector::Sort().
Future Add*() go on a new submenu for item which, or top of the stack.
This prompts the MenuItem to establish a new MenuInfo
If which is out of bounds, it is set to the final item on the stack
On success, 0 is returned. If curmenu has no items then nothing is done, and 1 is returned. If there is a problem creating a new submenu, then curmenu is not changed and 2 is returned.
References Laxkit::PtrStack< T >::e, Laxkit::MenuItem::GetSubmenu(), and menuitems.
Referenced by Laxkit::SplitWindow::GetMenu().
MenuInfo * Laxkit::MenuInfo::curmenu |
Holds a temporary pointer to the (sub)menu that should be added to or modified.
curmenu is set to this in the constructor. At no time should it be NULL.
Referenced by DoneSubMenus().
int Laxkit::MenuInfo::sortstyle |
Indicates how to sort.