Positioning Controls in a Dialog Box

 

To explicitly position controls within a dialog box, place the x=nx and/or a y=ny modifies in the display portion of the menu file, where nx and ny are integers indicating the location.  The position values are based on character coordinates within the dialog box where a value of 1 indicates 1 character.

 

If no position modifies are present, a control is placed below the previous control. To place a control horizontally to the right of the last control, use x=-1 and to place a control at the same vertical location, use y=-1.  To place a control on the same line but to the right of the previous control, use both x=-1 y=-1.

 

// button1.pan

@dialog

 

Button Example

 

Generate Noise <b>~~w0 := gnorm(1000, 0.001)

Generate Sin   <b>~~w0 := gsin(1000, 0.001)

<L>

Check1         <c>~<chk1 = <>>~<0><1>

Check2         <c>~<chk2 = <>>~<0><1>

<L>

~menuclear

 

 

 

// button2.pan

@dialog

 

Button Example

 

Generate Noise <b>~~w0 := gnorm(1000, 0.001)

Generate Sin   <b x=-1 y=-1>~~w0 := gsin(1000, 0.001)

<L>

Check1         <c >~<chk1 = <>>~<0><1>

Check2         <c x=-1 y=-1>~<chk2 = <>>~<0><1>

<L>

~menuclear

 

 

 

 

By default, radio buttons stack vertically and a frame the width of the dialog box is drawn around the control.

 

// radio1.pan

@dialog

 

Generate Data

 

Function   <r>~gfunc = "<>"~<Grandom><Gsin>

<L>

~menuclear

~eval(sprintf("W0 := %s(1000, 0.001)", gfunc))

 

 

By adding a x location modifier, the frame the width of the control is drawn.

 

// radio2.pan

@dialog

 

Generate Data

 

Function   <r x=5>~gfunc = "<>"~<Grandom><Gsin>

<L>

~menuclear

~eval(sprintf("W0 := %s(1000, 0.001)", gfunc))

 

 

 

Adding the h modifier places the radio button controls horizontally.

 

// radio3.pan

@dialog

 

Generate Data

 

Function   <r h x=5>~gfunc = "<>"~<Grandom><Gsin>

<L>

~menuclear

~eval(sprintf("W0 := %s(1000, 0.001)", gfunc))

 

 

 

The <L> modifier draws a horizontal line and <> adds a horizontal space.

 

In general, it is preferable to position controls using relative positions by not specifying a position or with x=-1, y=-1 rather setting explicit positions. Relative positioning allows a dialog box to display automatically independent of the size and style of the dialog box font.