Laxkit  0.0.7.1
Public Member Functions | Protected Member Functions | Protected Attributes
Laxkit::TextXEditBaseUtf8 Class Reference

The window base class for text edits using Latin-1 characters. More...

Inheritance diagram for Laxkit::TextXEditBaseUtf8:
Inheritance graph
[legend]

List of all members.

Public Member Functions

 TextXEditBaseUtf8 (anXWindow *parnt, const char *nname, const char *ntitle, unsigned long nstyle, int xx, int yy, int ww, int hh, int brder, anXWindow *prev, unsigned long nowner, const char *nsend, const char *newtext=NULL, unsigned long ntstyle=0, int ncntlchar=0)
virtual ~TextXEditBaseUtf8 ()
virtual int init ()
 Just calls settextrect(), and returns 0.
virtual void Refresh ()
virtual int MBUp (int x, int y, unsigned int state, const LaxMouse *d)
 Initiate a middle button paste via selectionPaste(1,0).
virtual int FocusOn (const FocusChangeData *e)
 Draws the caret on.
virtual int FocusOff (const FocusChangeData *e)
 Draws the caret off.
virtual int MoveResize (int nx, int ny, int nw, int nh)
virtual int Resize (int nw, int nh)
virtual int charwidth (int ch, int r=0)
 Returns real char width with r==1, else returns the custom hexified if r==0.
virtual int Cut ()
 Copy() then delsel().
virtual int Copy ()
 Calls anXApp::CopytoBuffer() with the current selection.
virtual int Paste ()
 Utilizes anXApp::GetBuffer().
virtual void Colors (int hl)
 Set curtextcolor and curbkcolor according to whether highlighting is on or not.
virtual void Black (int x, int y, int w, int h)
 Fill x,y,w,h with curbkcolor.
virtual int DrawTabLine ()
 Draw a marker at top of text area that shows where and what type of tabs exist for the line.
virtual void DrawCaret (int flag=0, int on=1)
 Update the caret and if necessary the change in the selection.
virtual void DrawText (int black=-1)=0
virtual int DrawLineOfText (int x, int y, long pos, long len, char &check, long eof=-1)
 Draw a single line of text.
virtual int TextOut (int x, int y, char *str, long len, long eof)
 Print out len bytes of str, which is a pointer to somewhere inside thetext.
virtual int ExtentAndStr (char *str, long len, char *&blah, long &p)
 Find a printable string, and its pixel extent.
virtual int GetExtent (long pos, long end, int lsofar=0, long eof=-1)
 Find the extent of the string in range [pos,end). Must be no newlines within the range.
virtual long GetPos (long pos, int pix, int lsofar=0, long eof=-1)
 Returns maximum pos less than or equal to an arbitrary window pixel position.
virtual int SetupMetrics ()
virtual int UseThisFont (LaxFont *newfont)
- Public Member Functions inherited from Laxkit::anXWindow
 anXWindow (anXWindow *parnt, const char *nname, const char *ntitle, unsigned long nstyle, int xx, int yy, int ww, int hh, int brder, anXWindow *prev, unsigned long nowner, const char *nsend)
 Constructor.
virtual ~anXWindow ()
 anXWindow destructor. Its X window should have been XDestroy'd before here.
virtual const charwhattype ()
virtual const charWindowTitle (int which=0)
 Return basically the name of the window.
virtual void WindowTitle (const char *newtitle)
 Change the title of the window. This text would usually be displayed in the bar provided by a window manager.
virtual const chartooltip (int mouseid=0)
 By default, return win_tooltip.
virtual const chartooltip (const char *newtooltip)
 Replace the current tooltip, return the current tooltip (after replacing).
virtual anXWindowfindChildWindowByTitle (const char *title)
 Find the first immediate child window that has win_title==title.
virtual anXWindowfindChildWindowByName (const char *name)
 Find the first immediate child window that has win_name==name.
