karbon

vselection.h
1/* This file is part of the KDE project
2 Copyright (C) 2001, The Karbon Developers
3 Copyright (C) 2002, The Karbon Developers
4
5 This library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Library General Public
7 License as published by the Free Software Foundation; either
8 version 2 of the License, or (at your option) any later version.
9
10 This library 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 GNU
13 Library General Public License for more details.
14
15 You should have received a copy of the GNU Library General Public License
16 along with this library; see the file COPYING.LIB. If not, write to
17 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
18 * Boston, MA 02110-1301, USA.
19*/
20
21#ifndef __VSELECTION_H__
22#define __VSELECTION_H__
23
24
25#include <tqptrlist.h>
26
27#include <KoRect.h>
28
29#include "vobject.h"
30#include "vvisitor.h"
31#include <koffice_export.h>
32class KoPoint;
33class TQObject;
34class VPainter;
35class VVisitor;
36class VSegment;
37
38typedef TQPtrList<VObject> VObjectList;
39typedef TQPtrListIterator<VObject> VObjectListIterator;
40
41
43enum VHandleNode
44{
45 node_none = 0,
46 node_lt = 1,
47 node_mt = 2,
48 node_rt = 3,
49 node_lm = 4,
50 node_mm = 5,
51 node_rm = 6,
52 node_lb = 7,
53 node_mb = 8,
54 node_rb = 9
55};
56
57
61class KARBONBASE_EXPORT VSelection : public VObject, public VVisitor
62{
63public:
69 VSelection( VObject* parent = 0L );
70
76 VSelection( const VSelection& selection );
77
81 virtual ~VSelection();
82
86 void draw( VPainter* painter, double zoomFactor ) const;
87
88 virtual const KoRect& boundingBox() const;
89
90 virtual VSelection* clone() const;
91
92 virtual void accept( VVisitor& visitor );
93
97 void append();
98
102 void append( VObject* object );
103
109 void append( const VObjectList &objects );
110
115 bool append( const KoRect& rect, bool selectObjects = true, bool exclusive = true );
116
120 void take( VObject& object );
121
126 bool take( const KoRect& rect, bool selectObjects = true, bool exclusive = true );
127
131 void clear();
132
136 const VObjectList& objects() const { return m_objects; }
137
144 TQPtrList<VSegment> getSegments( const KoRect& rect );
145
151 void selectNodes( bool select = true );
152
159 VHandleNode handleNode( const KoPoint &point ) const;
160
166 void showHandle( bool handle = true ) { m_showhandle = handle; }
167
173 virtual void setSelectObjects( bool selectObjects = true ) { m_selectObjects = selectObjects; }
174
175 static void setHandleSize( uint size )
176 { m_handleNodeSize = size; }
177
178 static uint handleSize()
179 { return m_handleNodeSize; }
180private:
184 bool m_showhandle;
185
189 bool m_selectObjects;
190
194 VObjectList m_objects;
195
200 KoRect *m_handleRect;
201
205 static uint m_handleNodeSize;
206};
207
208#endif
209
VObject(VObject *parent, VState state=edit)
Constructs a new object that is child of parent and has the given state.
Definition vobject.cpp:36
virtual VObject * clone() const =0
Create an exact copy of this object.
VObject * parent() const
Returns pointer to current parent object.
Definition vobject.h:147
virtual void accept(VVisitor &)
Accept a VVisitor.
Definition vobject.h:236
virtual const KoRect & boundingBox() const
Calculates the tightest bounding box around the object.
Definition vobject.h:111
virtual void draw(VPainter *painter, const KoRect *rect=0L) const
Draw the object to a painting device.
Definition vobject.h:100
A class representing lines and beziers.
Definition vsegment.h:43
const VObjectList & objects() const
Read only access to the selected objects.
Definition vselection.h:136
void append()
Adds all objects to the selection.
void clear()
Removes the references to all objects, not the objects themselves.
virtual void setSelectObjects(bool selectObjects=true)
Toggles selection of objects/nodes.
Definition vselection.h:173
void showHandle(bool handle=true)
Toggle selection handles on/off.
Definition vselection.h:166
VSelection(VObject *parent=0L)
Constructs a vselection with the specified parent.
void take(VObject &object)
Removes the reference to the object, not the object itself.
The abstract visitor class.
Definition vvisitor.h:51
VVisitor()
Constructs a new visitor class.
Definition vvisitor.h:56