llsliderctrl.h

Go to the documentation of this file.
00001 
00032 #ifndef LL_LLSLIDERCTRL_H
00033 #define LL_LLSLIDERCTRL_H
00034 
00035 #include "lluictrl.h"
00036 #include "v4color.h"
00037 #include "llslider.h"
00038 #include "lltextbox.h"
00039 #include "llrect.h"
00040 
00041 //
00042 // Constants
00043 //
00044 const S32       SLIDERCTRL_SPACING              =  4;                           // space between label, slider, and text
00045 const S32       SLIDERCTRL_HEIGHT               =  16;
00046 
00047 //
00048 // Classes
00049 //
00050 class LLFontGL;
00051 class LLLineEditor;
00052 class LLSlider;
00053 
00054 
00055 class LLSliderCtrl : public LLUICtrl
00056 {
00057 public:
00058         LLSliderCtrl(const LLString& name, 
00059                 const LLRect& rect, 
00060                 const LLString& label, 
00061                 const LLFontGL* font,
00062                 S32 slider_left,
00063                 S32 text_left,
00064                 BOOL show_text,
00065                 BOOL can_edit_text,
00066                 BOOL volume,             
00067                 void (*commit_callback)(LLUICtrl*, void*),
00068                 void* callback_userdata,
00069                 F32 initial_value, F32 min_value, F32 max_value, F32 increment,
00070                 const LLString& control_which = LLString::null );
00071 
00072         virtual ~LLSliderCtrl();
00073         virtual EWidgetType getWidgetType() const { return WIDGET_TYPE_SLIDER; }
00074         virtual LLString getWidgetTag() const { return LL_SLIDER_CTRL_TAG; }
00075         virtual LLXMLNodePtr getXML(bool save_children = true) const;
00076         static LLView* fromXML(LLXMLNodePtr node, LLView *parent, LLUICtrlFactory *factory);
00077 
00078         F32                             getValueF32() const;
00079         void                    setValue(F32 v, BOOL from_event = FALSE);
00080 
00081         virtual void    setValue(const LLSD& value )    { setValue((F32)value.asReal(), TRUE); }
00082         virtual LLSD    getValue() const                { return LLSD(getValueF32()); }
00083         virtual BOOL    setLabelArg( const LLString& key, const LLStringExplicit& text );
00084 
00085         virtual void    setMinValue(LLSD min_value)     { setMinValue((F32)min_value.asReal()); }
00086         virtual void    setMaxValue(LLSD max_value)     { setMaxValue((F32)max_value.asReal());  }
00087 
00088         BOOL                    isMouseHeldDown();
00089 
00090         virtual void    setEnabled( BOOL b );
00091         virtual void    clear();
00092         virtual void    setPrecision(S32 precision);
00093         void                    setMinValue(F32 min_value) {mSlider->setMinValue(min_value);}
00094         void                    setMaxValue(F32 max_value) {mSlider->setMaxValue(max_value);}
00095         void                    setIncrement(F32 increment) {mSlider->setIncrement(increment);}
00096 
00097         F32                             getMinValue() { return mSlider->getMinValue(); }
00098         F32                             getMaxValue() { return mSlider->getMaxValue(); }
00099 
00100         void                    setLabel(const LLStringExplicit& label)                         { if (mLabelBox) mLabelBox->setText(label); }
00101         void                    setLabelColor(const LLColor4& c)                        { mTextEnabledColor = c; }
00102         void                    setDisabledLabelColor(const LLColor4& c)        { mTextDisabledColor = c; }
00103 
00104         void                    setSliderMouseDownCallback(     void (*slider_mousedown_callback)(LLUICtrl* caller, void* userdata) );
00105         void                    setSliderMouseUpCallback(       void (*slider_mouseup_callback)(LLUICtrl* caller, void* userdata) );
00106 
00107         virtual void    onTabInto();
00108 
00109         virtual void    setTentative(BOOL b);                   // marks value as tentative
00110         virtual void    onCommit();                                             // mark not tentative, then commit
00111 
00112         virtual void            setControlName(const LLString& control_name, LLView* context);
00113         virtual LLString        getControlName() const;
00114         
00115         static void             onSliderCommit(LLUICtrl* caller, void* userdata);
00116         static void             onSliderMouseDown(LLUICtrl* caller,void* userdata);
00117         static void             onSliderMouseUp(LLUICtrl* caller,void* userdata);
00118 
00119         static void             onEditorCommit(LLUICtrl* caller, void* userdata);
00120         static void             onEditorGainFocus(LLUICtrl* caller, void *userdata);
00121         static void             onEditorChangeFocus(LLUICtrl* caller, S32 direction, void *userdata);
00122 
00123 private:
00124         void                    updateText();
00125         void                    reportInvalidData();
00126 
00127 private:
00128         const LLFontGL* mFont;
00129         BOOL                    mShowText;
00130         BOOL                    mCanEditText;
00131         BOOL                    mVolumeSlider;
00132         
00133         S32                             mPrecision;
00134         LLTextBox*              mLabelBox;
00135         S32                             mLabelWidth;
00136         
00137         F32                             mValue;
00138         LLSlider*               mSlider;
00139         LLLineEditor*   mEditor;
00140         LLTextBox*              mTextBox;
00141 
00142         LLColor4                mTextEnabledColor;
00143         LLColor4                mTextDisabledColor;
00144 
00145         void                    (*mSliderMouseUpCallback)( LLUICtrl* ctrl, void* userdata );
00146         void                    (*mSliderMouseDownCallback)( LLUICtrl* ctrl, void* userdata );
00147 };
00148 
00149 #endif  // LL_LLSLIDERCTRL_H

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