]>
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
;
45 while (!parent
->IsTopLevel())
46 parent
= parent
->GetParent();
52 int wxMessageDialog::ShowModal()
55 GtkMessageType type
= GTK_MESSAGE_ERROR
;
56 GtkButtonsType buttons
= GTK_BUTTONS_OK
;
58 if (m_dialogStyle
& wxYES_NO
)
60 buttons
= GTK_BUTTONS_YES_NO
;
63 if (m_dialogStyle
& wxOK
)
65 if (m_dialogStyle
& wxCANCEL
)
66 buttons
= GTK_BUTTONS_OK_CANCEL
;
68 buttons
= GTK_BUTTONS_OK
;
71 if (m_dialogStyle
& wxICON_EXCLAMATION
)
72 type
= GTK_MESSAGE_WARNING
;
73 else if (m_dialogStyle
& wxICON_ERROR
)
74 type
= GTK_MESSAGE_ERROR
;
75 else if (m_dialogStyle
& wxICON_INFORMATION
)
76 type
= GTK_MESSAGE_INFO
;
77 else if (m_dialogStyle
& wxICON_QUESTION
)
78 type
= GTK_MESSAGE_QUESTION
;
80 wxFAIL_MSG( _T("Unknown wxMessageDialog type") );
82 dlg
= gtk_message_dialog_new(m_parent
?
83 GTK_WINDOW(m_parent
->m_widget
) : NULL
,
86 "%s", (const char*)wxGTK_CONV(m_message
));
87 if (m_caption
!= wxMessageBoxCaptionStr
)
88 gtk_window_set_title(GTK_WINDOW(dlg
), wxGTK_CONV(m_caption
));
90 if (m_dialogStyle
& wxYES_NO
)
92 if (m_dialogStyle
& wxCANCEL
)
93 gtk_dialog_add_button(GTK_DIALOG(dlg
), GTK_STOCK_CANCEL
,
95 if (m_dialogStyle
& wxNO_DEFAULT
)
96 gtk_dialog_set_default_response(GTK_DIALOG(dlg
), GTK_RESPONSE_NO
);
98 gtk_dialog_set_default_response(GTK_DIALOG(dlg
), GTK_RESPONSE_YES
);
101 gint result
= gtk_dialog_run(GTK_DIALOG(dlg
));
102 gtk_widget_destroy(dlg
);
107 wxFAIL_MSG(_T("unexpected GtkMessageDialog return code"));
110 case GTK_RESPONSE_CANCEL
:
112 case GTK_RESPONSE_OK
:
114 case GTK_RESPONSE_YES
:
116 case GTK_RESPONSE_NO
:
121 #endif // wxUSE_MSGDLG && defined(__WXGTK20__)