1 /////////////////////////////////////////////////////////////////////////////
2 // Name: src/mac/classic/msgdlg.cpp
3 // Purpose: wxMessageDialog
4 // Author: Stefan Csomor
8 // Copyright: (c) Stefan Csomor
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
12 // for compilers that support precompilation, includes "wx.h".
13 #include "wx/wxprec.h"
15 #include "wx/msgdlg.h"
22 #include "wx/mac/uma.h"
24 IMPLEMENT_CLASS(wxMessageDialog
, wxDialog
)
26 wxMessageDialog::wxMessageDialog(wxWindow
*parent
, const wxString
& message
, const wxString
& caption
,
27 long style
, const wxPoint
& pos
)
32 SetMessageDialogStyle(style
);
35 int wxMessageDialog::ShowModal()
37 int resultbutton
= wxID_CANCEL
;
41 const long style
= GetMessageDialogStyle();
43 wxASSERT_MSG( ( style
& 0x3F ) != wxYES
, wxT("this style is not supported on mac") ) ;
45 AlertType alertType
= kAlertPlainAlert
;
46 if (style
& wxICON_EXCLAMATION
)
47 alertType
= kAlertNoteAlert
;
48 else if (style
& wxICON_HAND
)
49 alertType
= kAlertStopAlert
;
50 else if (style
& wxICON_INFORMATION
)
51 alertType
= kAlertNoteAlert
;
52 else if (style
& wxICON_QUESTION
)
53 alertType
= kAlertCautionAlert
;
56 if ( UMAGetSystemVersion() >= 0x1000 )
58 AlertStdCFStringAlertParamRec param
;
59 wxMacCFStringHolder
cfNoString(_("No") , m_font
.GetEncoding()) ;
60 wxMacCFStringHolder
cfYesString( _("Yes") , m_font
.GetEncoding()) ;
62 wxMacCFStringHolder
cfTitle(m_caption
, m_font
.GetEncoding());
63 wxMacCFStringHolder
cfText(m_message
, m_font
.GetEncoding());
68 bool skipDialog
= false ;
74 param
.defaultText
= cfYesString
;
75 param
.cancelText
= (CFStringRef
) kAlertDefaultCancelText
;
76 param
.otherText
= cfNoString
;
77 param
.helpButton
= false ;
78 param
.defaultButton
= kAlertStdAlertOKButton
;
79 param
.cancelButton
= kAlertStdAlertCancelButton
;
83 param
.defaultText
= cfYesString
;
84 param
.cancelText
= NULL
;
85 param
.otherText
= cfNoString
;
86 param
.helpButton
= false ;
87 param
.defaultButton
= kAlertStdAlertOKButton
;
88 param
.cancelButton
= 0;
91 // the msw implementation even shows an ok button if it is not specified, we'll do the same
96 // thats a cancel missing
97 param
.defaultText
= (CFStringRef
) kAlertDefaultOKText
;
98 param
.cancelText
= (CFStringRef
) kAlertDefaultCancelText
;
99 param
.otherText
= NULL
;
100 param
.helpButton
= false ;
101 param
.defaultButton
= kAlertStdAlertOKButton
;
102 param
.cancelButton
= 0;
106 param
.defaultText
= (CFStringRef
) kAlertDefaultOKText
;
107 param
.cancelText
= NULL
;
108 param
.otherText
= NULL
;
109 param
.helpButton
= false ;
110 param
.defaultButton
= kAlertStdAlertOKButton
;
111 param
.cancelButton
= 0;
121 param
.position
= kWindowDefaultPosition
;
125 CreateStandardAlert( alertType
, cfTitle
, cfText
, ¶m
, &alertRef
) ;
126 RunStandardAlert( alertRef
, NULL
, &result
) ;
134 AlertStdAlertParamRec param
;
141 wxMacStringToPascal( m_caption
, pascalTitle
) ;
142 wxMacStringToPascal( _("Yes") , yesPString
) ;
143 wxMacStringToPascal( _("No") , noPString
) ;
144 wxMacStringToPascal( m_message
, pascalText
) ;
146 param
.movable
= true;
147 param
.filterProc
= NULL
;
148 if (style
& wxYES_NO
)
150 if (style
& wxCANCEL
)
152 param
.defaultText
= yesPString
;
153 param
.cancelText
= (StringPtr
) kAlertDefaultCancelText
;
154 param
.otherText
= noPString
;
155 param
.helpButton
= false ;
156 param
.defaultButton
= kAlertStdAlertOKButton
;
157 param
.cancelButton
= kAlertStdAlertCancelButton
;
161 param
.defaultText
= yesPString
;
162 param
.cancelText
= NULL
;
163 param
.otherText
= noPString
;
164 param
.helpButton
= false ;
165 param
.defaultButton
= kAlertStdAlertOKButton
;
166 param
.cancelButton
= 0;
169 else if (style
& wxOK
)
171 if (style
& wxCANCEL
)
173 param
.defaultText
= (StringPtr
) kAlertDefaultOKText
;
174 param
.cancelText
= (StringPtr
) kAlertDefaultCancelText
;
175 param
.otherText
= NULL
;
176 param
.helpButton
= false ;
177 param
.defaultButton
= kAlertStdAlertOKButton
;
178 param
.cancelButton
= 0;
182 param
.defaultText
= (StringPtr
) kAlertDefaultOKText
;
183 param
.cancelText
= NULL
;
184 param
.otherText
= NULL
;
185 param
.helpButton
= false ;
186 param
.defaultButton
= kAlertStdAlertOKButton
;
187 param
.cancelButton
= 0;
192 return resultbutton
;
197 StandardAlert( alertType
, pascalTitle
, pascalText
, ¶m
, &result
);
202 if (style
& wxCANCEL
)
204 //TODO add Cancelbutton
208 resultbutton
= wxID_OK
;
221 resultbutton
= wxID_OK
;
230 else if (style
& wxYES_NO
)
232 if (style
& wxCANCEL
)
237 resultbutton
= wxID_YES
;
240 resultbutton
= wxID_CANCEL
;
243 resultbutton
= wxID_NO
;
252 resultbutton
= wxID_YES
;
257 resultbutton
= wxID_NO
;
263 return resultbutton
;