aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/linden/indra/llui/llradiogroup.h
diff options
context:
space:
mode:
authorJacek Antonelli2008-08-15 23:44:46 -0500
committerJacek Antonelli2008-08-15 23:44:46 -0500
commit38d6d37f2d982fa959e9e8a4a3f7e1ccfad7b5d4 (patch)
treeadca584755d22ca041a2dbfc35d4eca01f70b32c /linden/indra/llui/llradiogroup.h
parentREADME.txt (diff)
downloadmeta-impy-38d6d37f2d982fa959e9e8a4a3f7e1ccfad7b5d4.zip
meta-impy-38d6d37f2d982fa959e9e8a4a3f7e1ccfad7b5d4.tar.gz
meta-impy-38d6d37f2d982fa959e9e8a4a3f7e1ccfad7b5d4.tar.bz2
meta-impy-38d6d37f2d982fa959e9e8a4a3f7e1ccfad7b5d4.tar.xz
Second Life viewer sources 1.13.2.12
Diffstat (limited to 'linden/indra/llui/llradiogroup.h')
-rw-r--r--linden/indra/llui/llradiogroup.h121
1 files changed, 121 insertions, 0 deletions
diff --git a/linden/indra/llui/llradiogroup.h b/linden/indra/llui/llradiogroup.h
new file mode 100644
index 0000000..9324113
--- /dev/null
+++ b/linden/indra/llui/llradiogroup.h
@@ -0,0 +1,121 @@
1/**
2 * @file llradiogroup.h
3 * @brief LLRadioGroup base class
4 *
5 * Copyright (c) 2001-2007, Linden Research, Inc.
6 *
7 * The source code in this file ("Source Code") is provided by Linden Lab
8 * to you under the terms of the GNU General Public License, version 2.0
9 * ("GPL"), unless you have obtained a separate licensing agreement
10 * ("Other License"), formally executed by you and Linden Lab. Terms of
11 * the GPL can be found in doc/GPL-license.txt in this distribution, or
12 * online at http://secondlife.com/developers/opensource/gplv2
13 *
14 * There are special exceptions to the terms and conditions of the GPL as
15 * it is applied to this Source Code. View the full text of the exception
16 * in the file doc/FLOSS-exception.txt in this software distribution, or
17 * online at http://secondlife.com/developers/opensource/flossexception
18 *
19 * By copying, modifying or distributing this software, you acknowledge
20 * that you have read and understood your obligations described above,
21 * and agree to abide by those obligations.
22 *
23 * ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO
24 * WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY,
25 * COMPLETENESS OR PERFORMANCE.
26 */
27
28// An invisible view containing multiple mutually exclusive toggling
29// buttons (usually radio buttons). Automatically handles the mutex
30// condition by highlighting only one button at a time.
31
32#ifndef LL_LLRADIOGROUP_H
33#define LL_LLRADIOGROUP_H
34
35#include "lluictrl.h"
36#include "llcheckboxctrl.h"
37
38class LLFontGL;
39
40// Radio controls are checkbox controls with use_radio_style true
41class LLRadioCtrl : public LLCheckBoxCtrl
42{
43public:
44 LLRadioCtrl(const LLString& name, const LLRect& rect, const LLString& label,
45 const LLFontGL* font = NULL,
46 void (*commit_callback)(LLUICtrl*, void*) = NULL,
47 void* callback_userdata = NULL);
48 /*virtual*/ ~LLRadioCtrl();
49
50 /*virtual*/ void setValue(const LLSD& value);
51};
52
53class LLRadioGroup
54: public LLUICtrl
55{
56public:
57 // Build a radio group. The number (0...n-1) of the currently selected
58 // element will be stored in the named control. After the control is
59 // changed the callback will be called.
60 LLRadioGroup(const LLString& name, const LLRect& rect,
61 const LLString& control_name,
62 LLUICtrlCallback callback = NULL,
63 void* userdata = NULL,
64 BOOL border = TRUE);
65
66 // Another radio group constructor, but this one doesn't rely on
67 // needing a control
68 LLRadioGroup(const LLString& name, const LLRect& rect,
69 S32 initial_index,
70 LLUICtrlCallback callback = NULL,
71 void* userdata = NULL,
72 BOOL border = TRUE);
73
74 virtual ~LLRadioGroup();
75 virtual EWidgetType getWidgetType() const { return WIDGET_TYPE_RADIO_GROUP; }
76 virtual LLString getWidgetTag() const { return LL_RADIO_GROUP_TAG; }
77
78 virtual BOOL handleKeyHere(KEY key, MASK mask, BOOL called_from_parent);
79
80 virtual void setEnabled(BOOL enabled);
81 virtual LLXMLNodePtr getXML(bool save_children = true) const;
82 static LLView* fromXML(LLXMLNodePtr node, LLView *parent, LLUICtrlFactory *factory);
83 void setIndexEnabled(S32 index, BOOL enabled);
84
85 S32 getItemCount() { return mRadioButtons.size(); }
86 // return the index value of the selected item
87 S32 getSelectedIndex() const;
88
89 // set the index value programatically
90 BOOL setSelectedIndex(S32 index, BOOL from_event = FALSE);
91
92 // Accept and retrieve strings of the radio group control names
93 virtual void setValue(const LLSD& value );
94 virtual LLSD getValue() const;
95
96 // Draw the group, but also fix the highlighting based on the
97 // control.
98 void draw();
99
100 // You must use this method to add buttons to a radio group.
101 // Don't use addChild -- it won't set the callback function
102 // correctly.
103 LLRadioCtrl* addRadioButton(const LLString& name, const LLString& label, const LLRect& rect, const LLFontGL* font);
104 LLRadioCtrl* getRadioButton(const S32& index) { return mRadioButtons[index]; }
105 // Update the control as needed. Userdata must be a pointer to the
106 // button.
107 static void onClickButton(LLUICtrl* radio, void* userdata);
108
109protected:
110 // protected function shared by the two constructors.
111 void init(BOOL border);
112
113 S32 mSelectedIndex;
114 typedef std::vector<LLRadioCtrl*> button_list_t;
115 button_list_t mRadioButtons;
116
117 BOOL mHasBorder;
118};
119
120
121#endif