%wi enables the user to adjust and fix the exact position and size of every item in a window.
%wi provides a window with a unique user ID (for example, the value 10). The designed windows are stored in a .rcx file.
iw = winio@("%wi&", 10)
You enter a design mode by adding a tilde modifier (~), removing it to lock the design when finished:
iw = winio@("%~wi&", 10)
When you run the application with the tilde applied, you will be able to select items with a mouse click and move them
by dragging. If the Ctrl key is held down when clicking on an item then it remains selected and its size and position can be changed by
using the arrow keys:
- Right arrow - move to the right one pixel
- Left arrow - move to the left
- Up arrow - move up
- Down arrow - move down
With the Ctrl key applied:
- Right arrow - increase the width
- Left arrow - decrease the width
- Up arrow - increase the depth
- Down arrow - decrease the depth
With the Shift key applied, the pixel change is increased from 1 to 10. New controls can be dropped on to the window by selecting from a (right click) menu. These can be resized and repositioned. Also their properties can be changed from a one of three property dialogs:
- properties that are common to many controls. This includes the selection of a callback function, setting
text attributes, providing a "help" string, etc. (open this via the Ctrl+P accelerator key).
- for each control for properties that are not common. For example, for an integer edit box you can choose the
integer variable to associate with the control (open this via the RETURN accelerator key).
- properties of the control in response to the main window being resized (cf. %pv - Pivot format code).
This allows you to choose one or two "anchor" points at the corners of a control. A corner that is anchored maintains
its margin with respect to the main window as it is resized (open this dialog via the Ctrl+R accelerator key).
With the controls defined in a .rcx resource script, the only remaining requirement is to pass the associated
variables so that the window can be linked up with the Fortran code. For example, a %rd - Edit Integer format code has an associated
integer variable (N say) where the result is stored. Now that %rd - Edit Integer appears in the resource script and not in a winio@ call,
we need an independent way to pass N. New format codes are provided for this purpose:
iw = winio@("%qd[N]", N)
%qd is the new format code and [N] provides the name of the variable as it appears in the design process and in the
resulting .rcx resource script. It is natural to use N as the name of the variable N provided that it is unique when
designing, but any name can be used.
Other similar codes are illustrated by:
iw = winio@("%qf[X]", X) !double precision X
iw = winio@("%qs[STR]", STR) !character variable STR
iw = winio@("%qc[CB]", CB) !callback function CB
iw = winio@("%qh[HWND]",HWND) !Microsoft HANDLE HWND
iw = winio@("%12qd[ARR]",ARR) !an array of integers ARR(12)
iw = winio@("%*qd[ARR]",N,ARR) !an array of integers ARR(N)
iw = winio@("%12qs[STR]", STR) !a character variable array STR(12)
iw = winio@("%*qs[STR]", N,STR) !a character variable array STR(N)
When designing, you will be able to link to any of the variables that have been predefined in this way. In addition you
can link to any images that are already present in an associated .rc resource script (or the RESOURCES block of the FTN95
You can test a design without exiting design mode. Use the accelerator key Ctrl+T in order to run another instance
of the application in its finished (not designing) state. The new instance will start up on top of the design window.
Be careful to shut down the test before going back to designing.
When designing, you can allocate a popup menu to a given control. For this purpose, a new mechanism is provided for defining
a menu via calls to winio@...
%qi defines a named menu item together with its caption, callback and other attributes. %qm takes a list of these names and
groups them together to form a popup menu. Adding a grave accent, %`qm, allows you to provide a caption to the list with the
result that a popup menu becomes a "submenu". %qm can then be used to form the various kinds of menu that are needed as
iw = winio@("%~#?qi[iOpen][Open a file]", "Open", enable, check, cb)
| ||[iOpen]||iOpen is the design name of the item|
|[Open a file]||the help string (optional with the ? modifier)|
|"Open"||the caption for the menu item|
|enable||an integer variable controlling the grey state (optional with the ~ modifier)|
|check||an integer variable controlling the check state (optional with the # modifier)|
|cb||the associated callback function|
iw = winio@("%qm[Pop1]&", "iCopy,iPaste")
| ||Pop1||the name of the popup menu as it appears when designing|
|iCopy||the name of an existing "Copy" menu item|
|iPaste||the name of an existing "Paste" menu item|
The name #pm in %qm[#pm] is reserved and used to define the main popup menu (cf. %pm).
The name #sm in %qm[#sm] is reserved and used to define the systems menu add-on (cf. %sm).
The name #rm in %qm[#rm] is reserved and used to define the systems menu replacement (cf. %`sm).
A main menu can be defined like this:
w = winio@("%`qm[sm1]&", "File", "iOpen,|,iExit")
%`qm[sm1] provides a submenu, with name sm1, caption "File", and item list "iOpen,|,iExit".
The pipe symbol "|" provides a menu separator.
#mn is the reserved name for the main menu constructed from the list "sm1,sm2" of submenus (cf. %mn - Menu).
iw = winio@("%`qm[sm2]&", "Edit", "iCopy,iPaste")
iw = winio@("%qm[#mn]&", "sm1,sm2")
Enhanced menu are available as before by using %em - Enhanced Menu and by adding the name of an icon to a menu item caption.
Dynamic menus (where items are added at runtime by calling add_menu_item@) are constructed by using a %qi item name that
begins with an asterisk. For example the following uses the name *Extn:
iw = winio@("%qi[*Extn]&", hMenu)
iw = winio@("%`qm[sm1]&", "File", "iOpen,|,*Extn,|,iExit")
call add_menu_item@(hMenu, "File name 1", 1, 0, cb1)
Some additional points:
- Multiple items can be selected by holding down the Ctrl key.
- To resize the main window, you must now select "Resize the design" from the popup menu. Then the main window is given a thick frame which temporarily allows resizing
- A toolbar appears above the window and this allows you to take various actions. A right mouse click provides the same
actions via a popup menu. For example, if a single item is selected then "Align right" will move that item to the right
hand (%bd - Borders) border. Whilst if multiple items are selected then "Align right" will align all of the items with the first
item that was selected.
- The main window can be resized or moved but only its size is retained in the design.
Use a right mouse button click and select "Resize design" to enable resizing.
- The height of a list box or a combo box cannot be adjusted in this way.
- %mb - Multi-button Toolbar toolbars (see below) cannot be moved.
- Some items necessarily have a fixed width and height.
- A design session is ended by closing the window, using the x icon in the top right corner. You are prompted to save
your changes. The accelerator key Ctrl+S also provides a "save" action, whilst Ctrl+Z ends the session.
If your executable is named myapp.exe then design data is saved in a text file called myapp.rcx with the same path.
- When the design is complete, the ~ must be removed and the .rcx file may be added to the executable as a "LAYOUT" resource.
The value 1 and the keyword LAYOUT may not be changed.
1 LAYOUT "myapp.rcx"
- It is recommended that you use the tilde modifier with only one %wi window at a time and particularly when a window is a
%sh - Property Sheet child sheet for a %ps - Property Sheet Container tabbed control. For %ps, you can apply the %~wi to the main window in order to set its position
and size. Then (with %wi in the main window) use %~wi on any one of the %sh sheets in order to design the contents of
any of the sheets.
- If you want to add more items to a window after initial designing, then it is necessary to give each new item a unique ID
using a new format code %ci, otherwise the existing design data will not apply. For example...
iw = winio@("%ci&", 100)
gives this button the ID value of 100. Auto-generated IDs start at the value 300 so these must be avoided.
Alternatively new items and text can be added to the end of the winio@ list.
iw = winio@("%bt[OK]&, cb)
- All positioning format codes such as %nl, %ff - Form Feed, etc.
become redundant after designing and %ob - Open Box/%cb - Close Box box formats have limited use.
- %wi cannot be used with a MDI %fr - MDI Frame and is unlikely to be useful if the window can be resized at runtime.
- A new format code %gb[Group name] is available for use with %wi. It provides a group box that is similar to a single
%ob - Open Box/%cb - Close Box. For example..
iw = winio@("%gb[Group name]", wd, ht)
where wd and ht are integer values that provide the initial (pre-design) pixel width and height.
The %gb - Group box font, font size and font colour can be set in the usual way but a
%`bg background colour will only be applied to the group title.