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
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
00052 #define CHECKBOXCTRL_HEIGHT LLCHECKBOXCTRL_HEIGHT
00053
00054 const BOOL RADIO_STYLE = TRUE;
00055 const BOOL CHECK_STYLE = FALSE;
00056
00057
00058
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,
00074 const LLString& control_which = LLString::null);
00075 virtual ~LLCheckBoxCtrl();
00076
00077
00078
00079 virtual LLXMLNodePtr getXML(bool save_children = true) const;
00080 static LLView* fromXML(LLXMLNodePtr node, LLView *parent, LLUICtrlFactory *factory);
00081
00082 virtual void setEnabled( BOOL b );
00083
00084 virtual void draw();
00085 virtual void reshape(S32 width, S32 height, BOOL called_from_parent = TRUE);
00086
00087
00088 virtual void setValue(const LLSD& value );
00089 virtual LLSD getValue() const;
00090 BOOL get() { return (BOOL)getValue().asBoolean(); }
00091 void set(BOOL value) { setValue(value); }
00092
00093 virtual void setTentative(BOOL b) { mButton->setTentative(b); }
00094 virtual BOOL getTentative() const { return mButton->getTentative(); }
00095
00096 virtual BOOL setLabelArg( const LLString& key, const LLStringExplicit& text );
00097
00098 virtual void clear();
00099 virtual void onCommit();
00100
00101
00102 virtual BOOL toggle() { return mButton->toggleState(); }
00103
00104 void setEnabledColor( const LLColor4 &color ) { mTextEnabledColor = color; }
00105 void setDisabledColor( const LLColor4 &color ) { mTextDisabledColor = color; }
00106
00107 void setLabel( const LLStringExplicit& label );
00108 LLString getLabel() const;
00109
00110 virtual void setControlName(const LLString& control_name, LLView* context);
00111 virtual LLString getControlName() const;
00112
00113 static void onButtonPress(void *userdata);
00114
00115 virtual BOOL isDirty() const;
00116 virtual void resetDirty();
00117
00118 protected:
00119
00120 LLButton* mButton;
00121 LLTextBox* mLabel;
00122 const LLFontGL* mFont;
00123 LLColor4 mTextEnabledColor;
00124 LLColor4 mTextDisabledColor;
00125 BOOL mRadioStyle;
00126 BOOL mInitialValue;
00127 BOOL mSetValue;
00128 BOOL mKeyboardFocusOnClick;
00129 LLViewBorder* mBorder;
00130 };
00131
00132
00133
00134
00135 #define LLCheckboxCtrl LLCheckBoxCtrl
00136
00137
00138 #endif // LL_LLCHECKBOXCTRL_H