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
18 #include "support/types.h"
21 #include "forms_fwd.h"
23 /** This class simplifies interaction with a group of radio buttons:
24 * one, and only one, can be selected.
25 * The idea is that you register a bunch of radio buttons with
26 * an accompanying value. Then you can get or set the active button with a
27 * single function call.
28 * It is necessary to also group a family of radio buttons in the
29 * corresponding .fd file in order to unset the previously chosen button
30 * when a new one is selected.
32 class RadioButtonGroup {
35 typedef lyx::size_type size_type;
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 // Get the active button's value.
45 size_type get() const;
49 typedef std::pair<FL_OBJECT *, size_type> ButtonValuePair;
51 typedef std::vector<ButtonValuePair> ButtonValueMap;
56 #endif // RADIOBUTTONGROUP_H