~ubuntu-branches/ubuntu/precise/ipe/precise

« back to all changes in this revision

Viewing changes to src/ipe/tools.h

  • Committer: Bazaar Package Importer
  • Author(s): Steve M. Robbins
  • Date: 2009-12-11 21:22:35 UTC
  • mfrom: (4.1.6 sid)
  • Revision ID: james.westby@ubuntu.com-20091211212235-5iio4nzpra64snab
Tags: 7.0.10-1
* New upstream.  Closes: #551192.
  - New build-depends: libcairo2-dev, liblua5.1-0-dev, gsfonts
  - patches/config.diff: Remove.  Upstream build system replaced.
  - Runtime lib package changed to libipe7.0.10 from libipe1c2a
  - Devel package renamed to libipe-dev (from libipe1-dev)
  - Package ipe depends on lua5.1 due to ipe-update-master.

* rules: Re-write to use dh.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
// -*- C++ -*-
 
2
// --------------------------------------------------------------------
 
3
// Canvas tools
 
4
// --------------------------------------------------------------------
 
5
/*
 
6
 
 
7
    This file is part of the extensible drawing editor Ipe.
 
8
    Copyright (C) 1993-2009  Otfried Cheong
 
9
 
 
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 3 of the License, or
 
13
    (at your option) any later version.
 
14
 
 
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.
 
19
 
 
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.
 
24
 
 
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.
 
29
 
 
30
*/
 
31
 
 
32
#ifndef TOOLS_H
 
33
#define TOOLS_H
 
34
 
 
35
#include "ipetool.h"
 
36
 
 
37
// avoid including Lua headers here
 
38
typedef struct lua_State lua_State;
 
39
 
 
40
// --------------------------------------------------------------------
 
41
 
 
42
using namespace ipe;
 
43
using namespace ipeqt;
 
44
 
 
45
extern void push_button(lua_State *L, int button);
 
46
 
 
47
class IpeTransformTool : public TransformTool {
 
48
public:
 
49
  IpeTransformTool(Canvas *canvas, Page *page, int view, TType type,
 
50
                   bool withShift, lua_State *L0, int method);
 
51
  ~IpeTransformTool();
 
52
  virtual void report();
 
53
private:
 
54
  lua_State *L;
 
55
  int iMethod;
 
56
};
 
57
 
 
58
class LuaTool  : public Tool {
 
59
public:
 
60
  LuaTool(Canvas *canvas, lua_State *L0, int luatool);
 
61
  ~LuaTool();
 
62
 
 
63
  void setColor(Color color) { iColor = color; }
 
64
 
 
65
  virtual void mouseButton(int button, bool press);
 
66
  virtual void mouseMove(int button);
 
67
  virtual bool key(int code, int modifiers, String text);
 
68
protected:
 
69
  lua_State *L;
 
70
  int iLuaTool;
 
71
  Color iColor;
 
72
};
 
73
 
 
74
class ShapeTool : public LuaTool {
 
75
public:
 
76
  enum TMarkType { EVertex = 1, ESplineCP, EBezierCP, ECenter,
 
77
                   ERadius, EMinor, ECurrent, EScissor,
 
78
                   ENumMarkTypes };
 
79
 
 
80
  ShapeTool(Canvas *canvas, lua_State *L0, int luatool);
 
81
 
 
82
  void setShape(Shape shape, int which = 0);
 
83
  void clearMarks();
 
84
  void addMark(const Vector &v, TMarkType t);
 
85
 
 
86
  virtual void draw(Painter &painter) const;
 
87
private:
 
88
  Shape iShape;
 
89
  Shape iAuxShape;
 
90
  struct SMark {
 
91
    Vector v;
 
92
    TMarkType t;
 
93
  };
 
94
  std::vector<SMark> iMarks;
 
95
};
 
96
 
 
97
class PasteTool : public LuaTool {
 
98
public:
 
99
  PasteTool(Canvas *canvas, lua_State *L0, int luatool, Object *obj);
 
100
  ~PasteTool();
 
101
 
 
102
  void setMatrix(Matrix m) { iMatrix = m; }
 
103
 
 
104
  virtual void draw(Painter &painter) const;
 
105
private:
 
106
  Object *iObject;
 
107
  Matrix iMatrix;
 
108
};
 
109
 
 
110
// --------------------------------------------------------------------
 
111
#endif