1 /** 2 Dynamic bindings to the Appkit framework. 3 4 Copyright: Guillaume Piolat 2016. 5 License: $(LINK2 http://www.boost.org/LICENSE_1_0.txt, Boost License 1.0) 6 */ 7 module derelict.cocoa.appkit; 8 9 import std.string; 10 11 import derelict.cocoa.runtime; 12 import derelict.cocoa.foundation; 13 import derelict.cocoa.coreimage; 14 import derelict.cocoa.coregraphics; 15 16 version(X86) 17 version = AnyX86; 18 version(X86_64) 19 version = AnyX86; 20 21 22 // free functions 23 extern (C) nothrow @nogc 24 { 25 alias bool function() pfNSApplicationLoad; 26 } 27 28 __gshared 29 { 30 pfNSApplicationLoad NSApplicationLoad; 31 } 32 33 alias NSApplicationActivationPolicy = NSInteger; 34 enum : NSApplicationActivationPolicy 35 { 36 NSApplicationActivationPolicyRegular = 0, 37 NSApplicationActivationPolicyAccessory = 1, 38 NSApplicationActivationPolicyProhibited = 2 39 } 40 41 struct NSApplication 42 { 43 nothrow @nogc: 44 45 NSObject parent; 46 alias parent this; 47 48 mixin NSObjectTemplate!(NSApplication, "NSApplication"); 49 50 public static NSApplication sharedApplication () 51 { 52 alias fun_t = extern(C) id function (id, SEL) nothrow @nogc; 53 id result = (cast(fun_t)objc_msgSend)(lazyClass!"NSApplication", sel!"sharedApplication"); 54 return NSApplication(result); 55 } 56 57 void setDelegate (id object) 58 { 59 alias fun_t = extern(C) void function (id, SEL, id) nothrow @nogc; 60 (cast(fun_t)objc_msgSend)(_id, sel!"setDelegate:", object.id); 61 } 62 63 void setActivationPolicy(NSApplicationActivationPolicy policy) 64 { 65 alias fun_t = extern(C) void function (id, SEL, NSApplicationActivationPolicy) nothrow @nogc; 66 (cast(fun_t)objc_msgSend)(_id, sel!"setActivationPolicy:", policy); 67 } 68 69 void activateIgnoringOtherApps(BOOL b) 70 { 71 alias fun_t = extern(C) void function (id, SEL, BOOL) nothrow @nogc; 72 (cast(fun_t)objc_msgSend)(_id, sel!"activateIgnoringOtherApps:", b); 73 } 74 75 void run () 76 { 77 alias fun_t = extern(C) void function (id, SEL) nothrow @nogc; 78 (cast(fun_t)objc_msgSend)(_id, sel!"run"); 79 } 80 81 void stop (id sender) 82 { 83 alias fun_t = extern(C) void function (id, SEL, id) nothrow @nogc; 84 (cast(fun_t)objc_msgSend)(_id, sel!"stop:", sender); 85 } 86 87 void sendEvent(NSEvent event) 88 { 89 alias fun_t = extern(C) void function (id, SEL, id) nothrow @nogc; 90 (cast(fun_t)objc_msgSend)(_id, sel!"sendEvent:", event._id); 91 } 92 } 93 94 95 // NSResponder 96 97 struct NSResponder 98 { 99 nothrow @nogc: 100 NSObject parent; 101 alias parent this; 102 103 mixin NSObjectTemplate!(NSResponder, "NSResponder"); 104 } 105 106 107 // NSView 108 109 alias NSBorderType = NSUInteger; 110 enum : NSBorderType 111 { 112 NSNoBorder = 0, 113 NSLineBorder = 1, 114 NSBezelBorder = 2, 115 NSGrooveBorder = 3 116 } 117 118 alias NSAutoresizingMaskOptions = NSUInteger; 119 enum : NSAutoresizingMaskOptions 120 { 121 NSViewNotSizable = 0, 122 NSViewMinXMargin = 1, 123 NSViewWidthSizable = 2, 124 NSViewMaxXMargin = 4, 125 NSViewMinYMargin = 8, 126 NSViewHeightSizable = 16, 127 NSViewMaxYMargin = 32 128 } 129 130 131 struct NSView 132 { 133 nothrow @nogc: 134 135 NSResponder parent; 136 alias parent this; 137 138 mixin NSObjectTemplate!(NSView, "NSView"); 139 140 void initWithFrame(NSRect rect) 141 { 142 alias fun_t = extern(C) void function (id, SEL, NSRect) nothrow @nogc; 143 (cast(fun_t)objc_msgSend)(_id, sel!"initWithFrame:", rect); 144 } 145 146 void addSubview(NSView subView) 147 { 148 alias fun_t = extern(C) void function (id, SEL, id) nothrow @nogc; 149 (cast(fun_t)objc_msgSend)(_id, sel!"addSubview:", subView._id); 150 } 151 152 void removeFromSuperview() 153 { 154 alias fun_t = extern(C) void function (id, SEL) nothrow @nogc; 155 (cast(fun_t)objc_msgSend)(_id, sel!"removeFromSuperview"); 156 } 157 158 NSWindow window() 159 { 160 alias fun_t = extern(C) id function (id, SEL) nothrow @nogc; 161 id result = (cast(fun_t)objc_msgSend)(_id, sel!"window"); 162 return NSWindow(result); 163 } 164 165 void setNeedsDisplayInRect(NSRect rect) 166 { 167 alias fun_t = extern(C) void function (id, SEL, NSRect) nothrow @nogc; 168 (cast(fun_t)objc_msgSend)(_id, sel!"setNeedsDisplayInRect:", rect); 169 } 170 171 NSPoint convertPoint(NSPoint point, NSView view) 172 { 173 alias fun_t = extern(C) NSPoint function (id, const(SEL), NSPoint, id) nothrow @nogc; 174 return (cast(fun_t)objc_msgSend)(_id, sel!"convertPoint:fromView:", point, view._id); 175 } 176 177 NSRect convertRect(NSRect rect, NSView view) 178 { 179 alias fun_t = extern(C) NSRect function (id, const(SEL), NSRect, id) nothrow @nogc; 180 version(AnyX86) 181 return (cast(fun_t)objc_msgSend_stret)(_id, sel!"convertRect:fromView:", rect, view._id); 182 else 183 return (cast(fun_t)objc_msgSend )(_id, sel!"convertRect:fromView:", rect, view._id); 184 } 185 186 NSRect frame() 187 { 188 alias fun_t = extern(C) NSRect function (id, const(SEL)) nothrow @nogc; 189 version(AnyX86) 190 return (cast(fun_t)objc_msgSend_stret)(_id, sel!"frame"); 191 else 192 return (cast(fun_t)objc_msgSend )(_id, sel!"frame"); 193 } 194 195 NSRect bounds() 196 { 197 alias fun_t = extern(C) NSRect function (id, const(SEL)) nothrow @nogc; 198 version(AnyX86) 199 return (cast(fun_t)objc_msgSend_stret)(_id, sel!"bounds"); 200 else 201 return (cast(fun_t)objc_msgSend )(_id, sel!"bounds"); 202 } 203 204 CALayer layer() 205 { 206 alias fun_t = extern(C) id function (id, SEL) nothrow @nogc; 207 id result = (cast(fun_t)objc_msgSend)(_id, sel!"layer"); 208 return CALayer(result); 209 } 210 211 void setWantsLayer(BOOL value) 212 { 213 alias fun_t = extern(C) void function (id, SEL, BOOL) nothrow @nogc; 214 (cast(fun_t)objc_msgSend)(_id, sel!"setWantsLayer:", value); 215 } 216 217 void getRectsBeingDrawn(const(NSRect)** rects, NSInteger* count) 218 { 219 alias fun_t = extern(C) void function (id, SEL, const(NSRect)**, NSInteger*) nothrow @nogc; 220 (cast(fun_t)objc_msgSend)(_id, sel!"getRectsBeingDrawn:count:", rects, count); 221 } 222 223 void setFrameSize(NSSize newSize) 224 { 225 alias fun_t = extern(C) void function (id, SEL, NSSize) nothrow @nogc; 226 (cast(fun_t)objc_msgSend)(_id, sel!"setFrameSize:", newSize); 227 } 228 229 void addTrackingArea(NSTrackingArea trackingArea) 230 { 231 alias fun_t = extern(C) void function (id, SEL, id) nothrow @nogc; 232 (cast(fun_t)objc_msgSend)(_id, sel!"addTrackingArea:", trackingArea._id); 233 } 234 235 void removeTrackingArea(NSTrackingArea trackingArea) 236 { 237 alias fun_t = extern(C) void function (id, SEL, id) nothrow @nogc; 238 (cast(fun_t)objc_msgSend)(_id, sel!"removeTrackingArea:", trackingArea._id); 239 } 240 } 241 242 enum NSTrackingMouseEnteredAndExited = 1; 243 enum NSTrackingActiveAlways = 0x80; 244 245 // NSTrackingArea 246 247 struct NSTrackingArea 248 { 249 nothrow @nogc: 250 251 NSObject parent; 252 alias parent this; 253 254 mixin NSObjectTemplate!(NSTrackingArea, "NSTrackingArea"); 255 256 void initWithRect(NSRect rect, NSUInteger options, NSView owner, void* userData) 257 { 258 alias fun_t = extern(C) void function (id, SEL, NSRect, NSUInteger, id, void*) nothrow @nogc; 259 (cast(fun_t)objc_msgSend)(_id, sel!"initWithRect:options:owner:userInfo:", rect, options, owner._id, userData); 260 } 261 } 262 263 __gshared 264 { 265 NSString kCAContentsFormatRGBA8Uint; 266 } 267 268 269 // CALayer 270 struct CALayer 271 { 272 nothrow @nogc: 273 274 NSObject parent; 275 alias parent this; 276 277 mixin NSObjectTemplate!(CALayer, "CALayer"); 278 279 void setDrawsAsynchronously(BOOL value) 280 { 281 alias fun_t = extern(C) void function (id, SEL, BOOL) nothrow @nogc; 282 (cast(fun_t)objc_msgSend)(_id, sel!"setDrawsAsynchronously:", value); 283 } 284 285 void setOpaque(BOOL value) 286 { 287 alias fun_t = extern(C) void function (id, SEL, BOOL) nothrow @nogc; 288 (cast(fun_t)objc_msgSend)(_id, sel!"setOpaque:", value); 289 } 290 291 void setContentsFormat(NSString fmt) 292 { 293 alias fun_t = extern(C) void function (id, SEL, id) nothrow @nogc; 294 (cast(fun_t)objc_msgSend)(_id, sel!"setContentsFormat:", fmt._id); 295 } 296 } 297 298 299 // NSWindow 300 301 alias NSBackingStoreType = NSUInteger; 302 enum : NSBackingStoreType 303 { 304 NSBackingStoreRetained = 0, 305 NSBackingStoreNonretained = 1, 306 NSBackingStoreBuffered = 2 307 } 308 309 enum : NSUInteger 310 { 311 NSBorderlessWindowMask = 0, 312 NSTitledWindowMask = 1 << 0, 313 NSClosableWindowMask = 1 << 1, 314 NSMiniaturizableWindowMask = 1 << 2, 315 NSResizableWindowMask = 1 << 3, 316 NSTexturedBackgroundWindowMask = 1 << 8 317 } 318 319 struct NSWindow 320 { 321 nothrow @nogc: 322 323 NSResponder parent; 324 alias parent this; 325 326 mixin NSObjectTemplate!(NSWindow, "NSWindow"); 327 328 void initWithContentRect(NSRect contentRect) 329 { 330 alias fun_t = extern(C) void function (id, SEL, NSRect) nothrow @nogc; 331 (cast(fun_t)objc_msgSend)(_id, sel!"initWithContentRect:", contentRect); 332 } 333 334 void initWithContentRect(NSRect contentRect, NSUInteger windowStyle, NSBackingStoreType bufferingType, BOOL deferCreation) 335 { 336 alias fun_t = extern(C) void function (id, SEL, NSRect, NSUInteger, NSBackingStoreType, BOOL) nothrow @nogc; 337 (cast(fun_t)objc_msgSend)(_id, sel!"initWithContentRect:styleMask:backing:defer:", contentRect, windowStyle, bufferingType, deferCreation); 338 } 339 340 NSView contentView() 341 { 342 alias fun_t = extern(C) id function (id, SEL) nothrow @nogc; 343 id result = (cast(fun_t)objc_msgSend)(_id, sel!"contentView"); 344 return NSView(result); 345 } 346 347 void makeKeyAndOrderFront() 348 { 349 alias fun_t = extern(C) void function (id, SEL) nothrow @nogc; 350 (cast(fun_t)objc_msgSend)(_id, sel!"makeKeyAndOrderFront:"); 351 } 352 353 bool makeFirstResponder(NSResponder responder) 354 { 355 alias fun_t = extern(C) BOOL function (id, SEL, id) nothrow @nogc; 356 BOOL result = (cast(fun_t)objc_msgSend)(_id, sel!"makeFirstResponder:", responder._id); 357 return result != NO; 358 } 359 360 NSEvent nextEventMatchingMask(NSUInteger eventMask) 361 { 362 alias fun_t = extern(C) id function (id, SEL, NSUInteger) nothrow @nogc; 363 id result = (cast(fun_t)objc_msgSend)(_id, sel!"nextEventMatchingMask:", eventMask); 364 return NSEvent(result); 365 } 366 367 NSPoint mouseLocationOutsideOfEventStream() 368 { 369 alias fun_t = extern(C) NSPoint function (id, SEL) nothrow @nogc; 370 return (cast(fun_t)objc_msgSend)(_id, sel!"mouseLocationOutsideOfEventStream"); 371 } 372 373 void setAcceptsMouseMovedEvents(bool b) 374 { 375 alias fun_t = extern(C) void function (id, SEL, BOOL) nothrow @nogc; 376 (cast(fun_t)objc_msgSend)(_id, sel!"setAcceptsMouseMovedEvents:", b ? YES : NO); 377 } 378 } 379 380 381 alias NSEventType = int; 382 enum : NSEventType 383 { 384 NSLeftMouseDown = 1, 385 NSLeftMouseUp = 2, 386 NSRightMouseDown = 3, 387 NSRightMouseUp = 4, 388 NSMouseMoved = 5, 389 NSLeftMouseDragged = 6, 390 NSRightMouseDragged = 7, 391 NSMouseEntered = 8, 392 NSMouseExited = 9, 393 NSKeyDown = 10, 394 NSKeyUp = 11, 395 NSFlagsChanged = 12, 396 NSAppKitDefined = 13, 397 NSSystemDefined = 14, 398 NSApplicationDefined = 15, 399 NSPeriodic = 16, 400 NSCursorUpdate = 17, 401 NSScrollWheel = 22, 402 NSTabletPoint = 23, 403 NSTabletProximity = 24, 404 NSOtherMouseDown = 25, 405 NSOtherMouseUp = 26, 406 NSOtherMouseDragged = 27, 407 NSRotate = 18, 408 NSBeginGesture = 19, 409 NSEndGesture = 20, 410 NSMagnify = 30, 411 NSSwipe = 31 412 } 413 414 enum : NSUInteger 415 { 416 NSLeftMouseDownMask = 1 << NSLeftMouseDown, 417 NSLeftMouseUpMask = 1 << NSLeftMouseUp, 418 NSRightMouseDownMask = 1 << NSRightMouseDown, 419 NSRightMouseUpMask = 1 << NSRightMouseUp, 420 NSMouseMovedMask = 1 << NSMouseMoved, 421 NSLeftMouseDraggedMask = 1 << NSLeftMouseDragged, 422 NSRightMouseDraggedMask = 1 << NSRightMouseDragged, 423 NSMouseEnteredMask = 1 << NSMouseEntered, 424 NSMouseExitedMask = 1 << NSMouseExited, 425 NSKeyDownMask = 1 << NSKeyDown, 426 NSKeyUpMask = 1 << NSKeyUp, 427 NSFlagsChangedMask = 1 << NSFlagsChanged, 428 NSAppKitDefinedMask = 1 << NSAppKitDefined, 429 NSSystemDefinedMask = 1 << NSSystemDefined, 430 NSApplicationDefinedMask = 1 << NSApplicationDefined, 431 NSPeriodicMask = 1 << NSPeriodic, 432 NSCursorUpdateMask = 1 << NSCursorUpdate, 433 NSScrollWheelMask = 1 << NSScrollWheel, 434 NSTabletPointMask = 1 << NSTabletPoint, 435 NSTabletProximityMask = 1 << NSTabletProximity, 436 NSOtherMouseDownMask = 1 << NSOtherMouseDown, 437 NSOtherMouseUpMask = 1 << NSOtherMouseUp, 438 NSOtherMouseDraggedMask = 1 << NSOtherMouseDragged, 439 NSRotateMask = 1 << NSRotate, 440 NSBeginGestureMask = 1 << NSBeginGesture, 441 NSEndGestureMask = 1 << NSEndGesture, 442 NSMagnifyMask = 1 << NSMagnify, 443 NSSwipeMask = 1 << NSSwipe, 444 NSAnyEventMask = 0xffffffffU, 445 } 446 447 /// Keycodes 448 enum : ushort 449 { 450 kVK_ANSI_A = 0x00, 451 kVK_ANSI_S = 0x01, 452 kVK_ANSI_D = 0x02, 453 kVK_ANSI_F = 0x03, 454 kVK_ANSI_H = 0x04, 455 kVK_ANSI_G = 0x05, 456 kVK_ANSI_Z = 0x06, 457 kVK_ANSI_X = 0x07, 458 kVK_ANSI_C = 0x08, 459 kVK_ANSI_V = 0x09, 460 kVK_ANSI_B = 0x0B, 461 kVK_ANSI_Q = 0x0C, 462 kVK_ANSI_W = 0x0D, 463 kVK_ANSI_E = 0x0E, 464 kVK_ANSI_R = 0x0F, 465 kVK_ANSI_Y = 0x10, 466 kVK_ANSI_T = 0x11, 467 kVK_ANSI_1 = 0x12, 468 kVK_ANSI_2 = 0x13, 469 kVK_ANSI_3 = 0x14, 470 kVK_ANSI_4 = 0x15, 471 kVK_ANSI_6 = 0x16, 472 kVK_ANSI_5 = 0x17, 473 kVK_ANSI_Equal = 0x18, 474 kVK_ANSI_9 = 0x19, 475 kVK_ANSI_7 = 0x1A, 476 kVK_ANSI_Minus = 0x1B, 477 kVK_ANSI_8 = 0x1C, 478 kVK_ANSI_0 = 0x1D, 479 kVK_ANSI_RightBracket = 0x1E, 480 kVK_ANSI_O = 0x1F, 481 kVK_ANSI_U = 0x20, 482 kVK_ANSI_LeftBracket = 0x21, 483 kVK_ANSI_I = 0x22, 484 kVK_ANSI_P = 0x23, 485 kVK_ANSI_L = 0x25, 486 kVK_ANSI_J = 0x26, 487 kVK_ANSI_Quote = 0x27, 488 kVK_ANSI_K = 0x28, 489 kVK_ANSI_Semicolon = 0x29, 490 kVK_ANSI_Backslash = 0x2A, 491 kVK_ANSI_Comma = 0x2B, 492 kVK_ANSI_Slash = 0x2C, 493 kVK_ANSI_N = 0x2D, 494 kVK_ANSI_M = 0x2E, 495 kVK_ANSI_Period = 0x2F, 496 kVK_ANSI_Grave = 0x32, 497 kVK_ANSI_KeypadDecimal = 0x41, 498 kVK_ANSI_KeypadMultiply = 0x43, 499 kVK_ANSI_KeypadPlus = 0x45, 500 kVK_ANSI_KeypadClear = 0x47, 501 kVK_ANSI_KeypadDivide = 0x4B, 502 kVK_ANSI_KeypadEnter = 0x4C, 503 kVK_ANSI_KeypadMinus = 0x4E, 504 kVK_ANSI_KeypadEquals = 0x51, 505 kVK_ANSI_Keypad0 = 0x52, 506 kVK_ANSI_Keypad1 = 0x53, 507 kVK_ANSI_Keypad2 = 0x54, 508 kVK_ANSI_Keypad3 = 0x55, 509 kVK_ANSI_Keypad4 = 0x56, 510 kVK_ANSI_Keypad5 = 0x57, 511 kVK_ANSI_Keypad6 = 0x58, 512 kVK_ANSI_Keypad7 = 0x59, 513 kVK_ANSI_Keypad8 = 0x5B, 514 kVK_ANSI_Keypad9 = 0x5C 515 } 516 517 /// Keycodes for keys that are independent of keyboard layout. 518 enum : ushort 519 { 520 kVK_Return = 0x24, 521 kVK_Tab = 0x30, 522 kVK_Space = 0x31, 523 kVK_Delete = 0x33, 524 kVK_Escape = 0x35, 525 kVK_Command = 0x37, 526 kVK_Shift = 0x38, 527 kVK_CapsLock = 0x39, 528 kVK_Option = 0x3A, 529 kVK_Control = 0x3B, 530 kVK_RightShift = 0x3C, 531 kVK_RightOption = 0x3D, 532 kVK_RightControl = 0x3E, 533 kVK_Function = 0x3F, 534 kVK_F17 = 0x40, 535 kVK_VolumeUp = 0x48, 536 kVK_VolumeDown = 0x49, 537 kVK_Mute = 0x4A, 538 kVK_F18 = 0x4F, 539 kVK_F19 = 0x50, 540 kVK_F20 = 0x5A, 541 kVK_F5 = 0x60, 542 kVK_F6 = 0x61, 543 kVK_F7 = 0x62, 544 kVK_F3 = 0x63, 545 kVK_F8 = 0x64, 546 kVK_F9 = 0x65, 547 kVK_F11 = 0x67, 548 kVK_F13 = 0x69, 549 kVK_F16 = 0x6A, 550 kVK_F14 = 0x6B, 551 kVK_F10 = 0x6D, 552 kVK_F12 = 0x6F, 553 kVK_F15 = 0x71, 554 kVK_Help = 0x72, 555 kVK_Home = 0x73, 556 kVK_PageUp = 0x74, 557 kVK_ForwardDelete = 0x75, 558 kVK_F4 = 0x76, 559 kVK_End = 0x77, 560 kVK_F2 = 0x78, 561 kVK_PageDown = 0x79, 562 kVK_F1 = 0x7A, 563 kVK_LeftArrow = 0x7B, 564 kVK_RightArrow = 0x7C, 565 kVK_DownArrow = 0x7D, 566 kVK_UpArrow = 0x7E 567 } 568 569 /// ISO keyboards only. 570 enum : ushort 571 { 572 kVK_ISO_Section = 0x0A 573 } 574 575 ///JIS keyboards only. 576 enum : ushort 577 { 578 kVK_JIS_Yen = 0x5D, 579 kVK_JIS_Underscore = 0x5E, 580 kVK_JIS_KeypadComma = 0x5F, 581 kVK_JIS_Eisu = 0x66, 582 kVK_JIS_Kana = 0x68 583 } 584 585 alias NSEventModifierFlags = int; 586 enum : NSEventModifierFlags 587 { 588 NSAlphaShiftKeyMask = 1 << 16, 589 NSShiftKeyMask = 1 << 17, 590 NSControlKeyMask = 1 << 18, 591 NSAlternateKeyMask = 1 << 19, 592 NSCommandKeyMask = 1 << 20, 593 NSNumericPadKeyMask = 1 << 21, 594 NSHelpKeyMask = 1 << 22, 595 NSFunctionKeyMask = 1 << 23, 596 NSDeviceIndependentModifierFlagsMask = 0xffff0000U 597 } 598 599 struct NSEvent 600 { 601 nothrow @nogc: 602 603 NSObject parent; 604 alias parent this; 605 606 mixin NSObjectTemplate!(NSEvent, "NSEvent"); 607 608 NSWindow window() 609 { 610 alias fun_t = extern(C) id function (id, SEL) nothrow @nogc; 611 id result = (cast(fun_t)objc_msgSend)(_id, sel!"window"); 612 return NSWindow(result); 613 } 614 615 NSEventType type() 616 { 617 alias fun_t = extern(C) id function (id, SEL) nothrow @nogc; 618 id result = (cast(fun_t)objc_msgSend)(_id, sel!"type"); 619 return cast(NSEventType)result; 620 } 621 622 int clickCount() 623 { 624 alias fun_t = extern(C) NSInteger function (id, SEL) nothrow @nogc; 625 return cast(int)( (cast(fun_t)objc_msgSend)(_id, sel!"clickCount") ); 626 } 627 628 int buttonNumber() 629 { 630 alias fun_t = extern(C) NSInteger function (id, SEL) nothrow @nogc; 631 return cast(int)( (cast(fun_t)objc_msgSend)(_id, sel!"buttonNumber") ); 632 } 633 634 uint pressedMouseButtons() 635 { 636 alias fun_t = extern(C) NSUInteger function (id, SEL) nothrow @nogc; 637 return cast(uint)( (cast(fun_t)objc_msgSend)(getClassID(), sel!"pressedMouseButtons") ); 638 } 639 640 NSEventModifierFlags modifierFlags() 641 { 642 alias fun_t = extern(C) NSEventModifierFlags function (id, SEL) nothrow @nogc; 643 return cast(uint)( (cast(fun_t)objc_msgSend)(_id, sel!"modifierFlags") ); 644 } 645 646 NSPoint mouseLocation() 647 { 648 alias fun_t = extern(C) NSPoint function (id, SEL) nothrow @nogc; 649 return (cast(fun_t)objc_msgSend)(getClassID(), sel!"mouseLocation"); 650 } 651 652 double deltaX() 653 { 654 alias fun_t = extern(C) double function (id, SEL) nothrow @nogc; 655 version(X86) 656 return (cast(fun_t)objc_msgSend_fpret)(_id, sel!"deltaX"); 657 else version(X86_64) 658 return (cast(fun_t)objc_msgSend)(_id, sel!"deltaX"); 659 else 660 return (cast(fun_t)objc_msgSend)(_id, sel!"deltaX"); 661 } 662 663 double deltaY() 664 { 665 alias fun_t = extern(C) double function (id, SEL) nothrow @nogc; 666 version(X86) 667 return (cast(fun_t)objc_msgSend_fpret)(_id, sel!"deltaY"); 668 else version(X86_64) 669 return (cast(fun_t)objc_msgSend)(_id, sel!"deltaY"); 670 else 671 return (cast(fun_t)objc_msgSend)(_id, sel!"deltaY"); 672 } 673 674 ushort keyCode() 675 { 676 alias fun_t = extern(C) ushort function (id, SEL) nothrow @nogc; 677 return (cast(fun_t)objc_msgSend)(_id, sel!"keyCode"); 678 } 679 680 NSString charactersIgnoringModifiers() 681 { 682 alias fun_t = extern(C) id function (id, SEL) nothrow @nogc; 683 auto id = (cast(fun_t)objc_msgSend)(_id, sel!"charactersIgnoringModifiers"); 684 return NSString(id); 685 } 686 687 NSPoint locationInWindow() 688 { 689 alias fun_t = extern(C) NSPoint function (id, SEL) nothrow @nogc; 690 fun_t fun = cast(fun_t)objc_msgSend; 691 SEL sel = sel!"locationInWindow"; 692 return fun(_id, sel); 693 } 694 } 695 696 struct NSGraphicsContext 697 { 698 nothrow @nogc: 699 NSObject parent; 700 alias parent this; 701 702 mixin NSObjectTemplate!(NSGraphicsContext, "NSGraphicsContext"); 703 704 static NSGraphicsContext currentContext() 705 { 706 alias fun_t = extern(C) id function (id, SEL) nothrow @nogc; 707 id result = (cast(fun_t)objc_msgSend)(getClassID(), sel!"currentContext"); 708 return NSGraphicsContext(result); 709 } 710 711 void saveGraphicsState() 712 { 713 alias fun_t = extern(C) void function (id, SEL) nothrow @nogc; 714 (cast(fun_t)objc_msgSend)(_id, sel!"saveGraphicsState"); 715 } 716 717 void restoreGraphicsState() 718 { 719 alias fun_t = extern(C) void function (id, SEL) nothrow @nogc; 720 (cast(fun_t)objc_msgSend)(_id, sel!"restoreGraphicsState"); 721 } 722 723 bool flipped() 724 { 725 alias fun_t = extern(C) BOOL function (id, SEL) nothrow @nogc; 726 return (cast(fun_t)objc_msgSend)(_id, sel!"flipped") != NO; 727 } 728 729 CIContext getCIContext() 730 { 731 alias fun_t = extern(C) id function (id, SEL) nothrow @nogc; 732 id result = (cast(fun_t)objc_msgSend)(_id, sel!"CIContext"); 733 return CIContext(result); 734 } 735 736 CGContextRef getCGContext() 737 { 738 alias fun_t = extern(C) CGContextRef function (id, SEL) nothrow @nogc; 739 CGContextRef result = (cast(fun_t)objc_msgSend)(_id, sel!"CGContext"); 740 return result; 741 } 742 } 743 744 struct NSColorSpace 745 { 746 nothrow @nogc: 747 748 NSObject parent; 749 alias parent this; 750 751 mixin NSObjectTemplate!(NSColorSpace, "NSColorSpace"); 752 753 static NSColorSpace sRGBColorSpace() 754 { 755 alias fun_t = extern(C) id function (id, SEL) nothrow @nogc; 756 return NSColorSpace( (cast(fun_t)objc_msgSend)(getClassID(), sel!"sRGBColorSpace") ); 757 } 758 759 // Should the NSColorSpace outlive the returned reference? Documentation says nothing. 760 CGColorSpaceRef CGColorSpace() 761 { 762 alias fun_t = extern(C) CGColorSpaceRef function (id, SEL) nothrow @nogc; 763 return (cast(fun_t)objc_msgSend)(_id, sel!"CGColorSpace"); 764 } 765 } 766 767 struct NSCursor 768 { 769 nothrow @nogc: 770 771 NSObject parent; 772 alias parent this; 773 774 mixin NSObjectTemplate!(NSCursor, "NSCursor"); 775 776 static NSCursor arrowCursor() 777 { 778 alias fun_t = extern(C) id function (id, SEL) nothrow @nogc; 779 return NSCursor( (cast(fun_t)objc_msgSend)(getClassID(), sel!"arrowCursor") ); 780 } 781 782 static NSCursor crosshairCursor() 783 { 784 alias fun_t = extern(C) id function (id, SEL) nothrow @nogc; 785 return NSCursor( (cast(fun_t)objc_msgSend)(getClassID(), sel!"crosshairCursor") ); 786 } 787 788 static NSCursor pointingHandCursor() 789 { 790 alias fun_t = extern(C) id function (id, SEL) nothrow @nogc; 791 return NSCursor( (cast(fun_t)objc_msgSend)(getClassID(), sel!"pointingHandCursor") ); 792 } 793 794 static NSCursor openHandCursor() 795 { 796 alias fun_t = extern(C) id function (id, SEL) nothrow @nogc; 797 return NSCursor( (cast(fun_t)objc_msgSend)(getClassID(), sel!"openHandCursor") ); 798 } 799 800 static NSCursor closedHandCursor() 801 { 802 alias fun_t = extern(C) id function (id, SEL) nothrow @nogc; 803 return NSCursor( (cast(fun_t)objc_msgSend)(getClassID(), sel!"closedHandCursor") ); 804 } 805 806 static NSCursor resizeLeftRightCursor() 807 { 808 alias fun_t = extern(C) id function (id, SEL) nothrow @nogc; 809 return NSCursor( (cast(fun_t)objc_msgSend)(getClassID(), sel!"resizeLeftRightCursor") ); 810 } 811 812 static NSCursor resizeUpDownCursor() 813 { 814 alias fun_t = extern(C) id function (id, SEL) nothrow @nogc; 815 return NSCursor( (cast(fun_t)objc_msgSend)(getClassID(), sel!"resizeUpDownCursor") ); 816 } 817 818 static void hide() 819 { 820 alias fun_t = extern(C) id function (id, SEL) nothrow @nogc; 821 (cast(fun_t)objc_msgSend)(getClassID(), sel!"hide"); 822 } 823 824 static void unhide() 825 { 826 alias fun_t = extern(C) id function (id, SEL) nothrow @nogc; 827 (cast(fun_t)objc_msgSend)(getClassID(), sel!"unhide"); 828 } 829 830 static void pop() 831 { 832 alias fun_t = extern(C) id function (id, SEL) nothrow @nogc; 833 (cast(fun_t)objc_msgSend)(getClassID(), sel!"pop"); 834 } 835 836 void push() 837 { 838 alias fun_t = extern(C) void function (id, SEL) nothrow @nogc; 839 objc_msgSend(_id, sel!"push"); 840 } 841 842 void set() 843 { 844 alias fun_t = extern(C) void function (id, SEL) nothrow @nogc; 845 objc_msgSend(_id, sel!"set"); 846 } 847 }