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 strcpy( (char*) pascalTitle
, m_caption
) ;
76 c2pstr( (char*) pascalTitle
) ;
77 strcpy( (char*) pascalText
, m_message
) ;
78 wxMacConvertNewlines( (char*)pascalText
,(char*) pascalText
) ;
79 c2pstr( (char*) pascalText
) ;
81 if ( !UMAHasAppearance() )
85 if (m_dialogStyle
& wxYES_NO
)
87 if (m_dialogStyle
& wxCANCEL
)
88 resourceID
= kMacYesNoCancelAlertResourceID
;
90 resourceID
= kMacYesNoAlertResourceID
+ language
* 10 ;
92 else if (m_dialogStyle
& wxOK
)
94 if (m_dialogStyle
& wxCANCEL
)
95 resourceID
= kMacOKAlertResourceID
; // wrong
97 resourceID
= kMacOKAlertResourceID
;
101 return resultbutton
;
105 msStyle |= MB_APPLMODAL;
107 msStyle |= MB_TASKMODAL;
110 ParamText( pascalTitle
, pascalText
, NULL
, NULL
) ;
112 if (m_dialogStyle
& wxICON_EXCLAMATION
)
113 result
= Alert( resourceID
, NULL
) ;
114 else if (m_dialogStyle
& wxICON_HAND
)
115 result
= StopAlert( resourceID
, NULL
) ;
116 else if (m_dialogStyle
& wxICON_INFORMATION
)
117 result
= NoteAlert( resourceID
, NULL
) ;
118 else if (m_dialogStyle
& wxICON_QUESTION
)
119 result
= CautionAlert( resourceID
, NULL
) ;
121 result
= Alert( resourceID
, NULL
) ;
123 resultbutton
= result
;
125 if (m_dialogStyle
& wxYES_NO
)
127 if (m_dialogStyle
& wxCANCEL
)
132 resultbutton
= wxID_YES
;
135 resultbutton
= wxID_NO
;
138 resultbutton
= wxID_CANCEL
;
147 resultbutton
= wxID_YES
;
150 resultbutton
= wxID_NO
;
160 AlertStdAlertParamRec param
;
162 param
.movable
= true;
163 param
.filterProc
= NULL
;
165 if (m_dialogStyle
& wxYES_NO
)
167 if (m_dialogStyle
& wxCANCEL
)
169 param
.defaultText
= "\pYes" ;
170 param
.cancelText
= (StringPtr
) kAlertDefaultCancelText
;
171 param
.otherText
= "\pNo";
172 param
.helpButton
= false ;
173 param
.defaultButton
= kAlertStdAlertOKButton
;
174 param
.cancelButton
= kAlertStdAlertCancelButton
;
178 param
.defaultText
= "\pYes" ;
179 param
.cancelText
= NULL
;
180 param
.otherText
= "\pNo";
181 param
.helpButton
= false ;
182 param
.defaultButton
= kAlertStdAlertOKButton
;
183 param
.cancelButton
= 0;
186 else if (m_dialogStyle
& wxOK
)
188 if (m_dialogStyle
& wxCANCEL
)
190 // thats a cancel missing
191 param
.defaultText
= (StringPtr
) kAlertDefaultOKText
;
192 param
.cancelText
= NULL
;
193 param
.otherText
= NULL
;
194 param
.helpButton
= false ;
195 param
.defaultButton
= kAlertStdAlertOKButton
;
196 param
.cancelButton
= 0;
200 param
.defaultText
= (StringPtr
) kAlertDefaultOKText
;
201 param
.cancelText
= NULL
;
202 param
.otherText
= NULL
;
203 param
.helpButton
= false ;
204 param
.defaultButton
= kAlertStdAlertOKButton
;
205 param
.cancelButton
= 0;
210 return resultbutton
;
215 if (m_dialogStyle
& wxICON_EXCLAMATION
)
216 StandardAlert( kAlertNoteAlert
, pascalTitle
, pascalText
, ¶m
, &result
);
217 else if (m_dialogStyle
& wxICON_HAND
)
218 StandardAlert( kAlertStopAlert
, pascalTitle
, pascalText
, ¶m
, &result
);
219 else if (m_dialogStyle
& wxICON_INFORMATION
)
220 StandardAlert( kAlertNoteAlert
, pascalTitle
, pascalText
, ¶m
, &result
);
221 else if (m_dialogStyle
& wxICON_QUESTION
)
222 StandardAlert( kAlertCautionAlert
, pascalTitle
, pascalText
, ¶m
, &result
);
224 StandardAlert( kAlertPlainAlert
, pascalTitle
, pascalText
, ¶m
, &result
);
226 if (m_dialogStyle
& wxOK
)
228 if (m_dialogStyle
& wxCANCEL
)
230 //TODO add Cancelbutton
234 resultbutton
= wxID_OK
;
247 resultbutton
= wxID_OK
;
256 else if (m_dialogStyle
& wxYES_NO
)
258 if (m_dialogStyle
& wxCANCEL
)
263 resultbutton
= wxID_YES
;
266 resultbutton
= wxID_CANCEL
;
269 resultbutton
= wxID_NO
;
278 resultbutton
= wxID_YES
;
283 resultbutton
= wxID_NO
;
289 return resultbutton
;