Laxkit  0.0.7.1
linesinterface.h
1 //
2 //
3 // The Laxkit, a windowing toolkit
4 // Please consult http://laxkit.sourceforge.net about where to send any
5 // correspondence about this software.
6 //
7 // This library is free software; you can redistribute it and/or
8 // modify it under the terms of the GNU Library General Public
9 // License as published by the Free Software Foundation; either
10 // version 2 of the License, or (at your option) any later version.
11 //
12 // This library is distributed in the hope that it will be useful,
13 // but WITHOUT ANY WARRANTY; without even the implied warranty of
14 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 // Library General Public License for more details.
16 //
17 // You should have received a copy of the GNU Library General Public
18 // License along with this library; if not, write to the Free Software
19 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 //
21 // Copyright (C) 2004-2006,2011 by Tom Lechner
22 //
23 #ifndef _LAX_LINESINTERFACE_H
24 #define _LAX_LINESINTERFACE_H
25 
26 #include <lax/interfaces/aninterface.h>
27 #include <lax/vectors.h>
28 #include <lax/interfaces/somedata.h>
29 #include <lax/interfaces/linestyle.h>
30 
31 #define LINESDATA_CLOSED 1
32 #define LINESDATA_LINES 2
33 #define LINESDATA_POLYGON 4
34 #define LINESDATA_SYMPOLY 8
35 
36  // most of these are for polygon creation, and where the corners point
37 #define LINESDATA_UP 16
38 #define LINESDATA_DOWN 32
39 #define LINESDATA_RIGHT 64
40 #define LINESDATA_LEFT 128
41 #define LINESDATA_PLUSHALF 256
42 #define LINESDATA_RECT 512
43 #define LINESDATA_MAXINBOX 1024
44 
45 namespace LaxInterfaces {
46 
47 class LinesData : public SomeData
48 {
49 // protected:
50 
51  public:
52  int numsides,numturns;
53  flatpoint *points;
54  int npoints;
55  unsigned int style;
56  LineStyle linestyle;
57  LinesData() { points=NULL; style=0; npoints=0; }
58  ~LinesData() { if (points) delete[] points; }
59  const char *whattype() { return "LinesData"; }
60  int AddAfter(int afterwhich,flatpoint p); //returns new curpoint
61  int Delete(int which);
62  void FindBBox();
63 };
64 
65 //--------------------
66 
68 {
69  protected:
70  int mx,my;
71  int curpoint;
72  int creating;
73  flatpoint createp,createx,createy;
74  double newa,newb;
75  void Setupcreation(int sides,int turns);
76  void movecontrol(int which,int x,int y);
77  void movecontrol(int which,flatpoint d);
78  public:
79  unsigned long controlcolor;
80  int creationstyle,creationsides,creationturns,creationgravity,showdecs;
81  double creationangle;
82  LinesData *data;
83  LineStyle linestyle;
84  LinesInterface(int nid,Laxkit::Displayer *ndp);
85  virtual ~LinesInterface() { deletedata(); }
86  virtual void deletedata();
87  virtual int scan(int x,int y);
88  virtual int LBDown(int x,int y,unsigned int state,int count);
89  virtual int LBUp(int x,int y,unsigned int state);
90  virtual int MouseMove(int x,int y,unsigned int state);
91  virtual int CharInput(unsigned int ch, const char *buffer,int len,unsigned int state);
92  virtual int CharRelease(unsigned int ch,unsigned int state);
93  virtual int Refresh();
94  virtual int UseThis(int id,int ndata);
95  virtual int UseThis(Laxkit::anObject *newdata,unsigned int mask=0);
96  virtual int toggleclosed(int c=-1);
97  virtual int InterfaceOn();
98  virtual int InterfaceOff();
99  virtual const char *whattype() { return "LinesInterface"; }
100  virtual const char *whatdatatype() { return "LinesData"; }
101 };
102 
103 } // namespace LaxInterfaces
104 
105 #endif
106 

Mon Feb 17 2014 11:52:57, Laxkit