IUP Intro: Difference between revisions
Greshnatok (talk | contribs) New page: IUP ([http://www.tecgraf.puc-rio.br/iup/ homepage]) is the graphics library exposed to Lua. |
Greshnatok (talk | contribs) No edit summary |
||
Line 1: | Line 1: | ||
IUP ([http://www.tecgraf.puc-rio.br/iup/ homepage]) is the graphics library exposed to Lua. | IUP ([http://www.tecgraf.puc-rio.br/iup/ homepage]) is the graphics library exposed to Lua. | ||
== Overview == | |||
The basic building blocks elements (like buttons, dropdown boxes etc.) and containers (hbox and vbox). Elements are put into containers which then decide how to display the elements. | |||
== hbox and vbox == | |||
These are the basic containers. Elements put into an hbox ("horizontal box") will be stacked horizontally, while a vbox ("vertical box") will arrange them vertically. Containers can be added as elements into other containers, i.e. they can be nested. | |||
The following, for example, would produce a box with two vertically arranged labels as elements (i.e. they wouldd appear on top of each other). | |||
<source lang="lua"> | |||
iup.vbox { | |||
iup.label{ title = "[Label 1]" }, | |||
iup.label{ title = "[Label 2]" }, | |||
} | |||
</source> | |||
A simple example of nesting: | |||
<source lang="lua"> | |||
iup.hbox { | |||
iup.vbox { | |||
iup.label{ title = "[Label 1]" }, | |||
iup.label{ title = "[Label 2]" }, | |||
}, | |||
iup.vbox { | |||
iup.label { title = "[Label 3]" }, | |||
iup.label { title = "[Label 4]" }, | |||
} | |||
} | |||
</source> | |||
When stuck into a window, the result would look something like this: | |||
+-----------------x+ | |||
+------------------+ | |||
|[Label 1][Label 3]| | |||
|[Label 2][Label 4]| | |||
+------------------+ | |||
== Windows == | |||
The boxes need to be put into a window to actually be displayed. This is done by using an IUP dialog and a "pdarootframe". Using the example above ("iuppy" can obviously be replaced with anything): | |||
<source lang="lua"> | |||
iuppy.main = iup.dialog { | |||
iup.pdarootframe { | |||
iup.hbox { | |||
iup.vbox { | |||
iup.label{ title = "[Label 1]" }, | |||
iup.label{ title = "[Label 2]" } | |||
}, | |||
iup.vbox { | |||
iup.label { title = "[Label 3]" }, | |||
iup.label { title = "[Label 4]" } | |||
} | |||
} | |||
}; | |||
TOPMOST = "yes" | |||
} | |||
</source> | |||
== Show and Hide == | |||
You can control when to show and when not to show the created window using the "show" and "hide" functions; they do the obvious thing: | |||
<source lang="lua"> | |||
iuppy.main:show() -- Displays the window | |||
iuppy.main:hide() -- Hides the window | |||
</source> | |||
Calling show when the window is already showing or calling hide when it's already hidden does nothing. |
Revision as of 12:28, 31 January 2008
IUP (homepage) is the graphics library exposed to Lua.
Overview
The basic building blocks elements (like buttons, dropdown boxes etc.) and containers (hbox and vbox). Elements are put into containers which then decide how to display the elements.
hbox and vbox
These are the basic containers. Elements put into an hbox ("horizontal box") will be stacked horizontally, while a vbox ("vertical box") will arrange them vertically. Containers can be added as elements into other containers, i.e. they can be nested.
The following, for example, would produce a box with two vertically arranged labels as elements (i.e. they wouldd appear on top of each other). <source lang="lua"> iup.vbox {
iup.label{ title = "[Label 1]" }, iup.label{ title = "[Label 2]" },
} </source>
A simple example of nesting: <source lang="lua"> iup.hbox {
iup.vbox { iup.label{ title = "[Label 1]" }, iup.label{ title = "[Label 2]" }, }, iup.vbox { iup.label { title = "[Label 3]" }, iup.label { title = "[Label 4]" }, }
} </source>
When stuck into a window, the result would look something like this:
+-----------------x+ +------------------+ |[Label 1][Label 3]| |[Label 2][Label 4]| +------------------+
Windows
The boxes need to be put into a window to actually be displayed. This is done by using an IUP dialog and a "pdarootframe". Using the example above ("iuppy" can obviously be replaced with anything): <source lang="lua"> iuppy.main = iup.dialog {
iup.pdarootframe { iup.hbox { iup.vbox { iup.label{ title = "[Label 1]" }, iup.label{ title = "[Label 2]" } }, iup.vbox { iup.label { title = "[Label 3]" }, iup.label { title = "[Label 4]" } } } }; TOPMOST = "yes"
} </source>
Show and Hide
You can control when to show and when not to show the created window using the "show" and "hide" functions; they do the obvious thing: <source lang="lua"> iuppy.main:show() -- Displays the window iuppy.main:hide() -- Hides the window </source> Calling show when the window is already showing or calling hide when it's already hidden does nothing.