aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/linden/indra/llui/llcombobox.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'linden/indra/llui/llcombobox.cpp')
-rw-r--r--linden/indra/llui/llcombobox.cpp108
1 files changed, 57 insertions, 51 deletions
diff --git a/linden/indra/llui/llcombobox.cpp b/linden/indra/llui/llcombobox.cpp
index d5edba7..48050db 100644
--- a/linden/indra/llui/llcombobox.cpp
+++ b/linden/indra/llui/llcombobox.cpp
@@ -59,7 +59,7 @@ S32 MAX_COMBO_WIDTH = 500;
59 59
60static LLRegisterWidget<LLComboBox> r1("combo_box"); 60static LLRegisterWidget<LLComboBox> r1("combo_box");
61 61
62LLComboBox::LLComboBox( const LLString& name, const LLRect &rect, const LLString& label, 62LLComboBox::LLComboBox( const std::string& name, const LLRect &rect, const std::string& label,
63 void (*commit_callback)(LLUICtrl*,void*), 63 void (*commit_callback)(LLUICtrl*,void*),
64 void *callback_userdata 64 void *callback_userdata
65 ) 65 )
@@ -78,12 +78,12 @@ LLComboBox::LLComboBox( const LLString& name, const LLRect &rect, const LLString
78 // Text label button 78 // Text label button
79 mButton = new LLButton(label, 79 mButton = new LLButton(label,
80 LLRect(), 80 LLRect(),
81 LLString::null, 81 LLStringUtil::null,
82 NULL, this); 82 NULL, this);
83 mButton->setImageUnselected("square_btn_32x128.tga"); 83 mButton->setImageUnselected(std::string("square_btn_32x128.tga"));
84 mButton->setImageSelected("square_btn_selected_32x128.tga"); 84 mButton->setImageSelected(std::string("square_btn_selected_32x128.tga"));
85 mButton->setImageDisabled("square_btn_32x128.tga"); 85 mButton->setImageDisabled(std::string("square_btn_32x128.tga"));
86 mButton->setImageDisabledSelected("square_btn_selected_32x128.tga"); 86 mButton->setImageDisabledSelected(std::string("square_btn_selected_32x128.tga"));
87 mButton->setScaleImage(TRUE); 87 mButton->setScaleImage(TRUE);
88 88
89 mButton->setMouseDownCallback(onButtonDown); 89 mButton->setMouseDownCallback(onButtonDown);
@@ -94,9 +94,8 @@ LLComboBox::LLComboBox( const LLString& name, const LLRect &rect, const LLString
94 addChild(mButton); 94 addChild(mButton);
95 95
96 // disallow multiple selection 96 // disallow multiple selection
97 mList = new LLScrollListCtrl( 97 mList = new LLScrollListCtrl(std::string("ComboBox"), LLRect(),
98 "ComboBox", LLRect(), 98 &LLComboBox::onItemSelected, this, FALSE);
99 &LLComboBox::onItemSelected, this, FALSE);
100 mList->setVisible(FALSE); 99 mList->setVisible(FALSE);
101 mList->setBgWriteableColor( LLColor4(1,1,1,1) ); 100 mList->setBgWriteableColor( LLColor4(1,1,1,1) );
102 mList->setCommitOnKeyboardMovement(FALSE); 101 mList->setCommitOnKeyboardMovement(FALSE);
@@ -149,10 +148,10 @@ LLXMLNodePtr LLComboBox::getXML(bool save_children) const
149// static 148// static
150LLView* LLComboBox::fromXML(LLXMLNodePtr node, LLView *parent, LLUICtrlFactory *factory) 149LLView* LLComboBox::fromXML(LLXMLNodePtr node, LLView *parent, LLUICtrlFactory *factory)
151{ 150{
152 LLString name("combo_box"); 151 std::string name("combo_box");
153 node->getAttributeString("name", name); 152 node->getAttributeString("name", name);
154 153
155 LLString label(""); 154 std::string label("");
156 node->getAttributeString("label", label); 155 node->getAttributeString("label", label);
157 156
158 LLRect rect; 157 LLRect rect;
@@ -175,7 +174,7 @@ LLView* LLComboBox::fromXML(LLXMLNodePtr node, LLView *parent, LLUICtrlFactory *
175 174
176 combo_box->initFromXML(node, parent); 175 combo_box->initFromXML(node, parent);
177 176
178 const LLString& contents = node->getValue(); 177 const std::string& contents = node->getValue();
179 178
180 if (contents.find_first_not_of(" \n\t") != contents.npos) 179 if (contents.find_first_not_of(" \n\t") != contents.npos)
181 { 180 {
@@ -188,9 +187,9 @@ LLView* LLComboBox::fromXML(LLXMLNodePtr node, LLView *parent, LLUICtrlFactory *
188 { 187 {
189 if (child->hasName("combo_item")) 188 if (child->hasName("combo_item"))
190 { 189 {
191 LLString label = child->getTextContents(); 190 std::string label = child->getTextContents();
192 191
193 LLString value = label; 192 std::string value = label;
194 child->getAttributeString("value", value); 193 child->getAttributeString("value", value);
195 194
196 combo_box->add(label, LLSD(value) ); 195 combo_box->add(label, LLSD(value) );
@@ -213,12 +212,12 @@ void LLComboBox::clear()
213{ 212{
214 if (mTextEntry) 213 if (mTextEntry)
215 { 214 {
216 mTextEntry->setText(LLString::null); 215 mTextEntry->setText(LLStringUtil::null);
217 } 216 }
218 mButton->setLabelSelected(LLString::null); 217 mButton->setLabelSelected(LLStringUtil::null);
219 mButton->setLabelUnselected(LLString::null); 218 mButton->setLabelUnselected(LLStringUtil::null);
220 mButton->setDisabledLabel(LLString::null); 219 mButton->setDisabledLabel(LLStringUtil::null);
221 mButton->setDisabledSelectedLabel(LLString::null); 220 mButton->setDisabledSelectedLabel(LLStringUtil::null);
222 mList->deselectAllItems(); 221 mList->deselectAllItems();
223} 222}
224 223
@@ -256,7 +255,7 @@ void LLComboBox::resetDirty()
256 255
257 256
258// add item "name" to menu 257// add item "name" to menu
259LLScrollListItem* LLComboBox::add(const LLString& name, EAddPosition pos, BOOL enabled) 258LLScrollListItem* LLComboBox::add(const std::string& name, EAddPosition pos, BOOL enabled)
260{ 259{
261 LLScrollListItem* item = mList->addSimpleElement(name, pos); 260 LLScrollListItem* item = mList->addSimpleElement(name, pos);
262 item->setEnabled(enabled); 261 item->setEnabled(enabled);
@@ -265,7 +264,7 @@ LLScrollListItem* LLComboBox::add(const LLString& name, EAddPosition pos, BOOL e
265} 264}
266 265
267// add item "name" with a unique id to menu 266// add item "name" with a unique id to menu
268LLScrollListItem* LLComboBox::add(const LLString& name, const LLUUID& id, EAddPosition pos, BOOL enabled ) 267LLScrollListItem* LLComboBox::add(const std::string& name, const LLUUID& id, EAddPosition pos, BOOL enabled )
269{ 268{
270 LLScrollListItem* item = mList->addSimpleElement(name, pos, id); 269 LLScrollListItem* item = mList->addSimpleElement(name, pos, id);
271 item->setEnabled(enabled); 270 item->setEnabled(enabled);
@@ -274,7 +273,7 @@ LLScrollListItem* LLComboBox::add(const LLString& name, const LLUUID& id, EAddPo
274} 273}
275 274
276// add item "name" with attached userdata 275// add item "name" with attached userdata
277LLScrollListItem* LLComboBox::add(const LLString& name, void* userdata, EAddPosition pos, BOOL enabled ) 276LLScrollListItem* LLComboBox::add(const std::string& name, void* userdata, EAddPosition pos, BOOL enabled )
278{ 277{
279 LLScrollListItem* item = mList->addSimpleElement(name, pos); 278 LLScrollListItem* item = mList->addSimpleElement(name, pos);
280 item->setEnabled(enabled); 279 item->setEnabled(enabled);
@@ -284,7 +283,7 @@ LLScrollListItem* LLComboBox::add(const LLString& name, void* userdata, EAddPosi
284} 283}
285 284
286// add item "name" with attached generic data 285// add item "name" with attached generic data
287LLScrollListItem* LLComboBox::add(const LLString& name, LLSD value, EAddPosition pos, BOOL enabled ) 286LLScrollListItem* LLComboBox::add(const std::string& name, LLSD value, EAddPosition pos, BOOL enabled )
288{ 287{
289 LLScrollListItem* item = mList->addSimpleElement(name, pos, value); 288 LLScrollListItem* item = mList->addSimpleElement(name, pos, value);
290 item->setEnabled(enabled); 289 item->setEnabled(enabled);
@@ -299,7 +298,7 @@ LLScrollListItem* LLComboBox::addSeparator(EAddPosition pos)
299 298
300void LLComboBox::sortByName() 299void LLComboBox::sortByName()
301{ 300{
302 mList->sortByColumn(0, TRUE); 301 mList->sortByColumnIndex(0, TRUE);
303} 302}
304 303
305 304
@@ -331,9 +330,9 @@ void LLComboBox::setValue(const LLSD& value)
331 } 330 }
332} 331}
333 332
334const LLString LLComboBox::getSimple() const 333const std::string LLComboBox::getSimple() const
335{ 334{
336 const LLString res = mList->getSelectedItemLabel(); 335 const std::string res = mList->getSelectedItemLabel();
337 if (res.empty() && mAllowTextEntry) 336 if (res.empty() && mAllowTextEntry)
338 { 337 {
339 return mTextEntry->getText(); 338 return mTextEntry->getText();
@@ -344,7 +343,7 @@ const LLString LLComboBox::getSimple() const
344 } 343 }
345} 344}
346 345
347const LLString LLComboBox::getSelectedItemLabel(S32 column) const 346const std::string LLComboBox::getSelectedItemLabel(S32 column) const
348{ 347{
349 return mList->getSelectedItemLabel(column); 348 return mList->getSelectedItemLabel(column);
350} 349}
@@ -392,7 +391,7 @@ void LLComboBox::setLabel(const LLStringExplicit& name)
392} 391}
393 392
394 393
395BOOL LLComboBox::remove(const LLString& name) 394BOOL LLComboBox::remove(const std::string& name)
396{ 395{
397 BOOL found = mList->selectItemByLabel(name); 396 BOOL found = mList->selectItemByLabel(name);
398 397
@@ -495,10 +494,10 @@ void LLComboBox::updateLayout()
495 LLRect text_entry_rect(0, getRect().getHeight(), getRect().getWidth(), 0); 494 LLRect text_entry_rect(0, getRect().getHeight(), getRect().getWidth(), 0);
496 text_entry_rect.mRight -= llmax(8,mArrowImage->getWidth()) + 2 * LLUI::sConfigGroup->getS32("DropShadowButton"); 495 text_entry_rect.mRight -= llmax(8,mArrowImage->getWidth()) + 2 * LLUI::sConfigGroup->getS32("DropShadowButton");
497 // clear label on button 496 // clear label on button
498 LLString cur_label = mButton->getLabelSelected(); 497 std::string cur_label = mButton->getLabelSelected();
499 mTextEntry = new LLLineEditor("combo_text_entry", 498 mTextEntry = new LLLineEditor(std::string("combo_text_entry"),
500 text_entry_rect, 499 text_entry_rect,
501 "", 500 LLStringUtil::null,
502 LLFontGL::sSansSerifSmall, 501 LLFontGL::sSansSerifSmall,
503 mMaxChars, 502 mMaxChars,
504 onTextCommit, 503 onTextCommit,
@@ -520,7 +519,7 @@ void LLComboBox::updateLayout()
520 } 519 }
521 520
522 // clear label on button 521 // clear label on button
523 setLabel(LLString::null); 522 setLabel(LLStringUtil::null);
524 523
525 mButton->setFollows(FOLLOWS_BOTTOM | FOLLOWS_TOP | FOLLOWS_RIGHT); 524 mButton->setFollows(FOLLOWS_BOTTOM | FOLLOWS_TOP | FOLLOWS_RIGHT);
526 } 525 }
@@ -647,7 +646,7 @@ void LLComboBox::showList()
647void LLComboBox::hideList() 646void LLComboBox::hideList()
648{ 647{
649 //*HACK: store the original value explicitly somewhere, not just in label 648 //*HACK: store the original value explicitly somewhere, not just in label
650 LLString orig_selection = mAllowTextEntry ? mTextEntry->getText() : mButton->getLabelSelected(); 649 std::string orig_selection = mAllowTextEntry ? mTextEntry->getText() : mButton->getLabelSelected();
651 650
652 // assert selection in list 651 // assert selection in list
653 mList->selectItemByLabel(orig_selection, FALSE); 652 mList->selectItemByLabel(orig_selection, FALSE);
@@ -712,7 +711,7 @@ void LLComboBox::onItemSelected(LLUICtrl* item, void *userdata)
712 // Note: item is the LLScrollListCtrl 711 // Note: item is the LLScrollListCtrl
713 LLComboBox *self = (LLComboBox *) userdata; 712 LLComboBox *self = (LLComboBox *) userdata;
714 713
715 const LLString name = self->mList->getSelectedItemLabel(); 714 const std::string name = self->mList->getSelectedItemLabel();
716 715
717 S32 cur_id = self->getCurrentIndex(); 716 S32 cur_id = self->getCurrentIndex();
718 if (cur_id != -1) 717 if (cur_id != -1)
@@ -733,9 +732,9 @@ void LLComboBox::onItemSelected(LLUICtrl* item, void *userdata)
733 self->onCommit(); 732 self->onCommit();
734} 733}
735 734
736BOOL LLComboBox::handleToolTip(S32 x, S32 y, LLString& msg, LLRect* sticky_rect_screen) 735BOOL LLComboBox::handleToolTip(S32 x, S32 y, std::string& msg, LLRect* sticky_rect_screen)
737{ 736{
738 LLString tool_tip; 737 std::string tool_tip;
739 738
740 if(LLUICtrl::handleToolTip(x, y, msg, sticky_rect_screen)) 739 if(LLUICtrl::handleToolTip(x, y, msg, sticky_rect_screen))
741 { 740 {
@@ -775,6 +774,12 @@ BOOL LLComboBox::handleKeyHere(KEY key, MASK mask)
775 BOOL result = FALSE; 774 BOOL result = FALSE;
776 if (hasFocus()) 775 if (hasFocus())
777 { 776 {
777 if (mList->getVisible()
778 && key == KEY_ESCAPE && mask == MASK_NONE)
779 {
780 hideList();
781 return TRUE;
782 }
778 //give list a chance to pop up and handle key 783 //give list a chance to pop up and handle key
779 LLScrollListItem* last_selected_item = mList->getLastSelectedItem(); 784 LLScrollListItem* last_selected_item = mList->getLastSelectedItem();
780 if (last_selected_item) 785 if (last_selected_item)
@@ -925,7 +930,7 @@ void LLComboBox::updateSelection()
925 // user-entered portion of string, based on assumption that any selected 930 // user-entered portion of string, based on assumption that any selected
926 // text was a result of auto-completion 931 // text was a result of auto-completion
927 LLWString user_wstring = mTextEntry->hasSelection() ? left_wstring : mTextEntry->getWText(); 932 LLWString user_wstring = mTextEntry->hasSelection() ? left_wstring : mTextEntry->getWText();
928 LLString full_string = mTextEntry->getText(); 933 std::string full_string = mTextEntry->getText();
929 934
930 // go ahead and arrange drop down list on first typed character, even 935 // go ahead and arrange drop down list on first typed character, even
931 // though we aren't showing it... some code relies on prearrange 936 // though we aren't showing it... some code relies on prearrange
@@ -963,7 +968,7 @@ void LLComboBox::updateSelection()
963void LLComboBox::onTextCommit(LLUICtrl* caller, void* user_data) 968void LLComboBox::onTextCommit(LLUICtrl* caller, void* user_data)
964{ 969{
965 LLComboBox* self = (LLComboBox*)user_data; 970 LLComboBox* self = (LLComboBox*)user_data;
966 LLString text = self->mTextEntry->getText(); 971 std::string text = self->mTextEntry->getText();
967 self->setSimple(text); 972 self->setSimple(text);
968 self->onCommit(); 973 self->onCommit();
969 self->mTextEntry->selectAll(); 974 self->mTextEntry->selectAll();
@@ -1002,7 +1007,7 @@ void LLComboBox::clearColumns()
1002 mList->clearColumns(); 1007 mList->clearColumns();
1003} 1008}
1004 1009
1005void LLComboBox::setColumnLabel(const LLString& column, const LLString& label) 1010void LLComboBox::setColumnLabel(const std::string& column, const std::string& label)
1006{ 1011{
1007 mList->setColumnLabel(column, label); 1012 mList->setColumnLabel(column, label);
1008} 1013}
@@ -1012,7 +1017,7 @@ LLScrollListItem* LLComboBox::addElement(const LLSD& value, EAddPosition pos, vo
1012 return mList->addElement(value, pos, userdata); 1017 return mList->addElement(value, pos, userdata);
1013} 1018}
1014 1019
1015LLScrollListItem* LLComboBox::addSimpleElement(const LLString& value, EAddPosition pos, const LLSD& id) 1020LLScrollListItem* LLComboBox::addSimpleElement(const std::string& value, EAddPosition pos, const LLSD& id)
1016{ 1021{
1017 return mList->addSimpleElement(value, pos, id); 1022 return mList->addSimpleElement(value, pos, id);
1018} 1023}
@@ -1022,8 +1027,9 @@ void LLComboBox::clearRows()
1022 mList->clearRows(); 1027 mList->clearRows();
1023} 1028}
1024 1029
1025void LLComboBox::sortByColumn(LLString name, BOOL ascending) 1030void LLComboBox::sortByColumn(const std::string& name, BOOL ascending)
1026{ 1031{
1032 mList->sortByColumn(name, ascending);
1027} 1033}
1028 1034
1029//============================================================================ 1035//============================================================================
@@ -1100,19 +1106,19 @@ static LLRegisterWidget<LLFlyoutButton> r2("flyout_button");
1100const S32 FLYOUT_BUTTON_ARROW_WIDTH = 24; 1106const S32 FLYOUT_BUTTON_ARROW_WIDTH = 24;
1101 1107
1102LLFlyoutButton::LLFlyoutButton( 1108LLFlyoutButton::LLFlyoutButton(
1103 const LLString& name, 1109 const std::string& name,
1104 const LLRect &rect, 1110 const LLRect &rect,
1105 const LLString& label, 1111 const std::string& label,
1106 void (*commit_callback)(LLUICtrl*, void*) , 1112 void (*commit_callback)(LLUICtrl*, void*) ,
1107 void *callback_userdata) 1113 void *callback_userdata)
1108: LLComboBox(name, rect, LLString::null, commit_callback, callback_userdata), 1114: LLComboBox(name, rect, LLStringUtil::null, commit_callback, callback_userdata),
1109 mToggleState(FALSE), 1115 mToggleState(FALSE),
1110 mActionButton(NULL) 1116 mActionButton(NULL)
1111{ 1117{
1112 // Always use text box 1118 // Always use text box
1113 // Text label button 1119 // Text label button
1114 mActionButton = new LLButton(label, 1120 mActionButton = new LLButton(label,
1115 LLRect(), LLString::null, NULL, this); 1121 LLRect(), LLStringUtil::null, NULL, this);
1116 mActionButton->setScaleImage(TRUE); 1122 mActionButton->setScaleImage(TRUE);
1117 1123
1118 mActionButton->setClickedCallback(onActionButtonClick); 1124 mActionButton->setClickedCallback(onActionButtonClick);
@@ -1145,10 +1151,10 @@ LLFlyoutButton::LLFlyoutButton(
1145//static 1151//static
1146LLView* LLFlyoutButton::fromXML(LLXMLNodePtr node, LLView *parent, LLUICtrlFactory *factory) 1152LLView* LLFlyoutButton::fromXML(LLXMLNodePtr node, LLView *parent, LLUICtrlFactory *factory)
1147{ 1153{
1148 LLString name = "flyout_button"; 1154 std::string name = "flyout_button";
1149 node->getAttributeString("name", name); 1155 node->getAttributeString("name", name);
1150 1156
1151 LLString label(""); 1157 std::string label("");
1152 node->getAttributeString("label", label); 1158 node->getAttributeString("label", label);
1153 1159
1154 LLRect rect; 1160 LLRect rect;
@@ -1162,7 +1168,7 @@ LLView* LLFlyoutButton::fromXML(LLXMLNodePtr node, LLView *parent, LLUICtrlFacto
1162 callback, 1168 callback,
1163 NULL); 1169 NULL);
1164 1170
1165 LLString list_position; 1171 std::string list_position;
1166 node->getAttributeString("list_position", list_position); 1172 node->getAttributeString("list_position", list_position);
1167 if (list_position == "below") 1173 if (list_position == "below")
1168 { 1174 {
@@ -1181,9 +1187,9 @@ LLView* LLFlyoutButton::fromXML(LLXMLNodePtr node, LLView *parent, LLUICtrlFacto
1181 { 1187 {
1182 if (child->hasName("flyout_button_item")) 1188 if (child->hasName("flyout_button_item"))
1183 { 1189 {
1184 LLString label = child->getTextContents(); 1190 std::string label = child->getTextContents();
1185 1191
1186 LLString value = label; 1192 std::string value = label;
1187 child->getAttributeString("value", value); 1193 child->getAttributeString("value", value);
1188 1194
1189 flyout_button->add(label, LLSD(value) ); 1195 flyout_button->add(label, LLSD(value) );
@@ -1225,7 +1231,7 @@ void LLFlyoutButton::draw()
1225 1231
1226 //FIXME: this should be an attribute of comboboxes, whether they have a distinct label or 1232 //FIXME: this should be an attribute of comboboxes, whether they have a distinct label or
1227 // the label reflects the last selected item, for now we have to manually remove the label 1233 // the label reflects the last selected item, for now we have to manually remove the label
1228 mButton->setLabel(LLString::null); 1234 mButton->setLabel(LLStringUtil::null);
1229 LLComboBox::draw(); 1235 LLComboBox::draw();
1230} 1236}
1231 1237