llscrollbar.h

Go to the documentation of this file.
00001 
00032 #ifndef LL_SCROLLBAR_H
00033 #define LL_SCROLLBAR_H
00034 
00035 #include "stdtypes.h"
00036 #include "lluictrl.h"
00037 #include "v4color.h"
00038 
00039 //
00040 // Constants
00041 //
00042 const S32 SCROLLBAR_SIZE = 16;
00043 
00044 
00045 //
00046 // Classes
00047 //
00048 class LLScrollbar
00049 : public LLUICtrl
00050 {
00051 public:
00052         enum ORIENTATION { HORIZONTAL, VERTICAL };
00053 
00054         LLScrollbar(const LLString& name, LLRect rect,
00055                 ORIENTATION orientation,
00056                 S32 doc_size, S32 doc_pos, S32 page_size,
00057                 void(*change_callback)( S32 new_pos, LLScrollbar* self, void* userdata ),
00058                 void* callback_user_data = NULL,
00059                 S32 step_size = 1);
00060 
00061         virtual ~LLScrollbar();
00062 
00063         virtual void setValue(const LLSD& value);
00064         virtual EWidgetType getWidgetType() const;
00065         virtual LLString getWidgetTag() const;
00066 
00067         // Overrides from LLView
00068         virtual BOOL    handleKeyHere(KEY key, MASK mask, BOOL called_from_parent);
00069         virtual BOOL    handleMouseDown(S32 x, S32 y, MASK mask);
00070         virtual BOOL    handleMouseUp(S32 x, S32 y, MASK mask);
00071         virtual BOOL    handleHover(S32 x, S32 y, MASK mask);
00072         virtual BOOL    handleScrollWheel(S32 x, S32 y, S32 clicks);
00073         virtual BOOL    handleDragAndDrop(S32 x, S32 y, MASK mask, BOOL drop, 
00074                 EDragAndDropType cargo_type, void *carge_data, EAcceptance *accept, LLString &tooltip_msg);
00075 
00076         virtual void    reshape(S32 width, S32 height, BOOL called_from_parent = TRUE);
00077 
00078         virtual void    draw();
00079 
00080         void                            setDocParams( S32 size, S32 pos );
00081 
00082         // How long the "document" is.
00083         void                            setDocSize( S32 size );
00084         S32                                     getDocSize()                    { return mDocSize; }
00085 
00086         // How many "lines" the "document" has scrolled.
00087         // 0 <= DocPos <= DocSize - DocVisibile
00088         void                            setDocPos( S32 pos );
00089         S32                                     getDocPos()                             { return mDocPos; }
00090 
00091         // How many "lines" of the "document" is can appear on a page.
00092         void                            setPageSize( S32 page_size );
00093         S32                                     getPageSize()                   { return mPageSize; }
00094         
00095         // The farthest the document can be scrolled (top of the last page).
00096         S32                                     getDocPosMax()                  { return llmax( 0, mDocSize - mPageSize); }
00097 
00098         void                            pageUp(S32 overlap);
00099         void                            pageDown(S32 overlap);
00100 
00101         static void                     onLineUpBtnPressed(void* userdata);
00102         static void                     onLineDownBtnPressed(void* userdata);
00103 
00104         void setTrackColor( const LLColor4& color ) { mTrackColor = color; }
00105         void setThumbColor( const LLColor4& color ) { mThumbColor = color; }
00106         void setHighlightColor( const LLColor4& color ) { mHighlightColor = color; }
00107         void setShadowColor( const LLColor4& color ) { mShadowColor = color; }
00108 
00109         void setOnScrollEndCallback(void (*callback)(void*), void* userdata) { mOnScrollEndCallback = callback; mOnScrollEndData = userdata;}
00110 protected:
00111         void                            updateThumbRect();
00112         void                            changeLine(S32 delta, BOOL update_thumb );
00113 
00114 protected:
00115         void                            (*mChangeCallback)( S32 new_pos, LLScrollbar* self, void* userdata );
00116         void*                           mCallbackUserData;
00117 
00118         ORIENTATION                     mOrientation;   
00119         S32                                     mDocSize;               // Size of the document that the scrollbar is modeling.  Units depend on the user.  0 <= mDocSize.
00120         S32                                     mDocPos;                // Position within the doc that the scrollbar is modeling, in "lines" (user size)
00121         S32                                     mPageSize;              // Maximum number of lines that can be seen at one time.
00122         S32                                     mStepSize;
00123         BOOL                            mDocChanged;
00124 
00125         LLRect                          mThumbRect;
00126         S32                                     mDragStartX;
00127         S32                                     mDragStartY;
00128         F32                                     mHoverGlowStrength;
00129         F32                                     mCurGlowStrength;
00130 
00131         LLRect                          mOrigRect;
00132         S32                                     mLastDelta;
00133 
00134         LLColor4                        mTrackColor;
00135         LLColor4                        mThumbColor;
00136         LLColor4                        mFocusColor;
00137         LLColor4                        mHighlightColor;
00138         LLColor4                        mShadowColor;
00139 
00140         void                    (*mOnScrollEndCallback)(void*);
00141         void                    *mOnScrollEndData;
00142 };
00143 
00144 
00145 
00146 #endif  // LL_SCROLLBAR_H

Generated on Thu Jul 1 06:09:05 2010 for Second Life Viewer by  doxygen 1.4.7