virtual int Grayed ()
 Return whether this window is grayed.
virtual int Grayed (int g)
 Set the gray state of this window. Returns Grayed(void).
virtual int preinit ()
virtual int close ()
 Called by anXApp from anXApp::destroywindow() when a window is to be destroyed.
virtual int Idle (int tid=0)
 anXWindow::Idle() is an empty placeholeder. Just returns 1.
virtual DisplayerMakeCurrent ()
virtual int Needtodraw ()
 Default is to return needtodraw.
virtual void Needtodraw (int nntd)
 If 0, then the window does not need refreshing. Otherwise it does.
virtual int deletenow ()
 Return whether the window is allowed to be deleted.
virtual int setWinStyle (unsigned int stylebit, int newvalue)
 Control various window related basic styling of win_style.
virtual int getWinStyle (unsigned int stylebit)
 Currently, simply return win_style&stylebit.
virtual void installColors (WindowColors *newcolors)
 Dec_count old and inc_count new.
virtual ShortcutHandlerGetShortcuts ()
 Return a ShortcutHandler that contains stacks of bound shortcuts and possible window actions.
virtual int PerformAction (int action_number)
virtual int Event (const EventData *data, const char *mes)
 Default event handler.
virtual int ExposeChange (ScreenEventData *e)
 Default behavior on Expose events is to call Needtodraw(1).
virtual int DeviceChange (const DeviceEventData *e)
virtual int CharInput (unsigned int ch, const char *buffer, int len, unsigned int state, const LaxKeyboard *kb)
 Input of character data or control character presses.
virtual int KeyUp (unsigned int ch, unsigned int state, const LaxKeyboard *kb)
 Called when a key is released.
virtual int MouseMove (int x, int y, unsigned int state, const LaxMouse *m)
 Empty placeholder, just returns 1.
virtual int ButtonDown (int button, int x, int y, unsigned int state, int count, const LaxMouse *m)
virtual int ButtonUp (int button, int x, int y, unsigned int state, const LaxMouse *m)
virtual int LBDown (int x, int y, unsigned int state, int count, const LaxMouse *d)
 Default is just to return 1.
virtual int LBUp (int x, int y, unsigned int state, const LaxMouse *d)
 Default is just to return 1.
virtual int MBDown (int x, int y, unsigned int state, int count, const LaxMouse *d)
 Default is just to return 1.
virtual int RBDown (int x, int y, unsigned int state, int count, const LaxMouse *d)
 Default is just to return 1.
virtual int RBUp (int x, int y, unsigned int state, const LaxMouse *d)
 Default is just to return 1.
virtual int WheelUp (int x, int y, unsigned int state, int count, const LaxMouse *d)
 The wheel mouse rolling up. Default is just to return 1.
virtual int WheelDown (int x, int y, unsigned int state, int count, const LaxMouse *d)
 The wheel mouse rolling down. Default is just to return 1.
virtual void contentChanged ()
 Windows may call this when their contents change.
virtual void selectionChanged ()
 Windows may call this when their selections change.
virtual anXWindowGetController ()
 Return the window most relevant for tab control loops.
virtual int SelectNextControl (const LaxDevice *d)
 Transfer focus to nextcontrol.
virtual int SelectPrevControl (const LaxDevice *d)
 Transfer the focus to prevcontrol.
virtual void ControlActivation (int on)
 Do special activation or not when controls are activated by tabbing.
virtual int AddPrevControl (anXWindow *prev)
virtual int AddNextControl (anXWindow *next)
virtual int ConnectControl (anXWindow *towhat, int after=1)
 Connect towhat to this. Used for tab loops.
virtual int CloseControlLoop ()
 Close a tab loop.
virtual void SetOwner (anXWindow *nowner, const char *mes=NULL, unsigned int send_mask=0)
 Set the new owner and control message.
