]> git.lyx.org Git - lyx.git/blob - src/frontends/xforms/RadioButtonGroup.h
radiobutton group patch; set font_norm_type correctly in preferences
[lyx.git] / src / frontends / xforms / RadioButtonGroup.h
1 // -*- C++ -*-
2 /**
3  * \file RadioButtonGroup.h
4  * Copyright 2000 Baruch Even
5  * This file is part of LyX, the document processor.
6  * Licence details can be found in the file COPYING.
7  *
8  * \author Baruch Even
9  * \author Rob Lahaye
10  *
11  * Full author contact details are available in file CREDITS
12  */
13
14
15 #ifndef RADIOBUTTONGROUP_H
16 #define RADIOBUTTONGROUP_H
17
18
19 #include "support/types.h"
20 #include <vector>
21 #include <utility>
22 #include "forms_fwd.h"
23
24 /** This class simplifies interaction with a group of radio buttons:
25  *  one, and only one, can be selected.
26  *  The idea is that you register a bunch of radio buttons with
27  *  an accompanying value. Then you can get or set the active button with a
28  *  single function call.
29  *  It is necessary to also group a family of radio buttons in the
30  *  corresponding .fd file in order to unset the previously chosen button
31  *  when a new one is selected.
32  */
33 class RadioButtonGroup {
34 public:
35         ///
36         typedef lyx::size_type size_type;
37
38         /// Register a radio button with its corresponding value.
39         void init(FL_OBJECT * ob, size_type value);
40
41         // Set a single active button.
42         void set(size_type value) const;
43         void set(FL_OBJECT * ob) const;
44
45         // Get the active button's value.
46         size_type get() const;
47
48 private:
49         ///
50         typedef std::pair<FL_OBJECT *, size_type> ButtonValuePair;
51         ///
52         typedef std::vector<ButtonValuePair> ButtonValueMap;
53         ///
54         ButtonValueMap map;
55 };
56
57 #endif // RADIOBUTTONGROUP_H