diff options
author | Bryan O'Sullivan <bos@lindenlab.com> | 2009-08-31 13:47:47 -0700 |
---|---|---|
committer | Bryan O'Sullivan <bos@lindenlab.com> | 2009-08-31 13:47:47 -0700 |
commit | 30ff6cabd61f2f083df5df1e6e70cc94742af477 (patch) | |
tree | 631935f1cf59d19a91cdad65e9a75fe825afda7d /indra/llui/llradiogroup.h | |
parent | ff11d74820c89822cd067b51727d9df1dc87d0d0 (diff) | |
parent | 3ac3a4b206c08ed06b889bdaa24074b6aa0e020a (diff) |
Merge with trunk
Diffstat (limited to 'indra/llui/llradiogroup.h')
-rw-r--r-- | indra/llui/llradiogroup.h | 84 |
1 files changed, 46 insertions, 38 deletions
diff --git a/indra/llui/llradiogroup.h b/indra/llui/llradiogroup.h index 3410b74104..b5516307fd 100644 --- a/indra/llui/llradiogroup.h +++ b/indra/llui/llradiogroup.h @@ -39,23 +39,41 @@ /* - * A checkbox control with use_radio_style == true. + * An invisible view containing multiple mutually exclusive toggling + * buttons (usually radio buttons). Automatically handles the mutex + * condition by highlighting only one button at a time. */ class LLRadioCtrl : public LLCheckBoxCtrl { public: - LLRadioCtrl(const std::string& name, const LLRect& rect, const std::string& label, const LLFontGL* font = NULL, - void (*commit_callback)(LLUICtrl*, void*) = NULL, void* callback_userdata = NULL) : - LLCheckBoxCtrl(name, rect, label, font, commit_callback, callback_userdata, FALSE, RADIO_STYLE) + struct Params : public LLInitParam::Block<Params, LLCheckBoxCtrl::Params> { - setTabStop(FALSE); - } - /*virtual*/ ~LLRadioCtrl(); + Ignored length; + Ignored type; + + Params() + : length("length"), + type("type") + {} + }; + /*virtual*/ ~LLRadioCtrl(); /*virtual*/ void setValue(const LLSD& value); + + /*virtual*/ BOOL postBuild(); + + // Ensure label is in an attribute, not the contents + static void setupParamsForExport(Params& p, LLView* parent); + +protected: + LLRadioCtrl(const Params& p); + friend class LLUICtrlFactory; }; +struct RadioGroupRegistry : public LLChildRegistry<RadioGroupRegistry> +{}; + /* * An invisible view containing multiple mutually exclusive toggling * buttons (usually radio buttons). Automatically handles the mutex @@ -65,32 +83,30 @@ class LLRadioGroup : public LLUICtrl, public LLCtrlSelectionInterface { public: - // Build a radio group. The number (0...n-1) of the currently selected - // element will be stored in the named control. After the control is - // changed the callback will be called. - LLRadioGroup(const std::string& name, const LLRect& rect, - const std::string& control_name, - LLUICtrlCallback callback = NULL, - void* userdata = NULL, - BOOL border = TRUE); - - // Another radio group constructor, but this one doesn't rely on - // needing a control - LLRadioGroup(const std::string& name, const LLRect& rect, - S32 initial_index, - LLUICtrlCallback callback = NULL, - void* userdata = NULL, - BOOL border = TRUE); - virtual ~LLRadioGroup(); + struct Params : public LLInitParam::Block<Params, LLUICtrl::Params> + { + Optional<bool> has_border; + Params(); + }; + + // my valid children are stored in this registry + typedef RadioGroupRegistry child_registry_t; + +protected: + LLRadioGroup(const Params&); + friend class LLUICtrlFactory; +public: + virtual ~LLRadioGroup(); + + virtual BOOL postBuild(); + + virtual bool addChild(LLView* view, S32 tab_group = 0); + virtual BOOL handleKeyHere(KEY key, MASK mask); - virtual void setEnabled(BOOL enabled); - virtual LLXMLNodePtr getXML(bool save_children = true) const; - static LLView* fromXML(LLXMLNodePtr node, LLView *parent, LLUICtrlFactory *factory); void setIndexEnabled(S32 index, BOOL enabled); - // return the index value of the selected item S32 getSelectedIndex() const { return mSelectedIndex; } @@ -104,13 +120,8 @@ public: // Draw the group, but also fix the highlighting based on the control. void draw(); - // You must use this method to add buttons to a radio group. - // Don't use addChild -- it won't set the callback function - // correctly. - LLRadioCtrl* addRadioButton(const std::string& name, const std::string& label, const LLRect& rect, const LLFontGL* font); - LLRadioCtrl* getRadioButton(const S32& index) { return mRadioButtons[index]; } // Update the control as needed. Userdata must be a pointer to the button. - static void onClickButton(LLUICtrl* radio, void* userdata); + void onClickButton(LLUICtrl* clicked_radio); //======================================================================== LLCtrlSelectionInterface* getSelectionInterface() { return (LLCtrlSelectionInterface*)this; }; @@ -131,9 +142,7 @@ public: /*virtual*/ BOOL operateOnAll(EOperation op); private: - // protected function shared by the two constructors. - void init(BOOL border); - + const LLFontGL* mFont; S32 mSelectedIndex; typedef std::vector<LLRadioCtrl*> button_list_t; button_list_t mRadioButtons; @@ -141,5 +150,4 @@ private: BOOL mHasBorder; }; - #endif |