1 /////////////////////////////////////////////////////////////////////////////
3 // Purpose: wxMessageDialog
8 // Copyright: (c) AUTHOR
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
13 #pragma implementation "msgdlg.h"
17 #include "wx/msgdlg.h"
18 #include "wx/mac/uma.h"
20 #if !USE_SHARED_LIBRARY
21 IMPLEMENT_CLASS(wxMessageDialog
, wxDialog
)
24 #define kMacOKAlertResourceID 128
25 #define kMacYesNoAlertResourceID 129
26 #define kMacYesNoCancelAlertResourceID 130
27 #define kMacNoYesAlertResourceID 131
28 #define kMacNoYesCancelAlertResourceID 132
32 void wxMacConvertNewlines( const char *source
, char * destination
)
34 const char *s
= source
;
35 char *d
= destination
;
59 wxMessageDialog::wxMessageDialog(wxWindow
*parent
, const wxString
& message
, const wxString
& caption
,
60 long style
, const wxPoint
& pos
)
64 m_dialogStyle
= style
;
68 int wxMessageDialog::ShowModal()
70 int resultbutton
= wxID_CANCEL
;
77 if (wxApp::s_macDefaultEncodingIsPC
)
80 c2pstrcpy( (StringPtr
) pascalTitle
, wxMacMakeMacStringFromPC( m_caption
) ) ;
82 strcpy( (char *) pascalTitle
, wxMacMakeMacStringFromPC( m_caption
) ) ;
83 c2pstr( (char *) pascalTitle
) ;
85 strcpy(cText
, wxMacMakeMacStringFromPC( m_message
) ) ;
90 c2pstrcpy( (StringPtr
) pascalTitle
, m_caption
) ;
92 strcpy( (char *) pascalTitle
, m_caption
) ;
93 c2pstr( (char *) pascalTitle
) ;
95 strcpy( cText
, m_message
) ;
98 wxMacConvertNewlines( cText
, cText
) ;
100 c2pstrcpy( (StringPtr
) pascalText
, cText
) ;
102 strcpy( (char *) pascalText
, cText
) ;
103 c2pstr( (char *) pascalText
) ;
106 wxASSERT_MSG( ( m_dialogStyle
& 0x3F ) != wxYES
, "this style is not supported on mac" ) ;
108 if ( !UMAHasAppearance() )
112 if (m_dialogStyle
& wxYES_NO
)
114 if (m_dialogStyle
& wxCANCEL
)
115 resourceID
= kMacYesNoCancelAlertResourceID
;
117 resourceID
= kMacYesNoAlertResourceID
+ language
* 10 ;
119 else if (m_dialogStyle
& wxOK
)
121 if (m_dialogStyle
& wxCANCEL
)
122 resourceID
= kMacOKAlertResourceID
; // wrong
124 resourceID
= kMacOKAlertResourceID
;
128 return resultbutton
;
132 msStyle |= MB_APPLMODAL;
134 msStyle |= MB_TASKMODAL;
137 ParamText( pascalTitle
, pascalText
, NULL
, NULL
) ;
139 if (m_dialogStyle
& wxICON_EXCLAMATION
)
140 result
= Alert( resourceID
, NULL
) ;
141 else if (m_dialogStyle
& wxICON_HAND
)
142 result
= StopAlert( resourceID
, NULL
) ;
143 else if (m_dialogStyle
& wxICON_INFORMATION
)
144 result
= NoteAlert( resourceID
, NULL
) ;
145 else if (m_dialogStyle
& wxICON_QUESTION
)
146 result
= CautionAlert( resourceID
, NULL
) ;
148 result
= Alert( resourceID
, NULL
) ;
150 resultbutton
= result
;
152 if (m_dialogStyle
& wxYES_NO
)
154 if (m_dialogStyle
& wxCANCEL
)
159 resultbutton
= wxID_YES
;
162 resultbutton
= wxID_NO
;
165 resultbutton
= wxID_CANCEL
;
174 resultbutton
= wxID_YES
;
177 resultbutton
= wxID_NO
;
187 AlertStdAlertParamRec param
;
189 param
.movable
= true;
190 param
.filterProc
= NULL
;
192 if (m_dialogStyle
& wxYES_NO
)
194 if (m_dialogStyle
& wxCANCEL
)
196 param
.defaultText
= "\pYes" ;
197 param
.cancelText
= (StringPtr
) kAlertDefaultCancelText
;
198 param
.otherText
= "\pNo";
199 param
.helpButton
= false ;
200 param
.defaultButton
= kAlertStdAlertOKButton
;
201 param
.cancelButton
= kAlertStdAlertCancelButton
;
205 param
.defaultText
= "\pYes" ;
206 param
.cancelText
= NULL
;
207 param
.otherText
= "\pNo";
208 param
.helpButton
= false ;
209 param
.defaultButton
= kAlertStdAlertOKButton
;
210 param
.cancelButton
= 0;
213 else if (m_dialogStyle
& wxOK
)
215 if (m_dialogStyle
& wxCANCEL
)
217 // thats a cancel missing
218 param
.defaultText
= (StringPtr
) kAlertDefaultOKText
;
219 param
.cancelText
= NULL
;
220 param
.otherText
= NULL
;
221 param
.helpButton
= false ;
222 param
.defaultButton
= kAlertStdAlertOKButton
;
223 param
.cancelButton
= 0;
227 param
.defaultText
= (StringPtr
) kAlertDefaultOKText
;
228 param
.cancelText
= NULL
;
229 param
.otherText
= NULL
;
230 param
.helpButton
= false ;
231 param
.defaultButton
= kAlertStdAlertOKButton
;
232 param
.cancelButton
= 0;
237 return resultbutton
;
242 if (m_dialogStyle
& wxICON_EXCLAMATION
)
243 StandardAlert( kAlertNoteAlert
, pascalTitle
, pascalText
, ¶m
, &result
);
244 else if (m_dialogStyle
& wxICON_HAND
)
245 StandardAlert( kAlertStopAlert
, pascalTitle
, pascalText
, ¶m
, &result
);
246 else if (m_dialogStyle
& wxICON_INFORMATION
)
247 StandardAlert( kAlertNoteAlert
, pascalTitle
, pascalText
, ¶m
, &result
);
248 else if (m_dialogStyle
& wxICON_QUESTION
)
249 StandardAlert( kAlertCautionAlert
, pascalTitle
, pascalText
, ¶m
, &result
);
251 StandardAlert( kAlertPlainAlert
, pascalTitle
, pascalText
, ¶m
, &result
);
253 if (m_dialogStyle
& wxOK
)
255 if (m_dialogStyle
& wxCANCEL
)
257 //TODO add Cancelbutton
261 resultbutton
= wxID_OK
;
274 resultbutton
= wxID_OK
;
283 else if (m_dialogStyle
& wxYES_NO
)
285 if (m_dialogStyle
& wxCANCEL
)
290 resultbutton
= wxID_YES
;
293 resultbutton
= wxID_CANCEL
;
296 resultbutton
= wxID_NO
;
305 resultbutton
= wxID_YES
;
310 resultbutton
= wxID_NO
;
316 return resultbutton
;