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