Debian Codegraph @

src/tools/dlgedit/dlg_mover.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_mover.h
21 *
22 * @author Kai Sterker
23 * @brief A dummy node for drag'n dropping DlgArrows.
24 */
25
26 #ifndef DLG_MOVER_H
27 #define DLG_MOVER_H
28
29 #include "dlg_arrow.h"
30
31
32 /**
33 * Arrows have to be connected to two nodes, so to drag them from one
34 * Circle to another, they have to be connected to an (invisble) mover.
35 */
36 class DlgMover : public DlgNode
37 {
38 public:
39 /**
40 * Creates a new mover at the given position.
41 * @param position The center of the new mover
42 */
43 DlgMover (DlgPoint &position);
44
45 /**
46 * Attach an arrow to this mover. The method checks whether either
47 * the tip or the tail of the arrow overlap the mover and so decides
48 * how the arrow is dragged.
49 * @param arrow a DlgArrow to be dragged.
50 * @return <b>true</b> if the mover is close enough to the arrows end,
51 * <b>false</b> otherwise.
52 */
53 bool attach (DlgArrow *arrow);
54
55 /**
56 * Drop the mover onto the given node. Connects the arrow we are
57 * moving to the node, if possible.
58 * @param node A DlgNode or <b>NULL</b> if there is no node at the
59 * cursor position.
60 */
61 void drop (DlgNode *node);
62
63 private:
64 int moving; // is arrow dragged by it's tip or tail?
65 DlgNode *oldCircle; // the node the arrow was attached to before
66
67 enum { NONE, TIP, TAIL };
68 };
69
70 #endif // DLG_MOVER_H