kplato

kptpertcanvas.h
1/* This file is part of the KDE project
2 Copyright (C) 2003 - 2004 Dag Andersen <danders@get2net.dk>
3
4 This library is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Library General Public
6 License as published by the Free Software Foundation;
7 version 2 of the License.
8
9 This library is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 Library General Public License for more details.
13
14 You should have received a copy of the GNU Library General Public License
15 along with this library; see the file COPYING.LIB. If not, write to
16 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
17 * Boston, MA 02110-1301, USA.
18*/
19
20#ifndef KPTPERTCANVAS_H
21#define KPTPERTCANVAS_H
22
23#include "kptnode.h"
24#include "kptproject.h"
25
26#include <tqcanvas.h>
27#include <tqmemarray.h>
28#include <tqptrdict.h>
29
30class TQTimer;
31class TQPainter;
32class TQPoint;
33class TQSize;
34
35namespace KPlato
36{
37
38class PertNodeItem;
39
40class PertCanvas : public TQCanvasView
41{
42 TQ_OBJECT
43
44
45public:
46 PertCanvas( TQWidget *parent );
47 virtual ~PertCanvas();
48
49 void draw(Project& project);
50 void clear();
51 TQSize canvasSize();
52
53 PertNodeItem *selectedItem();
54
55 int verticalGap() { return m_verticalGap; }
56 int horizontalGap() { return m_horizontalGap; }
57 TQSize itemSize() { return m_itemSize; }
58
59 void setColumn(int row, int col) { m_rows.at(row)[col] = true; }
60
61 void mapNode(PertNodeItem *item);
62 void mapChildNode(PertNodeItem *parentItem, PertNodeItem *childItem, Relation::Type type);
63
64 Node *selectedNode();
65
66protected:
67 void drawRelations();
68
69 void createChildItems(PertNodeItem *node);
70 PertNodeItem *createNodeItem(Node *node);
71
72 void contentsMousePressEvent ( TQMouseEvent * e );
73 void contentsMouseReleaseEvent ( TQMouseEvent * e );
74
75signals:
76 void rightButtonPressed(Node *node, const TQPoint & point);
77 void updateView(bool calculate);
78 void addRelation(Node *par, Node *child);
79 void modifyRelation(Relation *rel);
80
81
82private:
83 TQCanvas *m_canvas;
84
85 TQTimer *m_scrollTimer;
86 bool m_mousePressed;
87 bool m_printing;
88
89 int m_verticalGap;
90 int m_horizontalGap;
91 TQSize m_itemSize;
92
93 TQPtrDict<PertNodeItem> m_nodes;
94 TQPtrList<Relation> m_relations;
95
96 TQPtrList<TQMemArray<bool> > m_rows;
97
98#ifndef NDEBUG
99 void printDebug( int );
100#endif
101
102};
103
104} //KPlato namespace
105
106#endif