-
Notifications
You must be signed in to change notification settings - Fork 1
/
Ulis World.h
executable file
·332 lines (256 loc) · 9.52 KB
/
Ulis World.h
1
/* °°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°° PROJECT: Uli's World PURPOSE: System WDEF replacement. COPYRIGHT: (C) Copyright 1998-99 by M. Uli Kusterer, all rights reserved. REACH ME AT: E-MAIL: [email protected] URL: http://www.weblayout.com/witness REVISIONS: 98-01-30 UK Took the shell from the old 'Uli's World' WDEF and rewrote it to support the Appearance extensions and cleaned up everything. °°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°° */#pragma once/* ÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑ Headers: ÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑ */ #include <appearance.h>/* ÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑ Compiler flags: ÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑ *//* Compile as a palette window that looks like small finder window: This also uses the different variations used by the MacOS palette. */#define _UW_FLOATING_PALETTE false// Compile with thick border a bit more like older releases:#define _UW_THICK_BORDER false// Force window title to be small font:#define _UW_CUSTOM_FONT false// Font and size for compiler flag _UW_CUSTOM_FONT:#define kCustomFontID 3 // geneva#define kCustomFontSize 9// Use small (palette window) grow box size:#define _UW_SMALL_GROWBOX false/* Draw grow box background as a placard. May look better with theme savvy scrollbars but looks awful with thick borders. */#define _UW_THEME_GROWBOX false/* Draw dotted title bar when highlighted instead of lines. Usually automatically set when _UW_FLOATING_PALETTE is set. */#define _UW_DRAW_AS_PALETTE false/* ÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑ More macros for conditional compilation: The stuff below is used by the compiler flags. ÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑ */#if _UW_FLOATING_PALETTE // Palettes have smaller size boxes: #undef _UW_SMALL_GROWBOX #define _UW_SMALL_GROWBOX true // Palettes have smaller title bars: #undef _UW_CUSTOM_FONT #define _UW_CUSTOM_FONT true // Palettes have dotted title bars: #undef _UW_DRAW_AS_PALETTE #define _UW_DRAW_AS_PALETTE true #define kBorderWidth 3#else #define kBorderWidth 4#endif#if _UW_SMALL_GROWBOX #define kUlisGrowBoxSize 11 // Default grow box size for OS 8 palettes. #define kUlisGrowBoxBorder 1#else #define kUlisGrowBoxSize 16 // Default grow box size for doc windows. #define kUlisGrowBoxBorder 2#endif#if _UW_THICK_BORDER #undef _UW_THEME_GROWBOX #define _UW_THEME_GROWBOX false // It would look really ugly.#endif/* ÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑ Macros: ÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑ */#define MixColors(colOne, colTwo, destCol) \ (destCol)->red = ((colTwo)->red + (colOne)->red) /2; \ (destCol)->green = ((colTwo)->green + (colOne)->green) /2; \ (destCol)->blue = ((colTwo)->blue + (colOne)->blue) /2;#define WIDTH(box) ((box).right -(box).left)#define HEIGHT(box) ((box).bottom -(box).top)#define MIN(one,two) ((one) > (two) ? (two) : (one))#define MAX(one,two) ((one) > (two) ? (one) : (two))#define BIT_TEST(value,bit) (((value) & (bit)) == (bit))/* ÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑ Compatibility code: ÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑ */// MACROS (Thanks to Godot for the following):#if defined(__MWERKS__)#if __powercPtr osCurrentA5 : 0x0904;#define GetGlobalPtr() osCurrentA5#define GetGlobalBase() (*(Handle)osCurrentA5)#else // ISAPPCPtr GetGlobalPtr(void):__A0 = 0x204d; // MOVE.L A5, A0Ptr GetGlobalBase(void):__A0 = 0x2055; // MOVE.L (A5), A0#endif // ISAPPC#define qd (*((QDGlobals*) GetGlobalBase() -sizeof(QDGlobals)))#define thePort (*GetThePort())#define qdGlobals (GetGlobalBase() - (sizeof(QDGlobals) + sizeof(GrafPtr))) // Points to privates[76]#define whitePat ((Pattern *)(GetGlobalBase() - sizeof(Pattern)))#define blackPat ((Pattern *)(GetGlobalBase() - (sizeof(Pattern) * 2)))#define grayPat ((Pattern *)(GetGlobalBase() - (sizeof(Pattern) * 3)))#define ltGrayPat ((Pattern *)(GetGlobalBase() - (sizeof(Pattern) * 4)))#define dkGrayPat ((Pattern *)(GetGlobalBase() - (sizeof(Pattern) * 5)))#define arrow ((Cursor *)(GetGlobalBase() - (sizeof(Cursor) + (sizeof(Pattern) * 5))))#define screenBits ((BitMap *)(GetGlobalBase() - (sizeof(BitMap) + sizeof(Cursor) + (sizeof(Pattern) * 5))))#define randSeed (*(long *)(GetGlobalBase() - (sizeof(long) + sizeof(BitMap) + sizeof(Cursor) + (sizeof(Pattern) * 5))))#define GlobalPtr GetGlobalPtr() // This would be better as GetGlobalPtrX, but MetroWorks' optimizer ain't that great (yet, V7)#endif // defined(__MWERKS__)/* ÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑ Constants: ÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑ */// Values to pass to DrawRectParts:enum { DR_Top = 1, DR_Left, DR_TopLeft, DR_Bottom, DR_TopBot, DR_LeftBot, DR_TopLeftBot, DR_Right, DR_TopRight, DR_LeftRight, DR_TopLeftRight, DR_BotRight, DR_TopBotRight, DR_LeftBotRight, DR_Full};// wctb colours:enum { wHiliteColorLight = 5, wHiliteColorDark, wTitleBarLight, wTitleBarDark, wDialogLight, wDialogDark, wTingeLight, wTingeDark};#ifndef __APPEARANCE__// Region values to pass into GetWindowRegionenum { kWindowTitleBarRgn = 0, kWindowTitleTextRgn = 1, kWindowCloseBoxRgn = 2, kWindowZoomBoxRgn = 3, kWindowDragRgn = 5, kWindowGrowRgn = 6, kWindowCollapseBoxRgn = 7, kWindowStructureRgn = 32, kWindowContentRgn = 33};// Window Features returned by GetWindowFeaturesenum { kWindowCanGrow = (1 << 0), kWindowCanZoom = (1 << 1), kWindowCanCollapse = (1 << 2), kWindowIsModal = (1 << 3), kWindowCanGetWindowRegion = (1 << 4), kWindowIsAlert = (1 << 5), kWindowHasTitleBar = (1 << 6)};// New window messagesenum { kWindowMsgGetFeatures = 7, kWindowMsgGetRegion = 8};// Window Definition hit test result codes ("WindowPart")enum { wInCollapseBox = 9};#endif /* __APPEARANCE__ */// Variation codes (8.0)enum { #if _UW_FLOATING_PALETTE kUlisHasGrowBox = 2, kUlisHasVertZoomBox = 4, kUlisHasHorzZoomBox = 8, kUlisHasFullZoomBox = 12 #else kUlisHasGrowBox = 1, kUlisHasVertZoomBox = 2, kUlisHasHorzZoomBox = 4, kUlisHasFullZoomBox = 6 #endif};/* ÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑ Zooming data structure: We use this to store zoom states and to make sure our gadgets are set. ÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑ */typedef struct UlisWStateData { Rect userState; // user state Rect stdState; // standard state Boolean gadget; // Gadget on while tracking?} UlisWStateData, **UlisWStateDataHandle;/* ÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑ Region getting data structure: Used by the Window Mgr so we can return window regions. ÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑ */#ifndef __APPEARANCE__typedef struct GetWindowRegionRec { RgnHandle winRgn; short regionCode;} GetWindowRegionRec, *GetWindowRegionRecPtr;#endif __APPEARANCE__/* ÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑ Prototypes: ÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑ */// Main Entry Point:pascal long main( short varCode, WindowPtr theWindow, short message, long param );// Main Dispatchers:void GetMyWindowRegion( GetWindowRegionPtr rgnRec );long ClickInWindow( Point hitPos );long Initialize();void Dispose();long ReturnWindowFeatures();// Window Drawing:void DrawGrowRect( Rect* box );void DrawWindowFrame();void DrawTitleText();void DrawTitleBar();void DrawCloseBox();void DrawZoomBox();long DrawCollapseBox();void DrawGrowBox();void DrawScrollbarLines( Rect *frame );// Region calculation:void CalcTitleBarRegion( RgnHandle theRgn );void CalcTitleTextRegion( RgnHandle theRgn );void CalcCloseBoxRegion( RgnHandle theRgn );void CalcZoomBoxRegion( RgnHandle theRgn );void CalcCollapseBoxRegion( RgnHandle theRgn );void CalcDragRegion( RgnHandle theRgn );void CalcGrowRegion( RgnHandle theRgn );void CalcStructureRegion( RgnHandle theRgn );void CalcContentRegion( RgnHandle theRgn );void CalcRegionsMessage();// Rect Calculation:void GetGlobalWRect( Rect *aRect );void GetTitleBarRect( Rect* box, Boolean baseOnInput );void GetTitleTextRect( Rect* box );void GetGrowBoxRect( Rect* box, Boolean baseOnInput );void GetCloseBoxRect( Rect* box );void GetZoomBoxRect( Rect* box );void GetCollapseBoxRect( Rect* box );// Utility Routines:void SetGadgetFlag( Boolean state );Boolean GetGadgetFlag();Boolean CheckColor( WindowPtr winPtr );long SetColorPort();void DrawRectParts( Rect *aRect, short choice );void DrawOneBox( Rect *box );void DrawCloseBoxStar( Rect *frame );void DrawGadget( Rect *frame, Boolean pressed );long GetCurrentZoomState();void GetIndexedWindowColor( short partCode, RGBColor *col );void GetWctbColor( short partCode, RGBColor *theColor );void GuessWctbColor( short index, RGBColor *theColor );