Download Project Management:
Transcript
if not value then
value = ih.hash_table.Get(name)
endif
if not value then
value = ih.GetParentHashTableAttribute(name)
endif
if not value then
value = ih.GetDefaultAttribute(name)
endif
}
The driver implementation of the control class can update or retreive a value even if the control is not mapped. This is enabled for only a few attributes.
Attribute names are always upper case, lower case names will not work. But attribute values like "YES", "NO", "TOP", are case insensitive, so "Yes", "no", "top", and
other variations will work. Boolean attributes accept the values "1", "YES", "ON" or "TRUE" for true, and NULL (not defined), "0", "NO", "OFF" or "FALSE" for
false, even if in the documentation is only one of these combinations.
There are attributes common to all the elements. These attributes sometimes are not mentioned in each element documentation. We assume that the programmer knows
they exist. In some cases, common attributes behave differently in different elements, but in such cases, there are comments explaining the behavior.
In LED there is no prefix IUP_ or quotation marks for attributes, names or values.
Inheritance
Elements included in other elements can inherit their attributes. This means there is an inheritance mechanism inside a given dialog.
This means, for example, that if you set the "MARGIN" attribute of a vbox containing several other elements, including other vboxes, all the elements depending on the
attribute "MARGIN" will be affected, except for those who the "MARGIN" attribute is already defined.
Please note that not all attributes are inherited. Some examples: "TIP", "ZORDER", "TITLE", "VALUE", "ALIGNMENT", "X", "Y", "RASTERSIZE", "SIZE",
"IMAGE", "IMINACTIVE", "IMPRESS", "SEPARATOR".
Id numbered attributes are NON inheritable always, like "1" or "MARK1:1". Attributes that are handle names like "IMAGE" and "MENU" are NON inheritable always.
Attributes that are read-only or write-only are NON inheritable.
The attribute is first checked at the element specific implementation at the driver (if mapped) or at the custom control. 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 and so forth, until it reaches 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).
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
transfered. 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 when the element is created. The required
parameters are exactly the paremeters that are necessary for the element to be created in C.
Some interface elements can contain one or more elements, as is the case of dialogs, lists and boxes. In such cases, the object’s element list is put together as a vector,
that is, the elements are placed one after the other, separated by commas. They can be accessed by indexing the object containing them, as can be seen in this example:
mybox = iup.hbox{bt1, bt2, bt3}
mybox[1].fgcolor = "255 0 0"
mybox[2].fgcolor = caixa[1].fgcolor
-- changes bt1 foreground color
-- changes bt2 foreground color
While the attributes receiving numbers or strings are directly transferred to IUP, attributes receiving other interface objects are not directly transferred, because IUP only
accepts strings as a value. The method that transfers attributes to IUP verifies if the attribute value is a handle, that is, if it is an interface element. If the element already
has a name, this name is passed to IUP. If not, a new name is created, associated to the element and passed to IUP as the value of the attribute being defined.
This policy is very useful for associating two interface elements, because you can abstract the fact that IUP uses a string to make associations and imagine the interface
element itself is being used.
IupStoreAttribute
Defines an attribute for an interface element.
Parameters/Return
void IupStoreAttribute(Ihandle *ih, char *name, char *value); [in C]
iup.StoreAttribute(ih: iulua_tag, name: string, value: string) [in Lua]
ih: identifier of the interface element. If NULL will set in the global environment.
name: name of the attribute.
value: value of the attribute. If NULL (nil in IupLua), the attribute will be removed from the element.
Notes