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 #if defined(__GNUG__) && !defined(NO_GCC_PRAGMA)
13 #pragma implementation "msgdlg.h"
16 #include "wx/wxprec.h"
19 #include "wx/msgdlg.h"
21 #include "wx/mac/uma.h"
23 #if !USE_SHARED_LIBRARY
24 IMPLEMENT_CLASS(wxMessageDialog
, wxDialog
)
27 wxMessageDialog::wxMessageDialog(wxWindow
*parent
, const wxString
& message
, const wxString
& caption
,
28 long style
, const wxPoint
& pos
)
33 SetMessageDialogStyle(style
);
36 int wxMessageDialog::ShowModal()
38 int resultbutton
= wxID_CANCEL
;
42 const long style
= GetMessageDialogStyle();
44 wxASSERT_MSG( ( style
& 0x3F ) != wxYES
, wxT("this style is not supported on mac") ) ;
46 AlertType alertType
= kAlertPlainAlert
;
47 if (style
& wxICON_EXCLAMATION
)
48 alertType
= kAlertNoteAlert
;
49 else if (style
& wxICON_HAND
)
50 alertType
= kAlertStopAlert
;
51 else if (style
& wxICON_INFORMATION
)
52 alertType
= kAlertNoteAlert
;
53 else if (style
& wxICON_QUESTION
)
54 alertType
= kAlertCautionAlert
;
57 if ( UMAGetSystemVersion() >= 0x1000 )
59 AlertStdCFStringAlertParamRec param
;
60 wxMacCFStringHolder
cfNoString(_("No") , m_font
.GetEncoding()) ;
61 wxMacCFStringHolder
cfYesString( _("Yes") , m_font
.GetEncoding()) ;
63 wxMacCFStringHolder
cfTitle(m_caption
, m_font
.GetEncoding());
64 wxMacCFStringHolder
cfText(m_message
, m_font
.GetEncoding());
68 param
.version
= kStdCFStringAlertVersionOne
;
70 bool skipDialog
= false ;
76 param
.defaultText
= cfYesString
;
77 param
.cancelText
= (CFStringRef
) kAlertDefaultCancelText
;
78 param
.otherText
= cfNoString
;
79 param
.helpButton
= false ;
80 param
.defaultButton
= style
& wxNO_DEFAULT
? kAlertStdAlertOtherButton
: kAlertStdAlertOKButton
;
81 param
.cancelButton
= kAlertStdAlertCancelButton
;
85 param
.defaultText
= cfYesString
;
86 param
.cancelText
= NULL
;
87 param
.otherText
= cfNoString
;
88 param
.helpButton
= false ;
89 param
.defaultButton
= style
& wxNO_DEFAULT
? kAlertStdAlertOtherButton
: kAlertStdAlertOKButton
;
90 param
.cancelButton
= 0;
93 // the msw implementation even shows an ok button if it is not specified, we'll do the same
98 // thats a cancel missing
99 param
.defaultText
= (CFStringRef
) kAlertDefaultOKText
;
100 param
.cancelText
= (CFStringRef
) kAlertDefaultCancelText
;
101 param
.otherText
= NULL
;
102 param
.helpButton
= false ;
103 param
.defaultButton
= kAlertStdAlertOKButton
;
104 param
.cancelButton
= 0;
108 param
.defaultText
= (CFStringRef
) kAlertDefaultOKText
;
109 param
.cancelText
= NULL
;
110 param
.otherText
= NULL
;
111 param
.helpButton
= false ;
112 param
.defaultButton
= kAlertStdAlertOKButton
;
113 param
.cancelButton
= 0;
123 param
.position
= kWindowDefaultPosition
;
127 CreateStandardAlert( alertType
, cfTitle
, cfText
, ¶m
, &alertRef
) ;
128 RunStandardAlert( alertRef
, NULL
, &result
) ;
136 AlertStdAlertParamRec param
;
143 wxMacStringToPascal( m_caption
, pascalTitle
) ;
144 wxMacStringToPascal( _("Yes") , yesPString
) ;
145 wxMacStringToPascal( _("No") , noPString
) ;
146 wxMacStringToPascal( m_message
, pascalText
) ;
148 param
.movable
= true;
149 param
.filterProc
= NULL
;
150 if (style
& wxYES_NO
)
152 if (style
& wxCANCEL
)
154 param
.defaultText
= yesPString
;
155 param
.cancelText
= (StringPtr
) kAlertDefaultCancelText
;
156 param
.otherText
= noPString
;
157 param
.helpButton
= false ;
158 param
.defaultButton
= kAlertStdAlertOKButton
;
159 param
.cancelButton
= kAlertStdAlertCancelButton
;
163 param
.defaultText
= yesPString
;
164 param
.cancelText
= NULL
;
165 param
.otherText
= noPString
;
166 param
.helpButton
= false ;
167 param
.defaultButton
= kAlertStdAlertOKButton
;
168 param
.cancelButton
= 0;
171 else if (style
& wxOK
)
173 if (style
& wxCANCEL
)
175 param
.defaultText
= (StringPtr
) kAlertDefaultOKText
;
176 param
.cancelText
= (StringPtr
) kAlertDefaultCancelText
;
177 param
.otherText
= NULL
;
178 param
.helpButton
= false ;
179 param
.defaultButton
= kAlertStdAlertOKButton
;
180 param
.cancelButton
= 0;
184 param
.defaultText
= (StringPtr
) kAlertDefaultOKText
;
185 param
.cancelText
= NULL
;
186 param
.otherText
= NULL
;
187 param
.helpButton
= false ;
188 param
.defaultButton
= kAlertStdAlertOKButton
;
189 param
.cancelButton
= 0;
194 return resultbutton
;
199 StandardAlert( alertType
, pascalTitle
, pascalText
, ¶m
, &result
);
204 if (style
& wxCANCEL
)
206 //TODO add Cancelbutton
210 resultbutton
= wxID_OK
;
223 resultbutton
= wxID_OK
;
232 else if (style
& wxYES_NO
)
234 if (style
& wxCANCEL
)
239 resultbutton
= wxID_YES
;
242 resultbutton
= wxID_CANCEL
;
245 resultbutton
= wxID_NO
;
254 resultbutton
= wxID_YES
;
259 resultbutton
= wxID_NO
;
265 return resultbutton
;