Debian Codegraph @

src/tools/dlgedit/gui_modal_dialog.h

raw
1 /*
2 Copyright (C) 2002/2004 Kai Sterker <[email protected]>
3 Part of the Adonthell Project <http://adonthell.nongnu.org>
4
5 Dlgedit is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2 of the License, or
8 (at your option) any later version.
9
10 Dlgedit is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
14
15 You should have received a copy of the GNU General Public License
16 along with Dlgedit. If not, see <http://www.gnu.org/licenses/>.
17 */
18
19 /**
20 * @file gui_modal_dialog.h
21 *
22 * @author Kai Sterker
23 * @brief Base class for modal dialog windows
24 */
25
26 #ifndef GUI_MODAL_DIALOG_H
27 #define GUI_MODAL_DIALOG_H
28
29 #include <gtk/gtk.h>
30
31 /**
32 * Encapsulates the most basic functionality a modal/transient dialog window needs.
33 */
34 class GuiModalDialog
35 {
36 public:
37 /**
38 * Initialize the dialog window.
39 * @param p parent of the dialog.
40 * @param m whether the dialog is model or just transient.
41 */
42 GuiModalDialog (GtkWindow *p, const bool & m = true);
43
44 /*
45 * Destroy the dialog window.
46 */
47 virtual ~GuiModalDialog ();
48
49 /**
50 * Displays the dialog window and sets it transient for the dlgedit main window.
51 * @return the state of pressedOK. This should be set to <b>true</b> if the dialog
52 * was closed via the OK button. By default it is <b>false</b>.
53 */
54 virtual bool run ();
55 /**
56 * Indicate whether the OK button of the dialog has been pressed.
57 * @param button Set this to <b>true</b> if the OK button has been pressed,
58 * otherwise to <b>false</b>
59 */
60 void okButtonPressed (bool button) { pressedOK = button; }
61 /**
62 * Get the dialog window.
63 * @return the dialog window.
64 */
65 GtkWidget *getWindow () { return window; }
66
67 protected:
68 /// whether the Cancel or OK button has been pushed
69 bool pressedOK;
70 /// whether the dialog is truly modal or merely transient
71 bool modal;
72 /// the dialog window
73 GtkWidget *window;
74 /// parent of the dialog.
75 GtkWindow *parent;
76 };
77
78 #endif // GUI_MODAL_DIALOG_H