aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/linden/indra/llui/llscrolllistctrl.h
diff options
context:
space:
mode:
authorJacek Antonelli2008-08-15 23:44:54 -0500
committerJacek Antonelli2008-08-15 23:44:54 -0500
commitb2afb8800bb033a04bb3ecdf0363068d56648ef1 (patch)
tree3568129b5bbddb47cd39d622b4137a8fbff4abaf /linden/indra/llui/llscrolllistctrl.h
parentSecond Life viewer sources 1.14.0.1 (diff)
downloadmeta-impy-b2afb8800bb033a04bb3ecdf0363068d56648ef1.zip
meta-impy-b2afb8800bb033a04bb3ecdf0363068d56648ef1.tar.gz
meta-impy-b2afb8800bb033a04bb3ecdf0363068d56648ef1.tar.bz2
meta-impy-b2afb8800bb033a04bb3ecdf0363068d56648ef1.tar.xz
Second Life viewer sources 1.15.0.2
Diffstat (limited to 'linden/indra/llui/llscrolllistctrl.h')
-rw-r--r--linden/indra/llui/llscrolllistctrl.h163
1 files changed, 132 insertions, 31 deletions
diff --git a/linden/indra/llui/llscrolllistctrl.h b/linden/indra/llui/llscrolllistctrl.h
index a1c4853..eed07b8 100644
--- a/linden/indra/llui/llscrolllistctrl.h
+++ b/linden/indra/llui/llscrolllistctrl.h
@@ -4,6 +4,7 @@
4 * 4 *
5 * Copyright (c) 2001-2007, Linden Research, Inc. 5 * Copyright (c) 2001-2007, Linden Research, Inc.
6 * 6 *
7 * Second Life Viewer Source Code
7 * The source code in this file ("Source Code") is provided by Linden Lab 8 * The source code in this file ("Source Code") is provided by Linden Lab
8 * to you under the terms of the GNU General Public License, version 2.0 9 * to you under the terms of the GNU General Public License, version 2.0
9 * ("GPL"), unless you have obtained a separate licensing agreement 10 * ("GPL"), unless you have obtained a separate licensing agreement
@@ -42,9 +43,12 @@
42#include "llviewborder.h" 43#include "llviewborder.h"
43#include "llframetimer.h" 44#include "llframetimer.h"
44#include "llcheckboxctrl.h" 45#include "llcheckboxctrl.h"
46#include "llcombobox.h"
45 47
46class LLScrollbar; 48class LLScrollbar;
47class LLScrollListCtrl; 49class LLScrollListCtrl;
50class LLColumnHeader;
51class LLResizeBar;
48 52
49class LLScrollListCell 53class LLScrollListCell
50{ 54{
@@ -58,11 +62,27 @@ public:
58 virtual const BOOL getVisible() const { return TRUE; } 62 virtual const BOOL getVisible() const { return TRUE; }
59 virtual void setWidth(S32 width) = 0; 63 virtual void setWidth(S32 width) = 0;
60 virtual void highlightText(S32 offset, S32 num_chars) {} 64 virtual void highlightText(S32 offset, S32 num_chars) {}
65 virtual BOOL isText() = 0;
61 66
62 virtual BOOL handleClick() { return FALSE; } 67 virtual BOOL handleClick() { return FALSE; }
63 virtual void setEnabled(BOOL enable) { } 68 virtual void setEnabled(BOOL enable) { }
64}; 69};
65 70
71class LLScrollListSeparator : public LLScrollListCell
72{
73public:
74 LLScrollListSeparator(S32 width);
75 virtual ~LLScrollListSeparator() {};
76 virtual void drawToWidth(S32 width, const LLColor4& color, const LLColor4& highlight_color) const; // truncate to given width, if possible
77 virtual S32 getWidth() const {return mWidth;}
78 virtual S32 getHeight() const { return 5; };
79 virtual void setWidth(S32 width) {mWidth = width; }
80 virtual BOOL isText() { return FALSE; }
81
82protected:
83 S32 mWidth;
84};
85
66class LLScrollListText : public LLScrollListCell 86class LLScrollListText : public LLScrollListCell
67{ 87{
68public: 88public:
@@ -77,6 +97,7 @@ public:
77 virtual const BOOL getVisible() const { return mVisible; } 97 virtual const BOOL getVisible() const { return mVisible; }
78 virtual void highlightText(S32 offset, S32 num_chars) {mHighlightOffset = offset; mHighlightCount = num_chars;} 98 virtual void highlightText(S32 offset, S32 num_chars) {mHighlightOffset = offset; mHighlightCount = num_chars;}
79 void setText(const LLString& text); 99 void setText(const LLString& text);
100 virtual BOOL isText() { return TRUE; }
80 101
81private: 102private:
82 LLUIString mText; 103 LLUIString mText;
@@ -105,6 +126,7 @@ public:
105 virtual const LLString& getText() const { return mImageUUID; } 126 virtual const LLString& getText() const { return mImageUUID; }
106 virtual const LLString& getTextLower() const { return mImageUUID; } 127 virtual const LLString& getTextLower() const { return mImageUUID; }
107 virtual void setWidth(S32 width) { mWidth = width; } 128 virtual void setWidth(S32 width) { mWidth = width; }
129 virtual BOOL isText() { return FALSE; }
108 130
109private: 131private:
110 LLPointer<LLImageGL> mIcon; 132 LLPointer<LLImageGL> mIcon;
@@ -126,6 +148,7 @@ public:
126 virtual void setEnabled(BOOL enable) { if (mCheckBox) mCheckBox->setEnabled(enable); } 148 virtual void setEnabled(BOOL enable) { if (mCheckBox) mCheckBox->setEnabled(enable); }
127 149
128 LLCheckBoxCtrl* getCheckBox() { return mCheckBox; } 150 LLCheckBoxCtrl* getCheckBox() { return mCheckBox; }
151 virtual BOOL isText() { return FALSE; }
129 152
130private: 153private:
131 LLCheckBoxCtrl* mCheckBox; 154 LLCheckBoxCtrl* mCheckBox;
@@ -136,20 +159,50 @@ class LLScrollListColumn
136{ 159{
137public: 160public:
138 // Default constructor 161 // Default constructor
139 LLScrollListColumn() : mName(""), mSortingColumn(""), mLabel(""), mWidth(-1), mRelWidth(-1.0), mDynamicWidth(FALSE), mIndex(-1), mParentCtrl(NULL), mButton(NULL), mFontAlignment(LLFontGL::LEFT) 162 LLScrollListColumn() :
163 mName(""),
164 mSortingColumn(""),
165 mSortAscending(TRUE),
166 mLabel(""),
167 mWidth(-1),
168 mRelWidth(-1.0),
169 mDynamicWidth(FALSE),
170 mMaxContentWidth(0),
171 mIndex(-1),
172 mParentCtrl(NULL),
173 mHeader(NULL),
174 mFontAlignment(LLFontGL::LEFT)
140 { } 175 { }
141 176
142 LLScrollListColumn(LLString name, LLString label, S32 width, F32 relwidth) 177 LLScrollListColumn(LLString name, LLString label, S32 width, F32 relwidth) :
143 : mName(name), mSortingColumn(name), mLabel(label), mWidth(width), mRelWidth(relwidth), mDynamicWidth(FALSE), mIndex(-1), mParentCtrl(NULL), mButton(NULL) { } 178 mName(name),
179 mSortingColumn(name),
180 mSortAscending(TRUE),
181 mLabel(label),
182 mWidth(width),
183 mRelWidth(relwidth),
184 mDynamicWidth(FALSE),
185 mMaxContentWidth(0),
186 mIndex(-1),
187 mParentCtrl(NULL),
188 mHeader(NULL)
189 { }
144 190
145 LLScrollListColumn(const LLSD &sd) 191 LLScrollListColumn(const LLSD &sd)
146 { 192 {
193 mMaxContentWidth = 0;
194
147 mName = sd.get("name").asString(); 195 mName = sd.get("name").asString();
148 mSortingColumn = mName; 196 mSortingColumn = mName;
149 if (sd.has("sort")) 197 if (sd.has("sort"))
150 { 198 {
151 mSortingColumn = sd.get("sort").asString(); 199 mSortingColumn = sd.get("sort").asString();
152 } 200 }
201 mSortAscending = TRUE;
202 if (sd.has("sort_ascending"))
203 {
204 mSortAscending = sd.get("sort_ascending").asBoolean();
205 }
153 mLabel = sd.get("label").asString(); 206 mLabel = sd.get("label").asString();
154 if (sd.has("relwidth") && (F32)sd.get("relwidth").asReal() > 0) 207 if (sd.has("relwidth") && (F32)sd.get("relwidth").asReal() > 0)
155 { 208 {
@@ -179,21 +232,57 @@ public:
179 232
180 mIndex = -1; 233 mIndex = -1;
181 mParentCtrl = NULL; 234 mParentCtrl = NULL;
182 mButton = NULL; 235 mHeader = NULL;
183 } 236 }
184 237
185 LLString mName; 238 LLString mName;
186 LLString mSortingColumn; 239 LLString mSortingColumn;
240 BOOL mSortAscending;
187 LLString mLabel; 241 LLString mLabel;
188 S32 mWidth; 242 S32 mWidth;
189 F32 mRelWidth; 243 F32 mRelWidth;
190 BOOL mDynamicWidth; 244 BOOL mDynamicWidth;
245 S32 mMaxContentWidth;
191 S32 mIndex; 246 S32 mIndex;
192 LLScrollListCtrl* mParentCtrl; 247 LLScrollListCtrl* mParentCtrl;
193 LLButton* mButton; 248 LLColumnHeader* mHeader;
194 LLFontGL::HAlign mFontAlignment; 249 LLFontGL::HAlign mFontAlignment;
195}; 250};
196 251
252class LLColumnHeader : public LLComboBox
253{
254public:
255 LLColumnHeader(const LLString& label, const LLRect &rect, LLScrollListColumn* column, const LLFontGL *font = NULL);
256 ~LLColumnHeader();
257
258 /*virtual*/ void draw();
259 /*virtual*/ BOOL handleDoubleClick(S32 x, S32 y, MASK mask);
260 /*virtual*/ void showList();
261 /*virtual*/ LLView* findSnapEdge(S32& new_edge_val, const LLCoordGL& mouse_dir, ESnapEdge snap_edge, ESnapType snap_type, S32 threshold, S32 padding);
262 /*virtual*/ void userSetShape(const LLRect& new_rect);
263
264 void setImage(const LLString &image_name);
265 LLScrollListColumn* getColumn() { return mColumn; }
266 void setHasResizableElement(BOOL resizable);
267 BOOL canResize();
268 void enableResizeBar(BOOL enable);
269 LLString getLabel() { return mOrigLabel; }
270
271 static void onSelectSort(LLUICtrl* ctrl, void* user_data);
272 static void onClick(void* user_data);
273 static void onMouseDown(void* user_data);
274 static void onHeldDown(void* user_data);
275
276protected:
277 LLScrollListColumn* mColumn;
278 LLResizeBar* mResizeBar;
279 LLString mOrigLabel;
280 LLUIString mAscendingText;
281 LLUIString mDescendingText;
282 BOOL mShowSortOptions;
283 BOOL mHasResizableElement;
284};
285
197class LLScrollListItem 286class LLScrollListItem
198{ 287{
199public: 288public:
@@ -235,7 +324,7 @@ public:
235 324
236 LLScrollListCell *getColumn(const S32 i) const { if (i < (S32)mColumns.size()) { return mColumns[i]; } return NULL; } 325 LLScrollListCell *getColumn(const S32 i) const { if (i < (S32)mColumns.size()) { return mColumns[i]; } return NULL; }
237 326
238 virtual BOOL handleMouseDown(S32 x, S32 y, MASK mask); 327 virtual BOOL handleClick(S32 x, S32 y, MASK mask);
239 328
240 LLString getContentsCSV(); 329 LLString getContentsCSV();
241 330
@@ -282,6 +371,10 @@ public:
282 virtual void addColumn(const LLSD& column, EAddPosition pos = ADD_BOTTOM); 371 virtual void addColumn(const LLSD& column, EAddPosition pos = ADD_BOTTOM);
283 virtual void clearColumns(); 372 virtual void clearColumns();
284 virtual void setColumnLabel(const LLString& column, const LLString& label); 373 virtual void setColumnLabel(const LLString& column, const LLString& label);
374
375 virtual LLScrollListColumn* getColumn(S32 index);
376 virtual S32 getNumColumns() const { return mColumnsIndexed.size(); }
377
285 // Adds a single element, from an array of: 378 // Adds a single element, from an array of:
286 // "columns" => [ "column" => column name, "value" => value, "type" => type, "font" => font, "font-style" => style ], "id" => uuid 379 // "columns" => [ "column" => column name, "value" => value, "type" => type, "font" => font, "font-style" => style ], "id" => uuid
287 // Creates missing columns automatically. 380 // Creates missing columns automatically.
@@ -316,11 +409,14 @@ public:
316 // Returns FALSE if not found. 409 // Returns FALSE if not found.
317 BOOL setSelectedByValue(LLSD value, BOOL selected); 410 BOOL setSelectedByValue(LLSD value, BOOL selected);
318 411
319 virtual BOOL isSelected(LLSD value); 412 BOOL isSorted();
320 413
414 virtual BOOL isSelected(LLSD value);
415
321 BOOL selectFirstItem(); 416 BOOL selectFirstItem();
322 BOOL selectNthItem( S32 index ); 417 BOOL selectNthItem( S32 index );
323 418 BOOL selectItemAt(S32 x, S32 y, MASK mask);
419
324 void deleteSingleItem( S32 index ) ; 420 void deleteSingleItem( S32 index ) ;
325 void deleteSelectedItems(); 421 void deleteSelectedItems();
326 void deselectAllItems(BOOL no_commit_on_change = FALSE); // by default, go ahead and commit on selection change 422 void deselectAllItems(BOOL no_commit_on_change = FALSE); // by default, go ahead and commit on selection change
@@ -357,23 +453,6 @@ public:
357 LLScrollListItem* addStringUUIDItem(const LLString& item_text, const LLUUID& id, EAddPosition pos = ADD_BOTTOM, BOOL enabled = TRUE, S32 column_width = 0); 453 LLScrollListItem* addStringUUIDItem(const LLString& item_text, const LLUUID& id, EAddPosition pos = ADD_BOTTOM, BOOL enabled = TRUE, S32 column_width = 0);
358 LLUUID getStringUUIDSelectedItem(); 454 LLUUID getStringUUIDSelectedItem();
359 455
360 // "Full" interface: use this when you're creating a list that has one or more of the following:
361 // * contains icons
362 // * contains multiple columns
363 // * allows multiple selection
364 // * has items that are not guarenteed to have unique names
365 // * has additional per-item data (e.g. a UUID or void* userdata)
366 //
367 // To add items using this approach, create new LLScrollListItems and LLScrollListCells. Add the
368 // cells (column entries) to each item, and add the item to the LLScrollListCtrl.
369 //
370 // The LLScrollListCtrl owns its items and is responsible for deleting them
371 // (except in the case that the addItem() call fails, in which case it is up
372 // to the caller to delete the item)
373
374 // returns FALSE if item faile to be added to list, does NOT delete 'item'
375 // TomY TODO - Deprecate this API and remove it
376 BOOL addItem( LLScrollListItem* item, EAddPosition pos = ADD_BOTTOM );
377 LLScrollListItem* getFirstSelected() const; 456 LLScrollListItem* getFirstSelected() const;
378 virtual S32 getFirstSelectedIndex(); 457 virtual S32 getFirstSelectedIndex();
379 std::vector<LLScrollListItem*> getAllSelected() const; 458 std::vector<LLScrollListItem*> getAllSelected() const;
@@ -382,6 +461,7 @@ public:
382 461
383 // iterate over all items 462 // iterate over all items
384 LLScrollListItem* getFirstData() const; 463 LLScrollListItem* getFirstData() const;
464 LLScrollListItem* getLastData() const;
385 std::vector<LLScrollListItem*> getAllData() const; 465 std::vector<LLScrollListItem*> getAllData() const;
386 466
387 void setAllowMultipleSelection(BOOL mult ) { mAllowMultipleSelection = mult; } 467 void setAllowMultipleSelection(BOOL mult ) { mAllowMultipleSelection = mult; }
@@ -398,6 +478,7 @@ public:
398 void setBackgroundVisible(BOOL b) { mBackgroundVisible = b; } 478 void setBackgroundVisible(BOOL b) { mBackgroundVisible = b; }
399 void setDrawStripes(BOOL b) { mDrawStripes = b; } 479 void setDrawStripes(BOOL b) { mDrawStripes = b; }
400 void setColumnPadding(const S32 c) { mColumnPadding = c; } 480 void setColumnPadding(const S32 c) { mColumnPadding = c; }
481 S32 getColumnPadding() { return mColumnPadding; }
401 void setCommitOnKeyboardMovement(BOOL b) { mCommitOnKeyboardMovement = b; } 482 void setCommitOnKeyboardMovement(BOOL b) { mCommitOnKeyboardMovement = b; }
402 void setCommitOnSelectionChange(BOOL b) { mCommitOnSelectionChange = b; } 483 void setCommitOnSelectionChange(BOOL b) { mCommitOnSelectionChange = b; }
403 void setAllowKeyboardMovement(BOOL b) { mAllowKeyboardMovement = b; } 484 void setAllowKeyboardMovement(BOOL b) { mAllowKeyboardMovement = b; }
@@ -417,6 +498,7 @@ public:
417 // Overridden from LLView 498 // Overridden from LLView
418 virtual void draw(); 499 virtual void draw();
419 virtual BOOL handleMouseDown(S32 x, S32 y, MASK mask); 500 virtual BOOL handleMouseDown(S32 x, S32 y, MASK mask);
501 virtual BOOL handleMouseUp(S32 x, S32 y, MASK mask);
420 virtual BOOL handleDoubleClick(S32 x, S32 y, MASK mask); 502 virtual BOOL handleDoubleClick(S32 x, S32 y, MASK mask);
421 virtual BOOL handleHover(S32 x, S32 y, MASK mask); 503 virtual BOOL handleHover(S32 x, S32 y, MASK mask);
422 virtual BOOL handleKeyHere(KEY key, MASK mask, BOOL called_from_parent); 504 virtual BOOL handleKeyHere(KEY key, MASK mask, BOOL called_from_parent);
@@ -424,6 +506,7 @@ public:
424 virtual BOOL handleScrollWheel(S32 x, S32 y, S32 clicks); 506 virtual BOOL handleScrollWheel(S32 x, S32 y, S32 clicks);
425 virtual void setEnabled(BOOL enabled); 507 virtual void setEnabled(BOOL enabled);
426 virtual void setFocus( BOOL b ); 508 virtual void setFocus( BOOL b );
509 virtual void onFocusReceived();
427 virtual void onFocusLost(); 510 virtual void onFocusLost();
428 511
429 virtual void reshape(S32 width, S32 height, BOOL called_from_parent = TRUE); 512 virtual void reshape(S32 width, S32 height, BOOL called_from_parent = TRUE);
@@ -431,17 +514,18 @@ public:
431 virtual LLRect getRequiredRect(); 514 virtual LLRect getRequiredRect();
432 static BOOL rowPreceeds(LLScrollListItem *new_row, LLScrollListItem *test_row); 515 static BOOL rowPreceeds(LLScrollListItem *new_row, LLScrollListItem *test_row);
433 516
517 LLRect getItemListRect() { return mItemListRect; }
518
434 // Used "internally" by the scroll bar. 519 // Used "internally" by the scroll bar.
435 static void onScrollChange( S32 new_pos, LLScrollbar* src, void* userdata ); 520 static void onScrollChange( S32 new_pos, LLScrollbar* src, void* userdata );
436 521
437 static void onClickColumn(void *userdata); 522 static void onClickColumn(void *userdata);
438 523
439 void updateColumns(); 524 void updateColumns();
440 void updateColumnButtons(); 525 void updateMaxContentWidth(LLScrollListItem* changed_item);
441 526
442 void setDisplayHeading(BOOL display); 527 void setDisplayHeading(BOOL display);
443 void setHeadingHeight(S32 heading_height); 528 void setHeadingHeight(S32 heading_height);
444 void setHeadingFont(const LLFontGL* heading_font);
445 void setCollapseEmptyColumns(BOOL collapse); 529 void setCollapseEmptyColumns(BOOL collapse);
446 void setIsPopup(BOOL is_popup) { mIsPopup = is_popup; } 530 void setIsPopup(BOOL is_popup) { mIsPopup = is_popup; }
447 531
@@ -473,6 +557,22 @@ public:
473 S32 selectMultiple( LLDynamicArray<LLUUID> ids ); 557 S32 selectMultiple( LLDynamicArray<LLUUID> ids );
474 558
475protected: 559protected:
560 // "Full" interface: use this when you're creating a list that has one or more of the following:
561 // * contains icons
562 // * contains multiple columns
563 // * allows multiple selection
564 // * has items that are not guarenteed to have unique names
565 // * has additional per-item data (e.g. a UUID or void* userdata)
566 //
567 // To add items using this approach, create new LLScrollListItems and LLScrollListCells. Add the
568 // cells (column entries) to each item, and add the item to the LLScrollListCtrl.
569 //
570 // The LLScrollListCtrl owns its items and is responsible for deleting them
571 // (except in the case that the addItem() call fails, in which case it is up
572 // to the caller to delete the item)
573
574 // returns FALSE if item faile to be added to list, does NOT delete 'item'
575 BOOL addItem( LLScrollListItem* item, EAddPosition pos = ADD_BOTTOM );
476 void selectPrevItem(BOOL extend_selection); 576 void selectPrevItem(BOOL extend_selection);
477 void selectNextItem(BOOL extend_selection); 577 void selectNextItem(BOOL extend_selection);
478 void drawItems(); 578 void drawItems();
@@ -482,6 +582,7 @@ protected:
482 void selectItem(LLScrollListItem* itemp, BOOL single_select = TRUE); 582 void selectItem(LLScrollListItem* itemp, BOOL single_select = TRUE);
483 void deselectItem(LLScrollListItem* itemp); 583 void deselectItem(LLScrollListItem* itemp);
484 void commitIfChanged(); 584 void commitIfChanged();
585 void setSorted(BOOL sorted);
485 586
486protected: 587protected:
487 S32 mCurIndex; // For get[First/Next]Data 588 S32 mCurIndex; // For get[First/Next]Data
@@ -492,7 +593,6 @@ protected:
492 S32 mPageLines; // max number of lines is it possible to see on the screen given mRect and mLineHeight 593 S32 mPageLines; // max number of lines is it possible to see on the screen given mRect and mLineHeight
493 S32 mHeadingHeight; // the height of the column header buttons, if visible 594 S32 mHeadingHeight; // the height of the column header buttons, if visible
494 U32 mMaxSelectable; 595 U32 mMaxSelectable;
495 const LLFontGL* mHeadingFont; // the font to use for column head buttons, if visible
496 LLScrollbar* mScrollbar; 596 LLScrollbar* mScrollbar;
497 BOOL mAllowMultipleSelection; 597 BOOL mAllowMultipleSelection;
498 BOOL mAllowKeyboardMovement; 598 BOOL mAllowKeyboardMovement;
@@ -500,7 +600,7 @@ protected:
500 BOOL mCommitOnSelectionChange; 600 BOOL mCommitOnSelectionChange;
501 BOOL mSelectionChanged; 601 BOOL mSelectionChanged;
502 BOOL mCanSelect; 602 BOOL mCanSelect;
503 BOOL mDisplayColumnButtons; 603 BOOL mDisplayColumnHeaders;
504 BOOL mCollapseEmptyColumns; 604 BOOL mCollapseEmptyColumns;
505 BOOL mIsPopup; 605 BOOL mIsPopup;
506 606
@@ -544,8 +644,9 @@ protected:
544 S32 mNumDynamicWidthColumns; 644 S32 mNumDynamicWidthColumns;
545 S32 mTotalStaticColumnWidth; 645 S32 mTotalStaticColumnWidth;
546 646
547 U32 mSortColumn; 647 S32 mSortColumn;
548 BOOL mSortAscending; 648 BOOL mSortAscending;
649 BOOL mSorted;
549 650
550 std::map<LLString, LLScrollListColumn> mColumns; 651 std::map<LLString, LLScrollListColumn> mColumns;
551 std::vector<LLScrollListColumn*> mColumnsIndexed; 652 std::vector<LLScrollListColumn*> mColumnsIndexed;