]> git.lyx.org Git - lyx.git/blobdiff - src/frontends/xforms/RadioButtonGroup.C
Tiny clean-ups.
[lyx.git] / src / frontends / xforms / RadioButtonGroup.C
index 145d641cb42cc94feb90ae86d55c3335cd1499a9..7509b78378984e6af58bf8b5697dadd3a503d24a 100644 (file)
@@ -6,25 +6,23 @@
  * \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 "lyx_forms.h"
 
-#include "support/LAssert.h"
-#include "debug.h" // for lyxerr
+#include "xforms_helpers.h"
+
+#include "debug.h"
+
 #include "support/lyxfunctional.h"
 
-#include <algorithm>
-#include <iterator>
+#include "lyx_forms.h"
 
-using namespace lyx::support;
+#include <boost/assert.hpp>
 
-using std::find_if;
 using std::endl;
 
 
@@ -32,7 +30,7 @@ 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).
-       Assert(ob && ob->objclass == FL_ROUND3DBUTTON
+       BOOST_ASSERT(ob && ob->objclass == FL_ROUND3DBUTTON
                        && ob->type == FL_RADIO_BUTTON);
 
        map.push_back(ButtonValuePair(ob, value));
@@ -83,6 +81,21 @@ struct is_set_button {
 };
 
 
+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);
+}
+
+
 RadioButtonGroup::size_type RadioButtonGroup::get() const
 {
        // Find the active button.
@@ -97,3 +110,13 @@ 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) {
+               ::setEnabled(it->first, enable);
+       }
+}