Measurements and Coordinates

The PageMaker application permits very precise positioning of items in a publication. In your plug-in, you may need to specify the location of items on a page or the pasteboard, or you may receive location information from PageMaker. This page describes how measurements and coordinate systems work in PageMaker.

Twips

All units of measurement in PageMaker are done in units called twips. A twip is defined as a twentieth (1/20) of a pica point.

Regardless of whether the user selects inches, millimeters, picas, or points for a publication, PageMaker represents and stores all measurement information in twips. Likewise, plug-ins use twips to represent units of measure.

Converting to/from twips

There are two ways to easily convert twips to or from the other units: using PGetConvertStr and PGetConvertTwips query objects or manually converting with numeric constants.

Using PGetConvertStr and PGetConvertTwips

Throughout this documentation, you will see a function named twips( ) that converts common units of measurement into twips. This simple wrapper function is based on the PGetConvertStr query, and is shown below. This twips( ) function is included in the SDK in the file "Twips.cpp".

long twips(const char * ch)
{
    try {
        PGetConvertStr toTwips(ch, kParmDontCare);
        return (long) toTwips;
    }
    catch (PMErr) {
       return 0;
    };
}

An example of this function:

long len = twips("3i"); // convert 3 inches to twips
PNudge(len, 0); // nudge the selected object three inches to the right.

PGetConvertTwips provides the opposite translation: given a long value representing twips, it returns a character string in the specified units.

long x = 2880;
PGetConvertTwips xInInches(x, kMeasurementInches);
cout << (const char *) xInInches;
// output: "2i"

Manually converting twips

Alternatively, when working directly with numeric types, you can use the following constants to convert to/from twips without using twips( ) or PGetConvertStr. This may improve performance in situations where your plug-in is doing a large number of measurement conversions.

Units Ratio
Twips per Inch 1440
Twips per Centimeter 72000 / 127
Twips per Millimeter 7200 / 127
Twips per PicaPoint 20
Twips per Pica 240
Twips per Cicero 6394 / 25
Twips per Didot 12000 / 563

The PageMaker pasteboard

A PageMaker publication is always presented to the user on the pasteboard. The pasteboard is a large work area on which the the page is displayed and on which the user can construct elements before placing them on the page.

PageMaker has a coordinate system in which any location on the pasteboard can be expressed. This is referred to as the world coordinate system. Locations and measurements in the world coordinate system are always expressed in twips.

This figure shows the PageMaker coordinate system. The origin for the world coordinate system is in the center of the pasteboard. The x axis has positive values to the right of the origin and the y axis has positive values toward the bottom of the pasteboard.

Pasteboard

The PageMaker SDK uses the WCPOINT type for variables that express points in the world coordinate system. The WCPOINT type is defined as:

typedef short WC; // World Coordinates
typedef struct __WCPOINT {
WC x;
WC y;
} WCPOINT, DCPOINT, *LPWCPOINT, *LPDCPOINT;

Since the WCPOINT holds the x and y values of a location in short (16 bit) fields, it is sufficient for expressing locations within the coordinate system (-32,768 to 32,767), but a larger type is needed for measurements that are not based on the origin (The width of the pasteboard, in twips, is 65,535 too large to be held in a short.) For the occasions that a larger type is needed we use LONGPOINT:

typedef struct __LONGPOINT {
long x;
long y;
} LONGPOINT, *LPLONGPOINT;

A third type that you will need to be familiar with when working with the world coordinate sytem is the RECT:

typedef struct _RECT {
long left;
long top;
long right;
long bottom;
} RECT;

This type is used for storing two points, usually representing the upper-left and lower-right corners of a region.

Screen coordinates

The screen coordinate system has its origin in the upper-right hand corner of the screen. The positive values on the x axis lead to the right of the sceen, and the positive values on the y axis lead to the bottom of the screen.

The CIBasic interface provides member functions for converting world coordinates to screen coordinates and back.


Comments or suggestions? Contact Adobe Developer Support
Copyright © 1997 - 2001 Adobe Systems Incorporated. All rights reserved.
Legal notices and trademark attributions