Omnis Technical Note TNGI0015 October 2006

Dynamic Positioning of Objects

For Omnis Studio 3 or after
By Andreas Pfeiffer

You need to allow users to adjust the size of the main windows in your Omnis applications, therefore you need to set up the sizing and positioning properties of all window fields in the most appropriate way. In particular, you need to set up the $edgefloat property for most of the fields in your window, taking account of how these fields will resize or reposition themselves when the main window is resized.

What does 'edgefloat' mean?
It means what it says: the edges (of a window field) can float. You can assign an edgefloat constant in the $edgefloat property to each window object; there are many different types of edgefloat constant that effect the resizing and, in some cases, the position of window objects. The constants are listed in the dropdown list on the $edgefloat property which is located in the Appearance group of your Property Manager, but they are also listed in the Catalog (F9) under the Constants group and in the 'Floating edges' subgroup.

For example, if you want a headed list box to be enlarged automatically when the window size is extended, you can set its $edgefloat property to kEFrightBottom. This means that the right edge of the headed list box will 'float' or extend with the right edge of the window, as it is resized, and similarly, the bottom edge of the list field will extend with the bottom edge of the window.

A tip when designing with edgefloats: if you have set the edgefloat property of a field and need to resize the window in design mode without the field resizing, you can hold down the Alt key and make the window larger. In this case, the basic edgefloat properties are disabled.

Make use of containers
Quite often the use of simple edgefloat properties is not sufficient to control the position or resizing of objects in your window. For example, you may want a whole group of entry fields to float as a group, so in this case you can use a container field such as the scroll box. You can design the container to be quite inconspicuous by setting the colours accordingly, by switching off the scrollbars and by setting the effect to kBorderChisel or even kBorderNone. Then you can set the edgefloat property for the container object, and all the objects within the container will move as a group within the container. You can also nest multiple containers.

More complex edgefloats
I like to assign edgefloat properties to containers, but also to bigger objects such as headed list boxes, tree lists and icon arrays to control the position and sizing of these objects in relation to the window or to other objects. For example, if you want to place a container object for buttons at the top border of your window you can assign the kEFposnTopToolbar edgefloat property to the container. In this case, the container and all the buttons it contains are "stuck" to the top border of the window in the toolbar position. You could use this idea in a window superclass so all subclasss windows inherit such standard functionality, that is, each of the inherited windows will automatically have the same base 'toolbar' which can even be added to in individual cases.

Floating objects

Edgefloats are powerful
There are further edgefloat properties that allow you to position objects in a window. For example, you can set the edgefloat property of a tree list to kEFposnLeftToolbar and it will be positioned in the left border: this technique is used in the latest version of the Studio Browser. A further object, such as another container or an icon array, could be placed to the right of the tree list and be assigned the kEFposnClient edgefloat constant so it takes up the remaining space in the window.

Floating objects

In combination with the $dragborder field property, which will become active when the appropriate constant is set in the edgefloat, you could even allow the user to resize the field at runtime. When you set the $dragborder property of the tree list to kTrue and the user moves their mouse over the field border, the cursor will change showing that the field can be resized. In this case, when the field is resized all other containers and objects in the window will adjust according to their edgefloat properties.

Search Omnis Developer Resources

 

Hit enter to search

X