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

FXText.h
1 /********************************************************************************
2 * *
3 * M u l t i - L i n e T e x t W i d g e t *
4 * *
5 *********************************************************************************
6 * Copyright (C) 1998,2024 by Jeroen van der Zijp. All Rights Reserved. *
7 *********************************************************************************
8 * This library is free software; you can redistribute it and/or modify *
9 * it under the terms of the GNU Lesser General Public License as published by *
10 * the Free Software Foundation; either version 3 of the License, or *
11 * (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 *
16 * GNU Lesser General Public License for more details. *
17 * *
18 * You should have received a copy of the GNU Lesser General Public License *
19 * along with this program. If not, see <http://www.gnu.org/licenses/> *
20 ********************************************************************************/
21 #ifndef FXTEXT_H
22 #define FXTEXT_H
23 
24 #ifndef FXSCROLLAREA_H
25 #include "FXScrollArea.h"
26 #endif
27 
28 namespace FX {
29 
30 
32 enum {
33  TEXT_READONLY = 0x00100000,
34  TEXT_WORDWRAP = 0x00200000,
35  TEXT_OVERSTRIKE = 0x00400000,
36  TEXT_FIXEDWRAP = 0x00800000,
37  TEXT_NO_TABS = 0x01000000,
38  TEXT_AUTOINDENT = 0x02000000,
39  TEXT_SHOWACTIVE = 0x04000000,
40  TEXT_SHOWMATCH = 0x08000000,
41  };
42 
43 
45 struct FXHiliteStyle {
46  FXColor normalForeColor;
47  FXColor normalBackColor;
48  FXColor selectForeColor;
49  FXColor selectBackColor;
50  FXColor hiliteForeColor;
51  FXColor hiliteBackColor;
52  FXColor activeBackColor;
53  FXuint style;
54  };
55 
56 
63 struct FXTextChange {
64  FXint pos;
65  FXint ndel;
66  FXint nins;
67  const FXchar *del;
68  const FXchar *ins;
69  };
70 
71 
78  FXint startpos;
79  FXint endpos;
80  FXint startcol;
81  FXint endcol;
82  };
83 
84 
155 class FXAPI FXText : public FXScrollArea {
156  FXDECLARE(FXText)
157 protected:
158  FXchar *buffer; // Text buffer being edited
159  FXchar *sbuffer; // Text style buffer
160  FXint *visrows; // Starts of rows in buffer
161  FXint nvisrows; // Number of visible rows
162  FXint gapbeg; // Buffer gap begin
163  FXint gaplen; // Buffer gap length
164  FXint gapend; // Buffer gap end
165  FXint length; // Length of the actual text in the buffer
166  FXint nrows; // Total number of rows
167  FXint toppos; // Start position of first visible row
168  FXint toprow; // Row number of first visible row
169  FXint keeppos; // Position to keep on top visible row
170  FXTextSelection select; // Text selection
171  FXTextSelection hilite; // Text highlight
172  FXint anchorpos; // Anchor position
173  FXint anchorrow; // Anchor row
174  FXint anchorcol; // Anchor column (kept inside text)
175  FXint anchorvcol; // Unconstrained anchor column
176  FXint cursorpos; // Cursor position
177  FXint cursorrow; // Cursor row
178  FXint cursorcol; // Cursor column (kept inside text)
179  FXint cursorvcol; // Unconstrained cursor column
180  FXint prefcol; // Preferred cursor column
181  FXint margintop; // Margins top
182  FXint marginbottom; // Margin bottom
183  FXint marginleft; // Margin left
184  FXint marginright; // Margin right
185  FXint wrapwidth; // Wrap width in pixels
186  FXint wrapcolumns; // Wrap columns
187  FXint tabwidth; // Tab width in pixels
188  FXint tabcolumns; // Tab columns
189  FXint barwidth; // Line number width
190  FXint barcolumns; // Line number columns
191  FXFont *font; // Text font
192  FXColor textColor; // Normal text color
193  FXColor selbackColor; // Select background color
194  FXColor seltextColor; // Select text color
195  FXColor hilitebackColor; // Highlight background color
196  FXColor hilitetextColor; // Highlight text color
197  FXColor activebackColor; // Background color for active line
198  FXColor numberColor; // Line number color
199  FXColor cursorColor; // Cursor color
200  FXColor barColor; // Bar background color
201  FXint textWidth; // Total width of all text
202  FXint textHeight; // Total height of all text
203  const FXchar *delimiters; // Delimiters
204  FXString clipped; // Clipped text
205  FXint vrows; // Default visible rows
206  FXint vcols; // Default visible columns
207  FXString help; // Status line help
208  FXString tip; // Tooltip
209  FXHiliteStyle *hilitestyles; // Style definitions
210  FXuint blink; // Next cursor blink state
211  FXTime matchtime; // Match time (ns)
212  FXint grabx; // Grab point x
213  FXint graby; // Grab point y
214  FXuchar mode; // Mode widget is in
215  FXbool modified; // User has modified text
216 protected:
217  FXText();
218  void movegap(FXint pos);
219  void sizegap(FXint sz);
220  FXwchar nxtChar(FXint& pos) const;
221  FXwchar prvChar(FXint& pos) const;
222  FXint charWidth(FXwchar ch,FXint indent) const;
223  FXint xoffset(FXint start,FXint pos) const;
224  FXint wrap(FXint start) const;
225  FXint rowFromPos(FXint pos) const;
226  FXint posFromRow(FXint row) const;
227  FXint columnFromPos(FXint start,FXint pos) const;
228  FXint posFromColumn(FXint start,FXint col) const;
229  FXint indentOfLine(FXint start,FXint pos) const;
230  FXbool isdelimiter(FXwchar w) const;
231  FXint measureText(FXint start,FXint end,FXint& wmax,FXint& hmax) const;
232  void calcVisRows(FXint s,FXint e);
233  void recompute();
234  FXint matchForward(FXint pos,FXint end,FXwchar l,FXwchar r,FXint level) const;
235  FXint matchBackward(FXint pos,FXint beg,FXwchar l,FXwchar r,FXint level) const;
236  FXint findMatching(FXint pos,FXint beg,FXint end,FXwchar ch,FXint level) const;
237  void flashMatching();
238  void moveContents(FXint x,FXint y);
239  FXint changeBeg(FXint pos) const;
240  FXint changeEnd(FXint pos) const;
241  void mutation(FXint pos,FXint ncins,FXint ncdel,FXint nrins,FXint nrdel);
242  FXint overstruck(FXint start,FXint end,const FXchar *text,FXint num);
243  void drawCursor(FXuint state);
244  virtual void paintCursor(FXDCWindow& dc) const;
245  virtual void eraseCursor(FXDCWindow& dc) const;
246  virtual void eraseCursorOverhang();
247  virtual void drawBufferText(FXDCWindow& dc,FXint x,FXint y,FXint w,FXint h,FXint pos,FXint n,FXuint style) const;
248  virtual void fillBufferRect(FXDCWindow& dc,FXint x,FXint y,FXint w,FXint h,FXuint style) const;
249  virtual FXuint styleOf(FXint beg,FXint end,FXint row,FXint col,FXint pos) const;
250  virtual void drawTextRow(FXDCWindow& dc,FXint row) const;
251  virtual void drawContents(FXDCWindow& dc) const;
252  virtual void drawNumbers(FXDCWindow& dc) const;
253  virtual void replace(FXint pos,FXint del,const FXchar *text,FXint ins,FXint style);
254  void updateRow(FXint row) const;
255  void updateLines(FXint startpos,FXint endpos) const;
256  void updateRange(FXint startpos,FXint endpos) const;
257  FXint shiftText(FXint startpos,FXint endpos,FXint shift,FXbool notify);
258  FXbool deletePendingSelection(FXbool notify);
259 protected:
260  enum {
261  MOUSE_NONE, // No mouse operation
262  MOUSE_CHARS, // Selecting characters
263  MOUSE_WORDS, // Selecting words
264  MOUSE_LINES, // Selecting lines
265  MOUSE_BLOCK, // Select block
266  MOUSE_SCROLL, // Scrolling
267  MOUSE_DRAG, // Dragging text
268  MOUSE_TRYDRAG // Tentative drag
269  };
270 private:
271  FXText(const FXText&);
272  FXText& operator=(const FXText&);
273 public:
274  long onPaint(FXObject*,FXSelector,void*);
275  long onEnter(FXObject*,FXSelector,void*);
276  long onLeave(FXObject*,FXSelector,void*);
277  long onBlink(FXObject*,FXSelector,void*);
278  long onFlash(FXObject*,FXSelector,void*);
279  long onFocusIn(FXObject*,FXSelector,void*);
280  long onFocusOut(FXObject*,FXSelector,void*);
281  long onMotion(FXObject*,FXSelector,void*);
282  long onAutoScroll(FXObject*,FXSelector,void*);
283  long onLeftBtnPress(FXObject*,FXSelector,void*);
284  long onLeftBtnRelease(FXObject*,FXSelector,void*);
285  long onMiddleBtnPress(FXObject*,FXSelector,void*);
286  long onMiddleBtnRelease(FXObject*,FXSelector,void*);
287  long onRightBtnPress(FXObject*,FXSelector,void*);
288  long onRightBtnRelease(FXObject*,FXSelector,void*);
289  long onKeyPress(FXObject*,FXSelector,void*);
290  long onKeyRelease(FXObject*,FXSelector,void*);
291  long onUngrabbed(FXObject*,FXSelector,void*);
292  long onBeginDrag(FXObject*,FXSelector,void*);
293  long onEndDrag(FXObject*,FXSelector,void*);
294  long onDragged(FXObject*,FXSelector,void*);
295  long onDNDEnter(FXObject*,FXSelector,void*);
296  long onDNDLeave(FXObject*,FXSelector,void*);
297  long onDNDMotion(FXObject*,FXSelector,void*);
298  long onDNDDrop(FXObject*,FXSelector,void*);
299  long onDNDRequest(FXObject*,FXSelector,void*);
300  long onSelectionLost(FXObject*,FXSelector,void*);
301  long onSelectionGained(FXObject*,FXSelector,void*);
302  long onSelectionRequest(FXObject*,FXSelector,void* ptr);
303  long onClipboardLost(FXObject*,FXSelector,void*);
304  long onClipboardGained(FXObject*,FXSelector,void*);
305  long onClipboardRequest(FXObject*,FXSelector,void*);
306  long onCmdSetTip(FXObject*,FXSelector,void*);
307  long onCmdGetTip(FXObject*,FXSelector,void*);
308  long onCmdSetHelp(FXObject*,FXSelector,void*);
309  long onCmdGetHelp(FXObject*,FXSelector,void*);
310  long onQueryTip(FXObject*,FXSelector,void*);
311  long onQueryHelp(FXObject*,FXSelector,void*);
312  long onUpdIsEditable(FXObject*,FXSelector,void*);
313  long onUpdHaveSelection(FXObject*,FXSelector,void*);
314  long onUpdHaveEditableSelection(FXObject*,FXSelector,void*);
315  long onIMEStart(FXObject*,FXSelector,void*);
316  long onTipTimer(FXObject*,FXSelector,void*);
317 
318  // Value access
319  long onCmdSetStringValue(FXObject*,FXSelector,void*);
320  long onCmdGetStringValue(FXObject*,FXSelector,void*);
321 
322  // Cursor movement
323  long onCmdCursorTop(FXObject*,FXSelector,void*);
324  long onCmdCursorBottom(FXObject*,FXSelector,void*);
325  long onCmdCursorHome(FXObject*,FXSelector,void*);
326  long onCmdCursorEnd(FXObject*,FXSelector,void*);
327  long onCmdCursorRight(FXObject*,FXSelector,void*);
328  long onCmdCursorLeft(FXObject*,FXSelector,void*);
329  long onCmdCursorUp(FXObject*,FXSelector,void*);
330  long onCmdCursorDown(FXObject*,FXSelector,void*);
331  long onCmdCursorPageUp(FXObject*,FXSelector,void*);
332  long onCmdCursorPageDown(FXObject*,FXSelector,void*);
333  long onCmdCursorWordLeft(FXObject*,FXSelector,void*);
334  long onCmdCursorWordRight(FXObject*,FXSelector,void*);
335 
336  // Cursor shift-drag movement
337  long onCmdCursorShiftTop(FXObject*,FXSelector,void*);
338  long onCmdCursorShiftBottom(FXObject*,FXSelector,void*);
339  long onCmdCursorShiftHome(FXObject*,FXSelector,void*);
340  long onCmdCursorShiftEnd(FXObject*,FXSelector,void*);
341  long onCmdCursorShiftRight(FXObject*,FXSelector,void*);
342  long onCmdCursorShiftLeft(FXObject*,FXSelector,void*);
343  long onCmdCursorShiftUp(FXObject*,FXSelector,void*);
344  long onCmdCursorShiftDown(FXObject*,FXSelector,void*);
345  long onCmdCursorShiftPageUp(FXObject*,FXSelector,void*);
346  long onCmdCursorShiftPageDown(FXObject*,FXSelector,void*);
347  long onCmdCursorShiftWordLeft(FXObject*,FXSelector,void*);
348  long onCmdCursorShiftWordRight(FXObject*,FXSelector,void*);
349 
350  // Cursor alt-drag movement
351  long onCmdCursorAltUp(FXObject*,FXSelector,void*);
352  long onCmdCursorAltDown(FXObject*,FXSelector,void*);
353  long onCmdCursorAltLeft(FXObject*,FXSelector,void*);
354  long onCmdCursorAltRight(FXObject*,FXSelector,void*);
355 
356  // Positioning
357  long onCmdScrollUp(FXObject*,FXSelector,void*);
358  long onCmdScrollDown(FXObject*,FXSelector,void*);
359  long onCmdScrollTop(FXObject*,FXSelector,void*);
360  long onCmdScrollBottom(FXObject*,FXSelector,void*);
361  long onCmdScrollCenter(FXObject*,FXSelector,void*);
362 
363  // Inserting
364  long onCmdInsertString(FXObject*,FXSelector,void*);
365  long onCmdInsertNewline(FXObject*,FXSelector,void*);
366  long onCmdInsertNewlineOnly(FXObject*,FXSelector,void*);
367  long onCmdInsertNewlineIndent(FXObject*,FXSelector,void*);
368  long onCmdInsertTab(FXObject*,FXSelector,void*);
369  long onCmdInsertHardTab(FXObject*,FXSelector,void*);
370  long onCmdInsertSoftTab(FXObject*,FXSelector,void*);
371 
372  // Manipulation Selection
373  long onCmdCutSel(FXObject*,FXSelector,void*);
374  long onCmdCopySel(FXObject*,FXSelector,void*);
375  long onCmdPasteSel(FXObject*,FXSelector,void*);
376  long onCmdPasteMiddle(FXObject*,FXSelector,void*);
377  long onCmdDeleteSel(FXObject*,FXSelector,void*);
378  long onCmdSelectChar(FXObject*,FXSelector,void*);
379  long onCmdSelectWord(FXObject*,FXSelector,void*);
380  long onCmdSelectLine(FXObject*,FXSelector,void*);
381  long onCmdSelectMatching(FXObject*,FXSelector,void*);
382  long onCmdSelectEnclosing(FXObject*,FXSelector,void*);
383  long onCmdSelectAll(FXObject*,FXSelector,void*);
384  long onCmdDeselectAll(FXObject*,FXSelector,void*);
385 
386  // Deletion
387  long onCmdBackspaceChar(FXObject*,FXSelector,void*);
388  long onCmdBackspaceWord(FXObject*,FXSelector,void*);
389  long onCmdBackspaceBol(FXObject*,FXSelector,void*);
390  long onCmdDeleteChar(FXObject*,FXSelector,void*);
391  long onCmdDeleteWord(FXObject*,FXSelector,void*);
392  long onCmdDeleteEol(FXObject*,FXSelector,void*);
393  long onCmdDeleteAll(FXObject*,FXSelector,void*);
394  long onCmdDeleteLine(FXObject*,FXSelector,void*);
395 
396  // Control commands
397  long onCmdShiftText(FXObject*,FXSelector,void*);
398  long onCmdChangeCase(FXObject*,FXSelector,void*);
399  long onCmdCopyLine(FXObject*,FXSelector,void*);
400  long onCmdMoveLineUp(FXObject*,FXSelector,void*);
401  long onCmdMoveLineDown(FXObject*,FXSelector,void*);
402  long onCmdJoinLines(FXObject*,FXSelector,void*);
403  long onCmdBlockBeg(FXObject*,FXSelector,void*);
404  long onCmdBlockEnd(FXObject*,FXSelector,void*);
405  long onCmdGotoMatching(FXObject*,FXSelector,void*);
406  long onCmdCursorPos(FXObject*,FXSelector,void*);
407  long onUpdCursorPos(FXObject*,FXSelector,void*);
408  long onCmdCursorRow(FXObject*,FXSelector,void*);
409  long onUpdCursorRow(FXObject*,FXSelector,void*);
410  long onCmdCursorColumn(FXObject*,FXSelector,void*);
411  long onUpdCursorColumn(FXObject*,FXSelector,void*);
412  long onCmdToggleEditable(FXObject*,FXSelector,void*);
413  long onUpdToggleEditable(FXObject*,FXSelector,void*);
414  long onCmdToggleOverstrike(FXObject*,FXSelector,void*);
415  long onUpdToggleOverstrike(FXObject*,FXSelector,void*);
416  long onUpdTextRows(FXObject*,FXSelector,void*);
417  long onUpdTextSize(FXObject*,FXSelector,void*);
418 public:
419 
421  enum {
422  STYLE_MASK = 0x00FF, // Mask color table
423  STYLE_TEXT = 0x0100, // Draw some content
424  STYLE_SELECTED = 0x0200, // Selected
425  STYLE_CONTROL = 0x0400, // Control character
426  STYLE_HILITE = 0x0800, // Highlighted
427  STYLE_ACTIVE = 0x1000, // Active
428  STYLE_INSERT = 0x2000 // Column insert
429  };
430 
432  enum {
433  STYLE_UNDERLINE = 0x0001, // Underline text
434  STYLE_STRIKEOUT = 0x0002, // Strike out text
435  STYLE_BOLD = 0x0004 // Bold text
436  };
437 
439  enum {
440  SelectNone, // Select nothing
441  SelectChars, // Select characters
442  SelectWords, // Select words
443  SelectRows, // Select rows
444  SelectLines // Select lines
445  };
446 
448  static const FXchar textDelimiters[];
449 
450 public:
451  enum {
452  ID_CURSOR_TOP=FXScrollArea::ID_LAST,
453  ID_CURSOR_BOTTOM,
454  ID_CURSOR_HOME,
455  ID_CURSOR_END,
456  ID_CURSOR_RIGHT,
457  ID_CURSOR_LEFT,
458  ID_CURSOR_UP,
459  ID_CURSOR_DOWN,
460  ID_CURSOR_PAGEUP,
461  ID_CURSOR_PAGEDOWN,
462  ID_CURSOR_WORD_LEFT,
463  ID_CURSOR_WORD_RIGHT,
464  ID_CURSOR_SHIFT_TOP,
465  ID_CURSOR_SHIFT_BOTTOM,
466  ID_CURSOR_SHIFT_HOME,
467  ID_CURSOR_SHIFT_END,
468  ID_CURSOR_SHIFT_UP,
469  ID_CURSOR_SHIFT_DOWN,
470  ID_CURSOR_SHIFT_LEFT,
471  ID_CURSOR_SHIFT_RIGHT,
472  ID_CURSOR_SHIFT_PAGEUP,
473  ID_CURSOR_SHIFT_PAGEDOWN,
474  ID_CURSOR_SHIFT_WORD_LEFT,
475  ID_CURSOR_SHIFT_WORD_RIGHT,
476  ID_CURSOR_ALT_UP,
477  ID_CURSOR_ALT_DOWN,
478  ID_CURSOR_ALT_LEFT,
479  ID_CURSOR_ALT_RIGHT,
480  ID_SCROLL_UP,
481  ID_SCROLL_DOWN,
482  ID_SCROLL_TOP,
483  ID_SCROLL_BOTTOM,
484  ID_SCROLL_CENTER,
485  ID_INSERT_STRING,
486  ID_INSERT_NEWLINE,
487  ID_INSERT_NEWLINE_ONLY,
488  ID_INSERT_NEWLINE_INDENT,
489  ID_INSERT_TAB,
490  ID_INSERT_HARDTAB,
491  ID_INSERT_SOFTTAB,
492  ID_CUT_SEL,
493  ID_COPY_SEL,
494  ID_DELETE_SEL,
495  ID_PASTE_SEL,
496  ID_PASTE_MIDDLE,
497  ID_SELECT_CHAR,
498  ID_SELECT_WORD,
499  ID_SELECT_LINE,
500  ID_SELECT_ALL,
501  ID_SELECT_MATCHING,
502  ID_SELECT_BRACE,
503  ID_SELECT_BRACK,
504  ID_SELECT_PAREN,
505  ID_SELECT_ANG,
506  ID_DESELECT_ALL,
507  ID_BACKSPACE_CHAR,
508  ID_BACKSPACE_WORD,
509  ID_BACKSPACE_BOL,
510  ID_DELETE_CHAR,
511  ID_DELETE_WORD,
512  ID_DELETE_EOL,
513  ID_DELETE_ALL,
514  ID_DELETE_LINE,
515  ID_TOGGLE_EDITABLE,
516  ID_TOGGLE_OVERSTRIKE,
517  ID_CURSOR_POS,
518  ID_CURSOR_ROW,
519  ID_CURSOR_COLUMN,
520  ID_JOIN_LINES,
521  ID_SHIFT_LEFT,
522  ID_SHIFT_RIGHT,
523  ID_SHIFT_TABLEFT,
524  ID_SHIFT_TABRIGHT,
525  ID_CLEAN_INDENT,
526  ID_COPY_LINE,
527  ID_MOVE_LINE_UP,
528  ID_MOVE_LINE_DOWN,
529  ID_UPPER_CASE,
530  ID_LOWER_CASE,
531  ID_GOTO_MATCHING,
532  ID_LEFT_BRACE,
533  ID_LEFT_BRACK,
534  ID_LEFT_PAREN,
535  ID_LEFT_ANG,
536  ID_RIGHT_BRACE,
537  ID_RIGHT_BRACK,
538  ID_RIGHT_PAREN,
539  ID_RIGHT_ANG,
540  ID_BLINK,
541  ID_FLASH,
542  ID_TEXT_ROWS,
543  ID_TEXT_SIZE,
544  ID_LAST
545  };
546 public:
547 
549  FXText(FXComposite *p,FXObject* tgt=nullptr,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);
550 
552  virtual void create();
553 
555  virtual void detach();
556 
558  virtual FXint getContentWidth();
559 
561  virtual FXint getContentHeight();
562 
564  virtual FXint getVisibleX() const;
565 
567  virtual FXint getVisibleY() const;
568 
570  virtual FXint getVisibleWidth() const;
571 
573  virtual FXint getVisibleHeight() const;
574 
576  virtual FXint getDefaultWidth();
577 
579  virtual FXint getDefaultHeight();
580 
582  virtual void layout();
583 
585  virtual void enable();
586 
588  virtual void disable();
589 
591  virtual void recalc();
592 
594  virtual FXbool canFocus() const;
595 
597  virtual void setFocus();
598 
600  virtual void killFocus();
601 
603  void setModified(FXbool mod=true){ modified=mod; }
604 
606  FXbool isModified() const { return modified; }
607 
609  void setEditable(FXbool edit=true);
610 
612  FXbool isEditable() const;
613 
615  void setOverstrike(FXbool over=true);
616 
618  FXbool isOverstrike() const;
619 
621  FXint getLength() const { return length; }
622 
624  FXint getNumRows() const { return nrows; }
625 
627  FXint getByte(FXint pos) const;
628 
630  FXint getStyle(FXint pos) const;
631 
633  FXint getCharLen(FXint pos) const;
634 
636  FXwchar getChar(FXint pos) const;
637 
639  FXint dec(FXint pos) const;
640 
642  FXint inc(FXint pos) const;
643 
645  FXint lineStart(FXint pos) const;
646 
648  FXint lineEnd(FXint pos) const;
649 
651  FXint nextLine(FXint pos,FXint nl=1) const;
652 
654  FXint prevLine(FXint pos,FXint nl=1) const;
655 
657  FXint rowStart(FXint pos) const;
658 
660  FXint rowEnd(FXint pos) const;
661 
663  FXint nextRow(FXint pos,FXint nr=1) const;
664 
666  FXint prevRow(FXint pos,FXint nr=1) const;
667 
669  FXint leftWord(FXint pos) const;
670 
672  FXint rightWord(FXint pos) const;
673 
675  FXint wordStart(FXint pos) const;
676 
678  FXint wordEnd(FXint pos) const;
679 
681  FXint validPos(FXint pos) const;
682 
687  FXint countCols(FXint start,FXint end) const;
688 
693  FXint countRows(FXint start,FXint end) const;
694 
699  FXint countLines(FXint start,FXint end) const;
700 
702  virtual FXint setText(const FXchar* text,FXint num,FXbool notify=false);
703  virtual FXint setText(const FXString& text,FXbool notify=false);
704 
706  virtual FXint setStyledText(const FXchar* text,FXint num,FXint style=0,FXbool notify=false);
707  virtual FXint setStyledText(const FXString& text,FXint style=0,FXbool notify=false);
708 
710  virtual FXint changeStyle(FXint pos,FXint num,FXint style);
711 
713  virtual FXint changeStyle(FXint pos,const FXchar* style,FXint num);
714  virtual FXint changeStyle(FXint pos,const FXString& style);
715 
717  virtual FXint appendText(const FXchar *text,FXint num,FXbool notify=false);
718  virtual FXint appendText(const FXString& text,FXbool notify=false);
719 
721  virtual FXint appendStyledText(const FXchar *text,FXint num,FXint style=0,FXbool notify=false);
722  virtual FXint appendStyledText(const FXString& text,FXint style=0,FXbool notify=false);
723 
725  virtual FXint replaceText(FXint pos,FXint del,const FXchar *text,FXint ins,FXbool notify=false);
726  virtual FXint replaceText(FXint pos,FXint del,const FXString& text,FXbool notify=false);
727 
729  virtual FXint replaceStyledText(FXint pos,FXint del,const FXchar *text,FXint ins,FXint style=0,FXbool notify=false);
730  virtual FXint replaceStyledText(FXint pos,FXint del,const FXString& text,FXint style=0,FXbool notify=false);
731 
733  virtual FXint replaceTextBlock(FXint startpos,FXint endpos,FXint startcol,FXint endcol,const FXchar *text,FXint num,FXbool notify=false);
734  virtual FXint replaceTextBlock(FXint startpos,FXint endpos,FXint startcol,FXint endcol,const FXString& text,FXbool notify=false);
735 
737  virtual FXint replaceStyledTextBlock(FXint startpos,FXint endpos,FXint startcol,FXint endcol,const FXchar *text,FXint num,FXint style=0,FXbool notify=false);
738  virtual FXint replaceStyledTextBlock(FXint startpos,FXint endpos,FXint startcol,FXint endcol,const FXString& text,FXint style=0,FXbool notify=false);
739 
741  virtual FXint insertText(FXint pos,const FXchar *text,FXint num,FXbool notify=false);
742  virtual FXint insertText(FXint pos,const FXString& text,FXbool notify=false);
743 
745  virtual FXint insertStyledText(FXint pos,const FXchar *text,FXint num,FXint style=0,FXbool notify=false);
746  virtual FXint insertStyledText(FXint pos,const FXString& text,FXint style=0,FXbool notify=false);
747 
749  virtual FXint insertTextBlock(FXint startpos,FXint endpos,FXint startcol,const FXchar *text,FXint num,FXbool notify=false);
750  virtual FXint insertTextBlock(FXint startpos,FXint endpos,FXint startcol,const FXString& text,FXbool notify=false);
751 
753  virtual FXint insertStyledTextBlock(FXint startpos,FXint endpos,FXint startcol,const FXchar *text,FXint num,FXint style=0,FXbool notify=false);
754  virtual FXint insertStyledTextBlock(FXint startpos,FXint endpos,FXint startcol,const FXString& text,FXint style=0,FXbool notify=false);
755 
757  virtual FXint overstrikeTextBlock(FXint startpos,FXint endpos,FXint startcol,const FXchar *text,FXint num,FXbool notify=false);
758  virtual FXint overstrikeTextBlock(FXint startpos,FXint endpos,FXint startcol,const FXString& text,FXbool notify=false);
759 
761  virtual FXint overstrikeStyledTextBlock(FXint startpos,FXint endpos,FXint startcol,const FXchar *text,FXint num,FXint style=0,FXbool notify=false);
762  virtual FXint overstrikeStyledTextBlock(FXint startpos,FXint endpos,FXint startcol,const FXString& text,FXint style=0,FXbool notify=false);
763 
764 
766  FXString getText() const;
767 
769  void getText(FXchar* text,FXint num) const;
770 
772  void getText(FXString& text) const;
773 
775  void extractText(FXchar *text,FXint pos,FXint num) const;
776 
778  void extractText(FXString& text,FXint pos,FXint num) const;
779 
781  FXString extractText(FXint pos,FXint num) const;
782 
784  void extractStyle(FXchar *style,FXint pos,FXint num) const;
785 
787  void extractStyle(FXString& style,FXint pos,FXint num) const;
788 
790  FXString extractStyle(FXint pos,FXint num) const;
791 
793  void extractTextBlock(FXString& text,FXint startpos,FXint endpos,FXint startcol,FXint endcol) const;
794 
796  FXString extractTextBlock(FXint startpos,FXint endpos,FXint startcol,FXint endcol) const;
797 
798 
800  virtual FXint removeText(FXint pos,FXint num,FXbool notify=false);
801 
803  virtual FXint removeTextBlock(FXint startpos,FXint endpos,FXint startcol,FXint endcol,FXbool notify=false);
804 
806  virtual FXint clearText(FXbool notify=false);
807 
808 
810  virtual FXbool selectAll(FXbool notify=false);
811 
813  virtual FXbool setSelection(FXint pos,FXint len,FXbool notify=false);
814 
816  virtual FXbool extendSelection(FXint pos,FXuint sel=SelectChars,FXbool notify=false);
817 
819  virtual FXbool setBlockSelection(FXint trow,FXint lcol,FXint brow,FXint rcol,FXbool notify=false);
820 
822  virtual FXbool extendBlockSelection(FXint row,FXint col,FXbool notify=false);
823 
825  virtual FXbool setSelection(FXint spos,FXint epos,FXint scol,FXint ecol,FXbool notify=false);
826 
828  virtual FXbool killSelection(FXbool notify=false);
829 
830 
832  FXbool isPosSelected(FXint pos) const;
833 
835  FXbool isPosSelected(FXint pos,FXint col) const;
836 
838  FXint getSelStartPos() const { return select.startpos; }
839 
841  FXint getSelEndPos() const { return select.endpos; }
842 
844  FXint getSelStartColumn() const { return select.startcol; }
845 
847  FXint getSelEndColumn() const { return select.endcol; }
848 
849 
851  FXbool copySelection();
852 
854  FXbool cutSelection(FXbool notify=false);
855 
857  FXbool deleteSelection(FXbool notify=false);
858 
860  FXbool pasteSelection(FXbool notify=false);
861 
863  FXbool pasteClipboard(FXbool notify=false);
864 
866  FXbool replaceSelection(const FXString& text,FXbool notify=false);
867 
869  FXString getSelectedText() const;
870 
872  FXbool setHighlight(FXint start,FXint len);
873 
875  FXbool killHighlight();
876 
877 
879  void setTopLine(FXint pos);
880 
882  FXint getTopLine() const;
883 
885  void setBottomLine(FXint pos);
886 
888  FXint getBottomLine() const;
889 
891  void setCenterLine(FXint pos);
892 
894  FXbool isPosVisible(FXint pos) const;
895 
897  void makePositionVisible(FXint pos);
898 
899 
901  FXint getPosAt(FXint x,FXint y) const;
902 
904  FXint getPosContaining(FXint x,FXint y) const;
905 
907  FXint getXOfPos(FXint pos) const;
908 
910  FXint getYOfPos(FXint pos) const;
911 
920  FXint getRowColumnAt(FXint x,FXint y,FXint& row,FXint& col) const;
921 
923  FXint getXOfRowColumn(FXint row,FXint col) const;
924 
926  FXint getYOfRowColumn(FXint row,FXint col) const;
927 
928 
930  virtual void setCursorPos(FXint pos,FXbool notify=false);
931 
933  FXint getCursorPos() const { return cursorpos; }
934 
936  void setCursorRowColumn(FXint row,FXint col,FXbool notify=false);
937 
939  void setCursorRow(FXint row,FXbool notify=false);
940 
942  FXint getCursorRow() const { return cursorrow; }
943 
945  void setCursorColumn(FXint col,FXbool notify=false);
946 
948  FXint getCursorColumn() const { return cursorcol; }
949 
950 
952  void setAnchorPos(FXint pos);
953 
955  FXint getAnchorPos() const { return anchorpos; }
956 
958  void setAnchorRowColumn(FXint row,FXint col);
959 
961  FXint getAnchorRow() const { return anchorrow; }
962 
964  FXint getAnchorColumn() const { return anchorcol; }
965 
966 
968  void moveCursor(FXint pos,FXbool notify=false);
969 
971  void moveCursorRowColumn(FXint row,FXint col,FXbool notify=false);
972 
974  void moveCursorAndSelect(FXint pos,FXuint sel,FXbool notify=false);
975 
977  void moveCursorRowColumnAndSelect(FXint row,FXint col,FXbool notify=false);
978 
979 
992  FXbool findText(const FXString& string,FXint* beg=nullptr,FXint* end=nullptr,FXint start=0,FXuint flags=SEARCH_FORWARD|SEARCH_WRAP|SEARCH_EXACT,FXint npar=1);
993 
994 
996  void setTextStyle(FXuint style);
997 
999  FXuint getTextStyle() const;
1000 
1002  void setFont(FXFont* fnt);
1003 
1005  FXFont* getFont() const { return font; }
1006 
1008  void setVisibleRows(FXint rows);
1009 
1011  FXint getVisibleRows() const { return vrows; }
1012 
1014  void setVisibleColumns(FXint cols);
1015 
1017  FXint getVisibleColumns() const { return vcols; }
1018 
1020  void setMarginTop(FXint pt);
1021 
1023  FXint getMarginTop() const { return margintop; }
1024 
1026  void setMarginBottom(FXint pb);
1027 
1029  FXint getMarginBottom() const { return marginbottom; }
1030 
1032  void setMarginLeft(FXint pl);
1033 
1035  FXint getMarginLeft() const { return marginleft; }
1036 
1038  void setMarginRight(FXint pr);
1039 
1041  FXint getMarginRight() const { return marginright; }
1042 
1044  FXint getBarColumns() const { return barcolumns; }
1045 
1047  void setBarColumns(FXint cols);
1048 
1050  void setWrapColumns(FXint cols);
1051 
1053  FXint getWrapColumns() const { return wrapcolumns; }
1054 
1056  void setTabColumns(FXint cols);
1057 
1059  FXint getTabColumns() const { return tabcolumns; }
1060 
1062  void setTextColor(FXColor clr);
1063 
1065  FXColor getTextColor() const { return textColor; }
1066 
1068  void setSelBackColor(FXColor clr);
1069 
1071  FXColor getSelBackColor() const { return selbackColor; }
1072 
1074  void setSelTextColor(FXColor clr);
1075 
1077  FXColor getSelTextColor() const { return seltextColor; }
1078 
1080  void setHiliteTextColor(FXColor clr);
1081 
1083  FXColor getHiliteTextColor() const { return hilitetextColor; }
1084 
1086  void setHiliteBackColor(FXColor clr);
1087 
1089  FXColor getHiliteBackColor() const { return hilitebackColor; }
1090 
1092  void setActiveBackColor(FXColor clr);
1093 
1095  FXColor getActiveBackColor() const { return activebackColor; }
1096 
1098  void setCursorColor(FXColor clr);
1099 
1101  FXColor getCursorColor() const { return cursorColor; }
1102 
1104  void setNumberColor(FXColor clr);
1105 
1107  FXColor getNumberColor() const { return numberColor; }
1108 
1110  void setBarColor(FXColor clr);
1111 
1113  FXColor getBarColor() const { return barColor; }
1114 
1116  FXbool setStyled(FXbool styled=true);
1117 
1119  FXbool isStyled() const { return (sbuffer!=nullptr); }
1120 
1128  void setHiliteStyles(FXHiliteStyle* styles);
1129 
1131  FXHiliteStyle* getHiliteStyles() const { return hilitestyles; }
1132 
1141  void setHiliteMatchTime(FXTime t){ matchtime=t; }
1142 
1144  FXTime getHiliteMatchTime() const { return matchtime; }
1145 
1147  void setDelimiters(const FXchar* delims=textDelimiters){ delimiters=delims; }
1148 
1150  const FXchar* getDelimiters() const { return delimiters; }
1151 
1153  void setHelpText(const FXString& text){ help=text; }
1154 
1156  FXString getHelpText() const { return help; }
1157 
1159  void setTipText(const FXString& text){ tip=text; }
1160 
1162  FXString getTipText() const { return tip; }
1163 
1165  virtual void save(FXStream& store) const;
1166 
1168  virtual void load(FXStream& store);
1169 
1171  virtual ~FXText();
1172  };
1173 
1174 }
1175 
1176 #endif
The text widget provides a multi-line text editing control.
Definition: FXText.h:155
const FXchar * del
Number characters inserted at position.
Definition: FXText.h:67
FXint getSelStartColumn() const
Return selection start column.
Definition: FXText.h:844
void setHelpText(const FXString &text)
Set help text.
Definition: FXText.h:1153
FXbool isModified() const
Return true if text was modified.
Definition: FXText.h:606
FXColor selectBackColor
Selected text foreground color.
Definition: FXText.h:49
FXint getSelEndColumn() const
Return selection end column.
Definition: FXText.h:847
FXint getVisibleRows() const
Return number of visible rows.
Definition: FXText.h:1011
FXint getSelEndPos() const
Return selection end position.
Definition: FXText.h:841
FXint getTabColumns() const
Return tab columns.
Definition: FXText.h:1059
FXColor normalBackColor
Normal text foreground color.
Definition: FXText.h:47
FXint getLength() const
Return length of buffer.
Definition: FXText.h:621
FXColor getBarColor() const
Return bar color.
Definition: FXText.h:1113
FXbool isStyled() const
Return true if style buffer.
Definition: FXText.h:1119
FXString getHelpText() const
Return help text.
Definition: FXText.h:1156
FXint getSelStartPos() const
Return selection start position.
Definition: FXText.h:838
FXint getCursorRow() const
Return cursor row.
Definition: FXText.h:942
FXint getMarginBottom() const
Return bottom margin.
Definition: FXText.h:1029
void setTipText(const FXString &text)
Set the tool tip message for this text widget.
Definition: FXText.h:1159
Highlight style entry.
Definition: FXText.h:45
Base composite.
Definition: FXComposite.h:32
FXint ndel
Position in buffer.
Definition: FXText.h:65
FXint getWrapColumns() const
Return wrap columns.
Definition: FXText.h:1053
const FXchar * ins
Text deleted at position.
Definition: FXText.h:68
FXColor getSelBackColor() const
Return selected background color.
Definition: FXText.h:1071
A stream is a way to serialize data and objects into a byte stream.
Definition: FXStream.h:81
const FXchar * getDelimiters() const
Return word delimiters.
Definition: FXText.h:1150
FXColor getTextColor() const
Return text color.
Definition: FXText.h:1065
FXColor getCursorColor() const
Return cursor color.
Definition: FXText.h:1101
FXint getMarginTop() const
Return top margin.
Definition: FXText.h:1023
FXColor hiliteForeColor
Selected text background color.
Definition: FXText.h:50
Definition: FX4Splitter.h:28
FXColor getSelTextColor() const
Return selected text color.
Definition: FXText.h:1077
FXHiliteStyle * getHiliteStyles() const
Return current value of the style table.
Definition: FXText.h:1131
FXint getMarginLeft() const
Return left margin.
Definition: FXText.h:1035
FXColor getHiliteTextColor() const
Return highlighted text color.
Definition: FXText.h:1083
void setModified(FXbool mod=true)
Set modified flag.
Definition: FXText.h:603
FXint getAnchorColumn() const
Return anchor row.
Definition: FXText.h:964
FXint endpos
Start of selection (begin of first line if block-select)
Definition: FXText.h:79
FXFont * getFont() const
Return text font.
Definition: FXText.h:1005
The scroll area widget manages a content area and a viewport area through which the content is viewed...
Definition: FXScrollArea.h:69
void setDelimiters(const FXchar *delims=textDelimiters)
Change delimiters of words.
Definition: FXText.h:1147
FXint endcol
Start column, if block-select (actually, indent)
Definition: FXText.h:81
FXint getVisibleColumns() const
Return number of visible columns.
Definition: FXText.h:1017
Text selection data.
Definition: FXText.h:77
Text mutation callback data passed with the SEL_INSERTED, SEL_REPLACED, and SEL_DELETED messages; bot...
Definition: FXText.h:63
FXColor getActiveBackColor() const
Return active background color.
Definition: FXText.h:1095
Object is the base class for all objects in FOX; in order to receive messages from the user interface...
Definition: FXObject.h:134
Window Device Context.
Definition: FXDCWindow.h:48
FXint getCursorPos() const
Return the cursor position.
Definition: FXText.h:933
FXint getAnchorRow() const
Return anchor row.
Definition: FXText.h:961
FXint startcol
End of selection (start of line past last if block-select)
Definition: FXText.h:80
FXint getCursorColumn() const
Return cursor row, i.e. indent position.
Definition: FXText.h:948
FXTime getHiliteMatchTime() const
Return brace and parenthesis match highlighting time, in nanoseconds.
Definition: FXText.h:1144
FXint getNumRows() const
Return number of rows in buffer.
Definition: FXText.h:624
FXString getTipText() const
Get the tool tip message for this text widget.
Definition: FXText.h:1162
FXColor selectForeColor
Normal text background color.
Definition: FXText.h:48
FXColor activeBackColor
Highlight text background color.
Definition: FXText.h:52
FXint nins
Number characters deleted at position.
Definition: FXText.h:66
FXint getAnchorPos() const
Return the anchor position.
Definition: FXText.h:955
void setHiliteMatchTime(FXTime t)
Change brace and parenthesis match highlighting time, in nanoseconds.
Definition: FXText.h:1141
FXint getMarginRight() const
Return right margin.
Definition: FXText.h:1041
FXColor getNumberColor() const
Return line number color.
Definition: FXText.h:1107
Font class.
Definition: FXFont.h:137
FXint getBarColumns() const
Return number of columns used for line numbers.
Definition: FXText.h:1044
FXuint style
Active text background color.
Definition: FXText.h:53
FXColor getHiliteBackColor() const
Return highlighted background color.
Definition: FXText.h:1089
FXColor hiliteBackColor
Highlight text foreground color.
Definition: FXText.h:51
FXString provides essential string manipulation capabilities in FOX.
Definition: FXString.h:42

Copyright © 1997-2022 Jeroen van der Zijp