Laxkit  0.0.7.1
boxselector.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 by Tom Lechner
22 //
23 #ifndef _LAX_BOXSELECTOR_H
24 #define _LAX_BOXSELECTOR_H
25 
26 #include <lax/anxapp.h>
27 #include <lax/boxarrange.h>
28 #include <lax/buttondowninfo.h>
29 
30 
31  //arrange boxes in columns or in rows
32 #define BOXSEL_COLUMNS (1<<16)
33 #define BOXSEL_VERTICAL (1<<16)
34 #define BOXSEL_ROWS (1<<17)
35 #define BOXSEL_HORIZONTAL (1<<17)
36 
37  //how to align the boxes in the window
38 #define BOXSEL_CENTER (1<<19|1<<22)
39 #define BOXSEL_LEFT (1<<18)
40 #define BOXSEL_HCENTER (1<<19)
41 #define BOXSEL_RIGHT (1<<20)
42 #define BOXSEL_TOP (1<<21)
43 #define BOXSEL_VCENTER (1<<22)
44 #define BOXSEL_BOTTOM (1<<23)
45 
46  // how to fill gaps between boxes, whether to stretch them, or put a gap between them
47  // these refer to filling whole window
48 #define BOXSEL_STRETCH (1<<24|1<<25)
49 #define BOXSEL_STRETCHX (1<<24)
50 #define BOXSEL_STRETCHY (1<<25)
51 #define BOXSEL_SPACE (1<<26|1<<27)
52 #define BOXSEL_SPACEX (1<<26)
53 #define BOXSEL_SPACEY (1<<27)
54 
55  // these refer to filling extra (width in cols) or (height in rows)
56 #define BOXSEL_STRETCH_IN_ROW (1<<28)
57 #define BOXSEL_STRETCH_IN_COL (1<<28)
58 
59  // make the panel look flat, mouse over highlights, selected ones are elevated.
60  // Otherwise default is all are either up or down, or flat if grayed
61 #define BOXSEL_FLAT (1<<29)
62 #define BOXSEL_ONE_ONLY (1<<30)
63 
64 
65 
66 namespace Laxkit {
67 
68 //------------------------------- SelBox --------------------------------
69 class SelBox : public SquishyBox
70 {
71  public:
72  unsigned int state;
73  int info,id;
75  SelBox(int xx,int yy,int ww,int hh,int nid);
76  SelBox(int nid=0);
77  virtual ~SelBox() {}
78 };
79 
80 //------------------------------- BoxSelector --------------------------------
81 
82 class BoxSelector : public anXWindow, public RowColBox
83 {
84  protected:
85  ButtonDownInfo buttondown;
86  virtual void togglebox(int which,int db=1);
87  public:
88  unsigned long highlight,shadow;
89  int pad,padi,bevel;
90  int curbox;
91  BoxSelector(anXWindow *parnt,const char *nname,const char *ntitle,unsigned long nstyle,
92  int xx,int yy,int ww,int hh,int brder,
93  anXWindow *prev,unsigned long nowner,const char *nsendmes,
94  int nid=0,int npad=0);
95  virtual ~BoxSelector();
96  virtual const char *whattype() { return "BoxSelector"; }
97  virtual void sync();
98  virtual int init();
99  virtual int Event(const EventData *e,const char *mes);
100 // virtual void WrapToExtent();
101  virtual int MoveResize(int nx,int ny,int nw,int nh);
102  virtual int Resize(int nw,int nh);
103  virtual void Refresh();
104  virtual int MouseMove(int x,int y,unsigned int state,const LaxMouse *d);
105  virtual int LBDown(int x,int y,unsigned int state,int count,const LaxMouse *d);
106  virtual int LBUp(int x,int y,unsigned int state,const LaxMouse *d);
107  virtual int WheelUp(int x,int y,unsigned int state,int count,const LaxMouse *d); // toggle curbox
108  virtual int WheelDown(int x,int y,unsigned int state,int count,const LaxMouse *d);
109 
110  virtual int SelectN(int whichindex);
111  virtual int Select(int whichID);
112  virtual int MouseInWhich(int x,int y);
113  virtual void drawbox(int which) = 0;
114  virtual int send();
115 };
116 
117 } // namespace Laxkit
118 
119 #endif
120 

Mon Feb 17 2014 11:52:56, Laxkit