1 /////////////////////////////////////////////////////////////////////////////
3 // Purpose: wxMessageDialog
8 // Copyright: (c) AUTHOR
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
13 #pragma implementation "msgdlg.h"
17 #include "wx/msgdlg.h"
18 #include "wx/mac/uma.h"
20 #if !USE_SHARED_LIBRARY
21 IMPLEMENT_CLASS(wxMessageDialog
, wxDialog
)
24 #define kMacOKAlertResourceID 128
25 #define kMacYesNoAlertResourceID 129
26 #define kMacYesNoCancelAlertResourceID 130
27 #define kMacNoYesAlertResourceID 131
28 #define kMacNoYesCancelAlertResourceID 132
32 void wxMacConvertNewlines( const char *source
, char * destination
) ;
33 void wxMacConvertNewlines( const char *source
, char * destination
)
35 const char *s
= source
;
36 char *d
= destination
;
60 wxMessageDialog::wxMessageDialog(wxWindow
*parent
, const wxString
& message
, const wxString
& caption
,
61 long style
, const wxPoint
& pos
)
65 m_dialogStyle
= style
;
69 int wxMessageDialog::ShowModal()
71 int resultbutton
= wxID_CANCEL
;
81 wxMacStringToPascal( m_caption
, pascalTitle
) ;
82 wxMacStringToPascal( _("Yes") , yesPString
) ;
83 wxMacStringToPascal( _("No") , noPString
) ;
85 if (wxApp::s_macDefaultEncodingIsPC
)
87 strcpy(cText
, wxMacMakeMacStringFromPC( m_message
) ) ;
91 strcpy( cText
, m_message
) ;
94 wxMacConvertNewlines( cText
, cText
) ;
95 CopyCStringToPascal( cText
, pascalText
) ;
97 wxASSERT_MSG( ( m_dialogStyle
& 0x3F ) != wxYES
, "this style is not supported on mac" ) ;
99 if ( !UMAHasAppearance() )
103 if (m_dialogStyle
& wxYES_NO
)
105 if (m_dialogStyle
& wxCANCEL
)
106 resourceID
= kMacYesNoCancelAlertResourceID
;
108 resourceID
= kMacYesNoAlertResourceID
+ language
* 10 ;
110 else if (m_dialogStyle
& wxOK
)
112 if (m_dialogStyle
& wxCANCEL
)
113 resourceID
= kMacOKAlertResourceID
; // wrong
115 resourceID
= kMacOKAlertResourceID
;
119 return resultbutton
;
123 msStyle |= MB_APPLMODAL;
125 msStyle |= MB_TASKMODAL;
128 ParamText( pascalTitle
, pascalText
, NULL
, NULL
) ;
130 if (m_dialogStyle
& wxICON_EXCLAMATION
)
131 result
= Alert( resourceID
, NULL
) ;
132 else if (m_dialogStyle
& wxICON_HAND
)
133 result
= StopAlert( resourceID
, NULL
) ;
134 else if (m_dialogStyle
& wxICON_INFORMATION
)
135 result
= NoteAlert( resourceID
, NULL
) ;
136 else if (m_dialogStyle
& wxICON_QUESTION
)
137 result
= CautionAlert( resourceID
, NULL
) ;
139 result
= Alert( resourceID
, NULL
) ;
141 resultbutton
= result
;
143 if (m_dialogStyle
& wxYES_NO
)
145 if (m_dialogStyle
& wxCANCEL
)
150 resultbutton
= wxID_YES
;
153 resultbutton
= wxID_NO
;
156 resultbutton
= wxID_CANCEL
;
165 resultbutton
= wxID_YES
;
168 resultbutton
= wxID_NO
;
178 AlertStdAlertParamRec param
;
180 param
.movable
= true;
181 param
.filterProc
= NULL
;
183 if (m_dialogStyle
& wxYES_NO
)
185 if (m_dialogStyle
& wxCANCEL
)
187 param
.defaultText
= yesPString
;
188 param
.cancelText
= (StringPtr
) kAlertDefaultCancelText
;
189 param
.otherText
= noPString
;
190 param
.helpButton
= false ;
191 param
.defaultButton
= kAlertStdAlertOKButton
;
192 param
.cancelButton
= kAlertStdAlertCancelButton
;
196 param
.defaultText
= yesPString
;
197 param
.cancelText
= NULL
;
198 param
.otherText
= noPString
;
199 param
.helpButton
= false ;
200 param
.defaultButton
= kAlertStdAlertOKButton
;
201 param
.cancelButton
= 0;
204 else if (m_dialogStyle
& wxOK
)
206 if (m_dialogStyle
& wxCANCEL
)
208 // thats a cancel missing
209 param
.defaultText
= (StringPtr
) kAlertDefaultOKText
;
210 param
.cancelText
= NULL
;
211 param
.otherText
= NULL
;
212 param
.helpButton
= false ;
213 param
.defaultButton
= kAlertStdAlertOKButton
;
214 param
.cancelButton
= 0;
218 param
.defaultText
= (StringPtr
) kAlertDefaultOKText
;
219 param
.cancelText
= NULL
;
220 param
.otherText
= NULL
;
221 param
.helpButton
= false ;
222 param
.defaultButton
= kAlertStdAlertOKButton
;
223 param
.cancelButton
= 0;
228 return resultbutton
;
233 if (m_dialogStyle
& wxICON_EXCLAMATION
)
234 StandardAlert( kAlertNoteAlert
, pascalTitle
, pascalText
, ¶m
, &result
);
235 else if (m_dialogStyle
& wxICON_HAND
)
236 StandardAlert( kAlertStopAlert
, pascalTitle
, pascalText
, ¶m
, &result
);
237 else if (m_dialogStyle
& wxICON_INFORMATION
)
238 StandardAlert( kAlertNoteAlert
, pascalTitle
, pascalText
, ¶m
, &result
);
239 else if (m_dialogStyle
& wxICON_QUESTION
)
240 StandardAlert( kAlertCautionAlert
, pascalTitle
, pascalText
, ¶m
, &result
);
242 StandardAlert( kAlertPlainAlert
, pascalTitle
, pascalText
, ¶m
, &result
);
244 if (m_dialogStyle
& wxOK
)
246 if (m_dialogStyle
& wxCANCEL
)
248 //TODO add Cancelbutton
252 resultbutton
= wxID_OK
;
265 resultbutton
= wxID_OK
;
274 else if (m_dialogStyle
& wxYES_NO
)
276 if (m_dialogStyle
& wxCANCEL
)
281 resultbutton
= wxID_YES
;
284 resultbutton
= wxID_CANCEL
;
287 resultbutton
= wxID_NO
;
296 resultbutton
= wxID_YES
;
301 resultbutton
= wxID_NO
;
307 return resultbutton
;