3 * \file RadioButtonGroup.h
4 * This file is part of LyX, the document processor.
5 * Licence details can be found in the file COPYING.
10 * Full author contact details are available in file CREDITS.
14 #ifndef RADIOBUTTONGROUP_H
15 #define RADIOBUTTONGROUP_H
17 #include "support/types.h"
20 #include "forms_fwd.h"
25 /** This class simplifies interaction with a group of radio buttons:
26 * one, and only one, can be selected.
27 * The idea is that you register a bunch of radio buttons with
28 * an accompanying value. Then you can get or set the active button with a
29 * single function call.
30 * It is necessary to also group a family of radio buttons in the
31 * corresponding .fd file in order to unset the previously chosen button
32 * when a new one is selected.
34 class RadioButtonGroup {
37 /// Register a radio button with its corresponding value.
38 void init(FL_OBJECT * ob, size_type value);
40 // Set a single active button.
41 void set(size_type value) const;
42 void set(FL_OBJECT * ob) const;
44 // None of the radiobuttons are set.
47 // Get the active button's value.
48 size_type get() const;
50 void setEnabled(bool enabled);
54 typedef std::pair<FL_OBJECT *, size_type> ButtonValuePair;
56 typedef std::vector<ButtonValuePair> ButtonValueMap;
61 } // namespace frontend
64 #endif // RADIOBUTTONGROUP_H