Laxkit  0.0.7.1
lineedit.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-2010 Tom Lechner
22 //
23 #ifndef _LAX_LINEEDIT_H
24 #define _LAX_LINEEDIT_H
25 
26 #include <lax/textxeditbase-utf8.h>
27 #include <lax/buttondowninfo.h>
28 
29 #include <cstdio>
30 #include <cctype>
31 #include <unistd.h>
32 #include <sys/times.h>
33 
34 #define LINEEDIT_CNTLTAB_NEXT (1<<16)
35 #define LINEEDIT_INT (1<<17)
36 #define LINEEDIT_FLOAT (1<<18)
37 #define LINEEDIT_FILE (1<<19)
38 //#define LINEEDIT_PASSWORD
39 //#define LINEEDIT_DATE
40 //#define LINEEDIT_TIME
41 #define LINEEDIT_SEND_ANY_CHANGE (1<<20)
42 #define LINEEDIT_SEND_FOCUS_ON (1<<21)
43 #define LINEEDIT_SEND_FOCUS_OFF (1<<22)
44 #define LINEEDIT_DESTROY_ON_ENTER (1<<23)
45 #define LINEEDIT_GRAB_ON_MAP (1<<24)
46 
47 namespace Laxkit {
48 
50 {
51  protected:
52  ButtonDownInfo buttondown;
53  virtual int send(int i);
54  virtual void settextrect();
55  public:
56  const char *qualifier;
57  char *blanktext;
58 
59  int padx,pady,mostpixwide;
60  LineEdit(anXWindow *parnt,const char *nname,const char *ntitle,unsigned int nstyle,
61  int xx,int yy,int ww,int hh,int brder,
62  anXWindow *prev,unsigned long nowner=0,const char *nsend=NULL,
63  const char *newtext=NULL,unsigned int ntstyle=0);
64  virtual ~LineEdit();
65  virtual const char *whattype() { return "LineEdit"; }
66  virtual int init();
67  virtual int Event(const EventData *e,const char *mes);
68  virtual int FocusOn(const FocusChangeData *e);
69  virtual int FocusOff(const FocusChangeData *e);
70  virtual void ControlActivation(int on);
71  virtual int CharInput(unsigned int ch,const char *buffer,int len,unsigned int state,const LaxKeyboard *d);
72  virtual int LBDown(int x,int y, unsigned int state,int count,const LaxMouse *d);
73  virtual int LBUp(int x,int y, unsigned int ,const LaxMouse *d);
74  virtual int RBDown(int x,int y, unsigned int ,int count,const LaxMouse *d);
75  virtual int RBUp(int x,int y,unsigned int ,const LaxMouse *d);
76  virtual int WheelUp(int x,int y,unsigned int state,int count,const Laxkit::LaxMouse *d);
77  virtual int WheelDown(int x,int y,unsigned int state,int count,const Laxkit::LaxMouse *d);
78  virtual int Idle(int tid=0); // for autoscroll
79  virtual int MouseMove(int x,int y,unsigned int state,const LaxMouse *d);
80  virtual int Resize(int nw,int nh);
81 
82  virtual int LBDblClick(int x,int y, int cntl,const LaxMouse *d);
83 
84  virtual void Valid(int v);
85  virtual void Valid(int v,unsigned long col);
86  virtual int Modified(int m=1);
87  virtual long GetLong(int *error_ret);
88  virtual double GetDouble(int *error_ret);
89  virtual int Replace(char *newstr,char *what,int all);
90  virtual int SetText(int newtext);
91  virtual int SetText(double newtext);
92  virtual int SetText(const char *newtext);
93  virtual long SetCurLine(long nline) { return 0; };
94  virtual long SetCurpos(long newcurpos); // removes selection
95  virtual int SetSelection(long newss,long newse);
96 
97  virtual int inschar(unsigned int ch,char a=1);
98  virtual int delchar(int bksp);
99  virtual int insstring(const char *blah,int after=0); //after=0
100  virtual int delsel();
101  virtual int replacesel(char ch) { return TextEditBaseUtf8::replacesel(ch); }
102  virtual int replacesel(const char *newt=NULL,int after=0); // after=0, newt=NULL
103  virtual int makeinwindow(); // assumes cx,cy already set accurately
104  virtual long findpos(int pix); // find char at pix from left, not use curlineoffset
105  virtual void findcaret();
106  virtual int Setpixwide();
107  virtual int SetupMetrics();
108  virtual void DrawText(int a=-1);
109 
110  virtual LaxFiles::Attribute *dump_out_atts(LaxFiles::Attribute *att,int what,Laxkit::anObject *savecontext);
111  virtual void dump_in_atts(LaxFiles::Attribute *att,int flag,Laxkit::anObject *loadcontext);
112 };
113 
114 } // namespace Laxkit
115 
116 
117 #endif

Mon Feb 17 2014 11:52:56, Laxkit