kspread

selection.h
1/* This file is part of the KDE project
2 Copyright (C) 1998, 1999 Torben Weis <weis@kde.org>
3 Copyright (C) 2005-2006 Stefan Nikolaus <stefan.nikolaus@kdemail.net>
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 KSPREAD_SELECTION
22#define KSPREAD_SELECTION
23
24#include <tqobject.h>
25
26#include <kdebug.h>
27
28#include "region.h"
29
30namespace KSpread
31{
32class View;
33
34class Selection : public TQObject, public Region
35{
36 TQ_OBJECT
37
38public:
39 Selection(View*);
40 Selection(const Selection&);
41 ~Selection();
42
46 void initialize(const TQPoint&, Sheet* sheet = 0);
50 void initialize(const TQRect&, Sheet* sheet = 0);
54 void initialize(const Region&, Sheet* sheet = 0);
55
59 void update();
63 void update(const TQPoint&);
64
68 void extend(const TQPoint&, Sheet* sheet = 0);
72 void extend(const TQRect&, Sheet* sheet = 0);
76 void extend(const Region&);
77
82 virtual Element* eor(const TQPoint& point, Sheet* sheet = 0);
83
87 const TQPoint& anchor() const;
91 const TQPoint& cursor() const;
95 const TQPoint& marker() const;
96
100 bool isSingular() const;
104 TQRect selectionHandleArea() const;
105
109 TQString name(Sheet* originSheet = 0) const;
110
115 void setSheet(Sheet* sheet);
119 Sheet* sheet() const;
120
124 void setActiveElement(const TQPoint& point);
128 void setActiveElement(uint number);
132 Element* activeElement() const;
137 void setActiveSubRegion(uint start, uint length);
141 TQString activeSubRegionName() const;
145 void clearSubRegion();
149 void fixSubRegionDimension();
153 virtual void clear();
154
155
159 void setMultipleSelection(bool state);
160
161 TQRect lastRange(bool extend = true) const;
162 TQRect extendToMergedAreas(TQRect area) const;
163
164 const TQValueList<TQColor>& colors() const;
165
166 // TODO Stefan #2: replace this
167 TQRect selection(bool extend = true) const;
168
169signals:
170 void changed(const Region&);
171
172protected:
173 class Point;
174 class Range;
175
176 virtual Region::Point* createPoint(const TQPoint&) const;
177 virtual Region::Point* createPoint(const TQString&) const;
178 virtual Region::Point* createPoint(const Point&) const;
179 virtual Region::Range* createRange(const TQRect&) const;
180 virtual Region::Range* createRange(const TQString&) const;
181 virtual Region::Range* createRange(const Range&) const;
182
183private:
184 class Private;
185 Private *d;
186};
187
188/***************************************************************************
189 class Selection::Point
190****************************************************************************/
191
192class Selection::Point : public Region::Point
193{
194public:
195 Point(const TQPoint& point);
196 Point(const TQString& string);
197
198 void setColor(const TQColor& color) { m_color = color; }
199 virtual const TQColor& color() const { return m_color; }
200
201 bool columnFixed() const { return m_columnFixed; }
202 bool rowFixed() const { return m_rowFixed; }
203
204protected:
205
206private:
207 TQColor m_color;
208 bool m_columnFixed : 1;
209 bool m_rowFixed : 1;
210};
211
212/***************************************************************************
213 class Selection::Range
214****************************************************************************/
215
216class Selection::Range : public Region::Range
217{
218public:
219 Range(const TQRect& rect);
220 Range(const TQString& string);
221
222 virtual bool isColorizable() const { return true; }
223
224 void setColor(const TQColor& color) { m_color = color; }
225 const TQColor& color() const { return m_color; }
226
227protected:
228
229private:
230 TQColor m_color;
231 bool m_leftFixed : 1;
232 bool m_rightFixed : 1;
233 bool m_topFixed : 1;
234 bool m_bottomFixed : 1;
235};
236
237} // namespace KSpread
238
239
240/***************************************************************************
241 kdDebug support
242****************************************************************************/
243
244inline kdbgstream operator<<( kdbgstream str, const KSpread::Selection& s )
245{
246 str << "Selection = " << s.name();
247 return str;
248}
249
250inline kndbgstream operator<<( kndbgstream str, const KSpread::Selection& )
251{
252 return str;
253}
254
255#endif // KSPREAD_SELECTION
Region()
Constructor.
Definition region.cpp:54
The KSpread namespace.
Definition commands.h:39