/indra/llui/lltextbase.h

https://bitbucket.org/lindenlab/viewer-beta/ · C Header · 578 lines · 410 code · 89 blank · 79 comment · 1 complexity · c40bfc78813bd2f2200f2dc5bb6743dc MD5 · raw file

  1. /**
  2. * @file lltextbase.h
  3. * @author Martin Reddy
  4. * @brief The base class of text box/editor, providing Url handling support
  5. *
  6. * $LicenseInfo:firstyear=2009&license=viewerlgpl$
  7. * Second Life Viewer Source Code
  8. * Copyright (C) 2010, Linden Research, Inc.
  9. *
  10. * This library is free software; you can redistribute it and/or
  11. * modify it under the terms of the GNU Lesser General Public
  12. * License as published by the Free Software Foundation;
  13. * version 2.1 of the License only.
  14. *
  15. * This library is distributed in the hope that it will be useful,
  16. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  17. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  18. * Lesser General Public License for more details.
  19. *
  20. * You should have received a copy of the GNU Lesser General Public
  21. * License along with this library; if not, write to the Free Software
  22. * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  23. *
  24. * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA
  25. * $/LicenseInfo$
  26. */
  27. #ifndef LL_LLTEXTBASE_H
  28. #define LL_LLTEXTBASE_H
  29. #include "v4color.h"
  30. #include "lleditmenuhandler.h"
  31. #include "llstyle.h"
  32. #include "llkeywords.h"
  33. #include "llpanel.h"
  34. #include <string>
  35. #include <vector>
  36. #include <set>
  37. #include <boost/signals2.hpp>
  38. class LLContextMenu;
  39. class LLUrlMatch;
  40. ///
  41. /// A text segment is used to specify a subsection of a text string
  42. /// that should be formatted differently, such as a hyperlink. It
  43. /// includes a start/end offset from the start of the string, a
  44. /// style to render with, an optional tooltip, etc.
  45. ///
  46. class LLTextSegment : public LLRefCount, public LLMouseHandler
  47. {
  48. public:
  49. LLTextSegment(S32 start, S32 end) : mStart(start), mEnd(end){};
  50. virtual ~LLTextSegment();
  51. virtual bool getDimensions(S32 first_char, S32 num_chars, S32& width, S32& height) const;
  52. virtual S32 getOffset(S32 segment_local_x_coord, S32 start_offset, S32 num_chars, bool round) const;
  53. virtual S32 getNumChars(S32 num_pixels, S32 segment_offset, S32 line_offset, S32 max_chars) const;
  54. virtual void updateLayout(const class LLTextBase& editor);
  55. virtual F32 draw(S32 start, S32 end, S32 selection_start, S32 selection_end, const LLRect& draw_rect);
  56. virtual bool canEdit() const;
  57. virtual void unlinkFromDocument(class LLTextBase* editor);
  58. virtual void linkToDocument(class LLTextBase* editor);
  59. virtual const LLColor4& getColor() const;
  60. //virtual void setColor(const LLColor4 &color);
  61. virtual LLStyleConstSP getStyle() const;
  62. virtual void setStyle(LLStyleConstSP style);
  63. virtual void setToken( LLKeywordToken* token );
  64. virtual LLKeywordToken* getToken() const;
  65. virtual void setToolTip(const std::string& tooltip);
  66. virtual void dump() const;
  67. // LLMouseHandler interface
  68. /*virtual*/ BOOL handleMouseDown(S32 x, S32 y, MASK mask);
  69. /*virtual*/ BOOL handleMouseUp(S32 x, S32 y, MASK mask);
  70. /*virtual*/ BOOL handleMiddleMouseDown(S32 x, S32 y, MASK mask);
  71. /*virtual*/ BOOL handleMiddleMouseUp(S32 x, S32 y, MASK mask);
  72. /*virtual*/ BOOL handleRightMouseDown(S32 x, S32 y, MASK mask);
  73. /*virtual*/ BOOL handleRightMouseUp(S32 x, S32 y, MASK mask);
  74. /*virtual*/ BOOL handleDoubleClick(S32 x, S32 y, MASK mask);
  75. /*virtual*/ BOOL handleHover(S32 x, S32 y, MASK mask);
  76. /*virtual*/ BOOL handleScrollWheel(S32 x, S32 y, S32 clicks);
  77. /*virtual*/ BOOL handleToolTip(S32 x, S32 y, MASK mask);
  78. /*virtual*/ const std::string& getName() const;
  79. /*virtual*/ void onMouseCaptureLost();
  80. /*virtual*/ void screenPointToLocal(S32 screen_x, S32 screen_y, S32* local_x, S32* local_y) const;
  81. /*virtual*/ void localPointToScreen(S32 local_x, S32 local_y, S32* screen_x, S32* screen_y) const;
  82. /*virtual*/ BOOL hasMouseCapture();
  83. S32 getStart() const { return mStart; }
  84. void setStart(S32 start) { mStart = start; }
  85. S32 getEnd() const { return mEnd; }
  86. void setEnd( S32 end ) { mEnd = end; }
  87. protected:
  88. S32 mStart;
  89. S32 mEnd;
  90. };
  91. class LLNormalTextSegment : public LLTextSegment
  92. {
  93. public:
  94. LLNormalTextSegment( LLStyleConstSP style, S32 start, S32 end, LLTextBase& editor );
  95. LLNormalTextSegment( const LLColor4& color, S32 start, S32 end, LLTextBase& editor, BOOL is_visible = TRUE);
  96. ~LLNormalTextSegment();
  97. /*virtual*/ bool getDimensions(S32 first_char, S32 num_chars, S32& width, S32& height) const;
  98. /*virtual*/ S32 getOffset(S32 segment_local_x_coord, S32 start_offset, S32 num_chars, bool round) const;
  99. /*virtual*/ S32 getNumChars(S32 num_pixels, S32 segment_offset, S32 line_offset, S32 max_chars) const;
  100. /*virtual*/ F32 draw(S32 start, S32 end, S32 selection_start, S32 selection_end, const LLRect& draw_rect);
  101. /*virtual*/ bool canEdit() const { return true; }
  102. /*virtual*/ const LLColor4& getColor() const { return mStyle->getColor(); }
  103. /*virtual*/ LLStyleConstSP getStyle() const { return mStyle; }
  104. /*virtual*/ void setStyle(LLStyleConstSP style) { mStyle = style; }
  105. /*virtual*/ void setToken( LLKeywordToken* token ) { mToken = token; }
  106. /*virtual*/ LLKeywordToken* getToken() const { return mToken; }
  107. /*virtual*/ BOOL getToolTip( std::string& msg ) const;
  108. /*virtual*/ void setToolTip(const std::string& tooltip);
  109. /*virtual*/ void dump() const;
  110. /*virtual*/ BOOL handleHover(S32 x, S32 y, MASK mask);
  111. /*virtual*/ BOOL handleRightMouseDown(S32 x, S32 y, MASK mask);
  112. /*virtual*/ BOOL handleMouseDown(S32 x, S32 y, MASK mask);
  113. /*virtual*/ BOOL handleMouseUp(S32 x, S32 y, MASK mask);
  114. /*virtual*/ BOOL handleToolTip(S32 x, S32 y, MASK mask);
  115. protected:
  116. F32 drawClippedSegment(S32 seg_start, S32 seg_end, S32 selection_start, S32 selection_end, LLRect rect);
  117. protected:
  118. class LLTextBase& mEditor;
  119. LLStyleConstSP mStyle;
  120. S32 mFontHeight;
  121. LLKeywordToken* mToken;
  122. std::string mTooltip;
  123. boost::signals2::connection mImageLoadedConnection;
  124. };
  125. // Text segment that changes it's style depending of mouse pointer position ( is it inside or outside segment)
  126. class LLOnHoverChangeableTextSegment : public LLNormalTextSegment
  127. {
  128. public:
  129. LLOnHoverChangeableTextSegment( LLStyleConstSP style, LLStyleConstSP normal_style, S32 start, S32 end, LLTextBase& editor );
  130. /*virtual*/ F32 draw(S32 start, S32 end, S32 selection_start, S32 selection_end, const LLRect& draw_rect);
  131. /*virtual*/ BOOL handleHover(S32 x, S32 y, MASK mask);
  132. protected:
  133. // Style used for text when mouse pointer is over segment
  134. LLStyleConstSP mHoveredStyle;
  135. // Style used for text when mouse pointer is outside segment
  136. LLStyleConstSP mNormalStyle;
  137. };
  138. class LLIndexSegment : public LLTextSegment
  139. {
  140. public:
  141. LLIndexSegment() : LLTextSegment(0, 0) {}
  142. };
  143. class LLInlineViewSegment : public LLTextSegment
  144. {
  145. public:
  146. struct Params : public LLInitParam::Block<Params>
  147. {
  148. Mandatory<LLView*> view;
  149. Optional<bool> force_newline;
  150. Optional<S32> left_pad,
  151. right_pad,
  152. bottom_pad,
  153. top_pad;
  154. };
  155. LLInlineViewSegment(const Params& p, S32 start, S32 end);
  156. ~LLInlineViewSegment();
  157. /*virtual*/ bool getDimensions(S32 first_char, S32 num_chars, S32& width, S32& height) const;
  158. /*virtual*/ S32 getNumChars(S32 num_pixels, S32 segment_offset, S32 line_offset, S32 max_chars) const;
  159. /*virtual*/ void updateLayout(const class LLTextBase& editor);
  160. /*virtual*/ F32 draw(S32 start, S32 end, S32 selection_start, S32 selection_end, const LLRect& draw_rect);
  161. /*virtual*/ bool canEdit() const { return false; }
  162. /*virtual*/ void unlinkFromDocument(class LLTextBase* editor);
  163. /*virtual*/ void linkToDocument(class LLTextBase* editor);
  164. private:
  165. S32 mLeftPad;
  166. S32 mRightPad;
  167. S32 mTopPad;
  168. S32 mBottomPad;
  169. LLView* mView;
  170. bool mForceNewLine;
  171. };
  172. class LLLineBreakTextSegment : public LLTextSegment
  173. {
  174. public:
  175. LLLineBreakTextSegment(LLStyleConstSP style,S32 pos);
  176. LLLineBreakTextSegment(S32 pos);
  177. ~LLLineBreakTextSegment();
  178. bool getDimensions(S32 first_char, S32 num_chars, S32& width, S32& height) const;
  179. S32 getNumChars(S32 num_pixels, S32 segment_offset, S32 line_offset, S32 max_chars) const;
  180. F32 draw(S32 start, S32 end, S32 selection_start, S32 selection_end, const LLRect& draw_rect);
  181. private:
  182. S32 mFontHeight;
  183. };
  184. class LLImageTextSegment : public LLTextSegment
  185. {
  186. public:
  187. LLImageTextSegment(LLStyleConstSP style,S32 pos,class LLTextBase& editor);
  188. ~LLImageTextSegment();
  189. bool getDimensions(S32 first_char, S32 num_chars, S32& width, S32& height) const;
  190. S32 getNumChars(S32 num_pixels, S32 segment_offset, S32 line_offset, S32 max_chars) const;
  191. F32 draw(S32 start, S32 end, S32 selection_start, S32 selection_end, const LLRect& draw_rect);
  192. private:
  193. class LLTextBase& mEditor;
  194. LLStyleConstSP mStyle;
  195. };
  196. typedef LLPointer<LLTextSegment> LLTextSegmentPtr;
  197. ///
  198. /// The LLTextBase class provides a base class for all text fields, such
  199. /// as LLTextEditor and LLTextBox. It implements shared functionality
  200. /// such as Url highlighting and opening.
  201. ///
  202. class LLTextBase
  203. : public LLUICtrl,
  204. protected LLEditMenuHandler
  205. {
  206. public:
  207. friend class LLTextSegment;
  208. friend class LLNormalTextSegment;
  209. friend class LLUICtrlFactory;
  210. struct LineSpacingParams : public LLInitParam::ChoiceBlock<LineSpacingParams>
  211. {
  212. Alternative<F32> multiple;
  213. Alternative<S32> pixels;
  214. LineSpacingParams();
  215. };
  216. struct Params : public LLInitParam::Block<Params, LLUICtrl::Params>
  217. {
  218. Optional<LLUIColor> cursor_color,
  219. text_color,
  220. text_readonly_color,
  221. bg_readonly_color,
  222. bg_writeable_color,
  223. bg_focus_color,
  224. text_selected_color,
  225. bg_selected_color;
  226. Optional<bool> bg_visible,
  227. border_visible,
  228. track_end,
  229. read_only,
  230. allow_scroll,
  231. plain_text,
  232. wrap,
  233. use_ellipses,
  234. parse_urls,
  235. parse_highlights,
  236. clip,
  237. clip_partial;
  238. Optional<S32> v_pad,
  239. h_pad;
  240. Optional<LineSpacingParams>
  241. line_spacing;
  242. Optional<S32> max_text_length;
  243. Optional<LLFontGL::ShadowType> font_shadow;
  244. Params();
  245. };
  246. // LLMouseHandler interface
  247. /*virtual*/ BOOL handleMouseDown(S32 x, S32 y, MASK mask);
  248. /*virtual*/ BOOL handleMouseUp(S32 x, S32 y, MASK mask);
  249. /*virtual*/ BOOL handleMiddleMouseDown(S32 x, S32 y, MASK mask);
  250. /*virtual*/ BOOL handleMiddleMouseUp(S32 x, S32 y, MASK mask);
  251. /*virtual*/ BOOL handleRightMouseDown(S32 x, S32 y, MASK mask);
  252. /*virtual*/ BOOL handleRightMouseUp(S32 x, S32 y, MASK mask);
  253. /*virtual*/ BOOL handleDoubleClick(S32 x, S32 y, MASK mask);
  254. /*virtual*/ BOOL handleHover(S32 x, S32 y, MASK mask);
  255. /*virtual*/ BOOL handleScrollWheel(S32 x, S32 y, S32 clicks);
  256. /*virtual*/ BOOL handleToolTip(S32 x, S32 y, MASK mask);
  257. // LLView interface
  258. /*virtual*/ void reshape(S32 width, S32 height, BOOL called_from_parent = TRUE);
  259. /*virtual*/ void draw();
  260. // LLUICtrl interface
  261. /*virtual*/ BOOL acceptsTextInput() const { return !mReadOnly; }
  262. /*virtual*/ void setColor( const LLColor4& c );
  263. virtual void setReadOnlyColor(const LLColor4 &c);
  264. virtual void handleVisibilityChange( BOOL new_visibility );
  265. /*virtual*/ void setValue(const LLSD& value );
  266. /*virtual*/ LLTextViewModel* getViewModel() const;
  267. // LLEditMenuHandler interface
  268. /*virtual*/ BOOL canDeselect() const;
  269. /*virtual*/ void deselect();
  270. // used by LLTextSegment layout code
  271. bool getWordWrap() { return mWordWrap; }
  272. bool getUseEllipses() { return mUseEllipses; }
  273. bool truncate(); // returns true of truncation occurred
  274. // TODO: move into LLTextSegment?
  275. void createUrlContextMenu(S32 x, S32 y, const std::string &url); // create a popup context menu for the given Url
  276. // Text accessors
  277. // TODO: add optional style parameter
  278. virtual void setText(const LLStringExplicit &utf8str , const LLStyle::Params& input_params = LLStyle::Params()); // uses default style
  279. virtual std::string getText() const;
  280. void setMaxTextLength(S32 length) { mMaxTextByteLength = length; }
  281. // wide-char versions
  282. void setWText(const LLWString& text);
  283. const LLWString& getWText() const;
  284. void appendText(const std::string &new_text, bool prepend_newline, const LLStyle::Params& input_params = LLStyle::Params());
  285. // force reflow of text
  286. void needsReflow(S32 index = 0);
  287. S32 getLength() const { return getWText().length(); }
  288. S32 getLineCount() const { return mLineInfoList.size(); }
  289. void addDocumentChild(LLView* view);
  290. void removeDocumentChild(LLView* view);
  291. const LLView* getDocumentView() const { return mDocumentView; }
  292. LLRect getVisibleTextRect() const { return mVisibleTextRect; }
  293. LLRect getTextBoundingRect();
  294. LLRect getVisibleDocumentRect() const;
  295. S32 getVPad() { return mVPad; }
  296. S32 getHPad() { return mHPad; }
  297. S32 getDocIndexFromLocalCoord( S32 local_x, S32 local_y, BOOL round, bool hit_past_end_of_line = true) const;
  298. LLRect getLocalRectFromDocIndex(S32 pos) const;
  299. LLRect getDocRectFromDocIndex(S32 pos) const;
  300. void setReadOnly(bool read_only) { mReadOnly = read_only; }
  301. bool getReadOnly() { return mReadOnly; }
  302. void setPlainText(bool value) { mPlainText = value;}
  303. bool getPlainText() const { return mPlainText; }
  304. // cursor manipulation
  305. bool setCursor(S32 row, S32 column);
  306. bool setCursorPos(S32 cursor_pos, bool keep_cursor_offset = false);
  307. void startOfLine();
  308. void endOfLine();
  309. void startOfDoc();
  310. void endOfDoc();
  311. void changePage( S32 delta );
  312. void changeLine( S32 delta );
  313. bool scrolledToStart();
  314. bool scrolledToEnd();
  315. const LLFontGL* getDefaultFont() const { return mDefaultFont; }
  316. virtual void appendLineBreakSegment(const LLStyle::Params& style_params);
  317. virtual void appendImageSegment(const LLStyle::Params& style_params);
  318. virtual void appendWidget(const LLInlineViewSegment::Params& params, const std::string& text, bool allow_undo);
  319. boost::signals2::connection setURLClickedCallback(const commit_signal_t::slot_type& cb);
  320. protected:
  321. // helper structs
  322. struct compare_bottom;
  323. struct compare_top;
  324. struct line_end_compare;
  325. typedef std::vector<LLTextSegmentPtr> segment_vec_t;
  326. // Abstract inner base class representing an undoable editor command.
  327. // Concrete sub-classes can be defined for operations such as insert, remove, etc.
  328. // Used as arguments to the execute() method below.
  329. class TextCmd
  330. {
  331. public:
  332. TextCmd( S32 pos, BOOL group_with_next, LLTextSegmentPtr segment = LLTextSegmentPtr() )
  333. : mPos(pos),
  334. mGroupWithNext(group_with_next)
  335. {
  336. if (segment.notNull())
  337. {
  338. mSegments.push_back(segment);
  339. }
  340. }
  341. virtual ~TextCmd() {}
  342. virtual BOOL execute(LLTextBase* editor, S32* delta) = 0;
  343. virtual S32 undo(LLTextBase* editor) = 0;
  344. virtual S32 redo(LLTextBase* editor) = 0;
  345. virtual BOOL canExtend(S32 pos) const { return FALSE; }
  346. virtual void blockExtensions() {}
  347. virtual BOOL extendAndExecute( LLTextBase* editor, S32 pos, llwchar c, S32* delta ) { llassert(0); return 0; }
  348. virtual BOOL hasExtCharValue( llwchar value ) const { return FALSE; }
  349. // Defined here so they can access protected LLTextEditor editing methods
  350. S32 insert(LLTextBase* editor, S32 pos, const LLWString &wstr) { return editor->insertStringNoUndo( pos, wstr, &mSegments ); }
  351. S32 remove(LLTextBase* editor, S32 pos, S32 length) { return editor->removeStringNoUndo( pos, length ); }
  352. S32 overwrite(LLTextBase* editor, S32 pos, llwchar wc) { return editor->overwriteCharNoUndo(pos, wc); }
  353. S32 getPosition() const { return mPos; }
  354. BOOL groupWithNext() const { return mGroupWithNext; }
  355. protected:
  356. const S32 mPos;
  357. BOOL mGroupWithNext;
  358. segment_vec_t mSegments;
  359. };
  360. struct compare_segment_end
  361. {
  362. bool operator()(const LLTextSegmentPtr& a, const LLTextSegmentPtr& b) const;
  363. };
  364. typedef std::multiset<LLTextSegmentPtr, compare_segment_end> segment_set_t;
  365. // protected member variables
  366. // List of offsets and segment index of the start of each line. Always has at least one node (0).
  367. struct line_info
  368. {
  369. line_info(S32 index_start, S32 index_end, LLRect rect, S32 line_num);
  370. S32 mDocIndexStart;
  371. S32 mDocIndexEnd;
  372. LLRect mRect;
  373. S32 mLineNum; // actual line count (ignoring soft newlines due to word wrap)
  374. };
  375. typedef std::vector<line_info> line_list_t;
  376. // member functions
  377. LLTextBase(const Params &p);
  378. virtual ~LLTextBase();
  379. void initFromParams(const Params& p);
  380. virtual void onValueChange(S32 start, S32 end);
  381. // draw methods
  382. void drawSelectionBackground(); // draws the black box behind the selected text
  383. void drawCursor();
  384. void drawText();
  385. // modify contents
  386. S32 insertStringNoUndo(S32 pos, const LLWString &wstr, segment_vec_t* segments = NULL); // returns num of chars actually inserted
  387. S32 removeStringNoUndo(S32 pos, S32 length);
  388. S32 overwriteCharNoUndo(S32 pos, llwchar wc);
  389. void appendAndHighlightText(const std::string &new_text, S32 highlight_part, const LLStyle::Params& stylep, bool underline_on_hover_only = false);
  390. // manage segments
  391. void getSegmentAndOffset( S32 startpos, segment_set_t::const_iterator* seg_iter, S32* offsetp ) const;
  392. void getSegmentAndOffset( S32 startpos, segment_set_t::iterator* seg_iter, S32* offsetp );
  393. LLTextSegmentPtr getSegmentAtLocalPos( S32 x, S32 y, bool hit_past_end_of_line = true);
  394. segment_set_t::iterator getEditableSegIterContaining(S32 index);
  395. segment_set_t::const_iterator getEditableSegIterContaining(S32 index) const;
  396. segment_set_t::iterator getSegIterContaining(S32 index);
  397. segment_set_t::const_iterator getSegIterContaining(S32 index) const;
  398. void clearSegments();
  399. void createDefaultSegment();
  400. virtual void updateSegments();
  401. void insertSegment(LLTextSegmentPtr segment_to_insert);
  402. const LLStyle::Params& getDefaultStyleParams();
  403. // manage lines
  404. S32 getLineStart( S32 line ) const;
  405. S32 getLineEnd( S32 line ) const;
  406. S32 getLineNumFromDocIndex( S32 doc_index, bool include_wordwrap = true) const;
  407. S32 getLineOffsetFromDocIndex( S32 doc_index, bool include_wordwrap = true) const;
  408. S32 getFirstVisibleLine() const;
  409. std::pair<S32, S32> getVisibleLines(bool fully_visible = false);
  410. S32 getLeftOffset(S32 width);
  411. void reflow();
  412. // cursor
  413. void updateCursorXPos();
  414. void setCursorAtLocalPos( S32 local_x, S32 local_y, bool round, bool keep_cursor_offset=false );
  415. S32 getEditableIndex(S32 index, bool increasing_direction); // constraint cursor to editable segments of document
  416. void resetCursorBlink() { mCursorBlinkTimer.reset(); }
  417. void updateScrollFromCursor();
  418. // text selection
  419. bool hasSelection() const { return (mSelectionStart !=mSelectionEnd); }
  420. void startSelection();
  421. void endSelection();
  422. // misc
  423. void updateRects();
  424. void needsScroll() { mScrollNeeded = TRUE; }
  425. struct URLLabelCallback;
  426. // Replace a URL with a new icon and label, for example, when
  427. // avatar names are looked up.
  428. void replaceUrl(const std::string &url, const std::string &label, const std::string& icon);
  429. void appendTextImpl(const std::string &new_text, const LLStyle::Params& input_params = LLStyle::Params());
  430. void appendAndHighlightTextImpl(const std::string &new_text, S32 highlight_part, const LLStyle::Params& style_params, bool underline_on_hover_only = false);
  431. protected:
  432. // text segmentation and flow
  433. segment_set_t mSegments;
  434. line_list_t mLineInfoList;
  435. LLRect mVisibleTextRect; // The rect in which text is drawn. Excludes borders.
  436. LLRect mTextBoundingRect;
  437. // default text style
  438. LLStyle::Params mDefaultStyle;
  439. bool mStyleDirty;
  440. const LLFontGL* const mDefaultFont; // font that is used when none specified, can only be set by constructor
  441. const LLFontGL::ShadowType mFontShadow; // shadow style, can only be set by constructor
  442. // colors
  443. LLUIColor mCursorColor;
  444. LLUIColor mFgColor;
  445. LLUIColor mReadOnlyFgColor;
  446. LLUIColor mWriteableBgColor;
  447. LLUIColor mReadOnlyBgColor;
  448. LLUIColor mFocusBgColor;
  449. LLUIColor mTextSelectedColor;
  450. LLUIColor mSelectedBGColor;
  451. // cursor
  452. S32 mCursorPos; // I-beam is just after the mCursorPos-th character.
  453. S32 mDesiredXPixel; // X pixel position where the user wants the cursor to be
  454. LLFrameTimer mCursorBlinkTimer; // timer that controls cursor blinking
  455. // selection
  456. S32 mSelectionStart;
  457. S32 mSelectionEnd;
  458. BOOL mIsSelecting; // Are we in the middle of a drag-select?
  459. // configuration
  460. S32 mHPad; // padding on left of text
  461. S32 mVPad; // padding above text
  462. LLFontGL::HAlign mHAlign;
  463. LLFontGL::VAlign mVAlign;
  464. F32 mLineSpacingMult; // multiple of line height used as space for a single line of text (e.g. 1.5 to get 50% padding)
  465. S32 mLineSpacingPixels; // padding between lines
  466. bool mBorderVisible;
  467. bool mParseHTML; // make URLs interactive
  468. bool mParseHighlights; // highlight user-defined keywords
  469. bool mWordWrap;
  470. bool mUseEllipses;
  471. bool mTrackEnd; // if true, keeps scroll position at end of document during resize
  472. bool mReadOnly;
  473. bool mBGVisible; // render background?
  474. bool mClip; // clip text to widget rect
  475. bool mClipPartial; // false if we show lines that are partially inside bounding rect
  476. bool mPlainText; // didn't use Image or Icon segments
  477. S32 mMaxTextByteLength; // Maximum length mText is allowed to be in bytes
  478. // support widgets
  479. LLContextMenu* mPopupMenu;
  480. LLView* mDocumentView;
  481. class LLScrollContainer* mScroller;
  482. // transient state
  483. S32 mReflowIndex; // index at which to start reflow. S32_MAX indicates no reflow needed.
  484. bool mScrollNeeded; // need to change scroll region because of change to cursor position
  485. S32 mScrollIndex; // index of first character to keep visible in scroll region
  486. // Fired when a URL link is clicked
  487. commit_signal_t* mURLClickSignal;
  488. };
  489. #endif