PageRenderTime 17ms CodeModel.GetById 2ms app.highlight 12ms RepoModel.GetById 1ms app.codeStats 0ms

/indra/llui/llscrollcontainer.h

https://bitbucket.org/lindenlab/viewer-beta/
C++ Header | 142 lines | 82 code | 22 blank | 38 comment | 0 complexity | 4668b0229179bc9e0eb5a66405ddc728 MD5 | raw file
  1/** 
  2 * @file llscrollcontainer.h
  3 * @brief LLScrollContainer class header file.
  4 *
  5 * $LicenseInfo:firstyear=2001&license=viewerlgpl$
  6 * Second Life Viewer Source Code
  7 * Copyright (C) 2010, Linden Research, Inc.
  8 * 
  9 * This library is free software; you can redistribute it and/or
 10 * modify it under the terms of the GNU Lesser General Public
 11 * License as published by the Free Software Foundation;
 12 * version 2.1 of the License only.
 13 * 
 14 * This library is distributed in the hope that it will be useful,
 15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 17 * Lesser General Public License for more details.
 18 * 
 19 * You should have received a copy of the GNU Lesser General Public
 20 * License along with this library; if not, write to the Free Software
 21 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
 22 * 
 23 * Linden Research, Inc., 945 Battery Street, San Francisco, CA  94111  USA
 24 * $/LicenseInfo$
 25 */
 26
 27#ifndef LL_LLSCROLLCONTAINER_H
 28#define LL_LLSCROLLCONTAINER_H
 29
 30#include "lluictrl.h"
 31#ifndef LL_V4COLOR_H
 32#include "v4color.h"
 33#endif
 34#include "stdenums.h"
 35#include "llcoord.h"
 36#include "llscrollbar.h"
 37
 38
 39class LLViewBorder;
 40class LLUICtrlFactory;
 41
 42/*****************************************************************************
 43 * 
 44 * A decorator view class meant to encapsulate a clipped region which is
 45 * scrollable. It automatically takes care of pixel perfect scrolling
 46 * and cliipping, as well as turning the scrollbars on or off based on
 47 * the width and height of the view you're scrolling.
 48 *
 49 *****************************************************************************/
 50
 51struct ScrollContainerRegistry : public LLChildRegistry<ScrollContainerRegistry>
 52{};
 53
 54class LLScrollContainer : public LLUICtrl
 55{
 56public:
 57	// Note: vertical comes before horizontal because vertical
 58	// scrollbars have priority for mouse and keyboard events.
 59	enum SCROLL_ORIENTATION { VERTICAL, HORIZONTAL, SCROLLBAR_COUNT };
 60
 61	struct Params : public LLInitParam::Block<Params, LLUICtrl::Params>
 62	{
 63		Optional<bool>		is_opaque,
 64							reserve_scroll_corner,
 65							border_visible,
 66							hide_scrollbar;
 67		Optional<F32>		min_auto_scroll_rate,
 68							max_auto_scroll_rate;
 69		Optional<LLUIColor>	bg_color;
 70		Optional<LLScrollbar::callback_t> scroll_callback;
 71		
 72		Params();
 73	};
 74
 75	// my valid children are stored in this registry
 76 	typedef ScrollContainerRegistry child_registry_t;
 77
 78protected:
 79	LLScrollContainer(const Params&);
 80	friend class LLUICtrlFactory;
 81public:
 82	virtual ~LLScrollContainer( void );
 83
 84	virtual void 	setValue(const LLSD& value) { mInnerRect.setValue(value); }
 85
 86	void			setBorderVisible( BOOL b );
 87
 88	void			scrollToShowRect( const LLRect& rect, const LLRect& constraint);
 89	void			scrollToShowRect( const LLRect& rect) { scrollToShowRect(rect, LLRect(0, mInnerRect.getHeight(), mInnerRect.getWidth(), 0)); }
 90
 91	void			setReserveScrollCorner( BOOL b ) { mReserveScrollCorner = b; }
 92	LLRect			getVisibleContentRect();
 93	LLRect			getContentWindowRect();
 94	const LLRect&	getScrolledViewRect() const { return mScrolledView ? mScrolledView->getRect() : LLRect::null; }
 95	void			pageUp(S32 overlap = 0);
 96	void			pageDown(S32 overlap = 0);
 97	void			goToTop();
 98	void			goToBottom();
 99	bool			isAtTop() { return mScrollbar[VERTICAL]->isAtBeginning(); }
100	bool			isAtBottom() { return mScrollbar[VERTICAL]->isAtEnd(); }
101	S32				getBorderWidth() const;
102
103	// LLView functionality
104	virtual void	reshape(S32 width, S32 height, BOOL called_from_parent = TRUE);
105	virtual BOOL	handleKeyHere(KEY key, MASK mask);
106	virtual BOOL	handleUnicodeCharHere(llwchar uni_char);
107	virtual BOOL	handleScrollWheel( S32 x, S32 y, S32 clicks );
108	virtual BOOL	handleDragAndDrop(S32 x, S32 y, MASK mask, BOOL drop,
109								   EDragAndDropType cargo_type,
110								   void* cargo_data,
111								   EAcceptance* accept,
112								   std::string& tooltip_msg);
113
114	virtual void	draw();
115	virtual bool	addChild(LLView* view, S32 tab_group = 0);
116	
117	bool autoScroll(S32 x, S32 y);
118
119private:
120	// internal scrollbar handlers
121	virtual void scrollHorizontal( S32 new_pos );
122	virtual void scrollVertical( S32 new_pos );
123	void updateScroll();
124	void calcVisibleSize( S32 *visible_width, S32 *visible_height, BOOL* show_h_scrollbar, BOOL* show_v_scrollbar ) const;
125
126	LLScrollbar* mScrollbar[SCROLLBAR_COUNT];
127	LLView*		mScrolledView;
128	S32			mSize;
129	BOOL		mIsOpaque;
130	LLUIColor	mBackgroundColor;
131	LLRect		mInnerRect;
132	LLViewBorder* mBorder;
133	BOOL		mReserveScrollCorner;
134	BOOL		mAutoScrolling;
135	F32			mAutoScrollRate;
136	F32			mMinAutoScrollRate;
137	F32			mMaxAutoScrollRate;
138	bool		mHideScrollbar;
139};
140
141
142#endif // LL_LLSCROLLCONTAINER_H