3 * \file RadioButtonGroup.h
4 * Copyright 2002 the LyX Team
5 * Copyright 2000 Baruch Even
6 * Read the file COPYING
8 * \author Baruch Even, baruch.even@writeme.com
12 #ifndef RADIOBUTTONGROUP_H
13 #define RADIOBUTTONGROUP_H
19 #include "support/types.h"
22 #include "forms_fwd.h"
24 /** This class simplifies the work with a group of radio buttons,
25 * the idea is that you register a bunch of radio buttons with the accompanying
26 * value for each radio button and then you get to query or set the active
27 * button in a single function call.
29 class RadioButtonGroup {
32 typedef lyx::size_type size_type;
34 /// Constructor. Allocate space for 'n' items in the group.
35 RadioButtonGroup(unsigned n = 5) : map(n) {};
37 /// Register a radio button with it's corresponding value.
38 void init(FL_OBJECT * button, size_type value);
39 /// Reset registrations.
42 // Set the active button.
43 void set(size_type value);
45 // Get the active button.
46 size_type get() const;
50 typedef std::pair<FL_OBJECT *, size_type> ButtonValuePair;
52 typedef std::vector<ButtonValuePair> ButtonValueMap;