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 #include "wx/msgdlg.h"
15 #include "wx/mac/uma.h"
17 IMPLEMENT_CLASS(wxMessageDialog
, wxDialog
)
19 wxMessageDialog::wxMessageDialog(wxWindow
*parent
, const wxString
& message
, const wxString
& caption
,
20 long style
, const wxPoint
& pos
)
25 SetMessageDialogStyle(style
);
28 int wxMessageDialog::ShowModal()
30 int resultbutton
= wxID_CANCEL
;
34 const long style
= GetMessageDialogStyle();
36 wxASSERT_MSG( ( style
& 0x3F ) != wxYES
, wxT("this style is not supported on mac") ) ;
38 AlertType alertType
= kAlertPlainAlert
;
39 if (style
& wxICON_EXCLAMATION
)
40 alertType
= kAlertNoteAlert
;
41 else if (style
& wxICON_HAND
)
42 alertType
= kAlertStopAlert
;
43 else if (style
& wxICON_INFORMATION
)
44 alertType
= kAlertNoteAlert
;
45 else if (style
& wxICON_QUESTION
)
46 alertType
= kAlertCautionAlert
;
49 if ( UMAGetSystemVersion() >= 0x1000 )
51 AlertStdCFStringAlertParamRec param
;
52 wxMacCFStringHolder
cfNoString(_("No") , m_font
.GetEncoding()) ;
53 wxMacCFStringHolder
cfYesString( _("Yes") , m_font
.GetEncoding()) ;
55 wxMacCFStringHolder
cfTitle(m_caption
, m_font
.GetEncoding());
56 wxMacCFStringHolder
cfText(m_message
, m_font
.GetEncoding());
61 bool skipDialog
= false ;
67 param
.defaultText
= cfYesString
;
68 param
.cancelText
= (CFStringRef
) kAlertDefaultCancelText
;
69 param
.otherText
= cfNoString
;
70 param
.helpButton
= false ;
71 param
.defaultButton
= kAlertStdAlertOKButton
;
72 param
.cancelButton
= kAlertStdAlertCancelButton
;
76 param
.defaultText
= cfYesString
;
77 param
.cancelText
= NULL
;
78 param
.otherText
= cfNoString
;
79 param
.helpButton
= false ;
80 param
.defaultButton
= kAlertStdAlertOKButton
;
81 param
.cancelButton
= 0;
84 // the msw implementation even shows an ok button if it is not specified, we'll do the same
89 // thats a cancel missing
90 param
.defaultText
= (CFStringRef
) kAlertDefaultOKText
;
91 param
.cancelText
= (CFStringRef
) kAlertDefaultCancelText
;
92 param
.otherText
= NULL
;
93 param
.helpButton
= false ;
94 param
.defaultButton
= kAlertStdAlertOKButton
;
95 param
.cancelButton
= 0;
99 param
.defaultText
= (CFStringRef
) kAlertDefaultOKText
;
100 param
.cancelText
= NULL
;
101 param
.otherText
= NULL
;
102 param
.helpButton
= false ;
103 param
.defaultButton
= kAlertStdAlertOKButton
;
104 param
.cancelButton
= 0;
114 param
.position
= kWindowDefaultPosition
;
118 CreateStandardAlert( alertType
, cfTitle
, cfText
, ¶m
, &alertRef
) ;
119 RunStandardAlert( alertRef
, NULL
, &result
) ;
127 AlertStdAlertParamRec param
;
134 wxMacStringToPascal( m_caption
, pascalTitle
) ;
135 wxMacStringToPascal( _("Yes") , yesPString
) ;
136 wxMacStringToPascal( _("No") , noPString
) ;
137 wxMacStringToPascal( m_message
, pascalText
) ;
139 param
.movable
= true;
140 param
.filterProc
= NULL
;
141 if (style
& wxYES_NO
)
143 if (style
& wxCANCEL
)
145 param
.defaultText
= yesPString
;
146 param
.cancelText
= (StringPtr
) kAlertDefaultCancelText
;
147 param
.otherText
= noPString
;
148 param
.helpButton
= false ;
149 param
.defaultButton
= kAlertStdAlertOKButton
;
150 param
.cancelButton
= kAlertStdAlertCancelButton
;
154 param
.defaultText
= yesPString
;
155 param
.cancelText
= NULL
;
156 param
.otherText
= noPString
;
157 param
.helpButton
= false ;
158 param
.defaultButton
= kAlertStdAlertOKButton
;
159 param
.cancelButton
= 0;
162 else if (style
& wxOK
)
164 if (style
& wxCANCEL
)
166 param
.defaultText
= (StringPtr
) kAlertDefaultOKText
;
167 param
.cancelText
= (StringPtr
) kAlertDefaultCancelText
;
168 param
.otherText
= NULL
;
169 param
.helpButton
= false ;
170 param
.defaultButton
= kAlertStdAlertOKButton
;
171 param
.cancelButton
= 0;
175 param
.defaultText
= (StringPtr
) kAlertDefaultOKText
;
176 param
.cancelText
= NULL
;
177 param
.otherText
= NULL
;
178 param
.helpButton
= false ;
179 param
.defaultButton
= kAlertStdAlertOKButton
;
180 param
.cancelButton
= 0;
185 return resultbutton
;
190 StandardAlert( alertType
, pascalTitle
, pascalText
, ¶m
, &result
);
195 if (style
& wxCANCEL
)
197 //TODO add Cancelbutton
201 resultbutton
= wxID_OK
;
214 resultbutton
= wxID_OK
;
223 else if (style
& wxYES_NO
)
225 if (style
& wxCANCEL
)
230 resultbutton
= wxID_YES
;
233 resultbutton
= wxID_CANCEL
;
236 resultbutton
= wxID_NO
;
245 resultbutton
= wxID_YES
;
250 resultbutton
= wxID_NO
;
256 return resultbutton
;