1/*
2 * Copyright 2007, Ingo Weinhold <bonefish@cs.tu-berlin.de>.
3 * All rights reserved. Distributed under the terms of the MIT License.
4 */
5#ifndef WIDGET_LAYOUT_TEST_RADIO_BUTTON_H
6#define WIDGET_LAYOUT_TEST_RADIO_BUTTON_H
7
8
9#include <Invoker.h>
10#include <List.h>
11
12#include "AbstractButton.h"
13#include "GroupView.h"
14
15
16// RadioButton
17class RadioButton : public AbstractButton {
18public:
19								RadioButton(BMessage* message = NULL,
20									BMessenger target = BMessenger());
21
22	virtual	BSize				MinSize();
23	virtual	BSize				MaxSize();
24
25	virtual	void				Draw(BView* container, BRect updateRect);
26};
27
28
29// LabeledRadioButton
30class LabeledRadioButton : public GroupView {
31public:
32								LabeledRadioButton(const char* label,
33									BMessage* message = NULL,
34									BMessenger target = BMessenger());
35
36			RadioButton*		GetRadioButton() const	{ return fRadioButton; }
37
38			void				SetTarget(BMessenger messenger);
39
40			void				SetSelected(bool selected);
41			bool				IsSelected() const;
42
43private:
44			RadioButton*		fRadioButton;
45};
46
47
48// RadioButtonGroup
49class RadioButtonGroup : public BInvoker, private AbstractButton::Listener {
50public:
51								RadioButtonGroup(BMessage* message = NULL,
52									BMessenger target = BMessenger());
53	virtual						~RadioButtonGroup();
54
55			void				AddButton(AbstractButton* button);
56			bool				RemoveButton(AbstractButton* button);
57			AbstractButton*		RemoveButton(int32 index);
58
59			int32				CountButtons() const;
60			AbstractButton*		ButtonAt(int32 index) const;
61			int32				IndexOfButton(AbstractButton* button) const;
62
63			void				SelectButton(AbstractButton* button);
64			void				SelectButton(int32 index);
65			AbstractButton*		SelectedButton() const;
66			int32				SelectedIndex() const;
67
68private:
69	virtual	void				SelectionChanged(AbstractButton* button);
70
71			void				_SelectionChanged();
72
73private:
74			BList				fButtons;
75			AbstractButton*		fSelected;
76};
77
78
79#endif	// WIDGET_LAYOUT_TEST_RADIO_BUTTON_H
80