virtual void SetOwner (unsigned long nowner_id, const char *mes=NULL, unsigned int send_mask=0)
virtual void dump_out (FILE *f, int indent, int what, anObject *context)
 Simple dumping function.
virtual LaxFiles::Attributedump_out_atts (LaxFiles::Attribute *att, int what, anObject *context)
virtual void dump_in_atts (LaxFiles::Attribute *att, int flag, anObject *context)
- Public Member Functions inherited from Laxkit::Tagged
virtual int HasTag (const char *tag, int casematters)
 Return whether the tag exists.
virtual int NumberOfTags ()
 Return the number of tags, strangely enough.
virtual const charGetTag (int i)
 Return const pointer to the tag text for tag number i, where i==0 is the first tag.
virtual charGetAllTags ()
 Return a new char[] with a space separated list of all the tags.
virtual int InsertTags (const char *tags, int casematters)
 Insert tags from a string such as 'tag1 tag2 tag3 "tag with spaces" tag4'.
virtual int InsertTag (const char *tag, int casematters)
 Insert tag if it doesn't exist already.
virtual int RemoveTag (const char *tag)
 The tag must be an exact match.
virtual int RemoveTag (int i)
 Remove tag number i. i must be in range [0..NumberOfTags()-1].
virtual void FlushTags ()
- Public Member Functions inherited from LaxFiles::DumpUtility
virtual void dump_in (FILE *f, int indent, int what, Laxkit::anObject *loadcontext, Attribute **att)
 Read in a file segment as an Attribute, and pass parsing duties to dump_in_atts.
virtual ~DumpUtility ()
 Empty virtual destructor.
- Public Member Functions inherited from Laxkit::aDrawable
 aDrawable (Drawable d=0)
virtual int DrawableType ()
virtual int ValidDrawable ()
- Public Member Functions inherited from Laxkit::TextEditBaseUtf8
 TextEditBaseUtf8 (const char *newtext=NULL, unsigned long nstyle=0, unsigned int ncntlchar=0)
 Constructor.
virtual ~TextEditBaseUtf8 ()
 delete[] thetext and cutbuffer.
virtual int charwidth (unsigned int usc, int actual=0)
virtual int GetTabChar (int atpix)
 For CHAR_TABS, returns the character to center on, or 0 if no such tab there.
virtual int GetNextTab (int atpix)
 Redefine for custom tabstops, default is even spacing with tabwidth pixels.
virtual int GetNextTab (int atpix, int &tabtype)
 Redefine for custom tabstops, default is even spacing with tabwidth pixels.
virtual int inschar (unsigned int ucs, char a=1)
 Insert character at curpos. Afterward, make curpos on it (a==0) or after (a==1) it. Ignores selection, always at curpos.
virtual int insstring (const char *blah, int after=0)
 Insert a string of text. after!=0 makes cursor jump to after the insert.
virtual int delsel ()
 Delete [selstart,curpos], but only if sellen>0.
virtual int delchar (int bksp)
 Delete: bksp==1 means delete curpos-1, 0 del curpos.
virtual int replacesel (unsigned int ucs)
 Replace the selection with character ch.
virtual int replacesel (const char *newt=NULL, int after=0)
 Replace the selection with utf8 encoded newt, placing cursor at beginning of newt (after=0) or after it.
virtual int onlf (long pos=-1)
 Return whether pos is on a delimiter. 0==no, 1==first delimiter, 2==second delimeter.
virtual int findword (long pos, long &start, long &end)
 Find the start and end of a word that includes position pos.
virtual int isword (long pos=-1)
 Return if character at pos is alphanumeric character.
virtual long findlinestart (long pos=-1)
 Return first place after the first newline before pos.
virtual int readonly (long pos=-1)
 Returns if the text is readonly at the given position.
virtual int SetText (const char *newtext)
 Set thetext equal to newtext (copies it).
virtual const charGetCText ()
 Return a const pointer to thetext.
virtual charGetText ()
 Return a new char[] copy of thetext.
