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
)
25 wxMessageDialog::wxMessageDialog(wxWindow
*parent
, const wxString
& message
, const wxString
& caption
,
26 long style
, const wxPoint
& pos
)
30 m_dialogStyle
= style
;
34 int wxMessageDialog::ShowModal()
36 int resultbutton
= wxID_CANCEL
;
40 wxASSERT_MSG( ( m_dialogStyle
& 0x3F ) != wxYES
, wxT("this style is not supported on mac") ) ;
42 AlertType alertType
= kAlertPlainAlert
;
43 if (m_dialogStyle
& wxICON_EXCLAMATION
)
44 alertType
= kAlertNoteAlert
;
45 else if (m_dialogStyle
& wxICON_HAND
)
46 alertType
= kAlertStopAlert
;
47 else if (m_dialogStyle
& wxICON_INFORMATION
)
48 alertType
= kAlertNoteAlert
;
49 else if (m_dialogStyle
& wxICON_QUESTION
)
50 alertType
= kAlertCautionAlert
;
53 if ( UMAGetSystemVersion() >= 0x1000 )
55 AlertStdCFStringAlertParamRec param
;
56 wxMacCFStringHolder
cfNoString(_("No")) ;
57 wxMacCFStringHolder
cfYesString( _("Yes")) ;
59 wxMacCFStringHolder
cfTitle(m_caption
);
60 wxMacCFStringHolder
cfText(m_message
);
65 bool skipDialog
= false ;
67 if (m_dialogStyle
& wxYES_NO
)
69 if (m_dialogStyle
& wxCANCEL
)
71 param
.defaultText
= cfYesString
;
72 param
.cancelText
= (CFStringRef
) kAlertDefaultCancelText
;
73 param
.otherText
= cfNoString
;
74 param
.helpButton
= false ;
75 param
.defaultButton
= kAlertStdAlertOKButton
;
76 param
.cancelButton
= kAlertStdAlertCancelButton
;
80 param
.defaultText
= cfYesString
;
81 param
.cancelText
= NULL
;
82 param
.otherText
= cfNoString
;
83 param
.helpButton
= false ;
84 param
.defaultButton
= kAlertStdAlertOKButton
;
85 param
.cancelButton
= 0;
88 // the msw implementation even shows an ok button if it is not specified, we'll do the same
91 if (m_dialogStyle
& wxCANCEL
)
93 // thats a cancel missing
94 param
.defaultText
= (CFStringRef
) kAlertDefaultOKText
;
95 param
.cancelText
= (CFStringRef
) kAlertDefaultCancelText
;
96 param
.otherText
= NULL
;
97 param
.helpButton
= false ;
98 param
.defaultButton
= kAlertStdAlertOKButton
;
99 param
.cancelButton
= 0;
103 param
.defaultText
= (CFStringRef
) kAlertDefaultOKText
;
104 param
.cancelText
= NULL
;
105 param
.otherText
= NULL
;
106 param
.helpButton
= false ;
107 param
.defaultButton
= kAlertStdAlertOKButton
;
108 param
.cancelButton
= 0;
118 param
.position
= kWindowDefaultPosition
;
122 CreateStandardAlert( alertType
, cfTitle
, cfText
, ¶m
, &alertRef
) ;
123 RunStandardAlert( alertRef
, NULL
, &result
) ;
131 AlertStdAlertParamRec param
;
138 wxMacStringToPascal( m_caption
, pascalTitle
) ;
139 wxMacStringToPascal( _("Yes") , yesPString
) ;
140 wxMacStringToPascal( _("No") , noPString
) ;
141 wxMacStringToPascal( m_message
, pascalText
) ;
143 param
.movable
= true;
144 param
.filterProc
= NULL
;
145 if (m_dialogStyle
& wxYES_NO
)
147 if (m_dialogStyle
& wxCANCEL
)
149 param
.defaultText
= yesPString
;
150 param
.cancelText
= (StringPtr
) kAlertDefaultCancelText
;
151 param
.otherText
= noPString
;
152 param
.helpButton
= false ;
153 param
.defaultButton
= kAlertStdAlertOKButton
;
154 param
.cancelButton
= kAlertStdAlertCancelButton
;
158 param
.defaultText
= yesPString
;
159 param
.cancelText
= NULL
;
160 param
.otherText
= noPString
;
161 param
.helpButton
= false ;
162 param
.defaultButton
= kAlertStdAlertOKButton
;
163 param
.cancelButton
= 0;
166 else if (m_dialogStyle
& wxOK
)
168 if (m_dialogStyle
& wxCANCEL
)
170 param
.defaultText
= (StringPtr
) kAlertDefaultOKText
;
171 param
.cancelText
= (StringPtr
) kAlertDefaultCancelText
;
172 param
.otherText
= NULL
;
173 param
.helpButton
= false ;
174 param
.defaultButton
= kAlertStdAlertOKButton
;
175 param
.cancelButton
= 0;
179 param
.defaultText
= (StringPtr
) kAlertDefaultOKText
;
180 param
.cancelText
= NULL
;
181 param
.otherText
= NULL
;
182 param
.helpButton
= false ;
183 param
.defaultButton
= kAlertStdAlertOKButton
;
184 param
.cancelButton
= 0;
189 return resultbutton
;
194 StandardAlert( alertType
, pascalTitle
, pascalText
, ¶m
, &result
);
197 if (m_dialogStyle
& wxOK
)
199 if (m_dialogStyle
& wxCANCEL
)
201 //TODO add Cancelbutton
205 resultbutton
= wxID_OK
;
218 resultbutton
= wxID_OK
;
227 else if (m_dialogStyle
& wxYES_NO
)
229 if (m_dialogStyle
& wxCANCEL
)
234 resultbutton
= wxID_YES
;
237 resultbutton
= wxID_CANCEL
;
240 resultbutton
= wxID_NO
;
249 resultbutton
= wxID_YES
;
254 resultbutton
= wxID_NO
;
260 return resultbutton
;