summaryrefslogtreecommitdiff
path: root/indra/llui/llscrolllistctrl.h
diff options
context:
space:
mode:
authorJosh Bell <josh@lindenlab.com>2007-03-31 01:41:19 +0000
committerJosh Bell <josh@lindenlab.com>2007-03-31 01:41:19 +0000
commitea8fb7238e6f12383ee4bc081475fa6235637581 (patch)
treef384da93c884353bef55cf887f6c86f2081db271 /indra/llui/llscrolllistctrl.h
parentffc6680d956069625fc1fe5da133bdf7922cea83 (diff)
svn merge -r 59364:59813 svn+ssh://svn.lindenlab.com/svn/linden/branches/maintenance --> release
Diffstat (limited to 'indra/llui/llscrolllistctrl.h')
-rw-r--r--indra/llui/llscrolllistctrl.h133
1 files changed, 103 insertions, 30 deletions
diff --git a/indra/llui/llscrolllistctrl.h b/indra/llui/llscrolllistctrl.h
index 9c16e4dff9..99218ab3c4 100644
--- a/indra/llui/llscrolllistctrl.h
+++ b/indra/llui/llscrolllistctrl.h
@@ -23,9 +23,12 @@
#include "llviewborder.h"
#include "llframetimer.h"
#include "llcheckboxctrl.h"
+#include "llcombobox.h"
class LLScrollbar;
class LLScrollListCtrl;
+class LLColumnHeader;
+class LLResizeBar;
class LLScrollListCell
{
@@ -39,6 +42,7 @@ public:
virtual const BOOL getVisible() const { return TRUE; }
virtual void setWidth(S32 width) = 0;
virtual void highlightText(S32 offset, S32 num_chars) {}
+ virtual BOOL isText() = 0;
virtual BOOL handleClick() { return FALSE; }
virtual void setEnabled(BOOL enable) { }
@@ -58,6 +62,7 @@ public:
virtual const BOOL getVisible() const { return mVisible; }
virtual void highlightText(S32 offset, S32 num_chars) {mHighlightOffset = offset; mHighlightCount = num_chars;}
void setText(const LLString& text);
+ virtual BOOL isText() { return TRUE; }
private:
LLUIString mText;
@@ -86,6 +91,7 @@ public:
virtual const LLString& getText() const { return mImageUUID; }
virtual const LLString& getTextLower() const { return mImageUUID; }
virtual void setWidth(S32 width) { mWidth = width; }
+ virtual BOOL isText() { return FALSE; }
private:
LLPointer<LLImageGL> mIcon;
@@ -107,6 +113,7 @@ public:
virtual void setEnabled(BOOL enable) { if (mCheckBox) mCheckBox->setEnabled(enable); }
LLCheckBoxCtrl* getCheckBox() { return mCheckBox; }
+ virtual BOOL isText() { return FALSE; }
private:
LLCheckBoxCtrl* mCheckBox;
@@ -117,14 +124,37 @@ class LLScrollListColumn
{
public:
// Default constructor
- LLScrollListColumn() : mName(""), mSortingColumn(""), mLabel(""), mWidth(-1), mRelWidth(-1.0), mDynamicWidth(FALSE), mIndex(-1), mParentCtrl(NULL), mButton(NULL), mFontAlignment(LLFontGL::LEFT)
+ LLScrollListColumn() :
+ mName(""),
+ mSortingColumn(""),
+ mLabel(""),
+ mWidth(-1),
+ mRelWidth(-1.0),
+ mDynamicWidth(FALSE),
+ mMaxContentWidth(0),
+ mIndex(-1),
+ mParentCtrl(NULL),
+ mHeader(NULL),
+ mFontAlignment(LLFontGL::LEFT)
{ }
- LLScrollListColumn(LLString name, LLString label, S32 width, F32 relwidth)
- : mName(name), mSortingColumn(name), mLabel(label), mWidth(width), mRelWidth(relwidth), mDynamicWidth(FALSE), mIndex(-1), mParentCtrl(NULL), mButton(NULL) { }
+ LLScrollListColumn(LLString name, LLString label, S32 width, F32 relwidth) :
+ mName(name),
+ mSortingColumn(name),
+ mLabel(label),
+ mWidth(width),
+ mRelWidth(relwidth),
+ mDynamicWidth(FALSE),
+ mMaxContentWidth(0),
+ mIndex(-1),
+ mParentCtrl(NULL),
+ mHeader(NULL)
+ { }
LLScrollListColumn(const LLSD &sd)
{
+ mMaxContentWidth = 0;
+
mName = sd.get("name").asString();
mSortingColumn = mName;
if (sd.has("sort"))
@@ -160,7 +190,7 @@ public:
mIndex = -1;
mParentCtrl = NULL;
- mButton = NULL;
+ mHeader = NULL;
}
LLString mName;
@@ -169,12 +199,47 @@ public:
S32 mWidth;
F32 mRelWidth;
BOOL mDynamicWidth;
+ S32 mMaxContentWidth;
S32 mIndex;
LLScrollListCtrl* mParentCtrl;
- LLButton* mButton;
+ LLColumnHeader* mHeader;
LLFontGL::HAlign mFontAlignment;
};
+class LLColumnHeader : public LLComboBox
+{
+public:
+ LLColumnHeader(const LLString& label, const LLRect &rect, LLScrollListColumn* column, const LLFontGL *font = NULL);
+ ~LLColumnHeader();
+
+ /*virtual*/ void draw();
+ /*virtual*/ BOOL handleDoubleClick(S32 x, S32 y, MASK mask);
+ /*virtual*/ void showList();
+ /*virtual*/ LLView* findSnapEdge(S32& new_edge_val, const LLCoordGL& mouse_dir, ESnapEdge snap_edge, ESnapType snap_type, S32 threshold, S32 padding);
+ /*virtual*/ void userSetShape(const LLRect& new_rect);
+
+ void setImage(const LLString &image_name);
+ LLScrollListColumn* getColumn() { return mColumn; }
+ void setHasResizableElement(BOOL resizable);
+ BOOL canResize();
+ void enableResizeBar(BOOL enable);
+ LLString getLabel() { return mOrigLabel; }
+
+ static void onSelectSort(LLUICtrl* ctrl, void* user_data);
+ static void onClick(void* user_data);
+ static void onMouseDown(void* user_data);
+ static void onHeldDown(void* user_data);
+
+protected:
+ LLScrollListColumn* mColumn;
+ LLResizeBar* mResizeBar;
+ LLString mOrigLabel;
+ LLUIString mAscendingText;
+ LLUIString mDescendingText;
+ BOOL mShowSortOptions;
+ BOOL mHasResizableElement;
+};
+
class LLScrollListItem
{
public:
@@ -216,7 +281,7 @@ public:
LLScrollListCell *getColumn(const S32 i) const { if (i < (S32)mColumns.size()) { return mColumns[i]; } return NULL; }
- virtual BOOL handleMouseDown(S32 x, S32 y, MASK mask);
+ virtual BOOL handleClick(S32 x, S32 y, MASK mask);
LLString getContentsCSV();
@@ -263,6 +328,10 @@ public:
virtual void addColumn(const LLSD& column, EAddPosition pos = ADD_BOTTOM);
virtual void clearColumns();
virtual void setColumnLabel(const LLString& column, const LLString& label);
+
+ virtual LLScrollListColumn* getColumn(S32 index);
+ virtual S32 getNumColumns() const { return mColumnsIndexed.size(); }
+
// Adds a single element, from an array of:
// "columns" => [ "column" => column name, "value" => value, "type" => type, "font" => font, "font-style" => style ], "id" => uuid
// Creates missing columns automatically.
@@ -301,7 +370,8 @@ public:
BOOL selectFirstItem();
BOOL selectNthItem( S32 index );
-
+ BOOL selectItemAt(S32 x, S32 y, MASK mask);
+
void deleteSingleItem( S32 index ) ;
void deleteSelectedItems();
void deselectAllItems(BOOL no_commit_on_change = FALSE); // by default, go ahead and commit on selection change
@@ -338,23 +408,6 @@ public:
LLScrollListItem* addStringUUIDItem(const LLString& item_text, const LLUUID& id, EAddPosition pos = ADD_BOTTOM, BOOL enabled = TRUE, S32 column_width = 0);
LLUUID getStringUUIDSelectedItem();
- // "Full" interface: use this when you're creating a list that has one or more of the following:
- // * contains icons
- // * contains multiple columns
- // * allows multiple selection
- // * has items that are not guarenteed to have unique names
- // * has additional per-item data (e.g. a UUID or void* userdata)
- //
- // To add items using this approach, create new LLScrollListItems and LLScrollListCells. Add the
- // cells (column entries) to each item, and add the item to the LLScrollListCtrl.
- //
- // The LLScrollListCtrl owns its items and is responsible for deleting them
- // (except in the case that the addItem() call fails, in which case it is up
- // to the caller to delete the item)
-
- // returns FALSE if item faile to be added to list, does NOT delete 'item'
- // TomY TODO - Deprecate this API and remove it
- BOOL addItem( LLScrollListItem* item, EAddPosition pos = ADD_BOTTOM );
LLScrollListItem* getFirstSelected() const;
virtual S32 getFirstSelectedIndex();
std::vector<LLScrollListItem*> getAllSelected() const;
@@ -363,6 +416,7 @@ public:
// iterate over all items
LLScrollListItem* getFirstData() const;
+ LLScrollListItem* getLastData() const;
std::vector<LLScrollListItem*> getAllData() const;
void setAllowMultipleSelection(BOOL mult ) { mAllowMultipleSelection = mult; }
@@ -379,6 +433,7 @@ public:
void setBackgroundVisible(BOOL b) { mBackgroundVisible = b; }
void setDrawStripes(BOOL b) { mDrawStripes = b; }
void setColumnPadding(const S32 c) { mColumnPadding = c; }
+ S32 getColumnPadding() { return mColumnPadding; }
void setCommitOnKeyboardMovement(BOOL b) { mCommitOnKeyboardMovement = b; }
void setCommitOnSelectionChange(BOOL b) { mCommitOnSelectionChange = b; }
void setAllowKeyboardMovement(BOOL b) { mAllowKeyboardMovement = b; }
@@ -398,6 +453,7 @@ public:
// Overridden from LLView
virtual void draw();
virtual BOOL handleMouseDown(S32 x, S32 y, MASK mask);
+ virtual BOOL handleMouseUp(S32 x, S32 y, MASK mask);
virtual BOOL handleDoubleClick(S32 x, S32 y, MASK mask);
virtual BOOL handleHover(S32 x, S32 y, MASK mask);
virtual BOOL handleKeyHere(KEY key, MASK mask, BOOL called_from_parent);
@@ -405,6 +461,7 @@ public:
virtual BOOL handleScrollWheel(S32 x, S32 y, S32 clicks);
virtual void setEnabled(BOOL enabled);
virtual void setFocus( BOOL b );
+ virtual void onFocusReceived();
virtual void onFocusLost();
virtual void reshape(S32 width, S32 height, BOOL called_from_parent = TRUE);
@@ -412,17 +469,18 @@ public:
virtual LLRect getRequiredRect();
static BOOL rowPreceeds(LLScrollListItem *new_row, LLScrollListItem *test_row);
+ LLRect getItemListRect() { return mItemListRect; }
+
// Used "internally" by the scroll bar.
static void onScrollChange( S32 new_pos, LLScrollbar* src, void* userdata );
static void onClickColumn(void *userdata);
void updateColumns();
- void updateColumnButtons();
+ void updateMaxContentWidth(LLScrollListItem* changed_item);
void setDisplayHeading(BOOL display);
void setHeadingHeight(S32 heading_height);
- void setHeadingFont(const LLFontGL* heading_font);
void setCollapseEmptyColumns(BOOL collapse);
void setIsPopup(BOOL is_popup) { mIsPopup = is_popup; }
@@ -454,6 +512,22 @@ public:
S32 selectMultiple( LLDynamicArray<LLUUID> ids );
protected:
+ // "Full" interface: use this when you're creating a list that has one or more of the following:
+ // * contains icons
+ // * contains multiple columns
+ // * allows multiple selection
+ // * has items that are not guarenteed to have unique names
+ // * has additional per-item data (e.g. a UUID or void* userdata)
+ //
+ // To add items using this approach, create new LLScrollListItems and LLScrollListCells. Add the
+ // cells (column entries) to each item, and add the item to the LLScrollListCtrl.
+ //
+ // The LLScrollListCtrl owns its items and is responsible for deleting them
+ // (except in the case that the addItem() call fails, in which case it is up
+ // to the caller to delete the item)
+
+ // returns FALSE if item faile to be added to list, does NOT delete 'item'
+ BOOL addItem( LLScrollListItem* item, EAddPosition pos = ADD_BOTTOM );
void selectPrevItem(BOOL extend_selection);
void selectNextItem(BOOL extend_selection);
void drawItems();
@@ -473,7 +547,6 @@ protected:
S32 mPageLines; // max number of lines is it possible to see on the screen given mRect and mLineHeight
S32 mHeadingHeight; // the height of the column header buttons, if visible
U32 mMaxSelectable;
- const LLFontGL* mHeadingFont; // the font to use for column head buttons, if visible
LLScrollbar* mScrollbar;
BOOL mAllowMultipleSelection;
BOOL mAllowKeyboardMovement;
@@ -481,7 +554,7 @@ protected:
BOOL mCommitOnSelectionChange;
BOOL mSelectionChanged;
BOOL mCanSelect;
- BOOL mDisplayColumnButtons;
+ BOOL mDisplayColumnHeaders;
BOOL mCollapseEmptyColumns;
BOOL mIsPopup;
@@ -525,8 +598,8 @@ protected:
S32 mNumDynamicWidthColumns;
S32 mTotalStaticColumnWidth;
- U32 mSortColumn;
- BOOL mSortAscending;
+ S32 mSortColumn;
+ BOOL mSortAscending;
std::map<LLString, LLScrollListColumn> mColumns;
std::vector<LLScrollListColumn*> mColumnsIndexed;