1 /////////////////////////////////////////////////////////////////////////////
3 // Purpose: wxMessageDialog
8 // Copyright: (c) AUTHOR
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
13 #pragma implementation "msgdlg.h"
17 #include "wx/msgdlg.h"
19 #include "wx/mac/uma.h"
21 #if !USE_SHARED_LIBRARY
22 IMPLEMENT_CLASS(wxMessageDialog
, wxDialog
)
25 #define kMacOKAlertResourceID 128
26 #define kMacYesNoAlertResourceID 129
27 #define kMacYesNoCancelAlertResourceID 130
28 #define kMacNoYesAlertResourceID 131
29 #define kMacNoYesCancelAlertResourceID 132
33 void wxMacConvertNewlines( const char *source
, char * destination
) ;
34 void wxMacConvertNewlines( const char *source
, char * destination
)
36 const char *s
= source
;
37 char *d
= destination
;
61 wxMessageDialog::wxMessageDialog(wxWindow
*parent
, const wxString
& message
, const wxString
& caption
,
62 long style
, const wxPoint
& pos
)
66 m_dialogStyle
= style
;
70 int wxMessageDialog::ShowModal()
72 int resultbutton
= wxID_CANCEL
;
82 wxMacStringToPascal( m_caption
, pascalTitle
) ;
83 wxMacStringToPascal( _("Yes") , yesPString
) ;
84 wxMacStringToPascal( _("No") , noPString
) ;
86 if (wxApp::s_macDefaultEncodingIsPC
)
88 strcpy(cText
, wxMacMakeMacStringFromPC( m_message
) ) ;
92 strcpy( cText
, m_message
) ;
95 wxMacConvertNewlines( cText
, cText
) ;
96 CopyCStringToPascal( cText
, pascalText
) ;
98 wxASSERT_MSG( ( m_dialogStyle
& 0x3F ) != wxYES
, "this style is not supported on mac" ) ;
100 if ( !UMAHasAppearance() )
104 if (m_dialogStyle
& wxYES_NO
)
106 if (m_dialogStyle
& wxCANCEL
)
107 resourceID
= kMacYesNoCancelAlertResourceID
;
109 resourceID
= kMacYesNoAlertResourceID
+ language
* 10 ;
111 else if (m_dialogStyle
& wxOK
)
113 if (m_dialogStyle
& wxCANCEL
)
114 resourceID
= kMacOKAlertResourceID
; // wrong
116 resourceID
= kMacOKAlertResourceID
;
120 return resultbutton
;
124 msStyle |= MB_APPLMODAL;
126 msStyle |= MB_TASKMODAL;
129 ParamText( pascalTitle
, pascalText
, NULL
, NULL
) ;
131 if (m_dialogStyle
& wxICON_EXCLAMATION
)
132 result
= Alert( resourceID
, NULL
) ;
133 else if (m_dialogStyle
& wxICON_HAND
)
134 result
= StopAlert( resourceID
, NULL
) ;
135 else if (m_dialogStyle
& wxICON_INFORMATION
)
136 result
= NoteAlert( resourceID
, NULL
) ;
137 else if (m_dialogStyle
& wxICON_QUESTION
)
138 result
= CautionAlert( resourceID
, NULL
) ;
140 result
= Alert( resourceID
, NULL
) ;
142 resultbutton
= result
;
144 if (m_dialogStyle
& wxYES_NO
)
146 if (m_dialogStyle
& wxCANCEL
)
151 resultbutton
= wxID_YES
;
154 resultbutton
= wxID_NO
;
157 resultbutton
= wxID_CANCEL
;
166 resultbutton
= wxID_YES
;
169 resultbutton
= wxID_NO
;
179 AlertStdAlertParamRec param
;
181 param
.movable
= true;
182 param
.filterProc
= NULL
;
184 if (m_dialogStyle
& wxYES_NO
)
186 if (m_dialogStyle
& wxCANCEL
)
188 param
.defaultText
= yesPString
;
189 param
.cancelText
= (StringPtr
) kAlertDefaultCancelText
;
190 param
.otherText
= noPString
;
191 param
.helpButton
= false ;
192 param
.defaultButton
= kAlertStdAlertOKButton
;
193 param
.cancelButton
= kAlertStdAlertCancelButton
;
197 param
.defaultText
= yesPString
;
198 param
.cancelText
= NULL
;
199 param
.otherText
= noPString
;
200 param
.helpButton
= false ;
201 param
.defaultButton
= kAlertStdAlertOKButton
;
202 param
.cancelButton
= 0;
205 else if (m_dialogStyle
& wxOK
)
207 if (m_dialogStyle
& wxCANCEL
)
209 // thats a cancel missing
210 param
.defaultText
= (StringPtr
) kAlertDefaultOKText
;
211 param
.cancelText
= NULL
;
212 param
.otherText
= NULL
;
213 param
.helpButton
= false ;
214 param
.defaultButton
= kAlertStdAlertOKButton
;
215 param
.cancelButton
= 0;
219 param
.defaultText
= (StringPtr
) kAlertDefaultOKText
;
220 param
.cancelText
= NULL
;
221 param
.otherText
= NULL
;
222 param
.helpButton
= false ;
223 param
.defaultButton
= kAlertStdAlertOKButton
;
224 param
.cancelButton
= 0;
229 return resultbutton
;
234 if (m_dialogStyle
& wxICON_EXCLAMATION
)
235 StandardAlert( kAlertNoteAlert
, pascalTitle
, pascalText
, ¶m
, &result
);
236 else if (m_dialogStyle
& wxICON_HAND
)
237 StandardAlert( kAlertStopAlert
, pascalTitle
, pascalText
, ¶m
, &result
);
238 else if (m_dialogStyle
& wxICON_INFORMATION
)
239 StandardAlert( kAlertNoteAlert
, pascalTitle
, pascalText
, ¶m
, &result
);
240 else if (m_dialogStyle
& wxICON_QUESTION
)
241 StandardAlert( kAlertCautionAlert
, pascalTitle
, pascalText
, ¶m
, &result
);
243 StandardAlert( kAlertPlainAlert
, pascalTitle
, pascalText
, ¶m
, &result
);
245 if (m_dialogStyle
& wxOK
)
247 if (m_dialogStyle
& wxCANCEL
)
249 //TODO add Cancelbutton
253 resultbutton
= wxID_OK
;
266 resultbutton
= wxID_OK
;
275 else if (m_dialogStyle
& wxYES_NO
)
277 if (m_dialogStyle
& wxCANCEL
)
282 resultbutton
= wxID_YES
;
285 resultbutton
= wxID_CANCEL
;
288 resultbutton
= wxID_NO
;
297 resultbutton
= wxID_YES
;
302 resultbutton
= wxID_NO
;
308 return resultbutton
;