diff options
author | das <das@noemail.net> | 2007-06-29 03:22:00 (GMT) |
---|---|---|
committer | das <das@noemail.net> | 2007-06-29 03:22:00 (GMT) |
commit | 394293e8ec190211a5d90b20f4e3f799a50945ae (patch) | |
tree | c06cbd1a38889e6a8b8630f5eceab1c1b9d60f13 /macosx/tkMacOSXPrivate.h | |
parent | 0ec736baa4e50ba3f5884d1e46ac0502acc962be (diff) | |
download | tk-394293e8ec190211a5d90b20f4e3f799a50945ae.zip tk-394293e8ec190211a5d90b20f4e3f799a50945ae.tar.gz tk-394293e8ec190211a5d90b20f4e3f799a50945ae.tar.bz2 |
* macosx/tkMacOSXScrlbr.c: correct int <-> dobule conversion issues
that could lead to Carbon getting confused about scrollbar thumb size.
* macosx/tkMacOSXDraw.c (XCopyArea, XCopyPlane, TkPutImage) use
TkMacOSX{Setup,Restore}DrawingContext() to setup/restore clip & colors.
(TkMacOSXSetupDrawingContext, TkMacOSXRestoreDrawingContext): add save
and restore of QD port clip region; factor out clip region code common
to CG and QD branches; check for port and context validity; handle
tkPictureIsOpen flag during QD port setup.
(TkScrollWindow): remove unnecessary scroll region manipulation
* macosx/tkMacOSXDraw.c: remove second global QD temp region
* macosx/tkMacOSXInt.h: (no longer necessary) and rename
* macosx/tkMacOSXRegion.c: remaining global QD temp region.
* macosx/tkMacOSXSubwindows.c:
* macosx/tkMacOSXWindowEvent.c:
* macosx/tkMacOSXDraw.c: make useCGDrawing variable MODULE_SCOPE
* macosx/tkMacOSXFont.c: and sync formatting with HEAD.
* macosx/tkMacOSXButton.c: reduce reliance on current QD port
* macosx/tkMacOSXColor.c: setting and remove unnecessary
* macosx/tkMacOSXDebug.c: references to a drawable's QD port,
* macosx/tkMacOSXDebug.h: notably replace GetWindowFromPort(
* macosx/tkMacOSXDialog.c: TkMacOSXGetDrawablePort()) idiom by new
* macosx/tkMacOSXDraw.c: TkMacOSXDrawableWindow() and change
* macosx/tkMacOSXKeyEvent.c: TkMacOSXSetColorInPort() to take a port
* macosx/tkMacOSXMenu.c: argument.
* macosx/tkMacOSXMenubutton.c:
* macosx/tkMacOSXMouseEvent.c:
* macosx/tkMacOSXScale.c:
* macosx/tkMacOSXScrlbr.c:
* macosx/tkMacOSXSubwindows.c:
* macosx/tkMacOSXWindowEvent.c:
* macosx/tkMacOSXWm.c:
* macosx/tkMacOSXInt.h: factor out macros, declarations
* macosx/tkMacOSXPrivate.h (new): and prototypes that are purely
internal and private to the 'macosx' sources into a new internal header
file that does _not_ get installed into Tk.framework/PrivateHeaders.
* macosx/tkMacOSXButton.c: #include new tkMacOSXPrivate.h
* macosx/tkMacOSXCarbonEvents.c: instead of tkMacOSXInt.h.
* macosx/tkMacOSXClipboard.c:
* macosx/tkMacOSXColor.c:
* macosx/tkMacOSXCursor.c:
* macosx/tkMacOSXDebug.c:
* macosx/tkMacOSXDialog.c:
* macosx/tkMacOSXDraw.c:
* macosx/tkMacOSXEntry.c:
* macosx/tkMacOSXEvent.c:
* macosx/tkMacOSXFont.c:
* macosx/tkMacOSXHLEvents.c:
* macosx/tkMacOSXInit.c:
* macosx/tkMacOSXKeyEvent.c:
* macosx/tkMacOSXMenu.c:
* macosx/tkMacOSXMenubutton.c:
* macosx/tkMacOSXMenus.c:
* macosx/tkMacOSXMouseEvent.c:
* macosx/tkMacOSXNotify.c:
* macosx/tkMacOSXRegion.c:
* macosx/tkMacOSXScale.c:
* macosx/tkMacOSXScrlbr.c:
* macosx/tkMacOSXSubwindows.c:
* macosx/tkMacOSXWindowEvent.c:
* macosx/tkMacOSXWm.c:
* macosx/tkMacOSXXStubs.c:
FossilOrigin-Name: 98571053aff75093d3f2522e005412f507b86c23
Diffstat (limited to 'macosx/tkMacOSXPrivate.h')
-rw-r--r-- | macosx/tkMacOSXPrivate.h | 298 |
1 files changed, 298 insertions, 0 deletions
diff --git a/macosx/tkMacOSXPrivate.h b/macosx/tkMacOSXPrivate.h new file mode 100644 index 0000000..3ab6b21 --- /dev/null +++ b/macosx/tkMacOSXPrivate.h @@ -0,0 +1,298 @@ +/* + * tkMacOSXPrivate.h -- + * + * Macros and declarations that are purely internal & private to TkAqua. + * + * Copyright (c) 2005-2007 Daniel A. Steffen <das@users.sourceforge.net> + * + * See the file "license.terms" for information on usage and redistribution + * of this file, and for a DISCLAIMER OF ALL WARRANTIES. + * + * RCS: @(#) $Id: tkMacOSXPrivate.h,v 1.1.2.2 2007/06/29 03:22:02 das Exp $ + */ + +#ifndef _TKMACPRIV +#define _TKMACPRIV + +#ifndef _TKMACINT +#include "tkMacOSXInt.h" +#endif + +/* Define constants only available on Mac OS X 10.3 or later */ +#if MAC_OS_X_VERSION_MAX_ALLOWED < 1030 + #define kEventAppAvailableWindowBoundsChanged 110 + #define kEventParamTransactionID 'trns' + #define kEventParamWindowPartCode 'wpar' + #define typeWindowPartCode 'wpar' + #define kMenuAttrDoNotUseUserCommandKeys (1 << 7) + #define kSimpleWindowClass 18 + #define kWindowDoesNotCycleAttribute (1L << 15) + #define kWindowAsyncDragAttribute (1L << 23) + #define kThemeBrushAlternatePrimaryHighlightColor -5 + #define kThemeResizeUpCursor 19 + #define kThemeResizeDownCursor 19 + #define kThemeResizeUpDownCursor 19 + #define kThemePoofCursor 19 + #define kThemeBackgroundMetal 6 + #define kThemeIncDecButtonSmall 21 + #define kThemeIncDecButtonMini 22 + #define kAppearancePartUpButton 20 + #define kAppearancePartDownButton 21 + #define kAppearancePartPageUpArea 22 + #define kAppearancePartPageDownArea 23 + #define kAppearancePartIndicator 129 + #define kUIModeAllSuppressed 4 + #define FixedToInt(a) ((short)(((Fixed)(a) + fixed1/2) >> 16)) + #define IntToFixed(a) ((Fixed)(a) << 16) +#endif +/* Define constants only available on Mac OS X 10.4 or later */ +#if MAC_OS_X_VERSION_MAX_ALLOWED < 1040 + #define kWindowNoTitleBarAttribute (1L << 9) + #define kWindowMetalNoContentSeparatorAttribute (1L << 11) + #define kThemeDisclosureTriangle 6 + #define kThemeBrushListViewOddRowBackground 56 + #define kThemeBrushListViewEvenRowBackground 57 + #define kThemeBrushListViewColumnDivider 58 + #define kThemeMetricScrollBarMinThumbHeight 132 + #define kThemeMetricSmallScrollBarMinThumbHeight 134 + #define kThemeScrollBarMedium kThemeMediumScrollBar + #define kThemeScrollBarSmall kThemeSmallScrollBar + #ifdef __BIG_ENDIAN__ + #define kCGBitmapByteOrder32Host (4 << 12) + #else + #define kCGBitmapByteOrder32Host (2 << 12) + #endif + #endif +/* Define constants only available on Mac OS X 10.5 or later */ +#if MAC_OS_X_VERSION_MAX_ALLOWED < 1050 + #define kWindowUnifiedTitleAndToolbarAttribute (1L << 7) + #define kWindowTexturedSquareCornersAttribute (1L << 10) +#endif +/* HIToolbox version constants */ +#ifndef kHIToolboxVersionNumber10_3 + #define kHIToolboxVersionNumber10_3 (145) +#endif +#ifndef kHIToolboxVersionNumber10_4 + #define kHIToolboxVersionNumber10_4 (219) +#endif +#ifndef kHIToolboxVersionNumber10_5 + #define kHIToolboxVersionNumber10_5 (316) +#endif +/* Macros for HIToolbox runtime version checking */ +MODULE_SCOPE float tkMacOSXToolboxVersionNumber; +#define TK_IF_HI_TOOLBOX(vers, ...) \ + tk_if_mac_os_x_min_10_##vers(tkMacOSXToolboxVersionNumber >= \ + kHIToolboxVersionNumber10_##vers, 1, __VA_ARGS__) +#define TK_ELSE_HI_TOOLBOX(vers, ...) \ + tk_else_mac_os_x_min_10_##vers(__VA_ARGS__) +/* Macros for Mac OS X API availability checking */ +#define TK_IF_MAC_OS_X_API(vers, symbol, ...) \ + tk_if_mac_os_x_10_##vers(symbol != NULL, 1, __VA_ARGS__) +#define TK_ELSE_MAC_OS_X(vers, ...) \ + tk_else_mac_os_x_10_##vers(__VA_ARGS__) +#define TK_IF_MAC_OS_X_API_COND(vers, symbol, cond, ...) \ + tk_if_mac_os_x_10_##vers(symbol != NULL, cond, __VA_ARGS__) +#define TK_ELSE(...) \ + } else { __VA_ARGS__ +#define TK_ENDIF \ + } +/* Private macros that implement the checking macros above */ +#define tk_if_mac_os_x_yes(chk, cond, ...) \ + if (cond) { __VA_ARGS__ +#define tk_else_mac_os_x_yes(...) \ + } else { +#define tk_if_mac_os_x_chk(chk, cond, ...) \ + if ((chk) && (cond)) { __VA_ARGS__ +#define tk_else_mac_os_x_chk(...) \ + } else { __VA_ARGS__ +#define tk_if_mac_os_x_no(chk, cond, ...) \ + if (0) { +#define tk_else_mac_os_x_no(...) \ + } else { __VA_ARGS__ +/* Private mapping macros defined according to Mac OS X version requirements */ +/* 10.3 Panther */ +#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1030 +#define tk_if_mac_os_x_min_10_3 tk_if_mac_os_x_yes +#define tk_else_mac_os_x_min_10_3 tk_else_mac_os_x_yes +#if MAC_OS_X_VERSION_MAX_ALLOWED >= 1030 +#define tk_if_mac_os_x_10_3 tk_if_mac_os_x_yes +#define tk_else_mac_os_x_10_3 tk_else_mac_os_x_yes +#endif /* MAC_OS_X_VERSION_MAX_ALLOWED */ +#else /* MAC_OS_X_VERSION_MIN_REQUIRED */ +#define tk_if_mac_os_x_min_10_3 tk_if_mac_os_x_chk +#define tk_else_mac_os_x_min_10_3 tk_else_mac_os_x_chk +#if MAC_OS_X_VERSION_MAX_ALLOWED >= 1030 +#define tk_if_mac_os_x_10_3 tk_if_mac_os_x_chk +#define tk_else_mac_os_x_10_3 tk_else_mac_os_x_chk +#endif /* MAC_OS_X_VERSION_MAX_ALLOWED */ +#endif /* MAC_OS_X_VERSION_MIN_REQUIRED */ +#if MAC_OS_X_VERSION_MAX_ALLOWED < 1030 +#define tk_if_mac_os_x_10_3 tk_if_mac_os_x_no +#define tk_else_mac_os_x_10_3 tk_else_mac_os_x_no +#endif /* MAC_OS_X_VERSION_MAX_ALLOWED */ +/* 10.4 Tiger */ +#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1040 +#define tk_if_mac_os_x_min_10_4 tk_if_mac_os_x_yes +#define tk_else_mac_os_x_min_10_4 tk_else_mac_os_x_yes +#if MAC_OS_X_VERSION_MAX_ALLOWED >= 1040 +#define tk_if_mac_os_x_10_4 tk_if_mac_os_x_yes +#define tk_else_mac_os_x_10_4 tk_else_mac_os_x_yes +#endif /* MAC_OS_X_VERSION_MAX_ALLOWED */ +#else /* MAC_OS_X_VERSION_MIN_REQUIRED */ +#define tk_if_mac_os_x_min_10_4 tk_if_mac_os_x_chk +#define tk_else_mac_os_x_min_10_4 tk_else_mac_os_x_chk +#if MAC_OS_X_VERSION_MAX_ALLOWED >= 1040 +#define tk_if_mac_os_x_10_4 tk_if_mac_os_x_chk +#define tk_else_mac_os_x_10_4 tk_else_mac_os_x_chk +#endif /* MAC_OS_X_VERSION_MAX_ALLOWED */ +#endif /* MAC_OS_X_VERSION_MIN_REQUIRED */ +#if MAC_OS_X_VERSION_MAX_ALLOWED < 1040 +#define tk_if_mac_os_x_10_4 tk_if_mac_os_x_no +#define tk_else_mac_os_x_10_4 tk_else_mac_os_x_no +#endif /* MAC_OS_X_VERSION_MAX_ALLOWED */ +/* 10.5 Leopard */ +#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1050 +#define tk_if_mac_os_x_min_10_5 tk_if_mac_os_x_yes +#define tk_else_mac_os_x_min_10_5 tk_else_mac_os_x_yes +#if MAC_OS_X_VERSION_MAX_ALLOWED >= 1050 +#define tk_if_mac_os_x_10_5 tk_if_mac_os_x_yes +#define tk_else_mac_os_x_10_5 tk_else_mac_os_x_yes +#endif /* MAC_OS_X_VERSION_MAX_ALLOWED */ +#else /* MAC_OS_X_VERSION_MIN_REQUIRED */ +#define tk_if_mac_os_x_min_10_5 tk_if_mac_os_x_chk +#define tk_else_mac_os_x_min_10_5 tk_else_mac_os_x_chk +#if MAC_OS_X_VERSION_MAX_ALLOWED >= 1050 +#define tk_if_mac_os_x_10_5 tk_if_mac_os_x_chk +#define tk_else_mac_os_x_10_5 tk_else_mac_os_x_chk +#endif /* MAC_OS_X_VERSION_MAX_ALLOWED */ +#endif /* MAC_OS_X_VERSION_MIN_REQUIRED */ +#if MAC_OS_X_VERSION_MAX_ALLOWED < 1050 +#define tk_if_mac_os_x_10_5 tk_if_mac_os_x_no +#define tk_else_mac_os_x_10_5 tk_else_mac_os_x_no +#endif /* MAC_OS_X_VERSION_MAX_ALLOWED */ + +/* + * Macros abstracting checks only active in a debug build. + */ + +#ifdef TK_MAC_DEBUG +/* + * Macro to do debug message output. + */ +#define TkMacOSXDbgMsg(m, ...) do { \ + fprintf(stderr, "%s:%d: %s(): " m "\n", strrchr(__FILE__, '/')+1, \ + __LINE__, __func__, ##__VA_ARGS__); \ + } while (0) +/* + * Macro to do debug API failure message output. + */ +#if !defined(DEBUGLEVEL) || !DEBUGLEVEL +#define TkMacOSXDbgOSErr(f, err) do { \ + TkMacOSXDbgMsg("%s failed: %ld", #f, err); \ + } while (0) +#else +#define TkMacOSXDbgOSErr(f, err) do { \ + DEBUG_ASSERT_MESSAGE(kComponentSignatureString, #f " failed:", \ + __func__, 0, strrchr(__FILE__, '/')+1, __LINE__, err); \ + } while (0) +#endif +/* + * Macro to do very common check for noErr return from given API and output + * debug message in case of failure. + */ +#define ChkErr(f, ...) ({ \ + OSStatus err = f(__VA_ARGS__); \ + if (err != noErr) { \ + TkMacOSXDbgOSErr(f, err); \ + } \ + err;}) +/* + * Macro to check emptyness of shared QD tmp region before use in debug builds. + */ +#define TkMacOSXCheckTmpQdRgnEmpty() do { \ + if (!EmptyRgn(tkMacOSXtmpQdRgn)) { \ + Tcl_Panic("tkMacOSXtmpQdRgn nonempty"); \ + } \ + } while(0) +#else /* TK_MAC_DEBUG */ +#define TkMacOSXDbgMsg(m, ...) +#define TkMacOSXDbgOSErr(f, err) +#define ChkErr(f, ...) ({f(__VA_ARGS__);}) +#define TkMacOSXCheckTmpQdRgnEmpty() +#endif /* TK_MAC_DEBUG */ + +/* + * Macro abstracting use of TkMacOSXGetNamedSymbol to init named symbols. + */ + +#define TkMacOSXInitNamedSymbol(module, ret, symbol, ...) \ + static ret (* symbol)(__VA_ARGS__) = (void*)(-1L); \ + if (symbol == (void*)(-1L)) { \ + symbol = TkMacOSXGetNamedSymbol(STRINGIFY(module), \ + STRINGIFY(_##symbol)); \ + } +MODULE_SCOPE void* TkMacOSXGetNamedSymbol(const char* module, + const char* symbol); + +/* + * Structure encapsulating current drawing environment. + */ + +typedef struct TkMacOSXDrawingContext { + CGContextRef context; + CGrafPtr port, savePort; + ThemeDrawingState saveState; + RgnHandle saveClip; + PixPatHandle penPat; + Rect portBounds; + Boolean portChanged; +} TkMacOSXDrawingContext; + +/* + * Variables internal to TkAqua. + */ + +MODULE_SCOPE RgnHandle tkMacOSXtmpQdRgn; +MODULE_SCOPE int tkMacOSXUseCGDrawing; + +/* + * Prototypes of TkAqua internal procs. + */ + +MODULE_SCOPE void TkMacOSXDisplayChanged(Display *display); +MODULE_SCOPE void TkMacOSXInitScrollbarMetrics(void); +MODULE_SCOPE int TkMacOSXUseAntialiasedText(Tcl_Interp *interp, int enable); +MODULE_SCOPE void TkMacOSXInitCarbonEvents(Tcl_Interp *interp); +MODULE_SCOPE int TkMacOSXInitCGDrawing(Tcl_Interp *interp, int enable, + int antiAlias); +MODULE_SCOPE void TkMacOSXInitKeyboard(Tcl_Interp *interp); +MODULE_SCOPE int TkMacOSXGenerateFocusEvent(Window window, int activeFlag); +MODULE_SCOPE int TkMacOSXGenerateParentMenuSelectEvent(MenuRef menu); +MODULE_SCOPE int TkMacOSXGenerateMenuSelectEvent(MenuRef menu, + MenuItemIndex index); +MODULE_SCOPE void TkMacOSXClearActiveMenu(MenuRef menu); +MODULE_SCOPE WindowClass TkMacOSXWindowClass(TkWindow *winPtr); +MODULE_SCOPE int TkMacOSXIsWindowZoomed(TkWindow *winPtr); +MODULE_SCOPE int TkGenerateButtonEventForXPointer(Window window); +MODULE_SCOPE EventModifiers TkMacOSXModifierState(void); +MODULE_SCOPE int TkMacOSXSetupDrawingContext(Drawable d, GC gc, int useCG, + TkMacOSXDrawingContext *dc); +MODULE_SCOPE void TkMacOSXRestoreDrawingContext(TkMacOSXDrawingContext *dc); +MODULE_SCOPE void TkMacOSXSetColorInPort(unsigned long pixel, int fg, + PixPatHandle penPat, CGrafPtr port); +MODULE_SCOPE void TkMacOSXSetColorInContext(unsigned long pixel, + CGContextRef context); +MODULE_SCOPE int TkMacOSXRunTclEventLoop(void); +MODULE_SCOPE OSStatus TkMacOSXStartTclEventLoopCarbonTimer(void); +MODULE_SCOPE OSStatus TkMacOSXStopTclEventLoopCarbonTimer(void); +MODULE_SCOPE void TkMacOSXTrackingLoop(int tracking); +MODULE_SCOPE OSStatus TkMacOSXReceiveAndDispatchEvent(void); +MODULE_SCOPE void TkMacOSXInstallWindowCarbonEventHandler(Tcl_Interp *interp, + WindowRef window); +MODULE_SCOPE int TkMacOSXMakeFullscreen(TkWindow *winPtr, WindowRef window, + int fullscreen, Tcl_Interp *interp); +MODULE_SCOPE void TkMacOSXEnterExitFullscreen(TkWindow *winPtr, int active); +MODULE_SCOPE void TkMacOSXBringWindowForward(WindowRef wRef); +MODULE_SCOPE WindowRef TkMacOSXDrawableWindow(Drawable drawable); + +#endif /* _TKMACPRIV */ |