]> git.saurik.com Git - wxWidgets.git/blob - src/mac/classic/msgdlg.cpp
removed USE_SHARED_LIBRARY mentions (and all variations in spelling) (patch 1231184)
[wxWidgets.git] / src / mac / classic / msgdlg.cpp
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: src/mac/classic/msgdlg.cpp
3 // Purpose: wxMessageDialog
4 // Author: Stefan Csomor
5 // Modified by:
6 // Created: 04/01/98
7 // RCS-ID: $Id$
8 // Copyright: (c) Stefan Csomor
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
11
12 #ifdef __GNUG__
13 #pragma implementation "msgdlg.h"
14 #endif
15
16 #include "wx/app.h"
17 #include "wx/msgdlg.h"
18 #include "wx/intl.h"
19 #include "wx/mac/uma.h"
20
21 IMPLEMENT_CLASS(wxMessageDialog, wxDialog)
22
23 wxMessageDialog::wxMessageDialog(wxWindow *parent, const wxString& message, const wxString& caption,
24 long style, const wxPoint& pos)
25 {
26 m_caption = caption;
27 m_message = message;
28 m_parent = parent;
29 SetMessageDialogStyle(style);
30 }
31
32 int wxMessageDialog::ShowModal()
33 {
34 int resultbutton = wxID_CANCEL ;
35
36 short result ;
37
38 const long style = GetMessageDialogStyle();
39
40 wxASSERT_MSG( ( style & 0x3F ) != wxYES , wxT("this style is not supported on mac") ) ;
41
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 ;
51
52 #if TARGET_CARBON
53 if ( UMAGetSystemVersion() >= 0x1000 )
54 {
55 AlertStdCFStringAlertParamRec param ;
56 wxMacCFStringHolder cfNoString(_("No") , m_font.GetEncoding()) ;
57 wxMacCFStringHolder cfYesString( _("Yes") , m_font.GetEncoding()) ;
58
59 wxMacCFStringHolder cfTitle(m_caption , m_font.GetEncoding());
60 wxMacCFStringHolder cfText(m_message , m_font.GetEncoding());
61
62 param.movable = true;
63 param.flags = 0 ;
64
65 bool skipDialog = false ;
66
67 if (style & wxYES_NO)
68 {
69 if (style & wxCANCEL)
70 {
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;
77 }
78 else
79 {
80 param.defaultText = cfYesString ;
81 param.cancelText = NULL;
82 param.otherText = cfNoString ;
83 param.helpButton = false ;
84 param.defaultButton = kAlertStdAlertOKButton;
85 param.cancelButton = 0;
86 }
87 }
88 // the msw implementation even shows an ok button if it is not specified, we'll do the same
89 else
90 {
91 if (style & wxCANCEL)
92 {
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;
100 }
101 else
102 {
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;
109 }
110 }
111 /*
112 else
113 {
114 skipDialog = true ;
115 }
116 */
117
118 param.position = kWindowDefaultPosition;
119 if ( !skipDialog )
120 {
121 DialogRef alertRef ;
122 CreateStandardAlert( alertType , cfTitle , cfText , &param , &alertRef ) ;
123 RunStandardAlert( alertRef , NULL , &result ) ;
124 }
125 if ( skipDialog )
126 return wxID_CANCEL ;
127 }
128 else
129 #endif
130 {
131 AlertStdAlertParamRec param;
132
133 Str255 yesPString ;
134 Str255 noPString ;
135
136 Str255 pascalTitle ;
137 Str255 pascalText ;
138 wxMacStringToPascal( m_caption , pascalTitle ) ;
139 wxMacStringToPascal( _("Yes") , yesPString ) ;
140 wxMacStringToPascal( _("No") , noPString ) ;
141 wxMacStringToPascal( m_message , pascalText ) ;
142
143 param.movable = true;
144 param.filterProc = NULL ;
145 if (style & wxYES_NO)
146 {
147 if (style & wxCANCEL)
148 {
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;
155 }
156 else
157 {
158 param.defaultText = yesPString ;
159 param.cancelText = NULL;
160 param.otherText = noPString ;
161 param.helpButton = false ;
162 param.defaultButton = kAlertStdAlertOKButton;
163 param.cancelButton = 0;
164 }
165 }
166 else if (style & wxOK)
167 {
168 if (style & wxCANCEL)
169 {
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;
176 }
177 else
178 {
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;
185 }
186 }
187 else
188 {
189 return resultbutton ;
190 }
191
192 param.position = 0;
193
194 StandardAlert( alertType, pascalTitle, pascalText, &param, &result );
195 }
196
197 if (style & wxOK)
198 {
199 if (style & wxCANCEL)
200 {
201 //TODO add Cancelbutton
202 switch( result )
203 {
204 case 1 :
205 resultbutton = wxID_OK ;
206 break ;
207 case 2 :
208 break ;
209 case 3 :
210 break ;
211 }
212 }
213 else
214 {
215 switch( result )
216 {
217 case 1 :
218 resultbutton = wxID_OK ;
219 break ;
220 case 2 :
221 break ;
222 case 3 :
223 break ;
224 }
225 }
226 }
227 else if (style & wxYES_NO)
228 {
229 if (style & wxCANCEL)
230 {
231 switch( result )
232 {
233 case 1 :
234 resultbutton = wxID_YES ;
235 break ;
236 case 2 :
237 resultbutton = wxID_CANCEL ;
238 break ;
239 case 3 :
240 resultbutton = wxID_NO ;
241 break ;
242 }
243 }
244 else
245 {
246 switch( result )
247 {
248 case 1 :
249 resultbutton = wxID_YES ;
250 break ;
251 case 2 :
252 break ;
253 case 3 :
254 resultbutton = wxID_NO ;
255 break ;
256 }
257 }
258 }
259
260 return resultbutton ;
261 }
262