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