]> git.lyx.org Git - lyx.git/blob - src/frontends/xforms/RadioButtonGroup.h
xforms clean-up, described in detail in my mail of 31 May. See
[lyx.git] / src / frontends / xforms / RadioButtonGroup.h
1 // -*- C++ -*-
2 /**
3  * \file RadioButtonGroup.h
4  * Copyright 2002 the LyX Team
5  * Copyright 2000 Baruch Even
6  * Read the file COPYING
7  *
8  * \author Baruch Even, baruch.even@writeme.com
9  */
10
11
12 #ifndef RADIOBUTTONGROUP_H
13 #define RADIOBUTTONGROUP_H
14
15 #ifdef __GNUG__
16 #pragma interface
17 #endif
18
19 #include "support/types.h"
20 #include <vector>
21 #include <utility>
22 #include "forms_fwd.h"
23
24 /** This class simplifies the work with a group of radio buttons,
25  * the idea is that you register a bunch of radio buttons with the accompanying
26  * value for each radio button and then you get to query or set the active
27  * button in a single function call.
28  */
29 class RadioButtonGroup {
30 public:
31         ///
32         typedef lyx::size_type size_type;
33
34         /// Constructor. Allocate space for 'n' items in the group.
35         RadioButtonGroup(unsigned n = 5) : map(n) {};
36
37         /// Register a radio button with it's corresponding value.
38         void init(FL_OBJECT * button, size_type value);
39         /// Reset registrations.
40         void reset();
41
42         // Set the active button.
43         void set(size_type value);
44
45         // Get the active button.
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