Laxkit
0.0.7.1
|
Simplify maintenance of icons with this stack of IconNode objects. More...
Public Member Functions | |
IconManager () | |
int | InstallIcon (const char *nname, int nid, const char *file) |
Return -1 for fail to load file. | |
int | InstallIcon (const char *nname, int nid, Laxkit::LaxImage *img) |
Laxkit::LaxImage * | GetIconByIndex (int index) |
Returns the icon. The icon's count is incremented. | |
Laxkit::LaxImage * | GetIcon (int id) |
Returns the icon. The icon's count is incremented. | |
Laxkit::LaxImage * | GetIcon (const char *name) |
Returns the icon. The icon's count is incremented. | |
int | HowMany () |
Return how many icons are currently installed. | |
void | addpath (const char *newpath) |
Add path to index 0 position of the path stack. | |
Public Member Functions inherited from Laxkit::PtrStack< IconNode > | |
PtrStack (char nar=1) | |
virtual IconNode * | operator[] (int i) |
virtual void | flush () |
virtual int | howmany () |
virtual void | swap (int i1, int i2) |
virtual int | push (IconNode *nd, char local=-1, int where=-1) |
virtual int | popp (IconNode *topop, int *local=NULL) |
virtual int | pop (IconNode *&popped, int which=-1, int *local=NULL) |
virtual IconNode * | pop (int which=-1, int *local=NULL) |
virtual int | findindex (IconNode *t) |
virtual int | remove (int which=-1) |
virtual int | pushnodup (IconNode *nd, char local, int where=-1) |
virtual void | Delta (int ndelta) |
virtual int | Delta () |
virtual IconNode ** | extractArrays (char **local=NULL, int *nn=NULL) |
virtual int | insertArrays (IconNode **a, char *nl, int nn) |
Protected Member Functions | |
Laxkit::LaxImage * | findicon (const char *name) |
Search for a icon file "name.png" in all the icon paths. |
Protected Attributes | |
Laxkit::PtrStack< char > | icon_path |
Protected Attributes inherited from Laxkit::PtrStack< IconNode > | |
int | max |
int | delta |
char | arrays |
Additional Inherited Members | |
Public Attributes inherited from Laxkit::PtrStack< IconNode > | |
char * | islocal |
int | n |
IconNode ** | e |
Simplify maintenance of icons with this stack of IconNode objects.
This is essentially a Laxkit::RefStackPtr<IconNode> with some helper functions to ease lookup of icons as button boxes come and go. The stack is sorted by id.
Laxkit::IconManager::IconManager | ( | ) |
Icons are added only when needed by GetIcon(), which uses findicon().
void Laxkit::IconManager::addpath | ( | const char * | newpath | ) |
Add path to index 0 position of the path stack.
When passed a name that is unrecognized, then the all the icon paths are searched for a loadable image named name.png.
References newstr(), and Laxkit::PtrStack< T >::push().
Search for a icon file "name.png" in all the icon paths.
Install and return the icon if found, else NULL.
This function assumes that name is not already in the stack.
References appendstr(), Laxkit::PtrStack< T >::e, Laxkit::anObject::inc_count(), InstallIcon(), Laxkit::load_image, Laxkit::PtrStack< T >::n, and newstr().
Referenced by GetIcon().
Laxkit::LaxImage * Laxkit::IconManager::GetIcon | ( | const char * | name | ) |
Returns the icon. The icon's count is incremented.
If name does not exist, then the icon is searched for in the icon paths, and the first one found is installed.
References findicon().
int Laxkit::IconManager::InstallIcon | ( | const char * | nname, |
int | nid, | ||
Laxkit::LaxImage * | img | ||
) |
If nid<=0, then make the id one more than the maximum nid in stack.
References Laxkit::PtrStack< IconNode >::e, Laxkit::PtrStack< IconNode >::n, and Laxkit::PtrStack< IconNode >::push().