Pixel and character positioning

In Sculptor 5, windows and objects can be positioned using a pixel grid. In previous versions character positioning was used. Sculptor 5 supports character positioning, but it is recommended that programs are converted to pixel positioning, which allows far greater accuracy.

In pixel positioning, the x and y co-ordinates represent numbers of horizontal and vertical pixels.

In character positioning, the x and y co-ordinates represent numbers of columns and rows.

The !chargrid declaration is used in Sculptor 5 to specify the grid being used. Both position and size are affected. The following example shows the code for a window and button on a character grid, and then the same code after conversion to a pixel grid:

!chargrid ON
+window Window1 at 19,7 {
     max_width = 30
     max_height = 10
     +button Button1 at 4,1 {
          label = "Button1"
     }
}

!chargrid OFF
+window Window1 at 152,133 {
     max_width = 246
     max_height = 215
     +button Button1 at 32,19 {
          label = "Button1"
     }
}

A set of functions that convert a pixel position to or from the character equivalent is provided .


Converting to pixel positioning

An automatic conversion procedure from character positioning to pixel positioning is provided. There is no automatic conversion back from pixel to character. It is therefore very important that all source files are backed up before the conversion process.

To convert a suite of programs to pixel positioning, follow these steps:

1

Edit every include file in the suite, appending the line !ctp (convert to pixels). It is not necessary to add this line to include files that contain no windows, but it does no harm to do so. Do not add !ctp to top-level program files (.f and .r).

2

Ensure that all include files that contain !ctp can be updated - i.e. that they are not read-only. Note that the screen designer, which performs the conversion, treats include files in angled brackets (<>) as read-only. The angled brackets indicate that the file is located in the standard Sculptor include directory $SCULPTOR/include. If it is necessary to convert a file in this directory, use the full path name to declare the file. See !include. The include files provided by Sculptor in this directory are lists of !defines and contain no windows.

3

The programs must now be converted before they can be recompiled, because the compiler does not recognise the line !ctp.

To convert a program from characters to pixels, load the main source file (.f or .r). into the Sculptor program designer. Select the menu option Options->Positioning->Pixel. A dialog opens asking whether or not to convert the program to pixel positioning. Say Yes. All windows and controls in the main program file, and in the include files that contain !ctp, are converted, by changing window and object positions from the character value to the corresponding pixel value The !ctp lines are then removed, in order to prevent the include files from being converted again when processed in the conversion of another program.

4

Repeat Step 3 for all top-level programs.

5

Recompile the programs. Programs using pixel positioning must be compiled using scc version 5.0 Beta 4 or later. All earlier versions of the compiler assume a character grid. The Sculptor 5 compiler assumes a pixel grid as the default. See !chargrid for details of how to use this declaration to override the default where necessary.

All positions and sizes in window and control definitions are converted. Defined values, and values coded into the program logic, must be converted manually.

In order to aid the process of converting by hand, the at command still works in characters. The equivalent command in pixels is move cursor to.

The move command now works in pixels. The new command charmove, which works in characters, is the equivalent of the old move. To make unconverted programs run as previously, either modify the co-ordinates of existing move commands or change the commands to charmove.


RELATED TOPICS

Pixel/character conversion functions

!chargrid