Laxkit  0.0.7.1
viewportwindow.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-2011 by Tom Lechner
22 //
23 #ifndef _LAX_VIEWPORTWINDOW_H
24 #define _LAX_VIEWPORTWINDOW_H
25 
26 #include <lax/anxapp.h>
27 #include <lax/interfaces/aninterface.h>
28 #include <lax/interfaces/viewportwindow.h>
29 #include <lax/rulerwin.h>
30 #include <lax/scroller.h>
31 #include <lax/panuser.h>
32 #include <lax/shortcuts.h>
33 #include <lax/buttondowninfo.h>
34 
35 
36 namespace LaxInterfaces {
37 
38 class anInterface; //forward declaration
39 
40 #define VIEWPORT_NO_XSCROLLER (1<<16)
41 #define VIEWPORT_NO_YSCROLLER (1<<17)
42 #define VIEWPORT_NO_SCROLLERS ((1<<16)|(1<<17))
43 #define VIEWPORT_NO_XRULER (1<<18)
44 #define VIEWPORT_NO_YRULER (1<<19)
45 #define VIEWPORT_NO_RULERS ((1<<18)|(1<<19))
46 #define VIEWPORT_ROTATABLE (1<<20)
47 #define VIEWPORT_BACK_BUFFER (1<<21)
48 #define VIEWPORT_RIGHT_HANDED (1<<22)
49 #define VIEWPORT_STYLE_MASK (0xffff0000)
50 
51 //---------------------------- ObjectContext -----------------------
53 {
54  public:
55  int i;
56  SomeData *obj;
57  ObjectContext();
58  ObjectContext(int ii, SomeData *o);
59  virtual ~ObjectContext();
60  virtual int isequal(const ObjectContext *oc) { return i==i; }
61  virtual void SetObject(SomeData *o);
62  virtual void set(int ii, SomeData *o);
63  virtual void clear();
64  virtual ObjectContext *duplicate();
65 };
66 
67 //---------------------------- ViewportWindow ----------------------
68 enum ViewportWindowActions {
69  VIEWPORT_ZoomIn=1,
70  VIEWPORT_ZoomOut,
71  VIEWPORT_CenterReal,
72  VIEWPORT_ResetView,
73  VIEWPORT_NextObject,
74  VIEWPORT_PreviousObject,
75  VIEWPORT_DeleteObj,
76 
77  VIEWPORT_ShiftLeft,
78  VIEWPORT_ShiftRight,
79  VIEWPORT_ShiftUp,
80  VIEWPORT_ShiftDown,
81  VIEWPORT_IncShift,
82  VIEWPORT_DecShift,
83 
84  VIEWPORT_MAX
85 };
86 
88 {
89  protected:
90  int interfacemenu;
91  char firsttime;
92  double view_shift_amount;
93  int last_mouse;
94 
95  // Object searching utility:
96  int searchx,searchy;
97  const char *searchtype;
98 
99  Laxkit::ButtonDownInfo buttondown;
101  virtual int PerformAction(int action);
102 
103  Laxkit::RulerWindow *xruler,*yruler;
104  Laxkit::Scroller *xscroller,*yscroller;
105  virtual void syncrulers(int which=3);
106  virtual void syncWithDp();
107 
108  public:
111 
112  ViewportWindow(anXWindow *parnt,const char *nname,const char *ntitle,unsigned long nstyle,
113  int xx,int yy,int ww,int hh,int brder, Laxkit::Displayer *ndp=NULL);
114  virtual ~ViewportWindow();
115  virtual const char *whattype() { return "ViewportWindow"; }
116  virtual int init();
117  virtual Laxkit::ShortcutHandler *GetShortcuts();
118  virtual void Refresh();
119  virtual void RefreshUnder();
120  virtual void RefreshOver();
121  virtual int LBDown(int x,int y,unsigned int state,int count,const Laxkit::LaxMouse *d);
122  virtual int MBDown(int x,int y,unsigned int state,int count,const Laxkit::LaxMouse *d);
123  virtual int RBDown(int x,int y,unsigned int state,int count,const Laxkit::LaxMouse *d);
124  virtual int LBUp(int x,int y,unsigned int state,const Laxkit::LaxMouse *d);
125  virtual int MBUp(int x,int y,unsigned int state,const Laxkit::LaxMouse *d);
126  virtual int RBUp(int x,int y,unsigned int state,const Laxkit::LaxMouse *d);
127  virtual int WheelUp(int x,int y,unsigned int state,int count,const Laxkit::LaxMouse *d);
128  virtual int WheelDown(int x,int y,unsigned int state,int count,const Laxkit::LaxMouse *d);
129  virtual int MouseMove(int x,int y,unsigned int state,const Laxkit::LaxMouse *d);
130  virtual int KeyUp(unsigned int ch,unsigned int state,const Laxkit::LaxKeyboard *d);
131  virtual int CharInput(unsigned int ch, const char *buffer,int len,unsigned int state,const Laxkit::LaxKeyboard *d);
132  virtual int Needtodraw();
133  virtual void Needtodraw(int ntd) { needtodraw=ntd; }
134  virtual int Event(const Laxkit::EventData *e,const char *mes);
135  virtual int MoveResize(int nx,int ny,int nw,int nh);
136  virtual int Resize(int nw,int nh);
137 
140  virtual int SetSpace(double minx,double maxx,double miny, double maxy);
141  virtual int Push(anInterface*i,int where, int absorbcount);
142  virtual int HasInterface(int iid);
143  virtual anInterface *Pop(anInterface *i,char deletetoo=0);
144  virtual anInterface *PopId(int iid,char deletetoo=0);
145  virtual void postmessage(const char *mes);
146 
147  //Object context adding, deleting, and adjusting
148  virtual int NewData(SomeData *d, ObjectContext **oc_ret);
149  virtual int DeleteObject();
150  virtual ObjectContext *ObjectMoved(ObjectContext *oc, int modifyoc);
151  virtual int ChangeContext(int x,int y,ObjectContext **oc);
152  virtual int ChangeContext(ObjectContext *oc);
153  virtual int ChangeObject(ObjectContext *oc, int switchtool);
154  virtual double *transformToContext(double *m,ObjectContext *oc,int invert,int full);
155 
156  //Object searching and selecting
157  virtual int FindObject(int x,int y, const char *dtype,
158  SomeData *exclude, int start,ObjectContext **oc);
159  virtual int FindObjects(Laxkit::DoubleBBox *box, char real, char ascurobj,
160  SomeData ***data_ret, ObjectContext ***c_ret);
161  virtual int SelectObject(int i);
162 
163  // coordinate helper functions
164  virtual flatpoint realtoscreen(flatpoint r);
165  virtual flatpoint screentoreal(int x,int y);
166  virtual double Getmag(int c=0);
167  virtual double GetVMag(int x,int y);
168 };
169 
170 } // namespace LaxInterfaces
171 
172 #endif
173 

Mon Feb 17 2014 11:52:57, Laxkit