]> OCCT Git - occt.git/commitdiff
0029156: Coding Rules - eliminate deprecation compiler warnings when targeting macOS...
authorkgv <kgv@opencascade.com>
Thu, 28 Sep 2017 20:48:55 +0000 (23:48 +0300)
committerkgv <kgv@opencascade.com>
Fri, 29 Sep 2017 06:42:14 +0000 (09:42 +0300)
src/Cocoa/Cocoa_Window.mm
src/Draw/Draw_Window_1.mm
src/OpenGl/OpenGl_Window_1.mm
src/ViewerTest/ViewerTest_ViewerCommands_1.mm

index 24f6545cb5e6fe3943ca9eb84c1c1da088702d85..73aa70110defe49143b42a9f9bc1f5fd43e68bce 100644 (file)
@@ -34,6 +34,14 @@ IMPLEMENT_STANDARD_RTTIEXT(Cocoa_Window,Aspect_Window)
 #if defined(TARGET_OS_IPHONE) && TARGET_OS_IPHONE
   //
 #else
+
+#if !defined(MAC_OS_X_VERSION_10_12) || (MAC_OS_X_VERSION_MAX_ALLOWED < MAC_OS_X_VERSION_10_12)
+  // replacements for macOS versions before 10.12
+  #define NSWindowStyleMaskResizable NSResizableWindowMask
+  #define NSWindowStyleMaskClosable  NSClosableWindowMask
+  #define NSWindowStyleMaskTitled    NSTitledWindowMask
+#endif
+
 static Standard_Integer getScreenBottom()
 {
   Cocoa_LocalPool aLocalPool;
@@ -95,7 +103,7 @@ Cocoa_Window::Cocoa_Window (const Standard_CString theTitle,
   myYBottom = myYTop + thePxHeight;
 
   Cocoa_LocalPool aLocalPool;
-  NSUInteger aWinStyle = NSTitledWindowMask | NSClosableWindowMask | NSResizableWindowMask;
+  NSUInteger aWinStyle = NSWindowStyleMaskTitled | NSWindowStyleMaskClosable | NSWindowStyleMaskResizable;
   NSRect aRectNs = NSMakeRect (float(myXLeft), float(myYTop), float(thePxWidth), float(thePxHeight));
   myHWindow = [[NSWindow alloc] initWithContentRect: aRectNs
                                           styleMask: aWinStyle
index e59b69890a961d520f50beaa71868347805ac70c..d17b2cb16e6c11340dc73435776be94e01afcec4 100644 (file)
 #include <Draw_Window.hxx>
 #include <Cocoa_LocalPool.hxx>
 
+#if !defined(MAC_OS_X_VERSION_10_12) || (MAC_OS_X_VERSION_MAX_ALLOWED < MAC_OS_X_VERSION_10_12)
+  // replacements for macOS versions before 10.12
+  #define NSEventTypeLeftMouseDown    NSLeftMouseDown
+  #define NSEventTypeRightMouseDown   NSRightMouseDown
+  #define NSEventTypeLeftMouseDragged NSLeftMouseDragged
+  #define NSEventTypeMouseMoved       NSMouseMoved
+
+  #define NSEventMaskLeftMouseDragged NSLeftMouseDraggedMask
+  #define NSEventMaskMouseMoved       NSMouseMovedMask
+  #define NSEventMaskLeftMouseDown    NSLeftMouseDownMask
+  #define NSEventMaskRightMouseDown   NSRightMouseDownMask
+
+  #define NSWindowStyleMaskResizable  NSResizableWindowMask
+  #define NSWindowStyleMaskClosable   NSClosableWindowMask
+  #define NSWindowStyleMaskTitled     NSTitledWindowMask
+
+  #define NSCompositingOperationSourceOver NSCompositeSourceOver
+#endif
+
 @interface Draw_CocoaView : NSView
 {
   NSImage* myImage;
@@ -53,7 +72,7 @@
 
   [myImage drawInRect: aBounds
              fromRect: NSZeroRect
-            operation: NSCompositeSourceOver
+            operation: NSCompositingOperationSourceOver
              fraction: 1
        respectFlipped: YES
                 hints: nil];
@@ -199,7 +218,7 @@ void Draw_Window::Init (const Standard_Integer& theXLeft, const Standard_Integer
   if (myWindow == NULL)
   {
     NSRect     aRectNs   = NSMakeRect (theXLeft, anYTop, theWidth, theHeight);
-    NSUInteger aWinStyle = NSTitledWindowMask | NSClosableWindowMask | NSResizableWindowMask;
+    NSUInteger aWinStyle = NSWindowStyleMaskTitled | NSWindowStyleMaskClosable | NSWindowStyleMaskResizable;
 
     myWindow = [[NSWindow alloc] initWithContentRect: aRectNs
                                            styleMask: aWinStyle
@@ -580,11 +599,11 @@ void GetNextEvent (Standard_Boolean  theWait,
 {
   Cocoa_LocalPool aLocalPool;
 
-  unsigned int anEventMatchMask = NSLeftMouseDownMask | NSRightMouseDownMask;
+  unsigned int anEventMatchMask = NSEventMaskLeftMouseDown | NSEventMaskRightMouseDown;
 
   if (!theWait)
   {
-    anEventMatchMask = anEventMatchMask | NSMouseMovedMask | NSLeftMouseDraggedMask;
+    anEventMatchMask = anEventMatchMask | NSEventMaskMouseMoved | NSEventMaskLeftMouseDragged;
     Draw_IsInZoomingMode = Standard_True;
   }
 
@@ -604,15 +623,15 @@ void GetNextEvent (Standard_Boolean  theWait,
 
   NSEventType anEventType = [anEvent type];
 
-  if (anEventType == NSLeftMouseDown)
+  if (anEventType == NSEventTypeLeftMouseDown)
   {
     theButton = 1;
   }
-  else if (anEventType == NSRightMouseDown)
+  else if (anEventType == NSEventTypeRightMouseDown)
   {
     theButton = 3;
   }
-  else if ((anEventType == NSMouseMoved || anEventType == NSLeftMouseDragged) && !theWait)
+  else if ((anEventType == NSEventTypeMouseMoved || anEventType == NSEventTypeLeftMouseDragged) && !theWait)
   {
     theButton = 0;
   }
index bbd37293fd7ae31392d9efb80b96f1aaf0a27fed..1b29a2d421dea4cebead6d3c4f888ffc7e071e39 100644 (file)
@@ -162,7 +162,11 @@ OpenGl_Window::OpenGl_Window (const Handle(OpenGl_GraphicDriver)& theDriver,
           {
             continue;
           }
+
+          // deprecated since macOS 10.12 without replacement
+          Standard_DISABLE_DEPRECATION_WARNINGS
           anAttribs[aLastAttrib++] = NSOpenGLPFAStereo;
+          Standard_ENABLE_DEPRECATION_WARNINGS
         }
 
         anAttribs[aLastAttrib] = 0;
index e29bd354e818301bffb14bf3f80d17556fc423ce..b727b1f6cbb4e479c0098fa9ba36fd13b04ce101 100644 (file)
 #include <TCollection_AsciiString.hxx>
 #include <NCollection_DoubleMap.hxx>
 
+#if !defined(MAC_OS_X_VERSION_10_12) || (MAC_OS_X_VERSION_MAX_ALLOWED < MAC_OS_X_VERSION_10_12)
+  // replacements for macOS versions before 10.12
+  #define NSEventModifierFlagControl NSControlKeyMask
+  #define NSEventModifierFlagShift   NSShiftKeyMask
+#endif
+
 //! Custom Cocoa view to handle events
 @interface ViewerTest_CocoaEventManagerView : NSView
 @end
@@ -227,7 +233,7 @@ static void getMouseCoords (NSView*           theView,
 - (void )mouseDown: (NSEvent* )theEvent
 {
   getMouseCoords (self, theEvent, X_ButtonPress, Y_ButtonPress);
-  VT_ProcessButton1Press (0, NULL, Standard_False, [theEvent modifierFlags] & NSShiftKeyMask);
+  VT_ProcessButton1Press (0, NULL, Standard_False, [theEvent modifierFlags] & NSEventModifierFlagShift);
 }
 
 // =======================================================================
@@ -237,7 +243,7 @@ static void getMouseCoords (NSView*           theView,
 - (void )mouseUp: (NSEvent* )theEvent
 {
   getMouseCoords (self, theEvent, X_Motion, Y_Motion);
-  VT_ProcessButton1Release([theEvent modifierFlags] & NSShiftKeyMask);
+  VT_ProcessButton1Release([theEvent modifierFlags] & NSEventModifierFlagShift);
 }
 
 
@@ -248,7 +254,7 @@ static void getMouseCoords (NSView*           theView,
 - (void )mouseDragged: (NSEvent* )theEvent
 {
   IsDragged = Standard_True;
-  if ([theEvent modifierFlags] & NSControlKeyMask)
+  if ([theEvent modifierFlags] & NSEventModifierFlagControl)
   {
     getMouseCoords (self, theEvent, X_Motion, Y_Motion);
     VT_ProcessControlButton2Motion();
@@ -281,7 +287,7 @@ static void getMouseCoords (NSView*           theView,
 // =======================================================================
 - (void )rightMouseDragged: (NSEvent* )theEvent
 {
-  if ([theEvent modifierFlags] & NSControlKeyMask)
+  if ([theEvent modifierFlags] & NSEventModifierFlagControl)
   {
     getMouseCoords (self, theEvent, X_Motion, Y_Motion);
     VT_ProcessControlButton3Motion();