2000-07-31 12:30:10 +00:00
|
|
|
// -*- C++ -*-
|
2002-03-11 17:00:41 +00:00
|
|
|
/**
|
|
|
|
* \file RadioButtonGroup.h
|
|
|
|
* Copyright 2002 the LyX Team
|
|
|
|
* Copyright 2000 Baruch Even
|
|
|
|
* Read the file COPYING
|
2000-07-31 12:30:10 +00:00
|
|
|
*
|
2002-03-11 17:00:41 +00:00
|
|
|
* \author Baruch Even, baruch.even@writeme.com
|
|
|
|
*/
|
2000-07-31 12:30:10 +00:00
|
|
|
|
|
|
|
|
|
|
|
#ifndef RADIOBUTTONGROUP_H
|
|
|
|
#define RADIOBUTTONGROUP_H
|
|
|
|
|
|
|
|
#ifdef __GNUG__
|
|
|
|
#pragma interface
|
2002-03-21 21:21:28 +00:00
|
|
|
#endif
|
2000-07-31 12:30:10 +00:00
|
|
|
|
2002-03-25 11:16:15 +00:00
|
|
|
#include "support/types.h"
|
|
|
|
#include <vector>
|
|
|
|
#include <utility>
|
2002-06-13 13:43:51 +00:00
|
|
|
#include "forms_fwd.h"
|
2000-07-31 12:30:10 +00:00
|
|
|
|
2000-10-02 00:10:25 +00:00
|
|
|
/** 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.
|
|
|
|
*/
|
2000-08-14 15:31:16 +00:00
|
|
|
class RadioButtonGroup {
|
2000-07-31 12:30:10 +00:00
|
|
|
public:
|
2002-03-25 11:16:15 +00:00
|
|
|
///
|
|
|
|
typedef lyx::size_type size_type;
|
|
|
|
|
2000-08-14 09:44:53 +00:00
|
|
|
/// Constructor. Allocate space for 'n' items in the group.
|
|
|
|
RadioButtonGroup(unsigned n = 5) : map(n) {};
|
|
|
|
|
|
|
|
/// Register a radio button with it's corresponding value.
|
2002-03-25 11:16:15 +00:00
|
|
|
void init(FL_OBJECT * button, size_type value);
|
2000-08-14 09:44:53 +00:00
|
|
|
/// Reset registrations.
|
|
|
|
void reset();
|
|
|
|
|
|
|
|
// Set the active button.
|
2002-03-25 11:16:15 +00:00
|
|
|
void set(size_type value);
|
2000-08-14 09:44:53 +00:00
|
|
|
|
|
|
|
// Get the active button.
|
2002-03-25 11:16:15 +00:00
|
|
|
size_type get() const;
|
2000-08-14 09:44:53 +00:00
|
|
|
|
2000-07-31 12:30:10 +00:00
|
|
|
private:
|
2000-08-14 15:31:16 +00:00
|
|
|
///
|
2002-03-25 11:16:15 +00:00
|
|
|
typedef std::pair<FL_OBJECT *, size_type> ButtonValuePair;
|
2000-08-14 15:31:16 +00:00
|
|
|
///
|
2002-02-16 15:59:55 +00:00
|
|
|
typedef std::vector<ButtonValuePair> ButtonValueMap;
|
2000-08-14 15:31:16 +00:00
|
|
|
///
|
2000-08-14 09:44:53 +00:00
|
|
|
ButtonValueMap map;
|
2000-07-31 12:30:10 +00:00
|
|
|
};
|
|
|
|
|
2002-03-21 21:21:28 +00:00
|
|
|
#endif
|