]> git.lyx.org Git - lyx.git/blob - src/frontends/xforms/RadioButtonGroup.h
fix crash with "save as"
[lyx.git] / src / frontends / xforms / RadioButtonGroup.h
1 // -*- C++ -*-
2 /**
3  * \file RadioButtonGroup.h
4  * Copyright 2000 Baruch Even
5  * This file is part of LyX, the document processor.
6  * Licence details can be found in the file COPYING.
7  *
8  * \author Baruch Even
9  * \author Rob Lahaye
10  *
11  * Full author contact details are available in file CREDITS
12  */
13
14
15 #ifndef RADIOBUTTONGROUP_H
16 #define RADIOBUTTONGROUP_H
17
18 #ifdef __GNUG__
19 #pragma interface
20 #endif
21
22 #include "support/types.h"
23 #include <vector>
24 #include <utility>
25 #include "forms_fwd.h"
26
27 /** This class simplifies interaction with a group of radio buttons:
28  *  one, and only one, can be selected.
29  *  The idea is that you register a bunch of radio buttons with
30  *  an accompanying value. Then you can get or set the active button with a
31  *  single function call.
32  *  It is necessary to also group a family of radio buttons in the
33  *  corresponding .fd file in order to unset the previously chosen button
34  *  when a new one is selected.
35  */
36 class RadioButtonGroup {
37 public:
38         ///
39         typedef lyx::size_type size_type;
40
41         /// Register a radio button with its corresponding value.
42         void init(FL_OBJECT * ob, size_type value);
43
44         // Set a single active button.
45         void set(size_type value);
46         void set(FL_OBJECT * ob);
47
48         // Get the active button's value.
49         size_type get() const;
50
51 private:
52         ///
53         typedef std::pair<FL_OBJECT *, size_type> ButtonValuePair;
54         ///
55         typedef std::vector<ButtonValuePair> ButtonValueMap;
56         ///
57         ButtonValueMap map;
58 };
59
60 #endif