]> git.lyx.org Git - lyx.git/blobdiff - src/frontends/xforms/RadioButtonGroup.C
Change glob() API to accept a dir parameter.
[lyx.git] / src / frontends / xforms / RadioButtonGroup.C
index 374cb564bd1d685a4fe0e73ee0fad989a73fce7f..e292c2ae7b08403039de3db835d91147e10e1b9b 100644 (file)
@@ -1,38 +1,40 @@
 /**
  * \file RadioButtonGroup.C
- * Copyright 1995 Matthias Ettrich.
- * Copyright 2000 Baruch Even
  * This file is part of LyX, the document processor.
  * Licence details can be found in the file COPYING.
  *
  * \author Baruch Even
  * \author Rob Lahaye
  *
- * Full author contact details are available in file CREDITS
+ * Full author contact details are available in file CREDITS.
  */
 
 #include <config.h>
 
-
 #include "RadioButtonGroup.h"
+
+#include "xforms_helpers.h"
+
+#include "debug.h"
+
 #include "lyx_forms.h"
 
-#include "support/LAssert.h"
-#include "debug.h" // for lyxerr
-#include "support/lyxfunctional.h"
+#include <boost/assert.hpp>
+#include <boost/bind.hpp>
 
-#include <algorithm>
-#include <iterator>
+using boost::bind;
 
-using std::find_if;
 using std::endl;
+using std::equal_to;
 
+namespace lyx {
+namespace frontend {
 
 void RadioButtonGroup::init(FL_OBJECT * ob, size_type value)
 {
        // Object must be a ROUND3DBUTTON (let all radio buttons look the same)
        // and of type RADIO_BUTTON (otherwise it ain't work).
-       lyx::Assert(ob && ob->objclass == FL_ROUND3DBUTTON
+       BOOST_ASSERT(ob && ob->objclass == FL_ROUND3DBUTTON
                        && ob->type == FL_RADIO_BUTTON);
 
        map.push_back(ButtonValuePair(ob, value));
@@ -43,7 +45,9 @@ void RadioButtonGroup::set(size_type value) const
 {
        ButtonValueMap::const_iterator it =
                find_if(map.begin(), map.end(),
-                       lyx::equal_2nd_in_pair<ButtonValuePair>(value));
+                       bind(equal_to<size_type>(),
+                            bind(&ButtonValuePair::second, _1),
+                            value));
 
        if (it != map.end()) {
                fl_set_button(it->first, 1);
@@ -74,8 +78,8 @@ void RadioButtonGroup::set(FL_OBJECT * ob) const
 }
 
 
-template < typename T >
-struct is_set_button {
+template <typename T>
+struct is_set_button : public std::unary_function<T, bool> {
        bool operator() (T const & item) const
        {
                return fl_get_button((item).first);
@@ -83,7 +87,22 @@ struct is_set_button {
 };
 
 
-RadioButtonGroup::size_type RadioButtonGroup::get() const
+void RadioButtonGroup::unset() const
+{
+       // Find the active button.
+       ButtonValueMap::const_iterator it =
+               find_if(map.begin(), map.end(),
+                       is_set_button<ButtonValuePair> ());
+
+       if (it == map.end())
+               // Nothing to do. No button is set.
+               return;
+
+       fl_set_button(it->first, 0);
+}
+
+
+size_type RadioButtonGroup::get() const
 {
        // Find the active button.
        ButtonValueMap::const_iterator it =
@@ -97,3 +116,16 @@ RadioButtonGroup::size_type RadioButtonGroup::get() const
        lyxerr << "BUG: No active radio button found." << endl;
        return 0;
 }
+
+
+void RadioButtonGroup::setEnabled(bool enable)
+{
+       ButtonValueMap::iterator it  = map.begin();
+       ButtonValueMap::iterator end = map.end();
+       for (; it != end; ++it) {
+               lyx::frontend::setEnabled(it->first, enable);
+       }
+}
+
+} // namespace frontend
+} // namespace lyx