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
22 #include "support/types.h"
25 #include "forms_fwd.h"
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.
36 class RadioButtonGroup {
39 typedef lyx::size_type size_type;
41 /// Register a radio button with its corresponding value.
42 void init(FL_OBJECT * ob, size_type value);
44 // Set a single active button.
45 void set(size_type value);
46 void set(FL_OBJECT * ob);
48 // Get the active button's value.
49 size_type get() const;
53 typedef std::pair<FL_OBJECT *, size_type> ButtonValuePair;
55 typedef std::vector<ButtonValuePair> ButtonValueMap;