tkMacOSXConstants.h 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119
  1. /*
  2. * tkMacOSXConstants.h --
  3. *
  4. * Macros which map the names of NS constants used in the Tk code to
  5. * the new name that Apple came up with for subsequent versions of the
  6. * operating system. (Each new OS release seems to come with a new
  7. * naming convention for the same old constants.)
  8. *
  9. * Copyright (c) 2017 Marc Culler
  10. *
  11. * See the file "license.terms" for information on usage and redistribution
  12. * of this file, and for a DISCLAIMER OF ALL WARRANTIES.
  13. */
  14. #ifndef _TKMACCONSTANTS
  15. #define _TKMACCONSTANTS
  16. #if MAC_OS_X_VERSION_MAX_ALLOWED < 1070
  17. #define NSFullScreenWindowMask (1 << 14)
  18. #endif
  19. #if MAC_OS_X_VERSION_MAX_ALLOWED < 1090
  20. typedef NSInteger NSModalResponse;
  21. #endif
  22. /*
  23. * Let's raise a glass for the project manager who improves our lives by
  24. * generating deprecation warnings about pointless changes of the names
  25. * of constants.
  26. */
  27. #if MAC_OS_X_VERSION_MIN_REQUIRED >= 1090
  28. #define kCTFontDefaultOrientation kCTFontOrientationDefault
  29. #define kCTFontVerticalOrientation kCTFontOrientationVertical
  30. #endif
  31. #if MAC_OS_X_VERSION_MIN_REQUIRED >= 101000
  32. #define NSOKButton NSModalResponseOK
  33. #endif
  34. #if MAC_OS_X_VERSION_MIN_REQUIRED >= 101100
  35. #define kCTFontUserFixedPitchFontType kCTFontUIFontUserFixedPitch
  36. #endif
  37. #if MAC_OS_X_VERSION_MIN_REQUIRED >= 101200
  38. #define NSAppKitDefined NSEventTypeAppKitDefined
  39. #define NSApplicationDefined NSEventTypeApplicationDefined
  40. #define NSApplicationActivatedEventType NSEventSubtypeApplicationActivated
  41. #define NSApplicationDeactivatedEventType NSEventSubtypeApplicationDeactivated
  42. #define NSWindowExposedEventType NSEventSubtypeWindowExposed
  43. #define NSScreenChangedEventType NSEventSubtypeScreenChanged
  44. #define NSWindowMovedEventType NSEventSubtypeWindowMoved
  45. #define NSKeyUp NSEventTypeKeyUp
  46. #define NSKeyDown NSEventTypeKeyDown
  47. #define NSFlagsChanged NSEventTypeFlagsChanged
  48. #define NSLeftMouseDown NSEventTypeLeftMouseDown
  49. #define NSLeftMouseUp NSEventTypeLeftMouseUp
  50. #define NSRightMouseDown NSEventTypeRightMouseDown
  51. #define NSRightMouseUp NSEventTypeRightMouseUp
  52. #define NSLeftMouseDragged NSEventTypeLeftMouseDragged
  53. #define NSRightMouseDragged NSEventTypeRightMouseDragged
  54. #define NSMouseMoved NSEventTypeMouseMoved
  55. #define NSMouseEntered NSEventTypeMouseEntered
  56. #define NSMouseExited NSEventTypeMouseExited
  57. #define NSScrollWheel NSEventTypeScrollWheel
  58. #define NSOtherMouseDown NSEventTypeOtherMouseDown
  59. #define NSOtherMouseUp NSEventTypeOtherMouseUp
  60. #define NSOtherMouseDragged NSEventTypeOtherMouseDragged
  61. #define NSTabletPoint NSEventTypeTabletPoint
  62. #define NSTabletProximity NSEventTypeTabletProximity
  63. #define NSDeviceIndependentModifierFlagsMask NSEventModifierFlagDeviceIndependentFlagsMask
  64. #define NSCommandKeyMask NSEventModifierFlagCommand
  65. #define NSShiftKeyMask NSEventModifierFlagShift
  66. #define NSAlphaShiftKeyMask NSEventModifierFlagCapsLock
  67. #define NSAlternateKeyMask NSEventModifierFlagOption
  68. #define NSControlKeyMask NSEventModifierFlagControl
  69. #define NSNumericPadKeyMask NSEventModifierFlagNumericPad
  70. #define NSFunctionKeyMask NSEventModifierFlagFunction
  71. #define NSCursorUpdate NSEventTypeCursorUpdate
  72. #define NSTexturedBackgroundWindowMask NSWindowStyleMaskTexturedBackground
  73. #define NSCompositeCopy NSCompositingOperationCopy
  74. #define NSWarningAlertStyle NSAlertStyleWarning
  75. #define NSInformationalAlertStyle NSAlertStyleInformational
  76. #define NSCriticalAlertStyle NSAlertStyleCritical
  77. #define NSCenterTextAlignment NSTextAlignmentCenter
  78. #define NSAnyEventMask NSEventMaskAny
  79. #define NSApplicationDefinedMask NSEventMaskApplicationDefined
  80. #define NSUtilityWindowMask NSWindowStyleMaskUtilityWindow
  81. #define NSNonactivatingPanelMask NSWindowStyleMaskNonactivatingPanel
  82. #define NSDocModalWindowMask NSWindowStyleMaskDocModalWindow
  83. #define NSHUDWindowMask NSWindowStyleMaskHUDWindow
  84. #define NSTitledWindowMask NSWindowStyleMaskTitled
  85. #define NSClosableWindowMask NSWindowStyleMaskClosable
  86. #define NSResizableWindowMask NSWindowStyleMaskResizable
  87. #define NSUnifiedTitleAndToolbarWindowMask NSWindowStyleMaskUnifiedTitleAndToolbar
  88. #define NSMiniaturizableWindowMask NSWindowStyleMaskMiniaturizable
  89. #define NSBorderlessWindowMask NSWindowStyleMaskBorderless
  90. #define NSFullScreenWindowMask NSWindowStyleMaskFullScreen
  91. #endif
  92. #if MAC_OS_X_VERSION_MIN_REQUIRED >= 101400
  93. #define NSStringPboardType NSPasteboardTypeString
  94. #define NSOnState NSControlStateValueOn
  95. #define NSOffState NSControlStateValueOff
  96. #endif
  97. #if MAC_OS_X_VERSION_MIN_REQUIRED >= 110000
  98. #define NSWindowStyleMaskTexturedBackground 0
  99. #endif
  100. #if MAC_OS_X_VERSION_MIN_REQUIRED < 101000
  101. #define GET_NSCONTEXT(context, flip) [NSGraphicsContext \
  102. graphicsContextWithGraphicsPort:context flipped:flip]
  103. #else
  104. #define GET_NSCONTEXT(context, flip) [NSGraphicsContext \
  105. graphicsContextWithCGContext:context flipped:NO]
  106. #endif
  107. #endif