annotate CSP2/CSP2_env/env-d9b9114564458d9d-741b3de822f2aaca6c6caa4325c4afce/include/tkMacOSXPrivate.h @ 69:33d812a61356

planemo upload commit 2e9511a184a1ca667c7be0c6321a36dc4e3d116d
author jpayne
date Tue, 18 Mar 2025 17:55:14 -0400
parents
children
rev   line source
jpayne@69 1 /*
jpayne@69 2 * tkMacOSXPrivate.h --
jpayne@69 3 *
jpayne@69 4 * Macros and declarations that are purely internal & private to TkAqua.
jpayne@69 5 *
jpayne@69 6 * Copyright (c) 2005-2009 Daniel A. Steffen <das@users.sourceforge.net>
jpayne@69 7 * Copyright (c) 2008-2009 Apple Inc.
jpayne@69 8 * Copyright (c) 2020 Marc Culler
jpayne@69 9 *
jpayne@69 10 * See the file "license.terms" for information on usage and redistribution
jpayne@69 11 * of this file, and for a DISCLAIMER OF ALL WARRANTIES.
jpayne@69 12 *
jpayne@69 13 * RCS: @(#) $Id$
jpayne@69 14 */
jpayne@69 15
jpayne@69 16 #ifndef _TKMACPRIV
jpayne@69 17 #define _TKMACPRIV
jpayne@69 18
jpayne@69 19 #if !__OBJC__
jpayne@69 20 #error Objective-C compiler required
jpayne@69 21 #endif
jpayne@69 22
jpayne@69 23 #ifndef __clang__
jpayne@69 24 #define instancetype id
jpayne@69 25 #endif
jpayne@69 26
jpayne@69 27 #define TextStyle MacTextStyle
jpayne@69 28 #import <ApplicationServices/ApplicationServices.h>
jpayne@69 29 #import <Cocoa/Cocoa.h>
jpayne@69 30 #import <QuartzCore/QuartzCore.h>
jpayne@69 31 #if MAC_OS_X_VERSION_MAX_ALLOWED >= 110000
jpayne@69 32 #import <UniformTypeIdentifiers/UniformTypeIdentifiers.h>
jpayne@69 33 #endif
jpayne@69 34 #ifndef NO_CARBON_H
jpayne@69 35 #import <Carbon/Carbon.h>
jpayne@69 36 #endif
jpayne@69 37 #undef TextStyle
jpayne@69 38 #import <objc/runtime.h> /* for sel_isEqual() */
jpayne@69 39
jpayne@69 40 #ifndef _TKMACINT
jpayne@69 41 #include "tkMacOSXInt.h"
jpayne@69 42 #endif
jpayne@69 43 #ifndef _TKMACDEFAULT
jpayne@69 44 #include "tkMacOSXDefault.h"
jpayne@69 45 #endif
jpayne@69 46
jpayne@69 47 /* Macros for Mac OS X API availability checking */
jpayne@69 48 #define TK_IF_MAC_OS_X_API(vers, symbol, ...) \
jpayne@69 49 tk_if_mac_os_x_10_##vers(symbol != NULL, 1, __VA_ARGS__)
jpayne@69 50 #define TK_ELSE_MAC_OS_X(vers, ...) \
jpayne@69 51 tk_else_mac_os_x_10_##vers(__VA_ARGS__)
jpayne@69 52 #define TK_IF_MAC_OS_X_API_COND(vers, symbol, cond, ...) \
jpayne@69 53 tk_if_mac_os_x_10_##vers(symbol != NULL, cond, __VA_ARGS__)
jpayne@69 54 #define TK_ELSE(...) \
jpayne@69 55 } else { __VA_ARGS__
jpayne@69 56 #define TK_ENDIF \
jpayne@69 57 }
jpayne@69 58 /* Private macros that implement the checking macros above */
jpayne@69 59 #define tk_if_mac_os_x_yes(chk, cond, ...) \
jpayne@69 60 if (cond) { __VA_ARGS__
jpayne@69 61 #define tk_else_mac_os_x_yes(...) \
jpayne@69 62 } else {
jpayne@69 63 #define tk_if_mac_os_x_chk(chk, cond, ...) \
jpayne@69 64 if ((chk) && (cond)) { __VA_ARGS__
jpayne@69 65 #define tk_else_mac_os_x_chk(...) \
jpayne@69 66 } else { __VA_ARGS__
jpayne@69 67 #define tk_if_mac_os_x_no(chk, cond, ...) \
jpayne@69 68 if (0) {
jpayne@69 69 #define tk_else_mac_os_x_no(...) \
jpayne@69 70 } else { __VA_ARGS__
jpayne@69 71
jpayne@69 72 /*
jpayne@69 73 * Macros for DEBUG_ASSERT_MESSAGE et al from Debugging.h.
jpayne@69 74 */
jpayne@69 75
jpayne@69 76 #undef kComponentSignatureString
jpayne@69 77 #undef COMPONENT_SIGNATURE
jpayne@69 78 #define kComponentSignatureString "TkMacOSX"
jpayne@69 79 #define COMPONENT_SIGNATURE 'Tk '
jpayne@69 80
jpayne@69 81 /*
jpayne@69 82 * Macros abstracting checks only active in a debug build.
jpayne@69 83 */
jpayne@69 84
jpayne@69 85 #ifdef TK_MAC_DEBUG
jpayne@69 86 #define TKLog(f, ...) NSLog(f, ##__VA_ARGS__)
jpayne@69 87
jpayne@69 88 /*
jpayne@69 89 * Macro to do debug message output.
jpayne@69 90 */
jpayne@69 91 #define TkMacOSXDbgMsg(m, ...) \
jpayne@69 92 do { \
jpayne@69 93 TKLog(@"%s:%d: %s(): " m, strrchr(__FILE__, '/')+1, \
jpayne@69 94 __LINE__, __func__, ##__VA_ARGS__); \
jpayne@69 95 } while (0)
jpayne@69 96
jpayne@69 97 /*
jpayne@69 98 * Macro to do debug API failure message output.
jpayne@69 99 */
jpayne@69 100 #define TkMacOSXDbgOSErr(f, err) \
jpayne@69 101 do { \
jpayne@69 102 TkMacOSXDbgMsg("%s failed: %d", #f, (int)(err)); \
jpayne@69 103 } while (0)
jpayne@69 104
jpayne@69 105 /*
jpayne@69 106 * Macro to do very common check for noErr return from given API and output
jpayne@69 107 * debug message in case of failure.
jpayne@69 108 */
jpayne@69 109 #define ChkErr(f, ...) ({ \
jpayne@69 110 OSStatus err_ = f(__VA_ARGS__); \
jpayne@69 111 if (err_ != noErr) { \
jpayne@69 112 TkMacOSXDbgOSErr(f, err_); \
jpayne@69 113 } \
jpayne@69 114 err_;})
jpayne@69 115
jpayne@69 116 #else /* TK_MAC_DEBUG */
jpayne@69 117 #define TKLog(f, ...)
jpayne@69 118 #define TkMacOSXDbgMsg(m, ...)
jpayne@69 119 #define TkMacOSXDbgOSErr(f, err)
jpayne@69 120 #define ChkErr(f, ...) ({f(__VA_ARGS__);})
jpayne@69 121 #endif /* TK_MAC_DEBUG */
jpayne@69 122
jpayne@69 123 /*
jpayne@69 124 * Macro abstracting use of TkMacOSXGetNamedSymbol to init named symbols.
jpayne@69 125 */
jpayne@69 126
jpayne@69 127 #define UNINITIALISED_SYMBOL ((void*)(-1L))
jpayne@69 128 #define TkMacOSXInitNamedSymbol(module, ret, symbol, ...) \
jpayne@69 129 static ret (* symbol)(__VA_ARGS__) = UNINITIALISED_SYMBOL; \
jpayne@69 130 if (symbol == UNINITIALISED_SYMBOL) { \
jpayne@69 131 symbol = TkMacOSXGetNamedSymbol(STRINGIFY(module), \
jpayne@69 132 STRINGIFY(symbol)); \
jpayne@69 133 }
jpayne@69 134
jpayne@69 135 /*
jpayne@69 136 * The structure of a 32-bit XEvent keycode on macOS. It may be viewed as
jpayne@69 137 * an unsigned int or as having either two or three bitfields.
jpayne@69 138 */
jpayne@69 139
jpayne@69 140 typedef struct keycode_v_t {
jpayne@69 141 unsigned keychar: 22; /* UCS-32 character */
jpayne@69 142 unsigned o_s: 2; /* State of Option and Shift keys. */
jpayne@69 143 unsigned virt: 8; /* 8-bit virtual keycode - identifies a key. */
jpayne@69 144 } keycode_v;
jpayne@69 145
jpayne@69 146 typedef struct keycode_x_t {
jpayne@69 147 unsigned keychar: 22; /* UCS-32 character */
jpayne@69 148 unsigned xvirtual: 10; /* Combines o_s and virtual. This 10-bit integer
jpayne@69 149 * is used as a key for looking up the character
jpayne@69 150 * produced when pressing a key with a particular
jpayne@69 151 * Shift and Option modifier state. */
jpayne@69 152 } keycode_x;
jpayne@69 153
jpayne@69 154 typedef union MacKeycode_t {
jpayne@69 155 unsigned int uint;
jpayne@69 156 keycode_v v;
jpayne@69 157 keycode_x x;
jpayne@69 158 } MacKeycode;
jpayne@69 159
jpayne@69 160 /*
jpayne@69 161 * Macros used in tkMacOSXKeyboard.c and tkMacOSXKeyEvent.c.
jpayne@69 162 * Note that 0x7f is del and 0xF8FF is the Apple Logo character.
jpayne@69 163 */
jpayne@69 164
jpayne@69 165 #define ON_KEYPAD(virt) ((virt >= 0x41) && (virt <= 0x5C))
jpayne@69 166 #define IS_PRINTABLE(keychar) ((keychar >= 0x20) && (keychar != 0x7f) && \
jpayne@69 167 ((keychar < 0xF700) || keychar >= 0xF8FF))
jpayne@69 168
jpayne@69 169 /*
jpayne@69 170 * An "index" is 2-bit bitfield showing the state of the Option and Shift
jpayne@69 171 * keys. It is used as an index when building the keymaps and it
jpayne@69 172 * is the value of the o_s bitfield of a keycode_v.
jpayne@69 173 */
jpayne@69 174
jpayne@69 175 #define INDEX_SHIFT 1
jpayne@69 176 #define INDEX_OPTION 2
jpayne@69 177 #define INDEX2STATE(index) ((index & INDEX_SHIFT ? ShiftMask : 0) | \
jpayne@69 178 (index & INDEX_OPTION ? Mod2Mask : 0))
jpayne@69 179 #define INDEX2CARBON(index) ((index & INDEX_SHIFT ? shiftKey : 0) | \
jpayne@69 180 (index & INDEX_OPTION ? optionKey : 0))
jpayne@69 181 #define STATE2INDEX(state) ((state & ShiftMask ? INDEX_SHIFT : 0) | \
jpayne@69 182 (state & Mod2Mask ? INDEX_OPTION : 0))
jpayne@69 183
jpayne@69 184 /*
jpayne@69 185 * Special values for the virtual bitfield. Actual virtual keycodes are < 128.
jpayne@69 186 */
jpayne@69 187
jpayne@69 188 #define NO_VIRTUAL 0xFF /* Not generated by a key or the NSText"InputClient. */
jpayne@69 189 #define REPLACEMENT_VIRTUAL 0x80 /* A BMP char sent by the NSTextInputClient. */
jpayne@69 190 #define NON_BMP_VIRTUAL 0x81 /* A non-BMP char sent by the NSTextInputClient. */
jpayne@69 191
jpayne@69 192 /*
jpayne@69 193 * A special character is used in the keycode for simulated modifier KeyPress
jpayne@69 194 * or KeyRelease XEvents. It is near the end of the private-use range but
jpayne@69 195 * different from the UniChar 0xF8FF which Apple uses for their logo character.
jpayne@69 196 * A different special character is used for keys, like the Menu key, which do
jpayne@69 197 * not appear on Macintosh keyboards.
jpayne@69 198 */
jpayne@69 199
jpayne@69 200 #define MOD_KEYCHAR 0xF8FE
jpayne@69 201 #define UNKNOWN_KEYCHAR 0xF8FD
jpayne@69 202
jpayne@69 203 /*
jpayne@69 204 * Structure encapsulating current drawing environment.
jpayne@69 205 */
jpayne@69 206
jpayne@69 207 typedef struct TkMacOSXDrawingContext {
jpayne@69 208 CGContextRef context;
jpayne@69 209 NSView *view;
jpayne@69 210 HIShapeRef clipRgn;
jpayne@69 211 } TkMacOSXDrawingContext;
jpayne@69 212
jpayne@69 213 /*
jpayne@69 214 * Prototypes for TkMacOSXRegion.c.
jpayne@69 215 */
jpayne@69 216
jpayne@69 217 MODULE_SCOPE HIShapeRef TkMacOSXGetNativeRegion(TkRegion r);
jpayne@69 218 MODULE_SCOPE void TkMacOSXSetWithNativeRegion(TkRegion r,
jpayne@69 219 HIShapeRef rgn);
jpayne@69 220 MODULE_SCOPE HIShapeRef TkMacOSXHIShapeCreateEmpty(void);
jpayne@69 221 MODULE_SCOPE HIMutableShapeRef TkMacOSXHIShapeCreateMutableWithRect(
jpayne@69 222 const CGRect *inRect);
jpayne@69 223 MODULE_SCOPE OSStatus TkMacOSXHIShapeSetWithShape(
jpayne@69 224 HIMutableShapeRef inDestShape,
jpayne@69 225 HIShapeRef inSrcShape);
jpayne@69 226 MODULE_SCOPE OSStatus TkMacOSHIShapeDifferenceWithRect(
jpayne@69 227 HIMutableShapeRef inShape, const CGRect *inRect);
jpayne@69 228 MODULE_SCOPE OSStatus TkMacOSHIShapeUnionWithRect(HIMutableShapeRef inShape,
jpayne@69 229 const CGRect *inRect);
jpayne@69 230 MODULE_SCOPE OSStatus TkMacOSHIShapeUnion(HIShapeRef inShape1,
jpayne@69 231 HIShapeRef inShape2, HIMutableShapeRef outResult);
jpayne@69 232 MODULE_SCOPE int TkMacOSXCountRectsInRegion(HIShapeRef shape);
jpayne@69 233 MODULE_SCOPE void TkMacOSXPrintRectsInRegion(HIShapeRef shape);
jpayne@69 234 /*
jpayne@69 235 * Prototypes of TkAqua internal procs.
jpayne@69 236 */
jpayne@69 237
jpayne@69 238 MODULE_SCOPE void * TkMacOSXGetNamedSymbol(const char *module,
jpayne@69 239 const char *symbol);
jpayne@69 240 MODULE_SCOPE void TkMacOSXDisplayChanged(Display *display);
jpayne@69 241 MODULE_SCOPE CGFloat TkMacOSXZeroScreenHeight();
jpayne@69 242 MODULE_SCOPE CGFloat TkMacOSXZeroScreenTop();
jpayne@69 243 MODULE_SCOPE int TkMacOSXUseAntialiasedText(Tcl_Interp *interp,
jpayne@69 244 int enable);
jpayne@69 245 MODULE_SCOPE int TkMacOSXInitCGDrawing(Tcl_Interp *interp, int enable,
jpayne@69 246 int antiAlias);
jpayne@69 247 MODULE_SCOPE int TkMacOSXIsWindowZoomed(TkWindow *winPtr);
jpayne@69 248 MODULE_SCOPE int TkGenerateButtonEventForXPointer(Window window);
jpayne@69 249 MODULE_SCOPE void TkMacOSXDrawCGImage(Drawable d, GC gc, CGContextRef context,
jpayne@69 250 CGImageRef image, unsigned long imageForeground,
jpayne@69 251 unsigned long imageBackground, CGRect imageBounds,
jpayne@69 252 CGRect srcBounds, CGRect dstBounds);
jpayne@69 253 MODULE_SCOPE int TkMacOSXSetupDrawingContext(Drawable d, GC gc,
jpayne@69 254 TkMacOSXDrawingContext *dcPtr);
jpayne@69 255 MODULE_SCOPE void TkMacOSXRestoreDrawingContext(
jpayne@69 256 TkMacOSXDrawingContext *dcPtr);
jpayne@69 257 MODULE_SCOPE void TkMacOSXSetColorInContext(GC gc, unsigned long pixel,
jpayne@69 258 CGContextRef context);
jpayne@69 259 #define TkMacOSXGetTkWindow(window) ((TkWindow *)Tk_MacOSXGetTkWindow(window))
jpayne@69 260 #define TkMacOSXGetNSWindowForDrawable(drawable) ((NSWindow *)TkMacOSXDrawable(drawable))
jpayne@69 261 #define TkMacOSXGetNSViewForDrawable(macWin) ((NSView *)Tk_MacOSXGetNSViewForDrawable((Drawable)(macWin)))
jpayne@69 262 MODULE_SCOPE CGContextRef TkMacOSXGetCGContextForDrawable(Drawable drawable);
jpayne@69 263 MODULE_SCOPE void TkMacOSXWinCGBounds(TkWindow *winPtr, CGRect *bounds);
jpayne@69 264 MODULE_SCOPE HIShapeRef TkMacOSXGetClipRgn(Drawable drawable);
jpayne@69 265 MODULE_SCOPE void TkMacOSXInvalidateViewRegion(NSView *view,
jpayne@69 266 HIShapeRef rgn);
jpayne@69 267 MODULE_SCOPE NSImage* TkMacOSXGetNSImageFromTkImage(Display *display,
jpayne@69 268 Tk_Image image, int width, int height);
jpayne@69 269 MODULE_SCOPE NSImage* TkMacOSXGetNSImageFromBitmap(Display *display,
jpayne@69 270 Pixmap bitmap, GC gc, int width, int height);
jpayne@69 271 MODULE_SCOPE NSColor* TkMacOSXGetNSColor(GC gc, unsigned long pixel);
jpayne@69 272 MODULE_SCOPE NSFont* TkMacOSXNSFontForFont(Tk_Font tkfont);
jpayne@69 273 MODULE_SCOPE NSDictionary* TkMacOSXNSFontAttributesForFont(Tk_Font tkfont);
jpayne@69 274 MODULE_SCOPE NSModalSession TkMacOSXGetModalSession(void);
jpayne@69 275 MODULE_SCOPE void TkMacOSXSelDeadWindow(TkWindow *winPtr);
jpayne@69 276 MODULE_SCOPE void TkMacOSXApplyWindowAttributes(TkWindow *winPtr,
jpayne@69 277 NSWindow *macWindow);
jpayne@69 278 MODULE_SCOPE Tcl_ObjCmdProc TkMacOSXStandardAboutPanelObjCmd;
jpayne@69 279 MODULE_SCOPE Tcl_ObjCmdProc TkMacOSXIconBitmapObjCmd;
jpayne@69 280 MODULE_SCOPE void TkMacOSXDrawSolidBorder(Tk_Window tkwin, GC gc,
jpayne@69 281 int inset, int thickness);
jpayne@69 282 MODULE_SCOPE int TkMacOSXServices_Init(Tcl_Interp *interp);
jpayne@69 283 MODULE_SCOPE Tcl_ObjCmdProc TkMacOSXRegisterServiceWidgetObjCmd;
jpayne@69 284 MODULE_SCOPE unsigned TkMacOSXAddVirtual(unsigned int keycode);
jpayne@69 285 MODULE_SCOPE void TkMacOSXWinNSBounds(TkWindow *winPtr, NSView *view,
jpayne@69 286 NSRect *bounds);
jpayne@69 287 MODULE_SCOPE Bool TkMacOSXInDarkMode(Tk_Window tkwin);
jpayne@69 288 MODULE_SCOPE void TkMacOSXDrawAllViews(void *clientData);
jpayne@69 289 MODULE_SCOPE unsigned long TkMacOSXClearPixel(void);
jpayne@69 290 MODULE_SCOPE NSString* TkMacOSXOSTypeToUTI(OSType ostype);
jpayne@69 291 MODULE_SCOPE NSImage* TkMacOSXIconForFileType(NSString *filetype);
jpayne@69 292
jpayne@69 293 #pragma mark Private Objective-C Classes
jpayne@69 294
jpayne@69 295 #define VISIBILITY_HIDDEN __attribute__((visibility("hidden")))
jpayne@69 296
jpayne@69 297 enum { tkMainMenu = 1, tkApplicationMenu, tkWindowsMenu, tkHelpMenu};
jpayne@69 298
jpayne@69 299 VISIBILITY_HIDDEN
jpayne@69 300 @interface TKMenu : NSMenu {
jpayne@69 301 @private
jpayne@69 302 void *_tkMenu;
jpayne@69 303 NSUInteger _tkOffset, _tkItemCount, _tkSpecial;
jpayne@69 304 }
jpayne@69 305 - (void)setSpecial:(NSUInteger)special;
jpayne@69 306 - (BOOL)isSpecial:(NSUInteger)special;
jpayne@69 307 @end
jpayne@69 308
jpayne@69 309 @interface TKMenu(TKMenuDelegate) <NSMenuDelegate>
jpayne@69 310 @end
jpayne@69 311
jpayne@69 312 VISIBILITY_HIDDEN
jpayne@69 313 @interface TKApplication : NSApplication {
jpayne@69 314 @private
jpayne@69 315 Tcl_Interp *_eventInterp;
jpayne@69 316 NSMenu *_servicesMenu;
jpayne@69 317 TKMenu *_defaultMainMenu, *_defaultApplicationMenu;
jpayne@69 318 NSMenuItem *_demoMenuItem;
jpayne@69 319 NSArray *_defaultApplicationMenuItems, *_defaultWindowsMenuItems;
jpayne@69 320 NSArray *_defaultHelpMenuItems, *_defaultFileMenuItems;
jpayne@69 321 NSAutoreleasePool *_mainPool;
jpayne@69 322 NSThread *_backgoundLoop;
jpayne@69 323
jpayne@69 324 #ifdef __i386__
jpayne@69 325 /* The Objective C runtime used on i386 requires this. */
jpayne@69 326 int _poolLock;
jpayne@69 327 int _macOSVersion; /* 10000 * major + 100*minor */
jpayne@69 328 Bool _isDrawing;
jpayne@69 329 Bool _needsToDraw;
jpayne@69 330 Bool _tkLiveResizeEnded;
jpayne@69 331 TkWindow *_tkPointerWindow;
jpayne@69 332 TkWindow *_tkEventTarget;
jpayne@69 333 TkWindow *_tkDragTarget;
jpayne@69 334 unsigned int _tkButtonState;
jpayne@69 335 #endif
jpayne@69 336
jpayne@69 337 }
jpayne@69 338 @property int poolLock;
jpayne@69 339 @property int macOSVersion;
jpayne@69 340 @property Bool isDrawing;
jpayne@69 341 @property Bool needsToDraw;
jpayne@69 342 @property Bool tkLiveResizeEnded;
jpayne@69 343
jpayne@69 344 /*
jpayne@69 345 * Persistent state variables used by processMouseEvent.
jpayne@69 346 */
jpayne@69 347
jpayne@69 348 @property(nonatomic) TkWindow *tkPointerWindow;
jpayne@69 349 @property(nonatomic) TkWindow *tkEventTarget;
jpayne@69 350 @property(nonatomic) TkWindow *tkDragTarget;
jpayne@69 351 @property unsigned int tkButtonState;
jpayne@69 352
jpayne@69 353 @end
jpayne@69 354 @interface TKApplication(TKInit)
jpayne@69 355 - (NSString *)tkFrameworkImagePath:(NSString*)image;
jpayne@69 356 - (void)_resetAutoreleasePool;
jpayne@69 357 - (void)_lockAutoreleasePool;
jpayne@69 358 - (void)_unlockAutoreleasePool;
jpayne@69 359 @end
jpayne@69 360 @interface TKApplication(TKKeyboard)
jpayne@69 361 - (void) keyboardChanged: (NSNotification *) notification;
jpayne@69 362 @end
jpayne@69 363 @interface TKApplication(TKWindowEvent) <NSApplicationDelegate>
jpayne@69 364 - (void) _setupWindowNotifications;
jpayne@69 365 @end
jpayne@69 366 @interface TKApplication(TKDialog) <NSOpenSavePanelDelegate>
jpayne@69 367 @end
jpayne@69 368 @interface TKApplication(TKMenu)
jpayne@69 369 - (void)tkSetMainMenu:(TKMenu *)menu;
jpayne@69 370 @end
jpayne@69 371 @interface TKApplication(TKMenus)
jpayne@69 372 - (void) _setupMenus;
jpayne@69 373 @end
jpayne@69 374 @interface NSApplication(TKNotify)
jpayne@69 375 /* We need to declare this hidden method. */
jpayne@69 376 - (void) _modalSession: (NSModalSession) session sendEvent: (NSEvent *) event;
jpayne@69 377 - (void) _runBackgroundLoop;
jpayne@69 378 @end
jpayne@69 379 @interface TKApplication(TKEvent)
jpayne@69 380 - (NSEvent *)tkProcessEvent:(NSEvent *)theEvent;
jpayne@69 381 @end
jpayne@69 382 @interface TKApplication(TKMouseEvent)
jpayne@69 383 - (NSEvent *)tkProcessMouseEvent:(NSEvent *)theEvent;
jpayne@69 384 @end
jpayne@69 385 @interface TKApplication(TKKeyEvent)
jpayne@69 386 - (NSEvent *)tkProcessKeyEvent:(NSEvent *)theEvent;
jpayne@69 387 @end
jpayne@69 388 @interface TKApplication(TKClipboard)
jpayne@69 389 - (void)tkProvidePasteboard:(TkDisplay *)dispPtr;
jpayne@69 390 - (void)tkCheckPasteboard;
jpayne@69 391 @end
jpayne@69 392 @interface TKApplication(TKHLEvents)
jpayne@69 393 - (void) terminate: (id) sender;
jpayne@69 394 - (void) superTerminate: (id) sender;
jpayne@69 395 - (void) preferences: (id) sender;
jpayne@69 396 - (void) handleQuitApplicationEvent: (NSAppleEventDescriptor *)event
jpayne@69 397 withReplyEvent: (NSAppleEventDescriptor *)replyEvent;
jpayne@69 398 - (void) handleOpenApplicationEvent: (NSAppleEventDescriptor *)event
jpayne@69 399 withReplyEvent: (NSAppleEventDescriptor *)replyEvent;
jpayne@69 400 - (void) handleReopenApplicationEvent: (NSAppleEventDescriptor *)event
jpayne@69 401 withReplyEvent: (NSAppleEventDescriptor *)replyEvent;
jpayne@69 402 - (void) handleShowPreferencesEvent: (NSAppleEventDescriptor *)event
jpayne@69 403 withReplyEvent: (NSAppleEventDescriptor *)replyEvent;
jpayne@69 404 - (void) handleOpenDocumentsEvent: (NSAppleEventDescriptor *)event
jpayne@69 405 withReplyEvent: (NSAppleEventDescriptor *)replyEvent;
jpayne@69 406 - (void) handlePrintDocumentsEvent: (NSAppleEventDescriptor *)event
jpayne@69 407 withReplyEvent: (NSAppleEventDescriptor *)replyEvent;
jpayne@69 408 - (void) handleDoScriptEvent: (NSAppleEventDescriptor *)event
jpayne@69 409 withReplyEvent: (NSAppleEventDescriptor *)replyEvent;
jpayne@69 410 - (void)handleURLEvent: (NSAppleEventDescriptor*)event
jpayne@69 411 withReplyEvent: (NSAppleEventDescriptor*)replyEvent;
jpayne@69 412 @end
jpayne@69 413
jpayne@69 414 VISIBILITY_HIDDEN
jpayne@69 415 /*
jpayne@69 416 * Subclass TKContentView from NSTextInputClient to enable composition and
jpayne@69 417 * input from the Character Palette.
jpayne@69 418 */
jpayne@69 419
jpayne@69 420 @interface TKContentView : NSView <NSTextInputClient>
jpayne@69 421 {
jpayne@69 422 @private
jpayne@69 423 NSString *privateWorkingText;
jpayne@69 424 Bool _tkNeedsDisplay;
jpayne@69 425 NSRect _tkDirtyRect;
jpayne@69 426 NSTrackingArea *trackingArea;
jpayne@69 427 }
jpayne@69 428 @property Bool tkNeedsDisplay;
jpayne@69 429 @property NSRect tkDirtyRect;
jpayne@69 430 @end
jpayne@69 431
jpayne@69 432 @interface TKContentView(TKKeyEvent)
jpayne@69 433 - (void) deleteWorkingText;
jpayne@69 434 - (void) cancelComposingText;
jpayne@69 435 @end
jpayne@69 436
jpayne@69 437 @interface TKContentView(TKWindowEvent)
jpayne@69 438 - (void) addTkDirtyRect: (NSRect) rect;
jpayne@69 439 - (void) clearTkDirtyRect;
jpayne@69 440 - (void) generateExposeEvents: (NSRect) rect;
jpayne@69 441 - (void) tkToolbarButton: (id) sender;
jpayne@69 442 @end
jpayne@69 443
jpayne@69 444 @interface NSWindow(TKWm)
jpayne@69 445 - (NSPoint) tkConvertPointToScreen:(NSPoint)point;
jpayne@69 446 - (NSPoint) tkConvertPointFromScreen:(NSPoint)point;
jpayne@69 447 @end
jpayne@69 448
jpayne@69 449 VISIBILITY_HIDDEN
jpayne@69 450 @interface TKWindow : NSWindow
jpayne@69 451 {
jpayne@69 452 #ifdef __i386__
jpayne@69 453 /* The Objective C runtime used on i386 requires this. */
jpayne@69 454 Window _tkWindow;
jpayne@69 455 #endif
jpayne@69 456 }
jpayne@69 457 @property Window tkWindow;
jpayne@69 458 @end
jpayne@69 459
jpayne@69 460 @interface TKWindow(TKWm)
jpayne@69 461 - (void) tkLayoutChanged;
jpayne@69 462 @end
jpayne@69 463
jpayne@69 464 @interface TKDrawerWindow : NSWindow
jpayne@69 465 {
jpayne@69 466 id _i1, _i2;
jpayne@69 467 #ifdef __i386__
jpayne@69 468 /* The Objective C runtime used on i386 requires this. */
jpayne@69 469 Window _tkWindow;
jpayne@69 470 #endif
jpayne@69 471 }
jpayne@69 472 @property Window tkWindow;
jpayne@69 473 @end
jpayne@69 474
jpayne@69 475 @interface TKPanel : NSPanel
jpayne@69 476 {
jpayne@69 477 #ifdef __i386__
jpayne@69 478 /* The Objective C runtime used on i386 requires this. */
jpayne@69 479 Window _tkWindow;
jpayne@69 480 #endif
jpayne@69 481 }
jpayne@69 482 @property Window tkWindow;
jpayne@69 483 @end
jpayne@69 484
jpayne@69 485 #pragma mark NSMenu & NSMenuItem Utilities
jpayne@69 486
jpayne@69 487 @interface NSMenu(TKUtils)
jpayne@69 488 + (id)menuWithTitle:(NSString *)title;
jpayne@69 489 + (id)menuWithTitle:(NSString *)title menuItems:(NSArray *)items;
jpayne@69 490 + (id)menuWithTitle:(NSString *)title submenus:(NSArray *)submenus;
jpayne@69 491 - (NSMenuItem *)itemWithSubmenu:(NSMenu *)submenu;
jpayne@69 492 - (NSMenuItem *)itemInSupermenu;
jpayne@69 493 @end
jpayne@69 494
jpayne@69 495 @interface NSMenuItem(TKUtils)
jpayne@69 496 + (id)itemWithSubmenu:(NSMenu *)submenu;
jpayne@69 497 + (id)itemWithTitle:(NSString *)title submenu:(NSMenu *)submenu;
jpayne@69 498 + (id)itemWithTitle:(NSString *)title action:(SEL)action;
jpayne@69 499 + (id)itemWithTitle:(NSString *)title action:(SEL)action
jpayne@69 500 target:(id)target;
jpayne@69 501 + (id)itemWithTitle:(NSString *)title action:(SEL)action
jpayne@69 502 keyEquivalent:(NSString *)keyEquivalent;
jpayne@69 503 + (id)itemWithTitle:(NSString *)title action:(SEL)action
jpayne@69 504 target:(id)target keyEquivalent:(NSString *)keyEquivalent;
jpayne@69 505 + (id)itemWithTitle:(NSString *)title action:(SEL)action
jpayne@69 506 keyEquivalent:(NSString *)keyEquivalent
jpayne@69 507 keyEquivalentModifierMask:(NSUInteger)keyEquivalentModifierMask;
jpayne@69 508 + (id)itemWithTitle:(NSString *)title action:(SEL)action
jpayne@69 509 target:(id)target keyEquivalent:(NSString *)keyEquivalent
jpayne@69 510 keyEquivalentModifierMask:(NSUInteger)keyEquivalentModifierMask;
jpayne@69 511 @end
jpayne@69 512
jpayne@69 513 @interface NSColorPanel(TKDialog)
jpayne@69 514 - (void) _setUseModalAppearance: (BOOL) flag;
jpayne@69 515 @end
jpayne@69 516
jpayne@69 517 @interface NSFont(TKFont)
jpayne@69 518 - (NSFont *) bestMatchingFontForCharacters: (const UTF16Char *) characters
jpayne@69 519 length: (NSUInteger) length attributes: (NSDictionary *) attributes
jpayne@69 520 actualCoveredLength: (NSUInteger *) coveredLength;
jpayne@69 521 @end
jpayne@69 522
jpayne@69 523 /*
jpayne@69 524 * This method of NSApplication is not declared in NSApplication.h so we
jpayne@69 525 * declare it here to be a method of the TKMenu category.
jpayne@69 526 */
jpayne@69 527
jpayne@69 528 @interface NSApplication(TKMenu)
jpayne@69 529 - (void) setAppleMenu: (NSMenu *) menu;
jpayne@69 530 @end
jpayne@69 531
jpayne@69 532 /*
jpayne@69 533 * These methods are exposed because they are needed to prevent zombie windows
jpayne@69 534 * on systems with a TouchBar. The TouchBar Key-Value observer holds a
jpayne@69 535 * reference to the key window, which prevents deallocation of the key window
jpayne@69 536 * when it is closed.
jpayne@69 537 */
jpayne@69 538
jpayne@69 539 @interface NSApplication(TkWm)
jpayne@69 540 - (id) _setKeyWindow: (NSWindow *) window;
jpayne@69 541 - (id) _setMainWindow: (NSWindow *) window;
jpayne@69 542 @end
jpayne@69 543
jpayne@69 544
jpayne@69 545 /*
jpayne@69 546 *---------------------------------------------------------------------------
jpayne@69 547 *
jpayne@69 548 * TKNSString --
jpayne@69 549 *
jpayne@69 550 * When Tcl is compiled with TCL_UTF_MAX = 3 (the default for 8.6) it cannot
jpayne@69 551 * deal directly with UTF-8 encoded non-BMP characters, since their UTF-8
jpayne@69 552 * encoding requires 4 bytes. Instead, when using these versions of Tcl, Tk
jpayne@69 553 * uses the CESU-8 encoding internally. This encoding is similar to UTF-8
jpayne@69 554 * except that it allows encoding surrogate characters as 3-byte sequences
jpayne@69 555 * using the same algorithm which UTF-8 uses for non-surrogates. This means
jpayne@69 556 * that a non-BMP character is encoded as a string of length 6. Apple's
jpayne@69 557 * NSString class does not provide a constructor which accepts a CESU-8 encoded
jpayne@69 558 * byte sequence as initial data. So we add a new class which does provide
jpayne@69 559 * such a constructor. It also has a DString property which is a DString whose
jpayne@69 560 * string pointer is a byte sequence encoding the NSString with the current Tk
jpayne@69 561 * encoding, namely UTF-8 if TCL_UTF_MAX >= 4 or CESU-8 if TCL_UTF_MAX = 3.
jpayne@69 562 *
jpayne@69 563 *---------------------------------------------------------------------------
jpayne@69 564 */
jpayne@69 565
jpayne@69 566 @interface TKNSString:NSString {
jpayne@69 567 @private
jpayne@69 568 Tcl_DString _ds;
jpayne@69 569 NSString *_string;
jpayne@69 570 const char *_UTF8String;
jpayne@69 571 }
jpayne@69 572 @property const char *UTF8String;
jpayne@69 573 @property (readonly) Tcl_DString DString;
jpayne@69 574 - (instancetype)initWithTclUtfBytes:(const void *)bytes
jpayne@69 575 length:(NSUInteger)len;
jpayne@69 576 @end
jpayne@69 577
jpayne@69 578 #endif /* _TKMACPRIV */
jpayne@69 579
jpayne@69 580 /*
jpayne@69 581 * Local Variables:
jpayne@69 582 * mode: objc
jpayne@69 583 * c-basic-offset: 4
jpayne@69 584 * fill-column: 79
jpayne@69 585 * coding: utf-8
jpayne@69 586 * End:
jpayne@69 587 */