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

FXText.h

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