]> git.lyx.org Git - lyx.git/blob - src/frontends/xforms/RadioButtonGroup.h
2b5623deb6a19e58200125eb7c1ad38c1fa51c7a
[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-2001 The LyX Team.
8  *
9  *          This file Copyright 2000 Baruch Even
10  * ================================================= */
11
12
13 #ifndef RADIOBUTTONGROUP_H
14 #define RADIOBUTTONGROUP_H
15
16 #include <vector>
17 #include <utility>
18
19 #include FORMS_H_LOCATION
20
21 #ifdef __GNUG__
22 #pragma interface
23 #endif 
24
25
26 /** This class simplifies the work with a group of radio buttons,
27  * the idea is that you register a bunch of radio buttons with the accompanying
28  * value for each radio button and then you get to query or set the active
29  * button in a single function call.
30  * @author Baruch Even
31  */
32 class RadioButtonGroup {
33 public:
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 registerRadioButton(FL_OBJECT * button, int value);
39         /// Reset registrations.
40         void reset();
41
42         // Set the active button.
43         void setButton(int value);
44
45         // Get the active button.
46         int getButton();
47
48 private:
49         ///
50         typedef std::pair<FL_OBJECT *, int> ButtonValuePair;
51         ///
52         typedef std::vector<ButtonValuePair> ButtonValueMap;
53         ///
54         ButtonValueMap map;
55 };
56
57 #endif