1 /* 2 * Copyright (c) 2015 Guillaume Piolat 3 * All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions are 7 * met: 8 * 9 * * Redistributions of source code must retain the above copyright 10 * notice, this list of conditions and the following disclaimer. 11 * 12 * * Redistributions in binary form must reproduce the above copyright 13 * notice, this list of conditions and the following disclaimer in the 14 * documentation and/or other materials provided with the distribution. 15 * 16 * * Neither the names 'Derelict', 'DerelictSDL', nor the names of its contributors 17 * may be used to endorse or promote products derived from this software 18 * without specific prior written permission. 19 * 20 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 21 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 22 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 23 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR 24 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 25 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 26 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 27 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 28 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 29 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 30 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 31 */ 32 /** 33 Dynamic bindings to the HIToolbox framework. 34 */ 35 module derelict.carbon.hitoolbox; 36 37 import derelict.carbon.corefoundation; 38 import derelict.carbon.coregraphics; 39 40 41 alias WindowRef = void*; // This actually belongs to QD framework 42 43 // <HIToolbox/CarbonEventsCore.h.h> 44 45 alias EventRef = void*; 46 alias EventLoopRef = void*; 47 alias EventLoopTimerRef = void*; 48 alias EventHandlerRef = void*; 49 alias EventHandlerCallRef = void*; 50 alias EventTargetRef = void*; 51 52 alias EventParamName = OSType; 53 alias EventParamType = OSType; 54 alias EventTime = double; 55 alias EventTimeout = EventTime; 56 alias EventTimerInterval = EventTime; 57 58 enum EventTime kEventDurationSecond = 1.0; 59 60 enum : int 61 { 62 eventAlreadyPostedErr = -9860, 63 eventTargetBusyErr = -9861, 64 eventClassInvalidErr = -9862, 65 eventClassIncorrectErr = -9864, 66 eventDeferAccessibilityEventErr = -9865, 67 eventHandlerAlreadyInstalledErr = -9866, 68 eventInternalErr = -9868, 69 eventKindIncorrectErr = -9869, 70 eventParameterNotFoundErr = -9870, 71 eventNotHandledErr = -9874, 72 eventLoopTimedOutErr = -9875, 73 eventLoopQuitErr = -9876, 74 eventNotInQueueErr = -9877, 75 eventHotKeyExistsErr = -9878, 76 eventHotKeyInvalidErr = -9879, 77 eventPassToNextTargetErr = -9880 78 } 79 80 81 struct EventTypeSpec 82 { 83 OSType eventClass; 84 UInt32 eventKind; 85 } 86 87 extern (C) nothrow @nogc 88 { 89 alias da_GetMainEventLoop = EventLoopRef function(); 90 alias da_InstallEventHandler = OSStatus function(EventTargetRef, EventHandlerUPP, ItemCount, const(EventTypeSpec)*, void*, EventHandlerRef*); 91 alias da_GetEventClass = OSType function(EventRef inEvent); 92 alias da_GetEventKind = UInt32 function(EventRef inEvent); 93 alias da_GetEventParameter = OSStatus function(EventRef, EventParamName, EventParamType, EventParamType*, ByteCount, ByteCount*, void*); 94 alias da_InstallEventLoopTimer = OSStatus function(EventLoopRef, EventTimerInterval, EventTimerInterval, 95 EventLoopTimerUPP, void*, EventLoopTimerRef*); 96 97 alias da_RemoveEventHandler = OSStatus function(EventHandlerRef); 98 alias da_RemoveEventLoopTimer = OSStatus function(EventLoopTimerRef); 99 } 100 101 __gshared 102 { 103 da_GetMainEventLoop GetMainEventLoop; 104 da_InstallEventHandler InstallEventHandler; 105 da_GetEventClass GetEventClass; 106 da_GetEventKind GetEventKind; 107 da_GetEventParameter GetEventParameter; 108 da_InstallEventLoopTimer InstallEventLoopTimer; 109 da_RemoveEventLoopTimer RemoveEventLoopTimer; 110 da_RemoveEventHandler RemoveEventHandler; 111 } 112 113 114 extern(C) nothrow 115 { 116 alias EventHandlerProcPtr = OSStatus function(EventHandlerCallRef inHandlerCallRef, EventRef inEvent, void *inUserData); 117 alias EventHandlerUPP = EventHandlerProcPtr; 118 alias EventLoopTimerUPP = void function(EventLoopTimerRef inTimer, void* inUserData); 119 } 120 121 122 123 // <HIToolbox/CarbonEvents.h> 124 125 enum : int 126 { 127 kEventClassMouse = CCONST('m', 'o', 'u', 's'), 128 kEventClassKeyboard = CCONST('k', 'e', 'y', 'b'), 129 kEventClassTextInput = CCONST('t', 'e', 'x', 't'), 130 kEventClassApplication = CCONST('a', 'p', 'p', 'l'), 131 kEventClassAppleEvent = CCONST('e', 'p', 'p', 'c'), 132 kEventClassMenu = CCONST('m', 'e', 'n', 'u'), 133 kEventClassWindow = CCONST('w', 'i', 'n', 'd'), 134 kEventClassControl = CCONST('c', 'n', 't', 'l'), 135 kEventClassCommand = CCONST('c', 'm', 'd', 's'), 136 kEventClassTablet = CCONST('t', 'b', 'l', 't'), 137 kEventClassVolume = CCONST('v', 'o', 'l', ' '), 138 kEventClassAppearance = CCONST('a', 'p', 'p', 'm'), 139 kEventClassService = CCONST('s', 'e', 'r', 'v'), 140 kEventClassToolbar = CCONST('t', 'b', 'a', 'r'), 141 kEventClassToolbarItem = CCONST('t', 'b', 'i', 't'), 142 kEventClassToolbarItemView = CCONST('t', 'b', 'i', 'v'), 143 kEventClassAccessibility = CCONST('a', 'c', 'c', 'e'), 144 kEventClassSystem = CCONST('m', 'a', 'c', 's'), 145 kEventClassInk = CCONST('i', 'n', 'k', ' '), 146 kEventClassTSMDocumentAccess = CCONST('t', 'd', 'a', 'c'), 147 kEventClassGesture = CCONST('g', 'e', 's', 't') 148 } 149 150 enum : int 151 { 152 kEventControlInitialize = 1000, 153 kEventControlDispose = 1001, 154 kEventControlGetOptimalBounds = 1003, 155 kEventControlOptimalBoundsChanged = 1004, 156 kEventControlDefInitialize = kEventControlInitialize, 157 kEventControlDefDispose = kEventControlDispose, 158 kEventControlHit = 1, 159 kEventControlSimulateHit = 2, 160 kEventControlHitTest = 3, 161 kEventControlDraw = 4, 162 kEventControlApplyBackground = 5, 163 kEventControlApplyTextColor = 6, 164 kEventControlSetFocusPart = 7, 165 kEventControlGetFocusPart = 8, 166 kEventControlActivate = 9, 167 kEventControlDeactivate = 10, 168 kEventControlSetCursor = 11, 169 kEventControlContextualMenuClick = 12, 170 kEventControlClick = 13, 171 kEventControlGetNextFocusCandidate = 14, 172 kEventControlGetAutoToggleValue = 15, 173 kEventControlInterceptSubviewClick = 16, 174 kEventControlGetClickActivation = 17, 175 kEventControlDragEnter = 18, 176 kEventControlDragWithin = 19, 177 kEventControlDragLeave = 20, 178 kEventControlDragReceive = 21, 179 kEventControlInvalidateForSizeChange = 22, 180 kEventControlTrackingAreaEntered = 23, 181 kEventControlTrackingAreaExited = 24, 182 kEventControlTrack = 51, 183 kEventControlGetScrollToHereStartPoint = 52, 184 kEventControlGetIndicatorDragConstraint = 53, 185 kEventControlIndicatorMoved = 54, 186 kEventControlGhostingFinished = 55, 187 kEventControlGetActionProcPart = 56, 188 kEventControlGetPartRegion = 101, 189 kEventControlGetPartBounds = 102, 190 kEventControlSetData = 103, 191 kEventControlGetData = 104, 192 kEventControlGetSizeConstraints = 105, 193 kEventControlGetFrameMetrics = 106, 194 kEventControlValueFieldChanged = 151, 195 kEventControlAddedSubControl = 152, 196 kEventControlRemovingSubControl = 153, 197 kEventControlBoundsChanged = 154, 198 kEventControlVisibilityChanged = 157, 199 kEventControlTitleChanged = 158, 200 kEventControlOwningWindowChanged = 159, 201 kEventControlHiliteChanged = 160, 202 kEventControlEnabledStateChanged = 161, 203 kEventControlLayoutInfoChanged = 162, 204 kEventControlFocusPartChanged = 164, 205 kEventControlArbitraryMessage = 201 206 } 207 208 enum : int 209 { 210 kEventMouseDown = 1, 211 kEventMouseUp = 2, 212 kEventMouseMoved = 5, 213 kEventMouseDragged = 6, 214 kEventMouseEntered = 8, 215 kEventMouseExited = 9, 216 kEventMouseWheelMoved = 10, 217 kEventMouseScroll = 11 218 } 219 220 alias EventMouseWheelAxis = UInt16; 221 enum : EventMouseWheelAxis 222 { 223 kEventMouseWheelAxisX = 0, 224 kEventMouseWheelAxisY = 1 225 } 226 227 228 enum : int 229 { 230 kEventRawKeyDown = 1, 231 kEventRawKeyRepeat = 2, 232 kEventRawKeyUp = 3, 233 kEventRawKeyModifiersChanged = 4, 234 kEventHotKeyPressed = 5, 235 kEventHotKeyReleased = 6 236 } 237 238 enum : int 239 { 240 kEventWindowUpdate = 1, 241 kEventWindowDrawContent = 2, 242 kEventWindowActivated = 5, 243 kEventWindowDeactivated = 6, 244 kEventWindowHandleActivate = 91, 245 kEventWindowHandleDeactivate = 92, 246 kEventWindowGetClickActivation = 7, 247 kEventWindowGetClickModality = 8, 248 kEventWindowShowing = 22, 249 kEventWindowHiding = 23, 250 kEventWindowShown = 24, 251 kEventWindowHidden = 25, 252 kEventWindowCollapsing = 86, 253 kEventWindowExpanding = 87, 254 kEventWindowExpanded = 70, 255 kEventWindowZoomed = 76, 256 kEventWindowBoundsChanging = 26, 257 kEventWindowBoundsChanged = 27, 258 kEventWindowResizeStarted = 28, 259 kEventWindowResizeCompleted = 29, 260 kEventWindowDragStarted = 30, 261 kEventWindowDragCompleted = 31, 262 kEventWindowClosed = 73, 263 kEventWindowTransitionStarted = 88, 264 kEventWindowTransitionCompleted = 89, 265 kEventWindowClickDragRgn = 32, 266 kEventWindowClickResizeRgn = 33, 267 kEventWindowClickCollapseRgn = 34, 268 kEventWindowClickCloseRgn = 35, 269 kEventWindowClickZoomRgn = 36, 270 kEventWindowClickContentRgn = 37, 271 kEventWindowClickProxyIconRgn = 38, 272 kEventWindowClickToolbarButtonRgn = 41, 273 kEventWindowClickStructureRgn = 42, 274 kEventWindowCursorChange = 40, 275 kEventWindowCollapse = 66, 276 kEventWindowCollapsed = 67, 277 kEventWindowCollapseAll = 68, 278 kEventWindowExpand = 69, 279 kEventWindowExpandAll = 71, 280 kEventWindowClose = 72, 281 kEventWindowCloseAll = 74, 282 kEventWindowZoom = 75, 283 kEventWindowZoomAll = 77, 284 kEventWindowContextualMenuSelect = 78, 285 kEventWindowPathSelect = 79, 286 kEventWindowGetIdealSize = 80, 287 kEventWindowGetMinimumSize = 81, 288 kEventWindowGetMaximumSize = 82, 289 kEventWindowConstrain = 83, 290 kEventWindowRestoreFromDock = 84, 291 kEventWindowHandleContentClick = 85, 292 kEventWindowGetDockTileMenu = 90, 293 kEventWindowGetIdealStandardState = 93, 294 kEventWindowUpdateDockTile = 94, 295 kEventWindowColorSpaceChanged = 95, 296 kEventWindowRestoredAfterRelaunch = 96, 297 kEventWindowProxyBeginDrag = 128, 298 kEventWindowProxyEndDrag = 129, 299 kEventWindowToolbarSwitchMode = 150, 300 kEventWindowFocusAcquired = 200, 301 kEventWindowFocusRelinquish = 201, 302 kEventWindowFocusContent = 202, 303 kEventWindowFocusToolbar = 203, 304 kEventWindowFocusDrawer = 204, 305 kEventWindowFocusLost = 205, 306 kEventWindowFocusRestored = 206, 307 kEventWindowSheetOpening = 210, 308 kEventWindowSheetOpened = 211, 309 kEventWindowSheetClosing = 212, 310 kEventWindowSheetClosed = 213, 311 kEventWindowDrawerOpening = 220, 312 kEventWindowDrawerOpened = 221, 313 kEventWindowDrawerClosing = 222, 314 kEventWindowDrawerClosed = 223, 315 kEventWindowGetFullScreenContentSize = 240, 316 kEventWindowFullScreenEnterStarted = 241, 317 kEventWindowFullScreenEnterCompleted = 242, 318 kEventWindowFullScreenExitStarted = 243, 319 kEventWindowFullScreenExitCompleted = 244, 320 kEventWindowDrawFrame = 1000, 321 kEventWindowDrawPart = 1001, 322 kEventWindowGetRegion = 1002, 323 kEventWindowHitTest = 1003, 324 kEventWindowInit = 1004, 325 kEventWindowDispose = 1005, 326 kEventWindowDragHilite = 1006, 327 kEventWindowModified = 1007, 328 kEventWindowSetupProxyDragImage = 1008, 329 kEventWindowStateChanged = 1009, 330 kEventWindowMeasureTitle = 1010, 331 kEventWindowDrawGrowBox = 1011, 332 kEventWindowGetGrowImageRegion = 1012, 333 kEventWindowPaint = 1013, 334 kEventWindowAttributesChanged = 1019, 335 kEventWindowTitleChanged = 1020 336 } 337 338 enum : int 339 { 340 kEventParamMouseLocation = CCONST('m', 'l', 'o', 'c'), 341 kEventParamWindowMouseLocation = CCONST('w', 'm', 'o', 'u'), 342 kEventParamMouseButton = CCONST('m', 'b', 't', 'n'), 343 kEventParamClickCount = CCONST('c', 'c', 'n', 't'), 344 kEventParamMouseWheelAxis = CCONST('m', 'w', 'a', 'x'), 345 kEventParamMouseWheelDelta = CCONST('m', 'w', 'd', 'l'), 346 kEventParamMouseWheelSmoothVerticalDelta = CCONST('s', 'a', 'x', 'y'), 347 kEventParamMouseWheelSmoothHorizontalDelta = CCONST('s', 'a', 'x', 'x'), 348 kEventParamDirectionInverted = CCONST('d', 'i', 'r', 'i'), 349 kEventParamMouseDelta = CCONST('m', 'd', 't', 'a'), 350 kEventParamMouseChord = CCONST('c', 'h', 'o', 'r'), 351 kEventParamTabletEventType = CCONST('t', 'b', 'l', 't'), 352 kEventParamMouseTrackingRef = CCONST('m', 't', 'r', 'f'), 353 typeMouseButton = CCONST('m', 'b', 't', 'n'), 354 typeMouseWheelAxis = CCONST('m', 'w', 'a', 'x'), 355 typeMouseTrackingRef = CCONST('m', 't', 'r', 'f') 356 } 357 358 enum : int 359 { 360 kEventParamWindowRef = CCONST('w', 'i', 'n', 'd'), 361 kEventParamGrafPort = CCONST('g', 'r', 'a', 'f'), 362 kEventParamMenuRef = CCONST('m', 'e', 'n', 'u'), 363 kEventParamEventRef = CCONST('e', 'v', 'n', 't'), 364 kEventParamControlRef = CCONST('c', 't', 'r', 'l'), 365 kEventParamRgnHandle = CCONST('r', 'g', 'n', 'h'), 366 kEventParamEnabled = CCONST('e', 'n', 'a', 'b'), 367 kEventParamDimensions = CCONST('d', 'i', 'm', 's'), 368 kEventParamBounds = CCONST('b', 'o', 'u', 'n'), 369 kEventParamAvailableBounds = CCONST('a', 'v', 'l', 'b'), 370 // kEventParamAEEventID = keyAEEventID, 371 // kEventParamAEEventClass = keyAEEventClass, 372 kEventParamCGContextRef = CCONST('c', 'n', 't', 'x'), 373 kEventParamCGImageRef = CCONST('c', 'g', 'i', 'm'), 374 kEventParamDeviceDepth = CCONST('d', 'e', 'v', 'd'), 375 kEventParamDeviceColor = CCONST('d', 'e', 'v', 'c'), 376 kEventParamMutableArray = CCONST('m', 'a', 'r', 'r'), 377 kEventParamResult = CCONST('a', 'n', 's', 'r'), 378 kEventParamMinimumSize = CCONST('m', 'n', 's', 'z'), 379 kEventParamMaximumSize = CCONST('m', 'x', 's', 'z'), 380 kEventParamAttributes = CCONST('a', 't', 't', 'r'), 381 kEventParamReason = CCONST('w', 'h', 'y', '?'), 382 kEventParamTransactionID = CCONST('t', 'r', 'n', 's'), 383 kEventParamDisplayDevice = CCONST('g', 'd', 'e', 'v'), 384 // kEventParamGDevice = kEventParamDisplayDevice, 385 kEventParamIndex = CCONST('i', 'n', 'd', 'x'), 386 kEventParamUserData = CCONST('u', 's', 'r', 'd'), 387 kEventParamShape = CCONST('s', 'h', 'a', 'p'), 388 typeWindowRef = CCONST('w', 'i', 'n', 'd'), 389 typeGrafPtr = CCONST('g', 'r', 'a', 'f'), 390 typeGWorldPtr = CCONST('g', 'w', 'l', 'd'), 391 typeMenuRef = CCONST('m', 'e', 'n', 'u'), 392 typeControlRef = CCONST('c', 't', 'r', 'l'), 393 typeCollection = CCONST('c', 'l', 't', 'n'), 394 typeQDRgnHandle = CCONST('r', 'g', 'n', 'h'), 395 typeOSStatus = CCONST('o', 's', 's', 't'), 396 typeCFIndex = CCONST('c', 'f', 'i', 'x'), 397 typeCGContextRef = CCONST('c', 'n', 't', 'x'), 398 typeCGImageRef = CCONST('c', 'g', 'i', 'm'), 399 typeHIPoint = CCONST('h', 'i', 'p', 't'), 400 typeHISize = CCONST('h', 'i', 's', 'z'), 401 typeHIRect = CCONST('h', 'i', 'r', 'c'), 402 typeHIShapeRef = CCONST('s', 'h', 'a', 'p'), 403 typeVoidPtr = CCONST('v', 'o', 'i', 'd'), 404 typeGDHandle = CCONST('g', 'd', 'e', 'v'), 405 typeCGDisplayID = CCONST('c', 'g', 'i', 'd'), 406 typeCGFloat = CCONST('c', 'g', 'f', 'l'), 407 typeHIPoint72DPIGlobal = CCONST('h', 'i', 'p', 'g'), 408 typeHIPointScreenPixel = CCONST('h', 'i', 'p', 's'), 409 typeHISize72DPIGlobal = CCONST('h', 'i', 's', 'g'), 410 typeHISizeScreenPixel = CCONST('h', 'i', 's', 's'), 411 typeHIRect72DPIGlobal = CCONST('h', 'i', 'r', 'g'), 412 typeHIRectScreenPixel = CCONST('h', 'i', 'r', 's'), 413 typeCGFloat72DPIGlobal = CCONST('h', 'i', 'f', 'g'), 414 typeCGFloatScreenPixel = CCONST('h', 'i', 'f', 's'), 415 kEventParamDisplayChangeFlags = CCONST('c', 'g', 'd', 'p'), 416 typeCGDisplayChangeFlags = CCONST('c', 'g', 'd', 'f') 417 } 418 419 enum : int 420 { 421 kEventParamKeyCode = CCONST('k', 'c', 'o', 'd'), 422 kEventParamKeyMacCharCodes = CCONST('k', 'c', 'h', 'r'), 423 kEventParamKeyModifiers = CCONST('k', 'm', 'o', 'd'), 424 kEventParamKeyUnicodes = CCONST('k', 'u', 'n', 'i'), 425 kEventParamKeyboardType = CCONST('k', 'b', 'd', 't'), 426 typeEventHotKeyID = CCONST('h', 'k', 'i', 'd') 427 } 428 429 alias EventMouseButton = UInt16; 430 enum : EventMouseButton 431 { 432 kEventMouseButtonPrimary = 1, 433 kEventMouseButtonSecondary = 2, 434 kEventMouseButtonTertiary = 3 435 } 436 437 OSStatus InstallControlEventHandler(ControlRef target, EventHandlerUPP handler, ItemCount numTypes, 438 const(EventTypeSpec)* list, void* userData, EventHandlerRef* outHandlerRef) nothrow @nogc 439 { 440 return InstallEventHandler(GetControlEventTarget(target), handler, numTypes, list, userData, outHandlerRef); 441 } 442 443 OSStatus InstallWindowEventHandler(WindowRef target, EventHandlerUPP handler, ItemCount numTypes, 444 const(EventTypeSpec)* list, void* userData, EventHandlerRef* outHandlerRef) nothrow @nogc 445 { 446 return InstallEventHandler(GetWindowEventTarget(target), handler, numTypes, list, userData, outHandlerRef); 447 } 448 449 450 451 452 453 extern (C) nothrow @nogc 454 { 455 alias da_GetControlEventTarget = EventTargetRef function(ControlRef); 456 alias da_GetWindowEventTarget = EventTargetRef function(WindowRef); 457 } 458 459 __gshared 460 { 461 da_GetControlEventTarget GetControlEventTarget; 462 da_GetWindowEventTarget GetWindowEventTarget; 463 } 464 465 466 // <HIToolbox/Controls.h> 467 468 enum : int 469 { 470 kControlSupportsGhosting = 1 << 0, 471 kControlSupportsEmbedding = 1 << 1, 472 kControlSupportsFocus = 1 << 2, 473 kControlWantsIdle = 1 << 3, 474 kControlWantsActivate = 1 << 4, 475 kControlHandlesTracking = 1 << 5, 476 kControlSupportsDataAccess = 1 << 6, 477 kControlHasSpecialBackground = 1 << 7, 478 kControlGetsFocusOnClick = 1 << 8, 479 kControlSupportsCalcBestRect = 1 << 9, 480 kControlSupportsLiveFeedback = 1 << 10, 481 kControlHasRadioBehavior = 1 << 11, 482 kControlSupportsDragAndDrop = 1 << 12, 483 kControlAutoToggles = 1 << 14, 484 kControlSupportsGetRegion = 1 << 17, 485 kControlSupportsFlattening = 1 << 19, 486 kControlSupportsSetCursor = 1 << 20, 487 kControlSupportsContextualMenus = 1 << 21, 488 kControlSupportsClickActivation = 1 << 22, 489 kControlIdlesWithTimer = 1 << 23, 490 kControlInvertsUpDownValueMeaning = 1 << 24 491 } 492 493 struct ControlID 494 { 495 OSType signature; 496 SInt32 id; 497 } 498 499 extern (C) nothrow @nogc 500 { 501 // alias da_GetRootControl = OSErr function(WindowRef, ControlRef*); 502 // alias da_CreateRootControl = OSErr function(WindowRef inWindow, ControlRef* outControl); 503 alias da_SizeControl = void function(ControlRef theControl, SInt16 w, SInt16 h); 504 // alias da_EmbedControl = OSErr function(ControlRef inControl, ControlRef inContainer); 505 } 506 507 __gshared 508 { 509 // da_GetRootControl GetRootControl; 510 // da_CreateRootControl CreateRootControl; 511 da_SizeControl SizeControl; 512 // da_EmbedControl EmbedControl; 513 } 514 515 516 // <HIToolbox/Events.h> 517 518 alias EventModifiers = ushort; 519 enum 520 { 521 activeFlagBit = 0, 522 btnStateBit = 7, 523 cmdKeyBit = 8, 524 shiftKeyBit = 9, 525 alphaLockBit = 10, 526 optionKeyBit = 11, 527 controlKeyBit = 12, 528 } 529 530 enum : EventModifiers 531 { 532 activeFlag = 1 << activeFlagBit, 533 btnState = 1 << btnStateBit, 534 cmdKey = 1 << cmdKeyBit, 535 shiftKey = 1 << shiftKeyBit, 536 alphaLock = 1 << alphaLockBit, 537 optionKey = 1 << optionKeyBit, 538 controlKey = 1 << controlKeyBit 539 } 540 541 542 // <HIToolbox/HIContainerViews.h> 543 544 extern (C) nothrow @nogc 545 { 546 alias da_CreateUserPaneControl = OSStatus function(WindowRef, const(Rect)*, UInt32, ControlRef*); 547 } 548 549 __gshared 550 { 551 da_CreateUserPaneControl CreateUserPaneControl; 552 } 553 554 555 556 // <HIToolbox/HIGeometry.h> 557 558 alias HIRect = CGRect; 559 alias HIPoint = CGPoint; 560 561 alias HICoordinateSpace = UInt32; 562 enum : HICoordinateSpace 563 { 564 kHICoordSpace72DPIGlobal = 1, 565 kHICoordSpaceScreenPixel = 2, 566 kHICoordSpaceWindow = 3, 567 kHICoordSpaceView = 4 568 } 569 570 extern (C) nothrow @nogc 571 { 572 alias da_HIPointConvert = void function(HIPoint*, HICoordinateSpace, void*, HICoordinateSpace, void*); 573 } 574 575 __gshared 576 { 577 da_HIPointConvert HIPointConvert; 578 } 579 580 581 582 // <HIToolbox/HIObject.h> 583 584 alias ControlRef = void*; 585 alias HIViewRef = ControlRef; 586 alias HIViewID = ControlID; 587 588 589 // <HIToolbox/HIView.h> 590 591 enum : int 592 { 593 kHIViewFeatureSupportsGhosting = 1 << 0, 594 kHIViewFeatureAllowsSubviews = 1 << 1, 595 kHIViewFeatureGetsFocusOnClick = 1 << 8, 596 kHIViewFeatureSupportsLiveFeedback = 1 << 10, 597 kHIViewFeatureSupportsRadioBehavior = 1 << 11, 598 kHIViewFeatureAutoToggles = 1 << 14, 599 kHIViewFeatureIdlesWithTimer = 1 << 23, 600 kHIViewFeatureInvertsUpDownValueMeaning = 1 << 24, 601 kHIViewFeatureIsOpaque = 1 << 25, 602 kHIViewFeatureDoesNotDraw = 1 << 27, 603 kHIViewFeatureDoesNotUseSpecialParts = 1 << 28, 604 kHIViewFeatureIgnoresClicks = 1 << 29 605 } 606 607 extern (C) nothrow @nogc 608 { 609 alias da_HIViewGetRoot = HIViewRef function(WindowRef inWindow); 610 alias da_HIViewFindByID = OSStatus function(HIViewRef inStartView, HIViewID inID, HIViewRef* outView); 611 alias da_HIViewAddSubview = OSStatus function(HIViewRef inParent, HIViewRef inNewChild); 612 alias da_HIViewSetNeedsDisplayInRect = OSStatus function(HIViewRef, const(HIRect)*, Boolean); 613 alias da_HIViewGetBounds = OSStatus function(HIViewRef, HIRect* outRect); 614 } 615 616 __gshared 617 { 618 da_HIViewGetRoot HIViewGetRoot; 619 da_HIViewFindByID HIViewFindByID; 620 da_HIViewAddSubview HIViewAddSubview; 621 da_HIViewSetNeedsDisplayInRect HIViewSetNeedsDisplayInRect; 622 da_HIViewGetBounds HIViewGetBounds; 623 } 624 625 626 // <HIToolbox/HIWindowViews.h> 627 628 static immutable HIViewID kHIViewWindowContentID = HIViewID(CCONST('w', 'i', 'n', 'd'), 1); // MAYDO: is it portable across OSX versions? Seems so. 629 630 // <HIToolbox/MacWindows.h> 631 632 alias WindowClass = int; 633 alias WindowAttributes = OptionBits; 634 635 enum : int 636 { 637 kHIWindowBitCloseBox = 1, 638 kHIWindowBitZoomBox = 2, 639 kHIWindowBitCollapseBox = 4, 640 kHIWindowBitResizable = 5, 641 kHIWindowBitSideTitlebar = 6, 642 kHIWindowBitToolbarButton = 7, 643 kHIWindowBitUnifiedTitleAndToolbar = 8, 644 kHIWindowBitTextured = 9, 645 kHIWindowBitNoTitleBar = 10, 646 kHIWindowBitTexturedSquareCorners = 11, 647 kHIWindowBitNoTexturedContentSeparator = 12, 648 kHIWindowBitRoundBottomBarCorners = 13, 649 kHIWindowBitDoesNotCycle = 16, 650 kHIWindowBitNoUpdates = 17, 651 kHIWindowBitNoActivates = 18, 652 kHIWindowBitOpaqueForEvents = 19, 653 kHIWindowBitCompositing = 20, 654 kHIWindowBitFrameworkScaled = 21, 655 kHIWindowBitNoShadow = 22, 656 kHIWindowBitCanBeVisibleWithoutLogin = 23, 657 kHIWindowBitAsyncDrag = 24, 658 kHIWindowBitHideOnSuspend = 25, 659 kHIWindowBitStandardHandler = 26, 660 kHIWindowBitHideOnFullScreen = 27, 661 kHIWindowBitInWindowMenu = 28, 662 kHIWindowBitLiveResize = 29, 663 kHIWindowBitIgnoreClicks = 30, 664 kHIWindowBitNoConstrain = 32, 665 kHIWindowBitDoesNotHide = 33, 666 kHIWindowBitAutoViewDragTracking = 34 667 } 668 669 enum : int 670 { 671 kWindowNoAttributes = 0, 672 kWindowCloseBoxAttribute = (1 << (kHIWindowBitCloseBox - 1)), 673 kWindowHorizontalZoomAttribute = (1 << (kHIWindowBitZoomBox - 1)), 674 kWindowVerticalZoomAttribute = (1 << kHIWindowBitZoomBox), 675 kWindowFullZoomAttribute = (kWindowVerticalZoomAttribute | kWindowHorizontalZoomAttribute), 676 kWindowCollapseBoxAttribute = (1 << (kHIWindowBitCollapseBox - 1)), 677 kWindowResizableAttribute = (1 << (kHIWindowBitResizable - 1)), 678 kWindowSideTitlebarAttribute = (1 << (kHIWindowBitSideTitlebar - 1)), 679 kWindowToolbarButtonAttribute = (1 << (kHIWindowBitToolbarButton - 1)), 680 kWindowUnifiedTitleAndToolbarAttribute = (1 << (kHIWindowBitUnifiedTitleAndToolbar - 1)), 681 kWindowMetalAttribute = (1 << (kHIWindowBitTextured - 1)), 682 kWindowNoTitleBarAttribute = (1 << (kHIWindowBitNoTitleBar - 1)), 683 kWindowTexturedSquareCornersAttribute = (1 << (kHIWindowBitTexturedSquareCorners - 1)), 684 kWindowMetalNoContentSeparatorAttribute = (1 << (kHIWindowBitNoTexturedContentSeparator - 1)), 685 kWindowHasRoundBottomBarCornersAttribute = (1 << (kHIWindowBitRoundBottomBarCorners - 1)), 686 kWindowDoesNotCycleAttribute = (1 << (kHIWindowBitDoesNotCycle - 1)), 687 kWindowNoUpdatesAttribute = (1 << (kHIWindowBitNoUpdates - 1)), 688 kWindowNoActivatesAttribute = (1 << (kHIWindowBitNoActivates - 1)), 689 kWindowOpaqueForEventsAttribute = (1 << (kHIWindowBitOpaqueForEvents - 1)), 690 kWindowCompositingAttribute = (1 << (kHIWindowBitCompositing - 1)), 691 kWindowNoShadowAttribute = (1 << (kHIWindowBitNoShadow - 1)), 692 kWindowCanBeVisibleWithoutLoginAttribute = (1 << (kHIWindowBitCanBeVisibleWithoutLogin - 1)), 693 kWindowHideOnSuspendAttribute = (1 << (kHIWindowBitHideOnSuspend - 1)), 694 kWindowAsyncDragAttribute = (1 << (kHIWindowBitAsyncDrag - 1)), 695 kWindowStandardHandlerAttribute = (1 << (kHIWindowBitStandardHandler - 1)), 696 kWindowHideOnFullScreenAttribute = (1 << (kHIWindowBitHideOnFullScreen - 1)), 697 kWindowInWindowMenuAttribute = (1 << (kHIWindowBitInWindowMenu - 1)), 698 kWindowLiveResizeAttribute = (1 << (kHIWindowBitLiveResize - 1)), 699 kWindowIgnoreClicksAttribute = (1 << (kHIWindowBitIgnoreClicks - 1)), 700 kWindowFrameworkScaledAttribute = (1 << (kHIWindowBitFrameworkScaled - 1)), 701 kWindowStandardDocumentAttributes = (kWindowCloseBoxAttribute | kWindowFullZoomAttribute | kWindowCollapseBoxAttribute | kWindowResizableAttribute), 702 kWindowStandardFloatingAttributes = (kWindowCloseBoxAttribute | kWindowCollapseBoxAttribute) 703 } 704 705 706 extern (C) nothrow @nogc 707 { 708 alias da_GetWindowAttributes = OSStatus function(WindowRef window, WindowAttributes* outAttributes); 709 } 710 711 __gshared 712 { 713 da_GetWindowAttributes GetWindowAttributes; 714 } 715