Ideally, you want the majority of your positioning coordinates to be integer values. This is easier to work with and improves
portability. While you will undoubtedly encounter cases where you need to use non-integer coordinates, their use should be
The simplest solution is to use the same font for your graphical objects as you use in the text layer. Then, if you also use
unboxed entry fields, you have eliminated both trouble points. The problem with this solution is that it looks wrong when
compared to other graphical programs; the font is fixed-pitch and the boxes are missing.
A more sophisticated solution is to change the way that coordinates are measured. If you can set the coordinate space so that
your controls fall on integral coordinates, the problem is solved. ACUCOBOL-GT provides a way to do this. When you create
a window (including the main application window), you can set its cell size with the CELL phrase of the DISPLAY WINDOW verb.
When you do this, you specify your own line and column sizes. The phrase allows you to have the run-time system measure a
graphical object and set the coordinate space appropriately. Typically, you would measure an entry field with the font you
want to use and have the run-time system lay out the screen accordingly. For details on the CELL phrase, see Format 11 DISPLAY FLOATING WINDOW.
Note: When you change the coordinate space, you affect both the text and graphical layers. Because of this, you have some restrictions
if you are going to use the text layer. In particular, you may not make a cell smaller than a character, nor may you make
it wider than a character (it can be taller).
Here are some general guidelines to apply when deciding how to set up your coordinate space:
- If you plan to mix graphical objects with classical textual displays, use the default cell size that is the size of the text-layer
font. In this case, the overriding consideration is the placement of the text in cells. The graphical objects will have to
be specified with whatever coordinates work. You should try to keep the number of graphical objects to a minimum, or consider
converting to an entirely graphical screen if you want to mix in a large number of graphical elements.
- If you anticipate using entry fields heavily (as would be typical in a conversion of a text-based application), you should
set up the coordinate space based on the size of an entry field. This makes the placement of label and entry-field pairs very
easy. Note that the CELL phrase allows you to specify OVERLAPPED (vertically adjacent entry fields share a common border)
or SEPARATE (a little space placed between entry fields). You can choose whichever style you think looks better. Here is an
example CELL phrase:
CELL SIZE = ENTRY-FIELD FONT MY-FONT, SEPARATE
- If you will be using a mix of graphical objects, but only a few entry fields, you should base the coordinate space on the
size of a label. This lets you measure with the correct font, but ignores the overhead associated with entry fields. This
setting is closest to what other graphical-design systems use (typically, these use a coordinate cell size that is some fraction
of the size of the system's font). A typical CELL phrase would be:
CELL SIZE = LABEL FONT MY-FONT
Another way to get the same result is to use the GRAPHICAL phrase with the DISPLAY WINDOW verb. For example:
DISPLAY STANDARD GRAPHICAL WINDOW
- If you want to compute exact pixel coordinates (for very specialized displays), you should use a cell height and width of
10. Then each tenth of a cell (.1) corresponds to one pixel.
Note: You should not use 1 as the cell height and width because this produces a text-layer memory map that is too large. Applications that use 1 as a measure are not portable to non-graphical systems.
- Finally, it is possible to set up your graphical control sizes based entirely on the pixel count. You can specify the 'x'
and 'y' coordinates, LINES, and SIZE of a control in pixels. This method allows you to always have your positioning coordinates
as integer values, which is nice when you need absolute positioning. You gain better control of your screen layouts, and screens
based on different cell sizes can easily be accommodated by the screen designer.
A sample DISPLAY statement would look like this:
DISPLAY PUSH-BUTTON LINE 300 PIXEL(S)
COL 225 PIXEL(S)
LINES 30 PIXEL(S)
SIZE 120 PIXEL(S).
Note: Pixel coordinates are relative to the size of the target window. The lowest legal value is '1', and the highest legal value
is equal to the largest resolution covered by the target window. If that value is exceeded, the property defaults to the closest
It is important to set your coordinate space early in your work. If you lay out screens and then change the coordinate system,
all of your previously designed screens will have to be reworked.
Because of the fundamental differences in the coordinate systems of character and graphical systems, ACUCOBOL-GT provides
two sets of statement phrases with which to specify control size and positioning. See The Character Coordinate Phrases for a discussion of these phrases.