aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/linden/indra/llui/llview.h
diff options
context:
space:
mode:
Diffstat (limited to 'linden/indra/llui/llview.h')
-rw-r--r--linden/indra/llui/llview.h486
1 files changed, 266 insertions, 220 deletions
diff --git a/linden/indra/llui/llview.h b/linden/indra/llui/llview.h
index 67a4d56..52c7e3d 100644
--- a/linden/indra/llui/llview.h
+++ b/linden/indra/llui/llview.h
@@ -52,10 +52,6 @@
52#include "stdenums.h" 52#include "stdenums.h"
53#include "lluistring.h" 53#include "lluistring.h"
54 54
55class LLColor4;
56class LLWindow;
57class LLUICtrl;
58class LLScrollListItem;
59 55
60const U32 FOLLOWS_NONE = 0x00; 56const U32 FOLLOWS_NONE = 0x00;
61const U32 FOLLOWS_LEFT = 0x01; 57const U32 FOLLOWS_LEFT = 0x01;
@@ -69,29 +65,90 @@ const BOOL NOT_MOUSE_OPAQUE = FALSE;
69 65
70const U32 GL_NAME_UI_RESERVED = 2; 66const U32 GL_NAME_UI_RESERVED = 2;
71 67
72class LLSimpleListener;
73class LLEventDispatcher;
74 68
75class LLViewHandle 69/*
76{ 70// virtual functions defined in LLView:
77public: 71
78 LLViewHandle() { mID = 0; } 72virtual BOOL isCtrl() const;
79 73 LLUICtrl
80 void init() { mID = ++sNextID; } 74virtual BOOL isPanel();
81 void markDead() { mID = 0; } 75 LLPanel
82 BOOL isDead() { return (mID == 0); } 76virtual void setRect(const LLRect &rect);
83 friend bool operator==(const LLViewHandle& lhs, const LLViewHandle& rhs); 77 LLLineEditor
84 friend bool operator!=(const LLViewHandle& lhs, const LLViewHandle& rhs); 78virtual void addCtrl( LLUICtrl* ctrl, S32 tab_group);
85 friend bool operator<(const LLViewHandle &a, const LLViewHandle &b); 79virtual void addCtrlAtEnd( LLUICtrl* ctrl, S32 tab_group);
86 80virtual void removeCtrl( LLUICtrl* ctrl);
87public: 81 LLPanel
88 static LLViewHandle sDeadHandle; 82virtual BOOL canFocusChildren() const { return TRUE; }
83 LLFolderView
84virtual void deleteAllChildren();
85 LLFolderView, LLPanelInventory
86virtual void setTentative(BOOL b) {}
87 LLUICtrl, LLSliderCtrl, LLSpinCtrl
88virtual BOOL getTentative() const { return FALSE; }
89 LLUICtrl, LLCheckBoxCtrl
90virtual void setVisible(BOOL visible);
91 LLFloater, LLAlertDialog, LLMenuItemGL, LLModalDialog
92virtual void setEnabled(BOOL enabled) { mEnabled = enabled; }
93 LLCheckBoxCtrl, LLComboBox, LLLineEditor, LLMenuGL, LLRadioGroup, etc
94virtual BOOL setLabelArg( const LLString& key, const LLStringExplicit& text ) { return FALSE; }
95 LLUICtrl, LLButton, LLCheckBoxCtrl, LLLineEditor, LLMenuGL, LLSliderCtrl
96virtual void onVisibilityChange ( BOOL curVisibilityIn );
97 LLMenuGL
98virtual LLRect getSnapRect() const { return mRect; } *TODO: Make non virtual
99 LLFloater
100virtual LLRect getRequiredRect() { return mRect; }
101 LLScrolllistCtrl
102virtual void reshape(S32 width, S32 height, BOOL called_from_parent = TRUE);
103 LLUICtrl, et. al.
104virtual void translate( S32 x, S32 y );
105 LLMenuGL
106virtual void userSetShape(const LLRect& new_rect);
107 LLFloater, LLScrollLIstVtrl
108virtual LLView* findSnapRect(LLRect& new_rect, const LLCoordGL& mouse_dir, LLView::ESnapType snap_type, S32 threshold, S32 padding = 0);
109virtual LLView* findSnapEdge(S32& new_edge_val, const LLCoordGL& mouse_dir, ESnapEdge snap_edge, ESnapType snap_type, S32 threshold, S32 padding = 0);
110 LLScrollListCtrl
111virtual BOOL canSnapTo(const LLView* other_view) const { return other_view != this && other_view->getVisible(); }
112 LLFloater
113virtual void snappedTo(LLView* snap_view) {}
114 LLFloater
115virtual BOOL handleKey(KEY key, MASK mask, BOOL called_from_parent);
116 *
117virtual BOOL handleUnicodeChar(llwchar uni_char, BOOL called_from_parent);
118 *
119virtual BOOL handleDragAndDrop(S32 x, S32 y, MASK mask, BOOL drop,EDragAndDropType cargo_type,void* cargo_data,EAcceptance* accept,LLString& tooltip_msg);
120 *
121virtual void draw();
122 *
123virtual EWidgetType getWidgetType() const = 0;
124 *
125virtual LLString getWidgetTag() const = 0;
126 *
127virtual LLXMLNodePtr getXML(bool save_children = true) const;
128 *
129virtual void initFromXML(LLXMLNodePtr node, LLView* parent);
130 *
131virtual void onFocusLost() {}
132 LLUICtrl, LLScrollListCtrl, LLMenuGL, LLLineEditor, LLComboBox
133virtual void onFocusReceived() {}
134 LLUICtrl, LLTextEditor, LLScrollListVtrl, LLMenuGL, LLLineEditor
135virtual LLView* getChildByName(const LLString& name, BOOL recurse = FALSE) const;
136 LLTabContainer, LLPanel, LLMenuGL
137virtual void setControlName(const LLString& control, LLView *context);
138 LLSliderCtrl, LLCheckBoxCtrl
139virtual LLString getControlName() const { return mControlName; }
140 LLSliderCtrl, LLCheckBoxCtrl
141virtual bool handleEvent(LLPointer<LLEvent> event, const LLSD& userdata);
142 LLMenuItem
143virtual void setValue(const LLSD& value);
144 *
89 145
90protected: 146protected:
91 S32 mID; 147virtual BOOL handleKeyHere(KEY key, MASK mask, BOOL called_from_parent);
92 148 *
93 static S32 sNextID; 149virtual BOOL handleUnicodeCharHere(llwchar uni_char, BOOL called_from_parent);
94}; 150 *
151*/
95 152
96class LLView : public LLMouseHandler, public LLMortician, public LLSimpleListenerObservable 153class LLView : public LLMouseHandler, public LLMortician, public LLSimpleListenerObservable
97{ 154{
@@ -128,7 +185,7 @@ public:
128 typedef child_list_t::reverse_iterator child_list_reverse_iter_t; 185 typedef child_list_t::reverse_iterator child_list_reverse_iter_t;
129 typedef child_list_t::const_reverse_iterator child_list_const_reverse_iter_t; 186 typedef child_list_t::const_reverse_iterator child_list_const_reverse_iter_t;
130 187
131 typedef std::vector<LLUICtrl *> ctrl_list_t; 188 typedef std::vector<class LLUICtrl *> ctrl_list_t;
132 189
133 typedef std::pair<S32, S32> tab_order_t; 190 typedef std::pair<S32, S32> tab_order_t;
134 typedef std::pair<LLUICtrl *, tab_order_t> tab_order_pair_t; 191 typedef std::pair<LLUICtrl *, tab_order_t> tab_order_pair_t;
@@ -139,105 +196,48 @@ public:
139 typedef child_tab_order_t::reverse_iterator child_tab_order_reverse_iter_t; 196 typedef child_tab_order_t::reverse_iterator child_tab_order_reverse_iter_t;
140 typedef child_tab_order_t::const_reverse_iterator child_tab_order_const_reverse_iter_t; 197 typedef child_tab_order_t::const_reverse_iterator child_tab_order_const_reverse_iter_t;
141 198
142private:
143 LLView* mParentView;
144 child_list_t mChildList;
145
146protected:
147 LLString mName;
148 // location in pixels, relative to surrounding structure, bottom,left=0,0
149 LLRect mRect;
150 LLRect mBoundingRect;
151
152 U32 mReshapeFlags;
153
154 child_tab_order_t mCtrlOrder;
155 S32 mDefaultTabGroup;
156
157 BOOL mEnabled; // Enabled means "accepts input that has an effect on the state of the application."
158 // A disabled view, for example, may still have a scrollbar that responds to mouse events.
159 BOOL mMouseOpaque; // Opaque views handle all mouse events that are over their rect.
160 LLUIString mToolTipMsg; // isNull() is true if none.
161
162 U8 mSoundFlags;
163 BOOL mSaveToXML;
164
165 BOOL mIsFocusRoot;
166 BOOL mUseBoundingRect; // hit test against bounding rectangle that includes all child elements
167
168public:
169 LLViewHandle mViewHandle;
170 BOOL mLastVisible;
171
172private:
173 BOOL mVisible;
174 BOOL mHidden; // Never show (generally for replacement text only)
175
176 S32 mNextInsertionOrdinal;
177
178protected:
179 static LLWindow* sWindow; // All root views must know about their window.
180
181public:
182 static BOOL sDebugRects; // Draw debug rects behind everything.
183 static BOOL sDebugKeys;
184 static S32 sDepth;
185 static BOOL sDebugMouseHandling;
186 static LLString sMouseHandlerMessage;
187 static S32 sSelectID;
188 static BOOL sEditingUI;
189 static LLView* sEditingUIView;
190 static S32 sLastLeftXML;
191 static S32 sLastBottomXML;
192 static std::map<LLViewHandle,LLView*> sViewHandleMap;
193 static BOOL sForceReshape;
194
195public:
196 static LLView* getViewByHandle(LLViewHandle handle);
197 static BOOL deleteViewByHandle(LLViewHandle handle);
198
199public:
200 LLView(); 199 LLView();
201 LLView(const LLString& name, BOOL mouse_opaque); 200 LLView(const LLString& name, BOOL mouse_opaque);
202 LLView(const LLString& name, const LLRect& rect, BOOL mouse_opaque, U32 follows=FOLLOWS_NONE); 201 LLView(const LLString& name, const LLRect& rect, BOOL mouse_opaque, U32 follows=FOLLOWS_NONE);
203 202
204 virtual ~LLView(); 203 virtual ~LLView();
205 204
206 // Hack to support LLFocusMgr 205 // Hack to support LLFocusMgr (from LLMouseHandler)
207 virtual BOOL isView(); 206 /*virtual*/ BOOL isView() const;
208 207
209 // Some UI widgets need to be added as controls. Others need to 208 // Some UI widgets need to be added as controls. Others need to
210 // be added as regular view children. isCtrl should return TRUE 209 // be added as regular view children. isCtrl should return TRUE
211 // if a widget needs to be added as a ctrl 210 // if a widget needs to be added as a ctrl
212 virtual BOOL isCtrl() const; 211 virtual BOOL isCtrl() const;
213 212
214 virtual BOOL isPanel(); 213 virtual BOOL isPanel() const;
215 214
216 // 215 //
217 // MANIPULATORS 216 // MANIPULATORS
218 // 217 //
219 void setMouseOpaque( BOOL b ); 218 void setMouseOpaque( BOOL b ) { mMouseOpaque = b; }
219 BOOL getMouseOpaque() const { return mMouseOpaque; }
220 void setToolTip( const LLStringExplicit& msg ); 220 void setToolTip( const LLStringExplicit& msg );
221 BOOL setToolTipArg( const LLStringExplicit& key, const LLStringExplicit& text ); 221 BOOL setToolTipArg( const LLStringExplicit& key, const LLStringExplicit& text );
222 void setToolTipArgs( const LLString::format_map_t& args ); 222 void setToolTipArgs( const LLString::format_map_t& args );
223 223
224 virtual void setRect(const LLRect &rect); 224 virtual void setRect(const LLRect &rect);
225 void setFollows(U32 flags); 225 void setFollows(U32 flags) { mReshapeFlags = flags; }
226 226
227 // deprecated, use setFollows() with FOLLOWS_LEFT | FOLLOWS_TOP, etc. 227 // deprecated, use setFollows() with FOLLOWS_LEFT | FOLLOWS_TOP, etc.
228 void setFollowsNone(); 228 void setFollowsNone() { mReshapeFlags = FOLLOWS_NONE; }
229 void setFollowsLeft(); 229 void setFollowsLeft() { mReshapeFlags |= FOLLOWS_LEFT; }
230 void setFollowsTop(); 230 void setFollowsTop() { mReshapeFlags |= FOLLOWS_TOP; }
231 void setFollowsRight(); 231 void setFollowsRight() { mReshapeFlags |= FOLLOWS_RIGHT; }
232 void setFollowsBottom(); 232 void setFollowsBottom() { mReshapeFlags |= FOLLOWS_BOTTOM; }
233 void setFollowsAll(); 233 void setFollowsAll() { mReshapeFlags |= FOLLOWS_ALL; }
234 234
235 void setSoundFlags(U8 flags); 235 void setSoundFlags(U8 flags) { mSoundFlags = flags; }
236 void setName(LLString name); 236 void setName(LLString name) { mName = name; }
237 void setUseBoundingRect( BOOL use_bounding_rect ); 237 void setUseBoundingRect( BOOL use_bounding_rect );
238 BOOL getUseBoundingRect(); 238 BOOL getUseBoundingRect();
239 239
240 const LLString& getToolTip(); 240 const LLString& getToolTip() const { return mToolTipMsg.getString(); }
241 241
242 void sendChildToFront(LLView* child); 242 void sendChildToFront(LLView* child);
243 void sendChildToBack(LLView* child); 243 void sendChildToBack(LLView* child);
@@ -253,61 +253,47 @@ public:
253 virtual void addCtrlAtEnd( LLUICtrl* ctrl, S32 tab_group); 253 virtual void addCtrlAtEnd( LLUICtrl* ctrl, S32 tab_group);
254 virtual void removeCtrl( LLUICtrl* ctrl); 254 virtual void removeCtrl( LLUICtrl* ctrl);
255 255
256 child_tab_order_t getCtrlOrder() const { return mCtrlOrder; } 256 child_tab_order_t getCtrlOrder() const { return mCtrlOrder; }
257 ctrl_list_t getCtrlList() const; 257 ctrl_list_t getCtrlList() const;
258 ctrl_list_t getCtrlListSorted() const; 258 ctrl_list_t getCtrlListSorted() const;
259 S32 getDefaultTabGroup() const; 259
260 void setDefaultTabGroup(S32 d) { mDefaultTabGroup = d; }
261 S32 getDefaultTabGroup() const { return mDefaultTabGroup; }
260 262
261 BOOL isInVisibleChain() const; 263 BOOL isInVisibleChain() const;
262 BOOL isInEnabledChain() const; 264 BOOL isInEnabledChain() const;
263 265
264 BOOL isFocusRoot() const; 266 void setFocusRoot(BOOL b) { mIsFocusRoot = b; }
265 LLView* findRootMostFocusRoot(); 267 BOOL isFocusRoot() const { return mIsFocusRoot; }
266 virtual BOOL canFocusChildren() const; 268 virtual BOOL canFocusChildren() const;
267 269
268 class LLFocusRootsFilter : public LLQueryFilter, public LLSingleton<LLFocusRootsFilter> 270 BOOL focusNextRoot();
269 { 271 BOOL focusPrevRoot();
270 /*virtual*/ filterResult_t operator() (const LLView* const view, const viewList_t & children) const
271 {
272 return filterResult_t(view->isCtrl() && view->isFocusRoot(), TRUE);
273 }
274 };
275
276 virtual BOOL focusNextRoot();
277 virtual BOOL focusPrevRoot();
278
279 virtual BOOL focusNextItem(BOOL text_entry_only);
280 virtual BOOL focusPrevItem(BOOL text_entry_only);
281 virtual BOOL focusFirstItem(BOOL prefer_text_fields = FALSE );
282 virtual BOOL focusLastItem(BOOL prefer_text_fields = FALSE);
283 272
284 // delete all children. Override this function if you need to 273 // delete all children. Override this function if you need to
285 // perform any extra clean up such as cached pointers to selected 274 // perform any extra clean up such as cached pointers to selected
286 // children, etc. 275 // children, etc.
287 virtual void deleteAllChildren(); 276 virtual void deleteAllChildren();
288 277
289 // by default, does nothing
290 virtual void setTentative(BOOL b); 278 virtual void setTentative(BOOL b);
291 // by default, returns false
292 virtual BOOL getTentative() const; 279 virtual BOOL getTentative() const;
293 virtual void setAllChildrenEnabled(BOOL b); 280 void setAllChildrenEnabled(BOOL b);
294 281
295 virtual void setEnabled(BOOL enabled);
296 virtual void setVisible(BOOL visible); 282 virtual void setVisible(BOOL visible);
297 virtual void setHidden(BOOL hidden); // Never show (replacement text) 283 BOOL getVisible() const { return mVisible; }
284 virtual void setEnabled(BOOL enabled);
285 BOOL getEnabled() const { return mEnabled; }
286 U8 getSoundFlags() const { return mSoundFlags; }
298 287
299 // by default, does nothing and returns false
300 virtual BOOL setLabelArg( const LLString& key, const LLStringExplicit& text ); 288 virtual BOOL setLabelArg( const LLString& key, const LLStringExplicit& text );
301 289
302 virtual void onVisibilityChange ( BOOL curVisibilityIn ); 290 virtual void onVisibilityChange ( BOOL curVisibilityIn );
303 291
304 void pushVisible(BOOL visible) { mLastVisible = mVisible; setVisible(visible); } 292 void pushVisible(BOOL visible) { mLastVisible = mVisible; setVisible(visible); }
305 void popVisible() { setVisible(mLastVisible); mLastVisible = TRUE; } 293 void popVisible() { setVisible(mLastVisible); mLastVisible = TRUE; }
294
295 LLHandle<LLView> getHandle() { mHandle.bind(this); return mHandle; }
306 296
307 //
308 // ACCESSORS
309 //
310 BOOL getMouseOpaque() const { return mMouseOpaque; }
311 297
312 U32 getFollows() const { return mReshapeFlags; } 298 U32 getFollows() const { return mReshapeFlags; }
313 BOOL followsLeft() const { return mReshapeFlags & FOLLOWS_LEFT; } 299 BOOL followsLeft() const { return mReshapeFlags & FOLLOWS_LEFT; }
@@ -318,26 +304,26 @@ public:
318 304
319 const LLRect& getRect() const { return mRect; } 305 const LLRect& getRect() const { return mRect; }
320 const LLRect& getBoundingRect() const { return mBoundingRect; } 306 const LLRect& getBoundingRect() const { return mBoundingRect; }
321 const LLRect getLocalBoundingRect() const; 307 LLRect getLocalBoundingRect() const;
322 const LLRect getScreenRect() const; 308 LLRect getScreenRect() const;
323 const LLRect getLocalRect() const; 309 LLRect getLocalRect() const;
324 virtual const LLRect getSnapRect() const { return mRect; } 310 virtual LLRect getSnapRect() const;
325 virtual const LLRect getLocalSnapRect() const; 311 LLRect getLocalSnapRect() const;
326 312
327 virtual LLRect getRequiredRect(); // Get required size for this object. 0 for width/height means don't care. 313 // Override and return required size for this object. 0 for width/height means don't care.
314 virtual LLRect getRequiredRect();
328 void updateBoundingRect(); 315 void updateBoundingRect();
329 316
330 LLView* getRootView(); 317 LLView* getRootView();
331 LLView* getParent() const { return mParentView; } 318 LLView* getParent() const { return mParentView; }
332 LLView* getFirstChild() { return (mChildList.empty()) ? NULL : *(mChildList.begin()); } 319 LLView* getFirstChild() const { return (mChildList.empty()) ? NULL : *(mChildList.begin()); }
333 S32 getChildCount() const { return (S32)mChildList.size(); } 320 S32 getChildCount() const { return (S32)mChildList.size(); }
334 template<class _Pr3> void sortChildren(_Pr3 _Pred) { mChildList.sort(_Pred); } 321 template<class _Pr3> void sortChildren(_Pr3 _Pred) { mChildList.sort(_Pred); }
335 BOOL hasAncestor(const LLView* parentp); 322 BOOL hasAncestor(const LLView* parentp) const;
336
337 BOOL hasChild(const LLString& childname, BOOL recurse = FALSE) const; 323 BOOL hasChild(const LLString& childname, BOOL recurse = FALSE) const;
338
339 BOOL childHasKeyboardFocus( const LLString& childname ) const; 324 BOOL childHasKeyboardFocus( const LLString& childname ) const;
340 325
326
341 // 327 //
342 // UTILITIES 328 // UTILITIES
343 // 329 //
@@ -345,15 +331,15 @@ public:
345 // Default behavior is to use reshape flags to resize child views 331 // Default behavior is to use reshape flags to resize child views
346 virtual void reshape(S32 width, S32 height, BOOL called_from_parent = TRUE); 332 virtual void reshape(S32 width, S32 height, BOOL called_from_parent = TRUE);
347 virtual void translate( S32 x, S32 y ); 333 virtual void translate( S32 x, S32 y );
348 virtual void setOrigin( S32 x, S32 y ) { mRect.translate( x - mRect.mLeft, y - mRect.mBottom ); } 334 void setOrigin( S32 x, S32 y ) { mRect.translate( x - mRect.mLeft, y - mRect.mBottom ); }
349 BOOL translateIntoRect( const LLRect& constraint, BOOL allow_partial_outside ); 335 BOOL translateIntoRect( const LLRect& constraint, BOOL allow_partial_outside );
336 void centerWithin(const LLRect& bounds);
350 337
351 virtual void userSetShape(const LLRect& new_rect); 338 virtual void userSetShape(const LLRect& new_rect);
352 virtual LLView* findSnapRect(LLRect& new_rect, const LLCoordGL& mouse_dir, LLView::ESnapType snap_type, S32 threshold, S32 padding = 0); 339 virtual LLView* findSnapRect(LLRect& new_rect, const LLCoordGL& mouse_dir, LLView::ESnapType snap_type, S32 threshold, S32 padding = 0);
353 virtual LLView* findSnapEdge(S32& new_edge_val, const LLCoordGL& mouse_dir, ESnapEdge snap_edge, ESnapType snap_type, S32 threshold, S32 padding = 0); 340 virtual LLView* findSnapEdge(S32& new_edge_val, const LLCoordGL& mouse_dir, ESnapEdge snap_edge, ESnapType snap_type, S32 threshold, S32 padding = 0);
354 341
355 // Defaults to other_view->getVisible() 342 virtual BOOL canSnapTo(const LLView* other_view) const;
356 virtual BOOL canSnapTo(LLView* other_view);
357 343
358 virtual void snappedTo(LLView* snap_view); 344 virtual void snappedTo(LLView* snap_view);
359 345
@@ -365,49 +351,97 @@ public:
365 EAcceptance* accept, 351 EAcceptance* accept,
366 LLString& tooltip_msg); 352 LLString& tooltip_msg);
367 353
368 // LLMouseHandler functions
369 // Default behavior is to pass events to children
370
371 /*virtual*/ BOOL handleHover(S32 x, S32 y, MASK mask);
372 /*virtual*/ BOOL handleMouseUp(S32 x, S32 y, MASK mask);
373 /*virtual*/ BOOL handleMouseDown(S32 x, S32 y, MASK mask);
374 /*virtual*/ BOOL handleDoubleClick(S32 x, S32 y, MASK mask);
375 /*virtual*/ BOOL handleScrollWheel(S32 x, S32 y, S32 clicks);
376 /*virtual*/ BOOL handleRightMouseDown(S32 x, S32 y, MASK mask);
377 /*virtual*/ BOOL handleRightMouseUp(S32 x, S32 y, MASK mask);
378 /*virtual*/ void onMouseCaptureLost();
379 /*virtual*/ BOOL hasMouseCapture();
380
381 // Default behavior is to pass the tooltip event to children,
382 // then display mToolTipMsg if no child handled it.
383 /*virtual*/ BOOL handleToolTip(S32 x, S32 y, LLString& msg, LLRect* sticky_rect);
384
385 LLString getShowNamesToolTip(); 354 LLString getShowNamesToolTip();
386 355
387 virtual void draw(); 356 virtual void draw();
388 357
389 void drawDebugRect();
390 void drawChild(LLView* childp, S32 x_offset = 0, S32 y_offset = 0, BOOL force_draw = FALSE);
391
392 virtual const LLString& getName() const;
393
394 virtual EWidgetType getWidgetType() const = 0; 358 virtual EWidgetType getWidgetType() const = 0;
395 virtual LLString getWidgetTag() const = 0; 359 virtual LLString getWidgetTag() const = 0;
396 virtual LLXMLNodePtr getXML(bool save_children = true) const; 360 virtual LLXMLNodePtr getXML(bool save_children = true) const;
397 361
398 static U32 createRect(LLXMLNodePtr node, LLRect &rect, LLView* parent_view, const LLRect &required_rect = LLRect());
399 virtual void initFromXML(LLXMLNodePtr node, LLView* parent); 362 virtual void initFromXML(LLXMLNodePtr node, LLView* parent);
400 void parseFollowsFlags(LLXMLNodePtr node); 363 void parseFollowsFlags(LLXMLNodePtr node);
401 364
365 // Some widgets, like close box buttons, don't need to be saved
366 BOOL getSaveToXML() const { return mSaveToXML; }
367 void setSaveToXML(BOOL b) { mSaveToXML = b; }
368
369 virtual void onFocusLost();
370 virtual void onFocusReceived();
371
372 typedef enum e_hit_test_type
373 {
374 HIT_TEST_USE_BOUNDING_RECT,
375 HIT_TEST_IGNORE_BOUNDING_RECT
376 }EHitTestType;
377
378 BOOL parentPointInView(S32 x, S32 y, EHitTestType type = HIT_TEST_USE_BOUNDING_RECT) const;
379 BOOL pointInView(S32 x, S32 y, EHitTestType type = HIT_TEST_USE_BOUNDING_RECT) const;
380 BOOL blockMouseEvent(S32 x, S32 y) const;
381
382 // See LLMouseHandler virtuals for screenPointToLocal and localPointToScreen
383 BOOL localPointToOtherView( S32 x, S32 y, S32 *other_x, S32 *other_y, LLView* other_view) const;
384 BOOL localRectToOtherView( const LLRect& local, LLRect* other, LLView* other_view ) const;
385 void screenRectToLocal( const LLRect& screen, LLRect* local ) const;
386 void localRectToScreen( const LLRect& local, LLRect* screen ) const;
387
388 // Listener dispatching functions (Dispatcher deletes pointers to listeners on deregistration or destruction)
389 LLSimpleListener* getListenerByName(const LLString &callback_name);
390 void registerEventListener(LLString name, LLSimpleListener* function);
391 void deregisterEventListener(LLString name);
392 LLString findEventListener(LLSimpleListener *listener) const;
393 void addListenerToControl(LLEventDispatcher *observer, const LLString& name, LLSD filter, LLSD userdata);
394
395 void addBoolControl(LLString name, bool initial_value);
396 LLControlBase *getControl(LLString name);
397 LLControlBase *findControl(LLString name);
398
399 void setControlValue(const LLSD& value);
400 virtual void setControlName(const LLString& control, LLView *context);
401 virtual LLString getControlName() const { return mControlName; }
402 virtual bool handleEvent(LLPointer<LLEvent> event, const LLSD& userdata);
403 virtual void setValue(const LLSD& value);
404 virtual LLSD getValue() const;
405
406 const child_list_t* getChildList() const { return &mChildList; }
407
408 // LLMouseHandler functions
409 // Default behavior is to pass events to children
410 /*virtual*/ BOOL handleHover(S32 x, S32 y, MASK mask);
411 /*virtual*/ BOOL handleMouseUp(S32 x, S32 y, MASK mask);
412 /*virtual*/ BOOL handleMouseDown(S32 x, S32 y, MASK mask);
413 /*virtual*/ BOOL handleDoubleClick(S32 x, S32 y, MASK mask);
414 /*virtual*/ BOOL handleScrollWheel(S32 x, S32 y, S32 clicks);
415 /*virtual*/ BOOL handleRightMouseDown(S32 x, S32 y, MASK mask);
416 /*virtual*/ BOOL handleRightMouseUp(S32 x, S32 y, MASK mask);
417 /*virtual*/ BOOL handleToolTip(S32 x, S32 y, LLString& msg, LLRect* sticky_rect); // Display mToolTipMsg if no child handles it.
418 /*virtual*/ const LLString& getName() const;
419 /*virtual*/ void onMouseCaptureLost();
420 /*virtual*/ BOOL hasMouseCapture();
421 /*virtual*/ BOOL isView(); // Hack to support LLFocusMgr
422 /*virtual*/ void screenPointToLocal(S32 screen_x, S32 screen_y, S32* local_x, S32* local_y) const;
423 /*virtual*/ void localPointToScreen(S32 local_x, S32 local_y, S32* screen_x, S32* screen_y) const;
424
425 template <class T> T* getChild(const LLString& name, BOOL recurse = TRUE) const
426 {
427 T* result = dynamic_cast<T*>(getChildByName(name, TRUE));
428 //if (!result)
429 //{
430 // // create dummy widget instance here
431 // result = gUICtrlFactory->createDummyWidget<T>(name);
432 //}
433 return result;
434 }
435
436 // statics
437 static U32 createRect(LLXMLNodePtr node, LLRect &rect, LLView* parent_view, const LLRect &required_rect = LLRect());
438
402 static LLFontGL* selectFont(LLXMLNodePtr node); 439 static LLFontGL* selectFont(LLXMLNodePtr node);
403 static LLFontGL::HAlign selectFontHAlign(LLXMLNodePtr node); 440 static LLFontGL::HAlign selectFontHAlign(LLXMLNodePtr node);
404 static LLFontGL::VAlign selectFontVAlign(LLXMLNodePtr node); 441 static LLFontGL::VAlign selectFontVAlign(LLXMLNodePtr node);
405 static LLFontGL::StyleFlags selectFontStyle(LLXMLNodePtr node); 442 static LLFontGL::StyleFlags selectFontStyle(LLXMLNodePtr node);
406 443
407 // Some widgets, like close box buttons, don't need to be saved 444
408 BOOL getSaveToXML() const { return mSaveToXML; }
409 void setSaveToXML(BOOL b) { mSaveToXML = b; }
410
411 // Only saves color if different from default setting. 445 // Only saves color if different from default setting.
412 static void addColorXML(LLXMLNodePtr node, const LLColor4& color, 446 static void addColorXML(LLXMLNodePtr node, const LLColor4& color,
413 const LLString& xml_name, const LLString& control_name); 447 const LLString& xml_name, const LLString& control_name);
@@ -432,54 +466,17 @@ public:
432 // return query for iterating over focus roots in tab order 466 // return query for iterating over focus roots in tab order
433 static const LLCtrlQuery & getFocusRootsQuery(); 467 static const LLCtrlQuery & getFocusRootsQuery();
434 468
435 BOOL getEnabled() const { return mEnabled; } 469 static BOOL deleteViewByHandle(LLHandle<LLView> handle);
436 BOOL getVisible() const { return mVisible && !mHidden; } 470 static LLWindow* getWindow(void) { return LLUI::sWindow; }
437 U8 getSoundFlags() const { return mSoundFlags; }
438
439 typedef enum e_hit_test_type
440 {
441 HIT_TEST_USE_BOUNDING_RECT,
442 HIT_TEST_IGNORE_BOUNDING_RECT
443 }EHitTestType;
444
445 BOOL parentPointInView(S32 x, S32 y, EHitTestType type = HIT_TEST_USE_BOUNDING_RECT) const;
446 BOOL pointInView(S32 x, S32 y, EHitTestType type = HIT_TEST_USE_BOUNDING_RECT) const;
447 BOOL blockMouseEvent(S32 x, S32 y) const;
448
449 virtual void screenPointToLocal(S32 screen_x, S32 screen_y, S32* local_x, S32* local_y) const;
450 virtual void localPointToScreen(S32 local_x, S32 local_y, S32* screen_x, S32* screen_y) const;
451 virtual BOOL localPointToOtherView( S32 x, S32 y, S32 *other_x, S32 *other_y, LLView* other_view);
452 virtual void screenRectToLocal( const LLRect& screen, LLRect* local ) const;
453 virtual void localRectToScreen( const LLRect& local, LLRect* screen ) const;
454 virtual BOOL localRectToOtherView( const LLRect& local, LLRect* other, LLView* other_view ) const;
455
456
457 static LLWindow* getWindow(void);
458
459 // Listener dispatching functions (Dispatcher deletes pointers to listeners on deregistration or destruction)
460 LLSimpleListener* getListenerByName(const LLString &callback_name);
461 void registerEventListener(LLString name, LLSimpleListener* function);
462 void deregisterEventListener(LLString name);
463 LLString findEventListener(LLSimpleListener *listener) const;
464 void addListenerToControl(LLEventDispatcher *observer, const LLString& name, LLSD filter, LLSD userdata);
465
466 virtual LLView* getChildByName(const LLString& name, BOOL recurse = FALSE) const;
467
468 void addBoolControl(LLString name, bool initial_value);
469 LLControlBase *getControl(LLString name);
470 virtual LLControlBase *findControl(LLString name);
471
472 void setControlValue(const LLSD& value);
473 virtual void setControlName(const LLString& control, LLView *context);
474 virtual LLString getControlName() const;
475 virtual bool handleEvent(LLPointer<LLEvent> event, const LLSD& userdata);
476 virtual void setValue(const LLSD& value);
477 const child_list_t* getChildList() const { return &mChildList; }
478 471
472
479protected: 473protected:
480 virtual BOOL handleKeyHere(KEY key, MASK mask, BOOL called_from_parent); 474 virtual BOOL handleKeyHere(KEY key, MASK mask, BOOL called_from_parent);
481 virtual BOOL handleUnicodeCharHere(llwchar uni_char, BOOL called_from_parent); 475 virtual BOOL handleUnicodeCharHere(llwchar uni_char, BOOL called_from_parent);
482 476
477 void drawDebugRect();
478 void drawChild(LLView* childp, S32 x_offset = 0, S32 y_offset = 0, BOOL force_draw = FALSE);
479
483 LLView* childrenHandleKey(KEY key, MASK mask); 480 LLView* childrenHandleKey(KEY key, MASK mask);
484 LLView* childrenHandleUnicodeChar(llwchar uni_char); 481 LLView* childrenHandleUnicodeChar(llwchar uni_char);
485 LLView* childrenHandleDragAndDrop(S32 x, S32 y, MASK mask, 482 LLView* childrenHandleDragAndDrop(S32 x, S32 y, MASK mask,
@@ -497,15 +494,64 @@ protected:
497 LLView* childrenHandleRightMouseDown(S32 x, S32 y, MASK mask); 494 LLView* childrenHandleRightMouseDown(S32 x, S32 y, MASK mask);
498 LLView* childrenHandleRightMouseUp(S32 x, S32 y, MASK mask); 495 LLView* childrenHandleRightMouseUp(S32 x, S32 y, MASK mask);
499 496
500 typedef std::map<LLString, LLPointer<LLSimpleListener> > dispatch_list_t;
501 dispatch_list_t mDispatchList;
502
503protected:
504 typedef std::map<LLString, LLControlBase*> control_map_t; 497 typedef std::map<LLString, LLControlBase*> control_map_t;
505 control_map_t mFloaterControls; 498 control_map_t mFloaterControls;
506 499
500 virtual LLView* getChildByName(const LLString& name, BOOL recurse = FALSE) const;
501
502private:
503 LLView* mParentView;
504 child_list_t mChildList;
505
506 LLString mName;
507 // location in pixels, relative to surrounding structure, bottom,left=0,0
508 LLRect mRect;
509 LLRect mBoundingRect;
510
511 U32 mReshapeFlags;
512
513 child_tab_order_t mCtrlOrder;
514 S32 mDefaultTabGroup;
515
516 BOOL mEnabled; // Enabled means "accepts input that has an effect on the state of the application."
517 // A disabled view, for example, may still have a scrollbar that responds to mouse events.
518 BOOL mMouseOpaque; // Opaque views handle all mouse events that are over their rect.
519 LLUIString mToolTipMsg; // isNull() is true if none.
520
521 U8 mSoundFlags;
522 BOOL mSaveToXML;
523
524 BOOL mIsFocusRoot;
525 BOOL mUseBoundingRect; // hit test against bounding rectangle that includes all child elements
526
527 LLRootHandle<LLView> mHandle;
528 BOOL mLastVisible;
529
530 BOOL mVisible;
531
532 S32 mNextInsertionOrdinal;
533
534 static LLWindow* sWindow; // All root views must know about their window.
535
536 typedef std::map<LLString, LLPointer<LLSimpleListener> > dispatch_list_t;
537 dispatch_list_t mDispatchList;
538
507 LLString mControlName; 539 LLString mControlName;
508 friend class LLUICtrlFactory; 540
541
542// Just debugging stuff? We should try to hide anything that's not. -MG
543public:
544 static BOOL sDebugRects; // Draw debug rects behind everything.
545 static BOOL sDebugKeys;
546 static S32 sDepth;
547 static BOOL sDebugMouseHandling;
548 static LLString sMouseHandlerMessage;
549 static S32 sSelectID;
550 static BOOL sEditingUI;
551 static LLView* sEditingUIView;
552 static S32 sLastLeftXML;
553 static S32 sLastBottomXML;
554 static BOOL sForceReshape;
509}; 555};
510 556
511 557
@@ -514,12 +560,12 @@ protected:
514class LLCompareByTabOrder 560class LLCompareByTabOrder
515{ 561{
516public: 562public:
517 LLCompareByTabOrder(LLView::child_tab_order_t order); 563 LLCompareByTabOrder(LLView::child_tab_order_t order) : mTabOrder(order) {}
518 virtual ~LLCompareByTabOrder() {} 564 virtual ~LLCompareByTabOrder() {}
519 bool operator() (const LLView* const a, const LLView* const b) const; 565 bool operator() (const LLView* const a, const LLView* const b) const;
520protected: 566private:
521 virtual bool compareTabOrders(const LLView::tab_order_t & a, const LLView::tab_order_t & b) const; 567 virtual bool compareTabOrders(const LLView::tab_order_t & a, const LLView::tab_order_t & b) const { return a < b; }
522 LLView::child_tab_order_t mTabOrder; 568 LLView::child_tab_order_t mTabOrder;
523}; 569};
524 570
525#endif 571#endif //LL_LLVIEW_H