X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/6869b469c6ba4a549b2bd463ce9778915781b0df..47e175a24f862aa8b7ca7dd4a2bb5957991e7f2d:/src/osx/carbon/colordlgosx.mm diff --git a/src/osx/carbon/colordlgosx.mm b/src/osx/carbon/colordlgosx.mm index 0dc098887f..4f12861d3d 100644 --- a/src/osx/carbon/colordlgosx.mm +++ b/src/osx/carbon/colordlgosx.mm @@ -1,5 +1,5 @@ ///////////////////////////////////////////////////////////////////////////// -// Name: src/osx/carbon/colordlg.mm +// Name: src/osx/carbon/colordlgosx.mm // Purpose: wxColourDialog class. NOTE: you can use the generic class // if you wish, instead of implementing this. // Author: Ryan Norton @@ -20,8 +20,9 @@ #include "wx/wxprec.h" -#include "wx/osx/colordlg.h" +#include "wx/colordlg.h" #include "wx/fontdlg.h" +#include "wx/testing.h" // ============================================================================ // implementation @@ -32,21 +33,16 @@ IMPLEMENT_DYNAMIC_CLASS(wxColourDialog, wxDialog) -// Cocoa headers -#include "wx/cocoa/autorelease.h" -#include "wx/cocoa/string.h" +#include "wx/osx/private.h" -#import -#import -#import -#import -#import +#import +#import // --------------------------------------------------------------------------- // wxCPWCDelegate - Window Closed delegate // --------------------------------------------------------------------------- -@interface wxCPWCDelegate : NSObject +@interface wxCPWCDelegate : NSObject wxOSX_10_6_AND_LATER() { bool m_bIsClosed; } @@ -61,7 +57,7 @@ IMPLEMENT_DYNAMIC_CLASS(wxColourDialog, wxDialog) - (id)init { - [super init]; + self = [super init]; m_bIsClosed = false; return self; @@ -106,28 +102,17 @@ bool wxColourDialog::Create(wxWindow *parent, wxColourData *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]; + [[NSColorPanel sharedColorPanel] setShowsAlpha:YES]; if(m_colourData.GetColour().IsOk()) [[NSColorPanel sharedColorPanel] setColor: - [NSColor colorWithCalibratedRed:m_colourData.GetColour().Red() / 255.0 - green:m_colourData.GetColour().Green() / 255.0 - blue:m_colourData.GetColour().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) (m_colourData.GetColour().Alpha() / 255.0)] ]; else [[NSColorPanel sharedColorPanel] setColor:[NSColor blackColor]]; @@ -135,10 +120,12 @@ bool wxColourDialog::Create(wxWindow *parent, wxColourData *data) //We're done - free up the pool [thePool release]; - return bOK; + return true; } int wxColourDialog::ShowModal() { + WX_TESTING_SHOW_MODAL_HOOK(); + //Start the pool. Required for carbon interaction //(For those curious, the only thing that happens //if you don't do this is a bunch of error @@ -158,6 +145,7 @@ int wxColourDialog::ShowModal() // // Start the color panel modal loop // + wxDialog::OSXBeginModalDialog(); NSModalSession session = [NSApp beginModalSessionForWindow:theColorPanel]; for (;;) { @@ -168,8 +156,10 @@ int wxColourDialog::ShowModal() break; } [NSApp endModalSession:session]; + wxDialog::OSXEndModalDialog(); //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 @@ -178,8 +168,9 @@ int wxColourDialog::ShowModal() 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 blueComponent] * 255.0), + (unsigned char) ([theColor alphaComponent] * 255.0) + ); //Release the pool, we're done :) [thePool release];