aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/linden/indra/llui/llspinctrl.cpp
diff options
context:
space:
mode:
authorJacek Antonelli2008-09-06 18:24:57 -0500
committerJacek Antonelli2008-09-06 18:25:07 -0500
commit798d367d54a6c6379ad355bd8345fa40e31e7fe9 (patch)
tree1921f1708cd0240648c97bc02df2c2ab5f2fc41e /linden/indra/llui/llspinctrl.cpp
parentSecond Life viewer sources 1.20.15 (diff)
downloadmeta-impy-798d367d54a6c6379ad355bd8345fa40e31e7fe9.zip
meta-impy-798d367d54a6c6379ad355bd8345fa40e31e7fe9.tar.gz
meta-impy-798d367d54a6c6379ad355bd8345fa40e31e7fe9.tar.bz2
meta-impy-798d367d54a6c6379ad355bd8345fa40e31e7fe9.tar.xz
Second Life viewer sources 1.21.0-RC
Diffstat (limited to 'linden/indra/llui/llspinctrl.cpp')
-rw-r--r--linden/indra/llui/llspinctrl.cpp63
1 files changed, 35 insertions, 28 deletions
diff --git a/linden/indra/llui/llspinctrl.cpp b/linden/indra/llui/llspinctrl.cpp
index f196975..a106af4 100644
--- a/linden/indra/llui/llspinctrl.cpp
+++ b/linden/indra/llui/llspinctrl.cpp
@@ -44,7 +44,6 @@
44#include "lltextbox.h" 44#include "lltextbox.h"
45#include "llkeyboard.h" 45#include "llkeyboard.h"
46#include "llmath.h" 46#include "llmath.h"
47#include "sound_ids.h"
48#include "audioengine.h" 47#include "audioengine.h"
49#include "llcontrol.h" 48#include "llcontrol.h"
50#include "llfocusmgr.h" 49#include "llfocusmgr.h"
@@ -54,11 +53,11 @@ const U32 MAX_STRING_LENGTH = 32;
54 53
55static LLRegisterWidget<LLSpinCtrl> r2("spinner"); 54static LLRegisterWidget<LLSpinCtrl> r2("spinner");
56 55
57LLSpinCtrl::LLSpinCtrl( const LLString& name, const LLRect& rect, const LLString& label, const LLFontGL* font, 56LLSpinCtrl::LLSpinCtrl( const std::string& name, const LLRect& rect, const std::string& label, const LLFontGL* font,
58 void (*commit_callback)(LLUICtrl*, void*), 57 void (*commit_callback)(LLUICtrl*, void*),
59 void* callback_user_data, 58 void* callback_user_data,
60 F32 initial_value, F32 min_value, F32 max_value, F32 increment, 59 F32 initial_value, F32 min_value, F32 max_value, F32 increment,
61 const LLString& control_name, 60 const std::string& control_name,
62 S32 label_width) 61 S32 label_width)
63 : 62 :
64 LLUICtrl(name, rect, TRUE, commit_callback, callback_user_data, FOLLOWS_LEFT | FOLLOWS_TOP ), 63 LLUICtrl(name, rect, TRUE, commit_callback, callback_user_data, FOLLOWS_LEFT | FOLLOWS_TOP ),
@@ -83,7 +82,7 @@ LLSpinCtrl::LLSpinCtrl( const LLString& name, const LLRect& rect, const LLString
83 if( !label.empty() ) 82 if( !label.empty() )
84 { 83 {
85 LLRect label_rect( 0, centered_top, label_width, centered_bottom ); 84 LLRect label_rect( 0, centered_top, label_width, centered_bottom );
86 mLabelBox = new LLTextBox( "SpinCtrl Label", label_rect, label.c_str(), font ); 85 mLabelBox = new LLTextBox( std::string("SpinCtrl Label"), label_rect, label, font );
87 addChild(mLabelBox); 86 addChild(mLabelBox);
88 87
89 btn_left += label_rect.mRight + SPINCTRL_SPACING; 88 btn_left += label_rect.mRight + SPINCTRL_SPACING;
@@ -93,14 +92,13 @@ LLSpinCtrl::LLSpinCtrl( const LLString& name, const LLRect& rect, const LLString
93 92
94 // Spin buttons 93 // Spin buttons
95 LLRect up_rect( btn_left, top, btn_right, top - SPINCTRL_BTN_HEIGHT ); 94 LLRect up_rect( btn_left, top, btn_right, top - SPINCTRL_BTN_HEIGHT );
96 LLString out_id = "UIImgBtnSpinUpOutUUID"; 95 std::string out_id = "UIImgBtnSpinUpOutUUID";
97 LLString in_id = "UIImgBtnSpinUpInUUID"; 96 std::string in_id = "UIImgBtnSpinUpInUUID";
98 mUpBtn = new LLButton( 97 mUpBtn = new LLButton(std::string("SpinCtrl Up"), up_rect,
99 "SpinCtrl Up", up_rect, 98 out_id,
100 out_id, 99 in_id,
101 in_id, 100 LLStringUtil::null,
102 "", 101 &LLSpinCtrl::onUpBtn, this, LLFontGL::sSansSerif );
103 &LLSpinCtrl::onUpBtn, this, LLFontGL::sSansSerif );
104 mUpBtn->setFollowsLeft(); 102 mUpBtn->setFollowsLeft();
105 mUpBtn->setFollowsBottom(); 103 mUpBtn->setFollowsBottom();
106 mUpBtn->setHeldDownCallback( &LLSpinCtrl::onUpBtn ); 104 mUpBtn->setHeldDownCallback( &LLSpinCtrl::onUpBtn );
@@ -110,12 +108,11 @@ LLSpinCtrl::LLSpinCtrl( const LLString& name, const LLRect& rect, const LLString
110 LLRect down_rect( btn_left, top - SPINCTRL_BTN_HEIGHT, btn_right, bottom ); 108 LLRect down_rect( btn_left, top - SPINCTRL_BTN_HEIGHT, btn_right, bottom );
111 out_id = "UIImgBtnSpinDownOutUUID"; 109 out_id = "UIImgBtnSpinDownOutUUID";
112 in_id = "UIImgBtnSpinDownInUUID"; 110 in_id = "UIImgBtnSpinDownInUUID";
113 mDownBtn = new LLButton( 111 mDownBtn = new LLButton(std::string("SpinCtrl Down"), down_rect,
114 "SpinCtrl Down", down_rect, 112 out_id,
115 out_id, 113 in_id,
116 in_id, 114 LLStringUtil::null,
117 "", 115 &LLSpinCtrl::onDownBtn, this, LLFontGL::sSansSerif );
118 &LLSpinCtrl::onDownBtn, this, LLFontGL::sSansSerif );
119 mDownBtn->setFollowsLeft(); 116 mDownBtn->setFollowsLeft();
120 mDownBtn->setFollowsBottom(); 117 mDownBtn->setFollowsBottom();
121 mDownBtn->setHeldDownCallback( &LLSpinCtrl::onDownBtn ); 118 mDownBtn->setHeldDownCallback( &LLSpinCtrl::onDownBtn );
@@ -123,10 +120,10 @@ LLSpinCtrl::LLSpinCtrl( const LLString& name, const LLRect& rect, const LLString
123 addChild(mDownBtn); 120 addChild(mDownBtn);
124 121
125 LLRect editor_rect( btn_right + 1, centered_top, getRect().getWidth(), centered_bottom ); 122 LLRect editor_rect( btn_right + 1, centered_top, getRect().getWidth(), centered_bottom );
126 mEditor = new LLLineEditor( "SpinCtrl Editor", editor_rect, "", font, 123 mEditor = new LLLineEditor( std::string("SpinCtrl Editor"), editor_rect, LLStringUtil::null, font,
127 MAX_STRING_LENGTH, 124 MAX_STRING_LENGTH,
128 &LLSpinCtrl::onEditorCommit, NULL, NULL, this, 125 &LLSpinCtrl::onEditorCommit, NULL, NULL, this,
129 &LLLineEditor::prevalidateFloat ); 126 &LLLineEditor::prevalidateFloat );
130 mEditor->setFollowsLeft(); 127 mEditor->setFollowsLeft();
131 mEditor->setFollowsBottom(); 128 mEditor->setFollowsBottom();
132 mEditor->setFocusReceivedCallback( &LLSpinCtrl::onEditorGainFocus, this ); 129 mEditor->setFocusReceivedCallback( &LLSpinCtrl::onEditorGainFocus, this );
@@ -283,8 +280,8 @@ void LLSpinCtrl::updateEditor()
283// displayed_value = 0.f; 280// displayed_value = 0.f;
284// } 281// }
285 282
286 LLString format = llformat("%%.%df", mPrecision); 283 std::string format = llformat("%%.%df", mPrecision);
287 LLString text = llformat(format.c_str(), displayed_value); 284 std::string text = llformat(format.c_str(), displayed_value);
288 mEditor->setText( text ); 285 mEditor->setText( text );
289} 286}
290 287
@@ -295,7 +292,7 @@ void LLSpinCtrl::onEditorCommit( LLUICtrl* caller, void *userdata )
295 LLSpinCtrl* self = (LLSpinCtrl*) userdata; 292 LLSpinCtrl* self = (LLSpinCtrl*) userdata;
296 llassert( caller == self->mEditor ); 293 llassert( caller == self->mEditor );
297 294
298 LLString text = self->mEditor->getText(); 295 std::string text = self->mEditor->getText();
299 if( LLLineEditor::postvalidateFloat( text ) ) 296 if( LLLineEditor::postvalidateFloat( text ) )
300 { 297 {
301 LLLocale locale(LLLocale::USER_LOCALE); 298 LLLocale locale(LLLocale::USER_LOCALE);
@@ -399,6 +396,12 @@ void LLSpinCtrl::setLabel(const LLStringExplicit& label)
399 } 396 }
400} 397}
401 398
399void LLSpinCtrl::setAllowEdit(BOOL allow_edit)
400{
401 mEditor->setEnabled(allow_edit);
402 mAllowEdit = allow_edit;
403}
404
402void LLSpinCtrl::onTabInto() 405void LLSpinCtrl::onTabInto()
403{ 406{
404 mEditor->onTabInto(); 407 mEditor->onTabInto();
@@ -494,10 +497,10 @@ LLXMLNodePtr LLSpinCtrl::getXML(bool save_children) const
494 497
495LLView* LLSpinCtrl::fromXML(LLXMLNodePtr node, LLView *parent, LLUICtrlFactory *factory) 498LLView* LLSpinCtrl::fromXML(LLXMLNodePtr node, LLView *parent, LLUICtrlFactory *factory)
496{ 499{
497 LLString name("spinner"); 500 std::string name("spinner");
498 node->getAttributeString("name", name); 501 node->getAttributeString("name", name);
499 502
500 LLString label; 503 std::string label;
501 node->getAttributeString("label", label); 504 node->getAttributeString("label", label);
502 505
503 LLRect rect; 506 LLRect rect;
@@ -523,6 +526,9 @@ LLView* LLSpinCtrl::fromXML(LLXMLNodePtr node, LLView *parent, LLUICtrlFactory *
523 S32 label_width = llmin(40, rect.getWidth() - 40); 526 S32 label_width = llmin(40, rect.getWidth() - 40);
524 node->getAttributeS32("label_width", label_width); 527 node->getAttributeS32("label_width", label_width);
525 528
529 BOOL allow_text_entry = TRUE;
530 node->getAttributeBOOL("allow_text_entry", allow_text_entry);
531
526 LLUICtrlCallback callback = NULL; 532 LLUICtrlCallback callback = NULL;
527 533
528 if(label.empty()) 534 if(label.empty())
@@ -540,12 +546,13 @@ LLView* LLSpinCtrl::fromXML(LLXMLNodePtr node, LLView *parent, LLUICtrlFactory *
540 min_value, 546 min_value,
541 max_value, 547 max_value,
542 increment, 548 increment,
543 "", 549 LLStringUtil::null,
544 label_width); 550 label_width);
545 551
546 spinner->setPrecision(precision); 552 spinner->setPrecision(precision);
547 553
548 spinner->initFromXML(node, parent); 554 spinner->initFromXML(node, parent);
555 spinner->setAllowEdit(allow_text_entry);
549 556
550 return spinner; 557 return spinner;
551} 558}