xref: /haiku/src/tests/kits/interface/layout/widget_layout_test/RadioButton.h (revision 4b5e868dcdb7fca9f532cfd6859b88344619f7f2)
10ce9bc68SIngo Weinhold /*
20ce9bc68SIngo Weinhold  * Copyright 2007, Ingo Weinhold <bonefish@cs.tu-berlin.de>.
30ce9bc68SIngo Weinhold  * All rights reserved. Distributed under the terms of the MIT License.
40ce9bc68SIngo Weinhold  */
5*4b5e868dSIngo Weinhold #ifndef WIDGET_LAYOUT_TEST_RADIO_BUTTON_H
6*4b5e868dSIngo Weinhold #define WIDGET_LAYOUT_TEST_RADIO_BUTTON_H
70ce9bc68SIngo Weinhold 
80ce9bc68SIngo Weinhold 
90ce9bc68SIngo Weinhold #include <Invoker.h>
100ce9bc68SIngo Weinhold #include <List.h>
110ce9bc68SIngo Weinhold 
120ce9bc68SIngo Weinhold #include "AbstractButton.h"
130ce9bc68SIngo Weinhold #include "GroupView.h"
140ce9bc68SIngo Weinhold 
150ce9bc68SIngo Weinhold 
160ce9bc68SIngo Weinhold // RadioButton
170ce9bc68SIngo Weinhold class RadioButton : public AbstractButton {
180ce9bc68SIngo Weinhold public:
190ce9bc68SIngo Weinhold 								RadioButton(BMessage* message = NULL,
200ce9bc68SIngo Weinhold 									BMessenger target = BMessenger());
210ce9bc68SIngo Weinhold 
220ce9bc68SIngo Weinhold 	virtual	BSize				MinSize();
230ce9bc68SIngo Weinhold 	virtual	BSize				MaxSize();
240ce9bc68SIngo Weinhold 
250ce9bc68SIngo Weinhold 	virtual	void				Draw(BView* container, BRect updateRect);
260ce9bc68SIngo Weinhold };
270ce9bc68SIngo Weinhold 
280ce9bc68SIngo Weinhold 
290ce9bc68SIngo Weinhold // LabeledRadioButton
300ce9bc68SIngo Weinhold class LabeledRadioButton : public GroupView {
310ce9bc68SIngo Weinhold public:
320ce9bc68SIngo Weinhold 								LabeledRadioButton(const char* label,
330ce9bc68SIngo Weinhold 									BMessage* message = NULL,
340ce9bc68SIngo Weinhold 									BMessenger target = BMessenger());
350ce9bc68SIngo Weinhold 
GetRadioButton()360ce9bc68SIngo Weinhold 			RadioButton*		GetRadioButton() const	{ return fRadioButton; }
370ce9bc68SIngo Weinhold 
380ce9bc68SIngo Weinhold 			void				SetTarget(BMessenger messenger);
390ce9bc68SIngo Weinhold 
400ce9bc68SIngo Weinhold 			void				SetSelected(bool selected);
410ce9bc68SIngo Weinhold 			bool				IsSelected() const;
420ce9bc68SIngo Weinhold 
430ce9bc68SIngo Weinhold private:
440ce9bc68SIngo Weinhold 			RadioButton*		fRadioButton;
450ce9bc68SIngo Weinhold };
460ce9bc68SIngo Weinhold 
470ce9bc68SIngo Weinhold 
480ce9bc68SIngo Weinhold // RadioButtonGroup
490ce9bc68SIngo Weinhold class RadioButtonGroup : public BInvoker, private AbstractButton::Listener {
500ce9bc68SIngo Weinhold public:
510ce9bc68SIngo Weinhold 								RadioButtonGroup(BMessage* message = NULL,
520ce9bc68SIngo Weinhold 									BMessenger target = BMessenger());
530ce9bc68SIngo Weinhold 	virtual						~RadioButtonGroup();
540ce9bc68SIngo Weinhold 
550ce9bc68SIngo Weinhold 			void				AddButton(AbstractButton* button);
560ce9bc68SIngo Weinhold 			bool				RemoveButton(AbstractButton* button);
570ce9bc68SIngo Weinhold 			AbstractButton*		RemoveButton(int32 index);
580ce9bc68SIngo Weinhold 
590ce9bc68SIngo Weinhold 			int32				CountButtons() const;
600ce9bc68SIngo Weinhold 			AbstractButton*		ButtonAt(int32 index) const;
610ce9bc68SIngo Weinhold 			int32				IndexOfButton(AbstractButton* button) const;
620ce9bc68SIngo Weinhold 
630ce9bc68SIngo Weinhold 			void				SelectButton(AbstractButton* button);
640ce9bc68SIngo Weinhold 			void				SelectButton(int32 index);
650ce9bc68SIngo Weinhold 			AbstractButton*		SelectedButton() const;
660ce9bc68SIngo Weinhold 			int32				SelectedIndex() const;
670ce9bc68SIngo Weinhold 
680ce9bc68SIngo Weinhold private:
690ce9bc68SIngo Weinhold 	virtual	void				SelectionChanged(AbstractButton* button);
700ce9bc68SIngo Weinhold 
710ce9bc68SIngo Weinhold 			void				_SelectionChanged();
720ce9bc68SIngo Weinhold 
730ce9bc68SIngo Weinhold private:
740ce9bc68SIngo Weinhold 			BList				fButtons;
750ce9bc68SIngo Weinhold 			AbstractButton*		fSelected;
760ce9bc68SIngo Weinhold };
770ce9bc68SIngo Weinhold 
780ce9bc68SIngo Weinhold 
79*4b5e868dSIngo Weinhold #endif	// WIDGET_LAYOUT_TEST_RADIO_BUTTON_H
80