Download IUP - Portable User Interface

Transcript
IUP Portable User Interface
06/07/2015
Handle names (like "CURSOR", "IMAGE" and "MENU")
Pointers that are not strings (like WID)
Read-only or write-only attributes
Internal attributes that starts with "_IUP"
Inheritable attributes are stored in the hash table so the IupGet/SetAttribute logic can work, even if the control class
store it internally. But when you change an attribute to NULL, then its value is removed from the hash table and the
default value if any is passed to the native system.
When consulted the attribute is first checked at the control class. If not defined then it checks in the hash table. If not
defined in its hash table, the attribute will be inherited from its parent's hash table and so forth, until it reaches the root
child (usually the dialog). But if still then the attribute is not defined a default value for the element is returned (the
default value can also be NULL).
When changed the attribute change is propagated to all children except for those who the attribute is already defined in
the hash table.
But some attributes can be marked as non inheritable at the control class. (since 3.0)
Non inheritable attributes at the element are not propagated to its children. If an attribute is not marked as non
inheritable at the element it is propagated as expected, but if marked as non inheritable at a child, that child will
ignore the propagated value.
Since Vbox, Hbox, and other containers have only a few registered attributes, by default an unknown attribute is treated
as inheritable, that's why it will be automatically propagated.
An example: the IMAGE attribute of a Label is non inheritable, so when checked at the Label it will return NULL if not
defined, and the Label parent tree will not be consulted. If you change the IMAGE attribute at a Vbox that contains
several Labels, the child Labels will not be affected.
Availability
Although attributes can be changed and retrieved at any time there are exceptions and some rules that must be
followed according to the documentation of the attribute:
read only: the attribute can not be changed. Ignored when set.
write only: the attribute can not be retrieved. Normally used for action attributes. Returns NULL, or eventually
some value set before the element was mapped.
creation only: it will be used only when the element is mapped on the native system. So set it before the
element is mapped. Ignored when set after the element is mapped.
IupLua
Each interface element is created as a Lua table, and its attributes are fields in this table. Some of these attributes are
directly transferred to IUP, so that any changes made to them immediately reflect on the screen. However, not all
attributes are transferred to IUP.
Control attributes, such as handle, which stores the handle of the IUP element, and parent, which stores the object
immediately above in the class hierarchy, are not transferred. Attributes that receive strings or numbers as values are
immediately transferred to IUP. Other values (such as functions or objects) are stored in IupLua and might receive
special treatment.
For instance, a button can be created as follows (defining a title and the background color):
myButton = iup.button{title = "Ok", bgcolor = "0 255 0"}
Font color can be subsequently changed by modifying the value of attribute fgcolor:
myButton.fgcolor = "255 0 0"
Note that the attribute names in C and in IupLua are the same, but in IupLua they can be written in lower case.
In the creation of an element some parameters are required attributes (such as title in buttons). Their types are checked
171/493