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/llcombobox.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/llcombobox.h')
-rw-r--r-- | linden/indra/llui/llcombobox.h | 197 |
1 files changed, 197 insertions, 0 deletions
diff --git a/linden/indra/llui/llcombobox.h b/linden/indra/llui/llcombobox.h new file mode 100644 index 0000000..b1dd468 --- /dev/null +++ b/linden/indra/llui/llcombobox.h | |||
@@ -0,0 +1,197 @@ | |||
1 | /** | ||
2 | * @file llcombobox.h | ||
3 | * @brief LLComboBox 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 | // A control that displays the name of the chosen item, which when clicked | ||
29 | // shows a scrolling box of choices. | ||
30 | |||
31 | #ifndef LL_LLCOMBOBOX_H | ||
32 | #define LL_LLCOMBOBOX_H | ||
33 | |||
34 | #include "llbutton.h" | ||
35 | #include "lluictrl.h" | ||
36 | #include "llctrlselectioninterface.h" | ||
37 | #include "llimagegl.h" | ||
38 | #include "llrect.h" | ||
39 | |||
40 | // Classes | ||
41 | |||
42 | class LLFontGL; | ||
43 | class LLButton; | ||
44 | class LLSquareButton; | ||
45 | class LLScrollListCtrl; | ||
46 | class LLLineEditor; | ||
47 | class LLViewBorder; | ||
48 | |||
49 | extern S32 LLCOMBOBOX_HEIGHT; | ||
50 | extern S32 LLCOMBOBOX_WIDTH; | ||
51 | |||
52 | class LLComboBox | ||
53 | : public LLUICtrl, public LLCtrlListInterface | ||
54 | { | ||
55 | public: | ||
56 | LLComboBox( | ||
57 | const LLString& name, | ||
58 | const LLRect &rect, | ||
59 | const LLString& label, | ||
60 | void (*commit_callback)(LLUICtrl*, void*) = NULL, | ||
61 | void *callback_userdata = NULL, | ||
62 | S32 list_width = 0 | ||
63 | ); | ||
64 | virtual ~LLComboBox(); | ||
65 | |||
66 | // LLView interface | ||
67 | virtual EWidgetType getWidgetType() const { return WIDGET_TYPE_COMBO_BOX; } | ||
68 | virtual LLString getWidgetTag() const { return LL_COMBO_BOX_TAG; } | ||
69 | virtual LLXMLNodePtr getXML(bool save_children = true) const; | ||
70 | static LLView* fromXML(LLXMLNodePtr node, LLView *parent, LLUICtrlFactory *factory); | ||
71 | |||
72 | virtual void draw(); | ||
73 | virtual void onFocusLost(); | ||
74 | |||
75 | virtual void setEnabled(BOOL enabled); | ||
76 | |||
77 | virtual BOOL handleToolTip(S32 x, S32 y, LLString& msg, LLRect* sticky_rect); | ||
78 | virtual BOOL handleKeyHere(KEY key, MASK mask, BOOL called_from_parent); | ||
79 | virtual BOOL handleUnicodeCharHere(llwchar uni_char, BOOL called_from_parent); | ||
80 | virtual BOOL handleHover(S32 x, S32 y, MASK mask); | ||
81 | virtual BOOL handleDoubleClick(S32 x, S32 y, MASK mask); | ||
82 | virtual BOOL handleMouseDown(S32 x, S32 y, MASK mask); | ||
83 | virtual BOOL handleRightMouseDown(S32 x, S32 y, MASK mask); | ||
84 | virtual BOOL handleRightMouseUp(S32 x, S32 y, MASK mask); | ||
85 | virtual BOOL handleMouseUp(S32 x, S32 y, MASK mask); | ||
86 | |||
87 | // LLUICtrl interface | ||
88 | virtual void clear(); // select nothing | ||
89 | virtual void onCommit(); | ||
90 | virtual BOOL acceptsTextInput() const { return mAllowTextEntry; } | ||
91 | |||
92 | virtual void setFocus(BOOL b); | ||
93 | |||
94 | // Selects item by underlying LLSD value, using LLSD::asString() matching. | ||
95 | // For simple items, this is just the name of the label. | ||
96 | virtual void setValue(const LLSD& value ); | ||
97 | |||
98 | // Gets underlying LLSD value for currently selected items. For simple | ||
99 | // items, this is just the label. | ||
100 | virtual LLSD getValue() const; | ||
101 | |||
102 | void setAllowTextEntry(BOOL allow, S32 max_chars = 50, BOOL make_tentative = TRUE); | ||
103 | void setTextEntry(const LLString& text); | ||
104 | |||
105 | void add(const LLString& name, EAddPosition pos = ADD_BOTTOM, BOOL enabled = TRUE); // add item "name" to menu | ||
106 | void add(const LLString& name, const LLUUID& id, EAddPosition pos = ADD_BOTTOM, BOOL enabled = TRUE); | ||
107 | void add(const LLString& name, void* userdata, EAddPosition pos = ADD_BOTTOM, BOOL enabled = TRUE); | ||
108 | void add(const LLString& name, LLSD value, EAddPosition pos = ADD_BOTTOM, BOOL enabled = TRUE); | ||
109 | BOOL remove( S32 index ); // remove item by index, return TRUE if found and removed | ||
110 | void removeall() { clearRows(); } | ||
111 | |||
112 | void sortByName(); // Sort the entries in the combobox by name | ||
113 | |||
114 | // Select current item by name using selectSimpleItem. Returns FALSE if not found. | ||
115 | BOOL setSimple(const LLString& name); | ||
116 | // Get name of current item. Returns an empty string if not found. | ||
117 | const LLString& getSimple() const; | ||
118 | // Get contents of column x of selected row | ||
119 | const LLString& getSimpleSelectedItem(S32 column = 0) const; | ||
120 | |||
121 | // Sets the label, which doesn't have to exist in the label. | ||
122 | // This is probably a UI abuse. | ||
123 | void setLabel(const LLString& name); | ||
124 | |||
125 | BOOL remove(const LLString& name); // remove item "name", return TRUE if found and removed | ||
126 | |||
127 | BOOL setCurrentByIndex( S32 index ); | ||
128 | S32 getCurrentIndex() const; | ||
129 | |||
130 | //======================================================================== | ||
131 | LLCtrlSelectionInterface* getSelectionInterface() { return (LLCtrlSelectionInterface*)this; }; | ||
132 | LLCtrlListInterface* getListInterface() { return (LLCtrlListInterface*)this; }; | ||
133 | |||
134 | // LLCtrlListInterface functions | ||
135 | // See llscrolllistctrl.h | ||
136 | virtual S32 getItemCount() const; | ||
137 | // Overwrites the default column (See LLScrollListCtrl for format) | ||
138 | virtual void addColumn(const LLSD& column, EAddPosition pos = ADD_BOTTOM); | ||
139 | virtual void clearColumns(); | ||
140 | virtual void setColumnLabel(const LLString& column, const LLString& label); | ||
141 | virtual LLScrollListItem* addElement(const LLSD& value, EAddPosition pos = ADD_BOTTOM, void* userdata = NULL); | ||
142 | virtual LLScrollListItem* addSimpleElement(const LLString& value, EAddPosition pos = ADD_BOTTOM, const LLSD& id = LLSD()); | ||
143 | virtual void clearRows(); | ||
144 | virtual void sortByColumn(LLString name, BOOL ascending); | ||
145 | |||
146 | // LLCtrlSelectionInterface functions | ||
147 | virtual BOOL getCanSelect() const { return TRUE; } | ||
148 | virtual BOOL selectFirstItem() { return setCurrentByIndex(0); } | ||
149 | virtual BOOL selectNthItem( S32 index ) { return setCurrentByIndex(index); } | ||
150 | virtual S32 getFirstSelectedIndex() { return getCurrentIndex(); } | ||
151 | virtual BOOL setCurrentByID( const LLUUID& id ); | ||
152 | virtual LLUUID getCurrentID(); // LLUUID::null if no items in menu | ||
153 | virtual BOOL setSelectedByValue(LLSD value, BOOL selected); | ||
154 | virtual LLSD getSimpleSelectedValue(); | ||
155 | virtual BOOL isSelected(LLSD value); | ||
156 | virtual BOOL operateOnSelection(EOperation op); | ||
157 | virtual BOOL operateOnAll(EOperation op); | ||
158 | |||
159 | //======================================================================== | ||
160 | |||
161 | void* getCurrentUserdata(); | ||
162 | |||
163 | void setPrearrangeCallback( void (*cb)(LLUICtrl*,void*) ) { mPrearrangeCallback = cb; } | ||
164 | void setTextEntryCallback( void (*cb)(LLLineEditor*, void*) ) { mTextEntryCallback = cb; } | ||
165 | |||
166 | void setButtonVisible(BOOL visible); | ||
167 | |||
168 | static void onButtonClick(void *userdata); | ||
169 | static void onItemSelected(LLUICtrl* item, void *userdata); | ||
170 | static void onTopViewLost(LLView* old_focus); | ||
171 | static void onMouseCaptureLost(LLMouseHandler* old_captor); | ||
172 | static void onTextEntry(LLLineEditor* line_editor, void* user_data); | ||
173 | static void onTextCommit(LLUICtrl* caller, void* user_data); | ||
174 | |||
175 | void updateSelection(); | ||
176 | void showList(); | ||
177 | void hideList(); | ||
178 | |||
179 | static void onListFocusLost(LLUICtrl* old_focus); | ||
180 | |||
181 | protected: | ||
182 | LLButton* mButton; | ||
183 | LLScrollListCtrl* mList; | ||
184 | LLViewBorder* mBorder; | ||
185 | BOOL mKeyboardFocusOnClick; | ||
186 | BOOL mDrawButton; | ||
187 | LLLineEditor* mTextEntry; | ||
188 | LLPointer<LLImageGL> mArrowImage; | ||
189 | BOOL mAllowTextEntry; | ||
190 | S32 mMaxChars; | ||
191 | BOOL mTextEntryTentative; | ||
192 | void (*mPrearrangeCallback)(LLUICtrl*,void*); | ||
193 | void (*mTextEntryCallback)(LLLineEditor*, void*); | ||
194 | S32 mListWidth; // width of pop-up list, 0 = use combobox width | ||
195 | }; | ||
196 | |||
197 | #endif | ||