00001
00032 #ifndef LL_TABCONTAINER_H
00033 #define LL_TABCONTAINER_H
00034
00035 #include "llpanel.h"
00036 #include "lltextbox.h"
00037 #include "llframetimer.h"
00038
00039 extern const S32 TABCNTR_HEADER_HEIGHT;
00040
00041 class LLTabContainer : public LLPanel
00042 {
00043 public:
00044 enum TabPosition
00045 {
00046 TOP,
00047 BOTTOM,
00048 LEFT
00049 };
00050 typedef enum e_insertion_point
00051 {
00052 START,
00053 END,
00054 LEFT_OF_CURRENT,
00055 RIGHT_OF_CURRENT
00056 } eInsertionPoint;
00057
00058 LLTabContainer( const LLString& name, const LLRect& rect, TabPosition pos,
00059 BOOL bordered, BOOL is_vertical);
00060
00061 ~LLTabContainer();
00062
00063
00064 void setValue(const LLSD& value);
00065
00066 void reshape(S32 width, S32 height, BOOL called_from_parent = TRUE);
00067 void draw();
00068 BOOL handleMouseDown( S32 x, S32 y, MASK mask );
00069 BOOL handleHover( S32 x, S32 y, MASK mask );
00070 BOOL handleMouseUp( S32 x, S32 y, MASK mask );
00071 BOOL handleToolTip(S32 x, S32 y, LLString& msg, LLRect* sticky_rect );
00072 BOOL handleKeyHere(KEY key, MASK mask);
00073 BOOL handleDragAndDrop(S32 x, S32 y, MASK mask, BOOL drop,
00074 EDragAndDropType type, void* cargo_data,
00075 EAcceptance* accept, LLString& tooltip);
00076 LLXMLNodePtr getXML(bool save_children = true) const;
00077 LLView* getChildView(const LLString& name, BOOL recurse = TRUE, BOOL create_if_missing = TRUE) const;
00078
00079 void addTabPanel(LLPanel* child,
00080 const LLString& label,
00081 BOOL select = FALSE,
00082 void (*on_tab_clicked)(void*, bool) = NULL,
00083 void* userdata = NULL,
00084 S32 indent = 0,
00085 BOOL placeholder = FALSE,
00086 eInsertionPoint insertion_point = END);
00087 void addPlaceholder(LLPanel* child, const LLString& label);
00088 void removeTabPanel( LLPanel* child );
00089 void lockTabs(S32 num_tabs = 0);
00090 void unlockTabs();
00091 S32 getNumLockedTabs() { return mLockedTabCount; }
00092 void enableTabButton(S32 which, BOOL enable);
00093 void deleteAllTabs();
00094 LLPanel* getCurrentPanel();
00095 S32 getCurrentPanelIndex();
00096 S32 getTabCount();
00097 LLPanel* getPanelByIndex(S32 index);
00098 S32 getIndexForPanel(LLPanel* panel);
00099 S32 getPanelIndexByTitle(const LLString& title);
00100 LLPanel* getPanelByName(const LLString& name);
00101 void setCurrentTabName(const LLString& name);
00102
00103 void selectFirstTab();
00104 void selectLastTab();
00105 void selectNextTab();
00106 void selectPrevTab();
00107 BOOL selectTabPanel( LLPanel* child );
00108 BOOL selectTab(S32 which);
00109 BOOL selectTabByName(const LLString& title);
00110
00111 BOOL getTabPanelFlashing(LLPanel* child);
00112 void setTabPanelFlashing(LLPanel* child, BOOL state);
00113 void setTabImage(LLPanel* child, std::string img_name, const LLColor4& color = LLColor4::white);
00114 void setTitle( const LLString& title );
00115 const LLString getPanelTitle(S32 index);
00116
00117 void setTopBorderHeight(S32 height);
00118 S32 getTopBorderHeight() const;
00119
00120 void setTabChangeCallback(LLPanel* tab, void (*on_tab_clicked)(void*,bool));
00121 void setTabUserData(LLPanel* tab, void* userdata);
00122
00123 void setRightTabBtnOffset( S32 offset );
00124 void setPanelTitle(S32 index, const LLString& title);
00125
00126 TabPosition getTabPosition() const { return mTabPosition; }
00127 void setMinTabWidth(S32 width) { mMinTabWidth = width; }
00128 void setMaxTabWidth(S32 width) { mMaxTabWidth = width; }
00129 S32 getMinTabWidth() const { return mMinTabWidth; }
00130 S32 getMaxTabWidth() const { return mMaxTabWidth; }
00131
00132 void startDragAndDropDelayTimer() { mDragAndDropDelayTimer.start(); }
00133
00134 static void onCloseBtn(void* userdata);
00135 static void onTabBtn(void* userdata);
00136 static void onNextBtn(void* userdata);
00137 static void onNextBtnHeld(void* userdata);
00138 static void onPrevBtn(void* userdata);
00139 static void onPrevBtnHeld(void* userdata);
00140 static void onJumpFirstBtn( void* userdata );
00141 static void onJumpLastBtn( void* userdata );
00142
00143 static LLView* fromXML(LLXMLNodePtr node, LLView *parent, LLUICtrlFactory *factory);
00144
00145 private:
00146
00147 struct LLTabTuple
00148 {
00149 LLTabTuple( LLTabContainer* c, LLPanel* p, LLButton* b,
00150 void (*cb)(void*,bool), void* userdata, LLTextBox* placeholder = NULL )
00151 :
00152 mTabContainer(c),
00153 mTabPanel(p),
00154 mButton(b),
00155 mOnChangeCallback( cb ),
00156 mUserData( userdata ),
00157 mOldState(FALSE),
00158 mPlaceholderText(placeholder),
00159 mPadding(0)
00160 {}
00161
00162 LLTabContainer* mTabContainer;
00163 LLPanel* mTabPanel;
00164 LLButton* mButton;
00165 void (*mOnChangeCallback)(void*, bool);
00166 void* mUserData;
00167 BOOL mOldState;
00168 LLTextBox* mPlaceholderText;
00169 S32 mPadding;
00170 };
00171
00172 void initButtons();
00173
00174 LLTabTuple* getTab(S32 index) { return mTabList[index]; }
00175 LLTabTuple* getTabByPanel(LLPanel* child);
00176 void insertTuple(LLTabTuple * tuple, eInsertionPoint insertion_point);
00177
00178 S32 getScrollPos() const { return mScrollPos; }
00179 void setScrollPos(S32 pos) { mScrollPos = pos; }
00180 S32 getMaxScrollPos() const { return mMaxScrollPos; }
00181 void setMaxScrollPos(S32 pos) { mMaxScrollPos = pos; }
00182 S32 getScrollPosPixels() const { return mScrollPosPixels; }
00183 void setScrollPosPixels(S32 pixels) { mScrollPosPixels = pixels; }
00184
00185 void setTabsHidden(BOOL hidden) { mTabsHidden = hidden; }
00186 BOOL getTabsHidden() const { return mTabsHidden; }
00187
00188 void setCurrentPanelIndex(S32 index) { mCurrentTabIdx = index; }
00189
00190 void scrollPrev() { mScrollPos = llmax(0, mScrollPos-1); }
00191 void scrollNext() { mScrollPos = llmin(mScrollPos+1, mMaxScrollPos); }
00192
00193 void updateMaxScrollPos();
00194 void commitHoveredButton(S32 x, S32 y);
00195
00196
00197
00198 typedef std::vector<LLTabTuple*> tuple_list_t;
00199 tuple_list_t mTabList;
00200
00201 S32 mCurrentTabIdx;
00202 BOOL mTabsHidden;
00203
00204 BOOL mScrolled;
00205 LLFrameTimer mScrollTimer;
00206 S32 mScrollPos;
00207 S32 mScrollPosPixels;
00208 S32 mMaxScrollPos;
00209
00210 void (*mCloseCallback)(void*);
00211 void* mCallbackUserdata;
00212
00213 LLTextBox* mTitleBox;
00214
00215 S32 mTopBorderHeight;
00216 TabPosition mTabPosition;
00217 S32 mLockedTabCount;
00218 S32 mMinTabWidth;
00219 LLButton* mPrevArrowBtn;
00220 LLButton* mNextArrowBtn;
00221
00222 BOOL mIsVertical;
00223
00224
00225 LLButton* mJumpPrevArrowBtn;
00226 LLButton* mJumpNextArrowBtn;
00227
00228 S32 mRightTabBtnOffset;
00229
00230 S32 mMaxTabWidth;
00231 S32 mTotalTabWidth;
00232
00233 LLFrameTimer mDragAndDropDelayTimer;
00234 };
00235
00236
00237 #endif // LL_TABCONTAINER_H