Laxkit  0.0.7.1
menuselector.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_MENUSELECTOR_H
24 #define _LAX_MENUSELECTOR_H
25 
26 #include <lax/anxapp.h>
27 #include <lax/menuinfo.h>
28 #include <lax/scrolledwindow.h>
29 #include <lax/buttondowninfo.h>
30 
31 #include <cstring>
32 
33 
34 
35  // Item placement and display flags
36 #define MENUSEL_CHECK_ON_RIGHT (1LL<<0)
37 #define MENUSEL_CHECK_ON_LEFT (1LL<<1)
38 #define MENUSEL_SUB_ON_RIGHT (1LL<<2)
39 #define MENUSEL_SUB_ON_LEFT (1LL<<3)
40 #define MENUSEL_STATUS_ON_RIGHT (1LL<<4)
41 #define MENUSEL_STATUS_ON_LEFT (1LL<<5)
42 #define MENUSEL_GRAPHIC_ON_RIGHT (1LL<<6)
43 #define MENUSEL_GRAPHIC_ON_LEFT (1LL<<7)
44 #define MENUSEL_SUB_FOLDER (1LL<<8)
45 #define MENUSEL_SUB_ARROW (1LL<<9)
46 #define MENUSEL_CENTER (1LL<<10)
47 #define MENUSEL_LEFT (1LL<<11)
48 #define MENUSEL_RIGHT (1LL<<12)
49 #define MENUSEL_TAB_JUSTIFY (1LL<<13)
50 #define MENUSEL_CHECKS (1LL<<14)
51 #define MENUSEL_CHECKBOXES (1LL<<15)
52 #define MENUSEL_SHOW_LEAF_ONLY (1LL<<16)
53 #define MENUSEL_SHOW_SUB_ONLY (1LL<<17)
54 #define MENUSEL_SCROLLERS (1LL<<18)
55 #define MENUSEL_USE_TITLE (1LL<<19)
56 #define MENUSEL_BUTTONCOLORS (1LL<<20)
57 #define MENUSEL_TEXTCOLORS (1LL<<21)
58 #define MENUSEL_FIT_TO_WIDTH (1LL<<22)
59 #define MENUSEL_FIT_TO_HEIGHT (1LL<<23)
60 #define MENUSEL_TREE (1LL<<24)
61 #define MENUSEL_COMPOUND_TREE (1LL<<25)
62 
63 #define MENUSEL_SORT_NUMBERS (1LL<<26)
64 #define MENUSEL_SORT_LETTERS (1LL<<27)
65 #define MENUSEL_SORT_REVERSE (1LL<<28)
66 #define MENUSEL_SORT_SUBS_FIRST (1LL<<29)
67 #define MENUSEL_SORT_IGNORE_CASE (1LL<<30)
68 #define MENUSEL_SORT_BY_EXTENSIONS (1LL<<31)
69 
70 #define MENUSEL_USE_DOT (1LL<<32)
71 #define MENUSEL_USE_DOT_DOT (1LL<<33)
72 #define MENUSEL_USE_UP (1LL<<34)
73 #define MENUSEL_USE_BACK (1LL<<35)
74 
75 #define MENUSEL_ONE_ONLY (1LL<<36)
76 #define MENUSEL_ZERO_OR_ONE (1LL<<37)
77 #define MENUSEL_SELECT_ANY (1LL<<38)
78 #define MENUSEL_SELECT_LEAF_ONLY (1LL<<39)
79 #define MENUSEL_SELECT_SUB_ONLY (1LL<<40)
80 #define MENUSEL_CURSSELECTS (1LL<<41)
81 #define MENUSEL_FOLLOW_MOUSE (1LL<<42)
82 #define MENUSEL_GRAB_ON_MAP (1LL<<43)
83 #define MENUSEL_GRAB_ON_ENTER (1LL<<44)
84 #define MENUSEL_OUT_CLICK_DESTROYS (1LL<<45)
85 #define MENUSEL_CLICK_UP_DESTROYS (1LL<<46)
86 #define MENUSEL_DESTROY_ON_LEAVE (1LL<<47)
87 #define MENUSEL_DESTROY_ON_FOCUS_OFF (1LL<<48)
88 
89 #define MENUSEL_REARRANGEABLE (1LL<<49)
90 #define MENUSEL_EDIT_IN_PLACE (1LL<<50)
91 //*** add items?? (more than just editing names)
92 //*** remove items??
93 
94 #define MENUSEL_SEND_ON_UP (1LL<<51)
95 #define MENUSEL_SEND_ON_ENTER (1LL<<52)
96 #define MENUSEL_SEND_IDS (1LL<<53)
97 #define MENUSEL_SEND_STRINGS (1LL<<54)
98 
99 //... remember that the buck stops with (1<<63)
100 
101 
102 namespace Laxkit {
103 
105 {
106  protected:
107  ButtonDownInfo buttondown;
112  int mx,my;
114  int firstinw;
118  int timerid;
119  virtual void adjustinrect();
120  virtual void findoutrect();
121  virtual double getitemextent(MenuItem *mitem,double *w,double *h,double *gx,double *tx);
122  virtual double getgraphicextent(MenuItem *mitem,double *x,double *y);
123  virtual void drawStatusGraphic(int x,int y,int state);
124  virtual void drawitem(MenuItem *mitem,IntRectangle *itemspot);
125  virtual void drawitem(int c);
126  virtual void drawsep(const char *name,IntRectangle *rect);
127  virtual void drawarrow(int x,int y,int r,int type);
128  virtual void drawcheck(int on, int x,int y);
129  virtual void drawsubindicator(MenuItem *mitem,int x,int y);
130  virtual void drawitemname(MenuItem *mitem,IntRectangle *rect);
131  virtual void drawtitle();
132  virtual int send(int deviceid);
133  virtual void addselect(int i,unsigned int state);
134  virtual int findmaxwidth(int s,int e, int *h_ret);
135  virtual int findItem(int x,int y);
136  virtual int findRect(int c,IntRectangle *itemspot);
137  virtual void editInPlace();
138  virtual int numItems();
139  virtual MenuItem *item(int i,char skipcache=0);
140  virtual void arrangeItems(int forwrapping=0);
141  virtual void setcuritem(int i);
142  virtual void syncWindows(int useinrect=0);
143  virtual int makeinwindow();
144 
145  public:
146  unsigned long highlight,shadow;
147  unsigned long long menustyle;
148  int padg,pad,leading;
149  MenuSelector(anXWindow *parnt,const char *nname,const char *ntitle,unsigned long nstyle,
150  int xx,int yy,int ww,int hh,int brder,
151  anXWindow *prev,unsigned long nowner=0,const char *mes=0,
152  unsigned long long nmstyle=0,MenuInfo *minfo=NULL,char nmenuislocal=0);
153  virtual ~MenuSelector();
154  virtual int init();
155  virtual void Refresh();
156  virtual int Event(const EventData *e,const char *mes);
157  virtual int CharInput(unsigned int ch,const char *buffer,int len,unsigned int state,const LaxKeyboard *d);
158  virtual int LBDown(int x,int y,unsigned int state,int count,const LaxMouse *d);
159  virtual int LBUp(int x,int y,unsigned int state,const LaxMouse *d);
160  virtual int RBDown(int x,int y,unsigned int state,int count,const LaxMouse *d);
161  virtual int RBUp(int x,int y,unsigned int state,const LaxMouse *d);
162  virtual int WheelUp(int x,int y,unsigned int state,int count,const LaxMouse *d);
163  virtual int WheelDown(int x,int y,unsigned int state,int count,const LaxMouse *d);
164  virtual int MouseMove(int x,int y,unsigned int state,const LaxMouse *d);
165  virtual int Idle(int tid);
166  virtual int MoveResize(int nx,int ny,int nw,int nh);
167  virtual int Resize(int nw,int nh);
168  virtual int FocusOn(const FocusChangeData *e);
169  virtual int FocusOff(const FocusChangeData *e);
170 
171  virtual int WrapToMouse(int mouseid, anXWindow *onedgeofthis=NULL);
172  virtual int WrapToPosition(int screen_x, int screen_y, int screen, anXWindow *onedgeofthis=NULL);
173  virtual int movescreen(int dx,int dy);
174  virtual int SetFirst(int which,int x,int y);
175  virtual int Curitem() { return curitem; }
176  virtual const MenuItem *Item(int c) { return item(c); }
177  virtual int Select(int which);
178  virtual int NumSelected();
179  virtual int *WhichSelected(unsigned int state);
180  virtual void SetLineHeight(int ntotalheight,int newleading,char forcearrange=1);
181  virtual void Sync();
182 
183 // virtual int RemoveItem(int whichid);
184 // virtual int RemoveItem(const char *i);
185  virtual void Sort(int t);
186  virtual int AddItems(const char **i,int n,int startid); // assume ids sequential, state=0
187  virtual int AddItem(const char *i,int nid,int nst);
188 };
189 
190 
191 } // namespace Laxkit
192 
193 #endif
194 
195 

Mon Feb 17 2014 11:52:57, Laxkit