1 /////////////////////////////////////////////////////////////////////////////
3 // Purpose: wxMessageDialog
8 // Copyright: (c) AUTHOR
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
)
27 void wxMacConvertNewlines( const char *source
, char * destination
) ;
28 void wxMacConvertNewlines( const char *source
, char * destination
)
30 const char *s
= source
;
31 char *d
= destination
;
55 wxMessageDialog::wxMessageDialog(wxWindow
*parent
, const wxString
& message
, const wxString
& caption
,
56 long style
, const wxPoint
& pos
)
60 m_dialogStyle
= style
;
64 int wxMessageDialog::ShowModal()
66 int resultbutton
= wxID_CANCEL
;
76 wxMacStringToPascal( m_caption
, pascalTitle
) ;
77 wxMacStringToPascal( _("Yes") , yesPString
) ;
78 wxMacStringToPascal( _("No") , noPString
) ;
80 if (wxApp::s_macDefaultEncodingIsPC
)
82 strcpy(cText
, wxMacMakeMacStringFromPC( m_message
) ) ;
86 strcpy( cText
, m_message
) ;
89 wxMacConvertNewlines( cText
, cText
) ;
90 CopyCStringToPascal( cText
, pascalText
) ;
92 wxASSERT_MSG( ( m_dialogStyle
& 0x3F ) != wxYES
, "this style is not supported on mac" ) ;
95 AlertStdAlertParamRec param
;
98 param
.filterProc
= NULL
;
100 if (m_dialogStyle
& wxYES_NO
)
102 if (m_dialogStyle
& wxCANCEL
)
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
;
113 param
.defaultText
= yesPString
;
114 param
.cancelText
= NULL
;
115 param
.otherText
= noPString
;
116 param
.helpButton
= false ;
117 param
.defaultButton
= kAlertStdAlertOKButton
;
118 param
.cancelButton
= 0;
121 else if (m_dialogStyle
& wxOK
)
123 if (m_dialogStyle
& wxCANCEL
)
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;
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;
145 return resultbutton
;
150 if (m_dialogStyle
& wxICON_EXCLAMATION
)
151 StandardAlert( kAlertNoteAlert
, pascalTitle
, pascalText
, ¶m
, &result
);
152 else if (m_dialogStyle
& wxICON_HAND
)
153 StandardAlert( kAlertStopAlert
, pascalTitle
, pascalText
, ¶m
, &result
);
154 else if (m_dialogStyle
& wxICON_INFORMATION
)
155 StandardAlert( kAlertNoteAlert
, pascalTitle
, pascalText
, ¶m
, &result
);
156 else if (m_dialogStyle
& wxICON_QUESTION
)
157 StandardAlert( kAlertCautionAlert
, pascalTitle
, pascalText
, ¶m
, &result
);
159 StandardAlert( kAlertPlainAlert
, pascalTitle
, pascalText
, ¶m
, &result
);
161 if (m_dialogStyle
& wxOK
)
163 if (m_dialogStyle
& wxCANCEL
)
165 //TODO add Cancelbutton
169 resultbutton
= wxID_OK
;
182 resultbutton
= wxID_OK
;
191 else if (m_dialogStyle
& wxYES_NO
)
193 if (m_dialogStyle
& wxCANCEL
)
198 resultbutton
= wxID_YES
;
201 resultbutton
= wxID_CANCEL
;
204 resultbutton
= wxID_NO
;
213 resultbutton
= wxID_YES
;
218 resultbutton
= wxID_NO
;
224 return resultbutton
;