Laxkit  0.0.7.1
rulerwin.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_RULERWINDOW_H
24 #define _LAX_RULERWINDOW_H
25 
26 #include <lax/anxapp.h>
27 
28 namespace Laxkit {
29 
30 #define RULER_X (1<<16)
31 #define RULER_Y (1<<17)
32 #define RULER_TOPTICKS (1<<18)
33 #define RULER_LEFTTICKS (1<<18)
34 
35 #define RULER_BOTTOMTICKS (1<<19)
36 #define RULER_RIGHTTICKS (1<<19)
37 
38 #define RULER_CENTERTICKS (1<<20)
39 #define RULER_NONUMBERS (1<<21)
40 
41  // defaults standard :inches, base=12, metric=cm
42 #define RULER_STANDARD (1<<22)
43 #define RULER_METRIC (1<<23)
44 
45  // send message when button down, and mouse leaves ruler
46 #define RULER_SENDONLBD (1<<24)
47 #define RULER_SENDONMBD (1<<25)
48 #define RULER_SENDONRBD (1<<26)
49 
50 #define RULER_UP_IS_POSITIVE (1<<27)
51 
52 #define RULER_UNITS_MENU (1<<28)
53 
54  //sent in ruler messages when currentunits are changed
55 #define RULER_Units 1
56 
57 
58 class RulerWindow : public anXWindow
59 {
60  protected:
61  double start,end,mag,umag; // real*mag=screen
62  double tf,stf,sstf;
64  LaxFont *smallnumbers;
65  int baseunits, currentunits;
66  virtual void adjustmetrics();
67  virtual void drawtext(double n,int pos,int &textpos,int toff);
68 
69  virtual int NumberOfUnits();
70  virtual int UnitInfo(int index, const char **name, int *id, double *scale, int *sdiv, int *ssdiv);
71  public:
72  unsigned long bgcolor,numcolor,tickcolor,curposcolor,subtickcolor,subsubtickcolor;
73  double base,unit;
74  double curpos;
76 
77  RulerWindow(anXWindow *parnt,const char *nname,const char *ntitle,unsigned long nstyle,
78  int xx,int yy,int ww,int hh,int brder,
79  anXWindow *prev=NULL,unsigned long nowner=0,const char *nsend=NULL,
80  const char *base_units=NULL, int syncwithscreen=1);
81  virtual ~RulerWindow();
82  virtual int init();
83  virtual int Event(const EventData *e,const char *mes);
84  virtual void Refresh();
85  virtual int MoveResize(int nx,int ny,int nw,int nh);
86  virtual int Resize(int nw,int nh);
87  virtual int MouseMove (int x,int y,unsigned int state, const LaxMouse *m);
88  virtual int LBDown(int x,int y,unsigned int state,int count,const LaxMouse *d);
89  virtual int RBDown(int x,int y,unsigned int state,int count,const LaxMouse *d);
90  virtual int RBUp(int x,int y,unsigned int state,const LaxMouse *d);
91 
92  virtual int SetBaseUnits(const char *units);
93  virtual int SetBaseUnits(int units);
94  virtual int SetCurrentUnits(const char *units);
95  virtual int SetCurrentUnits(int units);
96  virtual int SetDivisions(int sdiv, int ssdiv);
97 
98  virtual void TrackThisWindow(anXWindow *win);
99  virtual void Track();
100  virtual void SetPos(double crpos);
101  virtual void SetPosFromScreen(int p);
102  virtual void SetPosFromScreenCoord(int x,int y);
103  virtual void SetMag(double nmag);
104  virtual void Zoom(double f);
105  virtual void Set(double strt);
106  virtual void Set(double strt,double fin);
107  virtual void SetOrigin(int o);
108 
109  virtual void AddRange(int id, double start, double end);
110 
111  //serializing aids
112  virtual LaxFiles::Attribute *dump_out_atts(LaxFiles::Attribute *att,int what,anObject *context);
113  virtual void dump_in_atts(LaxFiles::Attribute *att,int flag,anObject *context);
114 };
115 
116 } // namespace Laxkit
117 
118 #endif

Mon Feb 17 2014 11:52:57, Laxkit