* Warning * The format is completely revamped

Now it is just Include xControl.ew

 

This will allow me to add new controls without each one requiring an include statement in the main file.

 

 

Function: GMID = xControl( Geometry, “”, Parent, 0, 0, 0, 0, 0, 0 )

 

Creates a new geometry manager and returns it's ID. The extra fields colored in red are not used in this control but needed for uniformity.

 

Procedure: manage( GMID, ChildID, {%,#}, {%,#}, {%,#}, {%,#} )

 

Adds ChildID to the list of managed windows for the geometry manager.

Parameters 3-6 are respectively Left, Top, Right and Bottom and they let the manager know how to position each child when a change in the parent is detected and are in the form:

 

{Percentage, Offset}

 

Percentage: may be any number between 0 and 1 inclusive.  0 being 0%

and 1 being 100%.  This tells the manager where to place that side of the window relative to the parent

 

Offset: any whole number.  This gives the offset (in pixels) that should be applied to the side after the percentage.

 

Examples:

manage( GMID, ChildID, {0, 0},  {0, 0},  {0.5, 0},  {0.5, 0} )

n       Left = place at 0% with no offset

n       Top = place at 0% with no offset

n       Right = place at 50% with no offset

n       Bottom = place at 50% with no offset

 

manage( GMID, ChildID, {0, 5},  {0, 5},  {0.5, 0},  {1, -5} )

n       Left = place at 0% with a 5 pixel offset

n       Top = place at 0% with a 5 pixel offset

n       Right = place at 50% with no offset

n       Bottom = place at 100% with a -5 pixel offset

I think you get the general idea...

For any controls side which has already been calculated, you can sub in its ChildID for the Percentage.  In this case it is the position of the ChildID's opposite side.

 

Example:

manage( GMID, ChildID1, {0, 5}, {0, 5}, {0.5, 0}, {1, -5} )

manage( GMID, ChildID2, {ChildID1, 5}, {0, 5}, {1, -5}, {0.5, 0} )

n       ChildID1

n       Left = place at 0% with a 5 pixel offset

n       Top = place at 0% with a 5 pixel offset

n       Right = place at 50% with no offset

n       Bottom = place at 100% with a -5 pixel offset

n       ChildID2

n       Left = place at ChildID1's right side plus 5 pixels

n       Top = place at 0% percent with a 5 pixel offset

n       Right = place at 100% with a -5 pixel offset

n       Bottom = place at 50% with no offset

 

Note:  It is legal syntax to include the current controls ID in the field as well. This facilitates controls with constant widths / heights.

 

Example:

manage( GMID, ChildID1,  {0, 5}, {0, 5}, {ChildID1, 30}, {1 , -5} )

This control has a constant width of 30 pixels.  It is read as ChildID1's left position plus 30.

 

Warning:

The afore mentioned stipulation of only using windows / sides which have been previously calculated holds true here as well.  Using a reference to yourself in the Left field will give unpredictable results as the right side has yet to be calculated.

 

Of further note:

This manager only has knowledge of the controls added to its scope.  Therefore you should not reference a side of a control not managed by the current geometry manager.

 

Version 1.1 new features:

Thanks to Matt Lewis for both of these excellent suggestions.

 

1>

In version 1.0, adding a new child to the geometry manager would basically append itself to a managed sequence and there was no way once defined to modify it.  In version 1.1 its implementation has changed so it can be redefined dynamically.

 

Note: The changes in a controls geometry will not take place until one of two conditions.  Either you must wait for a resize, or you must call the new function “manage_now”.

 

2>

Added procedure manage_now( GMID ).  This will force a reposition of all child controls according to their current definition.  I considered the possibility of doing this automatically when a control is redefined, but if you need to update multiple controls it would cause a lot of repositionings.  This way they are all done at once.

 

Version 1.2

 

No new features in this version, just streamlining a bit.  I had failed to realize that from moving to version 1.0 I had optimized away the need for the child window I was placing on the parent.  I removed the un-needed lines from the geometry function.

 

Version 1.3

 

Modified geometry for the new format

 

Version 1.4

 

Noticed that the onResize event for the parent was no longer being called. Added code to implicitly call it myself on a resize. This event is still needed because an object might need to resize and be a child of the parent but apart from the manager.

------

 

Enjoy!

Any questions, comments, suggestions, (ack bugs!) are welcome:

< dphillips@KBSI.com >