Note: This code was written MANY years ago. I'd be surprised if it still works on current versions of GTK+.
What is it?
gtkform is a gtk+ container that resembles the Motif XmFormWidget behavor. For every edge (side) of a widget, you can assign an attachment. These attachments can be relative to the form or to another widget. The attachments determine the layout behavior of the form when resizing occurs.
How it works.
Create a gtkform widget, add children and set contraints. After a widget is added to a form, you can assign the attachments with a call to gtk_form_constrain. Every call to gtk_form_constrain looks like this:
gtk_form_constrain (Form widget, Edge, Attachment, Target, Offset);
| Parameter | Explanation |
| Form widget | Form widget that contains the children. |
| Edge | GTK_FORM_EDGE_TOP
GTK_FORM_EDGE_LEFT GTK_FORM_EDGE_BOTTOM GTK_FORM_EDGE_RIGHT |
| Attachment | GTK_FORM_ATTACH_NONEGTK_FORM_ATTACH_FORM
GTK_FORM_ATTACH_WIDGET GTK_FORM_ATTACH_OPPOSITE_WIDGET GTK_FORM_ATTACH_CENTER |
| Target | For WIDGET, OPPOSITE_WIDGET or CENTER |
| Offset | Offset from the target or form side. |
Attachments:
| Attachment | Explanation |
| GTK_FORM_ATTACH_NONE | Edge does not have any constraint. |
| GTK_FORM_ATTACH_FORM | Edge is layed out Offset pixels from the side of the form. |
| GTK_FORM_ATTACH_WIDGET | Edge is layed out Offset pixels from Target. |
| GTK_FORM_ATTACH_OPPOSITE_WIDGET | Edge is layed out Offset pixels from the opposite side of Target. |
| GTK_FORM_ATTACH_CENTER | Component is centered with respect to Target. If Target is GTK_FORM_NULL_WIDGET, then widget is centered on the form. The Edge specified with this call only determines which direction to take the offset. If Offset is zero, then either edge will have the same outcome. |
Differences from XmForm
Aside from the fact that gtkform does not implement all of the XmForm functionality, gtkform does have extended functionality beyond XmForm. Unlike XmForm, gtkform will allow widgets to have contraints relative to each other as long as they are not truely circular. In other words, widget A can be attached to the left of widget B and widget B can be attached to the bottom of widget A. Similiarly, widget A can be attached to itself. This can be used to specify a fixed width or height for a component. Lastly, gtkform supports centering.
Download