]> git.lyx.org Git - lyx.git/blob - src/frontends/xforms/RadioButtonGroup.h
Change glob() API to accept a dir parameter.
[lyx.git] / src / frontends / xforms / RadioButtonGroup.h
1 // -*- C++ -*-
2 /**
3  * \file RadioButtonGroup.h
4  * This file is part of LyX, the document processor.
5  * Licence details can be found in the file COPYING.
6  *
7  * \author Baruch Even
8  * \author Rob Lahaye
9  *
10  * Full author contact details are available in file CREDITS.
11  */
12
13
14 #ifndef RADIOBUTTONGROUP_H
15 #define RADIOBUTTONGROUP_H
16
17 #include "support/types.h"
18 #include <vector>
19 #include <utility>
20 #include "forms_fwd.h"
21
22 namespace lyx {
23 namespace frontend {
24
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.
33  */
34 class RadioButtonGroup {
35 public:
36
37         /// Register a radio button with its corresponding value.
38         void init(FL_OBJECT * ob, size_type value);
39
40         // Set a single active button.
41         void set(size_type value) const;
42         void set(FL_OBJECT * ob) const;
43
44         // None of the radiobuttons are set.
45         void unset() const;
46
47         // Get the active button's value.
48         size_type get() const;
49
50         void setEnabled(bool enabled);
51
52 private:
53         ///
54         typedef std::pair<FL_OBJECT *, size_type> ButtonValuePair;
55         ///
56         typedef std::vector<ButtonValuePair> ButtonValueMap;
57         ///
58         ButtonValueMap map;
59 };
60
61 } // namespace frontend
62 } // namespace lyx
63
64 #endif // RADIOBUTTONGROUP_H