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.
11 * Full author contact details are available in file CREDITS
15 #ifndef RADIOBUTTONGROUP_H
16 #define RADIOBUTTONGROUP_H
19 #include "support/types.h"
22 #include "forms_fwd.h"
24 /** This class simplifies interaction with a group of radio buttons:
25 * one, and only one, can be selected.
26 * The idea is that you register a bunch of radio buttons with
27 * an accompanying value. Then you can get or set the active button with a
28 * single function call.
29 * It is necessary to also group a family of radio buttons in the
30 * corresponding .fd file in order to unset the previously chosen button
31 * when a new one is selected.
33 class RadioButtonGroup {
36 typedef lyx::size_type size_type;
38 /// Register a radio button with its corresponding value.
39 void init(FL_OBJECT * ob, size_type value);
41 // Set a single active button.
42 void set(size_type value) const;
43 void set(FL_OBJECT * ob) const;
45 // Get the active button's value.
46 size_type get() const;
50 typedef std::pair<FL_OBJECT *, size_type> ButtonValuePair;
52 typedef std::vector<ButtonValuePair> ButtonValueMap;
57 #endif // RADIOBUTTONGROUP_H