llmultisliderctrl.h

Go to the documentation of this file.
00001 
00032 #ifndef LL_MULTI_SLIDERCTRL_H
00033 #define LL_MULTI_SLIDERCTRL_H
00034 
00035 #include "lluictrl.h"
00036 #include "v4color.h"
00037 #include "llmultislider.h"
00038 #include "lltextbox.h"
00039 #include "llrect.h"
00040 
00041 //
00042 // Constants
00043 //
00044 const S32       MULTI_SLIDERCTRL_SPACING        =  4;                   // space between label, slider, and text
00045 const S32       MULTI_SLIDERCTRL_HEIGHT         =  16;
00046 
00047 //
00048 // Classes
00049 //
00050 class LLFontGL;
00051 class LLLineEditor;
00052 class LLSlider;
00053 
00054 
00055 class LLMultiSliderCtrl : public LLUICtrl
00056 {
00057 public:
00058         LLMultiSliderCtrl(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                 void (*commit_callback)(LLUICtrl*, void*),
00067                 void* callback_userdata,
00068                 F32 initial_value, F32 min_value, F32 max_value, F32 increment,
00069                 S32 max_sliders, BOOL allow_overlap, BOOL draw_track,
00070                 BOOL use_triangle,
00071                 const LLString& control_which = LLString::null );
00072 
00073         virtual ~LLMultiSliderCtrl();
00074         virtual LLXMLNodePtr getXML(bool save_children = true) const;
00075         static LLView* fromXML(LLXMLNodePtr node, LLView *parent, LLUICtrlFactory *factory);
00076 
00077         F32                             getSliderValue(const LLString& name) const;
00078         void                    setSliderValue(const LLString& name, F32 v, BOOL from_event = FALSE);
00079 
00080         virtual void    setValue(const LLSD& value );
00081         virtual LLSD    getValue() const                { return mMultiSlider->getValue(); }
00082         virtual BOOL    setLabelArg( const LLString& key, const LLStringExplicit& text );
00083 
00084         const LLString& getCurSlider() const                                    { return mMultiSlider->getCurSlider(); }
00085         F32                             getCurSliderValue() const                               { return mCurValue; }
00086         void                    setCurSlider(const LLString& name);             
00087         void                    setCurSliderValue(F32 val, BOOL from_event = false) { setSliderValue(mMultiSlider->getCurSlider(), val, from_event); }
00088 
00089         virtual void    setMinValue(LLSD min_value)     { setMinValue((F32)min_value.asReal()); }
00090         virtual void    setMaxValue(LLSD max_value)     { setMaxValue((F32)max_value.asReal());  }
00091 
00092         BOOL                    isMouseHeldDown();
00093 
00094         virtual void    setEnabled( BOOL b );
00095         virtual void    clear();
00096         virtual void    setPrecision(S32 precision);
00097         void                    setMinValue(F32 min_value) {mMultiSlider->setMinValue(min_value);}
00098         void                    setMaxValue(F32 max_value) {mMultiSlider->setMaxValue(max_value);}
00099         void                    setIncrement(F32 increment) {mMultiSlider->setIncrement(increment);}
00100 
00102         const LLString& addSlider();
00103         const LLString& addSlider(F32 val);
00104         void                    deleteSlider(const LLString& name);
00105         void                    deleteCurSlider()                       { deleteSlider(mMultiSlider->getCurSlider()); }
00106 
00107         F32                             getMinValue() { return mMultiSlider->getMinValue(); }
00108         F32                             getMaxValue() { return mMultiSlider->getMaxValue(); }
00109 
00110         void                    setLabel(const LLString& label)                         { if (mLabelBox) mLabelBox->setText(label); }
00111         void                    setLabelColor(const LLColor4& c)                        { mTextEnabledColor = c; }
00112         void                    setDisabledLabelColor(const LLColor4& c)        { mTextDisabledColor = c; }
00113 
00114         void                    setSliderMouseDownCallback(     void (*slider_mousedown_callback)(LLUICtrl* caller, void* userdata) );
00115         void                    setSliderMouseUpCallback(       void (*slider_mouseup_callback)(LLUICtrl* caller, void* userdata) );
00116 
00117         virtual void    onTabInto();
00118 
00119         virtual void    setTentative(BOOL b);                   // marks value as tentative
00120         virtual void    onCommit();                                             // mark not tentative, then commit
00121 
00122         virtual void            setControlName(const LLString& control_name, LLView* context);
00123         virtual LLString        getControlName() const;
00124         
00125         static void             onSliderCommit(LLUICtrl* caller, void* userdata);
00126         static void             onSliderMouseDown(LLUICtrl* caller,void* userdata);
00127         static void             onSliderMouseUp(LLUICtrl* caller,void* userdata);
00128 
00129         static void             onEditorCommit(LLUICtrl* caller, void* userdata);
00130         static void             onEditorGainFocus(LLFocusableElement* caller, void *userdata);
00131         static void             onEditorChangeFocus(LLUICtrl* caller, S32 direction, void *userdata);
00132 
00133 private:
00134         void                    updateText();
00135         void                    reportInvalidData();
00136 
00137 private:
00138         const LLFontGL* mFont;
00139         BOOL                    mShowText;
00140         BOOL                    mCanEditText;
00141 
00142         S32                             mPrecision;
00143         LLTextBox*              mLabelBox;
00144         S32                             mLabelWidth;
00145 
00146         F32                             mCurValue;
00147         LLMultiSlider*  mMultiSlider;
00148         LLLineEditor*   mEditor;
00149         LLTextBox*              mTextBox;
00150 
00151         LLColor4                mTextEnabledColor;
00152         LLColor4                mTextDisabledColor;
00153 
00154         void                    (*mSliderMouseUpCallback)( LLUICtrl* ctrl, void* userdata );
00155         void                    (*mSliderMouseDownCallback)( LLUICtrl* ctrl, void* userdata );
00156 };
00157 
00158 #endif  // LL_MULTI_SLIDERCTRL_H

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