Debian Codegraph @

src/tools/dlgedit/dlg_node_gfx.h

raw
1 /*
2 Copyright (C) 2002 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 dlg_node_gfx.h
21 *
22 * @author Kai Sterker
23 * @brief Base class for a DlgNode's graphical representation.
24 */
25
26 #ifndef DLG_NODE_GFX_H
27 #define DLG_NODE_GFX_H
28
29 #include <gtk/gtk.h>
30 #include "dlg_rect.h"
31 #include "dlg_types.h"
32
33 /**
34 * This class provide the interface for the graphical representation of
35 * the node in the graph window. This includes functionality needed for
36 * the actual rendering of the node, as well as positional information
37 * (inherited from DlgRect).
38 */
39 class DlgNodeGfx : public DlgRect
40 {
41 public:
42 DlgNodeGfx () { }
43 DlgNodeGfx (DlgPoint &position);
44 virtual ~DlgNodeGfx () { }
45
46 /**
47 * Change the mode of a node.
48 * @param m the new mode.
49 */
50 void setMode (mode_type m) { mode_ = m; }
51
52 /**
53 * Get the current mode of a node.
54 * @return the node's mode.
55 */
56 mode_type mode () { return mode_; }
57
58 /**
59 * Blit a certain area of the graph widget to the screen
60 * @param widget the widget to update
61 * @param area the rectangular area to update.
62 */
63 void update (GtkWidget *widget, DlgRect &area);
64
65 /**
66 * Draw this node to the given surface with the specified offset.
67 * The node's current mode determines the color thw node is drawn with.
68 * @param surface the cairo_surface_t to draw to
69 * @param offset the DlgPoint to use as offset
70 * @param widget the GtkWidget to update after drawing
71 */
72 virtual void draw (cairo_surface_t *surface, DlgPoint &offset, GtkWidget *widget) = 0;
73
74 /**
75 * Draw this node to the given surface. During drawing, the mode is
76 * temporarily changed to the given mode.
77 * @param surface the cairo_surface_t to draw to
78 * @param offset the DlgPoint to use as offset
79 * @param widget the GtkWidget to update after drawing
80 * @param mode the new mode of the node
81 */
82 virtual void draw (cairo_surface_t *surface, DlgPoint &offset, GtkWidget *widget, mode_type mode) = 0;
83
84 /**
85 * Check whether the node is located at the given point.
86 * @return <b>true</b> if this is the case, <b>false</b> otherwise.
87 */
88 virtual bool operator== (DlgPoint &point) { return contains (point); }
89
90 protected:
91 mode_type mode_; // This nodes mode (NONE, HILIGHTED, SELECTED)
92 };
93
94 #endif // DLG_NODE_GFX_H