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 
00065         // Overrides from LLView
00066         virtual BOOL    handleKeyHere(KEY key, MASK mask);
00067         virtual BOOL    handleMouseDown(S32 x, S32 y, MASK mask);
00068         virtual BOOL    handleMouseUp(S32 x, S32 y, MASK mask);
00069         virtual BOOL    handleHover(S32 x, S32 y, MASK mask);
00070         virtual BOOL    handleScrollWheel(S32 x, S32 y, S32 clicks);
00071         virtual BOOL    handleDragAndDrop(S32 x, S32 y, MASK mask, BOOL drop, 
00072                 EDragAndDropType cargo_type, void *cargo_data, EAcceptance *accept, LLString &tooltip_msg);
00073 
00074         virtual void    reshape(S32 width, S32 height, BOOL called_from_parent = TRUE);
00075 
00076         virtual void    draw();
00077 
00078         // How long the "document" is.
00079         void                            setDocSize( S32 size );
00080         S32                                     getDocSize() const              { return mDocSize; }
00081 
00082         // How many "lines" the "document" has scrolled.
00083         // 0 <= DocPos <= DocSize - DocVisibile
00084         void                            setDocPos( S32 pos );
00085         S32                                     getDocPos() const               { return mDocPos; }
00086 
00087         BOOL                            isAtBeginning();
00088         BOOL                            isAtEnd();
00089 
00090         // Setting both at once.
00091         void                            setDocParams( S32 size, S32 pos );
00092 
00093         // How many "lines" of the "document" is can appear on a page.
00094         void                            setPageSize( S32 page_size );
00095         S32                                     getPageSize() const             { return mPageSize; }
00096         
00097         // The farthest the document can be scrolled (top of the last page).
00098         S32                                     getDocPosMax() const    { return llmax( 0, mDocSize - mPageSize); }
00099 
00100         void                            pageUp(S32 overlap);
00101         void                            pageDown(S32 overlap);
00102 
00103         static void                     onLineUpBtnPressed(void* userdata);
00104         static void                     onLineDownBtnPressed(void* userdata);
00105 
00106         void setTrackColor( const LLColor4& color ) { mTrackColor = color; }
00107         void setThumbColor( const LLColor4& color ) { mThumbColor = color; }
00108         void setHighlightColor( const LLColor4& color ) { mHighlightColor = color; }
00109         void setShadowColor( const LLColor4& color ) { mShadowColor = color; }
00110 
00111         void setOnScrollEndCallback(void (*callback)(void*), void* userdata) { mOnScrollEndCallback = callback; mOnScrollEndData = userdata;}
00112 
00113 private:
00114         void                            updateThumbRect();
00115         void                            changeLine(S32 delta, BOOL update_thumb );
00116 
00117         void                            (*mChangeCallback)( S32 new_pos, LLScrollbar* self, void* userdata );
00118         void*                           mCallbackUserData;
00119 
00120         const ORIENTATION       mOrientation;   
00121         S32                                     mDocSize;               // Size of the document that the scrollbar is modeling.  Units depend on the user.  0 <= mDocSize.
00122         S32                                     mDocPos;                // Position within the doc that the scrollbar is modeling, in "lines" (user size)
00123         S32                                     mPageSize;              // Maximum number of lines that can be seen at one time.
00124         S32                                     mStepSize;
00125         BOOL                            mDocChanged;
00126 
00127         LLRect                          mThumbRect;
00128         S32                                     mDragStartX;
00129         S32                                     mDragStartY;
00130         F32                                     mHoverGlowStrength;
00131         F32                                     mCurGlowStrength;
00132 
00133         LLRect                          mOrigRect;
00134         S32                                     mLastDelta;
00135 
00136         LLColor4                        mTrackColor;
00137         LLColor4                        mThumbColor;
00138         LLColor4                        mFocusColor;
00139         LLColor4                        mHighlightColor;
00140         LLColor4                        mShadowColor;
00141 
00142         void                    (*mOnScrollEndCallback)(void*);
00143         void                    *mOnScrollEndData;
00144 };
00145 
00146 
00147 
00148 #endif  // LL_SCROLLBAR_H

Generated on Fri May 16 08:32:56 2008 for SecondLife by  doxygen 1.5.5