]>
Commit | Line | Data |
---|---|---|
e9576ca5 SC |
1 | ///////////////////////////////////////////////////////////////////////////// |
2 | // Name: colordlg.cpp | |
3 | // Purpose: wxColourDialog class. NOTE: you can use the generic class | |
4 | // if you wish, instead of implementing this. | |
a31a5f85 | 5 | // Author: Stefan Csomor |
e9576ca5 | 6 | // Modified by: |
a31a5f85 | 7 | // Created: 1998-01-01 |
e9576ca5 | 8 | // RCS-ID: $Id$ |
a31a5f85 | 9 | // Copyright: (c) Stefan Csomor |
65571936 | 10 | // Licence: wxWindows licence |
e9576ca5 SC |
11 | ///////////////////////////////////////////////////////////////////////////// |
12 | ||
a8e9860d SC |
13 | #include "wx/wxprec.h" |
14 | ||
519cb848 | 15 | #include "wx/mac/colordlg.h" |
356c775f RN |
16 | #include "wx/fontdlg.h" |
17 | ||
18 | ||
19 | #if !USE_NATIVE_FONT_DIALOG_FOR_MACOSX | |
e9576ca5 | 20 | |
e9576ca5 | 21 | IMPLEMENT_DYNAMIC_CLASS(wxColourDialog, wxDialog) |
e9576ca5 | 22 | |
76a5e5d2 | 23 | #include "wx/mac/private.h" |
66a09d47 SC |
24 | #ifndef __DARWIN__ |
25 | #include <ColorPicker.h> | |
26 | #endif | |
76a5e5d2 | 27 | |
e9576ca5 SC |
28 | /* |
29 | * wxColourDialog | |
30 | */ | |
31 | ||
32 | wxColourDialog::wxColourDialog() | |
33 | { | |
34 | m_dialogParent = NULL; | |
35 | } | |
36 | ||
37 | wxColourDialog::wxColourDialog(wxWindow *parent, wxColourData *data) | |
38 | { | |
39 | Create(parent, data); | |
40 | } | |
41 | ||
42 | bool wxColourDialog::Create(wxWindow *parent, wxColourData *data) | |
43 | { | |
44 | m_dialogParent = parent; | |
902725ee | 45 | |
e9576ca5 SC |
46 | if (data) |
47 | m_colourData = *data; | |
902725ee | 48 | return true; |
e9576ca5 SC |
49 | } |
50 | ||
51 | int wxColourDialog::ShowModal() | |
52 | { | |
7ea1c917 SC |
53 | RGBColor currentColor = *((RGBColor*)m_colourData.m_dataColour.GetPixel()) ; |
54 | ||
55 | #if TARGET_API_MAC_OSX | |
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 | err = NPickColor(&info); | |
66 | if ((err == noErr) && info.newColorChosen) | |
67 | { | |
68 | currentColor.red = info.theColor.color.rgb.red ; | |
69 | currentColor.green = info.theColor.color.rgb.green ; | |
70 | currentColor.blue = info.theColor.color.rgb.blue ; | |
71 | m_colourData.m_dataColour.Set((WXCOLORREF*) ¤tColor); | |
72 | return wxID_OK; | |
73 | } | |
74 | #else | |
75 | RGBColor newColor ; | |
e40298d5 | 76 | Point where ; |
902725ee | 77 | |
e40298d5 | 78 | where.h = where.v = -1; |
519cb848 | 79 | |
e40298d5 JS |
80 | if (GetColor( where, "\pSelect a new palette color.", ¤tColor, &newColor )) |
81 | { | |
ae500232 | 82 | m_colourData.m_dataColour.Set( (WXCOLORREF*) &newColor ) ; |
e40298d5 JS |
83 | return wxID_OK; |
84 | } | |
7ea1c917 | 85 | #endif |
e9576ca5 SC |
86 | return wxID_CANCEL; |
87 | } | |
88 | ||
356c775f | 89 | #endif |