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