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