mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-11-11 21:49:51 +00:00
92c3fca0bb
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@7625 a592a061-630c-0410-9148-cb99ea01b6c8
62 lines
1.5 KiB
C++
62 lines
1.5 KiB
C++
// -*- C++ -*-
|
|
/**
|
|
* \file RadioButtonGroup.h
|
|
* 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.
|
|
*/
|
|
|
|
|
|
#ifndef RADIOBUTTONGROUP_H
|
|
#define RADIOBUTTONGROUP_H
|
|
|
|
|
|
#include "support/types.h"
|
|
#include <vector>
|
|
#include <utility>
|
|
#include "forms_fwd.h"
|
|
|
|
/** 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;
|
|
|
|
/// 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;
|
|
|
|
// None of the radiobuttons are set.
|
|
void unset() const;
|
|
|
|
// Get the active button's value.
|
|
size_type get() const;
|
|
|
|
void setEnabled(bool enabled);
|
|
|
|
private:
|
|
///
|
|
typedef std::pair<FL_OBJECT *, size_type> ButtonValuePair;
|
|
///
|
|
typedef std::vector<ButtonValuePair> ButtonValueMap;
|
|
///
|
|
ButtonValueMap map;
|
|
};
|
|
|
|
#endif // RADIOBUTTONGROUP_H
|