diff options
author | Jacek Antonelli | 2008-08-15 23:44:46 -0500 |
---|---|---|
committer | Jacek Antonelli | 2008-08-15 23:44:46 -0500 |
commit | 38d6d37f2d982fa959e9e8a4a3f7e1ccfad7b5d4 (patch) | |
tree | adca584755d22ca041a2dbfc35d4eca01f70b32c /linden/indra/llui/lltabcontainer.h | |
parent | README.txt (diff) | |
download | meta-impy-38d6d37f2d982fa959e9e8a4a3f7e1ccfad7b5d4.zip meta-impy-38d6d37f2d982fa959e9e8a4a3f7e1ccfad7b5d4.tar.gz meta-impy-38d6d37f2d982fa959e9e8a4a3f7e1ccfad7b5d4.tar.bz2 meta-impy-38d6d37f2d982fa959e9e8a4a3f7e1ccfad7b5d4.tar.xz |
Second Life viewer sources 1.13.2.12
Diffstat (limited to 'linden/indra/llui/lltabcontainer.h')
-rw-r--r-- | linden/indra/llui/lltabcontainer.h | 261 |
1 files changed, 261 insertions, 0 deletions
diff --git a/linden/indra/llui/lltabcontainer.h b/linden/indra/llui/lltabcontainer.h new file mode 100644 index 0000000..c3146a1 --- /dev/null +++ b/linden/indra/llui/lltabcontainer.h | |||
@@ -0,0 +1,261 @@ | |||
1 | /** | ||
2 | * @file lltabcontainer.h | ||
3 | * @brief LLTabContainerCommon base class | ||
4 | * | ||
5 | * Copyright (c) 2001-2007, Linden Research, Inc. | ||
6 | * | ||
7 | * 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 | * ("GPL"), unless you have obtained a separate licensing agreement | ||
10 | * ("Other License"), formally executed by you and Linden Lab. Terms of | ||
11 | * the GPL can be found in doc/GPL-license.txt in this distribution, or | ||
12 | * online at http://secondlife.com/developers/opensource/gplv2 | ||
13 | * | ||
14 | * There are special exceptions to the terms and conditions of the GPL as | ||
15 | * it is applied to this Source Code. View the full text of the exception | ||
16 | * in the file doc/FLOSS-exception.txt in this software distribution, or | ||
17 | * online at http://secondlife.com/developers/opensource/flossexception | ||
18 | * | ||
19 | * By copying, modifying or distributing this software, you acknowledge | ||
20 | * that you have read and understood your obligations described above, | ||
21 | * and agree to abide by those obligations. | ||
22 | * | ||
23 | * ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO | ||
24 | * WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY, | ||
25 | * COMPLETENESS OR PERFORMANCE. | ||
26 | */ | ||
27 | |||
28 | // Fear my script-fu! | ||
29 | |||
30 | #ifndef LL_TABCONTAINER_H | ||
31 | #define LL_TABCONTAINER_H | ||
32 | |||
33 | #include "llpanel.h" | ||
34 | #include "llframetimer.h" | ||
35 | |||
36 | class LLButton; | ||
37 | class LLTextBox; | ||
38 | |||
39 | |||
40 | class LLTabContainerCommon : public LLPanel | ||
41 | { | ||
42 | public: | ||
43 | enum TabPosition | ||
44 | { | ||
45 | TOP, | ||
46 | BOTTOM, | ||
47 | LEFT | ||
48 | }; | ||
49 | typedef enum e_insertion_point | ||
50 | { | ||
51 | START, | ||
52 | END, | ||
53 | RIGHT_OF_CURRENT | ||
54 | } eInsertionPoint; | ||
55 | |||
56 | LLTabContainerCommon( const LLString& name, | ||
57 | const LLRect& rect, | ||
58 | TabPosition pos, | ||
59 | void(*close_callback)(void*), void* callback_userdata, | ||
60 | BOOL bordered = TRUE); | ||
61 | |||
62 | LLTabContainerCommon( const LLString& name, | ||
63 | const LLString& rect_control, | ||
64 | TabPosition pos, | ||
65 | void(*close_callback)(void*), void* callback_userdata, | ||
66 | BOOL bordered = TRUE); | ||
67 | |||
68 | virtual ~LLTabContainerCommon(); | ||
69 | |||
70 | virtual void initButtons() = 0; | ||
71 | |||
72 | virtual void setValue(const LLSD& value) { selectTab((S32) value.asInteger()); } | ||
73 | virtual EWidgetType getWidgetType() const { return WIDGET_TYPE_TAB_CONTAINER; } | ||
74 | virtual LLString getWidgetTag() const { return LL_TAB_CONTAINER_COMMON_TAG; } | ||
75 | |||
76 | virtual LLView* getChildByName(const LLString& name, BOOL recurse = FALSE) const; | ||
77 | |||
78 | static LLView* fromXML(LLXMLNodePtr node, LLView *parent, LLUICtrlFactory *factory); | ||
79 | |||
80 | virtual void addTabPanel(LLPanel* child, | ||
81 | const LLString& label, | ||
82 | BOOL select = FALSE, | ||
83 | void (*on_tab_clicked)(void*, bool) = NULL, | ||
84 | void* userdata = NULL, | ||
85 | S32 indent = 0, | ||
86 | BOOL placeholder = FALSE, | ||
87 | eInsertionPoint insertion_point = END) = 0; | ||
88 | virtual void addPlaceholder(LLPanel* child, const LLString& label); | ||
89 | |||
90 | virtual void enableTabButton(S32 which, BOOL enable); | ||
91 | |||
92 | virtual void removeTabPanel( LLPanel* child ); | ||
93 | virtual void deleteAllTabs(); | ||
94 | virtual LLPanel* getCurrentPanel(); | ||
95 | virtual S32 getCurrentPanelIndex(); | ||
96 | virtual S32 getTabCount(); | ||
97 | virtual S32 getPanelIndexByTitle(const LLString& title); | ||
98 | virtual LLPanel* getPanelByIndex(S32 index); | ||
99 | virtual LLPanel* getPanelByName(const LLString& name); | ||
100 | virtual S32 getIndexForPanel(LLPanel* panel); | ||
101 | |||
102 | virtual void setCurrentTabName(const LLString& name); | ||
103 | |||
104 | |||
105 | virtual void selectFirstTab(); | ||
106 | virtual void selectLastTab(); | ||
107 | virtual BOOL selectTabPanel( LLPanel* child ); | ||
108 | virtual BOOL selectTab(S32 which) = 0; | ||
109 | virtual BOOL selectTabByName(const LLString& title); | ||
110 | virtual void selectNextTab(); | ||
111 | virtual void selectPrevTab(); | ||
112 | |||
113 | BOOL getTabPanelFlashing(LLPanel* child); | ||
114 | void setTabPanelFlashing(LLPanel* child, BOOL state); | ||
115 | void setTitle( const LLString& title ); | ||
116 | const LLString getPanelTitle(S32 index); | ||
117 | |||
118 | virtual void setTopBorderHeight(S32 height); | ||
119 | |||
120 | virtual void setTabChangeCallback(LLPanel* tab, void (*on_tab_clicked)(void*,bool)); | ||
121 | virtual void setTabUserData(LLPanel* tab, void* userdata); | ||
122 | |||
123 | virtual void reshape(S32 width, S32 height, BOOL called_from_parent); | ||
124 | |||
125 | static void onCloseBtn(void* userdata); | ||
126 | static void onTabBtn(void* userdata); | ||
127 | static void onNextBtn(void* userdata); | ||
128 | static void onNextBtnHeld(void* userdata); | ||
129 | static void onPrevBtn(void* userdata); | ||
130 | static void onPrevBtnHeld(void* userdata); | ||
131 | |||
132 | virtual void setRightTabBtnOffset( S32 offset ) { } | ||
133 | virtual void setPanelTitle(S32 index, const LLString& title) { } | ||
134 | |||
135 | virtual TabPosition getTabPosition() { return mTabPosition; } | ||
136 | |||
137 | |||
138 | protected: | ||
139 | // Structure used to map tab buttons to and from tab panels | ||
140 | struct LLTabTuple | ||
141 | { | ||
142 | LLTabTuple( LLTabContainerCommon* c, LLPanel* p, LLButton* b, | ||
143 | void (*cb)(void*,bool), void* userdata, LLTextBox* placeholder = NULL ) | ||
144 | : | ||
145 | mTabContainer(c), | ||
146 | mTabPanel(p), | ||
147 | mButton(b), | ||
148 | mOnChangeCallback( cb ), | ||
149 | mUserData( userdata ), | ||
150 | mOldState(FALSE), | ||
151 | mPlaceholderText(placeholder) | ||
152 | {} | ||
153 | |||
154 | LLTabContainerCommon* mTabContainer; | ||
155 | LLPanel* mTabPanel; | ||
156 | LLButton* mButton; | ||
157 | void (*mOnChangeCallback)(void*, bool); | ||
158 | void* mUserData; | ||
159 | BOOL mOldState; | ||
160 | LLTextBox* mPlaceholderText; | ||
161 | }; | ||
162 | |||
163 | typedef std::vector<LLTabTuple*> tuple_list_t; | ||
164 | tuple_list_t mTabList; | ||
165 | S32 mCurrentTabIdx; | ||
166 | |||
167 | BOOL mScrolled; | ||
168 | LLFrameTimer mScrollTimer; | ||
169 | S32 mScrollPos; | ||
170 | S32 mScrollPosPixels; | ||
171 | S32 mMaxScrollPos; | ||
172 | |||
173 | void (*mCloseCallback)(void*); | ||
174 | void* mCallbackUserdata; | ||
175 | |||
176 | LLTextBox* mTitleBox; | ||
177 | |||
178 | S32 mTopBorderHeight; | ||
179 | TabPosition mTabPosition; | ||
180 | |||
181 | protected: | ||
182 | void scrollPrev(); | ||
183 | void scrollNext(); | ||
184 | |||
185 | virtual void updateMaxScrollPos() = 0; | ||
186 | virtual void commitHoveredButton(S32 x, S32 y) = 0; | ||
187 | LLTabTuple* getTabByPanel(LLPanel* child); | ||
188 | void insertTuple(LLTabTuple * tuple, eInsertionPoint insertion_point); | ||
189 | }; | ||
190 | |||
191 | class LLTabContainer : public LLTabContainerCommon | ||
192 | { | ||
193 | public: | ||
194 | LLTabContainer( const LLString& name, const LLRect& rect, TabPosition pos, | ||
195 | void(*close_callback)(void*), void* callback_userdata, | ||
196 | const LLString& title=LLString::null, BOOL bordered = TRUE ); | ||
197 | |||
198 | LLTabContainer( const LLString& name, const LLString& rect_control, TabPosition pos, | ||
199 | void(*close_callback)(void*), void* callback_userdata, | ||
200 | const LLString& title=LLString::null, BOOL bordered = TRUE ); | ||
201 | |||
202 | ~LLTabContainer(); | ||
203 | |||
204 | /*virtual*/ void initButtons(); | ||
205 | |||
206 | /*virtual*/ void draw(); | ||
207 | |||
208 | /*virtual*/ void addTabPanel(LLPanel* child, | ||
209 | const LLString& label, | ||
210 | BOOL select = FALSE, | ||
211 | void (*on_tab_clicked)(void*, bool) = NULL, | ||
212 | void* userdata = NULL, | ||
213 | S32 indent = 0, | ||
214 | BOOL placeholder = FALSE, | ||
215 | eInsertionPoint insertion_point = END); | ||
216 | |||
217 | /*virtual*/ BOOL selectTab(S32 which); | ||
218 | /*virtual*/ void removeTabPanel( LLPanel* child ); | ||
219 | |||
220 | /*virtual*/ void setPanelTitle(S32 index, const LLString& title); | ||
221 | |||
222 | /*virtual*/ void setRightTabBtnOffset( S32 offset ); | ||
223 | |||
224 | /*virtual*/ void setMinTabWidth(S32 width); | ||
225 | /*virtual*/ void setMaxTabWidth(S32 width); | ||
226 | |||
227 | /*virtual*/ S32 getMinTabWidth() const; | ||
228 | /*virtual*/ S32 getMaxTabWidth() const; | ||
229 | |||
230 | /*virtual*/ BOOL handleMouseDown( S32 x, S32 y, MASK mask ); | ||
231 | /*virtual*/ BOOL handleHover( S32 x, S32 y, MASK mask ); | ||
232 | /*virtual*/ BOOL handleMouseUp( S32 x, S32 y, MASK mask ); | ||
233 | /*virtual*/ BOOL handleToolTip(S32 x, S32 y, LLString& msg, LLRect* sticky_rect ); | ||
234 | /*virtual*/ BOOL handleKeyHere(KEY key, MASK mask, BOOL called_from_parent); | ||
235 | /*virtual*/ BOOL handleDragAndDrop(S32 x, S32 y, MASK mask, BOOL drop, | ||
236 | EDragAndDropType type, void* cargo_data, | ||
237 | EAcceptance* accept, LLString& tooltip); | ||
238 | |||
239 | virtual LLXMLNodePtr getXML(bool save_children = true) const; | ||
240 | |||
241 | |||
242 | protected: | ||
243 | |||
244 | LLButton* mLeftArrowBtn; | ||
245 | LLButton* mRightArrowBtn; | ||
246 | |||
247 | S32 mRightTabBtnOffset; // Extra room to the right of the tab buttons. | ||
248 | |||
249 | protected: | ||
250 | virtual void updateMaxScrollPos(); | ||
251 | virtual void commitHoveredButton(S32 x, S32 y); | ||
252 | |||
253 | S32 mMinTabWidth; | ||
254 | S32 mMaxTabWidth; | ||
255 | S32 mTotalTabWidth; | ||
256 | }; | ||
257 | |||
258 | const S32 TABCNTR_CLOSE_BTN_SIZE = 16; | ||
259 | const S32 TABCNTR_HEADER_HEIGHT = LLPANEL_BORDER_WIDTH + TABCNTR_CLOSE_BTN_SIZE; | ||
260 | |||
261 | #endif // LL_TABCONTAINER_H | ||