]> git.saurik.com Git - wxWidgets.git/blame - src/osx/carbon/colordlg.cpp
follow up parent chain to properly support modal dialog parents, see #15383
[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
489468fe
SC
8// Copyright: (c) Stefan Csomor
9// Licence: wxWindows licence
10/////////////////////////////////////////////////////////////////////////////
11
12#include "wx/wxprec.h"
13
17811bf9 14#include "wx/colordlg.h"
489468fe 15#include "wx/fontdlg.h"
691745ab 16#include "wx/modalhook.h"
489468fe
SC
17
18
19#if !USE_NATIVE_FONT_DIALOG_FOR_MACOSX
20
21IMPLEMENT_DYNAMIC_CLASS(wxColourDialog, wxDialog)
22
1f0c8f31 23#include "wx/osx/private.h"
489468fe
SC
24
25/*
26 * wxColourDialog
27 */
28
29wxColourDialog::wxColourDialog()
30{
31 m_dialogParent = NULL;
32}
33
34wxColourDialog::wxColourDialog(wxWindow *parent, wxColourData *data)
35{
36 Create(parent, data);
37}
38
39bool wxColourDialog::Create(wxWindow *parent, wxColourData *data)
40{
41 m_dialogParent = parent;
42
43 if (data)
44 m_colourData = *data;
45 return true;
46}
47
48int wxColourDialog::ShowModal()
49{
691745ab 50 WX_HOOK_MODAL_DIALOG();
643e9cf9 51
489468fe 52 RGBColor currentColor ;
03647350 53
8cbc59fe 54 m_colourData.m_dataColour.GetRGBColor( &currentColor );
489468fe
SC
55 NColorPickerInfo info;
56 OSStatus err ;
57 memset(&info, 0, sizeof(info)) ;
58 // TODO : use parent to determine better position and then kAtSpecifiedOrigin
03647350 59 info.placeWhere = kCenterOnMainScreen ;
489468fe
SC
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 ;
445e564f 64 wxDialog::OSXBeginModalDialog();
489468fe 65 err = NPickColor(&info);
445e564f 66 wxDialog::OSXEndModalDialog();
489468fe
SC
67 if ((err == noErr) && info.newColorChosen)
68 {
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;
73
74 return wxID_OK;
75 }
76 return wxID_CANCEL;
77}
78
79#endif