]> git.lyx.org Git - lyx.git/blob - src/frontends/xforms/RadioButtonGroup.h
sourcedoc-friendly files.
[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 #include <vector>
16 #include <utility>
17
18 #include FORMS_H_LOCATION
19
20 #ifdef __GNUG__
21 #pragma interface
22 #endif 
23
24
25 /** This class simplifies the work with a group of radio buttons,
26  * the idea is that you register a bunch of radio buttons with the accompanying
27  * value for each radio button and then you get to query or set the active
28  * button in a single function call.
29  */
30 class RadioButtonGroup {
31 public:
32         /// Constructor. Allocate space for 'n' items in the group.
33         RadioButtonGroup(unsigned n = 5) : map(n) {};
34
35         /// Register a radio button with it's corresponding value.
36         void registerRadioButton(FL_OBJECT * button, int value);
37         /// Reset registrations.
38         void reset();
39
40         // Set the active button.
41         void setButton(int value);
42
43         // Get the active button.
44         int getButton();
45
46 private:
47         ///
48         typedef std::pair<FL_OBJECT *, int> ButtonValuePair;
49         ///
50         typedef std::vector<ButtonValuePair> ButtonValueMap;
51         ///
52         ButtonValueMap map;
53 };
54
55 #endif