X-Git-Url: https://git.lyx.org/gitweb/?a=blobdiff_plain;f=src%2Ffrontends%2Fxforms%2FRadioButtonGroup.h;h=3be3c0ad6182c064d8b2e0fc325d343f151efb3e;hb=d5443737342903de489d527802cd2cdd38987d74;hp=682f344430f404a8adf85f8965fba88dc08b1441;hpb=67fbbc0fb2030284834ba1fe37c899769e96ec88;p=lyx.git diff --git a/src/frontends/xforms/RadioButtonGroup.h b/src/frontends/xforms/RadioButtonGroup.h index 682f344430..3be3c0ad61 100644 --- a/src/frontends/xforms/RadioButtonGroup.h +++ b/src/frontends/xforms/RadioButtonGroup.h @@ -1,50 +1,54 @@ // -*- C++ -*- /** * \file RadioButtonGroup.h - * Copyright 2002 the LyX Team - * Copyright 2000 Baruch Even - * Read 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 + * \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 #include -#include FORMS_H_LOCATION +#include "forms_fwd.h" + +namespace lyx { +namespace frontend { -/** 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. +/** 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: - /// - typedef lyx::size_type size_type; - /// Constructor. Allocate space for 'n' items in the group. - RadioButtonGroup(unsigned n = 5) : map(n) {}; + /// Register a radio button with its corresponding value. + void init(FL_OBJECT * ob, size_type value); - /// Register a radio button with it's corresponding value. - void init(FL_OBJECT * button, size_type value); - /// Reset registrations. - void reset(); + // Set a single active button. + void set(size_type value) const; + void set(FL_OBJECT * ob) const; - // Set the active button. - void set(size_type value); + // None of the radiobuttons are set. + void unset() const; - // Get the active button. + // Get the active button's value. size_type get() const; + void setEnabled(bool enabled); + private: /// typedef std::pair ButtonValuePair; @@ -54,4 +58,7 @@ private: ButtonValueMap map; }; -#endif +} // namespace frontend +} // namespace lyx + +#endif // RADIOBUTTONGROUP_H