home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / tk42r2x.zip / TclTk / lib / tkOS2Int.h < prev    next >
C/C++ Source or Header  |  1999-07-27  |  17KB  |  444 lines

  1. /*
  2.  * tkOS2Int.h --
  3.  *
  4.  *    Declarations of OS/2 PM specific shared variables and procedures.
  5.  *
  6.  * Copyright (c) 1996-1997 Illya Vaes
  7.  * Copyright (c) 1995 Sun Microsystems, Inc.
  8.  *
  9.  * See the file "license.terms" for information on usage and redistribution
  10.  * of this file, and for a DISCLAIMER OF ALL WARRANTIES.
  11.  *
  12.  */
  13.  
  14. #ifndef _OS2INT
  15. #define _OS2INT
  16.  
  17. #ifndef _TKINT
  18. #include "tkInt.h"
  19. #endif
  20.  
  21. #define INCL_BASE
  22. #define INCL_PM
  23. #include <os2.h>
  24. #undef INCL_PM
  25. #undef INCL_BASE
  26.  
  27. #ifndef OS2
  28. #define OS2
  29. #endif
  30.  
  31. /*
  32.  * A data structure of the following type holds information for
  33.  * each window manager protocol (such as WM_DELETE_WINDOW) for
  34.  * which a handler (i.e. a Tcl command) has been defined for a
  35.  * particular top-level window.
  36.  */
  37.  
  38. typedef struct ProtocolHandler {
  39.     Atom protocol;        /* Identifies the protocol. */
  40.     struct ProtocolHandler *nextPtr;
  41.                 /* Next in list of protocol handlers for
  42.                  * the same top-level window, or NULL for
  43.                  * end of list. */
  44.     Tcl_Interp *interp;        /* Interpreter in which to invoke command. */
  45.     char command[4];        /* Tcl command to invoke when a client
  46.                  * message for this protocol arrives. 
  47.                  * The actual size of the structure varies
  48.                  * to accommodate the needs of the actual
  49.                  * command. THIS MUST BE THE LAST FIELD OF
  50.                  * THE STRUCTURE. */
  51. } ProtocolHandler;
  52.  
  53. #define HANDLER_SIZE(cmdLength) \
  54.     ((unsigned) (sizeof(ProtocolHandler) - 3 + cmdLength))
  55.  
  56. /*
  57.  * A data structure of the following type holds window-manager-related
  58.  * information for each top-level window in an application.
  59.  */
  60.  
  61. typedef struct TkWmInfo {
  62.     TkWindow *winPtr;        /* Pointer to main Tk information for
  63.                  * this window. */
  64.     Window reparent;            /* This is the decorative frame window
  65.                                  * created by the window manager to wrap
  66.                                  * a toplevel window.  This window is
  67.                                  * a direct child of the root window. */
  68.     Tk_Uid titleUid;        /* Title to display in window caption.  If
  69.                  * NULL, use name of widget. */
  70.     Tk_Uid iconName;        /* Name to display in icon. */
  71.     Window master;        /* Master window for TRANSIENT_FOR property,
  72.                  * or None. */
  73.     XWMHints hints;        /* Various pieces of information for
  74.                  * window manager. */
  75.     Tk_Uid leaderName;        /* Path name of leader of window group
  76.                  * (corresponds to hints.window_group).
  77.                  * Note:  this field doesn't get updated
  78.                  * if leader is destroyed. */
  79.     Tk_Uid masterWindowName;    /* Path name of window specified as master
  80.                  * in "wm transient" command, or NULL.
  81.                  * Note:  this field doesn't get updated if
  82.                  * masterWindowName is destroyed. */
  83.     Tk_Window icon;        /* Window to use as icon for this window,
  84.                  * or NULL. */
  85.     Tk_Window iconFor;        /* Window for which this window is icon, or
  86.                  * NULL if this isn't an icon for anyone. */
  87.     int withdrawn;        /* Non-zero means window has been withdrawn. */
  88.  
  89.     /*
  90.      * Information used to construct an XSizeHints structure for
  91.      * the window manager:
  92.      */
  93.  
  94.     int defMinWidth, defMinHeight, defMaxWidth, defMaxHeight;
  95.                                 /* Default resize limits given by system. */
  96.     int sizeHintsFlags;        /* Flags word for XSizeHints structure.
  97.                  * If the PBaseSize flag is set then the
  98.                  * window is gridded;  otherwise it isn't
  99.                  * gridded. */
  100.     int minWidth, minHeight;    /* Minimum dimensions of window, in
  101.                  * grid units, not pixels. */
  102.     int maxWidth, maxHeight;    /* Maximum dimensions of window, in
  103.                  * grid units, not pixels, or 0 to default. */
  104.     Tk_Window gridWin;        /* Identifies the window that controls
  105.                  * gridding for this top-level, or NULL if
  106.                  * the top-level isn't currently gridded. */
  107.     int widthInc, heightInc;    /* Increments for size changes (# pixels
  108.                  * per step). */
  109.     struct {
  110.     int x;    /* numerator */
  111.     int y;  /* denominator */
  112.     } minAspect, maxAspect;    /* Min/max aspect ratios for window. */
  113.     int reqGridWidth, reqGridHeight;
  114.                 /* The dimensions of the window (in
  115.                  * grid units) requested through
  116.                  * the geometry manager. */
  117.     int gravity;        /* Desired window gravity. */
  118.  
  119.     /*
  120.      * Information used to manage the size and location of a window.
  121.      */
  122.  
  123.     int width, height;        /* Desired dimensions of window, specified
  124.                  * in grid units.  These values are
  125.                  * set by the "wm geometry" command and by
  126.                  * ConfigureNotify events (for when wm
  127.                  * resizes window).  -1 means user hasn't
  128.                  * requested dimensions. */
  129.     int x, y;            /* Desired X and Y coordinates for window.
  130.                  * These values are set by "wm geometry",
  131.                  * plus by ConfigureNotify events (when wm
  132.                  * moves window).  These numbers are
  133.                  * different than the numbers stored in
  134.                  * winPtr->changes because (a) they could be
  135.                  * measured from the right or bottom edge
  136.                  * of the screen (see WM_NEGATIVE_X and
  137.                  * WM_NEGATIVE_Y flags) and (b) if the window
  138.                  * has been reparented then they refer to the
  139.                  * parent rather than the window itself. */
  140.     int xInParent, yInParent;    /* Offset of window within reparent,  measured
  141.                  * from upper-left outer corner of parent's
  142.                  * border to upper-left outer corner of child's
  143.                  * border.  If not reparented then these are
  144.                  * zero. */
  145.     int borderWidth, borderHeight;
  146.                                 /* Width and height of window dressing, in
  147.                                  * pixels for the current style/exStyle.  This
  148.                                  * includes the border on both sides of the
  149.                                  * window. */
  150.     int configWidth, configHeight;
  151.                 /* Dimensions passed to last request that we
  152.                  * issued to change geometry of window.  Used
  153.                  * to eliminate redundant resize operations. */
  154.     long style;            /* Window style of reparent. */
  155.     long exStyle;               /* Window exStyle of reparent. */
  156.  
  157.     /*
  158.      * List of children of the toplevel which have private colormaps.
  159.      */
  160.  
  161.     TkWindow **cmapList;    /* Array of window with private colormaps. */
  162.     int cmapCount;        /* Number of windows in array. */
  163.  
  164.     /*
  165.      * Miscellaneous information.
  166.      */
  167.  
  168.     ProtocolHandler *protPtr;    /* First in list of protocol handlers for
  169.                  * this window (NULL means none). */
  170.     int cmdArgc;        /* Number of elements in cmdArgv below. */
  171.     char **cmdArgv;        /* Array of strings to store in the
  172.                  * WM_COMMAND property.  NULL means nothing
  173.                  * available. */
  174.     char *clientMachine;    /* String to store in WM_CLIENT_MACHINE
  175.                  * property, or NULL. */
  176.     int flags;            /* Miscellaneous flags, defined below. */
  177.     struct TkWmInfo *nextPtr;    /* Next in list of all top-level windows. */
  178. } WmInfo;
  179.  
  180. /*
  181.  * Flag values for WmInfo structures:
  182.  *
  183.  * WM_NEVER_MAPPED -        non-zero means window has never been
  184.  *                mapped;  need to update all info when
  185.  *                window is first mapped.
  186.  * WM_UPDATE_PENDING -        non-zero means a call to UpdateGeometryInfo
  187.  *                has already been scheduled for this
  188.  *                window;  no need to schedule another one.
  189.  * WM_NEGATIVE_X -        non-zero means x-coordinate is measured in
  190.  *                pixels from right edge of screen, rather
  191.  *                than from left edge.
  192.  * WM_NEGATIVE_Y -        non-zero means y-coordinate is measured in
  193.  *                pixels up from bottom of screen, rather than
  194.  *                down from top.
  195.  * WM_UPDATE_SIZE_HINTS -       non-zero means that new size hints need to be
  196.  *                              propagated to window manager.
  197.  * WM_SYNC_PENDING -        set to non-zero while waiting for the window
  198.  *                manager to respond to some state change.
  199.  * WM_MOVE_PENDING -        non-zero means the application has requested
  200.  *                a new position for the window, but it hasn't
  201.  *                been reflected through the window manager
  202.  *                yet.
  203.  * WM_COLORAMPS_EXPLICIT -    non-zero means the colormap windows were
  204.  *                set explicitly via "wm colormapwindows".
  205.  * WM_ADDED_TOPLEVEL_COLORMAP - non-zero means that when "wm colormapwindows"
  206.  *                was called the top-level itself wasn't
  207.  *                specified, so we added it implicitly at
  208.  *                the end of the list.
  209.  */
  210.  
  211. #define WM_NEVER_MAPPED            (1<<0)
  212. #define WM_UPDATE_PENDING        (1<<1)
  213. #define WM_NEGATIVE_X            (1<<2)
  214. #define WM_NEGATIVE_Y            (1<<3)
  215. #define WM_UPDATE_SIZE_HINTS        (1<<4)
  216. #define WM_SYNC_PENDING            (1<<5)
  217. #define WM_CREATE_PENDING        (1<<6)
  218. #define WM_MOVE_PENDING            (1<<7)
  219. #define WM_COLORMAPS_EXPLICIT        (1<<8)
  220. #define WM_ADDED_TOPLEVEL_COLORMAP    (1<<9)
  221. #define WM_WIDTH_NOT_RESIZABLE        (1<<10)
  222. #define WM_HEIGHT_NOT_RESIZABLE        (1<<11)
  223.  
  224. /*
  225.  * Window styles for various types of toplevel windows.
  226.  */
  227.  
  228. #define WM_TOPLEVEL_STYLE (WS_CLIPCHILDREN|WS_CLIPSIBLINGS)
  229. #define WM_OVERRIDE_STYLE (WS_CLIPCHILDREN|WS_CLIPSIBLINGS)
  230. #define WM_TRANSIENT_STYLE (WS_CLIPCHILDREN|WS_CLIPSIBLINGS)
  231. /* Force positioning on Tk-specified coordinates: turn off byte-alignment */
  232. #define EX_TOPLEVEL_STYLE (FCF_NOBYTEALIGN|FCF_TITLEBAR|FCF_SIZEBORDER|FCF_MINMAX|FCF_SYSMENU|FCF_TASKLIST)
  233. #define EX_OVERRIDE_STYLE (FCF_NOBYTEALIGN|FCF_BORDER)
  234. #define EX_TRANSIENT_STYLE (FCF_NOBYTEALIGN|FCF_DLGBORDER|FCF_TITLEBAR)
  235.  
  236.  
  237. /*
  238.  * The TkOS2PSState is used to save the state of a presentation space
  239.  * so that it can be restored later.
  240.  */
  241.  
  242. typedef struct TkOS2PSState {
  243.     HPAL palette;
  244.     HBITMAP bitmap;
  245. } TkOS2PSState;
  246.  
  247.  
  248. /*
  249.  * The TkOS2Drawable is the internal implementation of an X Drawable (either
  250.  * a Window or a Pixmap).  The following constants define the valid Drawable
  251.  * types.
  252.  */
  253.  
  254. #define TOD_BITMAP    1
  255. #define TOD_WINDOW    2
  256. #define TOD_WM_WINDOW    3
  257.  
  258. /* Tk OS2 Window Classes */
  259. #define TOC_TOPLEVEL    "TkTopLevel"
  260. #define TOC_CHILD    "TkChild"
  261.  
  262. #define CW_USEDEFAULT    0
  263.  
  264. /* Defines for which poly... function */
  265. #define TOP_POLYGONS    1
  266. #define TOP_POLYLINE    2
  267.  
  268. /* OS/2 system constants */
  269. #define MAX_LID    254
  270.  
  271. /*
  272.  * Override PM resolution for 120dpi displays with the following value if
  273.  * IGNOREPMRES is defined. Requested by Ilya Zakharevich
  274.  */
  275. #ifdef IGNOREPMRES
  276.     extern LONG overrideResolution;
  277. #endif
  278.  
  279. #define MAX(a,b)    ( (a) > (b) ? (a) : (b) )
  280. #define MIN(a,b)    ( (a) < (b) ? (a) : (b) )
  281.  
  282. typedef struct {
  283.     int type;
  284.     HWND handle;
  285.     TkWindow *winPtr;
  286. } TkOS2Window;
  287.  
  288. typedef struct {
  289.     int type;
  290.     HBITMAP handle;
  291.     Colormap colormap;
  292.     int depth;
  293.     HWND parent;
  294.     HDC dc;
  295.     HPS hps;
  296. } TkOS2Bitmap;
  297.     
  298. typedef union {
  299.     int type;
  300.     TkOS2Window window;
  301.     TkOS2Bitmap bitmap;
  302. } TkOS2Drawable;
  303.  
  304. /*
  305.  * The following macros are used to retrieve internal values from a Drawable.
  306.  */
  307. #define TkOS2GetHWND(w) (((TkOS2Drawable *)w)->window.handle)
  308. #define TkOS2GetWinPtr(w) (((TkOS2Drawable*)w)->window.winPtr)
  309. #define TkOS2GetHBITMAP(w) (((TkOS2Drawable*)w)->bitmap.handle)
  310. #define TkOS2GetColormap(w) (((TkOS2Drawable*)w)->bitmap.colormap)
  311.  
  312. /*
  313.  * The following macros are used to replace the Windows equivalents.
  314.  */
  315. #define RGB(R,G,B)       ((((ULONG)R)<<16) + (((ULONG)G)<<8) + (ULONG)B)
  316. #define RGBFlag(F,R,G,B) ((((ULONG)F)<<24) + (((ULONG)R)<<16) + (((ULONG)G)<<8) + (ULONG)B)
  317. #define GetFlag(RGB)     ((BYTE)(RGB>>24))
  318. /*
  319. #define GetRValue(RGB)   ((BYTE)((RGB & 0xFF0000)>>16))
  320. #define GetGValue(RGB)   ((BYTE)((RGB & 0x00FF00)>>8))
  321. */
  322. #define GetRValue(RGB)   ((BYTE)((RGB>>16) & 0x0000FF))
  323. #define GetGValue(RGB)   ((BYTE)((RGB>>8) & 0x0000FF))
  324. #define GetBValue(RGB)   ((BYTE)(RGB & 0x0000FF))
  325.  
  326. /*
  327.  * The following structure is used to encapsulate palette information.
  328.  */
  329.  
  330. typedef struct {
  331.     HPAL palette;        /* Palette handle used when drawing. */
  332.     ULONG size;            /* Number of entries in the palette. */
  333.     int stale;            /* 1 if palette needs to be realized,
  334.                  * otherwise 0.  If the palette is stale,
  335.                  * then an idle handler is scheduled to
  336.                  * realize the palette. */
  337.     Tcl_HashTable refCounts;    /* Hash table of palette entry reference counts
  338.                  * indexed by pixel value. */
  339. } TkOS2Colormap;
  340.  
  341. /*
  342.  * The following structure is used to remember font attributes that cannot be
  343.  * given to GpiCreateLogFont via FATTRS.
  344.  */
  345.  
  346. typedef struct {
  347.     FATTRS fattrs;    /* FATTRS structure */
  348.     POINTL shear;    /* Shear (angle) of characters, GpiSetCharShear */
  349.     BOOL setShear;    /* Should shear be changed after GpiCreateLogFont? */
  350.     BOOL outline;    /* Is this an outline font */
  351.     ULONG deciPoints;    /* Pointsize for outline font, in decipoints */
  352.     FONTMETRICS fm;    /* Fontmetrics, for concentrating outline font stuff */
  353. } TkOS2Font;
  354.  
  355. /*
  356.  * The following structures are used to mimic the WINDOWPOS structure that has
  357.  * fields for minimum and maximum width/height.
  358.  */
  359.  
  360. typedef struct {
  361.     LONG x;
  362.     LONG y;
  363. } TkOS2TrackSize;
  364. typedef struct {
  365.     TkOS2TrackSize ptMinTrackSize;
  366.     TkOS2TrackSize ptMaxTrackSize;
  367.     SWP swp;
  368. } TkOS2WINDOWPOS;
  369.  
  370. /*
  371.  * The following macro retrieves the PM palette from a colormap.
  372.  */
  373.  
  374. #define TkOS2GetPalette(colormap) (((TkOS2Colormap *) colormap)->palette)
  375.  
  376. /*
  377.  * Internal procedures used by more than one source file.
  378.  */
  379.  
  380. extern MRESULT EXPENTRY TkOS2ChildProc _ANSI_ARGS_((HWND hwnd, ULONG message,
  381.                             MPARAM param1, MPARAM param2));
  382. extern void        TkOS2ClipboardRender _ANSI_ARGS_((TkWindow *winPtr,
  383.                             ULONG format));
  384. extern void             TkOS2EnterModalLoop _ANSI_ARGS_((Tcl_Interp * interp));
  385. extern HAB         TkOS2GetAppInstance _ANSI_ARGS_((void));
  386. extern HPS        TkOS2GetDrawablePS _ANSI_ARGS_((Display *display,
  387.                 Drawable d, TkOS2PSState* state));
  388. extern TkOS2Drawable *    TkOS2GetDrawableFromHandle _ANSI_ARGS_((HWND hwnd));
  389. extern unsigned int    TkOS2GetModifierState _ANSI_ARGS_((ULONG message,
  390.                 USHORT flags, MPARAM param1, MPARAM param2));
  391. extern HPAL        TkOS2GetSystemPalette _ANSI_ARGS_((void));
  392. extern HMODULE        TkOS2GetTkModule _ANSI_ARGS_((void));
  393. extern void             TkOS2LeaveModalLoop _ANSI_ARGS_((Tcl_Interp * interp));
  394. extern void        TkOS2PointerDeadWindow _ANSI_ARGS_((TkWindow *winPtr));
  395. extern void        TkOS2PointerEvent _ANSI_ARGS_((XEvent *event,
  396.                             TkWindow *winPtr));
  397. extern void        TkOS2PointerInit _ANSI_ARGS_((void));
  398. extern void        TkOS2ReleaseDrawablePS _ANSI_ARGS_((Drawable d,
  399.                 HPS hps, TkOS2PSState* state));
  400. extern HPAL        TkOS2SelectPalette _ANSI_ARGS_((HPS hps, HWND hwnd,
  401.                             Colormap colormap));
  402. extern MRESULT EXPENTRY TkOS2FrameProc _ANSI_ARGS_((HWND hwnd, ULONG message,
  403.                             MPARAM param1, MPARAM param2));
  404. extern void        TkOS2UpdateCursor _ANSI_ARGS_((TkWindow *winPtr));
  405. extern void        TkOS2WmConfigure _ANSI_ARGS_((TkWindow *winPtr,
  406.                             SWP *pos));
  407. extern int        TkOS2WmInstallColormaps _ANSI_ARGS_((HWND hwnd,
  408.                 int message, int isForemost));
  409. extern void        TkOS2WmSetLimits _ANSI_ARGS_((HWND hwnd,
  410.                             TRACKINFO *info));
  411. extern void         TkOS2XInit _ANSI_ARGS_((HAB hInstance));
  412. extern void         TkOS2InitPM _ANSI_ARGS_((void));
  413. extern void         TkOS2ExitPM _ANSI_ARGS_((void));
  414. extern LONG        TkOS2WindowHeight _ANSI_ARGS_ ((TkOS2Drawable *todPtr));
  415. extern LONG        TkOS2WindowWidth _ANSI_ARGS_ ((TkOS2Drawable *todPtr));
  416. extern char        *TkOS2ReverseImageLines _ANSI_ARGS_ ((XImage *image, int height));
  417. extern BOOL        TkOS2ScaleFont _ANSI_ARGS_ ((HPS hps, ULONG pointSize,
  418.                 ULONG pointWidth));
  419.  
  420. /* Global variables */
  421. extern HAB hab;    /* Anchor block */
  422. extern HMQ hmq;    /* message queue */
  423. extern LONG aDevCaps[];    /* Device caps */
  424. extern LONG nextLogicalFont;    /* First free logical font ID */
  425. extern PFNWP oldFrameProc;    /* subclassed frame procedure */
  426. extern LONG xScreen;        /* System Value Screen width */
  427. extern LONG yScreen;        /* System Value Screen height */
  428. extern LONG titleBar;        /* System Value Title Bar */
  429. extern LONG xBorder;        /* System Value X nominal border */
  430. extern LONG yBorder;        /* System Value Y nominal border */
  431. extern LONG xSizeBorder;    /* System Value X Sizing border */
  432. extern LONG ySizeBorder;    /* System Value Y Sizing border */
  433. extern LONG xDlgBorder;        /* System Value X dialog-frame border */
  434. extern LONG yDlgBorder;        /* System Value Y dialog-frame border */
  435. extern HDC hScreenDC;        /* Device Context for screen */
  436. extern HPS globalPS;        /* Global PS */
  437. extern HBITMAP globalBitmap;    /* Bitmap for global PS */
  438. extern TkOS2Font logfonts[];    /* List of logical fonts */
  439. extern LONG nextColor;        /* Next free index in color table */
  440. extern LONG rc;            /* For checking return values */
  441. extern unsigned long dllHandle;    /* Handle of the Tk DLL */
  442.  
  443. #endif /* _OS2INT */
  444.