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