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