1
// --------------------------------------------------------------------
2
// Ipelet for moving objekts in small steps,
3
// best used with shortcuts
4
// --------------------------------------------------------------------
7
This file is part of the extensible drawing editor Ipe.
8
Copyright (C) 1993-2007 Otfried Cheong
10
Ipe is free software; you can redistribute it and/or modify it
11
under the terms of the GNU General Public License as published by
12
the Free Software Foundation; either version 2 of the License, or
13
(at your option) any later version.
15
As a special exception, you have permission to link Ipe with the
16
CGAL library and distribute executables, as long as you follow the
17
requirements of the Gnu General Public License in regard to all of
18
the software in the executable aside from CGAL.
20
Ipe is distributed in the hope that it will be useful, but WITHOUT
21
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
22
or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
23
License for more details.
25
You should have received a copy of the GNU General Public License
26
along with Ipe; if not, you can find it at
27
"http://www.gnu.org/copyleft/gpl.html", or write to the Free
28
Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
34
// --------------------------------------------------------------------
36
static const char *aboutText = "Written by Gunter Schenck";
38
class MoveIpelet : public Ipelet {
40
virtual int IpelibVersion() const { return IPELIB_VERSION; }
41
virtual int NumFunctions() const { return 24; }
42
virtual const char *Label() const { return "Move"; }
43
virtual const char *SubLabel(int function) const;
44
virtual void Run(int function, IpePage *page, IpeletHelper *helper);
45
virtual const char *About() const { return aboutText; }
48
// --------------------------------------------------------------------
50
const char * const sublabel[] = {
77
const char *MoveIpelet::SubLabel(int function) const
79
return sublabel[function];
82
// --------------------------------------------------------------------
84
const double dpmm = 72.0 / 25.4;
86
// --------------------------------------------------------------------
88
void MoveIpelet::Run(int function, IpePage *page, IpeletHelper *helper)
90
if (!page->HasSelection()) {
91
helper->Message("Nothing selected");
100
v = IpeVector( 1, 0 );
103
v = IpeVector( -1, 0 );
106
v = IpeVector( 0, 1 );
109
v = IpeVector( 0, -1 );
111
case 4: // right-up 1pt
112
v = IpeVector( 1, 1 );
115
v = IpeVector( -1, 1 );
118
v = IpeVector( 1, -1 );
121
v = IpeVector( -1, -1 );
125
v = IpeVector( .1, 0 );
128
v = IpeVector( -.1, 0 );
131
v = IpeVector( 0, .1 );
134
v = IpeVector( 0, -.1 );
136
case 12: // right-up 1pt
137
v = IpeVector( .1, .1 );
140
v = IpeVector( -.1, .1 );
142
case 14: //right-down
143
v = IpeVector( .1, -.1 );
146
v = IpeVector( -.1, -.1 );
150
v = IpeVector( 10, 0 );
153
v = IpeVector( -10, 0 );
156
v = IpeVector( 0, 10 );
159
v = IpeVector( 0, -10 );
161
case 20: // right-up 1pt
162
v = IpeVector( 10, 10 );
165
v = IpeVector( -10, 10 );
167
case 22: //right-down
168
v = IpeVector( 10, -10 );
171
v = IpeVector( -10, -10 );
176
for (IpePage::iterator it = page->begin(); it != page->end(); ++it) {
178
it->Transform(IpeMatrix(v));
182
// --------------------------------------------------------------------
184
IPELET_DECLARE Ipelet *NewIpelet()
186
return new MoveIpelet;
189
// --------------------------------------------------------------------