1 /////////////////////////////////////////////////////////////////////////////
3 // Purpose: wxMessageDialog
4 // Author: Stefan Csomor
8 // Copyright: (c) Stefan Csomor
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
)
27 void wxMacConvertNewlines( const char *source
, char * destination
) ;
28 void wxMacConvertNewlines( const char *source
, char * destination
)
30 const char *s
= source
;
31 char *d
= destination
;
55 wxMessageDialog::wxMessageDialog(wxWindow
*parent
, const wxString
& message
, const wxString
& caption
,
56 long style
, const wxPoint
& pos
)
60 m_dialogStyle
= style
;
64 int wxMessageDialog::ShowModal()
66 int resultbutton
= wxID_CANCEL
;
70 wxASSERT_MSG( ( m_dialogStyle
& 0x3F ) != wxYES
, wxT("this style is not supported on mac") ) ;
72 AlertType alertType
= kAlertPlainAlert
;
73 if (m_dialogStyle
& wxICON_EXCLAMATION
)
74 alertType
= kAlertNoteAlert
;
75 else if (m_dialogStyle
& wxICON_HAND
)
76 alertType
= kAlertStopAlert
;
77 else if (m_dialogStyle
& wxICON_INFORMATION
)
78 alertType
= kAlertNoteAlert
;
79 else if (m_dialogStyle
& wxICON_QUESTION
)
80 alertType
= kAlertCautionAlert
;
83 if ( UMAGetSystemVersion() >= 0x1000 )
85 AlertStdCFStringAlertParamRec param
;
86 wxMacCFStringHolder
cfNoString(_("No")) ;
87 wxMacCFStringHolder
cfYesString( _("Yes")) ;
89 wxMacCFStringHolder
cfTitle(m_caption
);
90 wxMacCFStringHolder
cfText(m_message
);
95 bool skipDialog
= false ;
97 if (m_dialogStyle
& wxYES_NO
)
99 if (m_dialogStyle
& wxCANCEL
)
101 param
.defaultText
= cfYesString
;
102 param
.cancelText
= (CFStringRef
) kAlertDefaultCancelText
;
103 param
.otherText
= cfNoString
;
104 param
.helpButton
= false ;
105 param
.defaultButton
= kAlertStdAlertOKButton
;
106 param
.cancelButton
= kAlertStdAlertCancelButton
;
110 param
.defaultText
= cfYesString
;
111 param
.cancelText
= NULL
;
112 param
.otherText
= cfNoString
;
113 param
.helpButton
= false ;
114 param
.defaultButton
= kAlertStdAlertOKButton
;
115 param
.cancelButton
= 0;
118 // the msw implementation even shows an ok button if it is not specified, we'll do the same
121 if (m_dialogStyle
& wxCANCEL
)
123 // thats a cancel missing
124 param
.defaultText
= (CFStringRef
) kAlertDefaultOKText
;
125 param
.cancelText
= (CFStringRef
) kAlertDefaultCancelText
;
126 param
.otherText
= NULL
;
127 param
.helpButton
= false ;
128 param
.defaultButton
= kAlertStdAlertOKButton
;
129 param
.cancelButton
= 0;
133 param
.defaultText
= (CFStringRef
) kAlertDefaultOKText
;
134 param
.cancelText
= NULL
;
135 param
.otherText
= NULL
;
136 param
.helpButton
= false ;
137 param
.defaultButton
= kAlertStdAlertOKButton
;
138 param
.cancelButton
= 0;
148 param
.position
= kWindowDefaultPosition
;
152 CreateStandardAlert( alertType
, cfTitle
, cfText
, ¶m
, &alertRef
) ;
153 RunStandardAlert( alertRef
, NULL
, &result
) ;
161 AlertStdAlertParamRec param
;
168 wxMacStringToPascal( m_caption
, pascalTitle
) ;
169 wxMacStringToPascal( _("Yes") , yesPString
) ;
170 wxMacStringToPascal( _("No") , noPString
) ;
171 wxMacStringToPascal( m_message
, pascalText
) ;
173 param
.movable
= true;
174 param
.filterProc
= NULL
;
175 if (m_dialogStyle
& wxYES_NO
)
177 if (m_dialogStyle
& wxCANCEL
)
179 param
.defaultText
= yesPString
;
180 param
.cancelText
= (StringPtr
) kAlertDefaultCancelText
;
181 param
.otherText
= noPString
;
182 param
.helpButton
= false ;
183 param
.defaultButton
= kAlertStdAlertOKButton
;
184 param
.cancelButton
= kAlertStdAlertCancelButton
;
188 param
.defaultText
= yesPString
;
189 param
.cancelText
= NULL
;
190 param
.otherText
= noPString
;
191 param
.helpButton
= false ;
192 param
.defaultButton
= kAlertStdAlertOKButton
;
193 param
.cancelButton
= 0;
196 else if (m_dialogStyle
& wxOK
)
198 if (m_dialogStyle
& wxCANCEL
)
200 param
.defaultText
= (StringPtr
) kAlertDefaultOKText
;
201 param
.cancelText
= (StringPtr
) kAlertDefaultCancelText
;
202 param
.otherText
= NULL
;
203 param
.helpButton
= false ;
204 param
.defaultButton
= kAlertStdAlertOKButton
;
205 param
.cancelButton
= 0;
209 param
.defaultText
= (StringPtr
) kAlertDefaultOKText
;
210 param
.cancelText
= NULL
;
211 param
.otherText
= NULL
;
212 param
.helpButton
= false ;
213 param
.defaultButton
= kAlertStdAlertOKButton
;
214 param
.cancelButton
= 0;
219 return resultbutton
;
224 StandardAlert( alertType
, pascalTitle
, pascalText
, ¶m
, &result
);
227 if (m_dialogStyle
& wxOK
)
229 if (m_dialogStyle
& wxCANCEL
)
231 //TODO add Cancelbutton
235 resultbutton
= wxID_OK
;
248 resultbutton
= wxID_OK
;
257 else if (m_dialogStyle
& wxYES_NO
)
259 if (m_dialogStyle
& wxCANCEL
)
264 resultbutton
= wxID_YES
;
267 resultbutton
= wxID_CANCEL
;
270 resultbutton
= wxID_NO
;
279 resultbutton
= wxID_YES
;
284 resultbutton
= wxID_NO
;
290 return resultbutton
;