PGTRAPS.H

Go to the documentation of this file.
00001 
00002 /*  $Id: PGTRAPS.H 601 2006-03-04 22:58:40Z andreradke $    */
00003 
00004 /* This header file maps machine-specific OS calls to the respective function
00005 for the currently defined platform. */
00006 
00007 #ifndef PGTRAPS_H
00008 #define PGTRAPS_H
00009 
00010 #include "CPUDEFS.H"
00011 
00012 #ifndef PAIGE_H
00013 #include "PAIGE.H"
00014 #endif
00015 
00016 #define RIGHT_FONT_FLAG         0x8000      /* Font is right-to-left */
00017 #define NON_ROMAN_FLAG          0x4000      /* Font is not Roman */
00018 #define MULTIBYTE_FLAG          0x2000      /* Multibytes possible */
00019 #define SCRIPT_CODE_MASK        0x0FFF      /* Script type mask */
00020 
00021 #ifdef MAC_PLATFORM
00022 /*******************************************************************************/
00023 /*                                                                             */
00024 /*                              MACINTOSH                                      */
00025 /*                                                                             */
00026 /*******************************************************************************/
00027 
00028 /* Updated by TR Shaw, OITC, Inc. 28 Dec 1994 for complete Universal Headers
00029     support and added more universal character values */
00030 
00031 #ifndef THINK_C
00032 
00033 #if !TARGET_API_MAC_CARBON
00034 #include <Quickdraw.h>
00035 #include <Memory.h>
00036 #include <Events.h>
00037 #include <Fonts.h>
00038 //#include <Packages.h>     /* 2004-09-29 AR: unused */
00039 #include <OSUtils.h>
00040 #include <ToolUtils.h>
00041 #include <Resources.h>
00042 #include <Files.h>
00043 #include <MacErrors.h>      /* 2004-09-29 AR: renamed from errors.h */
00044 #include <Gestalt.h>
00045 #endif
00046 
00047 #endif
00048 
00049 #if !TARGET_API_MAC_CARBON
00050 #include <Script.h>
00051 #endif
00052 
00053 /*********** Memory Definitions (for allocation, resize, etc.) ***********/
00054 
00055 #define SYSTEM_7_VAL            0x0700
00056 
00057 #define DEF_GLOBAL_RESTYPE      'pgdf'      /* Default globals resource */
00058 #define DEF_GLOBAL_ID           128         /* Default globals res ID */
00059 
00060 #define MAC_STYLE_MASK          0x007F      /* Mask for Macintosh style bits */
00061 
00062 #define DEF_POINT_SIZE   (long) 0x000C      /* Default point size */
00063 #define DEF_CHAR_WIDTH   (long) 0x0000      /* Default font width (not used in Mac) */
00064 
00065 /* Special underline bits:  */
00066 
00067 #define DOTTED_PAT              0x8888      /* Dot pattern for underlines */
00068 #define HIDDEN_TEXT_PAT         0x55AA      /* Gray pattern (to bypass QD globals) */
00069 #define SPECIAL_SYMBOL_TXSIZE   12          /* Text size for invisible symbols */
00070 
00071 #define MAX_RGN                 32700       /* Tallest non-scrolling shape */
00072 #define MAX_SCROLLABLE_RGN      8192        /* Tallest shape for clipping */
00073 
00074 /* Default values for pg_globals. These get placed in the "globals" area at startup
00075 time if the default resource is not available.  */
00076 
00077 #define CR_CHAR             0x0D        /* Return char */
00078 #define SOFT_CR_CHAR        0x0A        /* Soft CR */
00079 #define TEXT_BRK_CHAR       0x1B        /* Alternate text break char */
00080 #define TAB_CHAR            0x09        /* Tab char */
00081 #define SOFT_HYPHEN         0x1F        /* Soft hyphen char */
00082 #define FF_CHAR             0x0C        /* Form feed char */
00083 #define CONTAINER_BRK_CHAR  0x0E        /* Container/column-break char */
00084 #define DELETE_CHAR         0x08        /* Delete character (backspace) */
00085 #define LEFT_ARROW          0x1C        /* Left arrow key */
00086 #define RIGHT_ARROW         0x1D        /* Right arrow key */
00087 #define UP_ARROW            0x1E        /* Up arrow key */
00088 #define DOWN_ARROW          0x1F        /* Down arrow key */
00089 #define FWD_DELETE_CHAR     0x7F        /* Forward Delete */
00090 #define DECIMAL_CHAR        0x2E        /* Decimal */
00091 #define HYPHEN_CHAR         0x2D        /* Hyphen */
00092 #define INVIS_TAB           0x13        /* Invisible tab char */
00093 #define INVIS_SPACE         0x2E        /* Invisible space char */
00094 #define INVIS_BREAK         0xAD        /* Invisible container break char */
00095 #define INVIS_PBREAK        0xAD        /* Invisible page break char */
00096 #define APOSTROPHE          0x27        /* Single quote (flat single quote) */
00097 #define FLAT_QUOTE_CHAR     0x22        /* Flat double quote char */
00098 #define LEFT_SINGLE_QUOTE   0xD4        /* Left single quote */
00099 #define RIGHT_SINGLE_QUOTE  0xD5        /* Right single quote */
00100 #define LEFT_DOUBLE_QUOTE   0xD2        /* Left double quote */
00101 #define RIGHT_DOUBLE_QUOTE  0xD3        /* Right double quote */
00102 #define INVIS_CR            0xA6        /* Invisible CR char */
00103 #define INVIS_LF            0xB9        /* Invisible soft cr char */
00104 #define INVIS_END           0xB0        /* Invisible end-of-doc char */
00105 #define INVIS_UNKNOWN       0xC9        /* Unknown symbol value */
00106 #define ELIPSE_SYMBOL       0xC9        /* elipse symbol */
00107 #define UNSUPPORTED_CHAR    0xC9        /* Symbol to use for unsupported characters */
00108 #define BULLET_CHAR         0xA5        /* Bullet character */
00109 
00110 #define MAX_OFFSCREEN       48000       /* Maximum offscreen size */
00111 
00112 #define MAX_TEXTBLOCK       4096        /* Maximum text block size */
00113 #define DEF_TAB_SPACE       24          /* Default tab space, in pixels */
00114 #define DEF_MIN_WIDTH       16          /* Default minimum line width */
00115 
00116 /* GrafPort preserver record (to save/restore GrafPort info): */
00117 
00118 struct port_preserve {
00119     GrafPtr             prev_port;      /* Previous port set */
00120     graf_device_ptr     last_device;    /* Previous device */
00121     RgnHandle           clip_rgn;       /* Preserved clip (or NULL) */
00122     Rect                simple_clip;    /* Clip (if just a rect) */
00123     Point               origin;         /* Preserves previous origin */
00124     PenState            pen_state;      /* Presevred pen state */
00125     short               text_mode;      /* Preserved text draw mode */
00126     short               text_font;      /* Preserved font */
00127     short               text_face;      /* Preserved style */
00128     short               text_size;      /* Preserved point */
00129     RGBColor            text_fg;        /* Foreground color */
00130     RGBColor            text_bk;        /* Background color */
00131     long                old_fg;         /* Old-world fg color */
00132     long                old_bk;         /* Old-word bk color */
00133 };
00134 
00135 typedef struct port_preserve port_preserve;
00136 typedef port_preserve PG_FAR *port_preserve_ptr;
00137 
00138 
00139 /* Mac index to "previous_items" */
00140 
00141 #define ORIGINAL_CLIP       0
00142 
00143 
00144 /***************************** Special struct & function macros *************************/
00145 
00146 
00147 #ifdef GLOBALS_ARE_PSTRINGS
00148 
00149 #define DRAW_SYMBOL(the_str) DrawString((StringPtr) the_str)
00150 #define MEASURE_SYMBOL(the_str) StringWidth((StringPtr) the_str)
00151 
00152 #else
00153 
00154 #define DRAW_SYMBOL(the_str) DrawText((Ptr) the_str, 0, global_char_size(the_str))
00155 #define MEASURE_SYMBOL(the_str) TextWidth((Ptr) the_str, 0, global_char_size(the_str))
00156 
00157 #endif
00158 
00159 /*** Mac-specific Utilities ***/
00160 
00161 #ifdef __cplusplus
00162 extern  "C" {
00163 #endif
00164 
00165 /* The following are linkable only if you have pgMacPictUtils in your project */
00166 
00167 extern PG_PASCAL (void) PictOutlineToShape (PicHandle pict, shape_ref target_shape,
00168         short accuracy);
00169 extern PG_PASCAL (void) RegionOutlineToShape (RgnHandle rgn, shape_ref target_shape,
00170         short accuracy); // From TRS/OITC
00171 
00172 extern PG_PASCAL (memory_ref) HandleToMemory (pgm_globals *mem_globals, Handle h, pg_short_t rec_size);
00173 extern PG_PASCAL (Handle) MemoryToHandle (memory_ref ref);
00174 
00175 /* Exception handling */
00176 
00177 extern PG_PASCAL (void) pgFailMemError( pgm_globals_ptr pgm_globals_p );
00178 
00179 #define PG_FAIL_MEM_ERROR()                                     \
00180         pgFailMemError( __pg_globals_p)
00181         
00182 #ifdef __cplusplus
00183     }
00184 #endif
00185 
00186 #endif  /* MAC_PLATFORM */
00187 
00188 
00189 
00190 #ifdef WINDOWS_PLATFORM
00191 /*******************************************************************************/
00192 /*                                                                             */
00193 /*                              WINDOWS                                        */
00194 /*                                                                             */
00195 /*******************************************************************************/
00196 
00197 #ifdef WINDOWS_EMULATE_COMPILE
00198 #include "WinMac.h"
00199 #else
00200 
00201 #ifdef WIN32_COMPILE
00202 #ifndef NO_STRICT
00203 #ifndef STRICT
00204 #define STRICT 1
00205 #endif
00206 #endif
00207 #endif
00208 #include <WINDOWS.H>
00209 #endif
00210 
00211 #include <string.h>
00212 
00213 #define DEF_POINT_SIZE   (long) 0x000C      /* Default point size */
00214 #define DEF_CHAR_WIDTH   (long) 0           /* Default font width */
00215 
00216 #define DOTTED_PAT              0x8888      /* Dot pattern for underlines */
00217 #define SPECIAL_SYMBOL_TXSIZE   12          /* Text size for invisible symbols */
00218 
00219 #define MAX_RGN                 32700       /* Tallest non-scrolling shape */
00220 #define MAX_SCROLLABLE_RGN      8192        /* Tallest shape for clipping */
00221 
00222 /* Default values for pg_globals. These get placed in the "globals" area at startup
00223 time if the default resource is not available.  */
00224 
00225 #define CR_CHAR             0x0D        /* Return char */
00226 #define SOFT_CR_CHAR        0x0A        /* Soft CR */
00227 #define TEXT_BRK_CHAR       0x1B        /* Alternate text break char */
00228 #define TAB_CHAR            0x09        /* Tab char */
00229 #define SOFT_HYPHEN         0x1F        /* Old soft hyphen char */
00230 #define PC_SOFT_HYPHEN      0xAD        /* PC's Soft hyphen char */
00231 #define FF_CHAR             0x0C        /* Form feed char */
00232 #define CONTAINER_BRK_CHAR  0x0E        /* Container/column-break char */
00233 #define DELETE_CHAR         0x08        /* Delete character (backspace) */
00234 #define LEFT_ARROW          0x1C        /* Left arrow key */
00235 #define RIGHT_ARROW         0x1D        /* Right arrow key */
00236 #define UP_ARROW            0x1E        /* Up arrow key */
00237 #define DOWN_ARROW          0x1F        /* Down arrow key */
00238 #define FWD_DELETE_CHAR     0x7F        /* Forward delete key */
00239 #define DECIMAL_CHAR        0x2E        /* Decimal */
00240 #define HYPHEN_CHAR         0x2D        /* Hyphen */
00241 #define ELIPSE_SYMBOL       0x85        /* Elipse symbol */
00242 #define INVIS_CR            0xB6        /* Invisible CR char */
00243 #define INVIS_LF            0xB5        /* Invisible soft cr char */
00244 #define INVIS_SPACE         0x2E        /* Invisible space char */
00245 #define INVIS_BREAK         0xA5        /* Invisible container break char */
00246 #define INVIS_PBREAK        0xA5        /* Invisible page break char */
00247 #define INVIS_END           0xB5        /* Invisible end-of-doc char */
00248 #define INVIS_UNKNOWN       0xC9        /* Unknown symbol value */
00249 #define APOSTROPHE          0x27        /* Single quote (flat single quote) */
00250 #define FLAT_QUOTE_CHAR     0x22        /* Flat double quote char */
00251 #define UNSUPPORTED_CHAR    0x83        /* Symbol to use for unsupported characters */
00252 
00253 #ifdef UNICODE
00254     #define INVIS_TAB           0x2022      /* Invisible tab char */
00255     #define LEFT_SINGLE_QUOTE   0x2018      /* Left single quote */
00256     #define RIGHT_SINGLE_QUOTE  0x2019      /* Right single quote */
00257     #define LEFT_DOUBLE_QUOTE   0x201C      /* Left double quote */
00258     #define RIGHT_DOUBLE_QUOTE  0x201D      /* Right double quote */
00259     #define BULLET_CHAR         0x2022      /* Bullet character */
00260 #else
00261     #define INVIS_TAB           0x95        /* Invisible tab char */
00262     #define LEFT_SINGLE_QUOTE   0x91        /* Left single quote */
00263     #define RIGHT_SINGLE_QUOTE  0x92        /* Right single quote */
00264     #define LEFT_DOUBLE_QUOTE   0x93        /* Left double quote */
00265     #define RIGHT_DOUBLE_QUOTE  0x94        /* Right double quote */
00266     #define BULLET_CHAR         0x95        /* Bullet character */
00267 #endif
00268 
00269 #define MAX_OFFSCREEN       48000       /* Maximum offscreen size */
00270 
00271 #define MAX_TEXTBLOCK       4096        /* Maximum text block size */
00272 #define DEF_TAB_SPACE       24          /* Default tab space, in pixels */
00273 #define DEF_MIN_WIDTH       16          /* Default minimum line width */
00274 
00275 /***************************** Special struct & function macros *************************/
00276 
00277 typedef RECT    Rect;
00278 typedef HRGN    RgnHandle;
00279 
00280 struct Point {
00281     short       v;              /* vertical */
00282     short       h;              /* horizontal */
00283 };                              /* machine-specific point */
00284 typedef struct Point Point;
00285 
00286 typedef HWND          GrafPtr;          /* Best equiv. to GrafPtr for WINDOWS */
00287 // typedef COLORREF      RGBColor;          /* Color value for Windows. */
00288 
00289 struct port_preserve {
00290     int                 saved_dc_index;      /* return value of SaveDC */
00291     graf_device_ptr     last_device;         /* Previous device in globals */
00292     RECT                rgn_box;            /* Original region rect of clip */
00293 };
00294 typedef struct port_preserve port_preserve;
00295 
00296 typedef struct platform_globals    platform_globals;
00297 typedef struct platform_globals PG_FAR *platform_globals_ptr;
00298 
00299 #define PLATFORM_SIG     0x1994
00300 
00301 
00302 #ifdef GLOBALS_ARE_PSTRINGS
00303 
00304 #define MEASURE_SYMBOL(the_str) (GetTextWidth(hdc, (pg_char_ptr)&the_str[1], global_char_size(the_str)) & 0x0000FFFF)
00305 
00306 #else
00307 
00308 #define MEASURE_SYMBOL(the_str) (GetTextWidth(hdc, (pg_char_ptr)the_str, global_char_size(the_str)) & 0x0000FFFF)
00309 
00310 #endif
00311 
00312 #ifdef WINDOWS_COMPILE
00313 #ifdef WIN16_COMPILE
00314 #define GetTextWidth(hdc, str, length) LOWORD(GetTextExtent(hdc, (PGSTR)str, (int)length))
00315 #else
00316 extern short GetTextWidth (HDC hdc, PGSTR str, int length);
00317 #endif
00318 #endif
00319 
00320 /* The font object tracking record (we keep these around to know what fonts have
00321 been built): */
00322 
00323 #ifdef UNICODE
00324 struct font_object_rec {
00325     long                the_font;           // The font object
00326     long                style_ptsize;       // Original point size from style_info
00327     LOGFONT             log;                // Style info stuff that made the font
00328 };
00329 #else
00330 struct font_object_rec {
00331     long                the_font;           // The font object
00332     long                style_ptsize;       // Original point size from style_info
00333     LOGFONT             log;                // Style info stuff that made the font
00334     pg_short_t          valid_widths;       // Widths are all valid
00335     int                 widths[256];        // Recorded character widths
00336 };
00337 #endif
00338 
00339 typedef struct font_object_rec font_object_rec;
00340 typedef font_object_rec PG_FAR *font_object_ptr;
00341 
00342 /* Flags for valid_widths: */
00343 
00344 #define CHARWIDTHS_COMPUTED     0x0001
00345 #define USE_TEMP_WIDTHS         0x0002
00346 
00347 /* Index values for graf_device.previous_items[] */
00348 
00349 #define PREVIOUS_FONT       0
00350 #define PREVIOUS_PALETTE    1
00351 #define PREVIOUS_BITMAP     2
00352 
00353 
00354 #ifdef __cplusplus
00355 extern  "C" {
00356 #endif
00357 
00358 extern PG_PASCAL (memory_ref) HandleToMemory (pgm_globals_ptr mem_globals, HANDLE h, pg_short_t rec_size);
00359 extern PG_PASCAL (HANDLE) MemoryToHandle (memory_ref ref);
00360 extern PG_PASCAL (void) SetFontCharWidths (pg_ref pg, style_info_ptr style, int PG_FAR *charwidths);
00361 
00362 
00363 #ifdef __cplusplus
00364     }
00365 #endif
00366 
00367 #endif  /* WINDOWS_PLATFORM */
00368 
00369 
00370 /********************** Generic Multi-platform Utilities ********************/
00371 
00372 
00373 #ifdef __cplusplus
00374 extern  "C" {
00375 #endif
00376 
00377 /* Rect / rectangle conversion functions:  */
00378 
00379 extern PG_PASCAL (void) RectToRectangle (Rect PG_FAR *r, rectangle_ptr pg_rect);
00380 extern PG_PASCAL (void) RectangleToRect (rectangle_ptr pg_rect, co_ordinate_ptr offset,
00381         Rect PG_FAR *r);
00382 
00383 /* Shape / Region functions:  */
00384 
00385 /* ShapeToRgn fills in a region to match a Paige shape. The resulting region
00386 is offset h and v. Note that regions are limited to 32K each side so the
00387 values are truncated as needed. It is scaled if scale_factor is non-NULL.
00388 ADDED JULY 20th for page_modify hook support, shape is intersected with "sect_rect"
00389 if non-null. */
00390 
00391 extern PG_PASCAL (void) ShapeToRgn (shape_ref src_shape, long offset_h, long offset_v,
00392         pg_scale_factor PG_FAR *scale_factor, short inset_amount,
00393         rectangle_ptr sect_rect, pg_region rgn);
00394 extern PG_PASCAL (void) ScaleRect (pg_scale_ptr scale_factor, Rect PG_FAR *r);
00395 
00396 #ifdef __cplusplus
00397     }
00398 #endif
00399 
00400 
00401 #endif  /* PGTRAPS_H */
00402 

Generated on Wed May 31 18:19:59 2006 for frontierkernel 10.1.10a by  doxygen 1.4.6