lldraghandle.h

Go to the documentation of this file.
00001 
00032 // A widget for dragging a view around the screen using the mouse.
00033 
00034 #ifndef LL_DRAGHANDLE_H
00035 #define LL_DRAGHANDLE_H
00036 
00037 #include "llview.h"
00038 #include "v4color.h"
00039 #include "llrect.h"
00040 #include "llcoord.h"
00041 
00042 class LLTextBox;
00043 
00044 class LLDragHandle : public LLView
00045 {
00046 public:
00047         LLDragHandle(const LLString& name, const LLRect& rect, const LLString& title );
00048         virtual ~LLDragHandle() { setTitleBox(NULL); }
00049 
00050         virtual void setValue(const LLSD& value);
00051 
00052         void                    setForeground(BOOL b)           { mForeground = b; }
00053         BOOL                    getForeground() const           { return mForeground; }
00054         void                    setMaxTitleWidth(S32 max_width) {mMaxTitleWidth = llmin(max_width, mMaxTitleWidth); }
00055         S32                             getMaxTitleWidth() const { return mMaxTitleWidth; }
00056         void                    setTitleVisible(BOOL visible);
00057 
00058         virtual void    setTitle( const LLString& title ) = 0;
00059         virtual const LLString& getTitle() const = 0;
00060 
00061         virtual BOOL    handleHover(S32 x, S32 y, MASK mask);
00062         virtual BOOL    handleMouseDown(S32 x, S32 y, MASK mask);
00063         virtual BOOL    handleMouseUp(S32 x, S32 y, MASK mask);
00064 
00065 protected:
00066         LLTextBox*              getTitleBox() const { return mTitleBox; }
00067         void                    setTitleBox(LLTextBox*);
00068 
00069 private:
00070         S32                             mDragLastScreenX;
00071         S32                             mDragLastScreenY;
00072         S32                             mLastMouseScreenX;
00073         S32                             mLastMouseScreenY;
00074         LLCoordGL               mLastMouseDir;
00075         LLColor4                mDragHighlightColor;
00076         LLColor4                mDragShadowColor;
00077         LLTextBox*              mTitleBox;
00078         S32                             mMaxTitleWidth;
00079         BOOL                    mForeground;
00080 
00081         // Pixels near the edge to snap floaters.
00082         static S32              sSnapMargin;
00083 };
00084 
00085 
00086 // Use this one for traditional top-of-window draggers
00087 class LLDragHandleTop
00088 : public LLDragHandle
00089 {
00090 public:
00091         LLDragHandleTop(const LLString& name, const LLRect& rect, const LLString& title );
00092 
00093         virtual void    setTitle( const LLString& title );
00094         virtual const LLString& getTitle() const;
00095         virtual void    draw();
00096         virtual void    reshape(S32 width, S32 height, BOOL called_from_parent = TRUE);
00097 
00098 private:
00099         void    reshapeTitleBox();
00100 };
00101 
00102 
00103 // Use this for left-side, vertical text draggers
00104 class LLDragHandleLeft
00105 : public LLDragHandle
00106 {
00107 public:
00108         LLDragHandleLeft(const LLString& name, const LLRect& rect, const LLString& title );
00109 
00110         virtual void    setTitle( const LLString& title );
00111         virtual const LLString& getTitle() const;
00112         virtual void    draw();
00113         virtual void    reshape(S32 width, S32 height, BOOL called_from_parent = TRUE);
00114 
00115 };
00116 
00117 const S32 DRAG_HANDLE_HEIGHT = 16;
00118 const S32 DRAG_HANDLE_WIDTH = 16;
00119 
00120 #endif  // LL_DRAGHANDLE_H

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