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
= NULL
;
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 // thats a cancel missing
201 param
.defaultText
= (StringPtr
) kAlertDefaultOKText
;
202 param
.cancelText
= NULL
;
203 param
.otherText
= NULL
;
204 param
.helpButton
= false ;
205 param
.defaultButton
= kAlertStdAlertOKButton
;
206 param
.cancelButton
= 0;
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;
220 return resultbutton
;
225 StandardAlert( alertType
, pascalTitle
, pascalText
, ¶m
, &result
);
228 if (m_dialogStyle
& wxOK
)
230 if (m_dialogStyle
& wxCANCEL
)
232 //TODO add Cancelbutton
236 resultbutton
= wxID_OK
;
249 resultbutton
= wxID_OK
;
258 else if (m_dialogStyle
& wxYES_NO
)
260 if (m_dialogStyle
& wxCANCEL
)
265 resultbutton
= wxID_YES
;
268 resultbutton
= wxID_CANCEL
;
271 resultbutton
= wxID_NO
;
280 resultbutton
= wxID_YES
;
285 resultbutton
= wxID_NO
;
291 return resultbutton
;