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 #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
)
31 SetMessageDialogStyle(style
);
34 int wxMessageDialog::ShowModal()
36 int resultbutton
= wxID_CANCEL
;
40 const long style
= GetMessageDialogStyle();
42 wxASSERT_MSG( ( style
& 0x3F ) != wxYES
, wxT("this style is not supported on mac") ) ;
44 AlertType alertType
= kAlertPlainAlert
;
45 if (style
& wxICON_EXCLAMATION
)
46 alertType
= kAlertNoteAlert
;
47 else if (style
& wxICON_HAND
)
48 alertType
= kAlertStopAlert
;
49 else if (style
& wxICON_INFORMATION
)
50 alertType
= kAlertNoteAlert
;
51 else if (style
& wxICON_QUESTION
)
52 alertType
= kAlertCautionAlert
;
55 if ( UMAGetSystemVersion() >= 0x1000 )
57 AlertStdCFStringAlertParamRec param
;
58 wxMacCFStringHolder
cfNoString(_("No") , m_font
.GetEncoding()) ;
59 wxMacCFStringHolder
cfYesString( _("Yes") , m_font
.GetEncoding()) ;
61 wxMacCFStringHolder
cfTitle(m_caption
, m_font
.GetEncoding());
62 wxMacCFStringHolder
cfText(m_message
, m_font
.GetEncoding());
67 bool skipDialog
= false ;
73 param
.defaultText
= cfYesString
;
74 param
.cancelText
= (CFStringRef
) kAlertDefaultCancelText
;
75 param
.otherText
= cfNoString
;
76 param
.helpButton
= false ;
77 param
.defaultButton
= kAlertStdAlertOKButton
;
78 param
.cancelButton
= kAlertStdAlertCancelButton
;
82 param
.defaultText
= cfYesString
;
83 param
.cancelText
= NULL
;
84 param
.otherText
= cfNoString
;
85 param
.helpButton
= false ;
86 param
.defaultButton
= kAlertStdAlertOKButton
;
87 param
.cancelButton
= 0;
90 // the msw implementation even shows an ok button if it is not specified, we'll do the same
95 // thats a cancel missing
96 param
.defaultText
= (CFStringRef
) kAlertDefaultOKText
;
97 param
.cancelText
= (CFStringRef
) kAlertDefaultCancelText
;
98 param
.otherText
= NULL
;
99 param
.helpButton
= false ;
100 param
.defaultButton
= kAlertStdAlertOKButton
;
101 param
.cancelButton
= 0;
105 param
.defaultText
= (CFStringRef
) kAlertDefaultOKText
;
106 param
.cancelText
= NULL
;
107 param
.otherText
= NULL
;
108 param
.helpButton
= false ;
109 param
.defaultButton
= kAlertStdAlertOKButton
;
110 param
.cancelButton
= 0;
120 param
.position
= kWindowDefaultPosition
;
124 CreateStandardAlert( alertType
, cfTitle
, cfText
, ¶m
, &alertRef
) ;
125 RunStandardAlert( alertRef
, NULL
, &result
) ;
133 AlertStdAlertParamRec param
;
140 wxMacStringToPascal( m_caption
, pascalTitle
) ;
141 wxMacStringToPascal( _("Yes") , yesPString
) ;
142 wxMacStringToPascal( _("No") , noPString
) ;
143 wxMacStringToPascal( m_message
, pascalText
) ;
145 param
.movable
= true;
146 param
.filterProc
= NULL
;
147 if (style
& wxYES_NO
)
149 if (style
& wxCANCEL
)
151 param
.defaultText
= yesPString
;
152 param
.cancelText
= (StringPtr
) kAlertDefaultCancelText
;
153 param
.otherText
= noPString
;
154 param
.helpButton
= false ;
155 param
.defaultButton
= kAlertStdAlertOKButton
;
156 param
.cancelButton
= kAlertStdAlertCancelButton
;
160 param
.defaultText
= yesPString
;
161 param
.cancelText
= NULL
;
162 param
.otherText
= noPString
;
163 param
.helpButton
= false ;
164 param
.defaultButton
= kAlertStdAlertOKButton
;
165 param
.cancelButton
= 0;
168 else if (style
& wxOK
)
170 if (style
& wxCANCEL
)
172 param
.defaultText
= (StringPtr
) kAlertDefaultOKText
;
173 param
.cancelText
= (StringPtr
) kAlertDefaultCancelText
;
174 param
.otherText
= NULL
;
175 param
.helpButton
= false ;
176 param
.defaultButton
= kAlertStdAlertOKButton
;
177 param
.cancelButton
= 0;
181 param
.defaultText
= (StringPtr
) kAlertDefaultOKText
;
182 param
.cancelText
= NULL
;
183 param
.otherText
= NULL
;
184 param
.helpButton
= false ;
185 param
.defaultButton
= kAlertStdAlertOKButton
;
186 param
.cancelButton
= 0;
191 return resultbutton
;
196 StandardAlert( alertType
, pascalTitle
, pascalText
, ¶m
, &result
);
201 if (style
& wxCANCEL
)
203 //TODO add Cancelbutton
207 resultbutton
= wxID_OK
;
220 resultbutton
= wxID_OK
;
229 else if (style
& wxYES_NO
)
231 if (style
& wxCANCEL
)
236 resultbutton
= wxID_YES
;
239 resultbutton
= wxID_CANCEL
;
242 resultbutton
= wxID_NO
;
251 resultbutton
= wxID_YES
;
256 resultbutton
= wxID_NO
;
262 return resultbutton
;