1 /////////////////////////////////////////////////////////////////////////////
2 // Name: src/osx/carbon/colordlg.cpp
3 // Purpose: wxColourDialog class. NOTE: you can use the generic class
4 // if you wish, instead of implementing this.
5 // Author: Stefan Csomor
8 // Copyright: (c) Stefan Csomor
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
12 #include "wx/wxprec.h"
14 #include "wx/colordlg.h"
15 #include "wx/fontdlg.h"
16 #include "wx/modalhook.h"
19 #if !USE_NATIVE_FONT_DIALOG_FOR_MACOSX
21 IMPLEMENT_DYNAMIC_CLASS(wxColourDialog
, wxDialog
)
23 #include "wx/osx/private.h"
29 wxColourDialog::wxColourDialog()
31 m_dialogParent
= NULL
;
34 wxColourDialog::wxColourDialog(wxWindow
*parent
, wxColourData
*data
)
39 bool wxColourDialog::Create(wxWindow
*parent
, wxColourData
*data
)
41 m_dialogParent
= parent
;
48 int wxColourDialog::ShowModal()
50 WX_HOOK_MODAL_DIALOG();
52 RGBColor currentColor
;
54 m_colourData
.m_dataColour
.GetRGBColor( ¤tColor
);
55 NColorPickerInfo info
;
57 memset(&info
, 0, sizeof(info
)) ;
58 // TODO : use parent to determine better position and then kAtSpecifiedOrigin
59 info
.placeWhere
= kCenterOnMainScreen
;
60 info
.flags
= kColorPickerDialogIsMoveable
| kColorPickerDialogIsModal
;
61 info
.theColor
.color
.rgb
.red
= currentColor
.red
;
62 info
.theColor
.color
.rgb
.green
= currentColor
.green
;
63 info
.theColor
.color
.rgb
.blue
= currentColor
.blue
;
64 wxDialog::OSXBeginModalDialog();
65 err
= NPickColor(&info
);
66 wxDialog::OSXEndModalDialog();
67 if ((err
== noErr
) && info
.newColorChosen
)
69 currentColor
.red
= info
.theColor
.color
.rgb
.red
;
70 currentColor
.green
= info
.theColor
.color
.rgb
.green
;
71 currentColor
.blue
= info
.theColor
.color
.rgb
.blue
;
72 m_colourData
.m_dataColour
= currentColor
;