Main Page   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members

FXText.h
Go to the documentation of this file.
1 /********************************************************************************
2 * *
3 * M u l t i - L i ne T e x t W i d g e t *
4 * *
5 *********************************************************************************
6 * Copyright (C) 1998,2006 by Jeroen van der Zijp. All Rights Reserved. *
7 *********************************************************************************
8 * This library is free software; you can redistribute it and/or *
9 * modify it under the terms of the GNU Lesser General Public *
10 * License as published by the Free Software Foundation; either *
11 * version 2.1 of the License, or (at your option) any later version. *
12 * *
13 * This library is distributed in the hope that it will be useful, *
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
16 * Lesser General Public License for more details. *
17 * *
18 * You should have received a copy of the GNU Lesser General Public *
19 * License along with this library; if not, write to the Free Software *
20 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. *
21 *********************************************************************************
22 * $Id: FXText.h,v 1.166 2006/02/06 03:03:40 fox Exp $ *
23 ********************************************************************************/
24 #ifndef FXTEXT_H
25 #define FXTEXT_H
26 
27 #ifndef FXSCROLLAREA_H
28 #include "FXScrollArea.h"
29 #endif
30 
31 namespace FX {
32 
33 
34 /// Text widget options
35 enum {
36  TEXT_READONLY = 0x00100000, /// Text is NOT editable
37  TEXT_WORDWRAP = 0x00200000, /// Wrap at word breaks
38  TEXT_OVERSTRIKE = 0x00400000, /// Overstrike mode
39  TEXT_FIXEDWRAP = 0x00800000, /// Fixed wrap columns
40  TEXT_NO_TABS = 0x01000000, /// Insert spaces for tabs
41  TEXT_AUTOINDENT = 0x02000000, /// Autoindent
42  TEXT_SHOWACTIVE = 0x04000000, /// Show active line
43  TEXT_AUTOSCROLL = 0x08000000 /// Logging mode, keeping last line visible
44  };
45 
46 
47 /// Selection modes
52  };
53 
54 
55 /// Highlight style entry
56 struct FXHiliteStyle {
57  FXColor normalForeColor; /// Normal text foreground color
58  FXColor normalBackColor; /// Normal text background color
59  FXColor selectForeColor; /// Selected text foreground color
60  FXColor selectBackColor; /// Selected text background color
61  FXColor hiliteForeColor; /// Highlight text foreground color
62  FXColor hiliteBackColor; /// Highlight text background color
63  FXColor activeBackColor; /// Active text background color
64  FXuint style; /// Highlight text style
65  };
66 
67 
68 /**
69 * Text mutation callback data passed with the SEL_INSERTED,
70 * SEL_REPLACED, and SEL_DELETED messages; both old and new
71 * text is available on behalf of the undo system as well as
72 * syntax highlighting.
73 */
74 struct FXTextChange {
75  FXint pos; /// Position in buffer
76  FXint ndel; /// Number characters deleted at position
77  FXint nins; /// Number characters inserted at position
78  FXchar *ins; /// Text inserted at position
79  FXchar *del; /// Text deleted at position
80  };
81 
82 
83 /**
84 * The text widget supports editing of multiple lines of text.
85 * An optional style table can provide text coloring based on
86 * the contents of an optional parallel style buffer, which is
87 * maintained as text is edited. In a typical scenario, the
88 * contents of the style buffer is either directly written when
89 * the text is added to the widget, or is continually modified
90 * by editing the text via syntax-based highlighting engine which
91 * colors the text based on syntactical patterns.
92 */
93 class FXAPI FXText : public FXScrollArea {
95 protected:
96  FXchar *buffer; // Text buffer being edited
97  FXchar *sbuffer; // Text style buffer
98  FXint *visrows; // Starts of rows in buffer
99  FXint length; // Length of the actual text in the buffer
100  FXint nvisrows; // Number of visible rows
101  FXint nrows; // Total number of rows
102  FXint gapstart; // Start of the insertion point (the gap)
103  FXint gapend; // End of the insertion point+1
104  FXint toppos; // Start position of first visible row
105  FXint keeppos; // Position to keep on top visible row
106  FXint toprow; // Row number of first visible row
107  FXint selstartpos; // Start of selection
108  FXint selendpos; // End of selection
109  FXint hilitestartpos; // Hightlight start position
110  FXint hiliteendpos; // Hightlight end position
111  FXint anchorpos; // Anchor position
112  FXint cursorpos; // Cursor position
113  FXint revertpos; // Position of cursor prior to dragging
114  FXint cursorstart; // Cursor row start pos
115  FXint cursorend; // Cursor row end pos
116  FXint cursorrow; // Cursor row
117  FXint cursorcol; // Cursor column indent (not character offset!)
118  FXint prefcol; // Preferred cursor column
119  FXint margintop; // Margins top
120  FXint marginbottom; // Margin bottom
121  FXint marginleft; // Margin left
122  FXint marginright; // Margin right
123  FXint wrapwidth; // Wrap width in pixels
124  FXint wrapcolumns; // Wrap columns
125  FXint tabwidth; // Tab width in pixels
126  FXint tabcolumns; // Tab columns
127  FXint barwidth; // Line number width
128  FXint barcolumns; // Line number columns
129  FXFont *font; // Text font
130  FXColor textColor; // Normal text color
131  FXColor selbackColor; // Select background color
132  FXColor seltextColor; // Select text color
133  FXColor hilitebackColor; // Highlight background color
134  FXColor hilitetextColor; // Highlight text color
135  FXColor activebackColor; // Background color for active line
136  FXColor numberColor; // Line number color
137  FXColor cursorColor; // Cursor color
138  FXColor barColor; // Bar background color
139  FXint textWidth; // Total width of all text
140  FXint textHeight; // Total height of all text
141  FXString searchstring; // String of last search
142  FXuint searchflags; // Flags of last search
143  const FXchar *delimiters; // Delimiters
144  FXString clipped; // Clipped text
145  FXint vrows; // Default visible rows
146  FXint vcols; // Default visible columns
147  FXString help; // Status line help
148  FXString tip; // Tooltip
149  const FXHiliteStyle *hilitestyles; // Style definitions
150  FXuint matchtime; // Match time (ms)
151  FXint grabx; // Grab point x
152  FXint graby; // Grab point y
153  FXuchar mode; // Mode widget is in
154  FXbool modified; // User has modified text
155 protected:
156  FXText();
157  void calcVisRows(FXint s,FXint e);
158  virtual void eraseCursorOverhang();
159  virtual void drawCursor(FXuint state);
160  virtual FXuint style(FXint row,FXint beg,FXint end,FXint pos) const;
161  virtual void drawBufferText(FXDCWindow& dc,FXint x,FXint y,FXint w,FXint h,FXint pos,FXint n,FXuint style) const;
162  virtual void fillBufferRect(FXDCWindow& dc,FXint x,FXint y,FXint w,FXint h,FXuint style) const;
163  virtual void drawTextRow(FXDCWindow& dc,FXint line,FXint left,FXint right) const;
164  virtual void drawContents(FXDCWindow& dc,FXint x,FXint y,FXint w,FXint h) const;
165  virtual void drawNumbers(FXDCWindow& dc,FXint x,FXint y,FXint w,FXint h) const;
166  FXint posToLine(FXint pos,FXint ln) const;
167  FXbool posVisible(FXint pos) const;
168  void updateRange(FXint beg,FXint end) const;
169  void movegap(FXint pos);
170  void sizegap(FXint sz);
171  void squeezegap();
172  FXint charWidth(FXwchar ch,FXint indent) const;
173  FXint wrap(FXint start) const;
174  FXint measureText(FXint start,FXint end,FXint& wmax,FXint& hmax) const;
175  FXint lineWidth(FXint pos,FXint n) const;
176  FXint getYOfPos(FXint pos) const;
177  FXint getXOfPos(FXint pos) const;
178  FXint changeBeg(FXint pos) const;
179  FXint changeEnd(FXint pos) const;
180  FXint indentFromPos(FXint start,FXint pos) const;
181  FXint posFromIndent(FXint start,FXint indent) const;
182  void mutation(FXint pos,FXint ncins,FXint ncdel,FXint nrins,FXint nrdel);
183  virtual void replace(FXint pos,FXint m,const FXchar *text,FXint n,FXint style);
184  void recompute();
185  FXint matchForward(FXint pos,FXint end,FXwchar l,FXwchar r,FXint level) const;
186  FXint matchBackward(FXint pos,FXint beg,FXwchar l,FXwchar r,FXint level) const;
187  FXint findMatching(FXint pos,FXint beg,FXint end,FXwchar ch,FXint level) const;
188  void flashMatching();
189  void moveContents(FXint x,FXint y);
190 protected:
191  enum {
192  STYLE_MASK = 0x00FF, // Mask color table
193  STYLE_TEXT = 0x0100, // Draw some content
194  STYLE_SELECTED = 0x0200, // Selected
195  STYLE_CONTROL = 0x0400, // Control character
196  STYLE_HILITE = 0x0800, // Highlighted
197  STYLE_ACTIVE = 0x1000 // Active
198  };
199  enum {
200  MOUSE_NONE, // No mouse operation
201  MOUSE_CHARS, // Selecting characters
202  MOUSE_WORDS, // Selecting words
203  MOUSE_LINES, // Selecting lines
204  MOUSE_SCROLL, // Scrolling
205  MOUSE_DRAG, // Dragging text
206  MOUSE_TRYDRAG // Tentative drag
207  };
208 public:
209  enum {
210  STYLE_UNDERLINE = 0x0001, /// Underline text
211  STYLE_STRIKEOUT = 0x0002, /// Strike out text
212  STYLE_BOLD = 0x0004 /// Bold text
213  };
214 private:
215  FXText(const FXText&);
216  FXText& operator=(const FXText&);
217 public:
218  long onPaint(FXObject*,FXSelector,void*);
219  long onFocusIn(FXObject*,FXSelector,void*);
220  long onFocusOut(FXObject*,FXSelector,void*);
221  long onLeftBtnPress(FXObject*,FXSelector,void*);
222  long onLeftBtnRelease(FXObject*,FXSelector,void*);
223  long onMiddleBtnPress(FXObject*,FXSelector,void*);
224  long onMiddleBtnRelease(FXObject*,FXSelector,void*);
225  long onRightBtnPress(FXObject*,FXSelector,void*);
226  long onRightBtnRelease(FXObject*,FXSelector,void*);
227  long onUngrabbed(FXObject*,FXSelector,void*);
228  long onMotion(FXObject*,FXSelector,void*);
229  long onBeginDrag(FXObject*,FXSelector,void*);
230  long onEndDrag(FXObject*,FXSelector,void*);
231  long onDragged(FXObject*,FXSelector,void*);
232  long onDNDEnter(FXObject*,FXSelector,void*);
233  long onDNDLeave(FXObject*,FXSelector,void*);
234  long onDNDMotion(FXObject*,FXSelector,void*);
235  long onDNDDrop(FXObject*,FXSelector,void*);
236  long onDNDRequest(FXObject*,FXSelector,void*);
237  long onSelectionLost(FXObject*,FXSelector,void*);
238  long onSelectionGained(FXObject*,FXSelector,void*);
239  long onSelectionRequest(FXObject*,FXSelector,void* ptr);
240  long onClipboardLost(FXObject*,FXSelector,void*);
241  long onClipboardGained(FXObject*,FXSelector,void*);
242  long onClipboardRequest(FXObject*,FXSelector,void*);
243  long onKeyPress(FXObject*,FXSelector,void*);
244  long onKeyRelease(FXObject*,FXSelector,void*);
245  long onBlink(FXObject*,FXSelector,void*);
246  long onFlash(FXObject*,FXSelector,void*);
247  long onAutoScroll(FXObject*,FXSelector,void*);
248  long onQueryHelp(FXObject*,FXSelector,void*);
249  long onQueryTip(FXObject*,FXSelector,void*);
250 
251  // Control commands
252  long onCmdToggleEditable(FXObject*,FXSelector,void*);
253  long onUpdToggleEditable(FXObject*,FXSelector,void*);
254  long onCmdToggleOverstrike(FXObject*,FXSelector,void*);
255  long onUpdToggleOverstrike(FXObject*,FXSelector,void*);
256  long onCmdCursorRow(FXObject*,FXSelector,void*);
257  long onUpdCursorRow(FXObject*,FXSelector,void*);
258  long onCmdCursorColumn(FXObject*,FXSelector,void*);
259  long onUpdCursorColumn(FXObject*,FXSelector,void*);
260  long onUpdHaveSelection(FXObject*,FXSelector,void*);
261  long onUpdSelectAll(FXObject*,FXSelector,void*);
262  long onCmdSetStringValue(FXObject*,FXSelector,void*);
263  long onCmdGetStringValue(FXObject*,FXSelector,void*);
264  long onCmdSearch(FXObject*,FXSelector,void*);
265  long onCmdReplace(FXObject*,FXSelector,void*);
266  long onCmdSearchNext(FXObject*,FXSelector,void*);
267  long onCmdSearchSel(FXObject*,FXSelector,void*);
268 
269  // Cursor movement
270  long onCmdCursorTop(FXObject*,FXSelector,void*);
271  long onCmdCursorBottom(FXObject*,FXSelector,void*);
272  long onCmdCursorHome(FXObject*,FXSelector,void*);
273  long onCmdCursorEnd(FXObject*,FXSelector,void*);
274  long onCmdCursorRight(FXObject*,FXSelector,void*);
275  long onCmdCursorLeft(FXObject*,FXSelector,void*);
276  long onCmdCursorUp(FXObject*,FXSelector,void*);
277  long onCmdCursorDown(FXObject*,FXSelector,void*);
278  long onCmdCursorWordLeft(FXObject*,FXSelector,void*);
279  long onCmdCursorWordRight(FXObject*,FXSelector,void*);
280  long onCmdCursorWordStart(FXObject*,FXSelector,void*);
281  long onCmdCursorWordEnd(FXObject*,FXSelector,void*);
282  long onCmdCursorPageDown(FXObject*,FXSelector,void*);
283  long onCmdCursorPageUp(FXObject*,FXSelector,void*);
284  long onCmdCursorScreenTop(FXObject*,FXSelector,void*);
285  long onCmdCursorScreenBottom(FXObject*,FXSelector,void*);
286  long onCmdCursorScreenCenter(FXObject*,FXSelector,void*);
287  long onCmdCursorParHome(FXObject*,FXSelector,void*);
288  long onCmdCursorParEnd(FXObject*,FXSelector,void*);
289  long onCmdBlockBeg(FXObject*,FXSelector,void*);
290  long onCmdBlockEnd(FXObject*,FXSelector,void*);
291  long onCmdGotoMatching(FXObject*,FXSelector,void*);
292  long onCmdGotoSelected(FXObject*,FXSelector,void*);
293  long onCmdGotoLine(FXObject*,FXSelector,void*);
294  long onCmdScrollUp(FXObject*,FXSelector,void*);
295  long onCmdScrollDown(FXObject*,FXSelector,void*);
296 
297  // Mark and extend
298  long onCmdMark(FXObject*,FXSelector,void*);
299  long onCmdExtend(FXObject*,FXSelector,void*);
300 
301  // Inserting
302  long onCmdOverstString(FXObject*,FXSelector,void*);
303  long onCmdInsertString(FXObject*,FXSelector,void*);
304  long onCmdInsertNewline(FXObject*,FXSelector,void*);
305  long onCmdInsertTab(FXObject*,FXSelector,void*);
307  // Manipulation Selection
308  long onCmdCutSel(FXObject*,FXSelector,void*);
309  long onCmdCopySel(FXObject*,FXSelector,void*);
310  long onCmdPasteSel(FXObject*,FXSelector,void*);
311  long onCmdDeleteSel(FXObject*,FXSelector,void*);
312  long onCmdChangeCase(FXObject*,FXSelector,void*);
313  long onCmdShiftText(FXObject*,FXSelector,void*);
314  long onCmdPasteMiddle(FXObject*,FXSelector,void*);
315 
316  // Changing Selection
317  long onCmdSelectChar(FXObject*,FXSelector,void*);
318  long onCmdSelectWord(FXObject*,FXSelector,void*);
319  long onCmdSelectLine(FXObject*,FXSelector,void*);
320  long onCmdSelectAll(FXObject*,FXSelector,void*);
321  long onCmdSelectMatching(FXObject*,FXSelector,void*);
322  long onCmdSelectBlock(FXObject*,FXSelector,void*);
323  long onCmdDeselectAll(FXObject*,FXSelector,void*);
325  // Deletion
326  long onCmdBackspace(FXObject*,FXSelector,void*);
327  long onCmdBackspaceWord(FXObject*,FXSelector,void*);
328  long onCmdBackspaceBol(FXObject*,FXSelector,void*);
329  long onCmdDelete(FXObject*,FXSelector,void*);
330  long onCmdDeleteWord(FXObject*,FXSelector,void*);
331  long onCmdDeleteEol(FXObject*,FXSelector,void*);
332  long onCmdDeleteAll(FXObject*,FXSelector,void*);
333  long onCmdDeleteLine(FXObject*,FXSelector,void*);
334 
335 public:
336  static const FXchar textDelimiters[];
337 
338 public:
339 
340  enum {
341  ID_CURSOR_TOP=FXScrollArea::ID_LAST,
342  ID_CURSOR_BOTTOM,
343  ID_CURSOR_HOME,
344  ID_CURSOR_END,
345  ID_CURSOR_RIGHT,
346  ID_CURSOR_LEFT,
347  ID_CURSOR_UP,
348  ID_CURSOR_DOWN,
349  ID_CURSOR_WORD_LEFT,
350  ID_CURSOR_WORD_RIGHT,
351  ID_CURSOR_WORD_START,
352  ID_CURSOR_WORD_END,
353  ID_CURSOR_PAGEDOWN,
354  ID_CURSOR_PAGEUP,
355  ID_CURSOR_SCRNTOP,
356  ID_CURSOR_SCRNBTM,
357  ID_CURSOR_SCRNCTR,
358  ID_CURSOR_PAR_HOME,
359  ID_CURSOR_PAR_END,
360  ID_SCROLL_UP,
361  ID_SCROLL_DOWN,
362  ID_MARK,
363  ID_EXTEND,
364  ID_OVERST_STRING,
365  ID_INSERT_STRING,
366  ID_INSERT_NEWLINE,
367  ID_INSERT_TAB,
368  ID_CUT_SEL,
369  ID_COPY_SEL,
370  ID_DELETE_SEL,
371  ID_PASTE_SEL,
372  ID_PASTE_MIDDLE,
373  ID_SELECT_CHAR,
374  ID_SELECT_WORD,
375  ID_SELECT_LINE,
376  ID_SELECT_ALL,
377  ID_SELECT_MATCHING,
378  ID_SELECT_BRACE,
379  ID_SELECT_BRACK,
380  ID_SELECT_PAREN,
381  ID_SELECT_ANG,
382  ID_DESELECT_ALL,
383  ID_BACKSPACE,
384  ID_BACKSPACE_WORD,
385  ID_BACKSPACE_BOL,
386  ID_DELETE,
387  ID_DELETE_WORD,
388  ID_DELETE_EOL,
389  ID_DELETE_ALL,
390  ID_DELETE_LINE,
391  ID_TOGGLE_EDITABLE,
392  ID_TOGGLE_OVERSTRIKE,
393  ID_CURSOR_ROW,
394  ID_CURSOR_COLUMN,
395  ID_CLEAN_INDENT,
396  ID_SHIFT_LEFT,
397  ID_SHIFT_RIGHT,
398  ID_SHIFT_TABLEFT,
399  ID_SHIFT_TABRIGHT,
400  ID_UPPER_CASE,
401  ID_LOWER_CASE,
402  ID_GOTO_MATCHING,
403  ID_GOTO_SELECTED,
404  ID_GOTO_LINE,
405  ID_SEARCH_FORW_SEL,
406  ID_SEARCH_BACK_SEL,
407  ID_SEARCH_FORW,
408  ID_SEARCH_BACK,
409  ID_SEARCH,
410  ID_REPLACE,
411  ID_LEFT_BRACE,
412  ID_LEFT_BRACK,
413  ID_LEFT_PAREN,
414  ID_LEFT_ANG,
415  ID_RIGHT_BRACE,
416  ID_RIGHT_BRACK,
417  ID_RIGHT_PAREN,
418  ID_RIGHT_ANG,
419  ID_BLINK,
420  ID_FLASH,
421  ID_LAST
422  };
424 public:
425 
426  /// Construct multi-line text widget
427  FXText(FXComposite *p,FXObject* tgt=NULL,FXSelector sel=0,FXuint opts=0,FXint x=0,FXint y=0,FXint w=0,FXint h=0,FXint pl=3,FXint pr=3,FXint pt=2,FXint pb=2);
428 
429  /// Create server-side resources
430  virtual void create();
431 
432  /// Detach server-side resources
433  virtual void detach();
434 
435  /// Perform layout
436  virtual void layout();
437 
438  /// Return default width
439  virtual FXint getDefaultWidth();
440 
441  /// Return default height
442  virtual FXint getDefaultHeight();
443 
444  /// Enable the text widget
445  virtual void enable();
446 
447  /// Disable the text widget
448  virtual void disable();
449 
450  /// Need to recalculate size
451  virtual void recalc();
452 
453  /// Get default width
454  virtual FXint getContentWidth();
455 
456  /// Get default height
457  virtual FXint getContentHeight();
458 
459  /// Returns true because a text widget can receive focus
460  virtual bool canFocus() const;
461 
462  /// Move the focus to this window
463  virtual void setFocus();
464 
465  /// Remove the focus from this window
466  virtual void killFocus();
467 
468  /// Change top margin
469  void setMarginTop(FXint pt);
470 
471  /// Return top margin
472  FXint getMarginTop() const { return margintop; }
473 
474  /// Change bottom margin
475  void setMarginBottom(FXint pb);
476 
477  /// Return bottom margin
478  FXint getMarginBottom() const { return marginbottom; }
479 
480  /// Change left margin
481  void setMarginLeft(FXint pl);
482 
483  /// Return left margin
484  FXint getMarginLeft() const { return marginleft; }
485 
486  /// Change right margin
487  void setMarginRight(FXint pr);
488 
489  /// Return right margin
490  FXint getMarginRight() const { return marginright; }
491 
492  /// Return wrap columns
493  FXint getWrapColumns() const { return wrapcolumns; }
494 
495  /// Set wrap columns
496  void setWrapColumns(FXint cols);
497 
498  /// Return tab columns
499  FXint getTabColumns() const { return tabcolumns; }
500 
501  /// Change tab columns
502  void setTabColumns(FXint cols);
503 
504  /// Return number of columns used for line numbers
505  FXint getBarColumns() const { return barcolumns; }
506 
507  /// Change number of columns used for line numbers
508  void setBarColumns(FXint cols);
509 
510  /// Return TRUE if text was modified
511  FXbool isModified() const { return modified; }
512 
513  /// Set modified flag
514  void setModified(FXbool mod=TRUE){ modified=mod; }
515 
516  /// Set editable mode
517  void setEditable(FXbool edit=TRUE);
518 
519  /// Return TRUE if text is editable
520  FXbool isEditable() const;
521 
522  /// Set overstrike mode
523  void setOverstrike(FXbool over=TRUE);
524 
525  /// Return TRUE if overstrike mode in effect
526  FXbool isOverstrike() const;
527 
528  /// Set styled text mode
529  void setStyled(FXbool styled=TRUE);
530 
531  /// Return TRUE if style buffer
532  FXbool isStyled() const { return (sbuffer!=NULL); }
533 
534  /// Change delimiters of words
535  void setDelimiters(const FXchar* delims=textDelimiters){ delimiters=delims; }
536 
537  /// Return word delimiters
538  const FXchar* getDelimiters() const { return delimiters; }
539 
540  /// Change text font
541  void setFont(FXFont* fnt);
542 
543  /// Return text font
544  FXFont* getFont() const { return font; }
545 
546  /// Change text color
547  void setTextColor(FXColor clr);
548 
549  /// Return text color
550  FXColor getTextColor() const { return textColor; }
551 
552  /// Change selected background color
553  void setSelBackColor(FXColor clr);
554 
555  /// Return selected background color
556  FXColor getSelBackColor() const { return selbackColor; }
557 
558  /// Change selected text color
559  void setSelTextColor(FXColor clr);
560 
561  /// Return selected text color
562  FXColor getSelTextColor() const { return seltextColor; }
563 
564  /// Change highlighted text color
565  void setHiliteTextColor(FXColor clr);
566 
567  /// Return highlighted text color
568  FXColor getHiliteTextColor() const { return hilitetextColor; }
569 
570  /// Change highlighted background color
571  void setHiliteBackColor(FXColor clr);
572 
573  /// Return highlighted background color
574  FXColor getHiliteBackColor() const { return hilitebackColor; }
575 
576  /// Change active background color
577  void setActiveBackColor(FXColor clr);
578 
579  /// Return active background color
580  FXColor getActiveBackColor() const { return activebackColor; }
581 
582  /// Change cursor color
583  void setCursorColor(FXColor clr);
584 
585  /// Return cursor color
586  FXColor getCursorColor() const { return cursorColor; }
587 
588  /// Change line number color
589  void setNumberColor(FXColor clr);
590 
591  /// Return line number color
592  FXColor getNumberColor() const { return numberColor; }
593 
594  /// Change bar color
595  void setBarColor(FXColor clr);
596 
597  /// Return bar color
598  FXColor getBarColor() const { return barColor; }
599 
600  /// Set help text
601  void setHelpText(const FXString& text){ help=text; }
602 
603  /// Return help text
604  FXString getHelpText() const { return help; }
605 
606  /// Set the tool tip message for this text widget
607  void setTipText(const FXString& text){ tip=text; }
608 
609  /// Get the tool tip message for this text widget
610  FXString getTipText() const { return tip; }
611 
612  /// Get character at position in text buffer
613  FXint getByte(FXint pos) const;
614 
615  /// Get wide character at position pos
616  FXwchar getChar(FXint pos) const;
617 
618  /// Get length of wide character at position pos
619  FXint getCharLen(FXint pos) const;
620 
621  /// Get style at position pos
622  FXint getStyle(FXint pos) const;
623 
624  /// Extract n bytes of text from position pos
625  void extractText(FXchar *text,FXint pos,FXint n) const;
626  void extractText(FXString& text,FXint pos,FXint n) const;
627 
628  /// Extract n bytes of style info from position pos
629  void extractStyle(FXString& text,FXint pos,FXint n) const;
630  void extractStyle(FXchar *style,FXint pos,FXint n) const;
631 
632  /// Replace m bytes at pos by n characters
633  virtual void replaceText(FXint pos,FXint m,const FXchar *text,FXint n,FXbool notify=FALSE);
634  virtual void replaceText(FXint pos,FXint m,const FXString& text,FXbool notify=FALSE);
635 
636  /// Replace m bytes at pos by n characters
637  virtual void replaceStyledText(FXint pos,FXint m,const FXchar *text,FXint n,FXint style=0,FXbool notify=FALSE);
638  virtual void replaceStyledText(FXint pos,FXint m,const FXString& text,FXint style=0,FXbool notify=FALSE);
639 
640  /// Append n bytes of text at the end of the buffer
641  virtual void appendText(const FXchar *text,FXint n,FXbool notify=FALSE);
642  virtual void appendText(const FXString& text,FXbool notify=FALSE);
643 
644  /// Append n bytes of text at the end of the buffer
645  virtual void appendStyledText(const FXchar *text,FXint n,FXint style=0,FXbool notify=FALSE);
646  virtual void appendStyledText(const FXString& text,FXint style=0,FXbool notify=FALSE);
647 
648  /// Insert n bytes of text at position pos into the buffer
649  virtual void insertText(FXint pos,const FXchar *text,FXint n,FXbool notify=FALSE);
650  virtual void insertText(FXint pos,const FXString& text,FXbool notify=FALSE);
651 
652  /// Insert n bytes of text at position pos into the buffer
653  virtual void insertStyledText(FXint pos,const FXchar *text,FXint n,FXint style=0,FXbool notify=FALSE);
654  virtual void insertStyledText(FXint pos,const FXString& text,FXint style=0,FXbool notify=FALSE);
655 
656  /// Remove n bytes of text at position pos from the buffer
657  virtual void removeText(FXint pos,FXint n,FXbool notify=FALSE);
659  /// Change style of text range
660  virtual void changeStyle(FXint pos,FXint n,FXint style);
661 
662  /// Change style of text range from style-array
663  virtual void changeStyle(FXint pos,const FXchar* style,FXint n);
664  virtual void changeStyle(FXint pos,const FXString& style);
665 
666  /// Change the text in the buffer to new text
667  virtual void setText(const FXchar* text,FXint n,FXbool notify=FALSE);
668  virtual void setText(const FXString& text,FXbool notify=FALSE);
669 
670  /// Change the text in the buffer to new text
671  virtual void setStyledText(const FXchar* text,FXint n,FXint style=0,FXbool notify=FALSE);
672  virtual void setStyledText(const FXString& text,FXint style=0,FXbool notify=FALSE);
673 
674  /// Retrieve text into buffer
675  void getText(FXchar* text,FXint n) const;
676  void getText(FXString& text) const;
677 
678  /// Return text in the widget
679  FXString getText() const;
680 
681  /// Return length of buffer
682  FXint getLength() const { return length; }
683 
684  /// Return number of rows in buffer
685  FXint getNumRows() const { return nrows; }
686 
687  /// Shift block of lines from position start up to end by given amount
688  FXint shiftText(FXint start,FXint end,FXint amount,FXbool notify=FALSE);
689 
690  /**
691  * Search for string in text buffer, returning the extent of
692  * the string in beg and end. The search starts from the given
693  * starting position, scans forward (SEARCH_FORWARD) or backward
694  * (SEARCH_BACKWARD), and wraps around if SEARCH_WRAP has been
695  * specified. The search type is either a plain search (SEARCH_EXACT),
696  * case insensitive search (SEARCH_IGNORECASE), or regular expression
697  * search (SEARCH_REGEX).
698  * For regular expression searches, capturing parentheses are used if
699  * npar is greater than 1; in this case, the number of entries in the
700  * beg[], end[] arrays must be npar also. If either beg or end or
701  * both are NULL, internal arrays are used.
702  * [This API is still subject to change!!]
703  */
704  FXbool findText(const FXString& string,FXint* beg=NULL,FXint* end=NULL,FXint start=0,FXuint flags=SEARCH_FORWARD|SEARCH_WRAP|SEARCH_EXACT,FXint npar=1);
705 
706  /// Return TRUE if position pos is selected
707  FXbool isPosSelected(FXint pos) const;
708 
709  /// Return TRUE if position is fully visible
710  FXbool isPosVisible(FXint pos) const;
711 
712  /// Return text position at given visible x,y coordinate
713  FXint getPosAt(FXint x,FXint y) const;
714 
715  /// Count number of rows; start should be on a row start
716  FXint countRows(FXint start,FXint end) const;
717 
718  /// Count number of columns; start should be on a row start
719  FXint countCols(FXint start,FXint end) const;
720 
721  /// Count number of newlines
722  FXint countLines(FXint start,FXint end) const;
723 
724  /// Return position of begin of line containing position pos
725  FXint lineStart(FXint pos) const;
726 
727  /// Return position of end of line containing position pos
728  FXint lineEnd(FXint pos) const;
729 
730  /// Return start of next line
731  FXint nextLine(FXint pos,FXint nl=1) const;
732 
733  /// Return start of previous line
734  FXint prevLine(FXint pos,FXint nl=1) const;
735 
736  /// Return row start
737  FXint rowStart(FXint pos) const;
738 
739  /// Return row end
740  FXint rowEnd(FXint pos) const;
741 
742  /// Return start of next row
743  FXint nextRow(FXint pos,FXint nr=1) const;
744 
745  /// Return start of previous row
746  FXint prevRow(FXint pos,FXint nr=1) const;
747 
748  /// Return end of previous word
749  FXint leftWord(FXint pos) const;
750 
751  /// Return begin of next word
752  FXint rightWord(FXint pos) const;
753 
754  /// Return begin of word
755  FXint wordStart(FXint pos) const;
756 
757  /// Return end of word
758  FXint wordEnd(FXint pos) const;
759 
760  /// Return validated utf8 character start position
761  FXint validPos(FXint pos) const;
762 
763  /// Retreat to the previous valid utf8 character start
764  FXint dec(FXint pos) const;
765 
766  /// Advance to the next valid utf8 character start
767  FXint inc(FXint pos) const;
768 
769  /// Make line containing pos the top line
770  void setTopLine(FXint pos);
771 
772  /// Return position of top line
773  FXint getTopLine() const;
774 
775  /// Make line containing pos the bottom line
776  void setBottomLine(FXint pos);
777 
778  /// Return the position of the bottom line
779  FXint getBottomLine() const;
780 
781  /// Make line containing pos the center line
782  void setCenterLine(FXint pos);
783 
784  /// Set the anchor position
785  void setAnchorPos(FXint pos);
786 
787  /// Return the anchor position
788  FXint getAnchorPos() const { return anchorpos; }
789 
790  /// Set the cursor position
791  virtual void setCursorPos(FXint pos,FXbool notify=FALSE);
792 
793  /// Set cursor row
794  void setCursorRow(FXint row,FXbool notify=FALSE);
795 
796  /// Return cursor row
797  FXint getCursorRow() const { return cursorrow; }
798 
799  /// Set cursor column
800  void setCursorColumn(FXint col,FXbool notify=FALSE);
801 
802  /// Return cursor row, i.e. indent position
803  FXint getCursorColumn() const { return cursorcol; }
804 
805  /// Return the cursor position
806  FXint getCursorPos() const { return cursorpos; }
807 
808  /// Return selstartpos
809  FXint getSelStartPos() const { return selstartpos; }
810 
811  /// Return selendpos
812  FXint getSelEndPos() const { return selendpos; }
813 
814  /// Select all text
815  FXbool selectAll(FXbool notify=FALSE);
816 
817  /// Extend the selection from the anchor to the given position
818  virtual FXbool extendSelection(FXint pos,FXTextSelectionMode select=SELECT_CHARS,FXbool notify=FALSE);
819 
820  /// Select len characters starting at given position pos
821  FXbool setSelection(FXint pos,FXint len,FXbool notify=FALSE);
822 
823  /// Unselect the text
824  virtual FXbool killSelection(FXbool notify=FALSE);
825 
826  /// Highlight len characters starting at given position pos
827  FXbool setHighlight(FXint start,FXint len);
828 
829  /// Unhighlight the text
830  FXbool killHighlight();
831 
832  /// Scroll text to make the given position visible
833  void makePositionVisible(FXint pos);
834 
835  /// Change text widget style
836  void setTextStyle(FXuint style);
837 
838  /// Return text widget style
839  FXuint getTextStyle() const;
840 
841  /// Change number of visible rows
842  void setVisibleRows(FXint rows);
843 
844  /// Return number of visible rows
845  FXint getVisibleRows() const { return vrows; }
846 
847  /// Change number of visible columns
848  void setVisibleColumns(FXint cols);
849 
850  /// Return number of visible columns
851  FXint getVisibleColumns() const { return vcols; }
852 
853  /**
854  * Change brace and parenthesis match highlighting time, in ms.
855  * A match highlight time of 0 disables brace matching.
856  */
857  void setHiliteMatchTime(FXuint t){ matchtime=t; }
858 
859  /**
860  * Return brace and parenthesis match highlighting time, in ms.
861  */
862  FXuint getHiliteMatchTime() const { return matchtime; }
863 
864  /// Set highlight styles
865  void setHiliteStyles(const FXHiliteStyle* styles);
866 
867  /// Get highlight styles
868  const FXHiliteStyle* getHiliteStyles() const { return hilitestyles; }
869 
870  /// Save to a stream
871  virtual void save(FXStream& store) const;
872 
873  /// Load from a stream
874  virtual void load(FXStream& store);
875 
876  /// Destructor
877  virtual ~FXText();
878  };
879 
880 
881 }
882 
883 #endif
The text widget supports editing of multiple lines of text.
Definition: FXText.h:105
Show active line.
Definition: FXText.h:45
Overstrike mode.
Definition: FXText.h:41
FXColor selectBackColor
Selected text foreground color.
Definition: FXText.h:68
Search forward (default)
Definition: fxdefs.h:370
char FXchar
Definition: fxdefs.h:387
Definition: FXText.h:58
FXColor normalBackColor
Normal text foreground color.
Definition: FXText.h:66
#define TRUE
Definition: fxdefs.h:32
Exact match (default)
Definition: fxdefs.h:374
Definition: FXWindow.h:241
unsigned int FXuint
Definition: fxdefs.h:396
FXuint FXSelector
Association key.
Definition: FXObject.h:53
Fixed wrap columns.
Definition: FXText.h:42
#define FXAPI
Definition: fxdefs.h:122
FXuchar FXbool
Definition: fxdefs.h:393
Highlight style entry.
Definition: FXText.h:64
Base composite.
Definition: FXComposite.h:35
FXint ndel
Position in buffer.
Definition: FXText.h:84
FXchar * ins
Number characters inserted at position.
Definition: FXText.h:86
#define NULL
Definition: fxdefs.h:41
FXuint FXColor
Definition: fxdefs.h:454
Insert spaces for tabs.
Definition: FXText.h:43
FXTextSelectionMode
Selection modes.
Definition: FXText.h:55
Wrap at word breaks.
Definition: FXText.h:40
FXColor hiliteForeColor
Selected text background color.
Definition: FXText.h:69
wchar_t FXwchar
Definition: fxdefs.h:411
Definition: FXText.h:57
Definition: FX4Splitter.h:31
int FXint
Definition: fxdefs.h:397
Text is NOT editable.
Definition: FXText.h:39
The scroll area widget manages a content area and a viewport area through which the content is viewed...
Definition: FXScrollArea.h:75
Definition: FXText.h:56
#define FALSE
Definition: fxdefs.h:35
FXColor normalForeColor
Definition: FXText.h:65
Text mutation callback data passed with the SEL_INSERTED, SEL_REPLACED, and SEL_DELETED messages; bot...
Definition: FXText.h:82
Object is the base class for all objects in FOX; in order to receive messages from the user interface...
Definition: FXObject.h:166
unsigned char FXuchar
Definition: fxdefs.h:392
Window Device Context.
Definition: FXDCWindow.h:52
Wrap around to start.
Definition: fxdefs.h:373
FXColor selectForeColor
Normal text background color.
Definition: FXText.h:67
FXColor activeBackColor
Highlight text background color.
Definition: FXText.h:71
FXchar * del
Text inserted at position.
Definition: FXText.h:87
FXint nins
Number characters deleted at position.
Definition: FXText.h:85
Autoindent.
Definition: FXText.h:44
FXint pos
Definition: FXText.h:83
Logging mode, keeping last line visible.
Definition: FXText.h:46
Font class.
Definition: FXFont.h:142
FXuint style
Active text background color.
Definition: FXText.h:72
FXColor hiliteBackColor
Highlight text foreground color.
Definition: FXText.h:70
#define FXDECLARE(classname)
Macro to set up class declaration.
Definition: FXObject.h:92
FXString provides essential string manipulation capabilities.
Definition: FXString.h:33

Copyright © 1997-2005 Jeroen van der Zijp