2 * \file RadioButtonGroup.C
3 * Copyright 1995 Matthias Ettrich.
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
17 #pragma implementation
20 #include "RadioButtonGroup.h"
21 #include FORMS_H_LOCATION
23 #include "debug.h" // for lyxerr
24 #include "support/lyxfunctional.h"
33 void RadioButtonGroup::init(FL_OBJECT * ob, size_type value)
35 map.push_back(ButtonValuePair(ob, value));
39 void RadioButtonGroup::set(size_type value)
41 ButtonValueMap::const_iterator it =
42 find_if(map.begin(), map.end(),
43 lyx::equal_2nd_in_pair<ButtonValuePair>(value));
45 if (it != map.end()) {
48 // We found nothing: report it and do nothing.
49 lyxerr << "BUG: Requested value in RadioButtonGroup "
50 "doesn't exist" << endl;
55 void RadioButtonGroup::set(FL_OBJECT * ob)
61 template < typename T >
62 struct is_set_button {
63 bool operator() (T const & item) const
65 return fl_get_button((item).first);
70 RadioButtonGroup::size_type RadioButtonGroup::get() const
72 // Find the active button.
73 ButtonValueMap::const_iterator it =
74 find_if(map.begin(), map.end(),
75 is_set_button<ButtonValuePair> ());
80 // We found nothing: report it and return 0
81 lyxerr << "BUG: No active radio button found." << endl;