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
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
|
/**
This file is part of Kig, a KDE program for Interactive Geometry...
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_POPUP_H
#define KIG_MODES_POPUP_H
#include <tdepopupmenu.h>
#include <vector>
class KigDocument;
class KigPart;
class KigWidget;
class NormalMode;
class PopupActionProvider;
class ObjectHolder;
/**
* This is the popup menu that appears when you click on selected
* objects in NormalMode.. It's quite complex, since it has to fetch
* a lot of information from various places, and dispatch it again
* when the user selects something.
* Update: I'm also using it for when you clicked on an empty space in
* the document, because the difference between the two cases is not
* that important, and this class is generic enough to handle both
* cases.. When this is the case, mobjs is empty, some
* PopupActionProviders are disabled, and some others enabled..
*/
class NormalModePopupObjects
: public TDEPopupMenu
{
TQ_OBJECT
public:
NormalModePopupObjects( KigPart& part, KigWidget& view,
NormalMode& mode,
const std::vector<ObjectHolder*>& objs, const TQPoint& p );
~NormalModePopupObjects();
// the different "menu's", the toplevel is considered as just
// another menu..
enum { TransformMenu = 0, TestMenu, ConstructMenu, StartMenu, ShowMenu,
SetColorMenu, SetSizeMenu, SetStyleMenu, ToplevelMenu,
SetCoordinateSystemMenu, NumberOfMenus };
// used by the PopupActionProvider's to add actions to us..
void addAction( int menu, const TQString& name, int id );
void addAction( int menu, const TQPixmap& icon, const TQString& name, int id );
void addAction( int menu, const TQPixmap& pix, int id );
/**
* set the checked state of the \p n 'th item in \p menu to \p checked ..
*/
void setChecked( int menu, int n, bool checked );
std::vector<ObjectHolder*> objects() const { return mobjs; }
KigPart& part() { return mpart; }
KigWidget& widget() { return mview; }
TQPoint plc() { return mplc; }
bool onlyLabels() const { return monlylabels; }
protected:
void activateAction( int menu, int action );
private slots:
void transformMenuSlot( int );
void testMenuSlot( int );
void constructMenuSlot( int );
void startMenuSlot( int );
void showMenuSlot( int );
void setColorMenuSlot( int );
void setSizeMenuSlot( int );
void setStyleMenuSlot( int );
void toplevelMenuSlot( int );
void setCoordinateSystemMenuSlot( int );
protected:
TQPoint mplc;
KigPart& mpart;
KigWidget& mview;
std::vector<ObjectHolder*> mobjs;
NormalMode& mmode;
std::vector<PopupActionProvider*> mproviders;
TQPopupMenu* mmenus[NumberOfMenus];
private:
bool monlylabels;
};
/**
* This class is useful to choose one object from a list of some, by
* querying the user via popup menu.
*
* You can't use this class directly, but these's a convenience method.
*/
class ObjectChooserPopup
: public TDEPopupMenu
{
TQ_OBJECT
public:
/**
* Get the index of the choosen object from a list of objects.
*
* \param p is the point whene executre the popup
* \param w is the pointer to a KigWidget
* \param objs is the vector with the objects to chose from
* \param givepopup true means that we have to show a popup to the user
*
* \return the index of the chosen element ( starting from 0 ), or -1
* if none was selected.
*/
static int getObjectFromList( const TQPoint& p, KigWidget* w,
const std::vector<ObjectHolder*>& objs,
bool givepopup = true );
protected:
ObjectChooserPopup( const TQPoint& p, KigWidget& view,
const std::vector<ObjectHolder*>& objs );
~ObjectChooserPopup();
protected slots:
void actionActivatedSlot( int );
protected:
TQPoint mplc;
KigWidget& mview;
std::vector<ObjectHolder*> mobjs;
int mselected;
};
#endif
|