1 /////////////////////////////////////////////////////////////////////////////
3 // Purpose: wxMessageDialog
8 // Copyright: (c) AUTHOR
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
13 #pragma implementation "msgdlg.h"
16 #include "wx/msgdlg.h"
17 #include "wx/mac/uma.h"
19 #if !USE_SHARED_LIBRARY
20 IMPLEMENT_CLASS(wxMessageDialog
, wxDialog
)
23 #define kMacOKAlertResourceID 128
24 #define kMacYesNoAlertResourceID 129
25 #define kMacYesNoCancelAlertResourceID 130
26 #define kMacNoYesAlertResourceID 131
27 #define kMacNoYesCancelAlertResourceID 132
31 void wxMacConvertNewlines( const char *source
, char * destination
)
33 const char *s
= source
;
34 char *d
= destination
;
58 wxMessageDialog::wxMessageDialog(wxWindow
*parent
, const wxString
& message
, const wxString
& caption
,
59 long style
, const wxPoint
& pos
)
63 m_dialogStyle
= style
;
67 int wxMessageDialog::ShowModal()
69 int resultbutton
= wxID_CANCEL
;
75 if (wxApp::s_macDefaultEncodingIsPC
)
77 strcpy( (char*) pascalTitle
, wxMacMakeMacStringFromPC( m_caption
) ) ;
78 strcpy( (char*) pascalText
, wxMacMakeMacStringFromPC( m_message
) ) ;
82 strcpy( (char*) pascalTitle
, m_caption
) ;
83 strcpy( (char*) pascalText
, m_message
) ;
86 c2pstr( (char*) pascalTitle
) ;
87 wxMacConvertNewlines( (char*)pascalText
,(char*) pascalText
) ;
88 c2pstr( (char*) pascalText
) ;
90 wxASSERT_MSG( ( m_dialogStyle
& 0x3F ) != wxYES
, "this style is not supported on mac" ) ;
92 if ( !UMAHasAppearance() )
96 if (m_dialogStyle
& wxYES_NO
)
98 if (m_dialogStyle
& wxCANCEL
)
99 resourceID
= kMacYesNoCancelAlertResourceID
;
101 resourceID
= kMacYesNoAlertResourceID
+ language
* 10 ;
103 else if (m_dialogStyle
& wxOK
)
105 if (m_dialogStyle
& wxCANCEL
)
106 resourceID
= kMacOKAlertResourceID
; // wrong
108 resourceID
= kMacOKAlertResourceID
;
112 return resultbutton
;
116 msStyle |= MB_APPLMODAL;
118 msStyle |= MB_TASKMODAL;
121 ParamText( pascalTitle
, pascalText
, NULL
, NULL
) ;
123 if (m_dialogStyle
& wxICON_EXCLAMATION
)
124 result
= Alert( resourceID
, NULL
) ;
125 else if (m_dialogStyle
& wxICON_HAND
)
126 result
= StopAlert( resourceID
, NULL
) ;
127 else if (m_dialogStyle
& wxICON_INFORMATION
)
128 result
= NoteAlert( resourceID
, NULL
) ;
129 else if (m_dialogStyle
& wxICON_QUESTION
)
130 result
= CautionAlert( resourceID
, NULL
) ;
132 result
= Alert( resourceID
, NULL
) ;
134 resultbutton
= result
;
136 if (m_dialogStyle
& wxYES_NO
)
138 if (m_dialogStyle
& wxCANCEL
)
143 resultbutton
= wxID_YES
;
146 resultbutton
= wxID_NO
;
149 resultbutton
= wxID_CANCEL
;
158 resultbutton
= wxID_YES
;
161 resultbutton
= wxID_NO
;
171 AlertStdAlertParamRec param
;
173 param
.movable
= true;
174 param
.filterProc
= NULL
;
176 if (m_dialogStyle
& wxYES_NO
)
178 if (m_dialogStyle
& wxCANCEL
)
180 param
.defaultText
= "\pYes" ;
181 param
.cancelText
= (StringPtr
) kAlertDefaultCancelText
;
182 param
.otherText
= "\pNo";
183 param
.helpButton
= false ;
184 param
.defaultButton
= kAlertStdAlertOKButton
;
185 param
.cancelButton
= kAlertStdAlertCancelButton
;
189 param
.defaultText
= "\pYes" ;
190 param
.cancelText
= NULL
;
191 param
.otherText
= "\pNo";
192 param
.helpButton
= false ;
193 param
.defaultButton
= kAlertStdAlertOKButton
;
194 param
.cancelButton
= 0;
197 else if (m_dialogStyle
& wxOK
)
199 if (m_dialogStyle
& wxCANCEL
)
201 // thats a cancel missing
202 param
.defaultText
= (StringPtr
) kAlertDefaultOKText
;
203 param
.cancelText
= NULL
;
204 param
.otherText
= NULL
;
205 param
.helpButton
= false ;
206 param
.defaultButton
= kAlertStdAlertOKButton
;
207 param
.cancelButton
= 0;
211 param
.defaultText
= (StringPtr
) kAlertDefaultOKText
;
212 param
.cancelText
= NULL
;
213 param
.otherText
= NULL
;
214 param
.helpButton
= false ;
215 param
.defaultButton
= kAlertStdAlertOKButton
;
216 param
.cancelButton
= 0;
221 return resultbutton
;
226 if (m_dialogStyle
& wxICON_EXCLAMATION
)
227 StandardAlert( kAlertNoteAlert
, pascalTitle
, pascalText
, ¶m
, &result
);
228 else if (m_dialogStyle
& wxICON_HAND
)
229 StandardAlert( kAlertStopAlert
, pascalTitle
, pascalText
, ¶m
, &result
);
230 else if (m_dialogStyle
& wxICON_INFORMATION
)
231 StandardAlert( kAlertNoteAlert
, pascalTitle
, pascalText
, ¶m
, &result
);
232 else if (m_dialogStyle
& wxICON_QUESTION
)
233 StandardAlert( kAlertCautionAlert
, pascalTitle
, pascalText
, ¶m
, &result
);
235 StandardAlert( kAlertPlainAlert
, pascalTitle
, pascalText
, ¶m
, &result
);
237 if (m_dialogStyle
& wxOK
)
239 if (m_dialogStyle
& wxCANCEL
)
241 //TODO add Cancelbutton
245 resultbutton
= wxID_OK
;
258 resultbutton
= wxID_OK
;
267 else if (m_dialogStyle
& wxYES_NO
)
269 if (m_dialogStyle
& wxCANCEL
)
274 resultbutton
= wxID_YES
;
277 resultbutton
= wxID_CANCEL
;
280 resultbutton
= wxID_NO
;
289 resultbutton
= wxID_YES
;
294 resultbutton
= wxID_NO
;
300 return resultbutton
;