virtual charGetSelText ()
 Return a new char[] copy of the selected text.
virtual charCutSelText ()
 Cut out the selected text, and return a copy to a new char[] containing the text.
virtual long GetSelection (long &sels, long &sele)
 Get information about the selection positions.
virtual int SetSelection (long newss=-2, long newse=-2)
 Sets selstart to be newss and curpos to newse.
virtual long Getnumlines ()
 Return the number of newlines in the whole buffer.
virtual long Getnlines (long s=-1, long e=-1)
 Return the number of newlines in range [s,e].
virtual long Getcharswide ()
 Returns most characters wide in all of lines of thetext.
virtual int Getpixwide (long linenum)
 Return pix wide of line from p to newline.
virtual int Modified (int m=1)
virtual int Undo ()
virtual int Redo ()
virtual long WhichLine (long pos)
 Return how many newlines before pos.
virtual long GetCurLine ()
virtual long SetCurLine (long nline)
virtual long GetCurpos ()
virtual long SetCurpos (long ncurpos)
 Returns new curpos.
virtual int SetDelimiter (char n1, char n2=0)
 Set the newline delimiter to "n1n2". n2==0 means use single character newline.
virtual int Find (const char *str, int fromcurs=1)
 Find str in thetext, start search at fromcurs, wrap around.
virtual int Replace (const char *newstr, const char *, int which)
virtual int Replace (const char *newstr, int start, int end)
 Replace a range of text with a new string.

Protected Member Functions

virtual void docaret (int w=1)
 Inverts the caret area. DrawCaret is responsible for maintaining con.
virtual void settextrect ()
 This updates textrect based on new window dimensions.
virtual int selectionDropped (unsigned char *data, unsigned long len, Atom actual_type, Atom which)
virtual chargetSelectionData (int *len, Atom property, Atom targettype, Atom selection)
 Return the selected text, or NULL if no selection.
- Protected Member Functions inherited from Laxkit::anXWindow
virtual int deletekid (anXWindow *w)
 Purges child anXWindows from window's child stack.
virtual void SwapBuffers ()
 Swap buffers. This should be called from Refresh() if VIEWPORT_BACK_BUFFER is set in win_style.
virtual void SetupBackBuffer ()
 Initialize the backbuffer.
- Protected Member Functions inherited from Laxkit::TextEditBaseUtf8
virtual int extendtext ()
 Extend the memory allocated for thetext.
virtual long nextpos (long l)
 Return the next utf8 character position after l.
virtual long prevpos (long l)
 Return the utf8 character position befor l.
virtual void makevalidpos (long &l)
 Make l point only to 1st byte of a utf8 char or 2-char delimiter.
virtual int Undo (UndoData *data)
virtual int Redo (UndoData *data)
virtual int AddUndo (int type, const char *str, long len, long start, long end)

Protected Attributes

int cx
 The x position of the current position, measured from the top left corner of the window.
int cy
 The baseline y position of the current line, measured from the top left corner of the window.
int oldx
 The old value of cx for a caret that might need to be blanked out.
int oldy
 The old value of cy for a caret that might need to be blanked out.
int curlineoffset
 The pixel horizontal offset the text is shifted.
int padx
 Horizontal inset within textrect to place text.
int pady
 Vertical inset within textrect to place text.
char firsttime
char con
 Nonzero if the caret is supposed to be on, and is drawn on, on the screen.
long dpos
 The beginning position in thetext that needs to be redrawn.
long nlines
 The number of lines starting from the line of dpos that must be redrawn.
long oldsellen
 The previous selection length to help narrow down what on screen must be redrawn.
long oldcp
 The previous curpos to help narrow down what on screen must be redrawn.
int textascent
int textheight
int textdescent
unsigned long curtextcolor
unsigned long textbgcolor
unsigned long curbkcolor
unsigned long bkwrongcolor
unsigned long wscolor
LaxFontthefont
int valid
 An extra modifier to control what colors are used.
