Programming AmigaOS in C

5. How to organize your window and gadgets?

You now have a window and some gadgets. If you place them in your window, it will either appear in one long row or one long column. You do not want that.So, MUI can organize your gadgets into rows ad columns or rows in columns or columns in rows, in boxes, or even on seperate tabs. This section explain how to do that.

1. VGroup and HGroup

These two macros allow you to organize gadgets either vertically (VGroup) ie one on top of another or horizontally (HGroup) ie side by side. The group should be finished by an End statement.

SubWindow, WindowObject,
    WindowContents, VGroup,
        Child, String("foo",40),
        Child, String("bar",50),
    Child, HGroup,
        Child, CheckMark(TRUE),
        Child, CheckMark(FALSE),

The above code create a window with 4 gadgets in it. There are two string and two check marks. They are organised in to three rows, where the third row consists of two check marks, side by side.

2. Spacing of gadgets

Some objects need to spacing between them to make the interface look neater and not too crowded. There are a number of objects you can use to space your gadgets:

HVSpace - Creates a rectanglar space
HSpace(x) - Creates some horizontal space of x characters
VSpace(x) - Creates some vertical space of x characters
HCenter(obj) - Centers the object horizontally
VCenter(obj) - Centers the object vertically
InnerSpacing(h,v) - Centers following object within a rectanglar area
GroupSpacing(x) - Centers following group

e.g. Child, HCenter(Label3("Program Title")),

3. Tabbed Windows

Another useful feature of MUI Winodws is that you can have tabs, so you can use different gadgets and layouts on a seperate tab on the same window. All you need is an array of names for the tabs and then use the RegisterGroup(tabarray) command in the Window Contents, followed by the 3 lots of child object(s) to include inside each tab.


Tabs[0] = MSG("Title for Tab 1");
Tabs[1] = MSG("Title for Tab 2");
Tabs[2] = MSG("Title for Tab 3");
Tabs[3] = NULL;
SubWindow, window = WindowObject,
MUIA_Window_Title, MSG("Tab Window Program"),
MUIA_Window_ID , MAKE_ID('T','A','B','S'),
WindowContents, VGroup,

Child, RegisterGroup(Tabs),
MUIA_Register_Frame, TRUE,

Child, HGroup,

Child, HGroup,

Child, HGroup,


Next Page