Laxkit  0.0.7.1
somedata.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-2012 by Tom Lechner
22 //
23 #ifndef _LAX_SOMEDATA_H
24 #define _LAX_SOMEDATA_H
25 
26 #include <lax/anobject.h>
27 #include <lax/doublebbox.h>
28 #include <lax/vectors.h>
29 #include <lax/lists.h>
30 #include <lax/attributes.h>
31 #include <lax/dump.h>
32 #include <lax/laximages.h>
33 #include <lax/transformmath.h>
34 
35 #include <cstdio>
36 #include <ctime>
37 
38 #ifndef NULL
39 #define NULL 0
40 #endif
41 
42 using namespace std;
43 
44 namespace LaxInterfaces {
45 
46 #define SOMEDATA_KEEP_ASPECT (1<<0)
47 #define SOMEDATA_KEEP_1_TO_1 (1<<1)
48 #define SOMEDATA_LOCK_SHEAR (1<<2)
49 #define SOMEDATA_LOCK_ROTATION (1<<3)
50 #define SOMEDATA_LOCK_SCALEX (1<<4)
51 #define SOMEDATA_LOCK_SCALEY (1<<5)
52 #define SOMEDATA_LOCK_POSITION (1<<6)
53  //only object tool can touch it
54 #define SOMEDATA_LOCK_CONTENTS (1<<7)
55  //child objects are not selectable
56 #define SOMEDATA_LOCK_KIDS (1<<8)
57 #define SOMEDATA_UNSELECTABLE (1<<9)
58 #define SOMEDATA_UNEDITABLE (1<<10)
59 
60 
61 
62 
63 class SomeData : virtual public Laxkit::anObject,
64  virtual public Laxkit::Affine,
65  virtual public Laxkit::DoubleBBox
66 {
67  protected:
68  public:
69  //preview mechanism
72 
73  std::time_t previewtime;
74  std::time_t modtime;
75  virtual void touchContents();
76 
77  virtual Laxkit::LaxImage *GetPreview();
78  virtual void GeneratePreview(int w,int h);
79  virtual int renderToBuffer(unsigned char *buffer, int bufw, int bufh, int bufstride, int bufdepth, int bufchannels);
80 
81  int bboxstyle; //useparent
82  flatpoint centerpoint; //used as a passive center by ObjectInterface
83  unsigned int flags;
84  int iid; // interface id
85 
86  char *nameid;
87  virtual const char *Id();
88  virtual const char *Id(const char *newid);
89 
90  SomeData();
91  SomeData(double nminx,double nmaxx,double nminy,double nmaxy);
92  virtual ~SomeData();
93  virtual const char *whattype() { return "SomeData"; }
94 
95  virtual void FindBBox() {}
96  virtual flatpoint BBoxPoint(double x,double y, bool transform_to_parent);
97  virtual flatpoint ReferencePoint(int which, bool transform_to_parent);
98  virtual SomeData *duplicate(SomeData *dup);
99  virtual int pointin(flatpoint pp,int pin=1); // return in=1 | on=2 | out=0, default is pointin bbox
100  virtual int fitto(double *boxm,DoubleBBox *box,double alignx,double aligny, int whentoscale=2);
101  virtual SomeData *GetParent() { return NULL; }
102 
103  virtual void dump_out(FILE *f,int indent,int what,Laxkit::anObject *context);
104  virtual void dump_in(FILE *f,int indent,Laxkit::anObject *context,LaxFiles::Attribute **Att=NULL);
105  virtual void dump_in_atts(LaxFiles::Attribute *att,int flag,Laxkit::anObject *context);
106  virtual LaxFiles::Attribute *dump_out_atts(LaxFiles::Attribute *att,int what,Laxkit::anObject *savecontext);
107 };
108 
109 
110 
111 
112 } // namespace LaxInterfaces
113 
114 #endif
115 

Mon Feb 17 2014 11:52:57, Laxkit