1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
|
// Copyright (C) 2002 Dominique Devriese <devriese@kde.org>
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License
// as published by the Free Software Foundation; either version 2
// of the License, or (at your option) any later version.
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
// 02110-1301, USA.
#ifndef KIG_MODES_DRAGRECTMODE_H
#define KIG_MODES_DRAGRECTMODE_H
#include "mode.h"
#include "../misc/rect.h"
#include <tqpoint.h>
#include <vector>
class ObjectHolder;
/**
* DragRectMode is a mode that provides a rect for selecting the
* objects inside it. Here's an example of how to use it
* \code
* DragRectMode d( e->pos(), document, widget );
* mDoc.runMode( &d );
* Objects sel = d.ret();
* \endcode
*/
class DragRectMode
: public KigMode
{
TQPoint mstart;
std::vector<ObjectHolder*> mret;
Rect mrect;
bool mnc;
bool mstartselected;
bool mcancelled;
private:
void clicked( const TQPoint& p, KigWidget& w );
void clicked( const TQMouseEvent* e, KigWidget& w );
void released( const TQPoint& p, KigWidget& w, bool nc );
void released( TQMouseEvent* e, KigWidget& w );
void moved( const TQPoint& p, KigWidget& w );
void moved( TQMouseEvent*, KigWidget& w );
void leftClicked( TQMouseEvent*, KigWidget* );
void leftMouseMoved( TQMouseEvent*, KigWidget* );
void leftReleased( TQMouseEvent*, KigWidget* );
void midClicked( TQMouseEvent*, KigWidget* );
void midMouseMoved( TQMouseEvent*, KigWidget* );
void midReleased( TQMouseEvent*, KigWidget* );
void rightClicked( TQMouseEvent*, KigWidget* );
void rightMouseMoved( TQMouseEvent*, KigWidget* );
void rightReleased( TQMouseEvent*, KigWidget* );
void mouseMoved( TQMouseEvent*, KigWidget* );
void cancelConstruction();
void enableActions();
public:
DragRectMode( const TQPoint& start, KigPart& d, KigWidget& w );
DragRectMode( KigPart& d, KigWidget& w );
~DragRectMode();
/**
* this returns the selected objects..
*/
std::vector<ObjectHolder*> ret() const;
/**
* this returns the selected rect..
*/
Rect rect() const;
/**
* this returns false if the control or shift button were pressed
* when the mouse button was released, and true otherwise. This is
* because the user expects us to not clear the selection before
* adding the newly selected objects if (s)he pressed control or
* shift..
*/
bool needClear() const;
/**
* whether the user cancelled the rect mode.. If this returns true,
* all the other return data above will be in undefined state, so
* first check this function's result..
*/
bool cancelled() const;
};
#endif
|