]> git.saurik.com Git - wxWidgets.git/blob - src/gtk/msgdlg.cpp
Blind fix for library ordering.
[wxWidgets.git] / src / gtk / msgdlg.cpp
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: msgdlg.cpp
3 // Purpose: wxMessageDialog for GTK+2
4 // Author: Vaclav Slavik
5 // Modified by:
6 // Created: 2003/02/28
7 // RCS-ID: $Id$
8 // Copyright: (c) Vaclav Slavik, 2003
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
11
12 #if defined(__GNUG__) && !defined(NO_GCC_PRAGMA)
13 #pragma implementation "msgdlg.h"
14 #endif
15
16 // For compilers that support precompilation, includes "wx.h".
17 #include "wx/wxprec.h"
18
19 #ifdef __BORLANDC__
20 #pragma hdrstop
21 #endif
22
23 #if wxUSE_MSGDLG && defined(__WXGTK20__)
24
25 #include "wx/gtk/private.h"
26 #include <gtk/gtk.h>
27
28 #include "wx/msgdlg.h"
29 #include "wx/intl.h"
30
31 IMPLEMENT_CLASS(wxMessageDialog, wxDialog)
32
33 wxMessageDialog::wxMessageDialog(wxWindow *parent,
34 const wxString& message,
35 const wxString& caption,
36 long style,
37 const wxPoint& WXUNUSED(pos))
38 {
39 m_caption = caption;
40 m_message = message;
41 m_dialogStyle = style;
42 m_parent = parent;
43 }
44
45 int wxMessageDialog::ShowModal()
46 {
47 GtkWidget *dlg;
48 GtkMessageType type;
49 GtkButtonsType buttons = GTK_BUTTONS_OK;
50
51 if (m_dialogStyle & wxYES_NO)
52 {
53 buttons = GTK_BUTTONS_YES_NO;
54 }
55
56 if (m_dialogStyle & wxOK)
57 {
58 if (m_dialogStyle & wxCANCEL)
59 buttons = GTK_BUTTONS_OK_CANCEL;
60 else
61 buttons = GTK_BUTTONS_OK;
62 }
63
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;
72
73 dlg = gtk_message_dialog_new(m_parent ?
74 GTK_WINDOW(m_parent->m_widget) : NULL,
75 GTK_DIALOG_MODAL,
76 type, buttons,
77 "%s", (const char*)wxGTK_CONV(m_message));
78 if (m_caption != wxMessageBoxCaptionStr)
79 gtk_window_set_title(GTK_WINDOW(dlg), wxGTK_CONV(m_caption));
80
81 if (m_dialogStyle & wxYES_NO)
82 {
83 if (m_dialogStyle & wxCANCEL)
84 gtk_dialog_add_button(GTK_DIALOG(dlg), GTK_STOCK_CANCEL,
85 GTK_RESPONSE_CANCEL);
86 if (m_dialogStyle & wxNO_DEFAULT)
87 gtk_dialog_set_default_response(GTK_DIALOG(dlg), GTK_RESPONSE_NO);
88 else
89 gtk_dialog_set_default_response(GTK_DIALOG(dlg), GTK_RESPONSE_YES);
90 }
91
92 gint result = gtk_dialog_run(GTK_DIALOG(dlg));
93 gtk_widget_destroy(dlg);
94
95 switch (result)
96 {
97 default:
98 wxFAIL_MSG(_T("unexpected GtkMessageDialog return code"));
99 // fall through
100
101 case GTK_RESPONSE_CANCEL:
102 return wxID_CANCEL;
103 case GTK_RESPONSE_OK:
104 return wxID_OK;
105 case GTK_RESPONSE_YES:
106 return wxID_YES;
107 case GTK_RESPONSE_NO:
108 return wxID_NO;
109 }
110 }
111
112 #endif // wxUSE_MSGDLG && defined(__WXGTK20__)
113