DoubleRectangle textrect
 The rectangle inside of which text can be drawn.
- Protected Attributes inherited from Laxkit::anXWindow
charwin_tooltip
 Convenience variable to hold the window's tooltip, if any.
int needtodraw
RefPtrStack< anXWindow_kids
 Stack of children of the window.
- Protected Attributes inherited from Laxkit::Tagged
PtrStack< charlist_of_tags
- Protected Attributes inherited from Laxkit::TextEditBaseUtf8
long curline
long curpos
long selstart
long sellen
int cntlmovedist
int tabwidth
charthetext
charcutbuffer
long textlen
long maxtextmem
char newline
char newline2
char cntlchar
char modified
long maxtextlen
long mintextlen
long maxcharswide
long mincharswide
long maxlines
long minlines
unsigned long textstyle
int undomode
UndoManager undomanager

Additional Inherited Members

- Public Attributes inherited from Laxkit::anXWindow
WindowColorswin_colors
anXAppapp
charwin_name
 An arbitrary string to be used as an id.
charwin_title
 The title of the window.
anXWindowwin_parent
int win_screen
unsigned long win_style
int win_x
int win_y
int win_w
int win_h
unsigned int win_border
int win_pointer_shape
 Identifier for a stock mouse shape.
char win_on
 Nonzero if the window is mapped.
char win_active
 Should be positive when the window has a keyboard focus, 0 otherwise.
unsigned long win_owner
 Who gets control messages from this window.
unsigned int win_owner_send_mask
charwin_sendthis
 The type of message that gets sent to owner.
anXWindownextcontrol
anXWindowprevcontrol
- Public Attributes inherited from Laxkit::Tagged
int sorttags

Detailed Description

The window base class for text edits using Latin-1 characters.

This class provides basic text drawing utilities for subclasses to use. Mainly this means providing textrect to say what portion of the actual window is to be used for drawing text in, and functions to aid drawing single lines of text which take into account left, right, center, and numeric tabs.

Subclasses must define their own DrawText(). DrawLineOfText() can be called from DrawText(), once the subclass determines what part of thetext is supposed to be shown. a default DrawCaret done here, docaret done here, subclasses must upkeep oldx,oldy and cx,cy. Cursor events must be handled in subclasses.

Todo:

*** a utf8 must have different simple get extent for compound characters???

how best to standardize text controls?

*** snafus with really long lines

*** makeinwindow if it can fit, it should fit

*** map space to tab for TABS_SPACES in charwidth(), tabwidth=' '*4

*** color in the pad space, put little bevel, etc

*** NO_TAB

*** paste nl conversion

*** DrawLineOfText should use a maxpix and a maxpos for refreshing and word wrapping convenience respectively


Constructor & Destructor Documentation

Laxkit::TextXEditBaseUtf8::TextXEditBaseUtf8 ( anXWindow parnt,
const char nname,
const char ntitle,
unsigned long  nstyle,
int  xx,
int  yy,
int  ww,
int  hh,
int  brder,
anXWindow prev,
unsigned long  nowner,
const char nsend,
const char newtext = NULL,
unsigned long  ntstyle = 0,
int  ncntlchar = 0 
)

newtext is assumed to be utf8 encoded. ncntlchar is a UCS code.

Subclasses will want to initialize the various colors to something appropriate.

References con, curlineoffset, cx, cy, oldx, oldy, and valid.

Laxkit::TextXEditBaseUtf8::~TextXEditBaseUtf8 ( )
virtual

Decrements count of thefont.

References Laxkit::anObject::dec_count().


Member Function Documentation

int Laxkit::TextXEditBaseUtf8::charwidth ( int  ch,
int  r = 0 
)
virtual

Returns real char width with r==1, else returns the custom hexified if r==0.

WARNING: this is found from individual characters in the font, not from the context of the character.

