MacWindows.h
上传用户:xjjlds
上传日期:2015-12-05
资源大小:22823k
文件大小:91k
源码类别:

多媒体编程

开发平台:

Visual C++

  1. /*
  2.      File:       MacWindows.h
  3.  
  4.      Contains:   Window Manager Interfaces
  5.  
  6.      Version:    Technology: Mac OS 9
  7.                  Release:    QuickTime 6.0.2
  8.  
  9.      Copyright:  (c) 1997-2001 by Apple Computer, Inc., all rights reserved
  10.  
  11.      Bugs?:      For bug reports, consult the following page on
  12.                  the World Wide Web:
  13.  
  14.                      http://developer.apple.com/bugreporter/
  15.  
  16. */
  17. #ifndef __MACWINDOWS__
  18. #define __MACWINDOWS__
  19. #ifndef __MACTYPES__
  20. #include "MacTypes.h"
  21. #endif
  22. #ifndef __ALIASES__
  23. #include "Aliases.h"
  24. #endif
  25. #ifndef __APPLEEVENTS__
  26. #include "AppleEvents.h"
  27. #endif
  28. #ifndef __COLLECTIONS__
  29. #include "Collections.h"
  30. #endif
  31. #ifndef __DRAG__
  32. #include "Drag.h"
  33. #endif
  34. #ifndef __EVENTS__
  35. #include "Events.h"
  36. #endif
  37. #ifndef __MENUS__
  38. #include "Menus.h"
  39. #endif
  40. #ifndef __MIXEDMODE__
  41. #include "MixedMode.h"
  42. #endif
  43. #ifndef __QDOFFSCREEN__
  44. #include "QDOffscreen.h"
  45. #endif
  46. #ifndef __QUICKDRAW__
  47. #include "Quickdraw.h"
  48. #endif
  49. #ifndef __TEXTCOMMON__
  50. #include "TextCommon.h"
  51. #endif
  52. #ifndef __ICONS__
  53. #include "Icons.h"
  54. #endif
  55. #ifndef __MACERRORS__
  56. #include "MacErrors.h"
  57. #endif
  58. #if PRAGMA_ONCE
  59. #pragma once
  60. #endif
  61. #ifdef __cplusplus
  62. extern "C" {
  63. #endif
  64. #if PRAGMA_IMPORT
  65. #pragma import on
  66. #endif
  67. #if PRAGMA_STRUCT_ALIGN
  68.     #pragma options align=mac68k
  69. #elif PRAGMA_STRUCT_PACKPUSH
  70.     #pragma pack(push, 2)
  71. #elif PRAGMA_STRUCT_PACK
  72.     #pragma pack(2)
  73. #endif
  74. /*                                                                                                      */
  75. /* Current documentation for the Mac OS Window Manager is available on the web:                         */
  76. /*  <http://developer.apple.com/techpubs/macos8/HumanInterfaceToolbox/WindowManager/windowmanager.html> */
  77. /*                                                                                                      */
  78. /*--------------------------------------------------------------------------------------*/
  79. /* o Property Types                                                                     */
  80. /*--------------------------------------------------------------------------------------*/
  81. typedef OSType                          PropertyCreator;
  82. typedef OSType                          PropertyTag;
  83. /*--------------------------------------------------------------------------------------*/
  84. /* o Window Classes                                                                     */
  85. /*--------------------------------------------------------------------------------------*/
  86. typedef UInt32 WindowClass;
  87. enum {
  88.     kAlertWindowClass           = 1L,                           /* "I need your attention now."*/
  89.     kMovableAlertWindowClass    = 2L,                           /* "I need your attention now, but I'm kind enough to let you switch out of this app to do other things."*/
  90.     kModalWindowClass           = 3L,                           /* system modal, not draggable*/
  91.     kMovableModalWindowClass    = 4L,                           /* application modal, draggable*/
  92.     kFloatingWindowClass        = 5L,                           /* floats above all other application windows*/
  93.     kDocumentWindowClass        = 6L,                           /* document windows*/
  94.     kDesktopWindowClass         = 7L,                           /* desktop window (usually only one of these exists) - OS X only in CarbonLib 1.0*/
  95.     kUtilityWindowClass         = 8L,                           /* Available in CarbonLib 1.1 and later, and in Mac OS X*/
  96.     kHelpWindowClass            = 10L,                          /* Available in CarbonLib 1.1 and later, and in Mac OS X*/
  97.     kSheetWindowClass           = 11L,                          /* Available in CarbonLib 1.3 and later, and in Mac OS X*/
  98.     kToolbarWindowClass         = 12L,                          /* Available in CarbonLib 1.1 and later, and in Mac OS X*/
  99.     kPlainWindowClass           = 13L,                          /* Available in CarbonLib 1.2.5 and later, and Mac OS X*/
  100.     kOverlayWindowClass         = 14L,                          /* Available in Mac OS X*/
  101.     kSheetAlertWindowClass      = 15L,                          /* Available in CarbonLib 1.3 and later, and in Mac OS X 10.1 and later*/
  102.     kAltPlainWindowClass        = 16L,                          /* Available in CarbonLib 1.3 and later, and in Mac OS X 10.1 and later*/
  103.     kDrawerWindowClass          = 20L,                          /* Available in Mac OS X 10.2 or later*/
  104.     kAllWindowClasses           = (unsigned long)0xFFFFFFFF     /* for use with GetFrontWindowOfClass, FindWindowOfClass, GetNextWindowOfClass*/
  105. };
  106. /*--------------------------------------------------------------------------------------*/
  107. /* o Window Attributes                                                                  */
  108. /*--------------------------------------------------------------------------------------*/
  109. typedef UInt32                          WindowAttributes;
  110. enum {
  111.     kWindowNoAttributes         = 0L,                           /* no attributes*/
  112.     kWindowCloseBoxAttribute    = (1L << 0),                    /* window has a close box*/
  113.     kWindowHorizontalZoomAttribute = (1L << 1),                 /* window has horizontal zoom box*/
  114.     kWindowVerticalZoomAttribute = (1L << 2),                   /* window has vertical zoom box*/
  115.     kWindowFullZoomAttribute    = (kWindowVerticalZoomAttribute | kWindowHorizontalZoomAttribute),
  116.     kWindowCollapseBoxAttribute = (1L << 3),                    /* window has a collapse box*/
  117.     kWindowResizableAttribute   = (1L << 4),                    /* window is resizable*/
  118.     kWindowSideTitlebarAttribute = (1L << 5),                   /* window wants a titlebar on the side    (floating window class only)*/
  119.     kWindowNoUpdatesAttribute   = (1L << 16),                   /* this window receives no update events*/
  120.     kWindowNoActivatesAttribute = (1L << 17),                   /* this window receives no activate events*/
  121.     kWindowNoBufferingAttribute = (1L << 20),                   /* this window is not buffered (Mac OS X only)*/
  122.     kWindowStandardDocumentAttributes = (kWindowCloseBoxAttribute | kWindowFullZoomAttribute | kWindowCollapseBoxAttribute | kWindowResizableAttribute),
  123.     kWindowStandardFloatingAttributes = (kWindowCloseBoxAttribute | kWindowCollapseBoxAttribute)
  124. };
  125. /*--------------------------------------------------------------------------------------*/
  126. /* o Window Definition Type                                                             */
  127. /*--------------------------------------------------------------------------------------*/
  128. enum {
  129.     kWindowDefProcType          = FOUR_CHAR_CODE('WDEF')
  130. };
  131. /*--------------------------------------------------------------------------------------*/
  132. /* o Mac OS 7.5 Window Definition Resource IDs                                          */
  133. /*--------------------------------------------------------------------------------------*/
  134. enum {
  135.     kStandardWindowDefinition   = 0,                            /* for document windows and dialogs*/
  136.     kRoundWindowDefinition      = 1,                            /* old da-style window*/
  137.     kFloatingWindowDefinition   = 124                           /* for floating windows*/
  138. };
  139. /*--------------------------------------------------------------------------------------*/
  140. /* o Variant Codes                                                                      */
  141. /*--------------------------------------------------------------------------------------*/
  142. enum {
  143.                                                                 /* for use with kStandardWindowDefinition */
  144.     kDocumentWindowVariantCode  = 0,
  145.     kModalDialogVariantCode     = 1,
  146.     kPlainDialogVariantCode     = 2,
  147.     kShadowDialogVariantCode    = 3,
  148.     kMovableModalDialogVariantCode = 5,
  149.     kAlertVariantCode           = 7,
  150.     kMovableAlertVariantCode    = 9,                            /* for use with kFloatingWindowDefinition */
  151.     kSideFloaterVariantCode     = 8
  152. };
  153. /*--------------------------------------------------------------------------------------*/
  154. /* o DefProc IDs                                                                        */
  155. /*--------------------------------------------------------------------------------------*/
  156. enum {
  157.                                                                 /* classic ids */
  158.     documentProc                = 0,
  159.     dBoxProc                    = 1,
  160.     plainDBox                   = 2,
  161.     altDBoxProc                 = 3,
  162.     noGrowDocProc               = 4,
  163.     movableDBoxProc             = 5,
  164.     zoomDocProc                 = 8,
  165.     zoomNoGrow                  = 12,
  166.     rDocProc                    = 16,                           /* floating window defproc ids */
  167.     floatProc                   = 1985,
  168.     floatGrowProc               = 1987,
  169.     floatZoomProc               = 1989,
  170.     floatZoomGrowProc           = 1991,
  171.     floatSideProc               = 1993,
  172.     floatSideGrowProc           = 1995,
  173.     floatSideZoomProc           = 1997,
  174.     floatSideZoomGrowProc       = 1999
  175. };
  176. enum {
  177.                                                                 /* Resource IDs for theme-savvy window defprocs */
  178.     kWindowDocumentDefProcResID = 64,
  179.     kWindowDialogDefProcResID   = 65,
  180.     kWindowUtilityDefProcResID  = 66,
  181.     kWindowUtilitySideTitleDefProcResID = 67
  182. };
  183. enum {
  184.                                                                 /* Proc IDs for theme-savvy windows */
  185.     kWindowDocumentProc         = 1024,
  186.     kWindowGrowDocumentProc     = 1025,
  187.     kWindowVertZoomDocumentProc = 1026,
  188.     kWindowVertZoomGrowDocumentProc = 1027,
  189.     kWindowHorizZoomDocumentProc = 1028,
  190.     kWindowHorizZoomGrowDocumentProc = 1029,
  191.     kWindowFullZoomDocumentProc = 1030,
  192.     kWindowFullZoomGrowDocumentProc = 1031
  193. };
  194. enum {
  195.                                                                 /* Proc IDs for theme-savvy dialogs */
  196.     kWindowPlainDialogProc      = 1040,
  197.     kWindowShadowDialogProc     = 1041,
  198.     kWindowModalDialogProc      = 1042,
  199.     kWindowMovableModalDialogProc = 1043,
  200.     kWindowAlertProc            = 1044,
  201.     kWindowMovableAlertProc     = 1045
  202. };
  203. enum {
  204.                                                                 /* procIDs available from Mac OS 8.1 (Appearance 1.0.1) forward */
  205.     kWindowMovableModalGrowProc = 1046
  206. };
  207. enum {
  208.                                                                 /* Proc IDs for top title bar theme-savvy floating windows */
  209.     kWindowFloatProc            = 1057,
  210.     kWindowFloatGrowProc        = 1059,
  211.     kWindowFloatVertZoomProc    = 1061,
  212.     kWindowFloatVertZoomGrowProc = 1063,
  213.     kWindowFloatHorizZoomProc   = 1065,
  214.     kWindowFloatHorizZoomGrowProc = 1067,
  215.     kWindowFloatFullZoomProc    = 1069,
  216.     kWindowFloatFullZoomGrowProc = 1071
  217. };
  218. enum {
  219.                                                                 /* Proc IDs for side title bar theme-savvy floating windows */
  220.     kWindowFloatSideProc        = 1073,
  221.     kWindowFloatSideGrowProc    = 1075,
  222.     kWindowFloatSideVertZoomProc = 1077,
  223.     kWindowFloatSideVertZoomGrowProc = 1079,
  224.     kWindowFloatSideHorizZoomProc = 1081,
  225.     kWindowFloatSideHorizZoomGrowProc = 1083,
  226.     kWindowFloatSideFullZoomProc = 1085,
  227.     kWindowFloatSideFullZoomGrowProc = 1087
  228. };
  229. /*--------------------------------------------------------------------------------------*/
  230. /* o System 7 Window Positioning Constants                                              */
  231. /*                                                                                      */
  232. /* Passed into StandardAlert and used in 'WIND', 'DLOG', and 'ALRT' templates           */
  233. /* StandardAlert uses zero to specify the default position. Other calls use zero to     */
  234. /* specify "no position".  Do not pass these constants to RepositionWindow.  Do not     */
  235. /* store these constants in the BasicWindowDescription of a 'wind' resource.            */
  236. /*--------------------------------------------------------------------------------------*/
  237. enum {
  238.     kWindowNoPosition           = 0x0000,
  239.     kWindowDefaultPosition      = 0x0000,                       /* used by StandardAlert*/
  240.     kWindowCenterMainScreen     = 0x280A,
  241.     kWindowAlertPositionMainScreen = 0x300A,
  242.     kWindowStaggerMainScreen    = 0x380A,
  243.     kWindowCenterParentWindow   = 0xA80A,
  244.     kWindowAlertPositionParentWindow = 0xB00A,
  245.     kWindowStaggerParentWindow  = 0xB80A,
  246.     kWindowCenterParentWindowScreen = 0x680A,
  247.     kWindowAlertPositionParentWindowScreen = 0x700A,
  248.     kWindowStaggerParentWindowScreen = 0x780A
  249. };
  250. /*--------------------------------------------------------------------------------------*/
  251. /* o Window Positioning Methods                                                         */
  252. /*                                                                                      */
  253. /* Positioning methods passed to RepositionWindow.                                      */
  254. /* Do not use them in WIND, ALRT, DLOG templates.                                       */
  255. /* Do not confuse these constants with the constants above                              */
  256. /*--------------------------------------------------------------------------------------*/
  257. typedef UInt32 WindowPositionMethod;
  258. enum {
  259.     kWindowCenterOnMainScreen   = 0x00000001,
  260.     kWindowCenterOnParentWindow = 0x00000002,
  261.     kWindowCenterOnParentWindowScreen = 0x00000003,
  262.     kWindowCascadeOnMainScreen  = 0x00000004,
  263.     kWindowCascadeOnParentWindow = 0x00000005,
  264.     kWindowCascadeOnParentWindowScreen = 0x00000006,
  265.     kWindowAlertPositionOnMainScreen = 0x00000007,
  266.     kWindowAlertPositionOnParentWindow = 0x00000008,
  267.     kWindowAlertPositionOnParentWindowScreen = 0x00000009
  268. };
  269. /*--------------------------------------------------------------------------------------*/
  270. /* o GetWindowRegion Types                                                              */
  271. /*--------------------------------------------------------------------------------------*/
  272. typedef UInt16                          WindowRegionCode;
  273. enum {
  274.                                                                 /* Region values to pass into GetWindowRegion & GetWindowBounds */
  275.     kWindowTitleBarRgn          = 0,
  276.     kWindowTitleTextRgn         = 1,
  277.     kWindowCloseBoxRgn          = 2,
  278.     kWindowZoomBoxRgn           = 3,
  279.     kWindowDragRgn              = 5,
  280.     kWindowGrowRgn              = 6,
  281.     kWindowCollapseBoxRgn       = 7,
  282.     kWindowTitleProxyIconRgn    = 8,                            /* Mac OS 8.5 forward*/
  283.     kWindowStructureRgn         = 32,
  284.     kWindowContentRgn           = 33,                           /* Content area of the window; empty when the window is collapsed*/
  285.     kWindowUpdateRgn            = 34,                           /* Carbon forward*/
  286.     kWindowGlobalPortRgn        = 40                            /* Carbon forward - bounds of the window's port in global coordinates; not affected by CollapseWindow*/
  287. };
  288. /* GetWindowRegionRec - a pointer to this is passed in WDEF param for kWindowMsgGetRegion*/
  289. struct GetWindowRegionRec {
  290.     RgnHandle                       winRgn;
  291.     WindowRegionCode                regionCode;
  292. };
  293. typedef struct GetWindowRegionRec       GetWindowRegionRec;
  294. typedef GetWindowRegionRec *            GetWindowRegionPtr;
  295. typedef GetWindowRegionRec *            GetWindowRegionRecPtr;
  296. /*--------------------------------------------------------------------------------------*/
  297. /* o WDEF Message Types                                                                 */
  298. /*--------------------------------------------------------------------------------------*/
  299. /*
  300.    SetupWindowProxyDragImageRec - setup the proxy icon drag image
  301.    Both regions are allocated and disposed by the Window Manager.
  302.    The GWorld is disposed of by the Window Manager, but the WDEF must allocate
  303.    it.  See Technote on Drag Manager 1.1 additions for more information and sample code for
  304.    setting up drag images.
  305. */
  306. struct SetupWindowProxyDragImageRec {
  307.     GWorldPtr                       imageGWorld;                /* locked GWorld containing the drag image - output - can be NULL*/
  308.     RgnHandle                       imageRgn;                   /* image clip region, contains the portion of the image which gets blitted to screen - preallocated output - if imageGWorld is NULL, this is ignored*/
  309.     RgnHandle                       outlineRgn;                 /* the outline region used on shallow monitors - preallocated output - must always be non-empty*/
  310. };
  311. typedef struct SetupWindowProxyDragImageRec SetupWindowProxyDragImageRec;
  312. /* MeasureWindowTitleRec - a pointer to this is passed in WDEF param for kWindowMsgMeasureTitle*/
  313. struct MeasureWindowTitleRec {
  314.                                                                 /* output parameters (filled in by the WDEF)*/
  315.     SInt16                          fullTitleWidth;             /* text + proxy icon width*/
  316.     SInt16                          titleTextWidth;             /* text width*/
  317. };
  318. typedef struct MeasureWindowTitleRec    MeasureWindowTitleRec;
  319. typedef MeasureWindowTitleRec *         MeasureWindowTitleRecPtr;
  320. /*--------------------------------------------------------------------------------------*/
  321. /* o Standard Window Kinds                                                              */
  322. /*--------------------------------------------------------------------------------------*/
  323. enum {
  324.     dialogKind                  = 2,
  325.     userKind                    = 8,
  326.     kDialogWindowKind           = 2,
  327.     kApplicationWindowKind      = 8
  328. };
  329. /*--------------------------------------------------------------------------------------*/
  330. /* o FindWindow Result Codes                                                            */
  331. /*--------------------------------------------------------------------------------------*/
  332. typedef SInt16 WindowPartCode;
  333. enum {
  334.     inDesk                      = 0,
  335.     inNoWindow                  = 0,
  336.     inMenuBar                   = 1,
  337.     inSysWindow                 = 2,
  338.     inContent                   = 3,
  339.     inDrag                      = 4,
  340.     inGrow                      = 5,
  341.     inGoAway                    = 6,
  342.     inZoomIn                    = 7,
  343.     inZoomOut                   = 8,
  344.     inCollapseBox               = 11,                           /* Mac OS 8.0 forward*/
  345.     inProxyIcon                 = 12                            /* Mac OS 8.5 forward*/
  346. };
  347. /*--------------------------------------------------------------------------------------*/
  348. /* o Window Definition Hit Test Result Codes                                            */
  349. /*--------------------------------------------------------------------------------------*/
  350. typedef SInt16 WindowDefPartCode;
  351. enum {
  352.     wNoHit                      = 0,
  353.     wInContent                  = 1,
  354.     wInDrag                     = 2,
  355.     wInGrow                     = 3,
  356.     wInGoAway                   = 4,
  357.     wInZoomIn                   = 5,
  358.     wInZoomOut                  = 6,
  359.     wInCollapseBox              = 9,                            /* Mac OS 8.0 forward*/
  360.     wInProxyIcon                = 10                            /* Mac OS 8.5 forward*/
  361. };
  362. /*--------------------------------------------------------------------------------------*/
  363. /* o Window Definition Messages                                                         */
  364. /*--------------------------------------------------------------------------------------*/
  365. enum {
  366.     kWindowMsgDraw              = 0,
  367.     kWindowMsgHitTest           = 1,
  368.     kWindowMsgCalculateShape    = 2,
  369.     kWindowMsgInitialize        = 3,
  370.     kWindowMsgCleanUp           = 4,
  371.     kWindowMsgDrawGrowOutline   = 5,
  372.     kWindowMsgDrawGrowBox       = 6
  373. };
  374. /* Messages available from Mac OS 8.0 forward*/
  375. enum {
  376.     kWindowMsgGetFeatures       = 7,
  377.     kWindowMsgGetRegion         = 8
  378. };
  379. /* Messages available from Mac OS 8.5 forward*/
  380. enum {
  381.     kWindowMsgDragHilite        = 9,                            /* parameter boolean indicating on or off*/
  382.     kWindowMsgModified          = 10,                           /* parameter boolean indicating saved (false) or modified (true)*/
  383.     kWindowMsgDrawInCurrentPort = 11,                           /* same as kWindowMsgDraw, but must draw in current port*/
  384.     kWindowMsgSetupProxyDragImage = 12,                         /* parameter pointer to SetupWindowProxyDragImageRec*/
  385.     kWindowMsgStateChanged      = 13,                           /* something about the window's state has changed*/
  386.     kWindowMsgMeasureTitle      = 14                            /* measure and return the ideal title width*/
  387. };
  388. /* old names*/
  389. enum {
  390.     wDraw                       = 0,
  391.     wHit                        = 1,
  392.     wCalcRgns                   = 2,
  393.     wNew                        = 3,
  394.     wDispose                    = 4,
  395.     wGrow                       = 5,
  396.     wDrawGIcon                  = 6
  397. };
  398. /*--------------------------------------------------------------------------------------*/
  399. /* o State-changed Flags for kWindowMsgStateChanged                                     */
  400. /*--------------------------------------------------------------------------------------*/
  401. enum {
  402.     kWindowStateTitleChanged    = (1 << 0)
  403. };
  404. /*--------------------------------------------------------------------------------------*/
  405. /* o Window Feature Bits                                                                */
  406. /*--------------------------------------------------------------------------------------*/
  407. enum {
  408.     kWindowCanGrow              = (1 << 0),
  409.     kWindowCanZoom              = (1 << 1),
  410.     kWindowCanCollapse          = (1 << 2),
  411.     kWindowIsModal              = (1 << 3),
  412.     kWindowCanGetWindowRegion   = (1 << 4),
  413.     kWindowIsAlert              = (1 << 5),
  414.     kWindowHasTitleBar          = (1 << 6)
  415. };
  416. /* Feature bits available from Mac OS 8.5 forward*/
  417. enum {
  418.     kWindowSupportsDragHilite   = (1 << 7),                     /* window definition supports kWindowMsgDragHilite*/
  419.     kWindowSupportsModifiedBit  = (1 << 8),                     /* window definition supports kWindowMsgModified*/
  420.     kWindowCanDrawInCurrentPort = (1 << 9),                     /* window definition supports kWindowMsgDrawInCurrentPort*/
  421.     kWindowCanSetupProxyDragImage = (1 << 10),                  /* window definition supports kWindowMsgSetupProxyDragImage*/
  422.     kWindowCanMeasureTitle      = (1 << 11),                    /* window definition supports kWindowMsgMeasureTitle*/
  423.     kWindowWantsDisposeAtProcessDeath = (1 << 12),              /* window definition wants a Dispose message for windows still extant during ExitToShell*/
  424.     kWindowDefSupportsColorGrafPort = 0x40000002                /* window definition does not need the monochrome GrafPort hack during kWindowMsgCalculateShape*/
  425. };
  426. /*--------------------------------------------------------------------------------------*/
  427. /* o Desktop Pattern Resource ID                                                        */
  428. /*--------------------------------------------------------------------------------------*/
  429. enum {
  430.     deskPatID                   = 16
  431. };
  432. /*--------------------------------------------------------------------------------------*/
  433. /* o Window Color Part Codes                                                            */
  434. /*--------------------------------------------------------------------------------------*/
  435. enum {
  436.     wContentColor               = 0,
  437.     wFrameColor                 = 1,
  438.     wTextColor                  = 2,
  439.     wHiliteColor                = 3,
  440.     wTitleBarColor              = 4
  441. };
  442. /*--------------------------------------------------------------------------------------*/
  443. /*  o Region Dragging Constants                                                         */
  444. /*--------------------------------------------------------------------------------------*/
  445. enum {
  446.     kMouseUpOutOfSlop           = (long)0x80008000
  447. };
  448. /*--------------------------------------------------------------------------------------*/
  449. /* o Window Color Table                                                                 */
  450. /*--------------------------------------------------------------------------------------*/
  451. struct WinCTab {
  452.     long                            wCSeed;                     /* reserved */
  453.     short                           wCReserved;                 /* reserved */
  454.     short                           ctSize;                     /* usually 4 for windows */
  455.     ColorSpec                       ctTable[5];
  456. };
  457. typedef struct WinCTab                  WinCTab;
  458. typedef WinCTab *                       WCTabPtr;
  459. typedef WCTabPtr *                      WCTabHandle;
  460. /*--------------------------------------------------------------------------------------*/
  461. /* o WindowRecord                                                                       */
  462. /*--------------------------------------------------------------------------------------*/
  463. #if !OPAQUE_TOOLBOX_STRUCTS
  464. typedef struct WindowRecord             WindowRecord;
  465. typedef WindowRecord *                  WindowPeek;
  466. struct WindowRecord {
  467.     GrafPort                        port;
  468.     short                           windowKind;
  469.     Boolean                         visible;
  470.     Boolean                         hilited;
  471.     Boolean                         goAwayFlag;
  472.     Boolean                         spareFlag;
  473.     RgnHandle                       strucRgn;
  474.     RgnHandle                       contRgn;
  475.     RgnHandle                       updateRgn;
  476.     Handle                          windowDefProc;
  477.     Handle                          dataHandle;
  478.     StringHandle                    titleHandle;
  479.     short                           titleWidth;
  480.     Handle                          controlList;
  481.     WindowPeek                      nextWindow;
  482.     PicHandle                       windowPic;
  483.     long                            refCon;
  484. };
  485. #endif  /* !OPAQUE_TOOLBOX_STRUCTS */
  486. /*--------------------------------------------------------------------------------------*/
  487. /* o Color WindowRecord                                                                 */
  488. /*--------------------------------------------------------------------------------------*/
  489. #if !OPAQUE_TOOLBOX_STRUCTS
  490. typedef struct CWindowRecord            CWindowRecord;
  491. typedef CWindowRecord *                 CWindowPeek;
  492. struct CWindowRecord {
  493.     CGrafPort                       port;
  494.     short                           windowKind;
  495.     Boolean                         visible;
  496.     Boolean                         hilited;
  497.     Boolean                         goAwayFlag;
  498.     Boolean                         spareFlag;
  499.     RgnHandle                       strucRgn;
  500.     RgnHandle                       contRgn;
  501.     RgnHandle                       updateRgn;
  502.     Handle                          windowDefProc;
  503.     Handle                          dataHandle;
  504.     StringHandle                    titleHandle;
  505.     short                           titleWidth;
  506.     Handle                          controlList;
  507.     CWindowPeek                     nextWindow;
  508.     PicHandle                       windowPic;
  509.     long                            refCon;
  510. };
  511. #endif  /* !OPAQUE_TOOLBOX_STRUCTS */
  512. /*--------------------------------------------------------------------------------------*/
  513. /* o AuxWinHandle                                                                       */
  514. /*--------------------------------------------------------------------------------------*/
  515. #if !OPAQUE_TOOLBOX_STRUCTS
  516. typedef struct AuxWinRec                AuxWinRec;
  517. typedef AuxWinRec *                     AuxWinPtr;
  518. typedef AuxWinPtr *                     AuxWinHandle;
  519. struct AuxWinRec {
  520.     AuxWinHandle                    awNext;                     /*handle to next AuxWinRec*/
  521.     WindowPtr                       awOwner;                    /*ptr to window */
  522.     CTabHandle                      awCTable;                   /*color table for this window*/
  523.     Handle                          reserved;
  524.     long                            awFlags;                    /*reserved for expansion*/
  525.     CTabHandle                      awReserved;                 /*reserved for expansion*/
  526.     long                            awRefCon;                   /*user Constant*/
  527. };
  528. #endif  /* !OPAQUE_TOOLBOX_STRUCTS */
  529. /*--------------------------------------------------------------------------------------*/
  530. /*  o BasicWindowDescription                                                            */
  531. /*                                                                                      */
  532. /*  Contains statically-sized basic attributes of the window, for storage in a          */
  533. /*  collection item.                                                                    */
  534. /*--------------------------------------------------------------------------------------*/
  535. /* constants for the version field*/
  536. enum {
  537.     kWindowDefinitionVersionOne = 1,
  538.     kWindowDefinitionVersionTwo = 2
  539. };
  540. /* constants for the stateflags bit field */
  541. enum {
  542.     kWindowIsCollapsedState     = (1 << 0L)
  543. };
  544. struct BasicWindowDescription {
  545.     UInt32                          descriptionSize;            /* sizeof(BasicWindowDescription)*/
  546.     Rect                            windowContentRect;          /* location on screen*/
  547.     Rect                            windowZoomRect;             /* location on screen when zoomed out*/
  548.     UInt32                          windowRefCon;               /* the refcon - __avoid saving stale pointers here__  */
  549.     UInt32                          windowStateFlags;           /* window state bit flags*/
  550.     WindowPositionMethod            windowPositionMethod;       /* method last used by RepositionWindow to position the window (if any)*/
  551.     UInt32                          windowDefinitionVersion;
  552.     union {
  553.         struct {
  554.             SInt16                          windowDefProc;      /* defProc and variant*/
  555.             Boolean                         windowHasCloseBox;
  556.         }                                 versionOne;
  557.         struct {
  558.             WindowClass                     windowClass;        /* the class*/
  559.             WindowAttributes                windowAttributes;   /* the attributes*/
  560.         }                                 versionTwo;
  561.     }                                 windowDefinition;
  562. };
  563. typedef struct BasicWindowDescription   BasicWindowDescription;
  564. /*  the window manager stores the default collection items using these IDs*/
  565. enum {
  566.     kStoredWindowSystemTag      = FOUR_CHAR_CODE('appl'),       /* Only Apple collection items will be of this tag*/
  567.     kStoredBasicWindowDescriptionID = FOUR_CHAR_CODE('sbas'),   /* BasicWindowDescription*/
  568.     kStoredWindowPascalTitleID  = FOUR_CHAR_CODE('s255')        /* pascal title string*/
  569. };
  570. /*--------------------------------------------------------------------------------------*/
  571. /* o Window Class Ordering                                                              */
  572. /*                                                                                      */
  573. /*  Special cases for the "behind" parameter in window creation calls.                  */
  574. /*--------------------------------------------------------------------------------------*/
  575. #define kFirstWindowOfClass ((WindowRef)-1L)
  576. #define kLastWindowOfClass ((WindowRef)0L)
  577. /*--------------------------------------------------------------------------------------*/
  578. /* o Zoom Information Handle                                                            */
  579. /*--------------------------------------------------------------------------------------*/
  580. struct WStateData {
  581.     Rect                            userState;                  /*user zoom state*/
  582.     Rect                            stdState;                   /*standard zoom state*/
  583. };
  584. typedef struct WStateData               WStateData;
  585. typedef WStateData *                    WStateDataPtr;
  586. typedef WStateDataPtr *                 WStateDataHandle;
  587. /*--------------------------------------------------------------------------------------*/
  588. /* o MixedMode & ProcPtrs                                                               */
  589. /*--------------------------------------------------------------------------------------*/
  590. typedef CALLBACK_API( long , WindowDefProcPtr )(short varCode, WindowRef window, short message, long param);
  591. typedef CALLBACK_API( void , DeskHookProcPtr )(Boolean mouseClick, EventRecord *theEvent);
  592. /*
  593.     WARNING: DeskHookProcPtr uses register based parameters under classic 68k
  594.              and cannot be written in a high-level language without 
  595.              the help of mixed mode or assembly glue.
  596. */
  597. typedef CALLBACK_API( OSStatus , WindowPaintProcPtr )(GDHandle device, GrafPtr qdContext, WindowRef window, RgnHandle inClientPaintRgn, RgnHandle outSystemPaintRgn, void *refCon);
  598. typedef STACK_UPP_TYPE(WindowDefProcPtr)                        WindowDefUPP;
  599. typedef REGISTER_UPP_TYPE(DeskHookProcPtr)                      DeskHookUPP;
  600. typedef STACK_UPP_TYPE(WindowPaintProcPtr)                      WindowPaintUPP;
  601. #if OPAQUE_UPP_TYPES
  602.     EXTERN_API(WindowDefUPP)
  603.     NewWindowDefUPP                (WindowDefProcPtr        userRoutine);
  604. #if CALL_NOT_IN_CARBON
  605.     EXTERN_API(DeskHookUPP)
  606.     NewDeskHookUPP                 (DeskHookProcPtr         userRoutine);
  607. #endif  /* CALL_NOT_IN_CARBON */
  608.     EXTERN_API(WindowPaintUPP)
  609.     NewWindowPaintUPP              (WindowPaintProcPtr      userRoutine);
  610.     EXTERN_API(void)
  611.     DisposeWindowDefUPP            (WindowDefUPP            userUPP);
  612. #if CALL_NOT_IN_CARBON
  613.     EXTERN_API(void)
  614.     DisposeDeskHookUPP             (DeskHookUPP             userUPP);
  615. #endif  /* CALL_NOT_IN_CARBON */
  616.     EXTERN_API(void)
  617.     DisposeWindowPaintUPP          (WindowPaintUPP          userUPP);
  618.     EXTERN_API(long)
  619.     InvokeWindowDefUPP             (short                   varCode,
  620.                                     WindowRef               window,
  621.                                     short                   message,
  622.                                     long                    param,
  623.                                     WindowDefUPP            userUPP);
  624. #if CALL_NOT_IN_CARBON
  625.     EXTERN_API(void)
  626.     InvokeDeskHookUPP              (Boolean                 mouseClick,
  627.                                     EventRecord *           theEvent,
  628.                                     DeskHookUPP             userUPP);
  629. #endif  /* CALL_NOT_IN_CARBON */
  630.     EXTERN_API(OSStatus)
  631.     InvokeWindowPaintUPP           (GDHandle                device,
  632.                                     GrafPtr                 qdContext,
  633.                                     WindowRef               window,
  634.                                     RgnHandle               inClientPaintRgn,
  635.                                     RgnHandle               outSystemPaintRgn,
  636.                                     void *                  refCon,
  637.                                     WindowPaintUPP          userUPP);
  638. #else
  639.     enum { uppWindowDefProcInfo = 0x00003BB0 };                     /* pascal 4_bytes Func(2_bytes, 4_bytes, 2_bytes, 4_bytes) */
  640.     enum { uppDeskHookProcInfo = 0x00130802 };                      /* register no_return_value Func(1_byte:D0, 4_bytes:A0) */
  641.     enum { uppWindowPaintProcInfo = 0x0003FFF0 };                   /* pascal 4_bytes Func(4_bytes, 4_bytes, 4_bytes, 4_bytes, 4_bytes, 4_bytes) */
  642.     #define NewWindowDefUPP(userRoutine)                            (WindowDefUPP)NewRoutineDescriptor((ProcPtr)(userRoutine), uppWindowDefProcInfo, GetCurrentArchitecture())
  643.     #define NewDeskHookUPP(userRoutine)                             (DeskHookUPP)NewRoutineDescriptor((ProcPtr)(userRoutine), uppDeskHookProcInfo, GetCurrentArchitecture())
  644.     #define NewWindowPaintUPP(userRoutine)                          (WindowPaintUPP)NewRoutineDescriptor((ProcPtr)(userRoutine), uppWindowPaintProcInfo, GetCurrentArchitecture())
  645.     #define DisposeWindowDefUPP(userUPP)                            DisposeRoutineDescriptor(userUPP)
  646.     #define DisposeDeskHookUPP(userUPP)                             DisposeRoutineDescriptor(userUPP)
  647.     #define DisposeWindowPaintUPP(userUPP)                          DisposeRoutineDescriptor(userUPP)
  648.     #define InvokeWindowDefUPP(varCode, window, message, param, userUPP)  (long)CALL_FOUR_PARAMETER_UPP((userUPP), uppWindowDefProcInfo, (varCode), (window), (message), (param))
  649.     #if TARGET_OS_MAC && TARGET_CPU_68K && !TARGET_RT_MAC_CFM
  650.     #pragma parameter InvokeDeskHookUPP(__D0, __A0, __A1)
  651.     void InvokeDeskHookUPP(Boolean mouseClick, EventRecord * theEvent, DeskHookUPP userUPP) = 0x4E91;
  652.     #else
  653.         #define InvokeDeskHookUPP(mouseClick, theEvent, userUPP)        CALL_TWO_PARAMETER_UPP((userUPP), uppDeskHookProcInfo, (mouseClick), (theEvent))
  654.     #endif
  655.     #define InvokeWindowPaintUPP(device, qdContext, window, inClientPaintRgn, outSystemPaintRgn, refCon, userUPP)  (OSStatus)CALL_SIX_PARAMETER_UPP((userUPP), uppWindowPaintProcInfo, (device), (qdContext), (window), (inClientPaintRgn), (outSystemPaintRgn), (refCon))
  656. #endif
  657. /* support for pre-Carbon UPP routines: NewXXXProc and CallXXXProc */
  658. #define NewWindowDefProc(userRoutine)                           NewWindowDefUPP(userRoutine)
  659. #define NewDeskHookProc(userRoutine)                            NewDeskHookUPP(userRoutine)
  660. #define NewWindowPaintProc(userRoutine)                         NewWindowPaintUPP(userRoutine)
  661. #define CallWindowDefProc(userRoutine, varCode, window, message, param) InvokeWindowDefUPP(varCode, window, message, param, userRoutine)
  662. #define CallDeskHookProc(userRoutine, mouseClick, theEvent)     InvokeDeskHookUPP(mouseClick, theEvent, userRoutine)
  663. #define CallWindowPaintProc(userRoutine, device, qdContext, window, inClientPaintRgn, outSystemPaintRgn, refCon) InvokeWindowPaintUPP(device, qdContext, window, inClientPaintRgn, outSystemPaintRgn, refCon, userRoutine)
  664. /*--------------------------------------------------------------------------------------*/
  665. /* o Window Definition Spec.  Used in Carbon to specify the code that defines a window. */
  666. /*--------------------------------------------------------------------------------------*/
  667. enum {
  668.     kWindowDefProcPtr           = 0                             /* raw proc-ptr based access*/
  669. };
  670. typedef UInt32                          WindowDefType;
  671. struct WindowDefSpec {
  672.     WindowDefType                   defType;
  673.     union {
  674.         WindowDefUPP                    defProc;
  675.     }                                 u;
  676. };
  677. typedef struct WindowDefSpec            WindowDefSpec;
  678. /*--------------------------------------------------------------------------------------*/
  679. /* o Window Creation & Persistence                                                      */
  680. /*--------------------------------------------------------------------------------------*/
  681. EXTERN_API( WindowRef )
  682. GetNewCWindow                   (short                  windowID,
  683.                                  void *                 wStorage,
  684.                                  WindowRef              behind)                             ONEWORDINLINE(0xAA46);
  685. EXTERN_API( WindowRef )
  686. NewWindow                       (void *                 wStorage,
  687.                                  const Rect *           boundsRect,
  688.                                  ConstStr255Param       title,
  689.                                  Boolean                visible,
  690.                                  short                  theProc,
  691.                                  WindowRef              behind,
  692.                                  Boolean                goAwayFlag,
  693.                                  long                   refCon)                             ONEWORDINLINE(0xA913);
  694. EXTERN_API( WindowRef )
  695. GetNewWindow                    (short                  windowID,
  696.                                  void *                 wStorage,
  697.                                  WindowRef              behind)                             ONEWORDINLINE(0xA9BD);
  698. EXTERN_API( WindowRef )
  699. NewCWindow                      (void *                 wStorage,
  700.                                  const Rect *           boundsRect,
  701.                                  ConstStr255Param       title,
  702.                                  Boolean                visible,
  703.                                  short                  procID,
  704.                                  WindowRef              behind,
  705.                                  Boolean                goAwayFlag,
  706.                                  long                   refCon)                             ONEWORDINLINE(0xAA45);
  707. EXTERN_API( void )
  708. DisposeWindow                   (WindowRef              window)                             ONEWORDINLINE(0xA914);
  709. #if CALL_NOT_IN_CARBON
  710. #if TARGET_OS_MAC
  711.     #define MacCloseWindow CloseWindow
  712. #endif
  713. EXTERN_API( void )
  714. MacCloseWindow                  (WindowRef              window)                             ONEWORDINLINE(0xA92D);
  715. /*
  716.    Routines available from Mac OS 8.5 forward
  717.    or from Mac OS 8.1 forward when linking to CarbonLib
  718. */
  719. #endif  /* CALL_NOT_IN_CARBON */
  720. EXTERN_API( OSStatus )
  721. CreateNewWindow                 (WindowClass            windowClass,
  722.                                  WindowAttributes       attributes,
  723.                                  const Rect *           contentBounds,
  724.                                  WindowRef *            outWindow);
  725. /* Routines available from Mac OS 8.5 forward*/
  726. /* Create a window from a 'wind' resource*/
  727. EXTERN_API( OSStatus )
  728. CreateWindowFromResource        (SInt16                 resID,
  729.                                  WindowRef *            outWindow);
  730. /* window persistence*/
  731. EXTERN_API( OSStatus )
  732. StoreWindowIntoCollection       (WindowRef              window,
  733.                                  Collection             collection);
  734. EXTERN_API( OSStatus )
  735. CreateWindowFromCollection      (Collection             collection,
  736.                                  WindowRef *            outWindow);
  737. /* window refcounting*/
  738. EXTERN_API( OSStatus )
  739. GetWindowOwnerCount             (WindowRef              window,
  740.                                  UInt32 *               outCount);
  741. EXTERN_API( OSStatus )
  742. CloneWindow                     (WindowRef              window);
  743. /*--------------------------------------------------------------------------------------*/
  744. /* o Custom Windows                                                                     */
  745. /*--------------------------------------------------------------------------------------*/
  746. /* Routines available from Mac OS 8.1 forward when linking to CarbonLib*/
  747. EXTERN_API( OSStatus )
  748. CreateCustomWindow              (const WindowDefSpec *  def,
  749.                                  WindowClass            windowClass,
  750.                                  WindowAttributes       attributes,
  751.                                  const Rect *           contentBounds,
  752.                                  WindowRef *            outWindow);
  753. EXTERN_API( OSStatus )
  754. ReshapeCustomWindow             (WindowRef              window);
  755. /*--------------------------------------------------------------------------------------*/
  756. /* o Window Metainformation Accessors                                                   */
  757. /*--------------------------------------------------------------------------------------*/
  758. /*
  759.    Routines available from Mac OS 8.5 forward
  760.    or from Mac OS 8.1 forward when linking to CarbonLib
  761. */
  762. EXTERN_API( OSStatus )
  763. GetWindowClass                  (WindowRef              window,
  764.                                  WindowClass *          outClass);
  765. EXTERN_API( OSStatus )
  766. GetWindowAttributes             (WindowRef              window,
  767.                                  WindowAttributes *     outAttributes);
  768. /*
  769.    Routines available from Mac OS 9.0 forward
  770.    or from Mac OS 8.1 forward when linking to CarbonLib
  771. */
  772. EXTERN_API( OSStatus )
  773. ChangeWindowAttributes          (WindowRef              window,
  774.                                  WindowAttributes       setTheseAttributes,
  775.                                  WindowAttributes       clearTheseAttributes);
  776. /*--------------------------------------------------------------------------------------*/
  777. /* o Floating Windows                                                                   */
  778. /*--------------------------------------------------------------------------------------*/
  779. /*
  780.    Routines available from Mac OS 8.6 forward
  781.    or from Mac OS 8.1 forward when linking to CarbonLib
  782. */
  783. EXTERN_API( OSStatus )
  784. ShowFloatingWindows             (void);
  785. EXTERN_API( OSStatus )
  786. HideFloatingWindows             (void);
  787. EXTERN_API( Boolean )
  788. AreFloatingWindowsVisible       (void);
  789. /*--------------------------------------------------------------------------------------*/
  790. /* o Background Image                                                                   */
  791. /*--------------------------------------------------------------------------------------*/
  792. /* SetWinColor is not available in Carbon.*/
  793. #if CALL_NOT_IN_CARBON
  794. EXTERN_API( void )
  795. SetWinColor                     (WindowRef              window,
  796.                                  WCTabHandle            newColorTable)                      ONEWORDINLINE(0xAA41);
  797. /* SetDeskCPat is not available in Carbon.*/
  798. EXTERN_API( void )
  799. SetDeskCPat                     (PixPatHandle           deskPixPat)                         ONEWORDINLINE(0xAA47);
  800. /*
  801.    Routines available from Mac OS 8.5 forward
  802.    or from Mac OS 8.1 forward when linking to CarbonLib
  803. */
  804. #endif  /* CALL_NOT_IN_CARBON */
  805. EXTERN_API( OSStatus )
  806. SetWindowContentColor           (WindowRef              window,
  807.                                  const RGBColor *       color);
  808. EXTERN_API( OSStatus )
  809. GetWindowContentColor           (WindowRef              window,
  810.                                  RGBColor *             color);
  811. /* Routines available from Mac OS 8.5 forward*/
  812. EXTERN_API( OSStatus )
  813. GetWindowContentPattern         (WindowRef              window,
  814.                                  PixPatHandle           outPixPat);
  815. EXTERN_API( OSStatus )
  816. SetWindowContentPattern         (WindowRef              window,
  817.                                  PixPatHandle           pixPat);
  818. /* Routines available from Mac OS 9.0 forward*/
  819. typedef OptionBits                      WindowPaintProcOptions;
  820. enum {
  821.     kWindowPaintProcOptionsNone = 0
  822. };
  823. EXTERN_API( OSStatus )
  824. InstallWindowContentPaintProc   (WindowRef              window,
  825.                                  WindowPaintUPP         paintProc,
  826.                                  WindowPaintProcOptions  options,
  827.                                  void *                 refCon) /* can be NULL */;
  828. /*--------------------------------------------------------------------------------------*/
  829. /* o Scrolling Routines                                                                 */
  830. /*--------------------------------------------------------------------------------------*/
  831. typedef UInt32 ScrollWindowOptions;
  832. enum {
  833.     kScrollWindowNoOptions      = 0,
  834.     kScrollWindowInvalidate     = (1L << 0),                    /* add the exposed area to the window's update region*/
  835.     kScrollWindowEraseToPortBackground = (1L << 1)              /* erase the exposed area using the background color/pattern of the window's grafport*/
  836. };
  837. /* Routines available from Mac OS 8.1 forward when linking to CarbonLib*/
  838. EXTERN_API( OSStatus )
  839. ScrollWindowRect                (WindowRef              inWindow,
  840.                                  const Rect *           inScrollRect,
  841.                                  SInt16                 inHPixels,
  842.                                  SInt16                 inVPixels,
  843.                                  ScrollWindowOptions    inOptions,
  844.                                  RgnHandle              outExposedRgn) /* can be NULL */;
  845. EXTERN_API( OSStatus )
  846. ScrollWindowRegion              (WindowRef              inWindow,
  847.                                  RgnHandle              inScrollRgn,
  848.                                  SInt16                 inHPixels,
  849.                                  SInt16                 inVPixels,
  850.                                  ScrollWindowOptions    inOptions,
  851.                                  RgnHandle              outExposedRgn) /* can be NULL */;
  852. /*--------------------------------------------------------------------------------------*/
  853. /* o Low-Level Region & Painting Routines                                               */
  854. /*--------------------------------------------------------------------------------------*/
  855. EXTERN_API( void )
  856. ClipAbove                       (WindowRef              window)                             ONEWORDINLINE(0xA90B);
  857. /* SaveOld/DrawNew are not available in Carbon.  Use ReshapeCustomWindow instead.*/
  858. #if CALL_NOT_IN_CARBON
  859. EXTERN_API( void )
  860. SaveOld                         (WindowRef              window)                             ONEWORDINLINE(0xA90E);
  861. EXTERN_API( void )
  862. DrawNew                         (WindowRef              window,
  863.                                  Boolean                update)                             ONEWORDINLINE(0xA90F);
  864. #endif  /* CALL_NOT_IN_CARBON */
  865. EXTERN_API( void )
  866. PaintOne                        (WindowRef              window, /* can be NULL */
  867.                                  RgnHandle              clobberedRgn)                       ONEWORDINLINE(0xA90C);
  868. EXTERN_API( void )
  869. PaintBehind                     (WindowRef              startWindow, /* can be NULL */
  870.                                  RgnHandle              clobberedRgn)                       ONEWORDINLINE(0xA90D);
  871. EXTERN_API( void )
  872. CalcVis                         (WindowRef              window)                             ONEWORDINLINE(0xA909);
  873. EXTERN_API( void )
  874. CalcVisBehind                   (WindowRef              startWindow, /* can be NULL */
  875.                                  RgnHandle              clobberedRgn)                       ONEWORDINLINE(0xA90A);
  876. EXTERN_API( Boolean )
  877. CheckUpdate                     (EventRecord *          theEvent)                           ONEWORDINLINE(0xA911);
  878. /*--------------------------------------------------------------------------------------*/
  879. /* o Window List                                                                        */
  880. /*--------------------------------------------------------------------------------------*/
  881. #if TARGET_OS_MAC
  882.     #define MacFindWindow FindWindow
  883. #endif
  884. EXTERN_API( WindowPartCode )
  885. MacFindWindow                   (Point                  thePoint,
  886.                                  WindowRef *            window)                             ONEWORDINLINE(0xA92C);
  887. EXTERN_API( WindowRef )
  888. FrontWindow                     (void)                                                      ONEWORDINLINE(0xA924);
  889. EXTERN_API( void )
  890. BringToFront                    (WindowRef              window)                             ONEWORDINLINE(0xA920);
  891. EXTERN_API( void )
  892. SendBehind                      (WindowRef              window,
  893.                                  WindowRef              behindWindow)                       ONEWORDINLINE(0xA921);
  894. EXTERN_API( void )
  895. SelectWindow                    (WindowRef              window)                             ONEWORDINLINE(0xA91F);
  896. /*
  897.    Routines available from Mac OS 8.6 forward
  898.    or from Mac OS 8.1 forward when linking to CarbonLib
  899. */
  900. EXTERN_API( WindowRef )
  901. FrontNonFloatingWindow          (void);
  902. /* Routines available from Mac OS 8.1 forward when linking to CarbonLib*/
  903. EXTERN_API( WindowRef )
  904. GetNextWindowOfClass            (WindowRef              inWindow,
  905.                                  WindowClass            inWindowClass,
  906.                                  Boolean                mustBeVisible);
  907. EXTERN_API( WindowPtr )
  908. GetFrontWindowOfClass           (WindowClass            inWindowClass,
  909.                                  Boolean                mustBeVisible);
  910. EXTERN_API( OSStatus )
  911. FindWindowOfClass               (const Point *          where,
  912.                                  WindowClass            inWindowClass,
  913.                                  WindowRef *            outWindow,
  914.                                  SInt16 *               outWindowPart);
  915. /*--------------------------------------------------------------------------------------*/
  916. /* o Misc Low-Level stuff                                                               */
  917. /*--------------------------------------------------------------------------------------*/
  918. #if CALL_NOT_IN_CARBON
  919. EXTERN_API( void )
  920. InitWindows                     (void)                                                      ONEWORDINLINE(0xA912);
  921. /*  The window manager port does not exist in Carbon.   */
  922. /*  We are investigating replacement technologies.      */
  923. EXTERN_API( void )
  924. GetWMgrPort                     (GrafPtr *              wPort)                              ONEWORDINLINE(0xA910);
  925. EXTERN_API( void )
  926. GetCWMgrPort                    (CGrafPtr *             wMgrCPort)                          ONEWORDINLINE(0xAA48);
  927. /*
  928.    Routines available from Mac OS 8.5 forward
  929.    or from Mac OS 8.1 forward when linking to CarbonLib
  930. */
  931. #endif  /* CALL_NOT_IN_CARBON */
  932. EXTERN_API( Boolean )
  933. IsValidWindowPtr                (WindowPtr              possibleWindow);
  934. /*
  935.    Routines available from Mac OS 8.6 forward
  936.    InitFloatingWindows is not available in Carbon;
  937.    window ordering is always active for Carbon clients
  938. */
  939. #if CALL_NOT_IN_CARBON
  940. EXTERN_API( OSStatus )
  941. InitFloatingWindows             (void);
  942. /*--------------------------------------------------------------------------------------*/
  943. /* o Various & Sundry Window Accessors                                                  */
  944. /*--------------------------------------------------------------------------------------*/
  945. #endif  /* CALL_NOT_IN_CARBON */
  946. EXTERN_API( void )
  947. HiliteWindow                    (WindowRef              window,
  948.                                  Boolean                fHilite)                            ONEWORDINLINE(0xA91C);
  949. EXTERN_API( void )
  950. SetWRefCon                      (WindowRef              window,
  951.                                  long                   data)                               ONEWORDINLINE(0xA918);
  952. EXTERN_API( long )
  953. GetWRefCon                      (WindowRef              window)                             ONEWORDINLINE(0xA917);
  954. EXTERN_API( void )
  955. SetWindowPic                    (WindowRef              window,
  956.                                  PicHandle              pic)                                ONEWORDINLINE(0xA92E);
  957. EXTERN_API( PicHandle )
  958. GetWindowPic                    (WindowRef              window)                             ONEWORDINLINE(0xA92F);
  959. EXTERN_API( short )
  960. GetWVariant                     (WindowRef              window)                             ONEWORDINLINE(0xA80A);
  961. /* Routines available from Mac OS 8.0 (Appearance 1.0) forward*/
  962. EXTERN_API( OSStatus )
  963. GetWindowFeatures               (WindowRef              window,
  964.                                  UInt32 *               outFeatures)                        THREEWORDINLINE(0x303C, 0x0013, 0xAA74);
  965. EXTERN_API( OSStatus )
  966. GetWindowRegion                 (WindowRef              window,
  967.                                  WindowRegionCode       inRegionCode,
  968.                                  RgnHandle              ioWinRgn)                           THREEWORDINLINE(0x303C, 0x0014, 0xAA74);
  969. /*--------------------------------------------------------------------------------------*/
  970. /* o Update Events                                                                      */
  971. /*--------------------------------------------------------------------------------------*/
  972. /*
  973.    These aren't present in Carbon. Please use the InvalWindowRect, etc. routines
  974.    below instead.
  975. */
  976. #if CALL_NOT_IN_CARBON
  977. EXTERN_API( void )
  978. InvalRect                       (const Rect *           badRect)                            ONEWORDINLINE(0xA928);
  979. EXTERN_API( void )
  980. InvalRgn                        (RgnHandle              badRgn)                             ONEWORDINLINE(0xA927);
  981. EXTERN_API( void )
  982. ValidRect                       (const Rect *           goodRect)                           ONEWORDINLINE(0xA92A);
  983. EXTERN_API( void )
  984. ValidRgn                        (RgnHandle              goodRgn)                            ONEWORDINLINE(0xA929);
  985. #endif  /* CALL_NOT_IN_CARBON */
  986. EXTERN_API( void )
  987. BeginUpdate                     (WindowRef              window)                             ONEWORDINLINE(0xA922);
  988. EXTERN_API( void )
  989. EndUpdate                       (WindowRef              window)                             ONEWORDINLINE(0xA923);
  990. /*
  991.    Routines available from Mac OS 8.5 forward
  992.    or from Mac OS 8.1 forward when linking to CarbonLib
  993. */
  994. EXTERN_API( OSStatus )
  995. InvalWindowRgn                  (WindowRef              window,
  996.                                  RgnHandle              region);
  997. EXTERN_API( OSStatus )
  998. InvalWindowRect                 (WindowRef              window,
  999.                                  const Rect *           bounds);
  1000. EXTERN_API( OSStatus )
  1001. ValidWindowRgn                  (WindowRef              window,
  1002.                                  RgnHandle              region);
  1003. EXTERN_API( OSStatus )
  1004. ValidWindowRect                 (WindowRef              window,
  1005.                                  const Rect *           bounds);
  1006. /*--------------------------------------------------------------------------------------*/
  1007. /* o DrawGrowIcon                                                                       */
  1008. /*                                                                                      */
  1009. /*  DrawGrowIcon is deprecated from Mac OS 8.0 forward.  Theme-savvy window defprocs    */
  1010. /*  include the grow box in the window frame.                                           */
  1011. /*--------------------------------------------------------------------------------------*/
  1012. EXTERN_API( void )
  1013. DrawGrowIcon                    (WindowRef              window)                             ONEWORDINLINE(0xA904);
  1014. /*--------------------------------------------------------------------------------------*/
  1015. /* o Window Titles                                                                      */
  1016. /*--------------------------------------------------------------------------------------*/
  1017. EXTERN_API( void )
  1018. SetWTitle                       (WindowRef              window,
  1019.                                  ConstStr255Param       title)                              ONEWORDINLINE(0xA91A);
  1020. EXTERN_API( void )
  1021. GetWTitle                       (WindowRef              window,
  1022.                                  Str255                 title)                              ONEWORDINLINE(0xA919);
  1023. /*--------------------------------------------------------------------------------------*/
  1024. /* o Window Proxies                                                                     */
  1025. /*--------------------------------------------------------------------------------------*/
  1026. /*
  1027.    Routines available from Mac OS 8.5 forward
  1028.    or from Mac OS 8.1 forward when linking to CarbonLib
  1029. */
  1030. EXTERN_API( OSStatus )
  1031. SetWindowProxyFSSpec            (WindowRef              window,
  1032.                                  const FSSpec *         inFile);
  1033. EXTERN_API( OSStatus )
  1034. GetWindowProxyFSSpec            (WindowRef              window,
  1035.                                  FSSpec *               outFile);
  1036. EXTERN_API( OSStatus )
  1037. SetWindowProxyAlias             (WindowRef              window,
  1038.                                  AliasHandle            alias);
  1039. EXTERN_API( OSStatus )
  1040. GetWindowProxyAlias             (WindowRef              window,
  1041.                                  AliasHandle *          alias);
  1042. EXTERN_API( OSStatus )
  1043. SetWindowProxyCreatorAndType    (WindowRef              window,
  1044.                                  OSType                 fileCreator,
  1045.                                  OSType                 fileType,
  1046.                                  SInt16                 vRefNum);
  1047. EXTERN_API( OSStatus )
  1048. GetWindowProxyIcon              (WindowRef              window,
  1049.                                  IconRef *              outIcon);
  1050. EXTERN_API( OSStatus )
  1051. SetWindowProxyIcon              (WindowRef              window,
  1052.                                  IconRef                icon);
  1053. EXTERN_API( OSStatus )
  1054. RemoveWindowProxy               (WindowRef              window);
  1055. EXTERN_API( OSStatus )
  1056. BeginWindowProxyDrag            (WindowRef              window,
  1057.                                  DragReference *        outNewDrag,
  1058.                                  RgnHandle              outDragOutlineRgn);
  1059. EXTERN_API( OSStatus )
  1060. EndWindowProxyDrag              (WindowRef              window,
  1061.                                  DragReference          theDrag);
  1062. EXTERN_API( OSStatus )
  1063. TrackWindowProxyFromExistingDrag (WindowRef             window,
  1064.                                  Point                  startPt,
  1065.                                  DragReference          drag,
  1066.                                  RgnHandle              inDragOutlineRgn);
  1067. EXTERN_API( OSStatus )
  1068. TrackWindowProxyDrag            (WindowRef              window,
  1069.                                  Point                  startPt);
  1070. EXTERN_API( Boolean )
  1071. IsWindowModified                (WindowRef              window);
  1072. EXTERN_API( OSStatus )
  1073. SetWindowModified               (WindowRef              window,
  1074.                                  Boolean                modified);
  1075. EXTERN_API( Boolean )
  1076. IsWindowPathSelectClick         (WindowRef              window,
  1077.                                  const EventRecord *    event);
  1078. EXTERN_API( OSStatus )
  1079. WindowPathSelect                (WindowRef              window,
  1080.                                  MenuHandle             menu, /* can be NULL */
  1081.                                  SInt32 *               outMenuResult);
  1082. /*--------------------------------------------------------------------------------------*/
  1083. /*  o HiliteWindowFrameForDrag                                                          */
  1084. /*                                                                                      */
  1085. /*  If you call ShowDragHilite and HideDragHilite, you don't need to use this routine.  */
  1086. /*  If you implement custom drag hiliting, you should call HiliteWindowFrameForDrag     */
  1087. /*  when the drag is tracking inside a window with drag-hilited content.                */
  1088. /*--------------------------------------------------------------------------------------*/
  1089. /* Routines available from Mac OS 8.5 forward*/
  1090. EXTERN_API( OSStatus )
  1091. HiliteWindowFrameForDrag        (WindowRef              window,
  1092.                                  Boolean                hilited)                            TWOWORDINLINE(0x7019, 0xA829);
  1093. /*--------------------------------------------------------------------------------------*/
  1094. /* o Window Transitions                                                                 */
  1095. /*                                                                                      */
  1096. /*  TransitionWindow displays a window with accompanying animation and sound.           */
  1097. /*--------------------------------------------------------------------------------------*/
  1098. /* Routines available from Mac OS 8.5 forward*/
  1099. typedef UInt32 WindowTransitionEffect;
  1100. enum {
  1101.     kWindowZoomTransitionEffect = 1                             /* Finder-like zoom rectangles, use with Show or Open transition actions*/
  1102. };
  1103. typedef UInt32 WindowTransitionAction;
  1104. enum {
  1105.     kWindowShowTransitionAction = 1,                            /* param is rect in global coordinates from which to start the animation*/
  1106.     kWindowHideTransitionAction = 2                             /* param is rect in global coordinates at which to end the animation*/
  1107. };
  1108. EXTERN_API( OSStatus )
  1109. TransitionWindow                (WindowRef              window,
  1110.                                  WindowTransitionEffect  effect,
  1111.                                  WindowTransitionAction  action,
  1112.                                  const Rect *           rect) /* can be NULL */;
  1113. /*--------------------------------------------------------------------------------------*/
  1114. /* o Window Positioning                                                                 */
  1115. /*--------------------------------------------------------------------------------------*/
  1116. #if TARGET_OS_MAC
  1117.     #define MacMoveWindow MoveWindow
  1118. #endif
  1119. EXTERN_API( void )
  1120. MacMoveWindow                   (WindowRef              window,
  1121.                                  short                  hGlobal,
  1122.                                  short                  vGlobal,
  1123.                                  Boolean                front)                              ONEWORDINLINE(0xA91B);
  1124. EXTERN_API( void )
  1125. SizeWindow                      (WindowRef              window,
  1126.                                  short                  w,
  1127.                                  short                  h,
  1128.                                  Boolean                fUpdate)                            ONEWORDINLINE(0xA91D);
  1129. /* Note: bBox can only be NULL on Carbon or OS X systems */
  1130. EXTERN_API( long )
  1131. GrowWindow                      (WindowRef              window,
  1132.                                  Point                  startPt,
  1133.                                  const Rect *           bBox) /* can be NULL */             ONEWORDINLINE(0xA92B);
  1134. /* Note: boundsRect can only be NULL on Carbon or OS X systems */
  1135. EXTERN_API( void )
  1136. DragWindow                      (WindowRef              window,
  1137.                                  Point                  startPt,
  1138.                                  const Rect *           boundsRect) /* can be NULL */       ONEWORDINLINE(0xA925);
  1139. EXTERN_API( void )
  1140. ZoomWindow                      (WindowRef              window,
  1141.                                  WindowPartCode         partCode,
  1142.                                  Boolean                front)                              ONEWORDINLINE(0xA83A);
  1143. /* Routines available from Mac OS 8.0 (Appearance 1.0) forward*/
  1144. EXTERN_API( Boolean )
  1145. IsWindowCollapsable             (WindowRef              window)                             THREEWORDINLINE(0x303C, 0x000F, 0xAA74);
  1146. EXTERN_API( Boolean )
  1147. IsWindowCollapsed               (WindowRef              window)                             THREEWORDINLINE(0x303C, 0x0010, 0xAA74);
  1148. EXTERN_API( OSStatus )
  1149. CollapseWindow                  (WindowRef              window,
  1150.                                  Boolean                collapse)                           THREEWORDINLINE(0x303C, 0x0011, 0xAA74);
  1151. EXTERN_API( OSStatus )
  1152. CollapseAllWindows              (Boolean                collapse)                           THREEWORDINLINE(0x303C, 0x0012, 0xAA74);
  1153. /*
  1154.    Routines available from Mac OS 8.5 forward
  1155.    or from Mac OS 8.1 forward when linking to CarbonLib
  1156. */
  1157. EXTERN_API( OSStatus )
  1158. GetWindowBounds                 (WindowRef              window,
  1159.                                  WindowRegionCode       regionCode,
  1160.                                  Rect *                 globalBounds);
  1161. /* Note: newContentRect can only be NULL on Carbon or OS X systems */
  1162. EXTERN_API( Boolean )
  1163. ResizeWindow                    (WindowRef              window,
  1164.                                  Point                  startPoint,
  1165.                                  const Rect *           sizeConstraints, /* can be NULL */
  1166.                                  Rect *                 newContentRect) /* can be NULL */;
  1167. /* Routines available from Mac OS 8.5 forward*/
  1168. EXTERN_API( OSStatus )
  1169. SetWindowBounds                 (WindowRef              window,
  1170.                                  WindowRegionCode       regionCode,
  1171.                                  const Rect *           globalBounds);
  1172. EXTERN_API( OSStatus )
  1173. RepositionWindow                (WindowRef              window,
  1174.                                  WindowRef              parentWindow,
  1175.                                  WindowPositionMethod   method);
  1176. EXTERN_API( OSStatus )
  1177. MoveWindowStructure             (WindowRef              window,
  1178.                                  short                  hGlobal,
  1179.                                  short                  vGlobal);
  1180. EXTERN_API( Boolean )
  1181. IsWindowInStandardState         (WindowRef              window,
  1182.                                  Point *                idealSize,
  1183.                                  Rect *                 idealStandardState);
  1184. EXTERN_API( OSStatus )
  1185. ZoomWindowIdeal                 (WindowRef              window,
  1186.                                  SInt16                 partCode,
  1187.                                  Point *                ioIdealSize);
  1188. EXTERN_API( OSStatus )
  1189. GetWindowIdealUserState         (WindowRef              window,
  1190.                                  Rect *                 userState);
  1191. EXTERN_API( OSStatus )
  1192. SetWindowIdealUserState         (WindowRef              window,
  1193.                                  Rect *                 userState);
  1194. /*--------------------------------------------------------------------------------------*/
  1195. /* o Window Visibility                                                                  */
  1196. /*--------------------------------------------------------------------------------------*/
  1197. EXTERN_API( void )
  1198. HideWindow                      (WindowRef              window)                             ONEWORDINLINE(0xA916);
  1199. #if TARGET_OS_MAC
  1200.     #define MacShowWindow ShowWindow
  1201. #endif
  1202. EXTERN_API( void )
  1203. MacShowWindow                   (WindowRef              window)                             ONEWORDINLINE(0xA915);
  1204. EXTERN_API( void )
  1205. ShowHide                        (WindowRef              window,
  1206.                                  Boolean                showFlag)                           ONEWORDINLINE(0xA908);
  1207. /*--------------------------------------------------------------------------------------*/
  1208. /* o Window Properties                                                                  */
  1209. /*--------------------------------------------------------------------------------------*/
  1210. /*
  1211.    Routines available from Mac OS 8.5 forward
  1212.    or from Mac OS 8.1 forward when linking to CarbonLib
  1213. */
  1214. EXTERN_API( OSStatus )
  1215. GetWindowProperty               (WindowRef              window,
  1216.                                  PropertyCreator        propertyCreator,
  1217.                                  PropertyTag            propertyTag,
  1218.                                  UInt32                 bufferSize,
  1219.                                  UInt32 *               actualSize, /* can be NULL */
  1220.                                  void *                 propertyBuffer);
  1221. EXTERN_API( OSStatus )
  1222. GetWindowPropertySize           (WindowRef              window,
  1223.                                  PropertyCreator        creator,
  1224.                                  PropertyTag            tag,
  1225.                                  UInt32 *               size);
  1226. EXTERN_API( OSStatus )
  1227. SetWindowProperty               (WindowRef              window,
  1228.                                  PropertyCreator        propertyCreator,
  1229.                                  PropertyTag            propertyTag,
  1230.                                  UInt32                 propertySize,
  1231.                                  void *                 propertyBuffer);
  1232. EXTERN_API( OSStatus )
  1233. RemoveWindowProperty            (WindowRef              window,
  1234.                                  PropertyCreator        propertyCreator,
  1235.                                  PropertyTag            propertyTag);
  1236. /* Routines available from Mac OS 8.1 forward when linking to CarbonLib*/
  1237. enum {
  1238.     kWindowPropertyPersistent   = 0x00000001                    /* whether this property gets saved when flattening the window */
  1239. };
  1240. EXTERN_API( OSStatus )
  1241. GetWindowPropertyAttributes     (WindowRef              window,
  1242.                                  OSType                 propertyCreator,
  1243.                                  OSType                 propertyTag,
  1244.                                  UInt32 *               attributes);
  1245. EXTERN_API( OSStatus )
  1246. ChangeWindowPropertyAttributes  (WindowRef              window,
  1247.                                  OSType                 propertyCreator,
  1248.                                  OSType                 propertyTag,
  1249.                                  UInt32                 attributesToSet,
  1250.                                  UInt32                 attributesToClear);
  1251. /*--------------------------------------------------------------------------------------*/
  1252. /* o Utilities                                                                          */
  1253. /*--------------------------------------------------------------------------------------*/
  1254. EXTERN_API( long )
  1255. PinRect                         (const Rect *           theRect,
  1256.                                  Point                  thePt)                              ONEWORDINLINE(0xA94E);
  1257. EXTERN_API( RgnHandle )
  1258. GetGrayRgn                      (void)                                                      TWOWORDINLINE(0x2EB8, 0x09EE);
  1259. /*--------------------------------------------------------------------------------------*/
  1260. /* o Window Part Tracking                                                               */
  1261. /*--------------------------------------------------------------------------------------*/
  1262. EXTERN_API( Boolean )
  1263. TrackBox                        (WindowRef              window,
  1264.                                  Point                  thePt,
  1265.                                  WindowPartCode         partCode)                           ONEWORDINLINE(0xA83B);
  1266. EXTERN_API( Boolean )
  1267. TrackGoAway                     (WindowRef              window,
  1268.                                  Point                  thePt)                              ONEWORDINLINE(0xA91E);
  1269. /*--------------------------------------------------------------------------------------*/
  1270. /* o Region Dragging                                                                    */
  1271. /*--------------------------------------------------------------------------------------*/
  1272. EXTERN_API( long )
  1273. DragGrayRgn                     (RgnHandle              theRgn,
  1274.                                  Point                  startPt,
  1275.                                  const Rect *           limitRect,
  1276.                                  const Rect *           slopRect,
  1277.                                  short                  axis,
  1278.                                  DragGrayRgnUPP         actionProc)                         ONEWORDINLINE(0xA905);
  1279. EXTERN_API( long )
  1280. DragTheRgn                      (RgnHandle              theRgn,
  1281.                                  Point                  startPt,
  1282.                                  const Rect *           limitRect,
  1283.                                  const Rect *           slopRect,
  1284.                                  short                  axis,
  1285.                                  DragGrayRgnUPP         actionProc)                         ONEWORDINLINE(0xA926);
  1286. /*--------------------------------------------------------------------------------------*/
  1287. /*  o GetAuxWin                                                                         */
  1288. /*                                                                                      */
  1289. /*  GetAuxWin is not available in Carbon                                                */
  1290. /*--------------------------------------------------------------------------------------*/
  1291. #if !OPAQUE_TOOLBOX_STRUCTS
  1292. #if CALL_NOT_IN_CARBON
  1293. EXTERN_API( Boolean )
  1294. GetAuxWin                       (WindowRef              window,
  1295.                                  AuxWinHandle *         awHndl)                             ONEWORDINLINE(0xAA42);
  1296. #endif  /* CALL_NOT_IN_CARBON */
  1297. #endif  /* !OPAQUE_TOOLBOX_STRUCTS */
  1298. /*--------------------------------------------------------------------------------------*/
  1299. /* o C Glue                                                                             */
  1300. /*--------------------------------------------------------------------------------------*/
  1301. #if CALL_NOT_IN_CARBON
  1302. EXTERN_API_C( void )
  1303. setwtitle                       (WindowRef              window,
  1304.                                  const char *           title);
  1305. EXTERN_API_C( Boolean )
  1306. trackgoaway                     (WindowRef              window,
  1307.                                  Point *                thePt);
  1308. EXTERN_API_C( short )
  1309. findwindow                      (Point *                thePoint,
  1310.                                  WindowRef *            window);
  1311. EXTERN_API_C( void )
  1312. getwtitle                       (WindowRef              window,
  1313.                                  char *                 title);
  1314. EXTERN_API_C( long )
  1315. growwindow                      (WindowRef              window,
  1316.                                  Point *                startPt,
  1317.                                  const Rect *           bBox);
  1318. EXTERN_API_C( WindowRef )
  1319. newwindow                       (void *                 wStorage,
  1320.                                  const Rect *           boundsRect,
  1321.                                  const char *           title,
  1322.                                  Boolean                visible,
  1323.                                  short                  theProc,
  1324.                                  WindowRef              behind,
  1325.                                  Boolean                goAwayFlag,
  1326.                                  long                   refCon);
  1327. EXTERN_API_C( WindowRef )
  1328. newcwindow                      (void *                 wStorage,
  1329.                                  const Rect *           boundsRect,
  1330.                                  const char *           title,
  1331.                                  Boolean                visible,
  1332.                                  short                  procID,
  1333.                                  WindowRef              behind,
  1334.                                  Boolean                goAwayFlag,
  1335.                                  long                   refCon);
  1336. EXTERN_API_C( long )
  1337. pinrect                         (const Rect *           theRect,
  1338.                                  Point *                thePt);
  1339. EXTERN_API_C( Boolean )
  1340. trackbox                        (WindowRef              window,
  1341.                                  Point *                thePt,
  1342.                                  short                  partCode);
  1343. EXTERN_API_C( long )
  1344. draggrayrgn                     (RgnHandle              theRgn,
  1345.                                  Point *                startPt,
  1346.                                  const Rect *           boundsRect,
  1347.                                  const Rect *           slopRect,
  1348.                                  short                  axis,
  1349.                                  DragGrayRgnUPP         actionProc);
  1350. EXTERN_API_C( void )
  1351. dragwindow                      (WindowRef              window,
  1352.                                  Point *                startPt,
  1353.                                  const Rect *           boundsRect);
  1354. #endif  /* CALL_NOT_IN_CARBON */
  1355. /*--------------------------------------------------------------------------------------*/
  1356. /* o WindowRecord Accessors                                                             */
  1357. /*--------------------------------------------------------------------------------------*/
  1358. /*
  1359.     CHAPTER XVI - the Opacity Wars
  1360.     
  1361.     A long, long time ago, in a metaverse far, far away...
  1362.     
  1363.     On an ancient gravestone by the side of the road is a hastily-scrawled
  1364.     epitaph, written in an archaic dialect.  With the help of your robot guide,
  1365.     you translate it:
  1366.     "Shared data structures are difficult/impossible to coordinate in a preemptively
  1367.     multitasking OS.  To allow Apple to provide a fully reentrant toolbox in
  1368.     the future, while still maintaining a reasonable migration path for existing
  1369.     codebases and developer knowledge, the decision has been made to make all
  1370.     toolbox objects opaque."
  1371.     
  1372.     You hear a vague rumbling sound in the distance.  Your guide suggests backing
  1373.     away, but you ignore it, wishing to admire the ornamentation on the gravestone.
  1374.     
  1375.     Not the best decision.  The grave ERUPTS, a dusty maelstrom filling your
  1376.     senses, fragment of dirt and bone flying through the air.  You are thrown
  1377.     violently to the ground, shocked but conscious.
  1378.     
  1379.     The dust clears quickly, revealing a wizened man sitting on the gravestone.
  1380.     He wears a robe and speaks in deep, passionate tones:
  1381.     
  1382.     "N.B. If you attempt to access fields of the WindowRecord, ControlRecord,
  1383.     DialogRecord, or MenuInfo directly in Mac OS X, you _will_ crash.  To avoid
  1384.     this unpleasant situation, please use the accessor macros which correspond to
  1385.     the routines within the ACCESSOR_CALLS_ARE_FUNCTIONS conditional."
  1386.     
  1387.     Yes, this is another change in direction.  But you're sort 'o used to that
  1388.     by now.  And this time, there is no turning back.
  1389. */
  1390. #if !OPAQUE_TOOLBOX_STRUCTS && !ACCESSOR_CALLS_ARE_FUNCTIONS
  1391. #ifdef __cplusplus
  1392. inline CGrafPtr     GetWindowPort(WindowRef w)                  { return (CGrafPtr) w;                                                  }
  1393. inline void         SetPortWindowPort(WindowRef w)              { MacSetPort( (GrafPtr) GetWindowPort(w)); }
  1394. inline SInt16       GetWindowKind(WindowRef w)                  { return ( *(SInt16 *)  (((UInt8 *) w) + sizeof(GrafPort)));            }
  1395. inline void         SetWindowKind(WindowRef w, SInt16 wKind)    { *(SInt16 *)   (((UInt8 *) w) + sizeof(GrafPort)) = wKind;             }
  1396. #if TARGET_OS_MAC
  1397. inline Boolean      IsWindowVisible(WindowRef w)                { return *(Boolean *)   (((UInt8 *) w) + sizeof(GrafPort) + 0x2);       }
  1398. #endif
  1399. inline Boolean      MacIsWindowVisible(WindowRef w)             { return *(Boolean *)   (((UInt8 *) w) + sizeof(GrafPort) + 0x2);       }
  1400. inline Boolean      IsWindowHilited(WindowRef w)                { return *(Boolean *)   (((UInt8 *) w) + sizeof(GrafPort) + 0x3);       }
  1401. inline Boolean      GetWindowGoAwayFlag(WindowRef w)            { return *(Boolean *)   (((UInt8 *) w) + sizeof(GrafPort) + 0x4);       }
  1402. inline Boolean      GetWindowZoomFlag(WindowRef w)              { return *(Boolean *)   (((UInt8 *) w) + sizeof(GrafPort) + 0x5);       }
  1403. inline void         GetWindowStructureRgn(WindowRef w, RgnHandle r) { MacCopyRgn( *(RgnHandle *)(((UInt8 *) w) + sizeof(GrafPort) + 0x6), r );  }
  1404. inline void         GetWindowContentRgn(WindowRef w, RgnHandle r)   { MacCopyRgn( *(RgnHandle *)(((UInt8 *) w) + sizeof(GrafPort) + 0xA), r );  }
  1405. inline void         GetWindowUpdateRgn(WindowRef w, RgnHandle r)    { MacCopyRgn( *(RgnHandle *)(((UInt8 *) w) + sizeof(GrafPort) + 0xE), r );  }
  1406. inline SInt16       GetWindowTitleWidth(WindowRef w)                { return *(SInt16 *)(((UInt8 *) w) + sizeof(GrafPort) + 0x1E);          }
  1407. #if TARGET_OS_MAC
  1408. inline WindowRef    GetNextWindow(WindowRef w)                      { return *(WindowRef *) (((UInt8 *) w) + sizeof(GrafPort) + 0x24);      }
  1409. #endif
  1410. inline WindowRef    MacGetNextWindow(WindowRef w)                   { return *(WindowRef *) (((UInt8 *) w) + sizeof(GrafPort) + 0x24);      }
  1411. inline void GetWindowStandardState(WindowRef w, Rect *r)
  1412. {   Rect *stateRects = (  (Rect *) (**(Handle *) (((UInt8 *) w) + sizeof(GrafPort) + 0x16)));
  1413. if (stateRects != NULL) *r = stateRects[1];     }
  1414. inline void SetWindowStandardState(WindowRef w, const Rect *r)
  1415. {   Rect *stateRects = (  (Rect *) (**(Handle *) (((UInt8 *) w) + sizeof(GrafPort) + 0x16)));
  1416.     if (stateRects != NULL) stateRects[1] = *r;     }
  1417. inline void GetWindowUserState(WindowRef w, Rect *r)
  1418. {   Rect *stateRects = (  (Rect *) (**(Handle *) (((UInt8 *) w) + sizeof(GrafPort) + 0x16)));
  1419.     if (stateRects != NULL) *r = stateRects[0]; }
  1420. inline void SetWindowUserState(WindowRef w, const Rect *r)
  1421. { Rect *stateRects = (  (Rect *) (**(Handle *) (((UInt8 *) w) + sizeof(GrafPort) + 0x16)));
  1422.     if (stateRects != NULL) stateRects[0] = *r; }
  1423. inline Handle       GetWindowDataHandle(WindowRef w)                {   return  (((WindowPeek) (w))->dataHandle);               }
  1424. inline void         SetWindowDataHandle(WindowRef w, Handle data)   {   (((WindowPeek) (w))->dataHandle) = ((Handle) (data));   }
  1425. #else
  1426. #if TARGET_OS_MAC
  1427. #define IsWindowVisible MacIsWindowVisible
  1428. #define GetNextWindow MacGetNextWindow
  1429. #endif
  1430. #define ShowHideWindow(w)                       ShowHide(w)
  1431. #define SetPortWindowPort(w)                    MacSetPort( (GrafPtr) GetWindowPort(w) )
  1432. #define GetWindowPort(w)                        ( (CGrafPtr) w)
  1433. #define GetWindowKind(w)                        ( *(SInt16 *)   (((UInt8 *) w) + sizeof(GrafPort)))
  1434. #define SetWindowKind(w, wKind)                 ( *(SInt16 *)   (((UInt8 *) w) + sizeof(GrafPort)) = wKind )
  1435. #define MacIsWindowVisible(w)                   ( *(Boolean *)  (((UInt8 *) w) + sizeof(GrafPort) + 0x2))
  1436. #define IsWindowHilited(w)                      ( *(Boolean *)  (((UInt8 *) w) + sizeof(GrafPort) + 0x3))
  1437. #define GetWindowGoAwayFlag(w)                  ( *(Boolean *)  (((UInt8 *) w) + sizeof(GrafPort) + 0x4))
  1438. #define GetWindowZoomFlag(w)                    ( *(Boolean *)  (((UInt8 *) w) + sizeof(GrafPort) + 0x5))
  1439. #define GetWindowStructureRgn(w, aRgnHandle)    MacCopyRgn( *(RgnHandle *)(((UInt8 *) w) + sizeof(GrafPort) + 0x6), aRgnHandle )
  1440. #define GetWindowContentRgn(w, aRgnHandle)      MacCopyRgn( *(RgnHandle *)(((UInt8 *) w) + sizeof(GrafPort) + 0xA), aRgnHandle )
  1441. #define GetWindowUpdateRgn(w, aRgnHandle)       MacCopyRgn( *(RgnHandle *)(((UInt8 *) w) + sizeof(GrafPort) + 0xE), aRgnHandle )
  1442. #define GetWindowTitleWidth(w)                  ( *(SInt16 *)       (((UInt8 *) w) + sizeof(GrafPort) + 0x1E))
  1443. #define MacGetNextWindow(w)                     ( *(WindowRef *)    (((UInt8 *) w) + sizeof(GrafPort) + 0x24))
  1444. #define GetWindowStandardState(w, aRectPtr) do { Rect *stateRects = (  (Rect *) (**(Handle *) (((UInt8 *) w) + sizeof(GrafPort) + 0x16)));  
  1445.                                                                 if (stateRects != NULL) *aRectPtr = stateRects[1]; } while (false)
  1446. #define SetWindowStandardState(w, aRectPtr) do { Rect *stateRects = (  (Rect *) (**(Handle *) (((UInt8 *) w) + sizeof(GrafPort) + 0x16)));  
  1447.                                                                 if (stateRects != NULL) stateRects[1] = *aRectPtr; } while (false)
  1448. #define GetWindowUserState(w, aRectPtr)     do { Rect *stateRects = (  (Rect *) (**(Handle *) (((UInt8 *) w) + sizeof(GrafPort) + 0x16)));  
  1449.                                                                 if (stateRects != NULL) *aRectPtr = stateRects[0]; } while (false)
  1450. #define SetWindowUserState(w, aRectPtr)     do { Rect *stateRects = (  (Rect *) (**(Handle *) (((UInt8 *) w) + sizeof(GrafPort) + 0x16)));  
  1451.                                                                 if (stateRects != NULL) stateRects[0] = *aRectPtr; } while (false)
  1452. #define GetWindowDataHandle(windowRef)              (((WindowPeek) (windowRef))->dataHandle)
  1453. #define SetWindowDataHandle(windowRef, data)        (((WindowPeek) (windowRef))->dataHandle) = ((Handle) (data))
  1454. #endif  /* defined(__cplusplus) */
  1455. #endif  /* !OPAQUE_TOOLBOX_STRUCTS && !ACCESSOR_CALLS_ARE_FUNCTIONS */
  1456. #if ACCESSOR_CALLS_ARE_FUNCTIONS
  1457. /*                                                                                          */
  1458. /*  Direct modification of the close box and zoom box "flags" is not supported in Carbon.   */
  1459. /*                                                                                          */
  1460. /*  GetWindowGoAwayFlag                                                                     */
  1461. /*  GetWindowSpareFlag                                                                      */
  1462. /*  SetWindowGoAwayFlag                                                                     */
  1463. /*  SetWindowSpareFlag                                                                      */
  1464. /*                                                                                          */
  1465. /*  Use GetWindowAttributes and ChangeWindowAttributes if you must dynamically              */
  1466. /*  access the zoom box and close box attributes.                                           */
  1467. /*                                                                                          */
  1468. /* Still available as transitional API in PreCarbon.o, since GetWindowAttributes is not implemented there. */
  1469. EXTERN_API( Boolean )
  1470. GetWindowGoAwayFlag             (WindowRef              window);
  1471. EXTERN_API( Boolean )
  1472. GetWindowSpareFlag              (WindowRef              window);
  1473. /* Getters */
  1474. EXTERN_API( WindowRef )
  1475. GetWindowList                   (void);
  1476. EXTERN_API( CGrafPtr )
  1477. GetWindowPort                   (WindowRef              window);
  1478. EXTERN_API( short )
  1479. GetWindowKind                   (WindowRef              window);
  1480. #if TARGET_OS_MAC
  1481.     #define MacIsWindowVisible IsWindowVisible
  1482. #endif
  1483. EXTERN_API( Boolean )
  1484. MacIsWindowVisible              (WindowRef              window);
  1485. EXTERN_API( Boolean )
  1486. IsWindowHilited                 (WindowRef              window);
  1487. EXTERN_API( Boolean )
  1488. IsWindowUpdatePending           (WindowRef              window);
  1489. #if TARGET_OS_MAC
  1490.     #define MacGetNextWindow GetNextWindow
  1491. #endif
  1492. EXTERN_API( WindowRef )
  1493. MacGetNextWindow                (WindowRef              window);
  1494. EXTERN_API( Rect *)
  1495. GetWindowStandardState          (WindowRef              window,
  1496.                                  Rect *                 rect);
  1497. EXTERN_API( Rect *)
  1498. GetWindowUserState              (WindowRef              window,
  1499.                                  Rect *                 rect);
  1500. /* Setters */
  1501. EXTERN_API( void )
  1502. SetWindowKind                   (WindowRef              window,
  1503.                                  short                  kind);
  1504. EXTERN_API( void )
  1505. SetWindowStandardState          (WindowRef              window,
  1506.                                  const Rect *           rect);
  1507. EXTERN_API( void )
  1508. SetWindowUserState              (WindowRef              window,
  1509.                                  const Rect *           rect);
  1510. /* Utilities */
  1511. /* set the current QuickDraw port to the port associated with the window */
  1512. EXTERN_API( void )
  1513. SetPortWindowPort               (WindowRef              window);
  1514. EXTERN_API( Rect *)
  1515. GetWindowPortBounds             (WindowRef              window,
  1516.                                  Rect *                 bounds);
  1517. /* GetWindowFromPort is needed to 'cast up' to a WindowRef from a GrafPort */
  1518. EXTERN_API( WindowRef )
  1519. GetWindowFromPort               (CGrafPtr               port);
  1520. /* To prevent upward dependencies, GetDialogFromWindow() is defined in the Dialogs interface: */
  1521. /*      pascal DialogPtr        GetDialogFromWindow(WindowRef window); */
  1522. #endif  /* ACCESSOR_CALLS_ARE_FUNCTIONS */
  1523. #if PRAGMA_STRUCT_ALIGN
  1524.     #pragma options align=reset
  1525. #elif PRAGMA_STRUCT_PACKPUSH
  1526.     #pragma pack(pop)
  1527. #elif PRAGMA_STRUCT_PACK
  1528.     #pragma pack()
  1529. #endif
  1530. #ifdef PRAGMA_IMPORT_OFF
  1531. #pragma import off
  1532. #elif PRAGMA_IMPORT
  1533. #pragma import reset
  1534. #endif
  1535. #ifdef __cplusplus
  1536. }
  1537. #endif
  1538. #endif /* __MACWINDOWS__ */