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 /////////////////////////////////////////////////////////////////////////////
13 #pragma implementation "msgdlg.h"
17 #include "wx/msgdlg.h"
19 #include "wx/mac/uma.h"
21 IMPLEMENT_CLASS(wxMessageDialog
, wxDialog
)
23 wxMessageDialog::wxMessageDialog(wxWindow
*parent
, const wxString
& message
, const wxString
& caption
,
24 long style
, const wxPoint
& pos
)
29 SetMessageDialogStyle(style
);
32 int wxMessageDialog::ShowModal()
34 int resultbutton
= wxID_CANCEL
;
38 const long style
= GetMessageDialogStyle();
40 wxASSERT_MSG( ( style
& 0x3F ) != wxYES
, wxT("this style is not supported on mac") ) ;
42 AlertType alertType
= kAlertPlainAlert
;
43 if (style
& wxICON_EXCLAMATION
)
44 alertType
= kAlertNoteAlert
;
45 else if (style
& wxICON_HAND
)
46 alertType
= kAlertStopAlert
;
47 else if (style
& wxICON_INFORMATION
)
48 alertType
= kAlertNoteAlert
;
49 else if (style
& wxICON_QUESTION
)
50 alertType
= kAlertCautionAlert
;
53 if ( UMAGetSystemVersion() >= 0x1000 )
55 AlertStdCFStringAlertParamRec param
;
56 wxMacCFStringHolder
cfNoString(_("No") , m_font
.GetEncoding()) ;
57 wxMacCFStringHolder
cfYesString( _("Yes") , m_font
.GetEncoding()) ;
59 wxMacCFStringHolder
cfTitle(m_caption
, m_font
.GetEncoding());
60 wxMacCFStringHolder
cfText(m_message
, m_font
.GetEncoding());
65 bool skipDialog
= false ;
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
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 (style
& wxYES_NO
)
147 if (style
& 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 (style
& wxOK
)
168 if (style
& 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
);
199 if (style
& wxCANCEL
)
201 //TODO add Cancelbutton
205 resultbutton
= wxID_OK
;
218 resultbutton
= wxID_OK
;
227 else if (style
& wxYES_NO
)
229 if (style
& wxCANCEL
)
234 resultbutton
= wxID_YES
;
237 resultbutton
= wxID_CANCEL
;
240 resultbutton
= wxID_NO
;
249 resultbutton
= wxID_YES
;
254 resultbutton
= wxID_NO
;
260 return resultbutton
;