Laxkit  0.0.7.1
pointwarpinterface.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) 2014 by Tom Lechner
22 //
23 #ifndef _LAX_PATCHINTERFACE_H
24 #define _LAX_PATCHINTERFACE_H
25 
26 #include <lax/interfaces/aninterface.h>
27 #include <lax/interfaces/somedata.h>
28 #include <lax/interfaces/linestyle.h>
29 #include <lax/screencolor.h>
30 
31 
32 
33 
34 namespace LaxInterfaces {
35 
36 
37 //------------------------------ PointWarpData ---------------------
38 
39 
41 {
42  double length, shrink, grow;
43  int from; //index into PointWarpData::points
44  int to;
45 };
46 
48 {
49  flatpoint p;
50  unsigned int flags; //if constant point, how constrained
51  int constraint; //id of a constraint, such as a path it must lie on, but free to move on path
52  NumStack<PointWarpLink> links;
53 
55  virtual ~PointWarpPoint();
56 };
57 
58 class PointWarpData : virtual public SomeData
59 {
60  protected:
61 
62  public:
63  int numx,numy;
64  PointWarpPoint *points;
65  LineStyle linestyle;
66  PathsData *outline;
67 
68  PointWarpData();
69  PointWarpData(double xx,double yy,double ww,double hh,int nx,int ny,unsigned int stle);
70  virtual ~PointWarpData();
71  virtual const char *whattype() { return "PointWarpData"; }
72  virtual SomeData *duplicate(SomeData *dup);
73  virtual void FindBBox();
74 
77  virtual void Set(double xx,double yy,double ww,double hh,int nx,int ny,unsigned int stle);
78  virtual void zap(flatpoint p,flatpoint x,flatpoint y);
79  virtual void zap(); // zap to bbox
80  virtual int subdivide(int r,double rt,int c,double ct);
81  virtual int subdivide(int xn=2,int yn=2);
83 
86  //rendering functions
87  virtual int renderToBuffer(unsigned char *buffer, int bufw, int bufh, int bufstride, int bufdepth, int bufchannels);
88 
89  virtual void dump_out(FILE *f,int indent,int what,Laxkit::anObject *context);
90  virtual void dump_in_atts(LaxFiles::Attribute *att,int flag,Laxkit::anObject *context);
92 };
93 
94 
95 
96 //------------------------------ PointWarpInterface ---------------------
97 
98 enum PointWarpInterfaceActions {
99  POINTWARPA_RenderMode,
100  POINTWARPA_RecurseInc,
101  POINTWARPA_RecurseDec,
102  POINTWARPA_Decorations,
103  POINTWARPA_MAX
104 };
105 
107 {
108  protected:
109 
111  virtual int PerformAction(int action);
112  public:
113  // these are the state:
114  LineStyle linestyle;
115  unsigned long rimcolor,handlecolor,gridcolor;
116  int xs,ys;
117  int xdiv,ydiv;
118  unsigned long controlcolor;
119  int showdecs;
120  char whichcontrols;
121  int recurse;
122  int rendermode;
123 
124  PointWarpData *data;
125  ObjectContext *poc;
126 
128  virtual ~PointWarpInterface();
129  virtual Laxkit::ShortcutHandler *GetShortcuts();
130  virtual const char *IconId() { return "PointWarp"; }
131  virtual const char *Name();
132  virtual const char *whattype() { return "PointWarpInterface"; }
133  virtual const char *whatdatatype() { return "PointWarpData"; }
134  virtual anInterface *duplicate(anInterface *dup);
135  virtual int UseThisObject(ObjectContext *oc);
136  virtual int UseThis(Laxkit::anObject *newdata,unsigned int mask=0);
137  virtual int UseThis(int id,int ndata);
138  virtual void Clear(SomeData *d=NULL);
139  virtual int InterfaceOn();
140  virtual int InterfaceOff();
141  virtual ObjectContext *Context() { return poc; }
142  virtual int LBDown(int x,int y,unsigned int state,int count,const Laxkit::LaxMouse *d);
143  virtual int LBUp(int x,int y,unsigned int state,const Laxkit::LaxMouse *d);
144  virtual int MouseMove(int x,int y,unsigned int state,const Laxkit::LaxMouse *d);
145  virtual int CharInput(unsigned int ch, const char *buffer,int len,unsigned int state,const Laxkit::LaxKeyboard *d);
146  virtual int KeyUp(unsigned int ch,unsigned int state,const Laxkit::LaxKeyboard *d);
147 
148  virtual void drawpatch(int roff,int coff);
149  virtual void drawpatches();
150  virtual int Refresh();
151  virtual int DrawData(Laxkit::anObject *ndata,Laxkit::anObject *a1=NULL,Laxkit::anObject *a2=NULL,int info=0);
152 
153  virtual PointWarpData *newPointWarpData(double xx,double yy,double ww,double hh,int nr,int nc,unsigned int stle);
154  virtual void deletedata();
155  virtual int scan(int x,int y);
156  virtual int SelectPoint(int c,unsigned int state);
157 };
158 
159 } // namespace LaxInterfaces;
160 
161 #endif
162 

Mon Feb 17 2014 11:52:57, Laxkit