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 IMPLEMENT_CLASS(wxMessageDialog
, wxDialog
)
21 #define kMacOKAlertResourceID 128
22 #define kMacYesNoAlertResourceID 129
23 #define kMacYesNoCancelAlertResourceID 130
24 #define kMacNoYesAlertResourceID 131
25 #define kMacNoYesCancelAlertResourceID 132
29 void wxMacConvertNewlines( const char *source
, char * destination
)
31 const char *s
= source
;
32 char *d
= destination
;
56 wxMessageDialog::wxMessageDialog(wxWindow
*parent
, const wxString
& message
, const wxString
& caption
,
57 long style
, const wxPoint
& pos
)
61 m_dialogStyle
= style
;
65 int wxMessageDialog::ShowModal()
67 int resultbutton
= wxID_CANCEL
;
73 strcpy( (char*) pascalTitle
, m_caption
) ;
74 c2pstr( (char*) pascalTitle
) ;
75 strcpy( (char*) pascalText
, m_message
) ;
76 wxMacConvertNewlines( (char*)pascalText
,(char*) pascalText
) ;
77 c2pstr( (char*) pascalText
) ;
79 if ( !UMAHasAppearance() )
83 if (m_dialogStyle
& wxYES_NO
)
85 if (m_dialogStyle
& wxCANCEL
)
86 resourceID
= kMacYesNoCancelAlertResourceID
;
88 resourceID
= kMacYesNoAlertResourceID
+ language
* 10 ;
90 else if (m_dialogStyle
& wxOK
)
92 if (m_dialogStyle
& wxCANCEL
)
93 resourceID
= kMacOKAlertResourceID
; // wrong
95 resourceID
= kMacOKAlertResourceID
;
103 msStyle |= MB_APPLMODAL;
105 msStyle |= MB_TASKMODAL;
108 ParamText( pascalTitle
, pascalText
, NULL
, NULL
) ;
110 if (m_dialogStyle
& wxICON_EXCLAMATION
)
111 result
= Alert( resourceID
, NULL
) ;
112 else if (m_dialogStyle
& wxICON_HAND
)
113 result
= StopAlert( resourceID
, NULL
) ;
114 else if (m_dialogStyle
& wxICON_INFORMATION
)
115 result
= NoteAlert( resourceID
, NULL
) ;
116 else if (m_dialogStyle
& wxICON_QUESTION
)
117 result
= CautionAlert( resourceID
, NULL
) ;
119 result
= Alert( resourceID
, NULL
) ;
121 resultbutton
= result
;
123 if (m_dialogStyle
& wxYES_NO
)
125 if (m_dialogStyle
& wxCANCEL
)
130 resultbutton
= wxID_YES
;
133 resultbutton
= wxID_NO
;
136 resultbutton
= wxID_CANCEL
;
145 resultbutton
= wxID_YES
;
148 resultbutton
= wxID_NO
;
158 AlertStdAlertParamRec param
;
160 param
.movable
= true;
161 param
.filterProc
= NULL
;
163 if (m_dialogStyle
& wxYES_NO
)
165 if (m_dialogStyle
& wxCANCEL
)
167 param
.defaultText
= "\pYes" ;
168 param
.cancelText
= (StringPtr
) kAlertDefaultCancelText
;
169 param
.otherText
= "\pNo";
170 param
.helpButton
= false ;
171 param
.defaultButton
= kAlertStdAlertOKButton
;
172 param
.cancelButton
= kAlertStdAlertCancelButton
;
176 param
.defaultText
= "\pYes" ;
177 param
.cancelText
= NULL
;
178 param
.otherText
= "\pNo";
179 param
.helpButton
= false ;
180 param
.defaultButton
= kAlertStdAlertOKButton
;
181 param
.cancelButton
= 0;
184 else if (m_dialogStyle
& wxOK
)
186 if (m_dialogStyle
& wxCANCEL
)
188 // thats a cancel missing
189 param
.defaultText
= (StringPtr
) kAlertDefaultOKText
;
190 param
.cancelText
= NULL
;
191 param
.otherText
= NULL
;
192 param
.helpButton
= false ;
193 param
.defaultButton
= kAlertStdAlertOKButton
;
194 param
.cancelButton
= 0;
198 param
.defaultText
= (StringPtr
) kAlertDefaultOKText
;
199 param
.cancelText
= NULL
;
200 param
.otherText
= NULL
;
201 param
.helpButton
= false ;
202 param
.defaultButton
= kAlertStdAlertOKButton
;
203 param
.cancelButton
= 0;
208 return resultbutton
;
213 if (m_dialogStyle
& wxICON_EXCLAMATION
)
214 StandardAlert( kAlertNoteAlert
, pascalTitle
, pascalText
, ¶m
, &result
);
215 else if (m_dialogStyle
& wxICON_HAND
)
216 StandardAlert( kAlertStopAlert
, pascalTitle
, pascalText
, ¶m
, &result
);
217 else if (m_dialogStyle
& wxICON_INFORMATION
)
218 StandardAlert( kAlertNoteAlert
, pascalTitle
, pascalText
, ¶m
, &result
);
219 else if (m_dialogStyle
& wxICON_QUESTION
)
220 StandardAlert( kAlertCautionAlert
, pascalTitle
, pascalText
, ¶m
, &result
);
222 StandardAlert( kAlertPlainAlert
, pascalTitle
, pascalText
, ¶m
, &result
);
224 if (m_dialogStyle
& wxOK
)
226 if (m_dialogStyle
& wxCANCEL
)
228 //TODO add Cancelbutton
232 resultbutton
= wxID_OK
;
245 resultbutton
= wxID_OK
;
254 else if (m_dialogStyle
& wxYES_NO
)
256 if (m_dialogStyle
& wxCANCEL
)
261 resultbutton
= wxID_YES
;
264 resultbutton
= wxID_CANCEL
;
267 resultbutton
= wxID_NO
;
276 resultbutton
= wxID_YES
;
281 resultbutton
= wxID_NO
;
287 return resultbutton
;