]> git.saurik.com Git - wxWidgets.git/blobdiff - src/osx/carbon/colordlgosx.mm
Spell contributor name correctly.
[wxWidgets.git] / src / osx / carbon / colordlgosx.mm
index ea058c24f73200b10688b6d275fd0d7b7e06ab86..0f75e74eef432163079cf0bdddd1494f9f7b8865 100644 (file)
@@ -1,5 +1,5 @@
 /////////////////////////////////////////////////////////////////////////////
 /////////////////////////////////////////////////////////////////////////////
-// Name:        src/mac/carbon/colordlg.mm
+// Name:        src/osx/carbon/colordlg.mm
 // Purpose:     wxColourDialog class. NOTE: you can use the generic class
 //              if you wish, instead of implementing this.
 // Author:      Ryan Norton
 // Purpose:     wxColourDialog class. NOTE: you can use the generic class
 //              if you wish, instead of implementing this.
 // Author:      Ryan Norton
@@ -20,7 +20,7 @@
 
 #include "wx/wxprec.h"
 
 
 #include "wx/wxprec.h"
 
-#include "wx/mac/colordlg.h"
+#include "wx/osx/colordlg.h"
 #include "wx/fontdlg.h"
 
 // ============================================================================
 #include "wx/fontdlg.h"
 
 // ============================================================================
 
 IMPLEMENT_DYNAMIC_CLASS(wxColourDialog, wxDialog)
 
 
 IMPLEMENT_DYNAMIC_CLASS(wxColourDialog, wxDialog)
 
-// Cocoa headers
-#include "wx/cocoa/autorelease.h"
-#include "wx/cocoa/string.h"
+#include "wx/osx/private.h"
 
 
-#import <AppKit/NSFont.h>
-#import <AppKit/NSFontManager.h>
-#import <AppKit/NSFontPanel.h>
-#import <AppKit/NSColor.h>
-#import <AppKit/NSColorPanel.h>
+#import <Foundation/Foundation.h>
+#import <AppKit/AppKit.h>
 
 // ---------------------------------------------------------------------------
 // wxCPWCDelegate - Window Closed delegate
 // ---------------------------------------------------------------------------
 
 
 // ---------------------------------------------------------------------------
 // wxCPWCDelegate - Window Closed delegate
 // ---------------------------------------------------------------------------
 
-@interface wxCPWCDelegate : NSObject
+@interface wxCPWCDelegate : NSObject wxOSX_10_6_AND_LATER(<NSWindowDelegate>)
 {
     bool m_bIsClosed;
 }
 {
     bool m_bIsClosed;
 }
@@ -106,28 +101,16 @@ bool wxColourDialog::Create(wxWindow *parent, wxColourData *data)
     if (data)
         m_colourData = *data;
 
     if (data)
         m_colourData = *data;
 
-    //
-    // This is the key call - this initializes
-    // events and window stuff for cocoa for carbon
-    // applications.
-    //
-    // This is also the only call here that is
-    // 10.2+ specific (the rest is OSX only),
-    // which, ironically, the carbon font
-    // panel requires.
-    //
-    bool bOK = NSApplicationLoad();
-
     //autorelease pool - req'd for carbon
     NSAutoreleasePool *thePool;
     thePool = [[NSAutoreleasePool alloc] init];
 
     //autorelease pool - req'd for carbon
     NSAutoreleasePool *thePool;
     thePool = [[NSAutoreleasePool alloc] init];
 
-    if(m_colourData.m_dataColour.Ok())
+    if(m_colourData.GetColour().IsOk())
         [[NSColorPanel sharedColorPanel] setColor:
         [[NSColorPanel sharedColorPanel] setColor:
-            [NSColor colorWithCalibratedRed:m_colourData.m_dataColour.Red() / 255.0
-                                        green:m_colourData.m_dataColour.Green() / 255.0
-                                        blue:m_colourData.m_dataColour.Blue() / 255.0
-                                        alpha:1.0]
+            [NSColor colorWithCalibratedRed:(CGFloat) (m_colourData.GetColour().Red() / 255.0)
+                                        green:(CGFloat) (m_colourData.GetColour().Green() / 255.0)
+                                        blue:(CGFloat) (m_colourData.GetColour().Blue() / 255.0)
+                                        alpha:(CGFloat) 1.0]
         ];
     else
         [[NSColorPanel sharedColorPanel] setColor:[NSColor blackColor]];
         ];
     else
         [[NSColorPanel sharedColorPanel] setColor:[NSColor blackColor]];
@@ -135,7 +118,7 @@ bool wxColourDialog::Create(wxWindow *parent, wxColourData *data)
     //We're done - free up the pool
     [thePool release];
 
     //We're done - free up the pool
     [thePool release];
 
-    return bOK;
+    return true;
 }
 int wxColourDialog::ShowModal()
 {
 }
 int wxColourDialog::ShowModal()
 {
@@ -158,6 +141,7 @@ int wxColourDialog::ShowModal()
             //
             // Start the color panel modal loop
             //
             //
             // Start the color panel modal loop
             //
+            wxDialog::OSXBeginModalDialog();
             NSModalSession session = [NSApp beginModalSessionForWindow:theColorPanel];
             for (;;)
             {
             NSModalSession session = [NSApp beginModalSessionForWindow:theColorPanel];
             for (;;)
             {
@@ -168,14 +152,16 @@ int wxColourDialog::ShowModal()
                     break;
             }
             [NSApp endModalSession:session];
                     break;
             }
             [NSApp endModalSession:session];
+            wxDialog::OSXEndModalDialog();
 
     //free up the memory for the delegates - we don't need them anymore
 
     //free up the memory for the delegates - we don't need them anymore
+    [theColorPanel setDelegate:nil];
     [theCPDelegate release];
 
     //Get the shared color panel along with the chosen color and set the chosen color
     NSColor* theColor = [[theColorPanel color] colorUsingColorSpaceName:NSCalibratedRGBColorSpace];
 
     [theCPDelegate release];
 
     //Get the shared color panel along with the chosen color and set the chosen color
     NSColor* theColor = [[theColorPanel color] colorUsingColorSpaceName:NSCalibratedRGBColorSpace];
 
-    m_colourData.m_dataColour.Set(
+    m_colourData.GetColour().Set(
                                 (unsigned char) ([theColor redComponent] * 255.0),
                                 (unsigned char) ([theColor greenComponent] * 255.0),
                                 (unsigned char) ([theColor blueComponent] * 255.0)
                                 (unsigned char) ([theColor redComponent] * 255.0),
                                 (unsigned char) ([theColor greenComponent] * 255.0),
                                 (unsigned char) ([theColor blueComponent] * 255.0)