Debian Codegraph @

src/tools/dlgedit/gui_tree.h

raw
1 /*
2 Copyright (C) 2002/2003 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_tree.h
21 *
22 * @author Kai Sterker
23 * @brief View for the dialogue structure
24 */
25
26 #ifndef GUI_TREE_H
27 #define GUI_TREE_H
28
29 #include "dlg_module.h"
30
31 /**
32 * The %GuiTree displays the structure of a dialogue. Its root
33 * is the top-level dialogue, its children are the various
34 * sub-dialogues.
35 *
36 * The current selection of the tree will always match the
37 * dialogue currently displayed by the graph view. Clicking on
38 * an entry will have the same effect as clicking on a
39 * sub-dialogue node the graph view, i.e. switch to that
40 * module.
41 */
42 class GuiTree
43 {
44 public:
45 /**
46 * Speaking names for node icons,
47 */
48 enum {
49 BUBBLE = 0,
50 BUBBLE_SEL = 1,
51 BUBBLE_MOD = 2,
52 BUBBLE_SEL_MOD = 3,
53 PROJECT = 4,
54 MAX_ICONS = 5
55 };
56
57 /**
58 * Constructor. Creates the tree widget and adds it to the
59 * given pane.
60 * @param paned The GtkPaned that will hold the tree widget.
61 */
62 GuiTree (GtkWidget* paned);
63 /**
64 * Standard desctructor.
65 */
66 ~GuiTree ();
67
68 /**
69 * Displays the given module in the tree. In case the module
70 * is no top-level dialogue, this method will search backwards
71 * through the list of parents until it finds the top-level
72 * dialogue. It will then display the structure of this dialogue.
73 *
74 * @param module A module whose structure should be displayed.
75 */
76 void addModule (DlgModule *module);
77 /**
78 * Refresh the given module. This will remove the module sub-tree
79 * and generate it anew. To be called after reverting to saved.
80 *
81 * @param module The module to refresh.
82 */
83 void updateModule (DlgModule *module);
84 /**
85 * Attach the given module to a new project. To be called after
86 * changine the project the module belongs to.
87 *
88 * @param module The module to move to new project.
89 */
90 void updateProject (DlgModule *module);
91 /**
92 * Remove a module sub-tree. To be called when a module is closed
93 * or a sub-module is deleted.
94 *
95 * @param The module to remove.
96 */
97 void removeModule (DlgModule *module);
98
99 /**
100 * Add available projects to the tree.
101 */
102 void addProjects ();
103
104 /**
105 * Empty the widget.
106 */
107 void clear ();
108
109 /**
110 * Update the state (saved/modified) of the module's icon.
111 * @param module Module whose state (and icon) to update
112 */
113 void setChanged (DlgModule *module);
114 /**
115 * Update the name of the given module.
116 * @param module Module whose name should be updated.
117 */
118 void setName (DlgModule *module);
119
120 /**
121 * Insert a module into the tree, as child of the given parent.
122 * @param parent The parent of the module to add.
123 * @param module The module to add.
124 */
125 void insert (DlgModule *parent, DlgModule *module);
126
127 /**
128 * Select the given node of the tree. If another node is selected,
129 * it will be deselected first.
130 * @param node The node to be selected.
131 */
132 void select (GtkTreeIter *node);
133 /**
134 * Select the given module in the tree. If a node is currently
135 * selected, it will be deselected first.
136 * @param module The module to select.
137 */
138 void select (DlgModule *module);
139 /**
140 * Deselect the given module in the tree.
141 * @param module The module to deselect.
142 */
143 void unselect (DlgModule *module);
144
145 private:
146 /**
147 * Build the initial module tree, by descending recursively
148 * into the module's sub-dialogues, sub-sub-dialogues, and so on.
149 * @param root The root of the (sub-)tree to be build.
150 */
151 void build (GtkTreeIter root);
152 /**
153 * Insert a module into the tree, as child of the given parent.
154 * @param parent The parent of the module to add.
155 * @param module The module to add.
156 * @return The node that has been added.
157 */
158 GtkTreeIter insert (GtkTreeIter parent, DlgModule *module);
159 /**
160 * Set the icon of the given node to the appropriate state.
161 * @param node Node whose icon to change.
162 * @param select Whether to use the selected or normal icon.
163 * @param changed Whether the given node is saved or modified.
164 */
165 void setIcon (GtkTreeIter node, bool select, bool changed);
166 /**
167 * Find the node associated with the given module.
168 * @param module DlgModule whose node to retrieve.
169 * @param node iterator set to the node associated with the module
170 * @return true if node associated with the module was found, false otherwise.
171 */
172 bool locate (DlgModule *module, GtkTreeIter *node);
173 /**
174 * Find the node associated with the given project. If no such node
175 * exists, it will be created.
176 * @param project Name of the project
177 * @return Node associated with project
178 */
179 GtkTreeIter locateProject (const std::string &project);
180
181 GtkWidget *tree; // The actual GTK+ tree widget
182
183 // Icons to display next to tree nodes
184 GdkPixbuf *icon[MAX_ICONS];
185 };
186
187 #endif // GUI_TREE_H