References Laxkit::getextent(), Laxkit::hexify(), and Laxkit::utf8encode().

Referenced by ExtentAndStr(), and TextOut().

int Laxkit::TextXEditBaseUtf8::Copy ( )
virtual

Calls anXApp::CopytoBuffer() with the current selection.

Todo:
*** figure out what's wrong with the copy/paste stuff.. should be able to copy right from the terminal, but that's not working..

Reimplemented from Laxkit::TextEditBaseUtf8.

References Laxkit::anXApp::CopytoBuffer().

Referenced by Laxkit::LineEdit::CharInput(), and Cut().

void Laxkit::TextXEditBaseUtf8::docaret ( int  w = 1)
protectedvirtual

Inverts the caret area. DrawCaret is responsible for maintaining con.

w=1, 1 is new caret, 0 is old caret, assumes cx,cy set right

References cx, cy, Laxkit::drawing_function(), Laxkit::fill_rectangle(), Laxkit::LAXOP_Source, Laxkit::LAXOP_Xor, oldx, and oldy.

Referenced by DrawCaret().

void Laxkit::TextXEditBaseUtf8::DrawCaret ( int  removeold = 0,
int  on = 1 
)
virtual

Update the caret and if necessary the change in the selection.

Determines what to update based on the earliest and latest highlighted character, and the difference between WhichLine(earliest) and WhichLine(latest). dpos gets the earliest position, and nlines gets the line difference and DrawText(0) is called in this case.

If there is no selection and no old selection to redraw, then the caret is merely turned off or on.

removeold=1 means cursor movement, draw the caret and selection. removeold==0 assume cursor not there, so that area does not have to be redrawn.

If on is nonzero, then the cursor should be drawn on.

References con, cx, cy, docaret(), dpos, nlines, oldcp, oldsellen, oldx, oldy, and Laxkit::TextEditBaseUtf8::WhichLine().

Referenced by FocusOff(), FocusOn(), and Refresh().

int Laxkit::TextXEditBaseUtf8::DrawLineOfText ( int  x,
int  y,
long  pos,
long  len,
char check,
long  eof = -1 
)
virtual

Draw a single line of text.

y is the baseline of the text.

Assumes that x corresponds to pixel 0 of the text that needs drawing. Thus, doesn't inherently do right/center justify, but does map tabs (this conversion is done in TextOut()) to chars if right/center. Handles lines with highlighting, len==1 prints 1 char. Returns updated x.

If len==-1, then draw until a newline or '\0'. If check!=0, then check to see if the selection starts or stops within the line.

Todo:

*** automatically blacks out x to eol, is this ok?

is clipping really necessary? Sure it leaks when text out of bounds.. only a problem when textrect is very different from window and nothing else covers up overflow..

References Black(), Colors(), Laxkit::TextEditBaseUtf8::onlf(), TextOut(), and textrect.

Referenced by Laxkit::MultiLineEdit::DrawText().

int Laxkit::TextXEditBaseUtf8::DrawTabLine ( )
virtual

Draw a marker at top of text area that shows where and what type of tabs exist for the line.

assumes cy set right, draws just above current line

References curlineoffset, cy, Laxkit::fill_polygon(), Laxkit::fill_rectangle(), and Laxkit::TextEditBaseUtf8::GetNextTab().

Referenced by Refresh().

int Laxkit::TextXEditBaseUtf8::ExtentAndStr ( char str,
long  len,
char *&  blah,
long &  p 
)
virtual

Find a printable string, and its pixel extent.

Assumes no tabs. str points to somewhere in thetext. That segment of thetext gets converted into a string that is to be printed, and blah is made to point to that. Adds a pad of 6 bytes to blah,

Returns pixel extent, p is len of blah.

The previos contents of blah, if any, are ignored. They are not delete[]'d if blah!=NULL.

References charwidth(), Laxkit::getextent(), Laxkit::TextEditBaseUtf8::nextpos(), Laxkit::utf8decode(), and Laxkit::utf8encode().

