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