3.1 Application tree

Every RapaGUI application is basically a tree containing a lot of MOAI objects that make up the application. Typically, MOAI objects are just widgets like buttons, listviews, combo boxes, etc. but they can also top-level windows or abstract objects like group objects which are used to compute the GUI layout.

The root element of every application tree must always be an instance of Application class. No MOAI object can exist outside the application object. Application objects are created by calling moai.CreateApp() and there can be only one application object in every program. The application object is responsible for handling all the events and messaging required by your application. See Application class for details.

The most important children of the application object are the top-level windows of your application. These can be normal top-level windows or modal dialogs which block the rest of your application while they are open. To create those objects in XML, you just have to declare them using the <window> and <dialog> tags. See Window class for details. See Dialog class for details.

Every window or dialog always needs to have exactly one root object which must be derived from Group class. Group class allows you to combine one or more widgets in a horizontal, vertical, or grid-based layout. This is one of the most important classes and it can be accessed from XML by using the <vgroup>, <hgroup>, and <colgroup> tags. Whenever the window size changes, all groups are relayouted automatically which means that you don't have to care about the complex task of recalculating your GUI layout based on the current window size. RapaGUI does this all automatically for you. See Group class for details.

Another very important class is Area class. All widgets are children of Area class because Area class basically just describes a rectangular region within the GUI layout on which widget-dependent graphics are drawn. This means that you can use all attributes and methods of this class on all MOAI objects that are widgets. For example, you can set the dimensions of all your widgets by just using the attributes Area.Width and Area.Height. This is usually unnecessary, however, because RapaGUI automatically chooses the dimensions for all widgets. If you're unhappy with RapaGUI's choice, you can override it by using those attributes, though. See Area class for details.


Show TOC