Referenced by TextOut().

int Laxkit::TextXEditBaseUtf8::FocusOff ( const FocusChangeData e)
virtual

Draws the caret off.

Todo:
perhaps should also color the selection differently.

Reimplemented from Laxkit::anXWindow.

Reimplemented in Laxkit::LineEdit.

References con, DrawCaret(), and Laxkit::anXWindow::win_active.

int Laxkit::TextXEditBaseUtf8::GetExtent ( long  pos,
long  end,
int  lsofar = 0,
long  eof = -1 
)
virtual

Find the extent of the string in range [pos,end). Must be no newlines within the range.

This can be used to find where the caret should be. The function deals with tabs. Assumes lsofar starts at an accurate place. It must be the horizontal pixel location corresponding to pos. Also assumes curlineoffset set appropriately.

As always, pos and end point to the first byte of a multibyte character, or the first of a 2-character newline.

Returns the new lsofar.

Todo:
*** must fix the not taking into account missing chars..

References Laxkit::getextent(), Laxkit::TextEditBaseUtf8::GetNextTab(), Laxkit::TextEditBaseUtf8::GetTabChar(), Laxkit::TextEditBaseUtf8::onlf(), and Laxkit::utf8encode().

Referenced by Laxkit::MultiLineEdit::countout(), Laxkit::MultiLineEdit::DrawText(), Laxkit::MultiLineEdit::findcaret(), Laxkit::LineEdit::findcaret(), Laxkit::MultiLineEdit::findline(), Laxkit::MultiLineEdit::inschar(), Laxkit::LineEdit::Setpixwide(), and TextOut().

long Laxkit::TextXEditBaseUtf8::GetPos ( long  pos,
int  pix,
int  lsofar = 0,
long  eof = -1 
)
virtual

Returns maximum pos less than or equal to an arbitrary window pixel position.

This is basically used to find a position underneath the mouse. Assumes lsofar set to something reasonable for pos, as if it was on a lefttab. Handles tabs.

Scan from pos to an end of line, or to eof. If eof<0, then use eof=textlen.

Todo:
mishandles missing chars

References Laxkit::getextent(), Laxkit::TextEditBaseUtf8::GetNextTab(), Laxkit::TextEditBaseUtf8::GetTabChar(), Laxkit::TextEditBaseUtf8::nextpos(), Laxkit::TextEditBaseUtf8::onlf(), and Laxkit::utf8encode().

Referenced by Laxkit::MultiLineEdit::countout(), and Laxkit::LineEdit::findpos().

int Laxkit::TextXEditBaseUtf8::MoveResize ( int  nx,
int  ny,
int  nw,
int  nh 
)
virtual

Default is to set textrect equal to the new window bounds.

Reimplemented from Laxkit::anXWindow.

Reimplemented in Laxkit::MultiLineEdit.

References settextrect().

Referenced by Laxkit::LineInput::SetPlacement().

void Laxkit::TextXEditBaseUtf8::Refresh ( )
virtual

If needtodraw&1, draw all. Calls DrawText(). Else if needtodraw&2, then assumed to be updating either just mouse move, or mouse move plus only a part of the window needs updating.

Refresh potentially consists of optionally drawing the tab markers (done by DrawTabLine()), drawing the text with the selection shown (done by DrawText()), and drawing the caret (done by DrawCaret()).

This function also calls textdraw(NULL) right at the end.

Reimplemented from Laxkit::anXWindow.

References Laxkit::clear_window(), dpos, DrawCaret(), DrawTabLine(), nlines, SetupMetrics(), Laxkit::anXWindow::win_active, and Laxkit::anXWindow::win_on.

int Laxkit::TextXEditBaseUtf8::Resize ( int  nw,
int  nh 
)
virtual

Default is to set textrect equal to the new window bounds.

Reimplemented from Laxkit::anXWindow.

