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.
10 * Full author contact details are available in file CREDITS
14 #ifndef RADIOBUTTONGROUP_H
15 #define RADIOBUTTONGROUP_H
21 #include "support/types.h"
24 #include "forms_fwd.h"
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.
31 class RadioButtonGroup {
34 typedef lyx::size_type size_type;
36 /// Constructor. Allocate space for 'n' items in the group.
37 RadioButtonGroup(unsigned n = 5) : map(n) {};
39 /// Register a radio button with it's corresponding value.
40 void init(FL_OBJECT * button, size_type value);
41 /// Reset registrations.
44 // Set the active button.
45 void set(size_type value);
47 // Get the active button.
48 size_type get() const;
52 typedef std::pair<FL_OBJECT *, size_type> ButtonValuePair;
54 typedef std::vector<ButtonValuePair> ButtonValueMap;