aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/linden/indra/llui/lltextbox.cpp
diff options
context:
space:
mode:
authorJacek Antonelli2009-04-30 13:04:20 -0500
committerJacek Antonelli2009-04-30 13:07:16 -0500
commitca8149ca6d157eb4b5fc8ba0e5ba3a6e56f72e7e (patch)
tree8348301d0ac44a524f1819b777686bf086907d76 /linden/indra/llui/lltextbox.cpp
parentSecond Life viewer sources 1.22.11 (diff)
downloadmeta-impy-ca8149ca6d157eb4b5fc8ba0e5ba3a6e56f72e7e.zip
meta-impy-ca8149ca6d157eb4b5fc8ba0e5ba3a6e56f72e7e.tar.gz
meta-impy-ca8149ca6d157eb4b5fc8ba0e5ba3a6e56f72e7e.tar.bz2
meta-impy-ca8149ca6d157eb4b5fc8ba0e5ba3a6e56f72e7e.tar.xz
Second Life viewer sources 1.23.0-RC
Diffstat (limited to '')
-rw-r--r--linden/indra/llui/lltextbox.cpp113
1 files changed, 36 insertions, 77 deletions
diff --git a/linden/indra/llui/lltextbox.cpp b/linden/indra/llui/lltextbox.cpp
index f43b7d2..89893bc 100644
--- a/linden/indra/llui/lltextbox.cpp
+++ b/linden/indra/llui/lltextbox.cpp
@@ -17,7 +17,8 @@
17 * There are special exceptions to the terms and conditions of the GPL as 17 * There are special exceptions to the terms and conditions of the GPL as
18 * it is applied to this Source Code. View the full text of the exception 18 * it is applied to this Source Code. View the full text of the exception
19 * in the file doc/FLOSS-exception.txt in this software distribution, or 19 * in the file doc/FLOSS-exception.txt in this software distribution, or
20 * online at http://secondlifegrid.net/programs/open_source/licensing/flossexception 20 * online at
21 * http://secondlifegrid.net/programs/open_source/licensing/flossexception
21 * 22 *
22 * By copying, modifying or distributing this software, you acknowledge 23 * By copying, modifying or distributing this software, you acknowledge
23 * that you have read and understood your obligations described above, 24 * that you have read and understood your obligations described above,
@@ -33,32 +34,16 @@
33#include "lltextbox.h" 34#include "lltextbox.h"
34#include "lluictrlfactory.h" 35#include "lluictrlfactory.h"
35#include "llfocusmgr.h" 36#include "llfocusmgr.h"
37#include "llwindow.h"
36 38
37static LLRegisterWidget<LLTextBox> r("text"); 39static LLRegisterWidget<LLTextBox> r("text");
38 40
39LLTextBox::LLTextBox(const std::string& name, const LLRect& rect, const std::string& text, 41LLTextBox::LLTextBox(const std::string& name, const LLRect& rect, const std::string& text,
40 const LLFontGL* font, BOOL mouse_opaque) 42 const LLFontGL* font, BOOL mouse_opaque)
41: LLUICtrl(name, rect, mouse_opaque, NULL, NULL, FOLLOWS_LEFT | FOLLOWS_TOP ), 43: LLUICtrl(name, rect, mouse_opaque, NULL, NULL, FOLLOWS_LEFT | FOLLOWS_TOP ),
42 mFontGL(font ? font : LLFontGL::sSansSerifSmall), 44 mFontGL(font ? font : LLFontGL::getFontSansSerifSmall())
43 mTextColor( LLUI::sColorsGroup->getColor( "LabelTextColor" ) ),
44 mDisabledColor( LLUI::sColorsGroup->getColor( "LabelDisabledColor" ) ),
45 mBackgroundColor( LLUI::sColorsGroup->getColor( "DefaultBackgroundColor" ) ),
46 mBorderColor( LLUI::sColorsGroup->getColor( "DefaultHighlightLight" ) ),
47 mHoverColor( LLUI::sColorsGroup->getColor( "LabelSelectedColor" ) ),
48 mHoverActive( FALSE ),
49 mHasHover( FALSE ),
50 mBackgroundVisible( FALSE ),
51 mBorderVisible( FALSE ),
52 mFontStyle(LLFontGL::DROP_SHADOW_SOFT),
53 mBorderDropShadowVisible( FALSE ),
54 mUseEllipses( FALSE ),
55 mHPad(0),
56 mVPad(0),
57 mHAlign( LLFontGL::LEFT ),
58 mVAlign( LLFontGL::TOP ),
59 mClickedCallback(NULL),
60 mCallbackUserData(NULL)
61{ 45{
46 initDefaults();
62 setText( text ); 47 setText( text );
63 setTabStop(FALSE); 48 setTabStop(FALSE);
64} 49}
@@ -66,26 +51,9 @@ LLTextBox::LLTextBox(const std::string& name, const LLRect& rect, const std::str
66LLTextBox::LLTextBox(const std::string& name, const std::string& text, F32 max_width, 51LLTextBox::LLTextBox(const std::string& name, const std::string& text, F32 max_width,
67 const LLFontGL* font, BOOL mouse_opaque) : 52 const LLFontGL* font, BOOL mouse_opaque) :
68 LLUICtrl(name, LLRect(0, 0, 1, 1), mouse_opaque, NULL, NULL, FOLLOWS_LEFT | FOLLOWS_TOP), 53 LLUICtrl(name, LLRect(0, 0, 1, 1), mouse_opaque, NULL, NULL, FOLLOWS_LEFT | FOLLOWS_TOP),
69 mFontGL(font ? font : LLFontGL::sSansSerifSmall), 54 mFontGL(font ? font : LLFontGL::getFontSansSerifSmall())
70 mTextColor(LLUI::sColorsGroup->getColor("LabelTextColor")),
71 mDisabledColor(LLUI::sColorsGroup->getColor("LabelDisabledColor")),
72 mBackgroundColor(LLUI::sColorsGroup->getColor("DefaultBackgroundColor")),
73 mBorderColor(LLUI::sColorsGroup->getColor("DefaultHighlightLight")),
74 mHoverColor( LLUI::sColorsGroup->getColor( "LabelSelectedColor" ) ),
75 mHoverActive( FALSE ),
76 mHasHover( FALSE ),
77 mBackgroundVisible(FALSE),
78 mBorderVisible(FALSE),
79 mFontStyle(LLFontGL::DROP_SHADOW_SOFT),
80 mBorderDropShadowVisible(FALSE),
81 mUseEllipses( FALSE ),
82 mHPad(0),
83 mVPad(0),
84 mHAlign(LLFontGL::LEFT),
85 mVAlign( LLFontGL::TOP ),
86 mClickedCallback(NULL),
87 mCallbackUserData(NULL)
88{ 55{
56 initDefaults();
89 setWrappedText(text, max_width); 57 setWrappedText(text, max_width);
90 reshapeToFitText(); 58 reshapeToFitText();
91 setTabStop(FALSE); 59 setTabStop(FALSE);
@@ -93,47 +61,34 @@ LLTextBox::LLTextBox(const std::string& name, const std::string& text, F32 max_w
93 61
94LLTextBox::LLTextBox(const std::string& name_and_label, const LLRect& rect) : 62LLTextBox::LLTextBox(const std::string& name_and_label, const LLRect& rect) :
95 LLUICtrl(name_and_label, rect, TRUE, NULL, NULL, FOLLOWS_LEFT | FOLLOWS_TOP), 63 LLUICtrl(name_and_label, rect, TRUE, NULL, NULL, FOLLOWS_LEFT | FOLLOWS_TOP),
96 mFontGL(LLFontGL::sSansSerifSmall), 64 mFontGL(LLFontGL::getFontSansSerifSmall())
97 mTextColor(LLUI::sColorsGroup->getColor("LabelTextColor")),
98 mDisabledColor(LLUI::sColorsGroup->getColor("LabelDisabledColor")),
99 mBackgroundColor(LLUI::sColorsGroup->getColor("DefaultBackgroundColor")),
100 mBorderColor(LLUI::sColorsGroup->getColor("DefaultHighlightLight")),
101 mBackgroundVisible(FALSE),
102 mBorderVisible(FALSE),
103 mFontStyle(LLFontGL::DROP_SHADOW_SOFT),
104 mBorderDropShadowVisible(FALSE),
105 mHPad(0),
106 mVPad(0),
107 mHAlign(LLFontGL::LEFT),
108 mVAlign( LLFontGL::TOP ),
109 mClickedCallback(NULL),
110 mCallbackUserData(NULL)
111{ 65{
66 initDefaults();
112 setText( name_and_label ); 67 setText( name_and_label );
113 setTabStop(FALSE); 68 setTabStop(FALSE);
114} 69}
115 70
116LLTextBox::LLTextBox(const std::string& name_and_label) : 71void LLTextBox::initDefaults()
117 LLUICtrl(name_and_label, LLRect(0, 0, 1, 1), TRUE, NULL, NULL, FOLLOWS_LEFT | FOLLOWS_TOP),
118 mFontGL(LLFontGL::sSansSerifSmall),
119 mTextColor(LLUI::sColorsGroup->getColor("LabelTextColor")),
120 mDisabledColor(LLUI::sColorsGroup->getColor("LabelDisabledColor")),
121 mBackgroundColor(LLUI::sColorsGroup->getColor("DefaultBackgroundColor")),
122 mBorderColor(LLUI::sColorsGroup->getColor("DefaultHighlightLight")),
123 mBackgroundVisible(FALSE),
124 mBorderVisible(FALSE),
125 mFontStyle(LLFontGL::DROP_SHADOW_SOFT),
126 mBorderDropShadowVisible(FALSE),
127 mHPad(0),
128 mVPad(0),
129 mHAlign(LLFontGL::LEFT),
130 mVAlign( LLFontGL::TOP ),
131 mClickedCallback(NULL),
132 mCallbackUserData(NULL)
133{ 72{
134 setWrappedText(name_and_label); 73 mTextColor = LLUI::sColorsGroup->getColor("LabelTextColor");
135 reshapeToFitText(); 74 mDisabledColor = LLUI::sColorsGroup->getColor("LabelDisabledColor");
136 setTabStop(FALSE); 75 mBackgroundColor = LLUI::sColorsGroup->getColor("DefaultBackgroundColor");
76 mBorderColor = LLUI::sColorsGroup->getColor("DefaultHighlightLight");
77 mHoverColor = LLUI::sColorsGroup->getColor( "LabelSelectedColor" );
78 mHoverActive = FALSE;
79 mHasHover = FALSE;
80 mBackgroundVisible = FALSE;
81 mBorderVisible = FALSE;
82 mFontStyle = LLFontGL::DROP_SHADOW_SOFT;
83 mBorderDropShadowVisible = FALSE;
84 mUseEllipses = FALSE;
85 mLineSpacing = 0;
86 mHPad = 0;
87 mVPad = 0;
88 mHAlign = LLFontGL::LEFT;
89 mVAlign = LLFontGL::TOP;
90 mClickedCallback = NULL;
91 mCallbackUserData = NULL;
137} 92}
138 93
139BOOL LLTextBox::handleMouseDown(S32 x, S32 y, MASK mask) 94BOOL LLTextBox::handleMouseDown(S32 x, S32 y, MASK mask)
@@ -193,12 +148,14 @@ BOOL LLTextBox::handleMouseUp(S32 x, S32 y, MASK mask)
193 148
194BOOL LLTextBox::handleHover(S32 x, S32 y, MASK mask) 149BOOL LLTextBox::handleHover(S32 x, S32 y, MASK mask)
195{ 150{
151 BOOL handled = LLView::handleHover(x,y,mask);
196 if(mHoverActive) 152 if(mHoverActive)
197 { 153 {
198 mHasHover = TRUE; // This should be set every frame during a hover. 154 mHasHover = TRUE; // This should be set every frame during a hover.
199 return TRUE; 155 getWindow()->setCursor(UI_CURSOR_ARROW);
200 } 156 }
201 return LLView::handleHover(x,y,mask); 157
158 return (handled || mHasHover);
202} 159}
203 160
204void LLTextBox::setText(const LLStringExplicit& text) 161void LLTextBox::setText(const LLStringExplicit& text)
@@ -412,7 +369,7 @@ void LLTextBox::drawText( S32 x, S32 y, const LLColor4& color )
412 mFontStyle, 369 mFontStyle,
413 line_length, getRect().getWidth(), NULL, TRUE, mUseEllipses ); 370 line_length, getRect().getWidth(), NULL, TRUE, mUseEllipses );
414 cur_pos += line_length + 1; 371 cur_pos += line_length + 1;
415 y -= llfloor(mFontGL->getLineHeight()); 372 y -= llfloor(mFontGL->getLineHeight()) + mLineSpacing;
416 } 373 }
417 } 374 }
418} 375}
@@ -469,6 +426,8 @@ LLView* LLTextBox::fromXML(LLXMLNodePtr node, LLView *parent, LLUICtrlFactory *f
469 426
470 text_box->initFromXML(node, parent); 427 text_box->initFromXML(node, parent);
471 428
429 node->getAttributeS32("line_spacing", text_box->mLineSpacing);
430
472 std::string font_style; 431 std::string font_style;
473 if (node->getAttributeString("font-style", font_style)) 432 if (node->getAttributeString("font-style", font_style))
474 { 433 {