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

FXText.h

Go to the documentation of this file.
00001 /********************************************************************************
00002 *                                                                               *
00003 *                    M u l t i - L i ne   T e x t   W i d g e t                 *
00004 *                                                                               *
00005 *********************************************************************************
00006 * Copyright (C) 1998,2006 by Jeroen van der Zijp.   All Rights Reserved.        *
00007 *********************************************************************************
00008 * This library is free software; you can redistribute it and/or                 *
00009 * modify it under the terms of the GNU Lesser General Public                    *
00010 * License as published by the Free Software Foundation; either                  *
00011 * version 2.1 of the License, or (at your option) any later version.            *
00012 *                                                                               *
00013 * This library is distributed in the hope that it will be useful,               *
00014 * but WITHOUT ANY WARRANTY; without even the implied warranty of                *
00015 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU             *
00016 * Lesser General Public License for more details.                               *
00017 *                                                                               *
00018 * You should have received a copy of the GNU Lesser General Public              *
00019 * License along with this library; if not, write to the Free Software           *
00020 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA.    *
00021 *********************************************************************************
00022 * $Id: FXText.h,v 1.166 2006/02/06 03:03:40 fox Exp $                           *
00023 ********************************************************************************/
00024 #ifndef FXTEXT_H
00025 #define FXTEXT_H
00026 
00027 #ifndef FXSCROLLAREA_H
00028 #include "FXScrollArea.h"
00029 #endif
00030 
00031 namespace FX {
00032 
00033 
00034 /// Text widget options
00035 enum {
00036   TEXT_READONLY      = 0x00100000,      /// Text is NOT editable
00037   TEXT_WORDWRAP      = 0x00200000,      /// Wrap at word breaks
00038   TEXT_OVERSTRIKE    = 0x00400000,      /// Overstrike mode
00039   TEXT_FIXEDWRAP     = 0x00800000,      /// Fixed wrap columns
00040   TEXT_NO_TABS       = 0x01000000,      /// Insert spaces for tabs
00041   TEXT_AUTOINDENT    = 0x02000000,      /// Autoindent
00042   TEXT_SHOWACTIVE    = 0x04000000,      /// Show active line
00043   TEXT_AUTOSCROLL    = 0x08000000       /// Logging mode, keeping last line visible
00044   };
00045 
00046 
00047 /// Selection modes
00048 enum FXTextSelectionMode {
00049   SELECT_CHARS,
00050   SELECT_WORDS,
00051   SELECT_LINES
00052   };
00053 
00054 
00055 /// Highlight style entry
00056 struct FXHiliteStyle {
00057   FXColor normalForeColor;            /// Normal text foreground color
00058   FXColor normalBackColor;            /// Normal text background color
00059   FXColor selectForeColor;            /// Selected text foreground color
00060   FXColor selectBackColor;            /// Selected text background color
00061   FXColor hiliteForeColor;            /// Highlight text foreground color
00062   FXColor hiliteBackColor;            /// Highlight text background color
00063   FXColor activeBackColor;            /// Active text background color
00064   FXuint  style;                      /// Highlight text style
00065   };
00066 
00067 
00068 /**
00069 * Text mutation callback data passed with the SEL_INSERTED,
00070 * SEL_REPLACED, and SEL_DELETED messages; both old and new
00071 * text is available on behalf of the undo system as well as
00072 * syntax highlighting.
00073 */
00074 struct FXTextChange {
00075   FXint   pos;          /// Position in buffer
00076   FXint   ndel;         /// Number characters deleted at position
00077   FXint   nins;         /// Number characters inserted at position
00078   FXchar *ins;          /// Text inserted at position
00079   FXchar *del;          /// Text deleted at position
00080   };
00081 
00082 
00083 /**
00084 * The text widget supports editing of multiple lines of text.
00085 * An optional style table can provide text coloring based on
00086 * the contents of an optional parallel style buffer, which is
00087 * maintained as text is edited.  In a typical scenario, the
00088 * contents of the style buffer is either directly written when
00089 * the text is added to the widget, or is continually modified
00090 * by editing the text via syntax-based highlighting engine which
00091 * colors the text based on syntactical patterns.
00092 */
00093 class FXAPI FXText : public FXScrollArea {
00094   FXDECLARE(FXText)
00095 protected:
00096   FXchar        *buffer;              // Text buffer being edited
00097   FXchar        *sbuffer;             // Text style buffer
00098   FXint         *visrows;             // Starts of rows in buffer
00099   FXint          length;              // Length of the actual text in the buffer
00100   FXint          nvisrows;            // Number of visible rows
00101   FXint          nrows;               // Total number of rows
00102   FXint          gapstart;            // Start of the insertion point (the gap)
00103   FXint          gapend;              // End of the insertion point+1
00104   FXint          toppos;              // Start position of first visible row
00105   FXint          keeppos;             // Position to keep on top visible row
00106   FXint          toprow;              // Row number of first visible row
00107   FXint          selstartpos;         // Start of selection
00108   FXint          selendpos;           // End of selection
00109   FXint          hilitestartpos;      // Hightlight start position
00110   FXint          hiliteendpos;        // Hightlight end position
00111   FXint          anchorpos;           // Anchor position
00112   FXint          cursorpos;           // Cursor position
00113   FXint          revertpos;           // Position of cursor prior to dragging
00114   FXint          cursorstart;         // Cursor row start pos
00115   FXint          cursorend;           // Cursor row end pos
00116   FXint          cursorrow;           // Cursor row
00117   FXint          cursorcol;           // Cursor column indent (not character offset!)
00118   FXint          prefcol;             // Preferred cursor column
00119   FXint          margintop;           // Margins top
00120   FXint          marginbottom;        // Margin bottom
00121   FXint          marginleft;          // Margin left
00122   FXint          marginright;         // Margin right
00123   FXint          wrapwidth;           // Wrap width in pixels
00124   FXint          wrapcolumns;         // Wrap columns
00125   FXint          tabwidth;            // Tab width in pixels
00126   FXint          tabcolumns;          // Tab columns
00127   FXint          barwidth;            // Line number width
00128   FXint          barcolumns;          // Line number columns
00129   FXFont        *font;                // Text font
00130   FXColor        textColor;           // Normal text color
00131   FXColor        selbackColor;        // Select background color
00132   FXColor        seltextColor;        // Select text color
00133   FXColor        hilitebackColor;     // Highlight background color
00134   FXColor        hilitetextColor;     // Highlight text color
00135   FXColor        activebackColor;     // Background color for active line
00136   FXColor        numberColor;         // Line number color
00137   FXColor        cursorColor;         // Cursor color
00138   FXColor        barColor;            // Bar background color
00139   FXint          textWidth;           // Total width of all text
00140   FXint          textHeight;          // Total height of all text
00141   FXString       searchstring;        // String of last search
00142   FXuint         searchflags;         // Flags of last search
00143   const FXchar  *delimiters;          // Delimiters
00144   FXString       clipped;             // Clipped text
00145   FXint          vrows;               // Default visible rows
00146   FXint          vcols;               // Default visible columns
00147   FXString       help;                // Status line help
00148   FXString       tip;                 // Tooltip
00149   const FXHiliteStyle *hilitestyles;  // Style definitions
00150   FXuint         matchtime;           // Match time (ms)
00151   FXint          grabx;               // Grab point x
00152   FXint          graby;               // Grab point y
00153   FXuchar        mode;                // Mode widget is in
00154   FXbool         modified;            // User has modified text
00155 protected:
00156   FXText();
00157   void calcVisRows(FXint s,FXint e);
00158   virtual void eraseCursorOverhang();
00159   virtual void drawCursor(FXuint state);
00160   virtual FXuint style(FXint row,FXint beg,FXint end,FXint pos) const;
00161   virtual void drawBufferText(FXDCWindow& dc,FXint x,FXint y,FXint w,FXint h,FXint pos,FXint n,FXuint style) const;
00162   virtual void fillBufferRect(FXDCWindow& dc,FXint x,FXint y,FXint w,FXint h,FXuint style) const;
00163   virtual void drawTextRow(FXDCWindow& dc,FXint line,FXint left,FXint right) const;
00164   virtual void drawContents(FXDCWindow& dc,FXint x,FXint y,FXint w,FXint h) const;
00165   virtual void drawNumbers(FXDCWindow& dc,FXint x,FXint y,FXint w,FXint h) const;
00166   FXint posToLine(FXint pos,FXint ln) const;
00167   FXbool posVisible(FXint pos) const;
00168   void updateRange(FXint beg,FXint end) const;
00169   void movegap(FXint pos);
00170   void sizegap(FXint sz);
00171   void squeezegap();
00172   FXint charWidth(FXwchar ch,FXint indent) const;
00173   FXint wrap(FXint start) const;
00174   FXint measureText(FXint start,FXint end,FXint& wmax,FXint& hmax) const;
00175   FXint lineWidth(FXint pos,FXint n) const;
00176   FXint getYOfPos(FXint pos) const;
00177   FXint getXOfPos(FXint pos) const;
00178   FXint changeBeg(FXint pos) const;
00179   FXint changeEnd(FXint pos) const;
00180   FXint indentFromPos(FXint start,FXint pos) const;
00181   FXint posFromIndent(FXint start,FXint indent) const;
00182   void mutation(FXint pos,FXint ncins,FXint ncdel,FXint nrins,FXint nrdel);
00183   virtual void replace(FXint pos,FXint m,const FXchar *text,FXint n,FXint style);
00184   void recompute();
00185   FXint matchForward(FXint pos,FXint end,FXwchar l,FXwchar r,FXint level) const;
00186   FXint matchBackward(FXint pos,FXint beg,FXwchar l,FXwchar r,FXint level) const;
00187   FXint findMatching(FXint pos,FXint beg,FXint end,FXwchar ch,FXint level) const;
00188   void flashMatching();
00189   void moveContents(FXint x,FXint y);
00190 protected:
00191   enum {
00192     STYLE_MASK      = 0x00FF,   // Mask color table
00193     STYLE_TEXT      = 0x0100,   // Draw some content
00194     STYLE_SELECTED  = 0x0200,   // Selected
00195     STYLE_CONTROL   = 0x0400,   // Control character
00196     STYLE_HILITE    = 0x0800,   // Highlighted
00197     STYLE_ACTIVE    = 0x1000    // Active
00198     };
00199   enum {
00200     MOUSE_NONE,                 // No mouse operation
00201     MOUSE_CHARS,                // Selecting characters
00202     MOUSE_WORDS,                // Selecting words
00203     MOUSE_LINES,                // Selecting lines
00204     MOUSE_SCROLL,               // Scrolling
00205     MOUSE_DRAG,                 // Dragging text
00206     MOUSE_TRYDRAG               // Tentative drag
00207     };
00208 public:
00209   enum {
00210     STYLE_UNDERLINE = 0x0001,   /// Underline text
00211     STYLE_STRIKEOUT = 0x0002,   /// Strike out text
00212     STYLE_BOLD      = 0x0004    /// Bold text
00213     };
00214 private:
00215   FXText(const FXText&);
00216   FXText& operator=(const FXText&);
00217 public:
00218   long onPaint(FXObject*,FXSelector,void*);
00219   long onFocusIn(FXObject*,FXSelector,void*);
00220   long onFocusOut(FXObject*,FXSelector,void*);
00221   long onLeftBtnPress(FXObject*,FXSelector,void*);
00222   long onLeftBtnRelease(FXObject*,FXSelector,void*);
00223   long onMiddleBtnPress(FXObject*,FXSelector,void*);
00224   long onMiddleBtnRelease(FXObject*,FXSelector,void*);
00225   long onRightBtnPress(FXObject*,FXSelector,void*);
00226   long onRightBtnRelease(FXObject*,FXSelector,void*);
00227   long onUngrabbed(FXObject*,FXSelector,void*);
00228   long onMotion(FXObject*,FXSelector,void*);
00229   long onBeginDrag(FXObject*,FXSelector,void*);
00230   long onEndDrag(FXObject*,FXSelector,void*);
00231   long onDragged(FXObject*,FXSelector,void*);
00232   long onDNDEnter(FXObject*,FXSelector,void*);
00233   long onDNDLeave(FXObject*,FXSelector,void*);
00234   long onDNDMotion(FXObject*,FXSelector,void*);
00235   long onDNDDrop(FXObject*,FXSelector,void*);
00236   long onDNDRequest(FXObject*,FXSelector,void*);
00237   long onSelectionLost(FXObject*,FXSelector,void*);
00238   long onSelectionGained(FXObject*,FXSelector,void*);
00239   long onSelectionRequest(FXObject*,FXSelector,void* ptr);
00240   long onClipboardLost(FXObject*,FXSelector,void*);
00241   long onClipboardGained(FXObject*,FXSelector,void*);
00242   long onClipboardRequest(FXObject*,FXSelector,void*);
00243   long onKeyPress(FXObject*,FXSelector,void*);
00244   long onKeyRelease(FXObject*,FXSelector,void*);
00245   long onBlink(FXObject*,FXSelector,void*);
00246   long onFlash(FXObject*,FXSelector,void*);
00247   long onAutoScroll(FXObject*,FXSelector,void*);
00248   long onQueryHelp(FXObject*,FXSelector,void*);
00249   long onQueryTip(FXObject*,FXSelector,void*);
00250 
00251   // Control commands
00252   long onCmdToggleEditable(FXObject*,FXSelector,void*);
00253   long onUpdToggleEditable(FXObject*,FXSelector,void*);
00254   long onCmdToggleOverstrike(FXObject*,FXSelector,void*);
00255   long onUpdToggleOverstrike(FXObject*,FXSelector,void*);
00256   long onCmdCursorRow(FXObject*,FXSelector,void*);
00257   long onUpdCursorRow(FXObject*,FXSelector,void*);
00258   long onCmdCursorColumn(FXObject*,FXSelector,void*);
00259   long onUpdCursorColumn(FXObject*,FXSelector,void*);
00260   long onUpdHaveSelection(FXObject*,FXSelector,void*);
00261   long onUpdSelectAll(FXObject*,FXSelector,void*);
00262   long onCmdSetStringValue(FXObject*,FXSelector,void*);
00263   long onCmdGetStringValue(FXObject*,FXSelector,void*);
00264   long onCmdSearch(FXObject*,FXSelector,void*);
00265   long onCmdReplace(FXObject*,FXSelector,void*);
00266   long onCmdSearchNext(FXObject*,FXSelector,void*);
00267   long onCmdSearchSel(FXObject*,FXSelector,void*);
00268 
00269   // Cursor movement
00270   long onCmdCursorTop(FXObject*,FXSelector,void*);
00271   long onCmdCursorBottom(FXObject*,FXSelector,void*);
00272   long onCmdCursorHome(FXObject*,FXSelector,void*);
00273   long onCmdCursorEnd(FXObject*,FXSelector,void*);
00274   long onCmdCursorRight(FXObject*,FXSelector,void*);
00275   long onCmdCursorLeft(FXObject*,FXSelector,void*);
00276   long onCmdCursorUp(FXObject*,FXSelector,void*);
00277   long onCmdCursorDown(FXObject*,FXSelector,void*);
00278   long onCmdCursorWordLeft(FXObject*,FXSelector,void*);
00279   long onCmdCursorWordRight(FXObject*,FXSelector,void*);
00280   long onCmdCursorWordStart(FXObject*,FXSelector,void*);
00281   long onCmdCursorWordEnd(FXObject*,FXSelector,void*);
00282   long onCmdCursorPageDown(FXObject*,FXSelector,void*);
00283   long onCmdCursorPageUp(FXObject*,FXSelector,void*);
00284   long onCmdCursorScreenTop(FXObject*,FXSelector,void*);
00285   long onCmdCursorScreenBottom(FXObject*,FXSelector,void*);
00286   long onCmdCursorScreenCenter(FXObject*,FXSelector,void*);
00287   long onCmdCursorParHome(FXObject*,FXSelector,void*);
00288   long onCmdCursorParEnd(FXObject*,FXSelector,void*);
00289   long onCmdBlockBeg(FXObject*,FXSelector,void*);
00290   long onCmdBlockEnd(FXObject*,FXSelector,void*);
00291   long onCmdGotoMatching(FXObject*,FXSelector,void*);
00292   long onCmdGotoSelected(FXObject*,FXSelector,void*);
00293   long onCmdGotoLine(FXObject*,FXSelector,void*);
00294   long onCmdScrollUp(FXObject*,FXSelector,void*);
00295   long onCmdScrollDown(FXObject*,FXSelector,void*);
00296 
00297   // Mark and extend
00298   long onCmdMark(FXObject*,FXSelector,void*);
00299   long onCmdExtend(FXObject*,FXSelector,void*);
00300 
00301   // Inserting
00302   long onCmdOverstString(FXObject*,FXSelector,void*);
00303   long onCmdInsertString(FXObject*,FXSelector,void*);
00304   long onCmdInsertNewline(FXObject*,FXSelector,void*);
00305   long onCmdInsertTab(FXObject*,FXSelector,void*);
00306 
00307   // Manipulation Selection
00308   long onCmdCutSel(FXObject*,FXSelector,void*);
00309   long onCmdCopySel(FXObject*,FXSelector,void*);
00310   long onCmdPasteSel(FXObject*,FXSelector,void*);
00311   long onCmdDeleteSel(FXObject*,FXSelector,void*);
00312   long onCmdChangeCase(FXObject*,FXSelector,void*);
00313   long onCmdShiftText(FXObject*,FXSelector,void*);
00314   long onCmdPasteMiddle(FXObject*,FXSelector,void*);
00315 
00316   // Changing Selection
00317   long onCmdSelectChar(FXObject*,FXSelector,void*);
00318   long onCmdSelectWord(FXObject*,FXSelector,void*);
00319   long onCmdSelectLine(FXObject*,FXSelector,void*);
00320   long onCmdSelectAll(FXObject*,FXSelector,void*);
00321   long onCmdSelectMatching(FXObject*,FXSelector,void*);
00322   long onCmdSelectBlock(FXObject*,FXSelector,void*);
00323   long onCmdDeselectAll(FXObject*,FXSelector,void*);
00324 
00325   // Deletion
00326   long onCmdBackspace(FXObject*,FXSelector,void*);
00327   long onCmdBackspaceWord(FXObject*,FXSelector,void*);
00328   long onCmdBackspaceBol(FXObject*,FXSelector,void*);
00329   long onCmdDelete(FXObject*,FXSelector,void*);
00330   long onCmdDeleteWord(FXObject*,FXSelector,void*);
00331   long onCmdDeleteEol(FXObject*,FXSelector,void*);
00332   long onCmdDeleteAll(FXObject*,FXSelector,void*);
00333   long onCmdDeleteLine(FXObject*,FXSelector,void*);
00334 
00335 public:
00336   static const FXchar textDelimiters[];
00337 
00338 public:
00339 
00340   enum {
00341     ID_CURSOR_TOP=FXScrollArea::ID_LAST,
00342     ID_CURSOR_BOTTOM,
00343     ID_CURSOR_HOME,
00344     ID_CURSOR_END,
00345     ID_CURSOR_RIGHT,
00346     ID_CURSOR_LEFT,
00347     ID_CURSOR_UP,
00348     ID_CURSOR_DOWN,
00349     ID_CURSOR_WORD_LEFT,
00350     ID_CURSOR_WORD_RIGHT,
00351     ID_CURSOR_WORD_START,
00352     ID_CURSOR_WORD_END,
00353     ID_CURSOR_PAGEDOWN,
00354     ID_CURSOR_PAGEUP,
00355     ID_CURSOR_SCRNTOP,
00356     ID_CURSOR_SCRNBTM,
00357     ID_CURSOR_SCRNCTR,
00358     ID_CURSOR_PAR_HOME,
00359     ID_CURSOR_PAR_END,
00360     ID_SCROLL_UP,
00361     ID_SCROLL_DOWN,
00362     ID_MARK,
00363     ID_EXTEND,
00364     ID_OVERST_STRING,
00365     ID_INSERT_STRING,
00366     ID_INSERT_NEWLINE,
00367     ID_INSERT_TAB,
00368     ID_CUT_SEL,
00369     ID_COPY_SEL,
00370     ID_DELETE_SEL,
00371     ID_PASTE_SEL,
00372     ID_PASTE_MIDDLE,
00373     ID_SELECT_CHAR,
00374     ID_SELECT_WORD,
00375     ID_SELECT_LINE,
00376     ID_SELECT_ALL,
00377     ID_SELECT_MATCHING,
00378     ID_SELECT_BRACE,
00379     ID_SELECT_BRACK,
00380     ID_SELECT_PAREN,
00381     ID_SELECT_ANG,
00382     ID_DESELECT_ALL,
00383     ID_BACKSPACE,
00384     ID_BACKSPACE_WORD,
00385     ID_BACKSPACE_BOL,
00386     ID_DELETE,
00387     ID_DELETE_WORD,
00388     ID_DELETE_EOL,
00389     ID_DELETE_ALL,
00390     ID_DELETE_LINE,
00391     ID_TOGGLE_EDITABLE,
00392     ID_TOGGLE_OVERSTRIKE,
00393     ID_CURSOR_ROW,
00394     ID_CURSOR_COLUMN,
00395     ID_CLEAN_INDENT,
00396     ID_SHIFT_LEFT,
00397     ID_SHIFT_RIGHT,
00398     ID_SHIFT_TABLEFT,
00399     ID_SHIFT_TABRIGHT,
00400     ID_UPPER_CASE,
00401     ID_LOWER_CASE,
00402     ID_GOTO_MATCHING,
00403     ID_GOTO_SELECTED,
00404     ID_GOTO_LINE,
00405     ID_SEARCH_FORW_SEL,
00406     ID_SEARCH_BACK_SEL,
00407     ID_SEARCH_FORW,
00408     ID_SEARCH_BACK,
00409     ID_SEARCH,
00410     ID_REPLACE,
00411     ID_LEFT_BRACE,
00412     ID_LEFT_BRACK,
00413     ID_LEFT_PAREN,
00414     ID_LEFT_ANG,
00415     ID_RIGHT_BRACE,
00416     ID_RIGHT_BRACK,
00417     ID_RIGHT_PAREN,
00418     ID_RIGHT_ANG,
00419     ID_BLINK,
00420     ID_FLASH,
00421     ID_LAST
00422     };
00423 
00424 public:
00425 
00426   /// Construct multi-line text widget
00427   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);
00428 
00429   /// Create server-side resources
00430   virtual void create();
00431 
00432   /// Detach server-side resources
00433   virtual void detach();
00434 
00435   /// Perform layout
00436   virtual void layout();
00437 
00438   /// Return default width
00439   virtual FXint getDefaultWidth();
00440 
00441   /// Return default height
00442   virtual FXint getDefaultHeight();
00443 
00444   /// Enable the text widget
00445   virtual void enable();
00446 
00447   /// Disable the text widget
00448   virtual void disable();
00449 
00450   /// Need to recalculate size
00451   virtual void recalc();
00452 
00453   /// Get default width
00454   virtual FXint getContentWidth();
00455 
00456   /// Get default height
00457   virtual FXint getContentHeight();
00458 
00459   /// Returns true because a text widget can receive focus
00460   virtual bool canFocus() const;
00461 
00462   /// Move the focus to this window
00463   virtual void setFocus();
00464 
00465   /// Remove the focus from this window
00466   virtual void killFocus();
00467 
00468   /// Change top margin
00469   void setMarginTop(FXint pt);
00470 
00471   /// Return top margin
00472   FXint getMarginTop() const { return margintop; }
00473 
00474   /// Change bottom margin
00475   void setMarginBottom(FXint pb);
00476 
00477   /// Return bottom margin
00478   FXint getMarginBottom() const { return marginbottom; }
00479 
00480   /// Change left margin
00481   void setMarginLeft(FXint pl);
00482 
00483   /// Return left margin
00484   FXint getMarginLeft() const { return marginleft; }
00485 
00486   /// Change right margin
00487   void setMarginRight(FXint pr);
00488 
00489   /// Return right margin
00490   FXint getMarginRight() const { return marginright; }
00491 
00492   /// Return wrap columns
00493   FXint getWrapColumns() const { return wrapcolumns; }
00494 
00495   /// Set wrap columns
00496   void setWrapColumns(FXint cols);
00497 
00498   /// Return tab columns
00499   FXint getTabColumns() const { return tabcolumns; }
00500 
00501   /// Change tab columns
00502   void setTabColumns(FXint cols);
00503 
00504   /// Return number of columns used for line numbers
00505   FXint getBarColumns() const { return barcolumns; }
00506 
00507   /// Change number of columns used for line numbers
00508   void setBarColumns(FXint cols);
00509 
00510   /// Return TRUE if text was modified
00511   FXbool isModified() const { return modified; }
00512 
00513   /// Set modified flag
00514   void setModified(FXbool mod=TRUE){ modified=mod; }
00515 
00516   /// Set editable mode
00517   void setEditable(FXbool edit=TRUE);
00518 
00519   /// Return TRUE if text is editable
00520   FXbool isEditable() const;
00521 
00522   /// Set overstrike mode
00523   void setOverstrike(FXbool over=TRUE);
00524 
00525   /// Return TRUE if overstrike mode in effect
00526   FXbool isOverstrike() const;
00527 
00528   /// Set styled text mode
00529   void setStyled(FXbool styled=TRUE);
00530 
00531   /// Return TRUE if style buffer
00532   FXbool isStyled() const { return (sbuffer!=NULL); }
00533 
00534   /// Change delimiters of words
00535   void setDelimiters(const FXchar* delims=textDelimiters){ delimiters=delims; }
00536 
00537   /// Return word delimiters
00538   const FXchar* getDelimiters() const { return delimiters; }
00539 
00540   /// Change text font
00541   void setFont(FXFont* fnt);
00542 
00543   /// Return text font
00544   FXFont* getFont() const { return font; }
00545 
00546   /// Change text color
00547   void setTextColor(FXColor clr);
00548 
00549   /// Return text color
00550   FXColor getTextColor() const { return textColor; }
00551 
00552   /// Change selected background color
00553   void setSelBackColor(FXColor clr);
00554 
00555   /// Return selected background color
00556   FXColor getSelBackColor() const { return selbackColor; }
00557 
00558   /// Change selected text color
00559   void setSelTextColor(FXColor clr);
00560 
00561   /// Return selected text color
00562   FXColor getSelTextColor() const { return seltextColor; }
00563 
00564   /// Change highlighted text color
00565   void setHiliteTextColor(FXColor clr);
00566 
00567   /// Return highlighted text color
00568   FXColor getHiliteTextColor() const { return hilitetextColor; }
00569 
00570   /// Change highlighted background color
00571   void setHiliteBackColor(FXColor clr);
00572 
00573   /// Return highlighted background color
00574   FXColor getHiliteBackColor() const { return hilitebackColor; }
00575 
00576   /// Change active background color
00577   void setActiveBackColor(FXColor clr);
00578 
00579   /// Return active background color
00580   FXColor getActiveBackColor() const { return activebackColor; }
00581 
00582   /// Change cursor color
00583   void setCursorColor(FXColor clr);
00584 
00585   /// Return cursor color
00586   FXColor getCursorColor() const { return cursorColor; }
00587 
00588   /// Change line number color
00589   void setNumberColor(FXColor clr);
00590 
00591   /// Return line number color
00592   FXColor getNumberColor() const { return numberColor; }
00593 
00594   /// Change bar color
00595   void setBarColor(FXColor clr);
00596 
00597   /// Return bar color
00598   FXColor getBarColor() const { return barColor; }
00599 
00600   /// Set help text
00601   void setHelpText(const FXString& text){ help=text; }
00602 
00603   /// Return help text
00604   FXString getHelpText() const { return help; }
00605 
00606   /// Set the tool tip message for this text widget
00607   void setTipText(const FXString& text){ tip=text; }
00608 
00609   /// Get the tool tip message for this text widget
00610   FXString getTipText() const { return tip; }
00611 
00612   /// Get character at position in text buffer
00613   FXint getByte(FXint pos) const;
00614 
00615   /// Get wide character at position pos
00616   FXwchar getChar(FXint pos) const;
00617 
00618   /// Get length of wide character at position pos
00619   FXint getCharLen(FXint pos) const;
00620 
00621   /// Get style at position pos
00622   FXint getStyle(FXint pos) const;
00623 
00624   /// Extract n bytes of text from position pos
00625   void extractText(FXchar *text,FXint pos,FXint n) const;
00626   void extractText(FXString& text,FXint pos,FXint n) const;
00627 
00628   /// Extract n bytes of style info from position pos
00629   void extractStyle(FXString& text,FXint pos,FXint n) const;
00630   void extractStyle(FXchar *style,FXint pos,FXint n) const;
00631 
00632   /// Replace m bytes at pos by n characters
00633   virtual void replaceText(FXint pos,FXint m,const FXchar *text,FXint n,FXbool notify=FALSE);
00634   virtual void replaceText(FXint pos,FXint m,const FXString& text,FXbool notify=FALSE);
00635 
00636   /// Replace m bytes at pos by n characters
00637   virtual void replaceStyledText(FXint pos,FXint m,const FXchar *text,FXint n,FXint style=0,FXbool notify=FALSE);
00638   virtual void replaceStyledText(FXint pos,FXint m,const FXString& text,FXint style=0,FXbool notify=FALSE);
00639 
00640   /// Append n bytes of text at the end of the buffer
00641   virtual void appendText(const FXchar *text,FXint n,FXbool notify=FALSE);
00642   virtual void appendText(const FXString& text,FXbool notify=FALSE);
00643 
00644   /// Append n bytes of text at the end of the buffer
00645   virtual void appendStyledText(const FXchar *text,FXint n,FXint style=0,FXbool notify=FALSE);
00646   virtual void appendStyledText(const FXString& text,FXint style=0,FXbool notify=FALSE);
00647 
00648   /// Insert n bytes of text at position pos into the buffer
00649   virtual void insertText(FXint pos,const FXchar *text,FXint n,FXbool notify=FALSE);
00650   virtual void insertText(FXint pos,const FXString& text,FXbool notify=FALSE);
00651 
00652   /// Insert n bytes of text at position pos into the buffer
00653   virtual void insertStyledText(FXint pos,const FXchar *text,FXint n,FXint style=0,FXbool notify=FALSE);
00654   virtual void insertStyledText(FXint pos,const FXString& text,FXint style=0,FXbool notify=FALSE);
00655 
00656   /// Remove n bytes of text at position pos from the buffer
00657   virtual void removeText(FXint pos,FXint n,FXbool notify=FALSE);
00658 
00659   /// Change style of text range
00660   virtual void changeStyle(FXint pos,FXint n,FXint style);
00661 
00662   /// Change style of text range from style-array
00663   virtual void changeStyle(FXint pos,const FXchar* style,FXint n);
00664   virtual void changeStyle(FXint pos,const FXString& style);
00665 
00666   /// Change the text in the buffer to new text
00667   virtual void setText(const FXchar* text,FXint n,FXbool notify=FALSE);
00668   virtual void setText(const FXString& text,FXbool notify=FALSE);
00669 
00670   /// Change the text in the buffer to new text
00671   virtual void setStyledText(const FXchar* text,FXint n,FXint style=0,FXbool notify=FALSE);
00672   virtual void setStyledText(const FXString& text,FXint style=0,FXbool notify=FALSE);
00673 
00674   /// Retrieve text into buffer
00675   void getText(FXchar* text,FXint n) const;
00676   void getText(FXString& text) const;
00677 
00678   /// Return text in the widget
00679   FXString getText() const;
00680 
00681   /// Return length of buffer
00682   FXint getLength() const { return length; }
00683 
00684   /// Return number of rows in buffer
00685   FXint getNumRows() const { return nrows; }
00686   
00687   /// Shift block of lines from position start up to end by given amount
00688   FXint shiftText(FXint start,FXint end,FXint amount,FXbool notify=FALSE);
00689 
00690   /**
00691   * Search for string in text buffer, returning the extent of
00692   * the string in beg and end.  The search starts from the given
00693   * starting position, scans forward (SEARCH_FORWARD) or backward
00694   * (SEARCH_BACKWARD), and wraps around if SEARCH_WRAP has been
00695   * specified.  The search type is either a plain search (SEARCH_EXACT),
00696   * case insensitive search (SEARCH_IGNORECASE), or regular expression
00697   * search (SEARCH_REGEX).
00698   * For regular expression searches, capturing parentheses are used if
00699   * npar is greater than 1; in this case, the number of entries in the
00700   * beg[], end[] arrays must be npar also.  If either beg or end or
00701   * both are NULL, internal arrays are used.
00702   * [This API is still subject to change!!]
00703   */
00704   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);
00705 
00706   /// Return TRUE if position pos is selected
00707   FXbool isPosSelected(FXint pos) const;
00708 
00709   /// Return TRUE if position is fully visible
00710   FXbool isPosVisible(FXint pos) const;
00711 
00712   /// Return text position at given visible x,y coordinate
00713   FXint getPosAt(FXint x,FXint y) const;
00714 
00715   /// Count number of rows; start should be on a row start
00716   FXint countRows(FXint start,FXint end) const;
00717 
00718   /// Count number of columns; start should be on a row start
00719   FXint countCols(FXint start,FXint end) const;
00720 
00721   /// Count number of newlines
00722   FXint countLines(FXint start,FXint end) const;
00723 
00724   /// Return position of begin of line containing position pos
00725   FXint lineStart(FXint pos) const;
00726 
00727   /// Return position of end of line containing position pos
00728   FXint lineEnd(FXint pos) const;
00729 
00730   /// Return start of next line
00731   FXint nextLine(FXint pos,FXint nl=1) const;
00732 
00733   /// Return start of previous line
00734   FXint prevLine(FXint pos,FXint nl=1) const;
00735 
00736   /// Return row start
00737   FXint rowStart(FXint pos) const;
00738 
00739   /// Return row end
00740   FXint rowEnd(FXint pos) const;
00741 
00742   /// Return start of next row
00743   FXint nextRow(FXint pos,FXint nr=1) const;
00744 
00745   /// Return start of previous row
00746   FXint prevRow(FXint pos,FXint nr=1) const;
00747 
00748   /// Return end of previous word
00749   FXint leftWord(FXint pos) const;
00750 
00751   /// Return begin of next word
00752   FXint rightWord(FXint pos) const;
00753 
00754   /// Return begin of word
00755   FXint wordStart(FXint pos) const;
00756 
00757   /// Return end of word
00758   FXint wordEnd(FXint pos) const;
00759 
00760   /// Return validated utf8 character start position
00761   FXint validPos(FXint pos) const;
00762 
00763   /// Retreat to the previous valid utf8 character start
00764   FXint dec(FXint pos) const;
00765 
00766   /// Advance to the next valid utf8 character start
00767   FXint inc(FXint pos) const;
00768 
00769   /// Make line containing pos the top line
00770   void setTopLine(FXint pos);
00771 
00772   /// Return position of top line
00773   FXint getTopLine() const;
00774 
00775   /// Make line containing pos the bottom line
00776   void setBottomLine(FXint pos);
00777 
00778   /// Return the position of the bottom line
00779   FXint getBottomLine() const;
00780 
00781   /// Make line containing pos the center line
00782   void setCenterLine(FXint pos);
00783 
00784   /// Set the anchor position
00785   void setAnchorPos(FXint pos);
00786 
00787   /// Return the anchor position
00788   FXint getAnchorPos() const { return anchorpos; }
00789 
00790   /// Set the cursor position
00791   virtual void setCursorPos(FXint pos,FXbool notify=FALSE);
00792 
00793   /// Set cursor row
00794   void setCursorRow(FXint row,FXbool notify=FALSE);
00795 
00796   /// Return cursor row
00797   FXint getCursorRow() const { return cursorrow; }
00798 
00799   /// Set cursor column
00800   void setCursorColumn(FXint col,FXbool notify=FALSE);
00801 
00802   /// Return cursor row, i.e. indent position
00803   FXint getCursorColumn() const { return cursorcol; }
00804 
00805   /// Return the cursor position
00806   FXint getCursorPos() const { return cursorpos; }
00807 
00808   /// Return selstartpos
00809   FXint getSelStartPos() const { return selstartpos; }
00810 
00811   /// Return selendpos
00812   FXint getSelEndPos() const { return selendpos; }
00813 
00814   /// Select all text
00815   FXbool selectAll(FXbool notify=FALSE);
00816 
00817   /// Extend the selection from the anchor to the given position
00818   virtual FXbool extendSelection(FXint pos,FXTextSelectionMode select=SELECT_CHARS,FXbool notify=FALSE);
00819 
00820   /// Select len characters starting at given position pos
00821   FXbool setSelection(FXint pos,FXint len,FXbool notify=FALSE);
00822 
00823   /// Unselect the text
00824   virtual FXbool killSelection(FXbool notify=FALSE);
00825 
00826   /// Highlight len characters starting at given position pos
00827   FXbool setHighlight(FXint start,FXint len);
00828 
00829   /// Unhighlight the text
00830   FXbool killHighlight();
00831 
00832   /// Scroll text to make the given position visible
00833   void makePositionVisible(FXint pos);
00834 
00835   /// Change text widget style
00836   void setTextStyle(FXuint style);
00837 
00838   /// Return text widget style
00839   FXuint getTextStyle() const;
00840 
00841   /// Change number of visible rows
00842   void setVisibleRows(FXint rows);
00843 
00844   /// Return number of visible rows
00845   FXint getVisibleRows() const { return vrows; }
00846 
00847   /// Change number of visible columns
00848   void setVisibleColumns(FXint cols);
00849 
00850   /// Return number of visible columns
00851   FXint getVisibleColumns() const { return vcols; }
00852 
00853   /**
00854   * Change brace and parenthesis match highlighting time, in ms.
00855   * A match highlight time of 0 disables brace matching.
00856   */
00857   void setHiliteMatchTime(FXuint t){ matchtime=t; }
00858 
00859   /**
00860   * Return brace and parenthesis match highlighting time, in ms.
00861   */
00862   FXuint getHiliteMatchTime() const { return matchtime; }
00863 
00864   /// Set highlight styles
00865   void setHiliteStyles(const FXHiliteStyle* styles);
00866 
00867   /// Get highlight styles
00868   const FXHiliteStyle* getHiliteStyles() const { return hilitestyles; }
00869 
00870   /// Save to a stream
00871   virtual void save(FXStream& store) const;
00872 
00873   /// Load from a stream
00874   virtual void load(FXStream& store);
00875 
00876   /// Destructor
00877   virtual ~FXText();
00878   };
00879 
00880 
00881 }
00882 
00883 #endif

Copyright © 1997-2005 Jeroen van der Zijp