]> git.lyx.org Git - lyx.git/blob - src/frontends/xforms/RadioButtonGroup.h
More pref work from Angus
[lyx.git] / src / frontends / xforms / RadioButtonGroup.h
1 // -*- C++ -*-
2 /* This file is part of
3  * =================================================
4  * 
5  *          LyX, The Document Processor
6  *          Copyright 1995 Matthias Ettrich.
7  *          Copyright 1995-2000 The LyX Team.
8  *
9  *          This file Copyright 2000 Baruch Even
10  * ================================================= */
11
12
13 #ifndef RADIOBUTTONGROUP_H
14 #define RADIOBUTTONGROUP_H
15
16 #ifdef __GNUG__
17 #pragma interface
18 #endif 
19
20 #include <vector>
21 #include <utility>
22
23 using std::vector;
24 using std::pair;
25
26 #include FORMS_H_LOCATION
27
28 /** This class simplifies the work with a group of radio buttons,
29  * the idea is that you register a bunch of radio buttons with the accompanying
30  * value for each radio button and then you get to query or set the active
31  * button in a single function call.
32  * @author Baruch Even
33  */
34 class RadioButtonGroup {
35 public:
36         /// Constructor. Allocate space for 'n' items in the group.
37         RadioButtonGroup(unsigned n = 5) : map(n) {};
38
39         /// Register a radio button with it's corresponding value.
40         void registerRadioButton(FL_OBJECT *button, int value);
41         /// Reset registrations.
42         void reset();
43
44         // Set the active button.
45         void setButton(int value);
46
47         // Get the active button.
48         int getButton();
49
50 private:
51         ///
52         typedef pair<FL_OBJECT *, int> ButtonValuePair;
53         ///
54         typedef vector<ButtonValuePair> ButtonValueMap;
55         ///
56         ButtonValueMap map;
57 };
58
59 #endif