]> git.saurik.com Git - wxWidgets.git/blame - src/mac/msgdlg.cpp
use base 10 by default in wxString::To[U]Long
[wxWidgets.git] / src / mac / msgdlg.cpp
CommitLineData
e9576ca5
SC
1/////////////////////////////////////////////////////////////////////////////
2// Name: msgdlg.cpp
3// Purpose: wxMessageDialog
4// Author: AUTHOR
5// Modified by:
6// Created: 04/01/98
7// RCS-ID: $$
8// Copyright: (c) AUTHOR
9// Licence: wxWindows licence
10/////////////////////////////////////////////////////////////////////////////
11
12#ifdef __GNUG__
13#pragma implementation "msgdlg.h"
14#endif
15
03e11df5 16#include "wx/app.h"
e9576ca5 17#include "wx/msgdlg.h"
49e95e1d 18#include "wx/intl.h"
519cb848 19#include "wx/mac/uma.h"
e9576ca5 20
2f1ae414 21#if !USE_SHARED_LIBRARY
e9576ca5 22IMPLEMENT_CLASS(wxMessageDialog, wxDialog)
2f1ae414 23#endif
e9576ca5 24
519cb848
SC
25short language = 0 ;
26
3d2791f1 27void wxMacConvertNewlines( const char *source , char * destination ) ;
519cb848
SC
28void wxMacConvertNewlines( const char *source , char * destination )
29{
30 const char *s = source ;
31 char *d = destination ;
32
33 while( *s )
34 {
35 switch( *s )
36 {
37 case 0x0a :
38 *d++ = 0x0d ;
39 ++s ;
40 break ;
41 case 0x0d :
42 *d++ = 0x0d ;
43 ++s ;
44 if ( *s == 0x0a )
45 ++s ;
46 break ;
47 default :
48 *d++ = *s++ ;
49 break ;
50 }
51 }
52 *d = 0 ;
53}
54
e9576ca5
SC
55wxMessageDialog::wxMessageDialog(wxWindow *parent, const wxString& message, const wxString& caption,
56 long style, const wxPoint& pos)
57{
58 m_caption = caption;
59 m_message = message;
60 m_dialogStyle = style;
61 m_parent = parent;
62}
63
64int wxMessageDialog::ShowModal()
65{
519cb848
SC
66 int resultbutton = wxID_CANCEL ;
67
68 short result ;
69 Str255 pascalTitle ;
70 Str255 pascalText ;
03e11df5 71 char cText[256] ;
3d2791f1
SC
72
73 Str255 yesPString ;
74 Str255 noPString ;
75
76 wxMacStringToPascal( m_caption , pascalTitle ) ;
77 wxMacStringToPascal( _("Yes") , yesPString ) ;
78 wxMacStringToPascal( _("No") , noPString ) ;
519cb848 79
8208e181
SC
80 if (wxApp::s_macDefaultEncodingIsPC)
81 {
03e11df5 82 strcpy(cText , wxMacMakeMacStringFromPC( m_message) ) ;
8208e181
SC
83 }
84 else
85 {
03e11df5 86 strcpy( cText , m_message ) ;
8208e181
SC
87 }
88
03e11df5 89 wxMacConvertNewlines( cText , cText ) ;
3d2791f1 90 CopyCStringToPascal( cText , pascalText ) ;
519cb848 91
8208e181
SC
92 wxASSERT_MSG( ( m_dialogStyle & 0x3F ) != wxYES , "this style is not supported on mac" ) ;
93
519cb848 94
d09487dd 95 AlertStdAlertParamRec param;
519cb848 96
d09487dd
SC
97 param.movable = true;
98 param.filterProc = NULL ;
99
100 if (m_dialogStyle & wxYES_NO)
101 {
102 if (m_dialogStyle & wxCANCEL)
103 {
104 param.defaultText = yesPString ;
105 param.cancelText = (StringPtr) kAlertDefaultCancelText;
106 param.otherText = noPString ;
107 param.helpButton = false ;
108 param.defaultButton = kAlertStdAlertOKButton;
109 param.cancelButton = kAlertStdAlertCancelButton;
110 }
111 else
112 {
113 param.defaultText = yesPString ;
114 param.cancelText = NULL;
115 param.otherText = noPString ;
116 param.helpButton = false ;
117 param.defaultButton = kAlertStdAlertOKButton;
118 param.cancelButton = 0;
119 }
120 }
121 else if (m_dialogStyle & wxOK)
122 {
123 if (m_dialogStyle & wxCANCEL)
124 {
125 // thats a cancel missing
126 param.defaultText = (StringPtr) kAlertDefaultOKText ;
127 param.cancelText = NULL;
128 param.otherText = NULL;
129 param.helpButton = false ;
130 param.defaultButton = kAlertStdAlertOKButton;
131 param.cancelButton = 0;
132 }
133 else
134 {
135 param.defaultText = (StringPtr) kAlertDefaultOKText ;
136 param.cancelText = NULL;
137 param.otherText = NULL;
138 param.helpButton = false ;
139 param.defaultButton = kAlertStdAlertOKButton;
140 param.cancelButton = 0;
141 }
142 }
519cb848
SC
143 else
144 {
d09487dd
SC
145 return resultbutton ;
146 }
519cb848 147
d09487dd 148 param.position = 0;
519cb848 149
d09487dd 150 if (m_dialogStyle & wxICON_EXCLAMATION)
519cb848 151 StandardAlert( kAlertNoteAlert, pascalTitle, pascalText, &param, &result );
d09487dd
SC
152 else if (m_dialogStyle & wxICON_HAND)
153 StandardAlert( kAlertStopAlert, pascalTitle, pascalText, &param, &result );
154 else if (m_dialogStyle & wxICON_INFORMATION)
155 StandardAlert( kAlertNoteAlert, pascalTitle, pascalText, &param, &result );
156 else if (m_dialogStyle & wxICON_QUESTION)
157 StandardAlert( kAlertCautionAlert, pascalTitle, pascalText, &param, &result );
158 else
159 StandardAlert( kAlertPlainAlert, pascalTitle, pascalText, &param, &result );
160
161 if (m_dialogStyle & wxOK)
162 {
163 if (m_dialogStyle & wxCANCEL)
164 {
165 //TODO add Cancelbutton
166 switch( result )
519cb848 167 {
d09487dd
SC
168 case 1 :
169 resultbutton = wxID_OK ;
170 break ;
171 case 2 :
172 break ;
173 case 3 :
174 break ;
519cb848
SC
175 }
176 }
d09487dd
SC
177 else
178 {
179 switch( result )
180 {
181 case 1 :
182 resultbutton = wxID_OK ;
183 break ;
184 case 2 :
185 break ;
186 case 3 :
187 break ;
519cb848 188 }
d09487dd 189 }
519cb848 190 }
d09487dd
SC
191 else if (m_dialogStyle & wxYES_NO)
192 {
193 if (m_dialogStyle & wxCANCEL)
194 {
195 switch( result )
196 {
197 case 1 :
198 resultbutton = wxID_YES ;
199 break ;
200 case 2 :
201 resultbutton = wxID_CANCEL ;
202 break ;
203 case 3 :
204 resultbutton = wxID_NO ;
205 break ;
206 }
207 }
208 else
209 {
210 switch( result )
211 {
212 case 1 :
213 resultbutton = wxID_YES ;
214 break ;
215 case 2 :
216 break ;
217 case 3 :
218 resultbutton = wxID_NO ;
219 break ;
220 }
221 }
222 }
223
519cb848 224 return resultbutton ;
e9576ca5
SC
225}
226