aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/linden/indra
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--linden/indra/llui/llcombobox.cpp25
-rw-r--r--linden/indra/llui/llcombobox.h4
-rw-r--r--linden/indra/llui/llscrolllistctrl.cpp28
-rw-r--r--linden/indra/llui/llscrolllistctrl.h3
-rw-r--r--linden/indra/newview/llfloatertest.cpp4
-rw-r--r--linden/indra/newview/llnamelistctrl.cpp2
6 files changed, 51 insertions, 15 deletions
diff --git a/linden/indra/llui/llcombobox.cpp b/linden/indra/llui/llcombobox.cpp
index be34325..a93dc9b 100644
--- a/linden/indra/llui/llcombobox.cpp
+++ b/linden/indra/llui/llcombobox.cpp
@@ -43,6 +43,7 @@
43 43
44// newview includes 44// newview includes
45#include "llbutton.h" 45#include "llbutton.h"
46#include "llfont.h"
46#include "llkeyboard.h" 47#include "llkeyboard.h"
47#include "llscrolllistctrl.h" 48#include "llscrolllistctrl.h"
48#include "llwindow.h" 49#include "llwindow.h"
@@ -60,7 +61,7 @@ S32 MAX_COMBO_WIDTH = 500;
60 61
61static LLRegisterWidget<LLComboBox> r1("combo_box"); 62static LLRegisterWidget<LLComboBox> r1("combo_box");
62 63
63LLComboBox::LLComboBox( const std::string& name, const LLRect &rect, const std::string& label, 64LLComboBox::LLComboBox( const std::string& name, const LLRect &rect, const std::string& label, const LLFontGL* font,
64 void (*commit_callback)(LLUICtrl*,void*), 65 void (*commit_callback)(LLUICtrl*,void*),
65 void *callback_userdata 66 void *callback_userdata
66 ) 67 )
@@ -76,6 +77,15 @@ LLComboBox::LLComboBox( const std::string& name, const LLRect &rect, const std::
76 mTextEntryCallback( NULL ), 77 mTextEntryCallback( NULL ),
77 mLabel(label) 78 mLabel(label)
78{ 79{
80 if (font)
81 {
82 mGLFont = font;
83 }
84 else
85 {
86 mGLFont = LLFontGL::getFontSansSerifSmall();
87 }
88
79 // Always use text box 89 // Always use text box
80 // Text label button 90 // Text label button
81 mButton = new LLButton(mLabel, 91 mButton = new LLButton(mLabel,
@@ -89,14 +99,14 @@ LLComboBox::LLComboBox( const std::string& name, const LLRect &rect, const std::
89 mButton->setScaleImage(TRUE); 99 mButton->setScaleImage(TRUE);
90 100
91 mButton->setMouseDownCallback(onButtonDown); 101 mButton->setMouseDownCallback(onButtonDown);
92 mButton->setFont(LLFontGL::getFontSansSerifSmall()); 102 mButton->setFont(mGLFont);
93 mButton->setFollows(FOLLOWS_LEFT | FOLLOWS_BOTTOM | FOLLOWS_RIGHT); 103 mButton->setFollows(FOLLOWS_LEFT | FOLLOWS_BOTTOM | FOLLOWS_RIGHT);
94 mButton->setHAlign( LLFontGL::LEFT ); 104 mButton->setHAlign( LLFontGL::LEFT );
95 mButton->setRightHPad(2); 105 mButton->setRightHPad(2);
96 addChild(mButton); 106 addChild(mButton);
97 107
98 // disallow multiple selection 108 // disallow multiple selection
99 mList = new LLScrollListCtrl(std::string("ComboBox"), LLRect(), 109 mList = new LLScrollListCtrl(std::string("ComboBox"), LLRect(), mGLFont,
100 &LLComboBox::onItemSelected, this, FALSE); 110 &LLComboBox::onItemSelected, this, FALSE);
101 mList->setVisible(FALSE); 111 mList->setVisible(FALSE);
102 mList->setBgWriteableColor( LLColor4(1,1,1,1) ); 112 mList->setBgWriteableColor( LLColor4(1,1,1,1) );
@@ -167,11 +177,14 @@ LLView* LLComboBox::fromXML(LLXMLNodePtr node, LLView *parent, LLUICtrlFactory *
167 S32 max_chars = 20; 177 S32 max_chars = 20;
168 node->getAttributeS32("max_chars", max_chars); 178 node->getAttributeS32("max_chars", max_chars);
169 179
180 LLFontGL* font = LLView::selectFont(node);
181
170 LLUICtrlCallback callback = NULL; 182 LLUICtrlCallback callback = NULL;
171 183
172 LLComboBox* combo_box = new LLComboBox(name, 184 LLComboBox* combo_box = new LLComboBox(name,
173 rect, 185 rect,
174 label, 186 label,
187 font,
175 callback, 188 callback,
176 NULL); 189 NULL);
177 combo_box->setAllowTextEntry(allow_text_entry, max_chars); 190 combo_box->setAllowTextEntry(allow_text_entry, max_chars);
@@ -540,7 +553,7 @@ void LLComboBox::updateLayout()
540 mTextEntry = new LLLineEditor(std::string("combo_text_entry"), 553 mTextEntry = new LLLineEditor(std::string("combo_text_entry"),
541 text_entry_rect, 554 text_entry_rect,
542 LLStringUtil::null, 555 LLStringUtil::null,
543 LLFontGL::getFontSansSerifSmall(), 556 mGLFont,
544 mMaxChars, 557 mMaxChars,
545 onTextCommit, 558 onTextCommit,
546 onTextEntry, 559 onTextEntry,
@@ -1153,7 +1166,7 @@ LLFlyoutButton::LLFlyoutButton(
1153 const std::string& label, 1166 const std::string& label,
1154 void (*commit_callback)(LLUICtrl*, void*) , 1167 void (*commit_callback)(LLUICtrl*, void*) ,
1155 void *callback_userdata) 1168 void *callback_userdata)
1156: LLComboBox(name, rect, LLStringUtil::null, commit_callback, callback_userdata), 1169: LLComboBox(name, rect, LLStringUtil::null, NULL, commit_callback, callback_userdata),
1157 mToggleState(FALSE), 1170 mToggleState(FALSE),
1158 mActionButton(NULL) 1171 mActionButton(NULL)
1159{ 1172{
@@ -1214,6 +1227,8 @@ LLXMLNodePtr LLFlyoutButton::getXML(bool save_children) const
1214 } 1227 }
1215 } 1228 }
1216 1229
1230 node->createChild("font", TRUE)->setStringValue(LLFontGL::nameFromFont(mGLFont));
1231
1217 return node; 1232 return node;
1218} 1233}
1219 1234
diff --git a/linden/indra/llui/llcombobox.h b/linden/indra/llui/llcombobox.h
index 95ad17a..596f659 100644
--- a/linden/indra/llui/llcombobox.h
+++ b/linden/indra/llui/llcombobox.h
@@ -67,7 +67,8 @@ public:
67 LLComboBox( 67 LLComboBox(
68 const std::string& name, 68 const std::string& name,
69 const LLRect &rect, 69 const LLRect &rect,
70 const std::string& label, 70 const std::string& label,
71 const LLFontGL* font = NULL,
71 void (*commit_callback)(LLUICtrl*, void*) = NULL, 72 void (*commit_callback)(LLUICtrl*, void*) = NULL,
72 void *callback_userdata = NULL 73 void *callback_userdata = NULL
73 ); 74 );
@@ -190,6 +191,7 @@ protected:
190 EPreferredPosition mListPosition; 191 EPreferredPosition mListPosition;
191 LLPointer<LLUIImage> mArrowImage; 192 LLPointer<LLUIImage> mArrowImage;
192 std::string mLabel; 193 std::string mLabel;
194 const LLFontGL* mGLFont;
193 195
194private: 196private:
195 S32 mButtonPadding; 197 S32 mButtonPadding;
diff --git a/linden/indra/llui/llscrolllistctrl.cpp b/linden/indra/llui/llscrolllistctrl.cpp
index 1248a9a..1b93abf 100644
--- a/linden/indra/llui/llscrolllistctrl.cpp
+++ b/linden/indra/llui/llscrolllistctrl.cpp
@@ -570,7 +570,7 @@ void LLScrollListItemSeparator::draw(const LLRect& rect, const LLColor4& fg_colo
570// LLScrollListCtrl 570// LLScrollListCtrl
571//--------------------------------------------------------------------------- 571//---------------------------------------------------------------------------
572 572
573LLScrollListCtrl::LLScrollListCtrl(const std::string& name, const LLRect& rect, 573LLScrollListCtrl::LLScrollListCtrl(const std::string& name, const LLRect& rect, const LLFontGL* font,
574 void (*commit_callback)(LLUICtrl* ctrl, void* userdata), 574 void (*commit_callback)(LLUICtrl* ctrl, void* userdata),
575 void* callback_user_data, 575 void* callback_user_data,
576 BOOL allow_multiple_selection, 576 BOOL allow_multiple_selection,
@@ -619,6 +619,15 @@ LLScrollListCtrl::LLScrollListCtrl(const std::string& name, const LLRect& rect,
619 mOriginalSelection(-1), 619 mOriginalSelection(-1),
620 mDrewSelected(FALSE) 620 mDrewSelected(FALSE)
621{ 621{
622 if (font)
623 {
624 mGLFont = font;
625 }
626 else
627 {
628 mGLFont = LLFontGL::getFontSansSerifSmall();
629 }
630
622 mItemListRect.setOriginAndSize( 631 mItemListRect.setOriginAndSize(
623 mBorderThickness, 632 mBorderThickness,
624 mBorderThickness, 633 mBorderThickness,
@@ -987,14 +996,14 @@ void LLScrollListCtrl::calcColumnWidths()
987 column->setWidth(new_width); 996 column->setWidth(new_width);
988 997
989 // update max content width for this column, by looking at all items 998 // update max content width for this column, by looking at all items
990 column->mMaxContentWidth = column->mHeader ? LLFontGL::getFontSansSerifSmall()->getWidth(column->mLabel) + mColumnPadding + HEADING_TEXT_PADDING : 0; 999 column->mMaxContentWidth = column->mHeader ? mGLFont->getWidth(column->mLabel) + mColumnPadding + HEADING_TEXT_PADDING : 0;
991 item_list::iterator iter; 1000 item_list::iterator iter;
992 for (iter = mItemList.begin(); iter != mItemList.end(); iter++) 1001 for (iter = mItemList.begin(); iter != mItemList.end(); iter++)
993 { 1002 {
994 LLScrollListCell* cellp = (*iter)->getColumn(column->mIndex); 1003 LLScrollListCell* cellp = (*iter)->getColumn(column->mIndex);
995 if (!cellp) continue; 1004 if (!cellp) continue;
996 1005
997 column->mMaxContentWidth = llmax(LLFontGL::getFontSansSerifSmall()->getWidth(cellp->getValue().asString()) + mColumnPadding + COLUMN_TEXT_PADDING, column->mMaxContentWidth); 1006 column->mMaxContentWidth = llmax(mGLFont->getWidth(cellp->getValue().asString()) + mColumnPadding + COLUMN_TEXT_PADDING, column->mMaxContentWidth);
998 } 1007 }
999 1008
1000 max_item_width += column->mMaxContentWidth; 1009 max_item_width += column->mMaxContentWidth;
@@ -1642,7 +1651,7 @@ LLScrollListItem* LLScrollListCtrl::addStringUUIDItem(const std::string& item_te
1642 if (getItemCount() < mMaxItemCount) 1651 if (getItemCount() < mMaxItemCount)
1643 { 1652 {
1644 item = new LLScrollListItem( enabled, NULL, id ); 1653 item = new LLScrollListItem( enabled, NULL, id );
1645 item->addColumn(item_text, LLResMgr::getInstance()->getRes(LLFONT_SANSSERIF_SMALL), column_width); 1654 item->addColumn(item_text, mGLFont, column_width);
1646 addItem( item, pos ); 1655 addItem( item, pos );
1647 } 1656 }
1648 return item; 1657 return item;
@@ -2900,6 +2909,7 @@ LLView* LLScrollListCtrl::fromXML(LLXMLNodePtr node, LLView *parent, LLUICtrlFac
2900 LLScrollListCtrl* scroll_list = new LLScrollListCtrl( 2909 LLScrollListCtrl* scroll_list = new LLScrollListCtrl(
2901 name, 2910 name,
2902 rect, 2911 rect,
2912 NULL,
2903 callback, 2913 callback,
2904 NULL, 2914 NULL,
2905 multi_select, 2915 multi_select,
@@ -3374,7 +3384,11 @@ LLScrollListItem* LLScrollListCtrl::addElement(const LLSD& value, EAddPosition p
3374 const LLFontGL *font = LLResMgr::getInstance()->getRes(fontname); 3384 const LLFontGL *font = LLResMgr::getInstance()->getRes(fontname);
3375 if (!font) 3385 if (!font)
3376 { 3386 {
3377 font = LLResMgr::getInstance()->getRes( LLFONT_SANSSERIF_SMALL ); 3387 font = mGLFont;
3388 if (!font)
3389 {
3390 font = LLResMgr::getInstance()->getRes( LLFONT_SANSSERIF_SMALL );
3391 }
3378 } 3392 }
3379 U8 font_style = LLFontGL::getStyleFromString(fontstyle); 3393 U8 font_style = LLFontGL::getStyleFromString(fontstyle);
3380 3394
@@ -3446,7 +3460,7 @@ LLScrollListItem* LLScrollListCtrl::addElement(const LLSD& value, EAddPosition p
3446 if (new_item->getColumn(column_idx) == NULL) 3460 if (new_item->getColumn(column_idx) == NULL)
3447 { 3461 {
3448 LLScrollListColumn* column_ptr = &column_it->second; 3462 LLScrollListColumn* column_ptr = &column_it->second;
3449 new_item->setColumn(column_idx, new LLScrollListText(LLStringUtil::null, LLResMgr::getInstance()->getRes( LLFONT_SANSSERIF_SMALL ), column_ptr->getWidth(), LLFontGL::NORMAL)); 3463 new_item->setColumn(column_idx, new LLScrollListText(LLStringUtil::null, mGLFont, column_ptr->getWidth(), LLFontGL::NORMAL));
3450 } 3464 }
3451 } 3465 }
3452 3466
@@ -3466,7 +3480,7 @@ LLScrollListItem* LLScrollListCtrl::addSimpleElement(const std::string& value, E
3466 3480
3467 LLScrollListItem *new_item = new LLScrollListItem(entry_id); 3481 LLScrollListItem *new_item = new LLScrollListItem(entry_id);
3468 3482
3469 const LLFontGL *font = LLResMgr::getInstance()->getRes( LLFONT_SANSSERIF_SMALL ); 3483 const LLFontGL *font = mGLFont;
3470 3484
3471 new_item->addColumn(value, font, getRect().getWidth()); 3485 new_item->addColumn(value, font, getRect().getWidth());
3472 3486
diff --git a/linden/indra/llui/llscrolllistctrl.h b/linden/indra/llui/llscrolllistctrl.h
index 4be7ff7..1b7105f 100644
--- a/linden/indra/llui/llscrolllistctrl.h
+++ b/linden/indra/llui/llscrolllistctrl.h
@@ -353,6 +353,7 @@ public:
353 LLScrollListCtrl( 353 LLScrollListCtrl(
354 const std::string& name, 354 const std::string& name,
355 const LLRect& rect, 355 const LLRect& rect,
356 const LLFontGL* font,
356 void (*commit_callback)(LLUICtrl*, void*), 357 void (*commit_callback)(LLUICtrl*, void*),
357 void* callback_userdata, 358 void* callback_userdata,
358 BOOL allow_multiple_selection, 359 BOOL allow_multiple_selection,
@@ -694,6 +695,8 @@ private:
694 695
695 // HACK: Did we draw one selected item this frame? 696 // HACK: Did we draw one selected item this frame?
696 BOOL mDrewSelected; 697 BOOL mDrewSelected;
698
699 const LLFontGL* mGLFont;
697}; // end class LLScrollListCtrl 700}; // end class LLScrollListCtrl
698 701
699 702
diff --git a/linden/indra/newview/llfloatertest.cpp b/linden/indra/newview/llfloatertest.cpp
index e9aada3..1934dcc 100644
--- a/linden/indra/newview/llfloatertest.cpp
+++ b/linden/indra/newview/llfloatertest.cpp
@@ -228,7 +228,9 @@ LLFloaterTestImpl::LLFloaterTestImpl()
228 combo = new LLComboBox(std::string("combo"), 228 combo = new LLComboBox(std::string("combo"),
229 LLRect(LEFT, y, LEFT+100, y-LLCOMBOBOX_HEIGHT), 229 LLRect(LEFT, y, LEFT+100, y-LLCOMBOBOX_HEIGHT),
230 std::string("Combobox Label"), 230 std::string("Combobox Label"),
231 onCommitCombo, this); 231 NULL,
232 onCommitCombo,
233 this);
232 combo->add(std::string("first item")); 234 combo->add(std::string("first item"));
233 combo->add(std::string("second item")); 235 combo->add(std::string("second item"));
234 combo->add(std::string("should go to the top"), ADD_TOP); 236 combo->add(std::string("should go to the top"), ADD_TOP);
diff --git a/linden/indra/newview/llnamelistctrl.cpp b/linden/indra/newview/llnamelistctrl.cpp
index e30c129..935e6ac 100644
--- a/linden/indra/newview/llnamelistctrl.cpp
+++ b/linden/indra/newview/llnamelistctrl.cpp
@@ -54,7 +54,7 @@ LLNameListCtrl::LLNameListCtrl(const std::string& name,
54 BOOL draw_border, 54 BOOL draw_border,
55 S32 name_column_index, 55 S32 name_column_index,
56 const std::string& tooltip) 56 const std::string& tooltip)
57: LLScrollListCtrl(name, rect, cb, userdata, allow_multiple_selection, 57: LLScrollListCtrl(name, rect, NULL, cb, userdata, allow_multiple_selection,
58 draw_border), 58 draw_border),
59 mNameColumnIndex(name_column_index), 59 mNameColumnIndex(name_column_index),
60 mAllowCallingCardDrop(FALSE), 60 mAllowCallingCardDrop(FALSE),