00001
00032 #ifndef LL_LLSCROLLCONTAINER_H
00033 #define LL_LLSCROLLCONTAINER_H
00034
00035 #include "lluictrl.h"
00036 #ifndef LL_V4COLOR_H
00037 #include "v4color.h"
00038 #endif
00039 #include "stdenums.h"
00040 #include "llcoord.h"
00041 #include "llscrollbar.h"
00042
00043
00044
00045
00046
00047
00048
00049
00050
00051
00052
00053
00054 class LLViewBorder;
00055 class LLUICtrlFactory;
00056
00057
00058 class LLScrollableContainerView : public LLUICtrl
00059 {
00060 public:
00061
00062
00063 enum SCROLL_ORIENTATION { VERTICAL, HORIZONTAL, SCROLLBAR_COUNT };
00064
00065 LLScrollableContainerView( const LLString& name, const LLRect& rect,
00066 LLView* scrolled_view, BOOL is_opaque = FALSE,
00067 const LLColor4& bg_color = LLColor4(0,0,0,0) );
00068 LLScrollableContainerView( const LLString& name, const LLRect& rect,
00069 LLUICtrl* scrolled_ctrl, BOOL is_opaque = FALSE,
00070 const LLColor4& bg_color = LLColor4(0,0,0,0) );
00071 virtual ~LLScrollableContainerView( void );
00072
00073 void init();
00074
00075 void setScrolledView(LLView* view) { mScrolledView = view; }
00076
00077 virtual void setValue(const LLSD& value) { mInnerRect.setValue(value); }
00078 virtual EWidgetType getWidgetType() const { return WIDGET_TYPE_SCROLL_CONTAINER; }
00079 virtual LLString getWidgetTag() const { return LL_SCROLLABLE_CONTAINER_VIEW_TAG; }
00080
00081
00082 static void horizontalChange( S32 new_pos, LLScrollbar* sb, void* user_data );
00083 static void verticalChange( S32 new_pos, LLScrollbar* sb, void* user_data );
00084
00085 void calcVisibleSize( S32 *visible_width, S32 *visible_height, BOOL* show_h_scrollbar, BOOL* show_v_scrollbar );
00086 void calcVisibleSize( const LLRect& doc_rect, S32 *visible_width, S32 *visible_height, BOOL* show_h_scrollbar, BOOL* show_v_scrollbar );
00087 void setBorderVisible( BOOL b );
00088
00089 void scrollToShowRect( const LLRect& rect, const LLCoordGL& desired_offset );
00090 void setReserveScrollCorner( BOOL b ) { mReserveScrollCorner = b; }
00091 const LLRect& getScrolledViewRect() { return mScrolledView->getRect(); }
00092 void pageUp(S32 overlap = 0);
00093 void pageDown(S32 overlap = 0);
00094 void goToTop();
00095 void goToBottom();
00096 S32 getBorderWidth();
00097
00098 BOOL needsToScroll(S32 x, S32 y, SCROLL_ORIENTATION axis);
00099
00100
00101 virtual void reshape(S32 width, S32 height, BOOL called_from_parent);
00102 virtual BOOL handleKey(KEY key, MASK mask, BOOL called_from_parent);
00103 virtual BOOL handleScrollWheel( S32 x, S32 y, S32 clicks );
00104 virtual BOOL handleDragAndDrop(S32 x, S32 y, MASK mask, BOOL drop,
00105 EDragAndDropType cargo_type,
00106 void* cargo_data,
00107 EAcceptance* accept,
00108 LLString& tooltip_msg);
00109
00110 virtual BOOL handleToolTip(S32 x, S32 y, LLString& msg, LLRect* sticky_rect);
00111 virtual void draw();
00112
00113 virtual LLXMLNodePtr getXML(bool save_children = true) const;
00114 static LLView* fromXML(LLXMLNodePtr node, LLView *parent, LLUICtrlFactory *factory);
00115
00116 protected:
00117
00118 virtual void scrollHorizontal( S32 new_pos );
00119 virtual void scrollVertical( S32 new_pos );
00120 void updateScroll();
00121
00122 LLScrollbar* mScrollbar[SCROLLBAR_COUNT];
00123 LLView* mScrolledView;
00124 S32 mSize;
00125 BOOL mIsOpaque;
00126 LLColor4 mBackgroundColor;
00127 LLRect mInnerRect;
00128 LLViewBorder* mBorder;
00129 BOOL mReserveScrollCorner;
00130 BOOL mAutoScrolling;
00131 F32 mAutoScrollRate;
00132 };
00133
00134
00135 #endif // LL_LLSCROLLCONTAINER_H