diff options
Diffstat (limited to 'linden/indra/llui/llpanel.h')
-rw-r--r-- | linden/indra/llui/llpanel.h | 176 |
1 files changed, 86 insertions, 90 deletions
diff --git a/linden/indra/llui/llpanel.h b/linden/indra/llui/llpanel.h index aeba6d9..e0f48ca 100644 --- a/linden/indra/llui/llpanel.h +++ b/linden/indra/llui/llpanel.h | |||
@@ -33,10 +33,11 @@ | |||
33 | #ifndef LL_LLPANEL_H | 33 | #ifndef LL_LLPANEL_H |
34 | #define LL_LLPANEL_H | 34 | #define LL_LLPANEL_H |
35 | 35 | ||
36 | // Opaque view with a background and a border. Can contain LLUICtrls. | ||
37 | 36 | ||
38 | #include "llcallbackmap.h" | 37 | #include "llcallbackmap.h" |
39 | #include "lluictrl.h" | 38 | #include "lluictrl.h" |
39 | #include "llbutton.h" | ||
40 | #include "lllineeditor.h" | ||
40 | #include "llviewborder.h" | 41 | #include "llviewborder.h" |
41 | #include "lluistring.h" | 42 | #include "lluistring.h" |
42 | #include "v4color.h" | 43 | #include "v4color.h" |
@@ -47,39 +48,26 @@ const S32 LLPANEL_BORDER_WIDTH = 1; | |||
47 | const BOOL BORDER_YES = TRUE; | 48 | const BOOL BORDER_YES = TRUE; |
48 | const BOOL BORDER_NO = FALSE; | 49 | const BOOL BORDER_NO = FALSE; |
49 | 50 | ||
50 | class LLViewerImage; | 51 | |
51 | class LLUUID; | 52 | struct LLAlertInfo |
52 | class LLCheckBoxCtrl; | ||
53 | class LLComboBox; | ||
54 | class LLIconCtrl; | ||
55 | class LLLineEditor; | ||
56 | class LLRadioGroup; | ||
57 | class LLScrollListCtrl; | ||
58 | class LLSliderCtrl; | ||
59 | class LLSpinCtrl; | ||
60 | class LLTextBox; | ||
61 | class LLTextEditor; | ||
62 | |||
63 | class LLAlertInfo | ||
64 | { | 53 | { |
65 | public: | ||
66 | LLString mLabel; | 54 | LLString mLabel; |
67 | LLString::format_map_t mArgs; | 55 | LLString::format_map_t mArgs; |
68 | 56 | ||
69 | LLAlertInfo(LLString label, LLString::format_map_t args) | 57 | LLAlertInfo(LLString label, LLString::format_map_t args) : mLabel(label), mArgs(args) { } |
70 | : mLabel(label), mArgs(args) { } | 58 | LLAlertInfo(){} |
71 | |||
72 | LLAlertInfo() { } | ||
73 | }; | 59 | }; |
74 | 60 | ||
75 | class LLPanel : public LLUICtrl | 61 | |
62 | /* | ||
63 | * General purpose concrete view base class. | ||
64 | * Transparent or opaque, | ||
65 | * With or without border, | ||
66 | * Can contain LLUICtrls. | ||
67 | */ | ||
68 | class LLPanel : public LLUICtrl | ||
76 | { | 69 | { |
77 | public: | 70 | public: |
78 | virtual EWidgetType getWidgetType() const; | ||
79 | virtual LLString getWidgetTag() const; | ||
80 | |||
81 | // defaults to TRUE | ||
82 | virtual BOOL isPanel(); | ||
83 | 71 | ||
84 | // minimal constructor for data-driven initialization | 72 | // minimal constructor for data-driven initialization |
85 | LLPanel(); | 73 | LLPanel(); |
@@ -89,34 +77,46 @@ public: | |||
89 | LLPanel(const LLString& name, const LLRect& rect, BOOL bordered = TRUE); | 77 | LLPanel(const LLString& name, const LLRect& rect, BOOL bordered = TRUE); |
90 | 78 | ||
91 | // Position and size are saved to rect_control | 79 | // Position and size are saved to rect_control |
92 | LLPanel(const LLString& name, const LLString& rect_control, BOOL bordered = TRUE); | 80 | LLPanel(const LLString& name, const LLString& rect_control, BOOL bordered = TRUE); |
81 | |||
82 | /*virtual*/ ~LLPanel(); | ||
83 | |||
84 | // LLView interface | ||
85 | /*virtual*/ EWidgetType getWidgetType() const; | ||
86 | /*virtual*/ LLString getWidgetTag() const; | ||
87 | /*virtual*/ BOOL isPanel() const; | ||
88 | /*virtual*/ void draw(); | ||
89 | /*virtual*/ BOOL handleKey( KEY key, MASK mask, BOOL called_from_parent ); | ||
90 | /*virtual*/ BOOL handleKeyHere( KEY key, MASK mask, BOOL called_from_parent ); | ||
91 | /*virtual*/ LLXMLNodePtr getXML(bool save_children = true) const; | ||
93 | 92 | ||
93 | // From LLFocusableElement | ||
94 | /*virtual*/ void setFocus( BOOL b ); | ||
95 | |||
96 | // New virtuals | ||
97 | virtual void refresh(); // called in setFocus() | ||
98 | virtual BOOL postBuild(); | ||
99 | virtual void clearCtrls(); // overridden in LLPanelObject and LLPanelVolume | ||
100 | |||
101 | // Border controls | ||
94 | void addBorder( LLViewBorder::EBevel border_bevel = LLViewBorder::BEVEL_OUT, | 102 | void addBorder( LLViewBorder::EBevel border_bevel = LLViewBorder::BEVEL_OUT, |
95 | LLViewBorder::EStyle border_style = LLViewBorder::STYLE_LINE, | 103 | LLViewBorder::EStyle border_style = LLViewBorder::STYLE_LINE, |
96 | S32 border_thickness = LLPANEL_BORDER_WIDTH ); | 104 | S32 border_thickness = LLPANEL_BORDER_WIDTH ); |
97 | 105 | void removeBorder(); | |
98 | void removeBorder(); | 106 | BOOL hasBorder() const { return mBorder != NULL; } |
99 | 107 | void setBorderVisible( BOOL b ); | |
100 | virtual ~LLPanel(); | ||
101 | virtual void draw(); | ||
102 | virtual void refresh(); // called in setFocus() | ||
103 | virtual void setFocus( BOOL b ); | ||
104 | void setFocusRoot(BOOL b) { mIsFocusRoot = b; } | ||
105 | virtual BOOL handleKeyHere( KEY key, MASK mask, BOOL called_from_parent ); | ||
106 | virtual BOOL handleKey( KEY key, MASK mask, BOOL called_from_parent ); | ||
107 | virtual BOOL postBuild(); | ||
108 | 108 | ||
109 | void requires(LLString name, EWidgetType type = WIDGET_TYPE_DONTCARE); | 109 | void requires(LLString name, EWidgetType type = WIDGET_TYPE_DONTCARE); |
110 | BOOL checkRequirements(); | 110 | BOOL checkRequirements() const; |
111 | |||
112 | static void alertXml(LLString label, LLString::format_map_t args = LLString::format_map_t()); | ||
113 | static BOOL nextAlert(LLAlertInfo &alert); | ||
114 | 111 | ||
115 | void setBackgroundColor( const LLColor4& color ); | 112 | void setBackgroundColor( const LLColor4& color ) { mBgColorOpaque = color; } |
116 | LLColor4 getBackgroundColor(); | 113 | const LLColor4& getBackgroundColor() const { return mBgColorOpaque; } |
117 | void setTransparentColor(const LLColor4& color); | 114 | void setTransparentColor(const LLColor4& color) { mBgColorAlpha = color; } |
115 | const LLColor4& getTransparentColor() const { return mBgColorAlpha; } | ||
118 | void setBackgroundVisible( BOOL b ) { mBgVisible = b; } | 116 | void setBackgroundVisible( BOOL b ) { mBgVisible = b; } |
117 | BOOL isBackgroundVisible() const { return mBgVisible; } | ||
119 | void setBackgroundOpaque(BOOL b) { mBgOpaque = b; } | 118 | void setBackgroundOpaque(BOOL b) { mBgOpaque = b; } |
119 | BOOL isBackgroundOpaque() const { return mBgOpaque; } | ||
120 | void setDefaultBtn(LLButton* btn = NULL); | 120 | void setDefaultBtn(LLButton* btn = NULL); |
121 | void setDefaultBtn(const LLString& id); | 121 | void setDefaultBtn(const LLString& id); |
122 | void updateDefaultBtn(); | 122 | void updateDefaultBtn(); |
@@ -124,37 +124,28 @@ public: | |||
124 | LLString getLabel() const { return mLabel; } | 124 | LLString getLabel() const { return mLabel; } |
125 | 125 | ||
126 | void setRectControl(const LLString& rect_control) { mRectControl.assign(rect_control); } | 126 | void setRectControl(const LLString& rect_control) { mRectControl.assign(rect_control); } |
127 | const LLString& getRectControl() const { return mRectControl; } | ||
127 | void storeRectControl(); | 128 | void storeRectControl(); |
128 | |||
129 | void setBorderVisible( BOOL b ); | ||
130 | 129 | ||
131 | void setCtrlsEnabled(BOOL b); | 130 | void setCtrlsEnabled(BOOL b); |
132 | virtual void clearCtrls(); | ||
133 | |||
134 | LLViewHandle getHandle() { return mViewHandle; } | ||
135 | 131 | ||
136 | S32 getLastTabGroup() { return mLastTabGroup; } | 132 | LLHandle<LLPanel> getHandle() const { return mPanelHandle; } |
137 | 133 | ||
138 | LLView* getCtrlByNameAndType(const LLString& name, EWidgetType type); | 134 | S32 getLastTabGroup() const { return mLastTabGroup; } |
139 | 135 | ||
140 | static LLPanel* getPanelByHandle(LLViewHandle handle); | 136 | LLUICtrl* getCtrlByNameAndType(const LLString& name, EWidgetType type) const; |
141 | 137 | ||
142 | virtual const LLCallbackMap::map_t& getFactoryMap() const { return mFactoryMap; } | 138 | const LLCallbackMap::map_t& getFactoryMap() const { return mFactoryMap; } |
143 | 139 | ||
144 | virtual LLXMLNodePtr getXML(bool save_children = true) const; | ||
145 | static LLView* fromXML(LLXMLNodePtr node, LLView *parent, LLUICtrlFactory *factory); | ||
146 | BOOL initPanelXML(LLXMLNodePtr node, LLView *parent, LLUICtrlFactory *factory); | 140 | BOOL initPanelXML(LLXMLNodePtr node, LLView *parent, LLUICtrlFactory *factory); |
147 | void initChildrenXML(LLXMLNodePtr node, LLUICtrlFactory* factory); | 141 | void initChildrenXML(LLXMLNodePtr node, LLUICtrlFactory* factory); |
148 | void setPanelParameters(LLXMLNodePtr node, LLView *parentp); | 142 | void setPanelParameters(LLXMLNodePtr node, LLView *parentp); |
149 | 143 | ||
150 | LLString getFormattedUIString(const LLString& name, const LLString::format_map_t& args = LLUIString::sNullArgs) const; | 144 | LLString getString(const LLString& name, const LLString::format_map_t& args = LLUIString::sNullArgs) const; |
151 | LLUIString getUIString(const LLString& name) const; | 145 | LLUIString getUIString(const LLString& name) const; |
152 | 146 | ||
153 | // ** Wrappers for setting child properties by name ** -TomY | 147 | // ** Wrappers for setting child properties by name ** -TomY |
154 | 148 | ||
155 | // Override to set not found list | ||
156 | virtual LLView* getChildByName(const LLString& name, BOOL recurse = FALSE) const; | ||
157 | |||
158 | // LLView | 149 | // LLView |
159 | void childSetVisible(const LLString& name, bool visible); | 150 | void childSetVisible(const LLString& name, bool visible); |
160 | void childShow(const LLString& name) { childSetVisible(name, true); } | 151 | void childShow(const LLString& name) { childSetVisible(name, true); } |
@@ -183,9 +174,9 @@ public: | |||
183 | 174 | ||
184 | void childSetColor(const LLString& id, const LLColor4& color); | 175 | void childSetColor(const LLString& id, const LLColor4& color); |
185 | 176 | ||
186 | LLCtrlSelectionInterface* childGetSelectionInterface(const LLString& id); | 177 | LLCtrlSelectionInterface* childGetSelectionInterface(const LLString& id) const; |
187 | LLCtrlListInterface* childGetListInterface(const LLString& id); | 178 | LLCtrlListInterface* childGetListInterface(const LLString& id) const; |
188 | LLCtrlScrollInterface* childGetScrollInterface(const LLString& id); | 179 | LLCtrlScrollInterface* childGetScrollInterface(const LLString& id) const; |
189 | 180 | ||
190 | // This is the magic bullet for data-driven UI | 181 | // This is the magic bullet for data-driven UI |
191 | void childSetValue(const LLString& id, LLSD value); | 182 | void childSetValue(const LLString& id, LLSD value); |
@@ -197,21 +188,21 @@ public: | |||
197 | BOOL childSetLabelArg(const LLString& id, const LLString& key, const LLStringExplicit& text); | 188 | BOOL childSetLabelArg(const LLString& id, const LLString& key, const LLStringExplicit& text); |
198 | BOOL childSetToolTipArg(const LLString& id, const LLString& key, const LLStringExplicit& text); | 189 | BOOL childSetToolTipArg(const LLString& id, const LLString& key, const LLStringExplicit& text); |
199 | 190 | ||
200 | // LLSlider / LLSpinCtrl | 191 | // LLSlider / LLMultiSlider / LLSpinCtrl |
201 | void childSetMinValue(const LLString& id, LLSD min_value); | 192 | void childSetMinValue(const LLString& id, LLSD min_value); |
202 | void childSetMaxValue(const LLString& id, LLSD max_value); | 193 | void childSetMaxValue(const LLString& id, LLSD max_value); |
203 | 194 | ||
204 | // LLTabContainer | 195 | // LLTabContainer |
205 | void childShowTab(const LLString& id, const LLString& tabname, bool visible = true); | 196 | void childShowTab(const LLString& id, const LLString& tabname, bool visible = true); |
206 | LLPanel *childGetVisibleTab(const LLString& id); | 197 | LLPanel *childGetVisibleTab(const LLString& id) const; |
207 | void childSetTabChangeCallback(const LLString& id, const LLString& tabname, void (*on_tab_clicked)(void*, bool), void *userdata); | 198 | void childSetTabChangeCallback(const LLString& id, const LLString& tabname, void (*on_tab_clicked)(void*, bool), void *userdata); |
208 | 199 | ||
209 | // LLTextBox | 200 | // LLTextBox |
210 | void childSetWrappedText(const LLString& id, const LLString& text, bool visible = true); | 201 | void childSetWrappedText(const LLString& id, const LLString& text, bool visible = true); |
211 | 202 | ||
212 | // LLTextBox/LLTextEditor/LLLineEditor | 203 | // LLTextBox/LLTextEditor/LLLineEditor |
213 | void childSetText(const LLString& id, const LLStringExplicit& text); | 204 | void childSetText(const LLString& id, const LLStringExplicit& text) { childSetValue(id, LLSD(text)); } |
214 | LLString childGetText(const LLString& id); | 205 | LLString childGetText(const LLString& id) const { return childGetValue(id).asString(); } |
215 | 206 | ||
216 | // LLLineEditor | 207 | // LLLineEditor |
217 | void childSetKeystrokeCallback(const LLString& id, void (*keystroke_callback)(LLLineEditor* caller, void* user_data), void *user_data); | 208 | void childSetKeystrokeCallback(const LLString& id, void (*keystroke_callback)(LLLineEditor* caller, void* user_data), void *user_data); |
@@ -226,16 +217,23 @@ public: | |||
226 | void childNotFound(const LLString& id) const; | 217 | void childNotFound(const LLString& id) const; |
227 | void childDisplayNotFound(); | 218 | void childDisplayNotFound(); |
228 | 219 | ||
229 | typedef std::queue<LLAlertInfo> alert_queue_t; | 220 | static void alertXml(LLString label, LLString::format_map_t args = LLString::format_map_t()); |
230 | static alert_queue_t sAlertQueue; | 221 | static BOOL nextAlert(LLAlertInfo &alert); |
222 | static LLView* fromXML(LLXMLNodePtr node, LLView *parent, LLUICtrlFactory *factory); | ||
223 | |||
224 | protected: | ||
225 | // Override to set not found list | ||
226 | LLButton* getDefaultButton() { return mDefaultBtn; } | ||
227 | LLCallbackMap::map_t mFactoryMap; | ||
231 | 228 | ||
232 | typedef std::map<LLString, LLUIString> ui_string_map_t; | 229 | // Override to set not found list: |
230 | virtual LLView* getChildByName(const LLString& name, BOOL recurse = FALSE) const; | ||
233 | 231 | ||
234 | private: | 232 | private: |
235 | // common constructor | 233 | // common construction logic |
236 | void init(); | 234 | void init(); |
237 | 235 | ||
238 | protected: | 236 | // From LLView |
239 | virtual void addCtrl( LLUICtrl* ctrl, S32 tab_group ); | 237 | virtual void addCtrl( LLUICtrl* ctrl, S32 tab_group ); |
240 | virtual void addCtrlAtEnd( LLUICtrl* ctrl, S32 tab_group); | 238 | virtual void addCtrlAtEnd( LLUICtrl* ctrl, S32 tab_group); |
241 | 239 | ||
@@ -252,18 +250,20 @@ protected: | |||
252 | BOOL mBgOpaque; | 250 | BOOL mBgOpaque; |
253 | LLViewBorder* mBorder; | 251 | LLViewBorder* mBorder; |
254 | LLButton* mDefaultBtn; | 252 | LLButton* mDefaultBtn; |
255 | LLCallbackMap::map_t mFactoryMap; | ||
256 | LLString mLabel; | 253 | LLString mLabel; |
257 | S32 mLastTabGroup; | 254 | S32 mLastTabGroup; |
255 | LLRootHandle<LLPanel> mPanelHandle; | ||
258 | 256 | ||
257 | typedef std::map<LLString, LLUIString> ui_string_map_t; | ||
259 | ui_string_map_t mUIStrings; | 258 | ui_string_map_t mUIStrings; |
260 | 259 | ||
261 | typedef std::map<LLString, EWidgetType> requirements_map_t; | 260 | typedef std::map<LLString, EWidgetType> requirements_map_t; |
262 | requirements_map_t mRequirements; | 261 | requirements_map_t mRequirements; |
263 | 262 | ||
264 | typedef std::map<LLViewHandle, LLPanel*> panel_map_t; | 263 | typedef std::queue<LLAlertInfo> alert_queue_t; |
265 | static panel_map_t sPanelMap; | 264 | static alert_queue_t sAlertQueue; |
266 | }; | 265 | }; // end class LLPanel |
266 | |||
267 | 267 | ||
268 | class LLLayoutStack : public LLView | 268 | class LLLayoutStack : public LLView |
269 | { | 269 | { |
@@ -281,37 +281,33 @@ public: | |||
281 | /*virtual*/ LLXMLNodePtr getXML(bool save_children = true) const; | 281 | /*virtual*/ LLXMLNodePtr getXML(bool save_children = true) const; |
282 | /*virtual*/ void removeCtrl(LLUICtrl* ctrl); | 282 | /*virtual*/ void removeCtrl(LLUICtrl* ctrl); |
283 | 283 | ||
284 | virtual EWidgetType getWidgetType() const { return WIDGET_TYPE_LAYOUT_STACK; } | 284 | virtual EWidgetType getWidgetType() const; |
285 | virtual LLString getWidgetTag() const { return LL_LAYOUT_STACK_TAG; } | 285 | virtual LLString getWidgetTag() const; |
286 | 286 | ||
287 | static LLView* fromXML(LLXMLNodePtr node, LLView *parent, LLUICtrlFactory *factory); | 287 | static LLView* fromXML(LLXMLNodePtr node, LLView *parent, LLUICtrlFactory *factory); |
288 | 288 | ||
289 | S32 getMinWidth(); | 289 | S32 getMinWidth() const { return mMinWidth; } |
290 | S32 getMinHeight(); | 290 | S32 getMinHeight() const { return mMinHeight; } |
291 | 291 | ||
292 | void addPanel(LLPanel* panel, S32 min_width, S32 min_height, BOOL auto_resize, BOOL user_resize, S32 index = S32_MAX); | 292 | void addPanel(LLPanel* panel, S32 min_width, S32 min_height, BOOL auto_resize, BOOL user_resize, S32 index = S32_MAX); |
293 | void removePanel(LLPanel* panel); | 293 | void removePanel(LLPanel* panel); |
294 | void updateLayout(BOOL force_resize = FALSE); | 294 | void updateLayout(BOOL force_resize = FALSE); |
295 | 295 | ||
296 | protected: | 296 | private: |
297 | struct LLEmbeddedPanel; | ||
298 | |||
299 | LLEmbeddedPanel* findEmbeddedPanel(LLPanel* panelp); | ||
300 | void calcMinExtents(); | 297 | void calcMinExtents(); |
301 | S32 getMinStackSize(); | ||
302 | S32 getCurStackSize(); | ||
303 | S32 getDefaultHeight(S32 cur_height); | 298 | S32 getDefaultHeight(S32 cur_height); |
304 | S32 getDefaultWidth(S32 cur_width); | 299 | S32 getDefaultWidth(S32 cur_width); |
305 | 300 | ||
306 | protected: | 301 | const eLayoutOrientation mOrientation; |
307 | eLayoutOrientation mOrientation; | ||
308 | 302 | ||
303 | struct LLEmbeddedPanel; | ||
309 | typedef std::vector<LLEmbeddedPanel*> e_panel_list_t; | 304 | typedef std::vector<LLEmbeddedPanel*> e_panel_list_t; |
310 | e_panel_list_t mPanels; | 305 | e_panel_list_t mPanels; |
306 | LLEmbeddedPanel* findEmbeddedPanel(LLPanel* panelp) const; | ||
311 | 307 | ||
312 | S32 mMinWidth; | 308 | S32 mMinWidth; |
313 | S32 mMinHeight; | 309 | S32 mMinHeight; |
314 | S32 mPanelSpacing; | 310 | S32 mPanelSpacing; |
315 | }; | 311 | }; // end class LLLayoutStack |
316 | 312 | ||
317 | #endif | 313 | #endif |