1 /////////////////////////////////////////////////////////////////////////////
2 // Name: src/mac/carbon/msgdlg.cpp
3 // Purpose: wxMessageDialog
4 // Author: Stefan Csomor
8 // Copyright: (c) Stefan Csomor
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
12 #include "wx/wxprec.h"
15 #include "wx/msgdlg.h"
17 #include "wx/mac/uma.h"
19 IMPLEMENT_CLASS(wxMessageDialog
, wxDialog
)
21 wxMessageDialog::wxMessageDialog(wxWindow
*parent
, const wxString
& message
, const wxString
& caption
,
22 long style
, const wxPoint
& pos
)
27 SetMessageDialogStyle(style
);
30 int wxMessageDialog::ShowModal()
32 int resultbutton
= wxID_CANCEL
;
36 const long style
= GetMessageDialogStyle();
38 wxASSERT_MSG( ( style
& 0x3F ) != wxYES
, wxT("this style is not supported on mac") ) ;
40 AlertType alertType
= kAlertPlainAlert
;
41 if (style
& wxICON_EXCLAMATION
)
42 alertType
= kAlertNoteAlert
;
43 else if (style
& wxICON_HAND
)
44 alertType
= kAlertStopAlert
;
45 else if (style
& wxICON_INFORMATION
)
46 alertType
= kAlertNoteAlert
;
47 else if (style
& wxICON_QUESTION
)
48 alertType
= kAlertCautionAlert
;
51 if ( UMAGetSystemVersion() >= 0x1000 )
53 AlertStdCFStringAlertParamRec param
;
54 wxMacCFStringHolder
cfNoString(_("No") , m_font
.GetEncoding()) ;
55 wxMacCFStringHolder
cfYesString( _("Yes") , m_font
.GetEncoding()) ;
57 wxMacCFStringHolder
cfTitle(m_caption
, m_font
.GetEncoding());
58 wxMacCFStringHolder
cfText(m_message
, m_font
.GetEncoding());
62 param
.version
= kStdCFStringAlertVersionOne
;
64 bool skipDialog
= false ;
70 param
.defaultText
= cfYesString
;
71 param
.cancelText
= (CFStringRef
) kAlertDefaultCancelText
;
72 param
.otherText
= cfNoString
;
73 param
.helpButton
= false ;
74 param
.defaultButton
= style
& wxNO_DEFAULT
? kAlertStdAlertOtherButton
: kAlertStdAlertOKButton
;
75 param
.cancelButton
= kAlertStdAlertCancelButton
;
79 param
.defaultText
= cfYesString
;
80 param
.cancelText
= NULL
;
81 param
.otherText
= cfNoString
;
82 param
.helpButton
= false ;
83 param
.defaultButton
= style
& wxNO_DEFAULT
? kAlertStdAlertOtherButton
: kAlertStdAlertOKButton
;
84 param
.cancelButton
= 0;
87 // the msw implementation even shows an ok button if it is not specified, we'll do the same
92 // thats a cancel missing
93 param
.defaultText
= (CFStringRef
) kAlertDefaultOKText
;
94 param
.cancelText
= (CFStringRef
) kAlertDefaultCancelText
;
95 param
.otherText
= NULL
;
96 param
.helpButton
= false ;
97 param
.defaultButton
= kAlertStdAlertOKButton
;
98 param
.cancelButton
= 0;
102 param
.defaultText
= (CFStringRef
) kAlertDefaultOKText
;
103 param
.cancelText
= NULL
;
104 param
.otherText
= NULL
;
105 param
.helpButton
= false ;
106 param
.defaultButton
= kAlertStdAlertOKButton
;
107 param
.cancelButton
= 0;
117 param
.position
= kWindowDefaultPosition
;
121 CreateStandardAlert( alertType
, cfTitle
, cfText
, ¶m
, &alertRef
) ;
122 RunStandardAlert( alertRef
, NULL
, &result
) ;
130 AlertStdAlertParamRec param
;
137 wxMacStringToPascal( m_caption
, pascalTitle
) ;
138 wxMacStringToPascal( _("Yes") , yesPString
) ;
139 wxMacStringToPascal( _("No") , noPString
) ;
140 wxMacStringToPascal( m_message
, pascalText
) ;
142 param
.movable
= true;
143 param
.filterProc
= NULL
;
144 if (style
& wxYES_NO
)
146 if (style
& wxCANCEL
)
148 param
.defaultText
= yesPString
;
149 param
.cancelText
= (StringPtr
) kAlertDefaultCancelText
;
150 param
.otherText
= noPString
;
151 param
.helpButton
= false ;
152 param
.defaultButton
= kAlertStdAlertOKButton
;
153 param
.cancelButton
= kAlertStdAlertCancelButton
;
157 param
.defaultText
= yesPString
;
158 param
.cancelText
= NULL
;
159 param
.otherText
= noPString
;
160 param
.helpButton
= false ;
161 param
.defaultButton
= kAlertStdAlertOKButton
;
162 param
.cancelButton
= 0;
165 else if (style
& wxOK
)
167 if (style
& wxCANCEL
)
169 param
.defaultText
= (StringPtr
) kAlertDefaultOKText
;
170 param
.cancelText
= (StringPtr
) kAlertDefaultCancelText
;
171 param
.otherText
= NULL
;
172 param
.helpButton
= false ;
173 param
.defaultButton
= kAlertStdAlertOKButton
;
174 param
.cancelButton
= 0;
178 param
.defaultText
= (StringPtr
) kAlertDefaultOKText
;
179 param
.cancelText
= NULL
;
180 param
.otherText
= NULL
;
181 param
.helpButton
= false ;
182 param
.defaultButton
= kAlertStdAlertOKButton
;
183 param
.cancelButton
= 0;
188 return resultbutton
;
193 StandardAlert( alertType
, pascalTitle
, pascalText
, ¶m
, &result
);
198 if (style
& wxCANCEL
)
200 //TODO add Cancelbutton
204 resultbutton
= wxID_OK
;
217 resultbutton
= wxID_OK
;
226 else if (style
& wxYES_NO
)
228 if (style
& wxCANCEL
)
233 resultbutton
= wxID_YES
;
236 resultbutton
= wxID_CANCEL
;
239 resultbutton
= wxID_NO
;
248 resultbutton
= wxID_YES
;
253 resultbutton
= wxID_NO
;
259 return resultbutton
;