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,2021 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  FXchar *ins;
68  FXchar *del;
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 length; // Length of the actual text in the buffer
162  FXint nvisrows; // Number of visible rows
163  FXint nrows; // Total number of rows
164  FXint gapstart; // Start of the insertion point (the gap)
165  FXint gapend; // End of the insertion point+1
166  FXint toppos; // Start position of first visible row
167  FXint toprow; // Row number of first visible row
168  FXint keeppos; // Position to keep on top visible row
169  FXTextSelection select; // Text selection
170  FXTextSelection hilite; // Text highlight
171  FXint anchorpos; // Anchor position
172  FXint anchorrow; // Anchor row
173  FXint anchorcol; // Anchor column (kept inside text)
174  FXint anchorvcol; // Unconstrained anchor column
175  FXint cursorpos; // Cursor position
176  FXint cursorrow; // Cursor row
177  FXint cursorcol; // Cursor column (kept inside text)
178  FXint cursorvcol; // Unconstrained cursor column
179  FXint prefcol; // Preferred cursor column
180  FXint margintop; // Margins top
181  FXint marginbottom; // Margin bottom
182  FXint marginleft; // Margin left
183  FXint marginright; // Margin right
184  FXint wrapwidth; // Wrap width in pixels
185  FXint wrapcolumns; // Wrap columns
186  FXint tabwidth; // Tab width in pixels
187  FXint tabcolumns; // Tab columns
188  FXint barwidth; // Line number width
189  FXint barcolumns; // Line number columns
190  FXFont *font; // Text font
191  FXColor textColor; // Normal text color
192  FXColor selbackColor; // Select background color
193  FXColor seltextColor; // Select text color
194  FXColor hilitebackColor; // Highlight background color
195  FXColor hilitetextColor; // Highlight text color
196  FXColor activebackColor; // Background color for active line
197  FXColor numberColor; // Line number color
198  FXColor cursorColor; // Cursor color
199  FXColor barColor; // Bar background color
200  FXint textWidth; // Total width of all text
201  FXint textHeight; // Total height of all text
202  const FXchar *delimiters; // Delimiters
203  FXString clipped; // Clipped text
204  FXint vrows; // Default visible rows
205  FXint vcols; // Default visible columns
206  FXString help; // Status line help
207  FXString tip; // Tooltip
208  FXHiliteStyle *hilitestyles; // Style definitions
209  FXuint blink; // Next cursor blink state
210  FXTime matchtime; // Match time (ns)
211  FXint grabx; // Grab point x
212  FXint graby; // Grab point y
213  FXuchar mode; // Mode widget is in
214  FXbool modified; // User has modified text
215 protected:
216  FXText();
217  void movegap(FXint pos);
218  void sizegap(FXint sz);
219  FXint charWidth(FXwchar ch,FXint indent) const;
220  FXint xoffset(FXint start,FXint pos) const;
221  FXint wrap(FXint start) const;
222  FXint rowFromPos(FXint pos) const;
223  FXint posFromRow(FXint row) const;
224  FXint columnFromPos(FXint start,FXint pos) const;
225  FXint posFromColumn(FXint start,FXint col) const;
226  FXbool isdelimiter(FXwchar w) const;
227  FXint measureText(FXint start,FXint end,FXint& wmax,FXint& hmax) const;
228  void calcVisRows(FXint s,FXint e);
229  void recompute();
230  FXint matchForward(FXint pos,FXint end,FXwchar l,FXwchar r,FXint level) const;
231  FXint matchBackward(FXint pos,FXint beg,FXwchar l,FXwchar r,FXint level) const;
232  FXint findMatching(FXint pos,FXint beg,FXint end,FXwchar ch,FXint level) const;
233  void flashMatching();
234  void moveContents(FXint x,FXint y);
235  FXint changeBeg(FXint pos) const;
236  FXint changeEnd(FXint pos) const;
237  void mutation(FXint pos,FXint ncins,FXint ncdel,FXint nrins,FXint nrdel);
238  FXint overstruck(FXint start,FXint end,const FXchar *text,FXint num);
239  void drawCursor(FXuint state);
240  virtual void paintCursor(FXDCWindow& dc) const;
241  virtual void eraseCursor(FXDCWindow& dc) const;
242  virtual void eraseCursorOverhang();
243  virtual void drawBufferText(FXDCWindow& dc,FXint x,FXint y,FXint w,FXint h,FXint pos,FXint n,FXuint style) const;
244  virtual void fillBufferRect(FXDCWindow& dc,FXint x,FXint y,FXint w,FXint h,FXuint style) const;
245  virtual FXuint styleOf(FXint beg,FXint end,FXint row,FXint col,FXint pos) const;
246  virtual void drawTextRow(FXDCWindow& dc,FXint row) const;
247  virtual void drawContents(FXDCWindow& dc) const;
248  virtual void drawNumbers(FXDCWindow& dc) const;
249  virtual void replace(FXint pos,FXint del,const FXchar *text,FXint ins,FXint style);
250  void updateRow(FXint row) const;
251  void updateLines(FXint startpos,FXint endpos) const;
252  void updateRange(FXint startpos,FXint endpos) const;
253  FXint shiftText(FXint startpos,FXint endpos,FXint shift,FXbool notify);
254  FXint caseShift(FXint startpos,FXint endpos,FXint upper,FXbool notify);
255  FXbool deletePendingSelection(FXbool notify);
256 protected:
257  enum {
258  MOUSE_NONE, // No mouse operation
259  MOUSE_CHARS, // Selecting characters
260  MOUSE_WORDS, // Selecting words
261  MOUSE_LINES, // Selecting lines
262  MOUSE_BLOCK, // Select block
263  MOUSE_SCROLL, // Scrolling
264  MOUSE_DRAG, // Dragging text
265  MOUSE_TRYDRAG // Tentative drag
266  };
267 protected:
268  enum {
269  STYLE_MASK = 0x00FF, // Mask color table
270  STYLE_TEXT = 0x0100, // Draw some content
271  STYLE_SELECTED = 0x0200, // Selected
272  STYLE_CONTROL = 0x0400, // Control character
273  STYLE_HILITE = 0x0800, // Highlighted
274  STYLE_ACTIVE = 0x1000, // Active
275  STYLE_INSERT = 0x2000 // Column insert
276  };
277 public:
278  enum {
279  STYLE_UNDERLINE = 0x0001,
280  STYLE_STRIKEOUT = 0x0002,
281  STYLE_BOLD = 0x0004
282  };
283 private:
284  FXText(const FXText&);
285  FXText& operator=(const FXText&);
286 public:
287  long onPaint(FXObject*,FXSelector,void*);
288  long onEnter(FXObject*,FXSelector,void*);
289  long onLeave(FXObject*,FXSelector,void*);
290  long onBlink(FXObject*,FXSelector,void*);
291  long onFlash(FXObject*,FXSelector,void*);
292  long onFocusIn(FXObject*,FXSelector,void*);
293  long onFocusOut(FXObject*,FXSelector,void*);
294  long onMotion(FXObject*,FXSelector,void*);
295  long onAutoScroll(FXObject*,FXSelector,void*);
296  long onLeftBtnPress(FXObject*,FXSelector,void*);
297  long onLeftBtnRelease(FXObject*,FXSelector,void*);
298  long onMiddleBtnPress(FXObject*,FXSelector,void*);
299  long onMiddleBtnRelease(FXObject*,FXSelector,void*);
300  long onRightBtnPress(FXObject*,FXSelector,void*);
301  long onRightBtnRelease(FXObject*,FXSelector,void*);
302  long onKeyPress(FXObject*,FXSelector,void*);
303  long onKeyRelease(FXObject*,FXSelector,void*);
304  long onUngrabbed(FXObject*,FXSelector,void*);
305  long onBeginDrag(FXObject*,FXSelector,void*);
306  long onEndDrag(FXObject*,FXSelector,void*);
307  long onDragged(FXObject*,FXSelector,void*);
308  long onDNDEnter(FXObject*,FXSelector,void*);
309  long onDNDLeave(FXObject*,FXSelector,void*);
310  long onDNDMotion(FXObject*,FXSelector,void*);
311  long onDNDDrop(FXObject*,FXSelector,void*);
312  long onDNDRequest(FXObject*,FXSelector,void*);
313  long onSelectionLost(FXObject*,FXSelector,void*);
314  long onSelectionGained(FXObject*,FXSelector,void*);
315  long onSelectionRequest(FXObject*,FXSelector,void* ptr);
316  long onClipboardLost(FXObject*,FXSelector,void*);
317  long onClipboardGained(FXObject*,FXSelector,void*);
318  long onClipboardRequest(FXObject*,FXSelector,void*);
319  long onCmdSetTip(FXObject*,FXSelector,void*);
320  long onCmdGetTip(FXObject*,FXSelector,void*);
321  long onCmdSetHelp(FXObject*,FXSelector,void*);
322  long onCmdGetHelp(FXObject*,FXSelector,void*);
323  long onQueryTip(FXObject*,FXSelector,void*);
324  long onQueryHelp(FXObject*,FXSelector,void*);
325  long onUpdIsEditable(FXObject*,FXSelector,void*);
326  long onUpdHaveSelection(FXObject*,FXSelector,void*);
327  long onUpdHaveEditableSelection(FXObject*,FXSelector,void*);
328  long onIMEStart(FXObject*,FXSelector,void*);
329  long onTipTimer(FXObject*,FXSelector,void*);
330 
331  // Value access
332  long onCmdSetStringValue(FXObject*,FXSelector,void*);
333  long onCmdGetStringValue(FXObject*,FXSelector,void*);
334 
335  // Cursor movement
336  long onCmdCursorTop(FXObject*,FXSelector,void*);
337  long onCmdCursorBottom(FXObject*,FXSelector,void*);
338  long onCmdCursorHome(FXObject*,FXSelector,void*);
339  long onCmdCursorEnd(FXObject*,FXSelector,void*);
340  long onCmdCursorRight(FXObject*,FXSelector,void*);
341  long onCmdCursorLeft(FXObject*,FXSelector,void*);
342  long onCmdCursorUp(FXObject*,FXSelector,void*);
343  long onCmdCursorDown(FXObject*,FXSelector,void*);
344  long onCmdCursorPageUp(FXObject*,FXSelector,void*);
345  long onCmdCursorPageDown(FXObject*,FXSelector,void*);
346  long onCmdCursorWordLeft(FXObject*,FXSelector,void*);
347  long onCmdCursorWordRight(FXObject*,FXSelector,void*);
348 
349  // Cursor shift-drag movement
350  long onCmdCursorShiftTop(FXObject*,FXSelector,void*);
351  long onCmdCursorShiftBottom(FXObject*,FXSelector,void*);
352  long onCmdCursorShiftHome(FXObject*,FXSelector,void*);
353  long onCmdCursorShiftEnd(FXObject*,FXSelector,void*);
354  long onCmdCursorShiftRight(FXObject*,FXSelector,void*);
355  long onCmdCursorShiftLeft(FXObject*,FXSelector,void*);
356  long onCmdCursorShiftUp(FXObject*,FXSelector,void*);
357  long onCmdCursorShiftDown(FXObject*,FXSelector,void*);
358  long onCmdCursorShiftPageUp(FXObject*,FXSelector,void*);
359  long onCmdCursorShiftPageDown(FXObject*,FXSelector,void*);
360  long onCmdCursorShiftWordLeft(FXObject*,FXSelector,void*);
361  long onCmdCursorShiftWordRight(FXObject*,FXSelector,void*);
362 
363  // Cursor alt-drag movement
364  long onCmdCursorAltUp(FXObject*,FXSelector,void*);
365  long onCmdCursorAltDown(FXObject*,FXSelector,void*);
366  long onCmdCursorAltLeft(FXObject*,FXSelector,void*);
367  long onCmdCursorAltRight(FXObject*,FXSelector,void*);
368 
369  // Positioning
370  long onCmdScrollUp(FXObject*,FXSelector,void*);
371  long onCmdScrollDown(FXObject*,FXSelector,void*);
372  long onCmdScrollTop(FXObject*,FXSelector,void*);
373  long onCmdScrollBottom(FXObject*,FXSelector,void*);
374  long onCmdScrollCenter(FXObject*,FXSelector,void*);
375 
376  // Inserting
377  long onCmdInsertString(FXObject*,FXSelector,void*);
378  long onCmdInsertNewline(FXObject*,FXSelector,void*);
379  long onCmdInsertNewlineOnly(FXObject*,FXSelector,void*);
380  long onCmdInsertNewlineIndent(FXObject*,FXSelector,void*);
381  long onCmdInsertTab(FXObject*,FXSelector,void*);
382  long onCmdInsertHardTab(FXObject*,FXSelector,void*);
383  long onCmdInsertSoftTab(FXObject*,FXSelector,void*);
384 
385  // Manipulation Selection
386  long onCmdCutSel(FXObject*,FXSelector,void*);
387  long onCmdCopySel(FXObject*,FXSelector,void*);
388  long onCmdPasteSel(FXObject*,FXSelector,void*);
389  long onCmdPasteMiddle(FXObject*,FXSelector,void*);
390  long onCmdDeleteSel(FXObject*,FXSelector,void*);
391  long onCmdSelectChar(FXObject*,FXSelector,void*);
392  long onCmdSelectWord(FXObject*,FXSelector,void*);
393  long onCmdSelectLine(FXObject*,FXSelector,void*);
394  long onCmdSelectMatching(FXObject*,FXSelector,void*);
395  long onCmdSelectEnclosing(FXObject*,FXSelector,void*);
396  long onCmdSelectAll(FXObject*,FXSelector,void*);
397  long onCmdDeselectAll(FXObject*,FXSelector,void*);
398 
399  // Deletion
400  long onCmdBackspaceChar(FXObject*,FXSelector,void*);
401  long onCmdBackspaceWord(FXObject*,FXSelector,void*);
402  long onCmdBackspaceBol(FXObject*,FXSelector,void*);
403  long onCmdDeleteChar(FXObject*,FXSelector,void*);
404  long onCmdDeleteWord(FXObject*,FXSelector,void*);
405  long onCmdDeleteEol(FXObject*,FXSelector,void*);
406  long onCmdDeleteAll(FXObject*,FXSelector,void*);
407  long onCmdDeleteLine(FXObject*,FXSelector,void*);
408 
409  // Control commands
410  long onCmdShiftText(FXObject*,FXSelector,void*);
411  long onCmdChangeCase(FXObject*,FXSelector,void*);
412  long onCmdCopyLine(FXObject*,FXSelector,void*);
413  long onCmdMoveLineUp(FXObject*,FXSelector,void*);
414  long onCmdMoveLineDown(FXObject*,FXSelector,void*);
415  long onCmdJoinLines(FXObject*,FXSelector,void*);
416  long onCmdBlockBeg(FXObject*,FXSelector,void*);
417  long onCmdBlockEnd(FXObject*,FXSelector,void*);
418  long onCmdGotoMatching(FXObject*,FXSelector,void*);
419  long onCmdCursorRow(FXObject*,FXSelector,void*);
420  long onUpdCursorRow(FXObject*,FXSelector,void*);
421  long onCmdCursorColumn(FXObject*,FXSelector,void*);
422  long onUpdCursorColumn(FXObject*,FXSelector,void*);
423  long onCmdToggleEditable(FXObject*,FXSelector,void*);
424  long onUpdToggleEditable(FXObject*,FXSelector,void*);
425  long onCmdToggleOverstrike(FXObject*,FXSelector,void*);
426  long onUpdToggleOverstrike(FXObject*,FXSelector,void*);
427 public:
428  static const FXchar textDelimiters[];
429 
430 public:
431 
433  enum {
434  SelectNone,
438  SelectLines
439  };
440 
441 public:
442 
443  enum {
444  ID_CURSOR_TOP=FXScrollArea::ID_LAST,
445  ID_CURSOR_BOTTOM,
446  ID_CURSOR_HOME,
447  ID_CURSOR_END,
448  ID_CURSOR_RIGHT,
449  ID_CURSOR_LEFT,
450  ID_CURSOR_UP,
451  ID_CURSOR_DOWN,
452  ID_CURSOR_PAGEUP,
453  ID_CURSOR_PAGEDOWN,
454  ID_CURSOR_WORD_LEFT,
455  ID_CURSOR_WORD_RIGHT,
456  ID_CURSOR_SHIFT_TOP,
457  ID_CURSOR_SHIFT_BOTTOM,
458  ID_CURSOR_SHIFT_HOME,
459  ID_CURSOR_SHIFT_END,
460  ID_CURSOR_SHIFT_UP,
461  ID_CURSOR_SHIFT_DOWN,
462  ID_CURSOR_SHIFT_LEFT,
463  ID_CURSOR_SHIFT_RIGHT,
464  ID_CURSOR_SHIFT_PAGEUP,
465  ID_CURSOR_SHIFT_PAGEDOWN,
466  ID_CURSOR_SHIFT_WORD_LEFT,
467  ID_CURSOR_SHIFT_WORD_RIGHT,
468  ID_CURSOR_ALT_UP,
469  ID_CURSOR_ALT_DOWN,
470  ID_CURSOR_ALT_LEFT,
471  ID_CURSOR_ALT_RIGHT,
472  ID_SCROLL_UP,
473  ID_SCROLL_DOWN,
474  ID_SCROLL_TOP,
475  ID_SCROLL_BOTTOM,
476  ID_SCROLL_CENTER,
477  ID_INSERT_STRING,
478  ID_INSERT_NEWLINE,
479  ID_INSERT_NEWLINE_ONLY,
480  ID_INSERT_NEWLINE_INDENT,
481  ID_INSERT_TAB,
482  ID_INSERT_HARDTAB,
483  ID_INSERT_SOFTTAB,
484  ID_CUT_SEL,
485  ID_COPY_SEL,
486  ID_DELETE_SEL,
487  ID_PASTE_SEL,
488  ID_PASTE_MIDDLE,
489  ID_SELECT_CHAR,
490  ID_SELECT_WORD,
491  ID_SELECT_LINE,
492  ID_SELECT_ALL,
493  ID_SELECT_MATCHING,
494  ID_SELECT_BRACE,
495  ID_SELECT_BRACK,
496  ID_SELECT_PAREN,
497  ID_SELECT_ANG,
498  ID_DESELECT_ALL,
499  ID_BACKSPACE_CHAR,
500  ID_BACKSPACE_WORD,
501  ID_BACKSPACE_BOL,
502  ID_DELETE_CHAR,
503  ID_DELETE_WORD,
504  ID_DELETE_EOL,
505  ID_DELETE_ALL,
506  ID_DELETE_LINE,
507  ID_TOGGLE_EDITABLE,
508  ID_TOGGLE_OVERSTRIKE,
509  ID_CURSOR_ROW,
510  ID_CURSOR_COLUMN,
511  ID_JOIN_LINES,
512  ID_SHIFT_LEFT,
513  ID_SHIFT_RIGHT,
514  ID_SHIFT_TABLEFT,
515  ID_SHIFT_TABRIGHT,
516  ID_CLEAN_INDENT,
517  ID_COPY_LINE,
518  ID_MOVE_LINE_UP,
519  ID_MOVE_LINE_DOWN,
520  ID_UPPER_CASE,
521  ID_LOWER_CASE,
522  ID_GOTO_MATCHING,
523  ID_LEFT_BRACE,
524  ID_LEFT_BRACK,
525  ID_LEFT_PAREN,
526  ID_LEFT_ANG,
527  ID_RIGHT_BRACE,
528  ID_RIGHT_BRACK,
529  ID_RIGHT_PAREN,
530  ID_RIGHT_ANG,
531  ID_BLINK,
532  ID_FLASH,
533  ID_LAST
534  };
535 
536 public:
537 
539  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);
540 
542  virtual void create();
543 
545  virtual void detach();
546 
548  virtual FXint getContentWidth();
549 
551  virtual FXint getContentHeight();
552 
554  virtual FXint getVisibleX() const;
555 
557  virtual FXint getVisibleY() const;
558 
560  virtual FXint getVisibleWidth() const;
561 
563  virtual FXint getVisibleHeight() const;
564 
566  virtual FXint getDefaultWidth();
567 
569  virtual FXint getDefaultHeight();
570 
572  virtual void layout();
573 
575  virtual void enable();
576 
578  virtual void disable();
579 
581  virtual void recalc();
582 
584  virtual FXbool canFocus() const;
585 
587  virtual void setFocus();
588 
590  virtual void killFocus();
591 
593  void setModified(FXbool mod=true){ modified=mod; }
594 
596  FXbool isModified() const { return modified; }
597 
599  void setEditable(FXbool edit=true);
600 
602  FXbool isEditable() const;
603 
605  void setOverstrike(FXbool over=true);
606 
608  FXbool isOverstrike() const;
609 
611  FXint getLength() const { return length; }
612 
614  FXint getNumRows() const { return nrows; }
615 
617  FXint getByte(FXint pos) const;
618 
620  FXwchar getChar(FXint pos) const;
621 
623  FXint getCharLen(FXint pos) const;
624 
626  FXint getStyle(FXint pos) const;
627 
629  FXint dec(FXint pos) const;
630 
632  FXint inc(FXint pos) const;
633 
635  FXint lineStart(FXint pos) const;
636 
638  FXint lineEnd(FXint pos) const;
639 
641  FXint nextLine(FXint pos,FXint nl=1) const;
642 
644  FXint prevLine(FXint pos,FXint nl=1) const;
645 
647  FXint rowStart(FXint pos) const;
648 
650  FXint rowEnd(FXint pos) const;
651 
653  FXint nextRow(FXint pos,FXint nr=1) const;
654 
656  FXint prevRow(FXint pos,FXint nr=1) const;
657 
659  FXint leftWord(FXint pos) const;
660 
662  FXint rightWord(FXint pos) const;
663 
665  FXint wordStart(FXint pos) const;
666 
668  FXint wordEnd(FXint pos) const;
669 
671  FXint validPos(FXint pos) const;
672 
677  FXint countCols(FXint start,FXint end) const;
678 
683  FXint countRows(FXint start,FXint end) const;
684 
689  FXint countLines(FXint start,FXint end) const;
690 
691 
693  virtual FXint setText(const FXchar* text,FXint num,FXbool notify=false);
694  virtual FXint setText(const FXString& text,FXbool notify=false);
695 
697  virtual FXint setStyledText(const FXchar* text,FXint num,FXint style=0,FXbool notify=false);
698  virtual FXint setStyledText(const FXString& text,FXint style=0,FXbool notify=false);
699 
701  virtual FXint replaceText(FXint pos,FXint del,const FXchar *text,FXint ins,FXbool notify=false);
702  virtual FXint replaceText(FXint pos,FXint del,const FXString& text,FXbool notify=false);
703 
705  virtual FXint replaceStyledText(FXint pos,FXint del,const FXchar *text,FXint ins,FXint style=0,FXbool notify=false);
706  virtual FXint replaceStyledText(FXint pos,FXint del,const FXString& text,FXint style=0,FXbool notify=false);
707 
709  virtual FXint replaceTextBlock(FXint startpos,FXint endpos,FXint startcol,FXint endcol,const FXchar *text,FXint num,FXbool notify=false);
710  virtual FXint replaceTextBlock(FXint startpos,FXint endpos,FXint startcol,FXint endcol,const FXString& text,FXbool notify=false);
711 
713  virtual FXint replaceStyledTextBlock(FXint startpos,FXint endpos,FXint startcol,FXint endcol,const FXchar *text,FXint num,FXint style=0,FXbool notify=false);
714  virtual FXint replaceStyledTextBlock(FXint startpos,FXint endpos,FXint startcol,FXint endcol,const FXString& text,FXint style=0,FXbool notify=false);
715 
717  virtual FXint overstrikeTextBlock(FXint startpos,FXint endpos,FXint startcol,FXint endcol,const FXchar *text,FXint num,FXbool notify=false);
718  virtual FXint overstrikeTextBlock(FXint startpos,FXint endpos,FXint startcol,FXint endcol,const FXString& text,FXbool notify=false);
719 
721  virtual FXint overstrikeStyledTextBlock(FXint startpos,FXint endpos,FXint startcol,FXint endcol,const FXchar *text,FXint num,FXint style=0,FXbool notify=false);
722  virtual FXint overstrikeStyledTextBlock(FXint startpos,FXint endpos,FXint startcol,FXint endcol,const FXString& text,FXint style=0,FXbool notify=false);
723 
725  virtual FXint appendText(const FXchar *text,FXint num,FXbool notify=false);
726  virtual FXint appendText(const FXString& text,FXbool notify=false);
727 
729  virtual FXint appendStyledText(const FXchar *text,FXint num,FXint style=0,FXbool notify=false);
730  virtual FXint appendStyledText(const FXString& text,FXint style=0,FXbool notify=false);
731 
733  virtual FXint insertText(FXint pos,const FXchar *text,FXint num,FXbool notify=false);
734  virtual FXint insertText(FXint pos,const FXString& text,FXbool notify=false);
735 
737  virtual FXint insertStyledText(FXint pos,const FXchar *text,FXint num,FXint style=0,FXbool notify=false);
738  virtual FXint insertStyledText(FXint pos,const FXString& text,FXint style=0,FXbool notify=false);
739 
741  virtual FXint insertTextBlock(FXint startpos,FXint endpos,FXint startcol,const FXchar *text,FXint num,FXbool notify=false);
742  virtual FXint insertTextBlock(FXint startpos,FXint endpos,FXint startcol,const FXString& text,FXbool notify=false);
743 
745  virtual FXint insertStyledTextBlock(FXint startpos,FXint endpos,FXint startcol,const FXchar *text,FXint num,FXint style=0,FXbool notify=false);
746  virtual FXint insertStyledTextBlock(FXint startpos,FXint endpos,FXint startcol,const FXString& text,FXint style=0,FXbool notify=false);
747 
749  virtual FXint changeStyle(FXint pos,FXint num,FXint style);
750 
752  virtual FXint changeStyle(FXint pos,const FXchar* style,FXint num);
753  virtual FXint changeStyle(FXint pos,const FXString& style);
754 
756  virtual FXint removeText(FXint pos,FXint num,FXbool notify=false);
757 
759  virtual FXint removeTextBlock(FXint startpos,FXint endpos,FXint startcol,FXint endcol,FXbool notify=false);
760 
762  virtual FXint clearText(FXbool notify=false);
763 
764 
766  void extractText(FXchar *text,FXint pos,FXint num) const;
767 
769  void extractText(FXString& text,FXint pos,FXint num) const;
770 
772  FXString extractText(FXint pos,FXint num) const;
773 
775  void extractStyle(FXchar *style,FXint pos,FXint num) const;
776 
778  void extractStyle(FXString& style,FXint pos,FXint num) const;
779 
781  FXString extractStyle(FXint pos,FXint num) const;
782 
784  void extractTextBlock(FXString& text,FXint startpos,FXint endpos,FXint startcol,FXint endcol) const;
785 
787  FXString extractTextBlock(FXint startpos,FXint endpos,FXint startcol,FXint endcol) const;
788 
790  FXString getText() const;
791 
793  void getText(FXchar* text,FXint num) const;
794 
796  void getText(FXString& text) const;
797 
798 
800  virtual FXbool selectAll(FXbool notify=false);
801 
803  virtual FXbool setSelection(FXint pos,FXint len,FXbool notify=false);
804 
806  virtual FXbool extendSelection(FXint pos,FXuint sel=SelectChars,FXbool notify=false);
807 
809  virtual FXbool setBlockSelection(FXint trow,FXint lcol,FXint brow,FXint rcol,FXbool notify=false);
810 
812  virtual FXbool extendBlockSelection(FXint row,FXint col,FXbool notify=false);
813 
815  virtual FXbool killSelection(FXbool notify=false);
816 
818  FXbool isPosSelected(FXint pos) const;
819 
821  FXbool isPosSelected(FXint pos,FXint col) const;
822 
824  FXint getSelStartPos() const { return select.startpos; }
825 
827  FXint getSelEndPos() const { return select.endpos; }
828 
830  FXint getSelStartColumn() const { return select.startcol; }
831 
833  FXint getSelEndColumn() const { return select.endcol; }
834 
836  FXString getSelectedText() const;
837 
838 
840  FXbool copySelection();
841 
843  FXbool cutSelection(FXbool notify=false);
844 
846  FXbool deleteSelection(FXbool notify=false);
847 
849  FXbool pasteSelection(FXbool notify=false);
850 
852  FXbool pasteClipboard(FXbool notify=false);
853 
855  FXbool replaceSelection(const FXString& text,FXbool notify=false);
856 
858  FXbool setHighlight(FXint start,FXint len);
859 
861  FXbool killHighlight();
862 
863 
865  void setTopLine(FXint pos);
866 
868  FXint getTopLine() const;
869 
871  void setBottomLine(FXint pos);
872 
874  FXint getBottomLine() const;
875 
877  void setCenterLine(FXint pos);
878 
880  FXbool isPosVisible(FXint pos) const;
881 
883  void makePositionVisible(FXint pos);
884 
885 
887  FXint getPosAt(FXint x,FXint y) const;
888 
890  FXint getPosContaining(FXint x,FXint y) const;
891 
893  FXint getXOfPos(FXint pos) const;
894 
896  FXint getYOfPos(FXint pos) const;
897 
906  FXint getRowColumnAt(FXint x,FXint y,FXint& row,FXint& col) const;
907 
909  FXint getXOfRowColumn(FXint row,FXint col) const;
910 
912  FXint getYOfRowColumn(FXint row,FXint col) const;
913 
915  virtual void setCursorPos(FXint pos,FXbool notify=false);
916 
918  FXint getCursorPos() const { return cursorpos; }
919 
921  void setCursorRowColumn(FXint row,FXint col,FXbool notify=false);
922 
924  void setCursorRow(FXint row,FXbool notify=false);
925 
927  FXint getCursorRow() const { return cursorrow; }
928 
930  void setCursorColumn(FXint col,FXbool notify=false);
931 
933  FXint getCursorColumn() const { return cursorcol; }
934 
936  void setAnchorPos(FXint pos);
937 
939  FXint getAnchorPos() const { return anchorpos; }
940 
942  void setAnchorRowColumn(FXint row,FXint col);
943 
945  FXint getAnchorRow() const { return anchorrow; }
946 
948  FXint getAnchorColumn() const { return anchorcol; }
949 
951  void moveCursor(FXint pos,FXbool notify=false);
952 
954  void moveCursorRowColumn(FXint row,FXint col,FXbool notify=false);
955 
957  void moveCursorAndSelect(FXint pos,FXuint sel,FXbool notify=false);
958 
960  void moveCursorRowColumnAndSelect(FXint row,FXint col,FXbool notify=false);
961 
974  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);
975 
977  void setTextStyle(FXuint style);
978 
980  FXuint getTextStyle() const;
981 
983  void setFont(FXFont* fnt);
984 
986  FXFont* getFont() const { return font; }
987 
989  void setVisibleRows(FXint rows);
990 
992  FXint getVisibleRows() const { return vrows; }
993 
995  void setVisibleColumns(FXint cols);
996 
998  FXint getVisibleColumns() const { return vcols; }
999 
1001  void setMarginTop(FXint pt);
1002 
1004  FXint getMarginTop() const { return margintop; }
1005 
1007  void setMarginBottom(FXint pb);
1008 
1010  FXint getMarginBottom() const { return marginbottom; }
1011 
1013  void setMarginLeft(FXint pl);
1014 
1016  FXint getMarginLeft() const { return marginleft; }
1017 
1019  void setMarginRight(FXint pr);
1020 
1022  FXint getMarginRight() const { return marginright; }
1023 
1025  FXint getBarColumns() const { return barcolumns; }
1026 
1028  void setBarColumns(FXint cols);
1029 
1031  void setWrapColumns(FXint cols);
1032 
1034  FXint getWrapColumns() const { return wrapcolumns; }
1035 
1037  void setTabColumns(FXint cols);
1038 
1040  FXint getTabColumns() const { return tabcolumns; }
1041 
1043  void setTextColor(FXColor clr);
1044 
1046  FXColor getTextColor() const { return textColor; }
1047 
1049  void setSelBackColor(FXColor clr);
1050 
1052  FXColor getSelBackColor() const { return selbackColor; }
1053 
1055  void setSelTextColor(FXColor clr);
1056 
1058  FXColor getSelTextColor() const { return seltextColor; }
1059 
1061  void setHiliteTextColor(FXColor clr);
1062 
1064  FXColor getHiliteTextColor() const { return hilitetextColor; }
1065 
1067  void setHiliteBackColor(FXColor clr);
1068 
1070  FXColor getHiliteBackColor() const { return hilitebackColor; }
1071 
1073  void setActiveBackColor(FXColor clr);
1074 
1076  FXColor getActiveBackColor() const { return activebackColor; }
1077 
1079  void setCursorColor(FXColor clr);
1080 
1082  FXColor getCursorColor() const { return cursorColor; }
1083 
1085  void setNumberColor(FXColor clr);
1086 
1088  FXColor getNumberColor() const { return numberColor; }
1089 
1091  void setBarColor(FXColor clr);
1092 
1094  FXColor getBarColor() const { return barColor; }
1095 
1097  FXbool setStyled(FXbool styled=true);
1098 
1100  FXbool isStyled() const { return (sbuffer!=NULL); }
1101 
1109  void setHiliteStyles(FXHiliteStyle* styles);
1110 
1112  FXHiliteStyle* getHiliteStyles() const { return hilitestyles; }
1113 
1115  void setDelimiters(const FXchar* delims=textDelimiters){ delimiters=delims; }
1116 
1118  const FXchar* getDelimiters() const { return delimiters; }
1119 
1128  void setHiliteMatchTime(FXTime t){ matchtime=t; }
1129 
1131  FXTime getHiliteMatchTime() const { return matchtime; }
1132 
1134  void setHelpText(const FXString& text){ help=text; }
1135 
1137  FXString getHelpText() const { return help; }
1138 
1140  void setTipText(const FXString& text){ tip=text; }
1141 
1143  FXString getTipText() const { return tip; }
1144 
1146  virtual void save(FXStream& store) const;
1147 
1149  virtual void load(FXStream& store);
1150 
1152  virtual ~FXText();
1153  };
1154 
1155 }
1156 
1157 #endif
The text widget provides a multi-line text editing control.
Definition: FXText.h:155
FXint getSelStartColumn() const
Return selection start column.
Definition: FXText.h:830
void setHelpText(const FXString &text)
Set help text.
Definition: FXText.h:1134
FXbool isModified() const
Return true if text was modified.
Definition: FXText.h:596
FXColor selectBackColor
Selected text foreground color.
Definition: FXText.h:49
FXint getSelEndColumn() const
Return selection end column.
Definition: FXText.h:833
FXint getVisibleRows() const
Return number of visible rows.
Definition: FXText.h:992
FXint getSelEndPos() const
Return selection end position.
Definition: FXText.h:827
FXint getTabColumns() const
Return tab columns.
Definition: FXText.h:1040
FXColor normalBackColor
Normal text foreground color.
Definition: FXText.h:47
FXint getLength() const
Return length of buffer.
Definition: FXText.h:611
FXColor getBarColor() const
Return bar color.
Definition: FXText.h:1094
FXbool isStyled() const
Return true if style buffer.
Definition: FXText.h:1100
FXString getHelpText() const
Return help text.
Definition: FXText.h:1137
FXint getSelStartPos() const
Return selection start position.
Definition: FXText.h:824
FXint getCursorRow() const
Return cursor row.
Definition: FXText.h:927
FXint getMarginBottom() const
Return bottom margin.
Definition: FXText.h:1010
void setTipText(const FXString &text)
Set the tool tip message for this text widget.
Definition: FXText.h:1140
Highlight style entry.
Definition: FXText.h:45
Select characters.
Definition: FXText.h:436
FXint ndel
Position in buffer.
Definition: FXText.h:65
FXint getWrapColumns() const
Return wrap columns.
Definition: FXText.h:1034
FXchar * ins
Number characters inserted at position.
Definition: FXText.h:67
FXColor getSelBackColor() const
Return selected background color.
Definition: FXText.h:1052
A stream is a way to serialize data and objects into a byte stream.
Definition: FXStream.h:78
const FXchar * getDelimiters() const
Return word delimiters.
Definition: FXText.h:1118
FXColor getTextColor() const
Return text color.
Definition: FXText.h:1046
FXColor getCursorColor() const
Return cursor color.
Definition: FXText.h:1082
FXint getMarginTop() const
Return top margin.
Definition: FXText.h:1004
FXColor hiliteForeColor
Selected text background color.
Definition: FXText.h:50
Definition: FX4Splitter.h:28
FXColor getSelTextColor() const
Return selected text color.
Definition: FXText.h:1058
FXHiliteStyle * getHiliteStyles() const
Return current value of the style table.
Definition: FXText.h:1112
Select nothing.
Definition: FXText.h:435
FXint getMarginLeft() const
Return left margin.
Definition: FXText.h:1016
FXColor getHiliteTextColor() const
Return highlighted text color.
Definition: FXText.h:1064
void setModified(FXbool mod=true)
Set modified flag.
Definition: FXText.h:593
FXint getAnchorColumn() const
Return anchor row.
Definition: FXText.h:948
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:986
The scroll area widget manages a content area and a viewport area through which the content is viewed...
Definition: FXScrollArea.h:65
void setDelimiters(const FXchar *delims=textDelimiters)
Change delimiters of words.
Definition: FXText.h:1115
FXint endcol
Start column, if block-select (actually, indent)
Definition: FXText.h:81
FXint getVisibleColumns() const
Return number of visible columns.
Definition: FXText.h:998
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:1076
Object is the base class for all objects in FOX; in order to receive messages from the user interface...
Definition: FXObject.h:103
Window Device Context.
Definition: FXDCWindow.h:48
FXint getCursorPos() const
Return the cursor position.
Definition: FXText.h:918
FXint getAnchorRow() const
Return anchor row.
Definition: FXText.h:945
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:933
FXTime getHiliteMatchTime() const
Return brace and parenthesis match highlighting time, in nanoseconds.
Definition: FXText.h:1131
FXint getNumRows() const
Return number of rows in buffer.
Definition: FXText.h:614
FXString getTipText() const
Get the tool tip message for this text widget.
Definition: FXText.h:1143
FXColor selectForeColor
Normal text background color.
Definition: FXText.h:48
FXColor activeBackColor
Highlight text background color.
Definition: FXText.h:52
FXchar * del
Text inserted at position.
Definition: FXText.h:68
FXint nins
Number characters deleted at position.
Definition: FXText.h:66
FXint getAnchorPos() const
Return the anchor position.
Definition: FXText.h:939
void setHiliteMatchTime(FXTime t)
Change brace and parenthesis match highlighting time, in nanoseconds.
Definition: FXText.h:1128
FXint getMarginRight() const
Return right margin.
Definition: FXText.h:1022
FXColor getNumberColor() const
Return line number color.
Definition: FXText.h:1088
Select words.
Definition: FXText.h:437
Font class.
Definition: FXFont.h:137
FXint getBarColumns() const
Return number of columns used for line numbers.
Definition: FXText.h:1025
FXuint style
Active text background color.
Definition: FXText.h:53
FXColor getHiliteBackColor() const
Return highlighted background color.
Definition: FXText.h:1070
FXColor hiliteBackColor
Highlight text foreground color.
Definition: FXText.h:51
FXString provides essential string manipulation capabilities in FOX.
Definition: FXString.h:42

Copyright © 1997-2020 Jeroen van der Zijp