Reimplemented in Laxkit::MultiLineEdit.

References settextrect().

void Laxkit::TextXEditBaseUtf8::settextrect ( )
protectedvirtual

This updates textrect based on new window dimensions.

Normally called from MoveResize() or Resize(). Subclasses would want to remap cx, cy, and curlineoffset when resizing the window makes the textrect origin change.

Reimplemented in Laxkit::LineEdit.

References textrect.

Referenced by Laxkit::MultiLineEdit::init(), init(), MoveResize(), Laxkit::MultiLineEdit::MoveResize(), Resize(), and Laxkit::MultiLineEdit::Resize().

int Laxkit::TextXEditBaseUtf8::SetupMetrics ( )
virtual

Sets thefont=app->defaultlaxfont, and assigns textheight, textascent, and textdescent accordingly. Increments the count of app->defaultlaxfont.

Reimplemented in Laxkit::MultiLineEdit.

References Laxkit::anObject::inc_count().

Referenced by Refresh(), Laxkit::MultiLineEdit::SetupMetrics(), and UseThisFont().

int Laxkit::TextXEditBaseUtf8::TextOut ( int  x,
int  y,
char str,
long  len,
long  eof 
)
virtual

Print out len bytes of str, which is a pointer to somewhere inside thetext.

Handles tabs, treats '\n' as normal char, except when it is at position len. Returns updated x. y is baseline. Handles any number of tabs until a newline or len, checks for initial tab, does one segment, and if more tabs found, calls itself with rest of string.

Does not handle highlighting. Highlightind is accounted for in DrawLineOfText().

If eof<0, then use textlen-(str-thetext) for eof. str points to somewhere inside thetext. Do not use an arbitrary string. eof is a length, with eof==0 corresponding to *str.

IMPORTANT: this depends on thetext and textlen to do bounds checking while working out tab placement, do not call with arbitrary strings, else will seg fault on tab placement sometimes. If you must, you can temporarily redefine thetext, textlen, curpos, and curlineoffset. Only other thing it calls is onlf(), which uses curpos if the pos is out of bounds.

Todo:
break off the actual string output to laxutils::textout()?

References Black(), charwidth(), curlineoffset, Laxkit::draw_line(), Laxkit::draw_rectangle(), ExtentAndStr(), GetExtent(), Laxkit::TextEditBaseUtf8::GetNextTab(), Laxkit::TextEditBaseUtf8::GetTabChar(), Laxkit::TextEditBaseUtf8::onlf(), Laxkit::textout(), textrect, and Laxkit::utf8encode().

Referenced by DrawLineOfText().

int Laxkit::TextXEditBaseUtf8::UseThisFont ( LaxFont newfont)
virtual

Increments newfont's count.

References Laxkit::anObject::dec_count(), Laxkit::anObject::inc_count(), and SetupMetrics().


Member Data Documentation

int Laxkit::TextXEditBaseUtf8::curlineoffset
protected
int Laxkit::TextXEditBaseUtf8::nlines
protected
int Laxkit::TextXEditBaseUtf8::padx
protected

Horizontal inset within textrect to place text.

The horizontal area text can fill before scrolling is necessary is textrect.width-2*padx.

int Laxkit::TextXEditBaseUtf8::pady
protected

Vertical inset within textrect to place text.

The vertical area text can fill before scrolling is necessary is textrect.height-2*pady.

int Laxkit::TextXEditBaseUtf8::valid
protected

An extra modifier to control what colors are used.

This is used, for instance, to make the text background red when a file is invalid. bkwrongcolor will be used in this case, instead of bkcolor.

Referenced by Colors(), Laxkit::LineEdit::LineEdit(), Laxkit::LineEdit::Modified(), TextXEditBaseUtf8(), and Laxkit::LineEdit::Valid().


The documentation for this class was generated from the following files:

Mon Feb 17 2014 11:53:00, Laxkit