]>
git.saurik.com Git - wxWidgets.git/blob - src/gtk/msgdlg.cpp
1 /////////////////////////////////////////////////////////////////////////////
3 // Purpose: wxMessageDialog for GTK+2
4 // Author: Vaclav Slavik
8 // Copyright: (c) Vaclav Slavik, 2003
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
12 #if defined(__GNUG__) && !defined(NO_GCC_PRAGMA)
13 #pragma implementation "msgdlg.h"
16 // For compilers that support precompilation, includes "wx.h".
17 #include "wx/wxprec.h"
23 #if wxUSE_MSGDLG && defined(__WXGTK20__) && !defined(__WXGPE__)
25 #include "wx/gtk/private.h"
28 #include "wx/msgdlg.h"
31 IMPLEMENT_CLASS(wxMessageDialog
, wxDialog
)
33 wxMessageDialog::wxMessageDialog(wxWindow
*parent
,
34 const wxString
& message
,
35 const wxString
& caption
,
37 const wxPoint
& WXUNUSED(pos
))
41 m_dialogStyle
= style
;
42 m_parent
= wxGetTopLevelParent(parent
);
45 int wxMessageDialog::ShowModal()
48 GtkMessageType type
= GTK_MESSAGE_ERROR
;
49 GtkButtonsType buttons
= GTK_BUTTONS_OK
;
51 if (m_dialogStyle
& wxYES_NO
)
53 buttons
= GTK_BUTTONS_YES_NO
;
56 if (m_dialogStyle
& wxOK
)
58 if (m_dialogStyle
& wxCANCEL
)
59 buttons
= GTK_BUTTONS_OK_CANCEL
;
61 buttons
= GTK_BUTTONS_OK
;
64 if (m_dialogStyle
& wxICON_EXCLAMATION
)
65 type
= GTK_MESSAGE_WARNING
;
66 else if (m_dialogStyle
& wxICON_ERROR
)
67 type
= GTK_MESSAGE_ERROR
;
68 else if (m_dialogStyle
& wxICON_INFORMATION
)
69 type
= GTK_MESSAGE_INFO
;
70 else if (m_dialogStyle
& wxICON_QUESTION
)
71 type
= GTK_MESSAGE_QUESTION
;
74 // GTK+ doesn't have a "typeless" msg box, so try to auto detect...
75 type
= m_dialogStyle
& wxYES
? GTK_MESSAGE_QUESTION
: GTK_MESSAGE_INFO
;
78 dlg
= gtk_message_dialog_new(m_parent
?
79 GTK_WINDOW(m_parent
->m_widget
) : NULL
,
82 "%s", (const char*)wxGTK_CONV(m_message
));
83 if (m_caption
!= wxMessageBoxCaptionStr
)
84 gtk_window_set_title(GTK_WINDOW(dlg
), wxGTK_CONV(m_caption
));
86 if (m_dialogStyle
& wxYES_NO
)
88 if (m_dialogStyle
& wxCANCEL
)
89 gtk_dialog_add_button(GTK_DIALOG(dlg
), GTK_STOCK_CANCEL
,
91 if (m_dialogStyle
& wxNO_DEFAULT
)
92 gtk_dialog_set_default_response(GTK_DIALOG(dlg
), GTK_RESPONSE_NO
);
94 gtk_dialog_set_default_response(GTK_DIALOG(dlg
), GTK_RESPONSE_YES
);
97 gint result
= gtk_dialog_run(GTK_DIALOG(dlg
));
98 gtk_widget_destroy(dlg
);
103 wxFAIL_MSG(_T("unexpected GtkMessageDialog return code"));
106 case GTK_RESPONSE_CANCEL
:
108 case GTK_RESPONSE_OK
:
110 case GTK_RESPONSE_YES
:
112 case GTK_RESPONSE_NO
:
117 #endif // wxUSE_MSGDLG && defined(__WXGTK20__)