button = IupButton("button")
and without worrying too much about the
technical details of that, it should be obvious that it creates a button. Equally I am sure you can imagine a fairly long list of things
you might want to alter: size, font, colour, dynamically change the text, add an image, enable/disable it, and of course configure what
happens when it is clicked.
Aside: in IUP element position is dynamically determined through nested containers and fillers, though if you are adamantly married to
specifying everything in pixels you could always try using an IupCbox.
All of that, even the callbacks, is achieved through the use of attributes.
Without looking at the C source, I would hazard that all attributes are in fact stored as pointers, or more accurately machine-sized words, which delivers high performance, with a handful of selected routines carefully taking a copy of any volatile strings, floats, etc and keeping them safe for the duration. My first reaction was predictable enough given my obsession with performance, but once I accepted it is no big deal to convert "200" to 200, or "YES/NO" to 1/0, I realised it is a pretty good way to keep things simple.
The majority of attributes are implemented using text strings, but there are also routines for storing (and perhaps more importantly retrieving) numbers, pointers, etc. Depending on the interface element, some attributes are inheritable (for instance the BGCOLOR on an IupButton: if not specifically set, a button takes on the background colour of whatever control it is sitting on), and some attributes are non-inheritable (eg TITLE). Some must be set at creation time, ie before the dialog is first displayed (eg CANFOCUS), while others can be amended on the fly (eg ACTIVE), and some are read-only, or platform-specific. Whilst most attributes are static, referred to as needed, a few trigger actions when read or set (eg KEY). These are all documented for each element type.
You can also set bespoke application-specific attributes on any control, which the underlying platform-specific driver will completely ignore. The most likely thing I can think of where that might be useful would be to have a single callback that deals with several controls, which fetches an attribute off the control that triggered it, and tweaks the behaviour accordingly. Perhaps (I have not tried this) a clock application could have a single callback that gets called by three timers, and draws the hour, minute, and second hand appropriately, but I digress...
The point I am trying to make here is that, sheer number of different controls aside, by and large the core of IUP is jaw-droppingly trivial - all the important stuff gets controlled by attributes. Equally there are quite a few ways to set and retrieve attributes, of which there are plenty knocking about, but otherwise the attribute system itself is also conceptually quite trivial.
The following routines are used to set/retrieve attributes:
IupSetAttribute | - | Sets an interface element attribute. |
IupSetStrAttribute | - | Sets an interface element attribute, making a safe copy of any transient string. |
IupSetAttributes | - | Sets several attributes of an interface element. |
IupResetAttribute | - | Removes an attribute |
IupGetAttribute | - | Retrieve an interface element attribute value. |
IupGetAllAttributes | - | Returns a list of attribute names. |
IupSetAttributeHandle | - | Sets an attribute to a handle (instead of the usual string). |
IupSetGlobal | - | Sets an attribute in the global environment. |
IupGetGlobal | - | Returns an attribute value from the global environment. |
IupSetCallback | - | Associates a callback to an event. |
IupGetCallback | - | Returns the callback associated to an event. |
IupSetHandle | - | (deprecated) Associates a name with an interface element. |
IupGetClassName | - | Returns the name of the class of an interface element. |
IupGetAllClasses | - | Returns the names of all registered classes. |
IupGetClassType | - | Returns the name of the native type of an interface element. |
IupGetClassAttributes | - | Returns the names of all registered attributes of a class. |
IupGetClassCallbacks | - | Returns the names of all registered callbacks of a class. |
IupSaveClassAttributes | - | Saves all registered attributes on the internal hash table. |
IupCopyClassAttributes | - | Copies all registered attributes from one element to another. |
IupSetClassDefaultAttribute | - | Changes the default value of an attribute for a class. |
The following attributes are common to several controls/interface element types:
ACTIVE
BGCOLOR
CLIENTOFFSET
CLIENTSIZE
CURSOR
EXPAND
FGCOLOR
FLOATING
FONT NAME NATURALSIZE
MAXSIZE
MINSIZE
SCREENPOSITION
SCROLLBAR
POSITION
RASTERSIZE
SIZE
TIP
TITLE
VISIBLE
WID
ZORDER