]> git.saurik.com Git - wxWidgets.git/blame - src/osx/carbon/colordlg.cpp
guarding open combo box against AppDefined NSEvents issued by wxEventLoop::WakeUp...
[wxWidgets.git] / src / osx / carbon / colordlg.cpp
CommitLineData
489468fe 1/////////////////////////////////////////////////////////////////////////////
80fdcdb9 2// Name: src/osx/carbon/colordlg.cpp
489468fe
SC
3// Purpose: wxColourDialog class. NOTE: you can use the generic class
4// if you wish, instead of implementing this.
5// Author: Stefan Csomor
6// Modified by:
7// Created: 1998-01-01
8// RCS-ID: $Id$
9// Copyright: (c) Stefan Csomor
10// Licence: wxWindows licence
11/////////////////////////////////////////////////////////////////////////////
12
13#include "wx/wxprec.h"
14
17811bf9 15#include "wx/colordlg.h"
489468fe 16#include "wx/fontdlg.h"
691745ab 17#include "wx/modalhook.h"
489468fe
SC
18
19
20#if !USE_NATIVE_FONT_DIALOG_FOR_MACOSX
21
22IMPLEMENT_DYNAMIC_CLASS(wxColourDialog, wxDialog)
23
1f0c8f31 24#include "wx/osx/private.h"
489468fe
SC
25
26/*
27 * wxColourDialog
28 */
29
30wxColourDialog::wxColourDialog()
31{
32 m_dialogParent = NULL;
33}
34
35wxColourDialog::wxColourDialog(wxWindow *parent, wxColourData *data)
36{
37 Create(parent, data);
38}
39
40bool wxColourDialog::Create(wxWindow *parent, wxColourData *data)
41{
42 m_dialogParent = parent;
43
44 if (data)
45 m_colourData = *data;
46 return true;
47}
48
49int wxColourDialog::ShowModal()
50{
691745ab 51 WX_HOOK_MODAL_DIALOG();
643e9cf9 52
489468fe 53 RGBColor currentColor ;
03647350 54
8cbc59fe 55 m_colourData.m_dataColour.GetRGBColor( &currentColor );
489468fe
SC
56 NColorPickerInfo info;
57 OSStatus err ;
58 memset(&info, 0, sizeof(info)) ;
59 // TODO : use parent to determine better position and then kAtSpecifiedOrigin
03647350 60 info.placeWhere = kCenterOnMainScreen ;
489468fe
SC
61 info.flags = kColorPickerDialogIsMoveable | kColorPickerDialogIsModal ;
62 info.theColor.color.rgb.red = currentColor.red ;
63 info.theColor.color.rgb.green = currentColor.green ;
64 info.theColor.color.rgb.blue = currentColor.blue ;
445e564f 65 wxDialog::OSXBeginModalDialog();
489468fe 66 err = NPickColor(&info);
445e564f 67 wxDialog::OSXEndModalDialog();
489468fe
SC
68 if ((err == noErr) && info.newColorChosen)
69 {
70 currentColor.red = info.theColor.color.rgb.red ;
71 currentColor.green = info.theColor.color.rgb.green ;
72 currentColor.blue = info.theColor.color.rgb.blue ;
73 m_colourData.m_dataColour = currentColor;
74
75 return wxID_OK;
76 }
77 return wxID_CANCEL;
78}
79
80#endif