]> git.lyx.org Git - lyx.git/blobdiff - src/frontends/xforms/RadioButtonGroup.h
Change the semantics of 'none' and 'auto' viewers/editors: 'none' means now
[lyx.git] / src / frontends / xforms / RadioButtonGroup.h
index dbb33337b889efb71f39e86f6b0b05e0bc69f064..3be3c0ad6182c064d8b2e0fc325d343f151efb3e 100644 (file)
@@ -1,60 +1,64 @@
 // -*- C++ -*-
-/* This file is part of
- * =================================================
- * 
- *          LyX, The Document Processor
- *          Copyright 1995 Matthias Ettrich.
- *          Copyright 1995-2000 The LyX Team.
+/**
+ * \file RadioButtonGroup.h
+ * This file is part of LyX, the document processor.
+ * Licence details can be found in the file COPYING.
  *
- *          This file Copyright 2000 Baruch Even
- * ================================================= */
-
-/*
- * This class simplifies the work with a group of radio buttons,
- * the idea is that you register a bunch of radio buttons with the accompanying
- * value for each radio button and then you get to query or set the active
- * button in a single function call.
+ * \author Baruch Even
+ * \author Rob Lahaye
+ *
+ * Full author contact details are available in file CREDITS.
  */
 
+
 #ifndef RADIOBUTTONGROUP_H
 #define RADIOBUTTONGROUP_H
 
-#ifdef __GNUG__
-#pragma interface
-#endif 
-
+#include "support/types.h"
 #include <vector>
 #include <utility>
+#include "forms_fwd.h"
 
-using std::vector;
-using std::pair;
-
-#include FORMS_H_LOCATION
+namespace lyx {
+namespace frontend {
 
-///
+/** This class simplifies interaction with a group of radio buttons:
+ *  one, and only one, can be selected.
+ *  The idea is that you register a bunch of radio buttons with
+ *  an accompanying value. Then you can get or set the active button with a
+ *  single function call.
+ *  It is necessary to also group a family of radio buttons in the
+ *  corresponding .fd file in order to unset the previously chosen button
+ *  when a new one is selected.
+ */
 class RadioButtonGroup {
 public:
-       /// Constructor. Allocate space for 'n' items in the group.
-       RadioButtonGroup(unsigned n = 5) : map(n) {};
 
-       /// Register a radio button with it's corresponding value.
-       void registerRadioButton(FL_OBJECT *button, int value);
-       /// Reset registrations.
-       void reset();
+       /// Register a radio button with its corresponding value.
+       void init(FL_OBJECT * ob, size_type value);
+
+       // Set a single active button.
+       void set(size_type value) const;
+       void set(FL_OBJECT * ob) const;
 
-       // Set the active button.
-       void setButton(int value);
+       // None of the radiobuttons are set.
+       void unset() const;
 
-       // Get the active button.
-       int getButton();
+       // Get the active button's value.
+       size_type get() const;
+
+       void setEnabled(bool enabled);
 
 private:
        ///
-       typedef pair<FL_OBJECT *, int> ButtonValuePair;
+       typedef std::pair<FL_OBJECT *, size_type> ButtonValuePair;
        ///
-       typedef vector<ButtonValuePair> ButtonValueMap;
+       typedef std::vector<ButtonValuePair> ButtonValueMap;
        ///
        ButtonValueMap map;
 };
 
-#endif 
+} // namespace frontend
+} // namespace lyx
+
+#endif // RADIOBUTTONGROUP_H