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