llcheckboxctrl.h

Go to the documentation of this file.
00001 
00032 #ifndef LL_LLCHECKBOXCTRL_H
00033 #define LL_LLCHECKBOXCTRL_H
00034 
00035 
00036 #include "stdtypes.h"
00037 #include "lluictrl.h"
00038 #include "llbutton.h"
00039 #include "v4color.h"
00040 #include "llrect.h"
00041 
00042 //
00043 // Constants
00044 //
00045 const S32 LLCHECKBOXCTRL_BTN_SIZE = 13;
00046 const S32 LLCHECKBOXCTRL_VPAD = 2;
00047 const S32 LLCHECKBOXCTRL_HPAD = 2;
00048 const S32 LLCHECKBOXCTRL_SPACING = 5;
00049 const S32 LLCHECKBOXCTRL_HEIGHT = 16;
00050 
00051 // Deprecated, don't use.
00052 #define CHECKBOXCTRL_HEIGHT LLCHECKBOXCTRL_HEIGHT
00053 
00054 const BOOL      RADIO_STYLE = TRUE;
00055 const BOOL      CHECK_STYLE = FALSE;
00056 
00057 //
00058 // Classes
00059 //
00060 class LLFontGL;
00061 class LLTextBox;
00062 class LLViewBorder;
00063 
00064 class LLCheckBoxCtrl
00065 : public LLUICtrl
00066 {
00067 public:
00068         LLCheckBoxCtrl(const LLString& name, const LLRect& rect, const LLString& label, 
00069                 const LLFontGL* font = NULL,
00070                 void (*commit_callback)(LLUICtrl*, void*) = NULL,
00071                 void* callback_userdata = NULL,
00072                 BOOL initial_value = FALSE,
00073                 BOOL use_radio_style = FALSE, // if true, draw radio button style icons
00074                 const LLString& control_which = LLString::null);
00075         virtual ~LLCheckBoxCtrl();
00076 
00077         // LLView interface
00078         virtual EWidgetType getWidgetType() const       { return WIDGET_TYPE_CHECKBOX; }
00079         virtual LLString getWidgetTag() const { return LL_CHECK_BOX_CTRL_TAG; }
00080         virtual LLXMLNodePtr getXML(bool save_children = true) const;
00081         static LLView* fromXML(LLXMLNodePtr node, LLView *parent, LLUICtrlFactory *factory);
00082 
00083         virtual void            setEnabled( BOOL b );
00084 
00085         virtual void            draw();
00086         virtual void            reshape(S32 width, S32 height, BOOL called_from_parent);
00087 
00088         // LLUICtrl interface
00089         virtual void            setValue(const LLSD& value );
00090         virtual LLSD            getValue() const;
00091                         BOOL            get() { return (BOOL)getValue().asBoolean(); }
00092                         void            set(BOOL value) { setValue(value); }
00093 
00094         virtual void            setTentative(BOOL b)    { mButton->setTentative(b); }
00095         virtual BOOL            getTentative() const    { return mButton->getTentative(); }
00096 
00097         virtual BOOL            setLabelArg( const LLString& key, const LLStringExplicit& text );
00098 
00099         virtual void            clear();
00100         virtual void            onCommit();
00101 
00102         // LLCheckBoxCtrl interface
00103         virtual BOOL            toggle()                                { return mButton->toggleState(); }              // returns new state
00104 
00105         void                            setEnabledColor( const LLColor4 &color ) { mTextEnabledColor = color; }
00106         void                            setDisabledColor( const LLColor4 &color ) { mTextDisabledColor = color; }
00107 
00108         void                            setLabel( const LLStringExplicit& label );
00109         LLString                        getLabel() const;
00110 
00111         virtual void            setControlName(const LLString& control_name, LLView* context);
00112         virtual LLString        getControlName() const;
00113 
00114         static void                     onButtonPress(void *userdata);
00115 
00116         virtual BOOL            isDirty()       const;          // Returns TRUE if the user has modified this control.
00117         virtual void            resetDirty();                   // Clear dirty state
00118 
00119 protected:
00120         // note: value is stored in toggle state of button
00121         LLButton*               mButton;
00122         LLTextBox*              mLabel;
00123         const LLFontGL* mFont;
00124         LLColor4                mTextEnabledColor;
00125         LLColor4                mTextDisabledColor;
00126         BOOL                    mRadioStyle;
00127         BOOL                    mInitialValue;                  // Value set in constructor
00128         BOOL                    mSetValue;                              // Value set programmatically
00129         BOOL                    mKeyboardFocusOnClick;
00130         LLViewBorder*   mBorder;
00131 };
00132 
00133 
00134 // HACK: fix old capitalization problem
00135 //typedef LLCheckBoxCtrl LLCheckboxCtrl;
00136 #define LLCheckboxCtrl LLCheckBoxCtrl
00137 
00138 
00139 #endif  // LL_LLCHECKBOXCTRL_H

Generated on Thu Jul 1 06:08:21 2010 for Second Life Viewer by  doxygen 1.4.7