aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/linden/indra/llui/llscrolllistctrl.h
diff options
context:
space:
mode:
authorJacek Antonelli2008-08-15 23:45:34 -0500
committerJacek Antonelli2008-08-15 23:45:34 -0500
commitcd17687f01420952712a500107e0f93e7ab8d5f8 (patch)
treece48c2b706f2c1176290e39fb555fbdf6648ce01 /linden/indra/llui/llscrolllistctrl.h
parentSecond Life viewer sources 1.19.0.5 (diff)
downloadmeta-impy-cd17687f01420952712a500107e0f93e7ab8d5f8.zip
meta-impy-cd17687f01420952712a500107e0f93e7ab8d5f8.tar.gz
meta-impy-cd17687f01420952712a500107e0f93e7ab8d5f8.tar.bz2
meta-impy-cd17687f01420952712a500107e0f93e7ab8d5f8.tar.xz
Second Life viewer sources 1.19.1.0
Diffstat (limited to 'linden/indra/llui/llscrolllistctrl.h')
-rw-r--r--linden/indra/llui/llscrolllistctrl.h127
1 files changed, 72 insertions, 55 deletions
diff --git a/linden/indra/llui/llscrolllistctrl.h b/linden/indra/llui/llscrolllistctrl.h
index e9486cb..716d18a 100644
--- a/linden/indra/llui/llscrolllistctrl.h
+++ b/linden/indra/llui/llscrolllistctrl.h
@@ -1,6 +1,5 @@
1/** 1/**
2 * @file llscrolllistctrl.h 2 * @file llscrolllistctrl.h
3 * @brief LLScrollListCtrl base class
4 * 3 *
5 * $LicenseInfo:firstyear=2001&license=viewergpl$ 4 * $LicenseInfo:firstyear=2001&license=viewergpl$
6 * 5 *
@@ -43,16 +42,20 @@
43#include "llstring.h" 42#include "llstring.h"
44#include "llimagegl.h" 43#include "llimagegl.h"
45#include "lleditmenuhandler.h" 44#include "lleditmenuhandler.h"
46#include "llviewborder.h"
47#include "llframetimer.h" 45#include "llframetimer.h"
48#include "llcheckboxctrl.h" 46#include "llcheckboxctrl.h"
49#include "llcombobox.h" 47#include "llcombobox.h"
48#include "llscrollbar.h"
49#include "llresizebar.h"
50 50
51class LLScrollbar; 51/*
52class LLScrollListCtrl; 52 * Represents a cell in a scrollable table.
53class LLColumnHeader; 53 *
54class LLResizeBar; 54 * Sub-classes must return height and other properties
55 55 * though width accessors are implemented by the base class.
56 * It is therefore important for sub-class constructors to call
57 * setWidth() with realistic values.
58 */
56class LLScrollListCell 59class LLScrollListCell
57{ 60{
58public: 61public:
@@ -63,21 +66,24 @@ public:
63 virtual S32 getContentWidth() const { return 0; } 66 virtual S32 getContentWidth() const { return 0; }
64 virtual S32 getHeight() const = 0; 67 virtual S32 getHeight() const = 0;
65 virtual const LLSD getValue() const { return LLString::null; } 68 virtual const LLSD getValue() const { return LLString::null; }
66 virtual void setValue(LLSD value) { } 69 virtual void setValue(const LLSD& value) { }
67 virtual BOOL getVisible() const { return TRUE; } 70 virtual BOOL getVisible() const { return TRUE; }
68 virtual void setWidth(S32 width) { mWidth = width; } 71 virtual void setWidth(S32 width) { mWidth = width; }
69 virtual void highlightText(S32 offset, S32 num_chars) {} 72 virtual void highlightText(S32 offset, S32 num_chars) {}
70 virtual BOOL isText() = 0; 73 virtual BOOL isText() const = 0;
71 virtual void setColor(const LLColor4&) {} 74 virtual void setColor(const LLColor4&) {}
72 virtual void onCommit() {}; 75 virtual void onCommit() {};
73 76
74 virtual BOOL handleClick() { return FALSE; } 77 virtual BOOL handleClick() { return FALSE; }
75 virtual void setEnabled(BOOL enable) { } 78 virtual void setEnabled(BOOL enable) { }
76 79
77protected: 80private:
78 S32 mWidth; 81 S32 mWidth;
79}; 82};
80 83
84/*
85 * Draws a horizontal line.
86 */
81class LLScrollListSeparator : public LLScrollListCell 87class LLScrollListSeparator : public LLScrollListCell
82{ 88{
83public: 89public:
@@ -85,9 +91,12 @@ public:
85 virtual ~LLScrollListSeparator() {}; 91 virtual ~LLScrollListSeparator() {};
86 virtual void draw(const LLColor4& color, const LLColor4& highlight_color) const; // truncate to given width, if possible 92 virtual void draw(const LLColor4& color, const LLColor4& highlight_color) const; // truncate to given width, if possible
87 virtual S32 getHeight() const { return 5; }; 93 virtual S32 getHeight() const { return 5; };
88 virtual BOOL isText() { return FALSE; } 94 virtual BOOL isText() const { return FALSE; }
89}; 95};
90 96
97/*
98 * Cell displaying a text label.
99 */
91class LLScrollListText : public LLScrollListCell 100class LLScrollListText : public LLScrollListCell
92{ 101{
93public: 102public:
@@ -97,13 +106,13 @@ public:
97 virtual void draw(const LLColor4& color, const LLColor4& highlight_color) const; 106 virtual void draw(const LLColor4& color, const LLColor4& highlight_color) const;
98 virtual S32 getContentWidth() const; 107 virtual S32 getContentWidth() const;
99 virtual S32 getHeight() const { return llround(mFont->getLineHeight()); } 108 virtual S32 getHeight() const { return llround(mFont->getLineHeight()); }
100 virtual void setValue(LLSD value) { setText(value.asString()); } 109 virtual void setValue(const LLSD& value);
101 virtual const LLSD getValue() const { return LLSD(mText.getString()); } 110 virtual const LLSD getValue() const { return LLSD(mText.getString()); }
102 virtual BOOL getVisible() const { return mVisible; } 111 virtual BOOL getVisible() const { return mVisible; }
103 virtual void highlightText(S32 offset, S32 num_chars) {mHighlightOffset = offset; mHighlightCount = num_chars;} 112 virtual void highlightText(S32 offset, S32 num_chars) {mHighlightOffset = offset; mHighlightCount = num_chars;}
104 113
105 virtual void setColor(const LLColor4&); 114 virtual void setColor(const LLColor4&);
106 virtual BOOL isText() { return TRUE; } 115 virtual BOOL isText() const { return TRUE; }
107 116
108 void setText(const LLStringExplicit& text); 117 void setText(const LLStringExplicit& text);
109 void setFontStyle(const U8 font_style) { mFontStyle = font_style; } 118 void setFontStyle(const U8 font_style) { mFontStyle = font_style; }
@@ -124,6 +133,9 @@ private:
124 static U32 sCount; 133 static U32 sCount;
125}; 134};
126 135
136/*
137 * Cell displaying an image.
138 */
127class LLScrollListIcon : public LLScrollListCell 139class LLScrollListIcon : public LLScrollListCell
128{ 140{
129public: 141public:
@@ -135,8 +147,8 @@ public:
135 // used as sort criterion 147 // used as sort criterion
136 virtual const LLSD getValue() const { return LLSD(mImageUUID); } 148 virtual const LLSD getValue() const { return LLSD(mImageUUID); }
137 virtual void setColor(const LLColor4&); 149 virtual void setColor(const LLColor4&);
138 virtual BOOL isText() { return FALSE; } 150 virtual BOOL isText()const { return FALSE; }
139 virtual void setValue(LLSD value); 151 virtual void setValue(const LLSD& value);
140 152
141private: 153private:
142 LLPointer<LLImageGL> mIcon; 154 LLPointer<LLImageGL> mIcon;
@@ -144,6 +156,9 @@ private:
144 LLColor4 mColor; 156 LLColor4 mColor;
145}; 157};
146 158
159/*
160 * An interactive cell containing a check box.
161 */
147class LLScrollListCheck : public LLScrollListCell 162class LLScrollListCheck : public LLScrollListCell
148{ 163{
149public: 164public:
@@ -152,19 +167,22 @@ public:
152 virtual void draw(const LLColor4& color, const LLColor4& highlight_color) const; 167 virtual void draw(const LLColor4& color, const LLColor4& highlight_color) const;
153 virtual S32 getHeight() const { return 0; } 168 virtual S32 getHeight() const { return 0; }
154 virtual const LLSD getValue() const { return mCheckBox->getValue(); } 169 virtual const LLSD getValue() const { return mCheckBox->getValue(); }
155 virtual void setValue(LLSD value) { mCheckBox->setValue(value); } 170 virtual void setValue(const LLSD& value) { mCheckBox->setValue(value); }
156 virtual void onCommit() { mCheckBox->onCommit(); } 171 virtual void onCommit() { mCheckBox->onCommit(); }
157 172
158 virtual BOOL handleClick(); 173 virtual BOOL handleClick();
159 virtual void setEnabled(BOOL enable) { mCheckBox->setEnabled(enable); } 174 virtual void setEnabled(BOOL enable) { mCheckBox->setEnabled(enable); }
160 175
161 LLCheckBoxCtrl* getCheckBox() { return mCheckBox; } 176 LLCheckBoxCtrl* getCheckBox() { return mCheckBox; }
162 virtual BOOL isText() { return FALSE; } 177 virtual BOOL isText() const { return FALSE; }
163 178
164private: 179private:
165 LLCheckBoxCtrl* mCheckBox; 180 LLCheckBoxCtrl* mCheckBox;
166}; 181};
167 182
183/*
184 * A simple data class describing a column within a scroll list.
185 */
168class LLScrollListColumn 186class LLScrollListColumn
169{ 187{
170public: 188public:
@@ -245,6 +263,9 @@ public:
245 mHeader = NULL; 263 mHeader = NULL;
246 } 264 }
247 265
266 // Public data is fine so long as this remains a simple struct-like data class.
267 // If it ever gets any smarter than that, these should all become private
268 // with protected or public accessor methods added as needed. -MG
248 LLString mName; 269 LLString mName;
249 LLString mSortingColumn; 270 LLString mSortingColumn;
250 BOOL mSortAscending; 271 BOOL mSortAscending;
@@ -255,7 +276,7 @@ public:
255 S32 mMaxContentWidth; 276 S32 mMaxContentWidth;
256 S32 mIndex; 277 S32 mIndex;
257 LLScrollListCtrl* mParentCtrl; 278 LLScrollListCtrl* mParentCtrl;
258 LLColumnHeader* mHeader; 279 class LLColumnHeader* mHeader;
259 LLFontGL::HAlign mFontAlignment; 280 LLFontGL::HAlign mFontAlignment;
260}; 281};
261 282
@@ -284,7 +305,7 @@ public:
284 static void onMouseDown(void* user_data); 305 static void onMouseDown(void* user_data);
285 static void onHeldDown(void* user_data); 306 static void onHeldDown(void* user_data);
286 307
287protected: 308private:
288 LLScrollListColumn* mColumn; 309 LLScrollListColumn* mColumn;
289 LLResizeBar* mResizeBar; 310 LLResizeBar* mResizeBar;
290 LLString mOrigLabel; 311 LLString mOrigLabel;
@@ -331,11 +352,11 @@ public:
331 352
332 void setColumn( S32 column, LLScrollListCell *cell ); 353 void setColumn( S32 column, LLScrollListCell *cell );
333 354
334 S32 getNumColumns() const { return mColumns.size(); } 355 S32 getNumColumns() const { return mColumns.size(); }
335 356
336 LLScrollListCell *getColumn(const S32 i) const { if (0 <= i && i < (S32)mColumns.size()) { return mColumns[i]; } return NULL; } 357 LLScrollListCell *getColumn(const S32 i) const { if (0 <= i && i < (S32)mColumns.size()) { return mColumns[i]; } return NULL; }
337 358
338 LLString getContentsCSV(); 359 LLString getContentsCSV() const;
339 360
340 virtual void draw(const LLRect& rect, const LLColor4& fg_color, const LLColor4& bg_color, const LLColor4& highlight_color, S32 column_padding); 361 virtual void draw(const LLRect& rect, const LLColor4& fg_color, const LLColor4& bg_color, const LLColor4& highlight_color, S32 column_padding);
341 362
@@ -347,6 +368,11 @@ private:
347 std::vector<LLScrollListCell *> mColumns; 368 std::vector<LLScrollListCell *> mColumns;
348}; 369};
349 370
371/*
372 * A graphical control representing a scrollable table.
373 * Cells in the table can be simple text or more complicated things
374 * such as icons or even interactive elements like check boxes.
375 */
350class LLScrollListItemComment : public LLScrollListItem 376class LLScrollListItemComment : public LLScrollListItem
351{ 377{
352public: 378public:
@@ -421,7 +447,7 @@ public:
421 447
422 // DEPRECATED: Use setSelectedByValue() below. 448 // DEPRECATED: Use setSelectedByValue() below.
423 BOOL setCurrentByID( const LLUUID& id ) { return selectByID(id); } 449 BOOL setCurrentByID( const LLUUID& id ) { return selectByID(id); }
424 virtual LLUUID getCurrentID() { return getStringUUIDSelectedItem(); } 450 virtual LLUUID getCurrentID() const { return getStringUUIDSelectedItem(); }
425 451
426 BOOL operateOnSelection(EOperation op); 452 BOOL operateOnSelection(EOperation op);
427 BOOL operateOnAll(EOperation op); 453 BOOL operateOnAll(EOperation op);
@@ -433,11 +459,11 @@ public:
433 459
434 // Match item by value.asString(), which should work for string, integer, uuid. 460 // Match item by value.asString(), which should work for string, integer, uuid.
435 // Returns FALSE if not found. 461 // Returns FALSE if not found.
436 BOOL setSelectedByValue(LLSD value, BOOL selected); 462 BOOL setSelectedByValue(const LLSD& value, BOOL selected);
437 463
438 BOOL isSorted(); 464 BOOL isSorted() const { return mSorted; }
439 465
440 virtual BOOL isSelected(LLSD value); 466 virtual BOOL isSelected(const LLSD& value) const;
441 467
442 BOOL handleClick(S32 x, S32 y, MASK mask); 468 BOOL handleClick(S32 x, S32 y, MASK mask);
443 BOOL selectFirstItem(); 469 BOOL selectFirstItem();
@@ -461,8 +487,8 @@ public:
461 void setCanSelect(BOOL can_select) { mCanSelect = can_select; } 487 void setCanSelect(BOOL can_select) { mCanSelect = can_select; }
462 virtual BOOL getCanSelect() const { return mCanSelect; } 488 virtual BOOL getCanSelect() const { return mCanSelect; }
463 489
464 S32 getItemIndex( LLScrollListItem* item ); 490 S32 getItemIndex( LLScrollListItem* item ) const;
465 S32 getItemIndex( const LLUUID& item_id ); 491 S32 getItemIndex( const LLUUID& item_id ) const;
466 492
467 LLScrollListItem* addCommentText( const LLString& comment_text, EAddPosition pos = ADD_BOTTOM); 493 LLScrollListItem* addCommentText( const LLString& comment_text, EAddPosition pos = ADD_BOTTOM);
468 LLScrollListItem* addSeparator(EAddPosition pos); 494 LLScrollListItem* addSeparator(EAddPosition pos);
@@ -482,12 +508,11 @@ public:
482 // "StringUUID" interface: use this when you're creating a list that contains non-unique strings each of which 508 // "StringUUID" interface: use this when you're creating a list that contains non-unique strings each of which
483 // has an associated, unique UUID, and only one of which can be selected at a time. 509 // has an associated, unique UUID, and only one of which can be selected at a time.
484 LLScrollListItem* addStringUUIDItem(const LLString& item_text, const LLUUID& id, EAddPosition pos = ADD_BOTTOM, BOOL enabled = TRUE, S32 column_width = 0); 510 LLScrollListItem* addStringUUIDItem(const LLString& item_text, const LLUUID& id, EAddPosition pos = ADD_BOTTOM, BOOL enabled = TRUE, S32 column_width = 0);
485 LLUUID getStringUUIDSelectedItem(); 511 LLUUID getStringUUIDSelectedItem() const;
486 512
487 LLScrollListItem* getFirstSelected() const; 513 LLScrollListItem* getFirstSelected() const;
488 virtual S32 getFirstSelectedIndex() const; 514 virtual S32 getFirstSelectedIndex() const;
489 std::vector<LLScrollListItem*> getAllSelected() const; 515 std::vector<LLScrollListItem*> getAllSelected() const;
490
491 LLScrollListItem* getLastSelectedItem() const { return mLastSelected; } 516 LLScrollListItem* getLastSelectedItem() const { return mLastSelected; }
492 517
493 // iterate over all items 518 // iterate over all items
@@ -520,7 +545,7 @@ public:
520 S32 getMaxSelectable() { return mMaxSelectable; } 545 S32 getMaxSelectable() { return mMaxSelectable; }
521 546
522 547
523 virtual S32 getScrollPos(); 548 virtual S32 getScrollPos() const;
524 virtual void setScrollPos( S32 pos ); 549 virtual void setScrollPos( S32 pos );
525 550
526 S32 getSearchColumn() { return mSearchColumn; } 551 S32 getSearchColumn() { return mSearchColumn; }
@@ -576,19 +601,13 @@ public:
576 601
577 // LLEditMenuHandler functions 602 // LLEditMenuHandler functions
578 virtual void copy(); 603 virtual void copy();
579 virtual BOOL canCopy(); 604 virtual BOOL canCopy() const;
580
581 virtual void cut(); 605 virtual void cut();
582 virtual BOOL canCut(); 606 virtual BOOL canCut() const;
583
584 virtual void doDelete();
585 virtual BOOL canDoDelete();
586
587 virtual void selectAll(); 607 virtual void selectAll();
588 virtual BOOL canSelectAll(); 608 virtual BOOL canSelectAll() const;
589
590 virtual void deselect(); 609 virtual void deselect();
591 virtual BOOL canDeselect(); 610 virtual BOOL canDeselect() const;
592 611
593 void setNumDynamicColumns(int num) { mNumDynamicWidthColumns = num; } 612 void setNumDynamicColumns(int num) { mNumDynamicWidthColumns = num; }
594 void setTotalStaticColumnWidth(int width) { mTotalStaticColumnWidth = width; } 613 void setTotalStaticColumnWidth(int width) { mTotalStaticColumnWidth = width; }
@@ -600,7 +619,7 @@ public:
600 S32 selectMultiple( LLDynamicArray<LLUUID> ids ); 619 S32 selectMultiple( LLDynamicArray<LLUUID> ids );
601 void sortItems(); 620 void sortItems();
602 // manually call this whenever editing list items in place to flag need for resorting 621 // manually call this whenever editing list items in place to flag need for resorting
603 void setSorted(BOOL sorted); 622 void setSorted(BOOL sorted) { mSorted = sorted; }
604 void dirtyColumns(); // some operation has potentially affected column layout or ordering 623 void dirtyColumns(); // some operation has potentially affected column layout or ordering
605 624
606protected: 625protected:
@@ -617,9 +636,14 @@ protected:
617 // The LLScrollListCtrl owns its items and is responsible for deleting them 636 // The LLScrollListCtrl owns its items and is responsible for deleting them
618 // (except in the case that the addItem() call fails, in which case it is up 637 // (except in the case that the addItem() call fails, in which case it is up
619 // to the caller to delete the item) 638 // to the caller to delete the item)
620 639 //
621 // returns FALSE if item faile to be added to list, does NOT delete 'item' 640 // returns FALSE if item faile to be added to list, does NOT delete 'item'
622 BOOL addItem( LLScrollListItem* item, EAddPosition pos = ADD_BOTTOM, BOOL requires_column = TRUE ); 641 BOOL addItem( LLScrollListItem* item, EAddPosition pos = ADD_BOTTOM, BOOL requires_column = TRUE );
642
643 typedef std::deque<LLScrollListItem *> item_list;
644 item_list& getItemList() { return mItemList; }
645
646private:
623 void selectPrevItem(BOOL extend_selection); 647 void selectPrevItem(BOOL extend_selection);
624 void selectNextItem(BOOL extend_selection); 648 void selectNextItem(BOOL extend_selection);
625 void drawItems(); 649 void drawItems();
@@ -632,7 +656,7 @@ protected:
632 void commitIfChanged(); 656 void commitIfChanged();
633 BOOL setSort(S32 column, BOOL ascending); 657 BOOL setSort(S32 column, BOOL ascending);
634 658
635protected: 659
636 S32 mCurIndex; // For get[First/Next]Data 660 S32 mCurIndex; // For get[First/Next]Data
637 S32 mCurSelectedIndex; // For get[First/Next]Selected 661 S32 mCurSelectedIndex; // For get[First/Next]Selected
638 662
@@ -652,7 +676,6 @@ protected:
652 BOOL mDisplayColumnHeaders; 676 BOOL mDisplayColumnHeaders;
653 BOOL mColumnsDirty; 677 BOOL mColumnsDirty;
654 678
655 typedef std::deque<LLScrollListItem *> item_list;
656 item_list mItemList; 679 item_list mItemList;
657 680
658 LLScrollListItem *mLastSelected; 681 LLScrollListItem *mLastSelected;
@@ -681,7 +704,7 @@ protected:
681 void (*mOnSortChangedCallback)(void* userdata); 704 void (*mOnSortChangedCallback)(void* userdata);
682 705
683 S32 mHighlightedItem; 706 S32 mHighlightedItem;
684 LLViewBorder* mBorder; 707 class LLViewBorder* mBorder;
685 708
686 LLWString mSearchString; 709 LLWString mSearchString;
687 LLFrameTimer mSearchTimer; 710 LLFrameTimer mSearchTimer;
@@ -704,15 +727,9 @@ protected:
704 typedef std::pair<S32, BOOL> sort_column_t; 727 typedef std::pair<S32, BOOL> sort_column_t;
705 std::vector<sort_column_t> mSortColumns; 728 std::vector<sort_column_t> mSortColumns;
706 729
707public:
708 // HACK: Did we draw one selected item this frame? 730 // HACK: Did we draw one selected item this frame?
709 BOOL mDrewSelected; 731 BOOL mDrewSelected;
710}; 732}; // end class LLScrollListCtrl
711
712const BOOL MULTIPLE_SELECT_YES = TRUE;
713const BOOL MULTIPLE_SELECT_NO = FALSE;
714 733
715const BOOL SHOW_BORDER_YES = TRUE;
716const BOOL SHOW_BORDER_NO = FALSE;
717 734
718#endif // LL_SCROLLLISTCTRL_H 735#endif // LL_SCROLLLISTCTRL_H