Laxkit  0.0.7.1
rectinterface.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-2007,2010-2011 by Tom Lechner
22 //
23 #ifndef _LAX_RECTINTERFACE_H
24 #define _LAX_RECTINTERFACE_H
25 
26 
27 #include <lax/interfaces/aninterface.h>
28 #include <lax/interfaces/somedata.h>
29 #include <lax/interfaces/linestyle.h>
30 
31 namespace LaxInterfaces {
32 
33 // x+---->
34 //y 1 8 7
35 //+ 2 9 6
36 //| 3 4 5
37 //v
38 
39 //----------------------------- RectData ----------------------------------
40 #define RECT_ISSQUARE (1<<0)
41 #define RECT_OFF (1<<1)
42 #define RECT_DOTTED (1<<2)
43 #define RECT_SOLID (1<<3)
44 #define RECT_INVISIBLECENTER (1<<4)
45 #define RECT_CANTCREATE (1<<5)
46 #define RECT_AFFINE (1<<6)
47 #define RECT_ALLOW_SHEAR (1<<7)
48 #define RECT_NO_SHEAR
49 #define RECT_HIDE_CONTROLS (1<<8)
50 #define RECT_OBJECT_SHUNT (1<<9)
51 #define RECT_FLIP_AT_SIDES (1<<10)
52 #define RECT_FLIP_LINE (1<<11)
53 #define RECT_LINK_BALL (1<<12)
54 
55 class RectData : public SomeData
56 {
57  protected:
58 
59  public:
60  unsigned int style;
61  int griddivisions;
62  int centertype; // like rectinterface numbering, <1 means no center (center=p), >9 means stationary
63  flatpoint center,center2,shearpoint;
64  LineStyle *linestyle;
65  RectData();
66  RectData(flatpoint pp,double ww,double hh,int ct,unsigned int stle);
67  virtual ~RectData();
68  void centercenter();
69  const char *whattype() { return "RectData"; }
70 };
71 
72 
73 //----------------------------- RectInterface ----------------------------------
74 
75 enum RectInterfaceActions {
76  RIA_Decorations,
77  RIA_Normalize,
78  RIA_Rectify,
79  RIA_Constrain,
80  RIA_MoveCenter,
81  RIA_ExpandHandle,
82  RIA_ContractHandle,
83  RIA_FlipHorizontal,
84  RIA_FlipVertical,
85  RIA_ToggleFlipControls,
86  RIA_RotateCW,
87  RIA_RotateCCW,
88  RIA_MAX
89 };
90 
91 
92 class RectInterface : public anInterface
93 {
94  protected:
95  int lastpoint;
96  flatpoint createp,createx,createy;
97  flatpoint center1,center2,shearpoint,leftp;
98  flatpoint flip1,flip2;
99  double rotatestep;
100  int hover;
101  int mousetarget;
102  int shiftmode;
103  flatpoint hoverpoint;
104  double rw,rh;
105  flatpoint origin,xdir,ydir;
106  double xaxislen,yaxislen;
107  char dragmode;
108  virtual void syncToData();
109  virtual void syncFromData(int first);
110  virtual const char *hoverMessage(int p);
111  virtual void Flip(int type);
112  virtual void Rotate(double angle);
113 
115  virtual int PerformAction(int action);
116  virtual int GetMode();
117  public:
119  int extrapoints;
120  int griddivisions;
121  unsigned int style;
122  unsigned long controlcolor;
123  int creationstyle,createfrompoint,showdecs;
124  SomeData *somedata;
125  RectData *data;
126  RectInterface(int nid,Laxkit::Displayer *ndp);
127  virtual ~RectInterface();
128  virtual Laxkit::ShortcutHandler *GetShortcuts();
129  virtual Laxkit::MenuInfo *ContextMenu(int x,int y,int deviceid);
130  virtual const char *IconId() { return ""; }
131  virtual const char *Name();
132  virtual const char *whattype() { return "RectInterface"; }
133  virtual const char *whatdatatype() { return "RectData"; }
134  virtual anInterface *duplicate(anInterface *dup);
135  virtual int InterfaceOn();
136  virtual int InterfaceOff();
137  virtual int LBDown(int x,int y,unsigned int state,int count,const Laxkit::LaxMouse *d);
138  virtual int FakeLBDown(int x,int y,unsigned int state,int count,const Laxkit::LaxMouse *d);
139  virtual int LBUp(int x,int y,unsigned int state,const Laxkit::LaxMouse *d);
140  virtual int MouseMove(int x,int y,unsigned int state,const Laxkit::LaxMouse *d);
141  virtual int CharInput(unsigned int ch, const char *buffer,int len,unsigned int state,const Laxkit::LaxKeyboard *d);
142  virtual int KeyUp(unsigned int ch,unsigned int state,const Laxkit::LaxKeyboard *d);
143  virtual int Refresh();
144  virtual int DrawData(Laxkit::anObject *ndata,Laxkit::anObject *a1=NULL,Laxkit::anObject *a2=NULL,int info=0);
145  virtual int UseThis(Laxkit::anObject *newdata,unsigned int); // assumes not use local
146  virtual void Clear(SomeData *d=NULL);
147 
148  virtual int AlternateScan(flatpoint sp, flatpoint p, double xmag,double ymag, double onepix);
149  virtual int scan(int x,int y);
150  //virtual int SelectPoint(int c);
151  virtual void deletedata();
152  virtual flatpoint getpoint(int c,int trans);
153  virtual void GetOuterRect(Laxkit::DoubleBBox *box, double *mm);
154 };
155 
156 } // namespace LaxInterfaces
157 
158 #endif
159 

Mon Feb 17 2014 11:52:57, Laxkit