Chapter 11. DlgArea and DlgAreaU Classes

Table of Contents
DlgArea Class
DlgAreaU Class
Creating Resizeable Dialogs
Possible Problems
Sample Code

The DlgArea class provides assistance in laying out the dialog controls in a dynamically defined dialog. The DlgAreaU class provides assistance in resizing and / or positioning controls when a dialog is resized. Used together, the two classes provide a convenient way to create resizable dialogs.

DlgArea Class

The DlgArea class defines an area of a UserDialog and provides co-ordinates of and within it. It is a helper for the DefineDialog Method of an OODialog UserDialog Object and has no effect on any Windows Object.

To use objects of the DlgArea class include this line in your code:

::requires "OODIALOG.CLS"

The following figure shows the measuement attributes used to position a DlgArea on a UserDialog.

Figure 11-1. DlgArea Measurements

Init

>>- aDlgArea~Init(--X--,--Y--,--Width--,--Height--+-------------+--)--><
                                                  +--,--Margin--+

Arguments:

The arguments you pass to the new method when creating a DlgArea Object are:

X

The X Co-ordinate in dialog units relative to the UserDialog of the top left corner of the area you wish to define

Y

The Y Co-ordinate in dialog units relative to the UserDialog of the top left corner of the area you wish to define.

Width

The width in dialog units of the area of the UserDialog you wish to define

Height

The height in dialog units of the area of the UserDialog you wish to define

Margin

An inner margin within the DlgArea in Dialog Units to be left blank. The default is 5

Example:

u = .dlgArea~new(0, 0, self~SizeX,Self~SizeY)          /* u is whole of UserDialog */
b = .dlgArea~new(u~x("70%"), u~y , u~w("R"), u~h("R")) /* sub area for buttons */

B

Returns the y coordinate of the bottom margin in dialog units relative to UserDialog.

>>--ADlgArea~B--------------------------------------------------------><

Bottom

Returns the y coordinate of the bottom edge in dialog units relative to UserDialog.

>>--ADlgArea~Bottom---------------------------------------------------><

CX

Synonym for the W method.

>>--ADlgArea~cx(--+-------+--)----------------------------------------><
                  +--n%---+
                  +--"R"--+

CY

Synonym for the H method.

>>--ADlgArea~cy(--+-------+--)----------------------------------------><
                  +--n%---+
                  +--"R"--+

H

Returns a height in dialog units relative to the dialog area.

If no argument is passed returns the inter-margin height.

>>--ADlgArea~h(--+-------+--)-----------------------------------------><
                 +--n%---+
                 +--"R"--+

Arguments:

The arguments you pass to the H method are:

n%

If n is a percentage returns n% of the inter-margin height.

"R"

If "R" is passed returns Remaining height between last ~y and bottom margin.

HR

Returns the remaining height between last ~Y and bottom margin in dialog units. This is equivalent to ~H("R").

>>--ADlgArea~hr-------------------------------------------------------><

L

Returns the x coordinate of the left margin in dialog units relative to UserDialog.

>>--ADlgArea~L--------------------------------------------------------><

Left

Returns the x coordinate of the left edge in dialog units relative to UserDialog.

>>--ADlgArea~Left-----------------------------------------------------><

Margin

Size in dialog units of DlgArea margin.

>>--ADlgArea~Margin---------------------------------------------------><

R

Returns the x coordinate of the right margin in dialog units relative to UserDialog.

>>--ADlgArea~R--------------------------------------------------------><

Right

Returns the x coordinate of the right edge in dialog units relative to UserDialog.

>>--ADlgArea~Right----------------------------------------------------><

T

Returns the y coordinate of the top margin in dialog units relative to UserDialog.

>>--ADlgArea~T--------------------------------------------------------><

Top

Returns the y coordinate of the top edge in dialog units relative to UserDialog.

>>--ADlgArea~Top------------------------------------------------------><

W

Returns a width in dialog units relative to the dialog area.

If no argument is passed returns the inter-margin width.

>>--ADlgArea~w(--+-------+--)-----------------------------------------><
                 +--n%---+
                 +--"R"--+

Arguments:

The arguments you pass to the Y method are:

n%

If n is a percentage returns n% of the inter-margin width.

"R"

If "R" is passed returns Remaining width between last ~x and right margin.

WR

Returns the remaining width between last ~X and right margin in dialog units. This is equivalent to ~W("R").

>>--ADlgArea~wr-------------------------------------------------------><

X

Returns an X Coordinate in dialog units relative to the dialog area.

If no n is passed returns the x coordinate of the left margin.

>>--ADlgArea~x(--+------+--)------------------------------------------><
                 +--n---+
                 +--n%--+

Arguments:

The arguments you pass to the X method are:

n

If n is passed and is positive, then returns the x coordinate n dialog units to the right of the left margin. If n is passed and is negative, then returns the x coordinate n dialog units to the left of the right margin..

n%

If n is passed and is a percentage, then returns the x coordinate n% of the way between the left and right margins.

Y

Returns an Y Coordinate in dialog units relative to the dialog area.

If no n is passed returns the x coordinate of the top margin.

>>--ADlgArea~y(--+------+--)------------------------------------------><
                 +--n---+
                 +--n%--+

Arguments:

The arguments you pass to the Y method are:

n

If n is passed and is positive, then returns the y coordinate n dialog units below the topmargin. If n is passed and is negative, then returns the y coordinate n dialog units above the bottom margin..

n%

If n is passed and is a percentage, then returns the y coordinate n% of the way between the top and bottom margins.

DlgArea Example

On a UserDialog we want the top left to be an entry area, with an area for buttons on the right and a status area below.

We decide to give 70% of the width and 90% of the height to the entry area. We leave the margin as the default. We want all the areas to resize themselves if we change the UserDialog size except the OK button should remain 15 units high.

Figure 11-2. DlgArea Plan

Here is what our DefineDialog method might look like:

/* ------------------------------------------------------------------------- */
::method DefineDialog
/* ------------------------------------------------------------------------- */
/* define DlgArea named u as whole of user dialog                            */
u=.dlgArea~new(  0       ,         0,self~SizeX,Self~SizeY)   /* whole dlg   */

/* define DlgArea named e within DlgArea u for entry line                    */
e=.dlgArea~new(u~x       ,u~y       ,u~w("70%"),u~h("90%"))

/* define DlgArea named s within DlgArea u for Status Area in remaining height*/
s=.dlgArea~new(u~x       ,u~y("90%"),u~w("70%"),u~hr      )

/* define DlgArea named b within DlgArea u for Button area                   */
b=.dlgArea~new(u~x("70%"),u~y       ,u~wr      ,u~hr      )

/* entry line coterminous with area e margins                                */
self~AddEntryLine(12,"text",e~x,e~y,e~w,e~h,"multiline")

/* Status Area Coterminous with area s margins                               */
self~AddText(s~x,s~y,s~w,s~h,"Status info appears here",11)

/* Seven buttons evenly spaced at 10% intervals, 9% high                     */
do i = 0 to 6
   self~addButton(12+i,b~x,b~y((i * 10)||"%"),b~w,b~h("9%"),"Button" i,"Button"||i)
end /* DO */

/* ok button 15 dialog units high at bottom of area b                        */
self~AddButton(1,b~x,b~y(-15),b~w,15,"OK","OK","Default")

Here is the resultant dialog.

Figure 11-3. Sample DlgArea