]> git.saurik.com Git - wxWidgets.git/blob - src/osx/carbon/colordlg.cpp
new method for contentScaleFactor on main screen
[wxWidgets.git] / src / osx / carbon / colordlg.cpp
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
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
15 #include "wx/colordlg.h"
16 #include "wx/fontdlg.h"
17 #include "wx/modalhook.h"
18
19
20 #if !USE_NATIVE_FONT_DIALOG_FOR_MACOSX
21
22 IMPLEMENT_DYNAMIC_CLASS(wxColourDialog, wxDialog)
23
24 #include "wx/osx/private.h"
25
26 /*
27 * wxColourDialog
28 */
29
30 wxColourDialog::wxColourDialog()
31 {
32 m_dialogParent = NULL;
33 }
34
35 wxColourDialog::wxColourDialog(wxWindow *parent, wxColourData *data)
36 {
37 Create(parent, data);
38 }
39
40 bool wxColourDialog::Create(wxWindow *parent, wxColourData *data)
41 {
42 m_dialogParent = parent;
43
44 if (data)
45 m_colourData = *data;
46 return true;
47 }
48
49 int wxColourDialog::ShowModal()
50 {
51 WX_HOOK_MODAL_DIALOG();
52
53 RGBColor currentColor ;
54
55 m_colourData.m_dataColour.GetRGBColor( &currentColor );
56 NColorPickerInfo info;
57 OSStatus err ;
58 memset(&info, 0, sizeof(info)) ;
59 // TODO : use parent to determine better position and then kAtSpecifiedOrigin
60 info.placeWhere = kCenterOnMainScreen ;
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 ;
65 wxDialog::OSXBeginModalDialog();
66 err = NPickColor(&info);
67 wxDialog::OSXEndModalDialog();
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