llscrolllistctrl.h

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

Generated on Fri May 16 08:32:57 2008 for SecondLife by  doxygen 1.5.5