]> git.saurik.com Git - wxWidgets.git/blame - src/mac/carbon/msgdlg.cpp
Hopefully fixed library names generated by wx-config for OS/2's PM port.
[wxWidgets.git] / src / mac / carbon / msgdlg.cpp
CommitLineData
e9576ca5 1/////////////////////////////////////////////////////////////////////////////
e5b50758 2// Name: src/mac/carbon/msgdlg.cpp
e9576ca5 3// Purpose: wxMessageDialog
a31a5f85 4// Author: Stefan Csomor
e9576ca5
SC
5// Modified by:
6// Created: 04/01/98
e5b50758 7// RCS-ID: $Id$
a31a5f85 8// Copyright: (c) Stefan Csomor
e5b50758 9// Licence: wxWindows licence
e9576ca5
SC
10/////////////////////////////////////////////////////////////////////////////
11
3d1a4878 12#if defined(__GNUG__) && !defined(NO_GCC_PRAGMA)
e9576ca5
SC
13#pragma implementation "msgdlg.h"
14#endif
15
3d1a4878
SC
16#include "wx/wxprec.h"
17
03e11df5 18#include "wx/app.h"
e9576ca5 19#include "wx/msgdlg.h"
49e95e1d 20#include "wx/intl.h"
519cb848 21#include "wx/mac/uma.h"
e9576ca5 22
e9576ca5 23IMPLEMENT_CLASS(wxMessageDialog, wxDialog)
e9576ca5
SC
24
25wxMessageDialog::wxMessageDialog(wxWindow *parent, const wxString& message, const wxString& caption,
e40298d5 26 long style, const wxPoint& pos)
e9576ca5
SC
27{
28 m_caption = caption;
29 m_message = message;
e9576ca5 30 m_parent = parent;
e5b50758 31 SetMessageDialogStyle(style);
e9576ca5
SC
32}
33
34int wxMessageDialog::ShowModal()
35{
e40298d5 36 int resultbutton = wxID_CANCEL ;
e5b50758 37
e40298d5 38 short result ;
e5b50758
WS
39
40 const long style = GetMessageDialogStyle();
41
42 wxASSERT_MSG( ( style & 0x3F ) != wxYES , wxT("this style is not supported on mac") ) ;
43
e40298d5 44 AlertType alertType = kAlertPlainAlert ;
e5b50758 45 if (style & wxICON_EXCLAMATION)
e40298d5 46 alertType = kAlertNoteAlert ;
e5b50758 47 else if (style & wxICON_HAND)
e40298d5 48 alertType = kAlertStopAlert ;
e5b50758 49 else if (style & wxICON_INFORMATION)
e40298d5 50 alertType = kAlertNoteAlert ;
e5b50758 51 else if (style & wxICON_QUESTION)
e40298d5 52 alertType = kAlertCautionAlert ;
e5b50758 53
992c81e2 54#if TARGET_CARBON
e40298d5
JS
55 if ( UMAGetSystemVersion() >= 0x1000 )
56 {
57 AlertStdCFStringAlertParamRec param ;
a9412f8f
SC
58 wxMacCFStringHolder cfNoString(_("No") , m_font.GetEncoding()) ;
59 wxMacCFStringHolder cfYesString( _("Yes") , m_font.GetEncoding()) ;
e5b50758 60
a9412f8f
SC
61 wxMacCFStringHolder cfTitle(m_caption , m_font.GetEncoding());
62 wxMacCFStringHolder cfText(m_message , m_font.GetEncoding());
e5b50758 63
e40298d5
JS
64 param.movable = true;
65 param.flags = 0 ;
939a2e80 66 param.version = kStdCFStringAlertVersionOne ;
e5b50758 67
e40298d5 68 bool skipDialog = false ;
e5b50758
WS
69
70 if (style & wxYES_NO)
e40298d5 71 {
e5b50758 72 if (style & wxCANCEL)
e40298d5
JS
73 {
74 param.defaultText = cfYesString ;
75 param.cancelText = (CFStringRef) kAlertDefaultCancelText;
76 param.otherText = cfNoString ;
77 param.helpButton = false ;
e5b50758 78 param.defaultButton = style & wxNO_DEFAULT ? kAlertStdAlertOtherButton : kAlertStdAlertOKButton;
e40298d5
JS
79 param.cancelButton = kAlertStdAlertCancelButton;
80 }
81 else
82 {
83 param.defaultText = cfYesString ;
84 param.cancelText = NULL;
85 param.otherText = cfNoString ;
86 param.helpButton = false ;
e5b50758 87 param.defaultButton = style & wxNO_DEFAULT ? kAlertStdAlertOtherButton : kAlertStdAlertOKButton;
e40298d5
JS
88 param.cancelButton = 0;
89 }
90 }
c4a49e11 91 // the msw implementation even shows an ok button if it is not specified, we'll do the same
e5b50758 92 else
e40298d5 93 {
e5b50758 94 if (style & wxCANCEL)
e40298d5
JS
95 {
96 // thats a cancel missing
97 param.defaultText = (CFStringRef) kAlertDefaultOKText ;
b7aec135 98 param.cancelText = (CFStringRef) kAlertDefaultCancelText ;
e40298d5
JS
99 param.otherText = NULL;
100 param.helpButton = false ;
101 param.defaultButton = kAlertStdAlertOKButton;
102 param.cancelButton = 0;
103 }
104 else
105 {
106 param.defaultText = (CFStringRef) kAlertDefaultOKText ;
107 param.cancelText = NULL;
108 param.otherText = NULL;
109 param.helpButton = false ;
110 param.defaultButton = kAlertStdAlertOKButton;
111 param.cancelButton = 0;
112 }
113 }
c4a49e11 114 /*
e40298d5
JS
115 else
116 {
117 skipDialog = true ;
118 }
c4a49e11 119 */
e5b50758 120
e40298d5
JS
121 param.position = kWindowDefaultPosition;
122 if ( !skipDialog )
123 {
124 DialogRef alertRef ;
125 CreateStandardAlert( alertType , cfTitle , cfText , &param , &alertRef ) ;
126 RunStandardAlert( alertRef , NULL , &result ) ;
127 }
e5b50758 128 if ( skipDialog )
e40298d5
JS
129 return wxID_CANCEL ;
130 }
131 else
992c81e2 132#endif
e40298d5
JS
133 {
134 AlertStdAlertParamRec param;
e5b50758 135
e40298d5
JS
136 Str255 yesPString ;
137 Str255 noPString ;
e5b50758 138
e40298d5
JS
139 Str255 pascalTitle ;
140 Str255 pascalText ;
141 wxMacStringToPascal( m_caption , pascalTitle ) ;
142 wxMacStringToPascal( _("Yes") , yesPString ) ;
143 wxMacStringToPascal( _("No") , noPString ) ;
427ff662 144 wxMacStringToPascal( m_message , pascalText ) ;
e5b50758 145
e40298d5
JS
146 param.movable = true;
147 param.filterProc = NULL ;
e5b50758 148 if (style & wxYES_NO)
e40298d5 149 {
e5b50758 150 if (style & wxCANCEL)
e40298d5
JS
151 {
152 param.defaultText = yesPString ;
153 param.cancelText = (StringPtr) kAlertDefaultCancelText;
154 param.otherText = noPString ;
155 param.helpButton = false ;
156 param.defaultButton = kAlertStdAlertOKButton;
157 param.cancelButton = kAlertStdAlertCancelButton;
158 }
159 else
160 {
161 param.defaultText = yesPString ;
162 param.cancelText = NULL;
163 param.otherText = noPString ;
164 param.helpButton = false ;
165 param.defaultButton = kAlertStdAlertOKButton;
166 param.cancelButton = 0;
167 }
168 }
e5b50758 169 else if (style & wxOK)
e40298d5 170 {
e5b50758 171 if (style & wxCANCEL)
e40298d5 172 {
e40298d5 173 param.defaultText = (StringPtr) kAlertDefaultOKText ;
b7aec135 174 param.cancelText = (StringPtr) kAlertDefaultCancelText ;
e40298d5
JS
175 param.otherText = NULL;
176 param.helpButton = false ;
177 param.defaultButton = kAlertStdAlertOKButton;
178 param.cancelButton = 0;
179 }
180 else
181 {
182 param.defaultText = (StringPtr) kAlertDefaultOKText ;
183 param.cancelText = NULL;
184 param.otherText = NULL;
185 param.helpButton = false ;
186 param.defaultButton = kAlertStdAlertOKButton;
187 param.cancelButton = 0;
188 }
189 }
190 else
191 {
192 return resultbutton ;
193 }
e5b50758 194
e40298d5 195 param.position = 0;
e5b50758 196
e40298d5
JS
197 StandardAlert( alertType, pascalTitle, pascalText, &param, &result );
198 }
e5b50758
WS
199
200 if (style & wxOK)
e40298d5 201 {
e5b50758 202 if (style & wxCANCEL)
e40298d5
JS
203 {
204 //TODO add Cancelbutton
205 switch( result )
206 {
207 case 1 :
208 resultbutton = wxID_OK ;
209 break ;
210 case 2 :
211 break ;
212 case 3 :
213 break ;
214 }
215 }
216 else
217 {
218 switch( result )
219 {
220 case 1 :
221 resultbutton = wxID_OK ;
222 break ;
223 case 2 :
224 break ;
225 case 3 :
226 break ;
227 }
228 }
229 }
e5b50758 230 else if (style & wxYES_NO)
e40298d5 231 {
e5b50758 232 if (style & wxCANCEL)
e40298d5
JS
233 {
234 switch( result )
235 {
236 case 1 :
237 resultbutton = wxID_YES ;
238 break ;
239 case 2 :
240 resultbutton = wxID_CANCEL ;
241 break ;
242 case 3 :
243 resultbutton = wxID_NO ;
244 break ;
245 }
246 }
247 else
248 {
249 switch( result )
250 {
251 case 1 :
252 resultbutton = wxID_YES ;
253 break ;
254 case 2 :
255 break ;
256 case 3 :
257 resultbutton = wxID_NO ;
258 break ;
259 }
260 }
e5b50758
WS
261 }
262
e40298d5 263 return resultbutton ;
e9576ca5
SC
264}
265