llscrolllistctrl.h

Go to the documentation of this file.
00001 
00032 #ifndef LL_SCROLLLISTCTRL_H
00033 #define LL_SCROLLLISTCTRL_H
00034 
00035 #include <vector>
00036 #include <deque>
00037 
00038 #include "lluictrl.h"
00039 #include "llctrlselectioninterface.h"
00040 #include "lldarray.h"
00041 #include "llfontgl.h"
00042 #include "llui.h"
00043 #include "llstring.h"
00044 #include "llimagegl.h"
00045 #include "lleditmenuhandler.h"
00046 #include "llviewborder.h"
00047 #include "llframetimer.h"
00048 #include "llcheckboxctrl.h"
00049 #include "llcombobox.h"
00050 
00051 class LLScrollbar;
00052 class LLScrollListCtrl;
00053 class LLColumnHeader;
00054 class LLResizeBar;
00055 
00056 class LLScrollListCell
00057 {
00058 public:
00059         virtual ~LLScrollListCell() {};
00060         virtual void                    drawToWidth(S32 width, const LLColor4& color, const LLColor4& highlight_color) const = 0;               // truncate to given width, if possible
00061         virtual S32                             getWidth() const = 0;
00062         virtual S32                             getHeight() const = 0;
00063         virtual const LLString& getText() const { return LLString::null; }
00064         virtual const LLString& getTextLower() const { return LLString::null; }
00065         virtual BOOL                    getVisible() const { return TRUE; }
00066         virtual void                    setWidth(S32 width) = 0;
00067         virtual void                    highlightText(S32 offset, S32 num_chars) {}
00068         virtual BOOL                    isText() = 0;
00069         virtual void                    setColor(const LLColor4&) = 0;
00070 
00071         virtual BOOL    handleClick() { return FALSE; }
00072         virtual void    setEnabled(BOOL enable) { }
00073 };
00074 
00075 class LLScrollListSeparator : public LLScrollListCell
00076 {
00077 public:
00078         LLScrollListSeparator(S32 width);
00079         virtual ~LLScrollListSeparator() {};
00080         virtual void                    drawToWidth(S32 width, const LLColor4& color, const LLColor4& highlight_color) const;           // truncate to given width, if possible
00081         virtual S32                             getWidth() const {return mWidth;}
00082         virtual S32                             getHeight() const { return 5; };
00083         virtual void                    setWidth(S32 width) {mWidth = width; }
00084         virtual void                    setColor(const LLColor4&) {};
00085         virtual BOOL                    isText() { return FALSE; }
00086 
00087 protected:
00088         S32 mWidth;
00089 };
00090 
00091 class LLScrollListText : public LLScrollListCell
00092 {
00093 public:
00094         LLScrollListText( const LLString& text, const LLFontGL* font, S32 width = 0, U8 font_style = LLFontGL::NORMAL, LLFontGL::HAlign font_alignment = LLFontGL::LEFT, LLColor4& color = LLColor4::black, BOOL use_color = FALSE, BOOL visible = TRUE);
00095         /*virtual*/ ~LLScrollListText();
00096 
00097         virtual void    drawToWidth(S32 width, const LLColor4& color, const LLColor4& highlight_color) const;
00098         virtual S32             getWidth() const                        { return mWidth; }
00099         virtual void    setWidth(S32 width)                     { mWidth = width; }
00100         virtual S32             getHeight() const                       { return llround(mFont->getLineHeight()); }
00101         virtual const LLString&         getText() const         { return mText.getString(); }
00102         virtual BOOL    getVisible() const  { return mVisible; }
00103         virtual void    highlightText(S32 offset, S32 num_chars) {mHighlightOffset = offset; mHighlightCount = num_chars;}
00104         void                    setText(const LLStringExplicit& text);
00105         virtual void    setColor(const LLColor4&);
00106         virtual BOOL    isText() { return TRUE; }
00107 
00108 private:
00109         LLUIString              mText;
00110         const LLFontGL* mFont;
00111         LLColor4*               mColor;
00112         const U8                mFontStyle;
00113         LLFontGL::HAlign mFontAlignment;
00114         S32                             mWidth;
00115         BOOL                    mVisible;
00116         S32                             mHighlightCount;
00117         S32                             mHighlightOffset;
00118 
00119         LLPointer<LLImageGL> mRoundedRectImage;
00120 
00121         static U32 sCount;
00122 };
00123 
00124 class LLScrollListIcon : public LLScrollListCell
00125 {
00126 public:
00127         LLScrollListIcon( LLImageGL* icon, S32 width = 0, LLUUID image_id = LLUUID::null);
00128         /*virtual*/ ~LLScrollListIcon();
00129         virtual void    drawToWidth(S32 width, const LLColor4& color, const LLColor4& highlight_color) const;
00130         virtual S32             getWidth() const                        { return mWidth; }
00131         virtual S32             getHeight() const                       { return mIcon->getHeight(); }
00132         virtual const LLString& getText() const { return mImageUUID; }
00133         virtual const LLString& getTextLower() const { return mImageUUID; }
00134         virtual void    setWidth(S32 width)                     { mWidth = width; }
00135         virtual void    setColor(const LLColor4&);
00136         virtual BOOL    isText() { return FALSE; }
00137 
00138 private:
00139         LLPointer<LLImageGL> mIcon;
00140         LLString mImageUUID;
00141         S32 mWidth;
00142         LLColor4 mColor;
00143 };
00144 
00145 class LLScrollListCheck : public LLScrollListCell
00146 {
00147 public:
00148         LLScrollListCheck( LLCheckBoxCtrl* check_box, S32 width = 0);
00149         /*virtual*/ ~LLScrollListCheck();
00150         virtual void    drawToWidth(S32 width, const LLColor4& color, const LLColor4& highlight_color) const;
00151         virtual S32             getWidth() const                        { return mWidth; }
00152         virtual S32             getHeight() const                       { return 0; } 
00153         virtual void    setWidth(S32 width)                     { mWidth = width; }
00154 
00155         virtual BOOL    handleClick();
00156         virtual void    setEnabled(BOOL enable)         { if (mCheckBox) mCheckBox->setEnabled(enable); }
00157         virtual void    setColor(const LLColor4& color) {};
00158 
00159         LLCheckBoxCtrl* getCheckBox()                           { return mCheckBox; }
00160         virtual BOOL    isText() { return FALSE; }
00161 
00162 private:
00163         LLCheckBoxCtrl* mCheckBox;
00164         S32 mWidth;
00165 };
00166 
00167 class LLScrollListColumn
00168 {
00169 public:
00170         // Default constructor
00171         LLScrollListColumn() : 
00172                 mName(), 
00173                 mSortingColumn(), 
00174                 mSortAscending(TRUE), 
00175                 mLabel(), 
00176                 mWidth(-1), 
00177                 mRelWidth(-1.0), 
00178                 mDynamicWidth(FALSE), 
00179                 mMaxContentWidth(0),
00180                 mIndex(-1), 
00181                 mParentCtrl(NULL), 
00182                 mHeader(NULL), 
00183                 mFontAlignment(LLFontGL::LEFT)
00184         { }
00185 
00186         LLScrollListColumn(LLString name, LLString label, S32 width, F32 relwidth) : 
00187                 mName(name), 
00188                 mSortingColumn(name), 
00189                 mSortAscending(TRUE), 
00190                 mLabel(label), 
00191                 mWidth(width), 
00192                 mRelWidth(relwidth), 
00193                 mDynamicWidth(FALSE), 
00194                 mMaxContentWidth(0),
00195                 mIndex(-1), 
00196                 mParentCtrl(NULL), 
00197                 mHeader(NULL) 
00198         { }
00199 
00200         LLScrollListColumn(const LLSD &sd)
00201         {
00202                 mMaxContentWidth = 0;
00203 
00204                 mName = sd.get("name").asString();
00205                 mSortingColumn = mName;
00206                 if (sd.has("sort"))
00207                 {
00208                         mSortingColumn = sd.get("sort").asString();
00209                 }
00210                 mSortAscending = TRUE;
00211                 if (sd.has("sort_ascending"))
00212                 {
00213                         mSortAscending = sd.get("sort_ascending").asBoolean();
00214                 }
00215                 mLabel = sd.get("label").asString();
00216                 if (sd.has("relwidth") && (F32)sd.get("relwidth").asReal() > 0)
00217                 {
00218                         mRelWidth = (F32)sd.get("relwidth").asReal();
00219                         if (mRelWidth < 0) mRelWidth = 0;
00220                         if (mRelWidth > 1) mRelWidth = 1;
00221                         mDynamicWidth = FALSE;
00222                         mWidth = 0;
00223                 }
00224                 else if(sd.has("dynamicwidth") && (BOOL)sd.get("dynamicwidth").asBoolean() == TRUE)
00225                 {
00226                         mDynamicWidth = TRUE;
00227                         mRelWidth = -1;
00228                         mWidth = 0;
00229                 }
00230                 else
00231                 {
00232                         mWidth = sd.get("width").asInteger();
00233                         mDynamicWidth = FALSE;
00234                         mRelWidth = -1;
00235                 }
00236 
00237                 if (sd.has("halign"))
00238                 {
00239                         mFontAlignment = (LLFontGL::HAlign)llclamp(sd.get("halign").asInteger(), (S32)LLFontGL::LEFT, (S32)LLFontGL::HCENTER);
00240                 }
00241 
00242                 mIndex = -1;
00243                 mParentCtrl = NULL;
00244                 mHeader = NULL;
00245         }
00246 
00247         LLString                        mName;
00248         LLString                        mSortingColumn;
00249         BOOL                            mSortAscending;
00250         LLString                        mLabel;
00251         S32                                     mWidth;
00252         F32                                     mRelWidth;
00253         BOOL                            mDynamicWidth;
00254         S32                                     mMaxContentWidth;
00255         S32                                     mIndex;
00256         LLScrollListCtrl*       mParentCtrl;
00257         LLColumnHeader*         mHeader;
00258         LLFontGL::HAlign        mFontAlignment;
00259 };
00260 
00261 class LLColumnHeader : public LLComboBox
00262 {
00263 public:
00264         LLColumnHeader(const LLString& label, const LLRect &rect, LLScrollListColumn* column, const LLFontGL *font = NULL);
00265         ~LLColumnHeader();
00266 
00267         /*virtual*/ void draw();
00268         /*virtual*/ BOOL handleDoubleClick(S32 x, S32 y, MASK mask);
00269         /*virtual*/ void showList();
00270         /*virtual*/ LLView*     findSnapEdge(S32& new_edge_val, const LLCoordGL& mouse_dir, ESnapEdge snap_edge, ESnapType snap_type, S32 threshold, S32 padding);
00271         /*virtual*/ void userSetShape(const LLRect& new_rect);
00272         
00273         void setImage(const LLString &image_name);
00274         LLScrollListColumn* getColumn() { return mColumn; }
00275         void setHasResizableElement(BOOL resizable);
00276         BOOL canResize();
00277         void enableResizeBar(BOOL enable);
00278         LLString getLabel() { return mOrigLabel; }
00279 
00280         static void onSelectSort(LLUICtrl* ctrl, void* user_data);
00281         static void onClick(void* user_data);
00282         static void onMouseDown(void* user_data);
00283         static void onHeldDown(void* user_data);
00284 
00285 protected:
00286         LLScrollListColumn* mColumn;
00287         LLResizeBar*            mResizeBar;
00288         LLString                        mOrigLabel;
00289         LLUIString                      mAscendingText;
00290         LLUIString                      mDescendingText;
00291         BOOL                            mShowSortOptions;
00292         BOOL                            mHasResizableElement;
00293 };
00294 
00295 class LLScrollListItem
00296 {
00297 public:
00298         LLScrollListItem( BOOL enabled = TRUE, void* userdata = NULL, const LLUUID& uuid = LLUUID::null )
00299                 : mSelected(FALSE), mEnabled( enabled ), mUserdata( userdata ), mItemValue( uuid ), mColumns() {}
00300         LLScrollListItem( LLSD item_value, void* userdata = NULL )
00301                 : mSelected(FALSE), mEnabled( TRUE ), mUserdata( userdata ), mItemValue( item_value ), mColumns() {}
00302 
00303         virtual ~LLScrollListItem();
00304 
00305         void    setSelected( BOOL b )                   { mSelected = b; }
00306         BOOL    getSelected() const                             { return mSelected; }
00307 
00308         void    setEnabled( BOOL b );
00309         BOOL    getEnabled() const                              { return mEnabled; }
00310 
00311         void    setUserdata( void* userdata )   { mUserdata = userdata; }
00312         void*   getUserdata() const                     { return mUserdata; }
00313 
00314         LLUUID  getUUID() const                                 { return mItemValue.asUUID(); }
00315         LLSD    getValue() const                                { return mItemValue; }
00316 
00317         // If width = 0, just use the width of the text.  Otherwise override with
00318         // specified width in pixels.
00319         void    addColumn( const LLString& text, const LLFontGL* font, S32 width = 0 , U8 font_style = LLFontGL::NORMAL, LLFontGL::HAlign font_alignment = LLFontGL::LEFT, BOOL visible = TRUE)
00320                                 { mColumns.push_back( new LLScrollListText(text, font, width, font_style, font_alignment, LLColor4::black, FALSE, visible) ); }
00321 
00322         void    addColumn( LLImageGL* icon, S32 width = 0 )
00323                                 { mColumns.push_back( new LLScrollListIcon(icon, width) ); }
00324 
00325         void    addColumn( LLCheckBoxCtrl* check, S32 width = 0 )
00326                                 { mColumns.push_back( new LLScrollListCheck(check,width) ); }
00327 
00328         void    setNumColumns(S32 columns);
00329 
00330         void    setColumn( S32 column, LLScrollListCell *cell );
00331         
00332         S32             getNumColumns() const                           { return mColumns.size(); }
00333 
00334         LLScrollListCell *getColumn(const S32 i) const  { if (i >= 0 && i < (S32)mColumns.size()) { return mColumns[i]; } return NULL; }
00335 
00336         virtual BOOL handleClick(S32 x, S32 y, MASK mask);
00337 
00338         LLString getContentsCSV();
00339 
00340 private:
00341         BOOL    mSelected;
00342         BOOL    mEnabled;
00343         void*   mUserdata;
00344         LLSD    mItemValue;
00345         std::vector<LLScrollListCell *> mColumns;
00346 };
00347 
00348 
00349 class LLScrollListCtrl : public LLUICtrl, public LLEditMenuHandler, 
00350         public LLCtrlListInterface, public LLCtrlScrollInterface
00351 {
00352 public:
00353         LLScrollListCtrl(
00354                 const LLString& name,
00355                 const LLRect& rect,
00356                 void (*commit_callback)(LLUICtrl*, void*),
00357                 void* callback_userdata,
00358                 BOOL allow_multiple_selection,
00359                 BOOL draw_border = TRUE);
00360 
00361         virtual ~LLScrollListCtrl();
00362         virtual EWidgetType getWidgetType() const { return WIDGET_TYPE_SCROLL_LIST; }
00363         virtual LLString getWidgetTag() const { return LL_SCROLL_LIST_CTRL_TAG; }
00364         virtual LLXMLNodePtr getXML(bool save_children = true) const;
00365         void setScrollListParameters(LLXMLNodePtr node);
00366         static LLView* fromXML(LLXMLNodePtr node, LLView *parent, LLUICtrlFactory *factory);
00367 
00368         S32                             isEmpty() const;
00369 
00370         void                    deleteAllItems() { clearRows(); }
00371         
00372         // Sets an array of column descriptors
00373         void                     setColumnHeadings(LLSD headings);
00374         // Numerical based sort by column function (used by LLComboBox)
00375         void                     sortByColumn(U32 column, BOOL ascending);
00376         void                    sort();
00377 
00378         // LLCtrlListInterface functions
00379         virtual S32  getItemCount() const;
00380         // Adds a single column descriptor: ["name" : string, "label" : string, "width" : integer, "relwidth" : integer ]
00381         virtual void addColumn(const LLSD& column, EAddPosition pos = ADD_BOTTOM);
00382         virtual void clearColumns();
00383         virtual void setColumnLabel(const LLString& column, const LLString& label);
00384 
00385         virtual LLScrollListColumn* getColumn(S32 index);
00386         virtual S32 getNumColumns() const { return mColumnsIndexed.size(); }
00387 
00388         // Adds a single element, from an array of:
00389         // "columns" => [ "column" => column name, "value" => value, "type" => type, "font" => font, "font-style" => style ], "id" => uuid
00390         // Creates missing columns automatically.
00391         virtual LLScrollListItem* addElement(const LLSD& value, EAddPosition pos = ADD_BOTTOM, void* userdata = NULL);
00392         // Simple add element. Takes a single array of:
00393         // [ "value" => value, "font" => font, "font-style" => style ]
00394         virtual LLScrollListItem* addSimpleElement(const LLString& value, EAddPosition pos = ADD_BOTTOM, const LLSD& id = LLSD());
00395         virtual void clearRows(); // clears all elements
00396         virtual void sortByColumn(LLString name, BOOL ascending);
00397 
00398         // These functions take and return an array of arrays of elements, as above
00399         virtual void    setValue(const LLSD& value );
00400         virtual LLSD    getValue() const;
00401 
00402         LLCtrlSelectionInterface*       getSelectionInterface() { return (LLCtrlSelectionInterface*)this; }
00403         LLCtrlListInterface*            getListInterface()              { return (LLCtrlListInterface*)this; }
00404         LLCtrlScrollInterface*          getScrollInterface()    { return (LLCtrlScrollInterface*)this; }
00405 
00406         // DEPRECATED: Use setSelectedByValue() below.
00407         BOOL                    setCurrentByID( const LLUUID& id )      { return selectByID(id); }
00408         virtual LLUUID  getCurrentID()                                          { return getStringUUIDSelectedItem(); }
00409 
00410         BOOL                    operateOnSelection(EOperation op);
00411         BOOL                    operateOnAll(EOperation op);
00412 
00413         // returns FALSE if unable to set the max count so low
00414         BOOL                    setMaxItemCount(S32 max_count);
00415 
00416         BOOL                    selectByID( const LLUUID& id );         // FALSE if item not found
00417 
00418         // Match item by value.asString(), which should work for string, integer, uuid.
00419         // Returns FALSE if not found.
00420         BOOL                    setSelectedByValue(LLSD value, BOOL selected);
00421 
00422         BOOL                    isSorted();
00423 
00424         virtual BOOL    isSelected(LLSD value);
00425         
00426         BOOL                    selectFirstItem();
00427         BOOL                    selectNthItem( S32 index );
00428         BOOL                    selectItemAt(S32 x, S32 y, MASK mask);
00429         
00430         void                    deleteSingleItem( S32 index ) ;
00431         void                    deleteSelectedItems();
00432         void                    deselectAllItems(BOOL no_commit_on_change = FALSE);     // by default, go ahead and commit on selection change
00433 
00434         void                    highlightNthItem( S32 index );
00435         void                    setDoubleClickCallback( void (*cb)(void*) ) { mOnDoubleClickCallback = cb; }
00436         void                    setMaxiumumSelectCallback( void (*cb)(void*) ) { mOnMaximumSelectCallback = cb; }
00437         void                    setSortChangedCallback( void (*cb)(void*) ) { mOnSortChangedCallback = cb; }
00438 
00439         void                    swapWithNext(S32 index);
00440         void                    swapWithPrevious(S32 index);
00441 
00442         void                    setCanSelect(BOOL can_select)           { mCanSelect = can_select; }
00443         virtual BOOL    getCanSelect() const                            { return mCanSelect; }
00444 
00445         S32                             getItemIndex( LLScrollListItem* item );
00446         S32                             getItemIndex( LLUUID& item_id );
00447 
00448         // "Simple" interface: use this when you're creating a list that contains only unique strings, only
00449         // one of which can be selected at a time.
00450         LLScrollListItem* addSimpleItem( const LLString& item_text, EAddPosition pos = ADD_BOTTOM, BOOL enabled = TRUE );
00451         // Add an item with an associated LLSD
00452         LLScrollListItem* addSimpleItem(const LLString& item_text, LLSD sd, EAddPosition pos = ADD_BOTTOM, BOOL enabled = TRUE, S32 column_width = 0 );
00453 
00454         BOOL                    selectSimpleItem( const LLString& item, BOOL case_sensitive = TRUE );           // FALSE if item not found
00455         BOOL                    selectSimpleItemByPrefix(const LLString& target, BOOL case_sensitive);
00456         BOOL                    selectSimpleItemByPrefix(const LLWString& target, BOOL case_sensitive);
00457         const LLString& getSimpleSelectedItem(S32 column = 0) const;
00458         LLSD                    getSimpleSelectedValue();
00459 
00460         // DEPRECATED: Use LLSD versions of addSimpleItem() and getSimpleSelectedValue().
00461         // "StringUUID" interface: use this when you're creating a list that contains non-unique strings each of which
00462         // has an associated, unique UUID, and only one of which can be selected at a time.
00463         LLScrollListItem*       addStringUUIDItem(const LLString& item_text, const LLUUID& id, EAddPosition pos = ADD_BOTTOM, BOOL enabled = TRUE, S32 column_width = 0);
00464         LLUUID                          getStringUUIDSelectedItem();
00465 
00466         LLScrollListItem*       getFirstSelected() const;
00467         virtual S32                     getFirstSelectedIndex() const;
00468         std::vector<LLScrollListItem*> getAllSelected() const;
00469         LLDynamicArray<LLUUID>  getSelectedIDs();
00470 
00471         LLScrollListItem*       getLastSelectedItem() const { return mLastSelected; }
00472 
00473         // iterate over all items
00474         LLScrollListItem*       getFirstData() const;
00475         LLScrollListItem*       getLastData() const;
00476         std::vector<LLScrollListItem*>  getAllData() const;
00477         
00478         void setAllowMultipleSelection(BOOL mult )      { mAllowMultipleSelection = mult; }
00479 
00480         void setBgWriteableColor(const LLColor4 &c)     { mBgWriteableColor = c; }
00481         void setReadOnlyBgColor(const LLColor4 &c)      { mBgReadOnlyColor = c; }
00482         void setBgSelectedColor(const LLColor4 &c)      { mBgSelectedColor = c; }
00483         void setBgStripeColor(const LLColor4& c)        { mBgStripeColor = c; }
00484         void setFgSelectedColor(const LLColor4 &c)      { mFgSelectedColor = c; }
00485         void setFgUnselectedColor(const LLColor4 &c){ mFgUnselectedColor = c; }
00486         void setHighlightedColor(const LLColor4 &c)     { mHighlightedColor = c; }
00487         void setFgDisableColor(const LLColor4 &c)       { mFgDisabledColor = c; }
00488 
00489         void setBackgroundVisible(BOOL b)                       { mBackgroundVisible = b; }
00490         void setDrawStripes(BOOL b)                                     { mDrawStripes = b; }
00491         void setColumnPadding(const S32 c)          { mColumnPadding = c; }
00492         S32  getColumnPadding()                                         { return mColumnPadding; }
00493         void setCommitOnKeyboardMovement(BOOL b)        { mCommitOnKeyboardMovement = b; }
00494         void setCommitOnSelectionChange(BOOL b)         { mCommitOnSelectionChange = b; }
00495         void setAllowKeyboardMovement(BOOL b)           { mAllowKeyboardMovement = b; }
00496 
00497         void                    setMaxSelectable(U32 max_selected) { mMaxSelectable = max_selected; }
00498         S32                             getMaxSelectable() { return mMaxSelectable; }
00499 
00500 
00501         virtual S32             getScrollPos();
00502         virtual void    setScrollPos( S32 pos );
00503 
00504         S32                             getSearchColumn() { return mSearchColumn; }
00505         void                    setSearchColumn(S32 column) { mSearchColumn = column; }
00506 
00507         void                    clearSearchString() { mSearchString.clear(); }
00508 
00509         // Overridden from LLView
00510         virtual void    draw();
00511         virtual BOOL    handleMouseDown(S32 x, S32 y, MASK mask);
00512         virtual BOOL    handleMouseUp(S32 x, S32 y, MASK mask);
00513         virtual BOOL    handleDoubleClick(S32 x, S32 y, MASK mask);
00514         virtual BOOL    handleHover(S32 x, S32 y, MASK mask);
00515         virtual BOOL    handleKeyHere(KEY key, MASK mask, BOOL called_from_parent);
00516         virtual BOOL    handleUnicodeCharHere(llwchar uni_char, BOOL called_from_parent);
00517         virtual BOOL    handleScrollWheel(S32 x, S32 y, S32 clicks);
00518         virtual void    setEnabled(BOOL enabled);
00519         virtual void    setFocus( BOOL b );
00520         virtual void    onFocusReceived();
00521         virtual void    onFocusLost();
00522 
00523         virtual BOOL    isDirty() const;
00524         virtual void    resetDirty();           // Clear dirty state
00525 
00526         virtual void    reshape(S32 width, S32 height, BOOL called_from_parent = TRUE);
00527         virtual void    arrange(S32 max_width, S32 max_height);
00528         virtual LLRect  getRequiredRect();
00529         static  BOOL    rowPreceeds(LLScrollListItem *new_row, LLScrollListItem *test_row);
00530 
00531         LLRect                  getItemListRect() { return mItemListRect; }
00532 
00533         // Used "internally" by the scroll bar.
00534         static void             onScrollChange( S32 new_pos, LLScrollbar* src, void* userdata );
00535 
00536         static void onClickColumn(void *userdata);
00537 
00538         void updateColumns();
00539         void updateMaxContentWidth(LLScrollListItem* changed_item);
00540 
00541         void setDisplayHeading(BOOL display);
00542         void setHeadingHeight(S32 heading_height);
00543         void setCollapseEmptyColumns(BOOL collapse);
00544         void setIsPopup(BOOL is_popup) { mIsPopup = is_popup; }
00545 
00546         LLScrollListItem*       hitItem(S32 x,S32 y);
00547         virtual void            scrollToShowSelected();
00548 
00549         // LLEditMenuHandler functions
00550         virtual void    copy();
00551         virtual BOOL    canCopy();
00552 
00553         virtual void    cut();
00554         virtual BOOL    canCut();
00555 
00556         virtual void    doDelete();
00557         virtual BOOL    canDoDelete();
00558 
00559         virtual void    selectAll();
00560         virtual BOOL    canSelectAll();
00561 
00562         virtual void    deselect();
00563         virtual BOOL    canDeselect();
00564 
00565         void setNumDynamicColumns(int num) { mNumDynamicWidthColumns = num; }
00566         void setTotalStaticColumnWidth(int width) { mTotalStaticColumnWidth = width; }
00567 
00568         std::string     getSortColumnName();
00569         BOOL                    getSortAscending() { return mSortAscending; }
00570 
00571         S32             selectMultiple( LLDynamicArray<LLUUID> ids );
00572 
00573 protected:
00574         // "Full" interface: use this when you're creating a list that has one or more of the following:
00575         // * contains icons
00576         // * contains multiple columns
00577         // * allows multiple selection
00578         // * has items that are not guarenteed to have unique names
00579         // * has additional per-item data (e.g. a UUID or void* userdata)
00580         //
00581         // To add items using this approach, create new LLScrollListItems and LLScrollListCells.  Add the
00582         // cells (column entries) to each item, and add the item to the LLScrollListCtrl.
00583         //
00584         // The LLScrollListCtrl owns its items and is responsible for deleting them
00585         // (except in the case that the addItem() call fails, in which case it is up
00586         // to the caller to delete the item)
00587 
00588         // returns FALSE if item faile to be added to list, does NOT delete 'item'
00589         BOOL                    addItem( LLScrollListItem* item, EAddPosition pos = ADD_BOTTOM );
00590         void                    selectPrevItem(BOOL extend_selection);
00591         void                    selectNextItem(BOOL extend_selection);
00592         void                    drawItems();
00593         void                    updateLineHeight();
00594         void                    reportInvalidInput();
00595         BOOL                    isRepeatedChars(const LLWString& string) const;
00596         void                    selectItem(LLScrollListItem* itemp, BOOL single_select = TRUE);
00597         void                    deselectItem(LLScrollListItem* itemp);
00598         void                    commitIfChanged();
00599         void                    setSorted(BOOL sorted);
00600 
00601 protected:
00602         S32                             mCurIndex;                      // For get[First/Next]Data
00603         S32                             mCurSelectedIndex;  // For get[First/Next]Selected
00604 
00605         S32                             mLineHeight;    // the max height of a single line
00606         S32                             mScrollLines;   // how many lines we've scrolled down
00607         S32                             mPageLines;             // max number of lines is it possible to see on the screen given mRect and mLineHeight
00608         S32                             mHeadingHeight; // the height of the column header buttons, if visible
00609         U32                             mMaxSelectable; 
00610         LLScrollbar*    mScrollbar;
00611         BOOL                    mAllowMultipleSelection;
00612         BOOL                    mAllowKeyboardMovement;
00613         BOOL                    mCommitOnKeyboardMovement;
00614         BOOL                    mCommitOnSelectionChange;
00615         BOOL                    mSelectionChanged;
00616         BOOL                    mNeedsScroll;
00617         BOOL                    mCanSelect;
00618         BOOL                    mDisplayColumnHeaders;
00619         BOOL                    mCollapseEmptyColumns;
00620         BOOL                    mIsPopup;
00621 
00622         typedef std::deque<LLScrollListItem *> item_list;
00623         item_list               mItemList;
00624 
00625         LLScrollListItem *mLastSelected;
00626 
00627         S32                             mMaxItemCount; 
00628 
00629         LLRect                  mItemListRect;
00630 
00631         S32             mColumnPadding;
00632 
00633         BOOL                    mBackgroundVisible;
00634         BOOL                    mDrawStripes;
00635 
00636         LLColor4                mBgWriteableColor;
00637         LLColor4                mBgReadOnlyColor;
00638         LLColor4                mBgSelectedColor;
00639         LLColor4                mBgStripeColor;
00640         LLColor4                mFgSelectedColor;
00641         LLColor4                mFgUnselectedColor;
00642         LLColor4                mFgDisabledColor;
00643         LLColor4                mHighlightedColor;
00644 
00645         S32                             mBorderThickness;
00646         void                    (*mOnDoubleClickCallback)(void* userdata);
00647         void                    (*mOnMaximumSelectCallback)(void* userdata );
00648         void                    (*mOnSortChangedCallback)(void* userdata);
00649 
00650         S32                             mHighlightedItem;
00651         LLViewBorder*   mBorder;
00652 
00653         LLWString               mSearchString;
00654         LLFrameTimer    mSearchTimer;
00655         
00656         LLString                mDefaultColumn;
00657 
00658         S32                             mSearchColumn;
00659         S32                             mNumDynamicWidthColumns;
00660         S32                             mTotalStaticColumnWidth;
00661 
00662         S32                             mSortColumn;
00663         BOOL                    mSortAscending;
00664         BOOL                    mSorted;
00665 
00666         std::map<LLString, LLScrollListColumn> mColumns;
00667         std::vector<LLScrollListColumn*> mColumnsIndexed;
00668 
00669         BOOL                    mDirty;
00670         S32                             mOriginalSelection;
00671 
00672 public:
00673         // HACK:  Did we draw one selected item this frame?
00674         BOOL mDrewSelected;
00675 };
00676 
00677 const BOOL MULTIPLE_SELECT_YES = TRUE;
00678 const BOOL MULTIPLE_SELECT_NO = FALSE;
00679 
00680 const BOOL SHOW_BORDER_YES = TRUE;
00681 const BOOL SHOW_BORDER_NO = FALSE;
00682 
00683 #endif  // LL_SCROLLLISTCTRL_H

Generated on Thu Jul 1 06:09:06 2010 for Second Life Viewer by  doxygen 1.4.7