mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-11-28 04:17:43 +00:00
a97c4f51c3
http://www.mail-archive.com/lyx-devel@lists.lyx.org/msg38939.html git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@4393 a592a061-630c-0410-9148-cb99ea01b6c8
58 lines
1.2 KiB
C++
58 lines
1.2 KiB
C++
// -*- C++ -*-
|
|
/**
|
|
* \file RadioButtonGroup.h
|
|
* Copyright 2002 the LyX Team
|
|
* Copyright 2000 Baruch Even
|
|
* Read the file COPYING
|
|
*
|
|
* \author Baruch Even, baruch.even@writeme.com
|
|
*/
|
|
|
|
|
|
#ifndef RADIOBUTTONGROUP_H
|
|
#define RADIOBUTTONGROUP_H
|
|
|
|
#ifdef __GNUG__
|
|
#pragma interface
|
|
#endif
|
|
|
|
#include "support/types.h"
|
|
#include <vector>
|
|
#include <utility>
|
|
#include "forms_fwd.h"
|
|
|
|
/** 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.
|
|
*/
|
|
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 it's corresponding value.
|
|
void init(FL_OBJECT * button, size_type value);
|
|
/// Reset registrations.
|
|
void reset();
|
|
|
|
// Set the active button.
|
|
void set(size_type value);
|
|
|
|
// Get the active button.
|
|
size_type get() const;
|
|
|
|
private:
|
|
///
|
|
typedef std::pair<FL_OBJECT *, size_type> ButtonValuePair;
|
|
///
|
|
typedef std::vector<ButtonValuePair> ButtonValueMap;
|
|
///
|
|
ButtonValueMap map;
|
|
};
|
|
|
|
#endif
|