00001
00032
00033
00034
00035
00036 #ifndef LL_LLRADIOGROUP_H
00037 #define LL_LLRADIOGROUP_H
00038
00039 #include "lluictrl.h"
00040 #include "llcheckboxctrl.h"
00041 #include "llctrlselectioninterface.h"
00042
00043 class LLFontGL;
00044
00045
00046 class LLRadioCtrl : public LLCheckBoxCtrl
00047 {
00048 public:
00049 LLRadioCtrl(const LLString& name, const LLRect& rect, const LLString& label,
00050 const LLFontGL* font = NULL,
00051 void (*commit_callback)(LLUICtrl*, void*) = NULL,
00052 void* callback_userdata = NULL);
00053 ~LLRadioCtrl();
00054
00055 void setValue(const LLSD& value);
00056 };
00057
00058 class LLRadioGroup
00059 : public LLUICtrl, public LLCtrlSelectionInterface
00060 {
00061 public:
00062
00063
00064
00065 LLRadioGroup(const LLString& name, const LLRect& rect,
00066 const LLString& control_name,
00067 LLUICtrlCallback callback = NULL,
00068 void* userdata = NULL,
00069 BOOL border = TRUE);
00070
00071
00072
00073 LLRadioGroup(const LLString& name, const LLRect& rect,
00074 S32 initial_index,
00075 LLUICtrlCallback callback = NULL,
00076 void* userdata = NULL,
00077 BOOL border = TRUE);
00078
00079 virtual ~LLRadioGroup();
00080 virtual EWidgetType getWidgetType() const { return WIDGET_TYPE_RADIO_GROUP; }
00081 virtual LLString getWidgetTag() const { return LL_RADIO_GROUP_TAG; }
00082
00083 virtual BOOL handleKeyHere(KEY key, MASK mask, BOOL called_from_parent);
00084
00085 virtual void setEnabled(BOOL enabled);
00086 virtual LLXMLNodePtr getXML(bool save_children = true) const;
00087 static LLView* fromXML(LLXMLNodePtr node, LLView *parent, LLUICtrlFactory *factory);
00088 void setIndexEnabled(S32 index, BOOL enabled);
00089
00090
00091 S32 getSelectedIndex() const;
00092
00093
00094 BOOL setSelectedIndex(S32 index, BOOL from_event = FALSE);
00095
00096
00097 virtual void setValue(const LLSD& value );
00098 virtual LLSD getValue() const;
00099
00100
00101
00102 void draw();
00103
00104
00105
00106
00107 LLRadioCtrl* addRadioButton(const LLString& name, const LLString& label, const LLRect& rect, const LLFontGL* font);
00108 LLRadioCtrl* getRadioButton(const S32& index) { return mRadioButtons[index]; }
00109
00110
00111 static void onClickButton(LLUICtrl* radio, void* userdata);
00112
00113
00114 LLCtrlSelectionInterface* getSelectionInterface() { return (LLCtrlSelectionInterface*)this; };
00115
00116
00117 S32 getItemCount() const { return mRadioButtons.size(); }
00118 BOOL getCanSelect() const { return TRUE; }
00119 BOOL selectFirstItem() { return setSelectedIndex(0); }
00120 BOOL selectNthItem( S32 index ) { return setSelectedIndex(index); }
00121 S32 getFirstSelectedIndex() const { return getSelectedIndex(); }
00122 BOOL setCurrentByID( const LLUUID& id );
00123 LLUUID getCurrentID();
00124 BOOL setSelectedByValue(LLSD value, BOOL selected);
00125 LLSD getSimpleSelectedValue();
00126 BOOL isSelected(LLSD value);
00127 BOOL operateOnSelection(EOperation op);
00128 BOOL operateOnAll(EOperation op);
00129
00130 protected:
00131
00132 void init(BOOL border);
00133
00134 S32 mSelectedIndex;
00135 typedef std::vector<LLRadioCtrl*> button_list_t;
00136 button_list_t mRadioButtons;
00137
00138 BOOL mHasBorder;
00139 };
00140
00141
00142 #endif