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/llscrolllistctrl.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/llscrolllistctrl.h')
-rw-r--r-- | linden/indra/llui/llscrolllistctrl.h | 554 |
1 files changed, 554 insertions, 0 deletions
diff --git a/linden/indra/llui/llscrolllistctrl.h b/linden/indra/llui/llscrolllistctrl.h new file mode 100644 index 0000000..d097cb5 --- /dev/null +++ b/linden/indra/llui/llscrolllistctrl.h | |||
@@ -0,0 +1,554 @@ | |||
1 | /** | ||
2 | * @file llscrolllistctrl.h | ||
3 | * @brief LLScrollListCtrl 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 | #ifndef LL_SCROLLLISTCTRL_H | ||
29 | #define LL_SCROLLLISTCTRL_H | ||
30 | |||
31 | #include <vector> | ||
32 | #include <deque> | ||
33 | |||
34 | #include "lluictrl.h" | ||
35 | #include "llctrlselectioninterface.h" | ||
36 | #include "lldarray.h" | ||
37 | #include "llfontgl.h" | ||
38 | #include "llui.h" | ||
39 | #include "llstring.h" | ||
40 | #include "llimagegl.h" | ||
41 | #include "lleditmenuhandler.h" | ||
42 | #include "llviewborder.h" | ||
43 | #include "llframetimer.h" | ||
44 | #include "llcheckboxctrl.h" | ||
45 | |||
46 | class LLScrollbar; | ||
47 | class LLScrollListCtrl; | ||
48 | |||
49 | class LLScrollListCell | ||
50 | { | ||
51 | public: | ||
52 | virtual ~LLScrollListCell() {}; | ||
53 | virtual void drawToWidth(S32 width, const LLColor4& color, const LLColor4& highlight_color) const = 0; // truncate to given width, if possible | ||
54 | virtual S32 getWidth() const = 0; | ||
55 | virtual S32 getHeight() const = 0; | ||
56 | virtual const LLString& getText() const { return LLString::null; } | ||
57 | virtual const LLString& getTextLower() const { return LLString::null; } | ||
58 | virtual const BOOL getVisible() const { return TRUE; } | ||
59 | virtual void setWidth(S32 width) = 0; | ||
60 | virtual void highlightText(S32 num_chars) {} | ||
61 | |||
62 | virtual BOOL handleClick() { return FALSE; } | ||
63 | virtual void setEnabled(BOOL enable) { } | ||
64 | }; | ||
65 | |||
66 | class LLScrollListText : public LLScrollListCell | ||
67 | { | ||
68 | static U32 sCount; | ||
69 | public: | ||
70 | LLScrollListText( const LLString& text, const LLFontGL* font, S32 width = 0, U8 font_style = LLFontGL::NORMAL, LLColor4& color = LLColor4::black, BOOL use_color = FALSE, BOOL visible = TRUE); | ||
71 | /*virtual*/ ~LLScrollListText(); | ||
72 | |||
73 | virtual void drawToWidth(S32 width, const LLColor4& color, const LLColor4& highlight_color) const; | ||
74 | virtual S32 getWidth() const { return mWidth; } | ||
75 | virtual void setWidth(S32 width) { mWidth = width; } | ||
76 | virtual S32 getHeight() const { return llround(mFont->getLineHeight()); } | ||
77 | virtual const LLString& getText() const { return mText.getString(); } | ||
78 | virtual const BOOL getVisible() const { return mVisible; } | ||
79 | virtual void highlightText(S32 num_chars) {mHighlightChars = num_chars;} | ||
80 | void setText(const LLString& text); | ||
81 | |||
82 | private: | ||
83 | LLUIString mText; | ||
84 | const LLFontGL* mFont; | ||
85 | LLColor4* mColor; | ||
86 | const U8 mFontStyle; | ||
87 | S32 mWidth; | ||
88 | S32 mEllipsisWidth; // in pixels, of "..." | ||
89 | BOOL mVisible; | ||
90 | S32 mHighlightChars; | ||
91 | |||
92 | LLPointer<LLImageGL> mRoundedRectImage; | ||
93 | }; | ||
94 | |||
95 | class LLScrollListIcon : public LLScrollListCell | ||
96 | { | ||
97 | public: | ||
98 | LLScrollListIcon( LLImageGL* icon, S32 width = 0, LLUUID image_id = LLUUID::null); | ||
99 | /*virtual*/ ~LLScrollListIcon(); | ||
100 | virtual void drawToWidth(S32 width, const LLColor4& color, const LLColor4& highlight_color) const { gl_draw_image(0, 0, mIcon); } | ||
101 | virtual S32 getWidth() const { return mWidth; } | ||
102 | virtual S32 getHeight() const { return mIcon->getHeight(); } | ||
103 | virtual const LLString& getText() const { return mImageUUID; } | ||
104 | virtual const LLString& getTextLower() const { return mImageUUID; } | ||
105 | virtual void setWidth(S32 width) { mWidth = width; } | ||
106 | |||
107 | private: | ||
108 | LLPointer<LLImageGL> mIcon; | ||
109 | LLString mImageUUID; | ||
110 | S32 mWidth; | ||
111 | }; | ||
112 | |||
113 | class LLScrollListCheck : public LLScrollListCell | ||
114 | { | ||
115 | public: | ||
116 | LLScrollListCheck( LLCheckBoxCtrl* check_box, S32 width = 0); | ||
117 | /*virtual*/ ~LLScrollListCheck(); | ||
118 | virtual void drawToWidth(S32 width, const LLColor4& color, const LLColor4& highlight_color) const; | ||
119 | virtual S32 getWidth() const { return mWidth; } | ||
120 | virtual S32 getHeight() const { return 0; } | ||
121 | virtual void setWidth(S32 width) { mWidth = width; } | ||
122 | |||
123 | virtual BOOL handleClick(); | ||
124 | virtual void setEnabled(BOOL enable) { if (mCheckBox) mCheckBox->setEnabled(enable); } | ||
125 | |||
126 | LLCheckBoxCtrl* getCheckBox() { return mCheckBox; } | ||
127 | |||
128 | private: | ||
129 | LLCheckBoxCtrl* mCheckBox; | ||
130 | S32 mWidth; | ||
131 | }; | ||
132 | |||
133 | class LLScrollListColumn | ||
134 | { | ||
135 | public: | ||
136 | // Default constructor | ||
137 | LLScrollListColumn() : mName(""), mSortingColumn(""), mLabel(""), mWidth(-1), mRelWidth(-1.0), mDynamicWidth(FALSE), mIndex(-1), mParentCtrl(NULL), mButton(NULL) { } | ||
138 | |||
139 | LLScrollListColumn(LLString name, LLString label, S32 width, F32 relwidth) | ||
140 | : mName(name), mSortingColumn(name), mLabel(label), mWidth(width), mRelWidth(relwidth), mDynamicWidth(FALSE), mIndex(-1), mParentCtrl(NULL), mButton(NULL) { } | ||
141 | |||
142 | LLScrollListColumn(const LLSD &sd) | ||
143 | { | ||
144 | mName = sd.get("name").asString(); | ||
145 | mSortingColumn = mName; | ||
146 | if (sd.has("sort")) | ||
147 | { | ||
148 | mSortingColumn = sd.get("sort").asString(); | ||
149 | } | ||
150 | mLabel = sd.get("label").asString(); | ||
151 | if (sd.has("relwidth") && (F32)sd.get("relwidth").asReal() > 0) | ||
152 | { | ||
153 | mRelWidth = (F32)sd.get("relwidth").asReal(); | ||
154 | if (mRelWidth < 0) mRelWidth = 0; | ||
155 | if (mRelWidth > 1) mRelWidth = 1; | ||
156 | mDynamicWidth = FALSE; | ||
157 | mWidth = 0; | ||
158 | } | ||
159 | else if(sd.has("dynamicwidth") && (BOOL)sd.get("dynamicwidth").asBoolean() == TRUE) | ||
160 | { | ||
161 | mDynamicWidth = TRUE; | ||
162 | mRelWidth = -1; | ||
163 | mWidth = 0; | ||
164 | } | ||
165 | else | ||
166 | { | ||
167 | mWidth = sd.get("width").asInteger(); | ||
168 | mDynamicWidth = FALSE; | ||
169 | mRelWidth = -1; | ||
170 | } | ||
171 | mIndex = -1; | ||
172 | mParentCtrl = NULL; | ||
173 | mButton = NULL; | ||
174 | } | ||
175 | |||
176 | LLString mName; | ||
177 | LLString mSortingColumn; | ||
178 | LLString mLabel; | ||
179 | S32 mWidth; | ||
180 | F32 mRelWidth; | ||
181 | BOOL mDynamicWidth; | ||
182 | S32 mIndex; | ||
183 | LLScrollListCtrl *mParentCtrl; | ||
184 | LLButton *mButton; | ||
185 | }; | ||
186 | |||
187 | class LLScrollListItem | ||
188 | { | ||
189 | public: | ||
190 | LLScrollListItem( BOOL enabled = TRUE, void* userdata = NULL, const LLUUID& uuid = LLUUID::null ) | ||
191 | : mSelected(FALSE), mEnabled( enabled ), mUserdata( userdata ), mItemValue( uuid ), mColumns() {} | ||
192 | LLScrollListItem( LLSD item_value, void* userdata = NULL ) | ||
193 | : mSelected(FALSE), mEnabled( TRUE ), mUserdata( userdata ), mItemValue( item_value ), mColumns() {} | ||
194 | |||
195 | virtual ~LLScrollListItem(); | ||
196 | |||
197 | void setSelected( BOOL b ) { mSelected = b; } | ||
198 | BOOL getSelected() const { return mSelected; } | ||
199 | |||
200 | void setEnabled( BOOL b ); | ||
201 | BOOL getEnabled() const { return mEnabled; } | ||
202 | |||
203 | void setUserdata( void* userdata ) { mUserdata = userdata; } | ||
204 | void* getUserdata() const { return mUserdata; } | ||
205 | |||
206 | LLUUID getUUID() const { return mItemValue.asUUID(); } | ||
207 | LLSD getValue() const { return mItemValue; } | ||
208 | |||
209 | // If width = 0, just use the width of the text. Otherwise override with | ||
210 | // specified width in pixels. | ||
211 | void addColumn( const LLString& text, const LLFontGL* font, S32 width = 0 , U8 font_style = LLFontGL::NORMAL, BOOL visible = TRUE) | ||
212 | { mColumns.push_back( new LLScrollListText(text, font, width, font_style, LLColor4::black, FALSE, visible) ); } | ||
213 | |||
214 | void addColumn( LLImageGL* icon, S32 width = 0 ) | ||
215 | { mColumns.push_back( new LLScrollListIcon(icon, width) ); } | ||
216 | |||
217 | void addColumn( LLCheckBoxCtrl* check, S32 width = 0 ) | ||
218 | { mColumns.push_back( new LLScrollListCheck(check,width) ); } | ||
219 | |||
220 | void setNumColumns(S32 columns); | ||
221 | |||
222 | void setColumn( S32 column, LLScrollListCell *cell ); | ||
223 | |||
224 | S32 getNumColumns() const { return mColumns.size(); } | ||
225 | |||
226 | LLScrollListCell *getColumn(const S32 i) const { if (i < (S32)mColumns.size()) { return mColumns[i]; } return NULL; } | ||
227 | |||
228 | virtual BOOL handleMouseDown(S32 x, S32 y, MASK mask); | ||
229 | |||
230 | LLString getContentsCSV(); | ||
231 | |||
232 | private: | ||
233 | BOOL mSelected; | ||
234 | BOOL mEnabled; | ||
235 | void* mUserdata; | ||
236 | LLSD mItemValue; | ||
237 | std::vector<LLScrollListCell *> mColumns; | ||
238 | }; | ||
239 | |||
240 | |||
241 | class LLScrollListCtrl : public LLUICtrl, public LLEditMenuHandler, | ||
242 | public LLCtrlListInterface, public LLCtrlScrollInterface | ||
243 | { | ||
244 | public: | ||
245 | LLScrollListCtrl( | ||
246 | const LLString& name, | ||
247 | const LLRect& rect, | ||
248 | void (*commit_callback)(LLUICtrl*, void*), | ||
249 | void* callback_userdata, | ||
250 | BOOL allow_multiple_selection, | ||
251 | BOOL draw_border = TRUE); | ||
252 | |||
253 | virtual ~LLScrollListCtrl(); | ||
254 | virtual EWidgetType getWidgetType() const { return WIDGET_TYPE_SCROLL_LIST; } | ||
255 | virtual LLString getWidgetTag() const { return LL_SCROLL_LIST_CTRL_TAG; } | ||
256 | virtual LLXMLNodePtr getXML(bool save_children = true) const; | ||
257 | void setScrollListParameters(LLXMLNodePtr node); | ||
258 | static LLView* fromXML(LLXMLNodePtr node, LLView *parent, LLUICtrlFactory *factory); | ||
259 | |||
260 | S32 isEmpty() const; | ||
261 | |||
262 | void deleteAllItems() { clearRows(); } | ||
263 | |||
264 | // Sets an array of column descriptors | ||
265 | void setColumnHeadings(LLSD headings); | ||
266 | // Numerical based sort by column function (used by LLComboBox) | ||
267 | void sortByColumn(U32 column, BOOL ascending); | ||
268 | |||
269 | // LLCtrlListInterface functions | ||
270 | virtual S32 getItemCount() const; | ||
271 | // Adds a single column descriptor: ["name" : string, "label" : string, "width" : integer, "relwidth" : integer ] | ||
272 | virtual void addColumn(const LLSD& column, EAddPosition pos = ADD_BOTTOM); | ||
273 | virtual void clearColumns(); | ||
274 | virtual void setColumnLabel(const LLString& column, const LLString& label); | ||
275 | // Adds a single element, from an array of: | ||
276 | // "columns" => [ "column" => column name, "value" => value, "type" => type, "font" => font, "font-style" => style ], "id" => uuid | ||
277 | // Creates missing columns automatically. | ||
278 | virtual LLScrollListItem* addElement(const LLSD& value, EAddPosition pos = ADD_BOTTOM, void* userdata = NULL); | ||
279 | // Simple add element. Takes a single array of: | ||
280 | // [ "value" => value, "font" => font, "font-style" => style ] | ||
281 | virtual LLScrollListItem* addSimpleElement(const LLString& value, EAddPosition pos = ADD_BOTTOM, const LLSD& id = LLSD()); | ||
282 | virtual void clearRows(); // clears all elements | ||
283 | virtual void sortByColumn(LLString name, BOOL ascending); | ||
284 | |||
285 | // These functions take and return an array of arrays of elements, as above | ||
286 | virtual void setValue(const LLSD& value ); | ||
287 | virtual LLSD getValue() const; | ||
288 | |||
289 | LLCtrlSelectionInterface* getSelectionInterface() { return (LLCtrlSelectionInterface*)this; } | ||
290 | LLCtrlListInterface* getListInterface() { return (LLCtrlListInterface*)this; } | ||
291 | LLCtrlScrollInterface* getScrollInterface() { return (LLCtrlScrollInterface*)this; } | ||
292 | |||
293 | // DEPRECATED: Use setSelectedByValue() below. | ||
294 | BOOL setCurrentByID( const LLUUID& id ) { return selectByID(id); } | ||
295 | virtual LLUUID getCurrentID() { return getStringUUIDSelectedItem(); } | ||
296 | |||
297 | BOOL operateOnSelection(EOperation op); | ||
298 | BOOL operateOnAll(EOperation op); | ||
299 | |||
300 | // returns FALSE if unable to set the max count so low | ||
301 | BOOL setMaxItemCount(S32 max_count); | ||
302 | |||
303 | BOOL selectByID( const LLUUID& id ); // FALSE if item not found | ||
304 | |||
305 | // Match item by value.asString(), which should work for string, integer, uuid. | ||
306 | // Returns FALSE if not found. | ||
307 | BOOL setSelectedByValue(LLSD value, BOOL selected); | ||
308 | |||
309 | virtual BOOL isSelected(LLSD value); | ||
310 | |||
311 | BOOL selectFirstItem(); | ||
312 | BOOL selectNthItem( S32 index ); | ||
313 | |||
314 | void deleteSingleItem( S32 index ) ; | ||
315 | void deleteSelectedItems(); | ||
316 | void deselectAllItems(BOOL no_commit_on_change = FALSE); // by default, go ahead and commit on selection change | ||
317 | |||
318 | void highlightNthItem( S32 index ); | ||
319 | void setDoubleClickCallback( void (*cb)(void*) ) { mOnDoubleClickCallback = cb; } | ||
320 | void setMaxiumumSelectCallback( void (*cb)(void*) ) { mOnMaximumSelectCallback = cb; } | ||
321 | void setSortChangedCallback( void (*cb)(void*) ) { mOnSortChangedCallback = cb; } | ||
322 | |||
323 | void swapWithNext(S32 index); | ||
324 | void swapWithPrevious(S32 index); | ||
325 | |||
326 | void setCanSelect(BOOL can_select) { mCanSelect = can_select; } | ||
327 | virtual BOOL getCanSelect() const { return mCanSelect; } | ||
328 | |||
329 | S32 getItemIndex( LLScrollListItem* item ); | ||
330 | S32 getItemIndex( LLUUID& item_id ); | ||
331 | |||
332 | // "Simple" interface: use this when you're creating a list that contains only unique strings, only | ||
333 | // one of which can be selected at a time. | ||
334 | LLScrollListItem* addSimpleItem( const LLString& item_text, EAddPosition pos = ADD_BOTTOM, BOOL enabled = TRUE ); | ||
335 | // Add an item with an associated LLSD | ||
336 | LLScrollListItem* addSimpleItem(const LLString& item_text, LLSD sd, EAddPosition pos = ADD_BOTTOM, BOOL enabled = TRUE, S32 column_width = 0 ); | ||
337 | |||
338 | BOOL selectSimpleItem( const LLString& item, BOOL case_sensitive = TRUE ); // FALSE if item not found | ||
339 | BOOL selectSimpleItemByPrefix(const LLString& target, BOOL case_sensitive); | ||
340 | BOOL selectSimpleItemByPrefix(const LLWString& target, BOOL case_sensitive); | ||
341 | const LLString& getSimpleSelectedItem(S32 column = 0) const; | ||
342 | LLSD getSimpleSelectedValue(); | ||
343 | |||
344 | // DEPRECATED: Use LLSD versions of addSimpleItem() and getSimpleSelectedValue(). | ||
345 | // "StringUUID" interface: use this when you're creating a list that contains non-unique strings each of which | ||
346 | // has an associated, unique UUID, and only one of which can be selected at a time. | ||
347 | LLScrollListItem* addStringUUIDItem(const LLString& item_text, const LLUUID& id, EAddPosition pos = ADD_BOTTOM, BOOL enabled = TRUE, S32 column_width = 0); | ||
348 | LLUUID getStringUUIDSelectedItem(); | ||
349 | |||
350 | // "Full" interface: use this when you're creating a list that has one or more of the following: | ||
351 | // * contains icons | ||
352 | // * contains multiple columns | ||
353 | // * allows multiple selection | ||
354 | // * has items that are not guarenteed to have unique names | ||
355 | // * has additional per-item data (e.g. a UUID or void* userdata) | ||
356 | // | ||
357 | // To add items using this approach, create new LLScrollListItems and LLScrollListCells. Add the | ||
358 | // cells (column entries) to each item, and add the item to the LLScrollListCtrl. | ||
359 | // | ||
360 | // The LLScrollListCtrl owns its items and is responsible for deleting them | ||
361 | // (except in the case that the addItem() call fails, in which case it is up | ||
362 | // to the caller to delete the item) | ||
363 | |||
364 | // returns FALSE if item faile to be added to list, does NOT delete 'item' | ||
365 | // TomY TODO - Deprecate this API and remove it | ||
366 | BOOL addItem( LLScrollListItem* item, EAddPosition pos = ADD_BOTTOM ); | ||
367 | LLScrollListItem* getFirstSelected() const; | ||
368 | virtual S32 getFirstSelectedIndex(); | ||
369 | std::vector<LLScrollListItem*> getAllSelected() const; | ||
370 | |||
371 | LLScrollListItem* getLastSelectedItem() const { return mLastSelected; } | ||
372 | |||
373 | // iterate over all items | ||
374 | LLScrollListItem* getFirstData() const; | ||
375 | std::vector<LLScrollListItem*> getAllData() const; | ||
376 | |||
377 | void setAllowMultipleSelection(BOOL mult ) { mAllowMultipleSelection = mult; } | ||
378 | |||
379 | void setBgWriteableColor(const LLColor4 &c) { mBgWriteableColor = c; } | ||
380 | void setReadOnlyBgColor(const LLColor4 &c) { mBgReadOnlyColor = c; } | ||
381 | void setBgSelectedColor(const LLColor4 &c) { mBgSelectedColor = c; } | ||
382 | void setBgStripeColor(const LLColor4& c) { mBgStripeColor = c; } | ||
383 | void setFgSelectedColor(const LLColor4 &c) { mFgSelectedColor = c; } | ||
384 | void setFgUnselectedColor(const LLColor4 &c){ mFgUnselectedColor = c; } | ||
385 | void setHighlightedColor(const LLColor4 &c) { mHighlightedColor = c; } | ||
386 | void setFgDisableColor(const LLColor4 &c) { mFgDisabledColor = c; } | ||
387 | |||
388 | void setBackgroundVisible(BOOL b) { mBackgroundVisible = b; } | ||
389 | void setDrawStripes(BOOL b) { mDrawStripes = b; } | ||
390 | void setColumnPadding(const S32 c) { mColumnPadding = c; } | ||
391 | void setCommitOnKeyboardMovement(BOOL b) { mCommitOnKeyboardMovement = b; } | ||
392 | void setCommitOnSelectionChange(BOOL b) { mCommitOnSelectionChange = b; } | ||
393 | void setAllowKeyboardMovement(BOOL b) { mAllowKeyboardMovement = b; } | ||
394 | |||
395 | void setMaxSelectable(U32 max_selected) { mMaxSelectable = max_selected; } | ||
396 | S32 getMaxSelectable() { return mMaxSelectable; } | ||
397 | |||
398 | |||
399 | virtual S32 getScrollPos(); | ||
400 | virtual void setScrollPos( S32 pos ); | ||
401 | |||
402 | S32 getSearchColumn() { return mSearchColumn; } | ||
403 | void setSearchColumn(S32 column) { mSearchColumn = column; } | ||
404 | |||
405 | void clearSearchString() { mSearchString.clear(); } | ||
406 | |||
407 | // Overridden from LLView | ||
408 | virtual void draw(); | ||
409 | virtual BOOL handleMouseDown(S32 x, S32 y, MASK mask); | ||
410 | virtual BOOL handleDoubleClick(S32 x, S32 y, MASK mask); | ||
411 | virtual BOOL handleHover(S32 x, S32 y, MASK mask); | ||
412 | virtual BOOL handleKeyHere(KEY key, MASK mask, BOOL called_from_parent); | ||
413 | virtual BOOL handleUnicodeCharHere(llwchar uni_char, BOOL called_from_parent); | ||
414 | virtual BOOL handleScrollWheel(S32 x, S32 y, S32 clicks); | ||
415 | virtual void setEnabled(BOOL enabled); | ||
416 | virtual void setFocus( BOOL b ); | ||
417 | virtual void onFocusLost(); | ||
418 | |||
419 | virtual void reshape(S32 width, S32 height, BOOL called_from_parent = TRUE); | ||
420 | virtual void arrange(S32 max_width, S32 max_height); | ||
421 | virtual LLRect getRequiredRect(); | ||
422 | static BOOL rowPreceeds(LLScrollListItem *new_row, LLScrollListItem *test_row); | ||
423 | |||
424 | // Used "internally" by the scroll bar. | ||
425 | static void onScrollChange( S32 new_pos, LLScrollbar* src, void* userdata ); | ||
426 | |||
427 | static void onClickColumn(void *userdata); | ||
428 | |||
429 | void updateColumns(); | ||
430 | void updateColumnButtons(); | ||
431 | |||
432 | void setDisplayHeading(BOOL display); | ||
433 | void setHeadingHeight(S32 heading_height); | ||
434 | void setHeadingFont(const LLFontGL* heading_font); | ||
435 | void setCollapseEmptyColumns(BOOL collapse); | ||
436 | void setIsPopup(BOOL is_popup) { mIsPopup = is_popup; } | ||
437 | |||
438 | LLScrollListItem* hitItem(S32 x,S32 y); | ||
439 | virtual void scrollToShowSelected(); | ||
440 | |||
441 | // LLEditMenuHandler functions | ||
442 | virtual void copy(); | ||
443 | virtual BOOL canCopy(); | ||
444 | |||
445 | virtual void cut(); | ||
446 | virtual BOOL canCut(); | ||
447 | |||
448 | virtual void doDelete(); | ||
449 | virtual BOOL canDoDelete(); | ||
450 | |||
451 | virtual void selectAll(); | ||
452 | virtual BOOL canSelectAll(); | ||
453 | |||
454 | virtual void deselect(); | ||
455 | virtual BOOL canDeselect(); | ||
456 | |||
457 | void setNumDynamicColumns(int num) { mNumDynamicWidthColumns = num; } | ||
458 | void setTotalStaticColumnWidth(int width) { mTotalStaticColumnWidth = width; } | ||
459 | |||
460 | std::string getSortColumnName(); | ||
461 | BOOL getSortAscending() { return mSortAscending; } | ||
462 | |||
463 | S32 selectMultiple( LLDynamicArray<LLUUID> ids ); | ||
464 | |||
465 | protected: | ||
466 | void selectPrevItem(BOOL extend_selection); | ||
467 | void selectNextItem(BOOL extend_selection); | ||
468 | void drawItems(); | ||
469 | void updateLineHeight(); | ||
470 | void reportInvalidInput(); | ||
471 | BOOL isRepeatedChars(const LLWString& string) const; | ||
472 | void selectItem(LLScrollListItem* itemp, BOOL single_select = TRUE); | ||
473 | void deselectItem(LLScrollListItem* itemp); | ||
474 | void commitIfChanged(); | ||
475 | |||
476 | protected: | ||
477 | S32 mCurIndex; // For get[First/Next]Data | ||
478 | S32 mCurSelectedIndex; // For get[First/Next]Selected | ||
479 | |||
480 | S32 mLineHeight; // the max height of a single line | ||
481 | S32 mScrollLines; // how many lines we've scrolled down | ||
482 | S32 mPageLines; // max number of lines is it possible to see on the screen given mRect and mLineHeight | ||
483 | S32 mHeadingHeight; // the height of the column header buttons, if visible | ||
484 | U32 mMaxSelectable; | ||
485 | const LLFontGL* mHeadingFont; // the font to use for column head buttons, if visible | ||
486 | LLScrollbar* mScrollbar; | ||
487 | BOOL mAllowMultipleSelection; | ||
488 | BOOL mAllowKeyboardMovement; | ||
489 | BOOL mCommitOnKeyboardMovement; | ||
490 | BOOL mCommitOnSelectionChange; | ||
491 | BOOL mSelectionChanged; | ||
492 | BOOL mCanSelect; | ||
493 | BOOL mDisplayColumnButtons; | ||
494 | BOOL mCollapseEmptyColumns; | ||
495 | BOOL mIsPopup; | ||
496 | |||
497 | typedef std::deque<LLScrollListItem *> item_list; | ||
498 | item_list mItemList; | ||
499 | |||
500 | LLScrollListItem *mLastSelected; | ||
501 | |||
502 | S32 mMaxItemCount; | ||
503 | |||
504 | LLRect mItemListRect; | ||
505 | |||
506 | S32 mColumnPadding; | ||
507 | |||
508 | BOOL mBackgroundVisible; | ||
509 | BOOL mDrawStripes; | ||
510 | |||
511 | LLColor4 mBgWriteableColor; | ||
512 | LLColor4 mBgReadOnlyColor; | ||
513 | LLColor4 mBgSelectedColor; | ||
514 | LLColor4 mBgStripeColor; | ||
515 | LLColor4 mFgSelectedColor; | ||
516 | LLColor4 mFgUnselectedColor; | ||
517 | LLColor4 mFgDisabledColor; | ||
518 | LLColor4 mHighlightedColor; | ||
519 | |||
520 | S32 mBorderThickness; | ||
521 | void (*mOnDoubleClickCallback)(void* userdata); | ||
522 | void (*mOnMaximumSelectCallback)(void* userdata ); | ||
523 | void (*mOnSortChangedCallback)(void* userdata); | ||
524 | |||
525 | S32 mHighlightedItem; | ||
526 | LLViewBorder* mBorder; | ||
527 | |||
528 | LLWString mSearchString; | ||
529 | LLFrameTimer mSearchTimer; | ||
530 | |||
531 | LLString mDefaultColumn; | ||
532 | |||
533 | S32 mSearchColumn; | ||
534 | S32 mNumDynamicWidthColumns; | ||
535 | S32 mTotalStaticColumnWidth; | ||
536 | |||
537 | U32 mSortColumn; | ||
538 | BOOL mSortAscending; | ||
539 | |||
540 | std::map<LLString, LLScrollListColumn> mColumns; | ||
541 | std::vector<LLScrollListColumn*> mColumnsIndexed; | ||
542 | |||
543 | public: | ||
544 | // HACK: Did we draw one selected item this frame? | ||
545 | BOOL mDrewSelected; | ||
546 | }; | ||
547 | |||
548 | const BOOL MULTIPLE_SELECT_YES = TRUE; | ||
549 | const BOOL MULTIPLE_SELECT_NO = FALSE; | ||
550 | |||
551 | const BOOL SHOW_BORDER_YES = TRUE; | ||
552 | const BOOL SHOW_BORDER_NO = FALSE; | ||
553 | |||
554 | #endif // LL_SCROLLLISTCTRL_H | ||