]> git.lyx.org Git - lyx.git/blobdiff - src/frontends/xforms/RadioButtonGroup.C
Yet more dialog tweaking from Rob.
[lyx.git] / src / frontends / xforms / RadioButtonGroup.C
index e2a0df2cff90a54d25337682db63e90b3875fd8c..19e350c5f88deb00ad8f0772c29f7ccabd64793c 100644 (file)
@@ -1,20 +1,23 @@
 /**
  * \file RadioButtonGroup.C
  * Copyright 1995 Matthias Ettrich.
- * Copyright 1995-2001 The LyX Team.
  * Copyright 2000 Baruch Even
- * See the file COPYING.
+ * This file is part of LyX, the document processor.
+ * Licence details can be found in the file COPYING.
  *
- * \author Baruch Even, baruch.even@writeme.com
+ * \author Baruch Even
+ *
+ * Full author contact details are available in file CREDITS
  */
 
-#include <config.h> 
+#include <config.h>
 
 #ifdef __GNUG__
 #pragma implementation
-#endif 
+#endif
 
 #include "RadioButtonGroup.h"
+#include FORMS_H_LOCATION
 
 #include "debug.h" // for lyxerr
 #include "support/lyxfunctional.h"
@@ -28,7 +31,7 @@ using std::find_if;
 using std::endl;
 
 
-void RadioButtonGroup::registerRadioButton(FL_OBJECT *button, int value)
+void RadioButtonGroup::init(FL_OBJECT *button, size_type value)
 {
        map.push_back(ButtonValuePair(button, value));
 }
@@ -40,48 +43,16 @@ void RadioButtonGroup::reset()
 }
 
 
-#if 0
-// Functor to help us in our work, we should try to find how to achieve
-// this with only STL predicates, but its easier to write this than to
-// dig. If you can find the equivalent STL predicate combination, let me
-// know.
-//
-// The idea is to take a pair and a value and return true when the second
-// element in the pair equals the value.
-template < typename T >
-struct equal_to_second_in_pair
+void RadioButtonGroup::set(size_type value)
 {
-       typedef bool result_type;
-       typedef T       first_argument_type;
-       typedef typename T::second_type second_argument_type;
-
-       bool operator() (
-           pair < typename T::first_type, typename T::second_type > const & left,
-           typename T::second_type const & right) const
-       {
-               return left.second == right;
-       }
-};
-#endif
-
-
-void RadioButtonGroup::setButton(int value)
-{
-#if 0
-       ButtonValueMap::const_iterator it =
-           find_if(map.begin(), map.end(),
-                   bind2nd(equal_to_second_in_pair<ButtonValuePair>(),
-                           value));
-#else
        ButtonValueMap::const_iterator it =
                find_if(map.begin(), map.end(),
                        lyx::equal_2nd_in_pair<ButtonValuePair>(value));
-#endif
-       
+
        // If we found nothing, report it and return
        if (it == map.end()) {
                lyxerr << "BUG: Requested value in RadioButtonGroup doesn't exists"
-               << endl;
+                      << endl;
        }
        else {
                fl_set_button(it->first, 1);
@@ -99,12 +70,12 @@ struct is_set_button {
 };
 
 
-int RadioButtonGroup::getButton()
+RadioButtonGroup::size_type RadioButtonGroup::get() const
 {
        // Find the first button that is active
-       ButtonValueMap::iterator it =
-           find_if(map.begin(), map.end(),
-                   is_set_button<ButtonValuePair> ());
+       ButtonValueMap::const_iterator it =
+               find_if(map.begin(), map.end(),
+                       is_set_button<ButtonValuePair> ());
 
        // If such a button was found, return its value.
        if (it != map.end()) {
@@ -116,4 +87,3 @@ int RadioButtonGroup::getButton()
        // Else return 0.
        return 0;
 }
-