Laxkit  0.0.7.1
multilineedit.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_GOODEDITWW_H
24 #define _LAX_GOODEDITWW_H
25 
26 
27 #include <lax/textxeditbase-utf8.h>
28 #include <lax/scroller.h>
29 #include <lax/buttondowninfo.h>
30 
31 #define GOODEDITWW_Y_IS_CHARS (1<<16)
32 
33 
34 namespace Laxkit {
35 
37 {
38  protected:
39  char *blanktext;
40  ButtonDownInfo buttondown;
41  int cdir,scrollwidth,mostpixwide,mostcharswide,maxpixwide;
42  int numlines,lpers,longestline;
43  int mx,my;
44  struct Linestat {
45  long start;
46  int pixlen,indent;
47  } *linestats;
48  Scroller *xscroller,*yscroller;
49  int xscrollislocal,yscrollislocal;
50  virtual int send() { return 0; }
51  public:
52  int padx,pady;
53  MultiLineEdit(anXWindow *prnt,const char *nname,const char *ntitle,unsigned long nstyle,
54  int xx,int yy,int ww,int hh,int brder,
55  anXWindow *prev,unsigned long nowner=0,const char *nsend=NULL,
56  unsigned int ntstyle=0,const char *newtext=NULL);
57  virtual ~MultiLineEdit();
58  virtual void UseTheseScrollers(Scroller *xscroll,Scroller *yscroll);
59  // if goodeditww uses outside supplied scrollers, the must be passed on to
60  virtual int init();
61  virtual int Event(const EventData *e,const char *mes);
62  virtual int CharInput(unsigned int ch,const char *buffer,int len,unsigned int state,const LaxKeyboard *d);
63  virtual int LBDown(int x,int y, unsigned int state,int count,const LaxMouse *d);
64  virtual int LBDblClick(int x,int y, unsigned int state,const LaxMouse *d);
65  virtual int LBUp(int x,int y, unsigned int state,const LaxMouse *d);
66  virtual int RBDown(int x,int y, unsigned int state,int count,const LaxMouse *d);
67  virtual int RBUp(int x,int y,unsigned int state,const LaxMouse *d);
68  virtual int WheelDown(int x,int y,unsigned int state,int count,const LaxMouse *d);
69  virtual int WheelUp(int x,int y,unsigned int state,int count,const LaxMouse *d);
70  virtual int MouseMove(int x,int y,unsigned int state,const LaxMouse *d);
71  virtual int Idle(int tid=0);
72  virtual int Resize(int nw,int nh);
73  virtual int MoveResize(int nx,int ny,int nw,int nh);
74 
75  virtual int Find(char *str,int fromcurs=1); // fromcurs=1
76  virtual int Replace(const char *oldstr,const char *newstr,int all);
77  virtual int SetText(const char *newtext);
78  virtual long SetCurPos(long newcurpos);
79  virtual int SetSelection(long newss,long newse);
80  // NOTE: the scrollers are always flush with right and bottom, and newyssize,newxssize modify textrect
81  virtual int newyssize();
82  virtual int newxssize(int p=1); //p=1, p is to prevent race with newyssize
83  // called anytime changes are made in thetext
84  // it changes linestats, needtodraw, dpos, nlines
85  virtual void wwinspect(int fromline=0); //fromline=0, this and fineline are the linebreaking procs
86  virtual int inschar(int ch);
87  virtual int delchar(int bksp); // assumes not sellen
88  virtual int insstring(const char *blah,int after=0); // after=0
89  virtual int replacesel(int ch);
90  virtual int delsel();
91  virtual int getscreenline(long pos);
92  virtual int replacesel(const char *newt,int after=0); //newt=NULL deletes, after=0
93  // return position most appropriate for x=pix,y=l max <= pi
94  // sets curpos to pos near (x,y)=(l,pix)
95  virtual long findpos(int l,int pix,int updatecp=1,int conv=1);
96  virtual long countout(int linenumber,int &pout);
97  virtual int makeinwindow(); // assumes cx,cy already set accurately
98  virtual void findcaret();
99  // returns 1 if there is a change, 0 if not
100  virtual int ShiftScreen(int x,long y); // ylines
101  virtual int isword(long pos);
102  // returns pos of start of next potential screen line after ls, assumes ilsofar set right
103  // updates ilsofar which basically becomes pixlen of line with ls
104  virtual long findline(long ls,int &ilsofar);
105  // find what should be the start of the screen line that contains pos
106  virtual long findlinestart(long pos=-1); //pos=-1 means use curpos
107  // this remaps linestats, but does not findcaret
108  // it does find and set mostpixwide,longestline, dpos,nlines
109  virtual int makelinestart(int startline,long ulwc,int godown,int ifdelete);
110  // does not recompute linestats.pixlens
111  virtual int Getmostwide(); // returns which line
112  virtual long WhichLine(long pos);
113  virtual void DrawText(int black=1); // black=1
114  virtual int SetupMetrics();
115  virtual void SetupScreen();
116 
117  virtual LaxFiles::Attribute *dump_out_atts(LaxFiles::Attribute *att,int what,Laxkit::anObject *savecontext);
118  virtual void dump_in_atts(LaxFiles::Attribute *att,int flag,Laxkit::anObject *loadcontext);
119 
120 };
121 
122 } // namespace Laxkit
123 
124 #endif

Mon Feb 17 2014 11:52:57, Laxkit