2000-07-31 12:30:10 +00:00
|
|
|
// -*- C++ -*-
|
2002-03-11 17:00:41 +00:00
|
|
|
/**
|
|
|
|
* \file RadioButtonGroup.h
|
|
|
|
* Copyright 2000 Baruch Even
|
2002-09-05 15:14:23 +00:00
|
|
|
* This file is part of LyX, the document processor.
|
|
|
|
* Licence details can be found in the file COPYING.
|
2000-07-31 12:30:10 +00:00
|
|
|
*
|
2002-09-05 14:10:50 +00:00
|
|
|
* \author Baruch Even
|
2002-10-23 08:31:10 +00:00
|
|
|
* \author Rob Lahaye
|
2002-09-05 14:10:50 +00:00
|
|
|
*
|
|
|
|
* Full author contact details are available in file CREDITS
|
2002-03-11 17:00:41 +00:00
|
|
|
*/
|
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
|
|
|
|
2002-10-23 08:31:10 +00:00
|
|
|
/** 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.
|
2000-10-02 00:10:25 +00:00
|
|
|
*/
|
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;
|
|
|
|
|
2002-10-23 08:31:10 +00:00
|
|
|
/// Register a radio button with its corresponding value.
|
|
|
|
void init(FL_OBJECT * ob, size_type value);
|
2000-08-14 09:44:53 +00:00
|
|
|
|
2002-10-23 08:31:10 +00:00
|
|
|
// Set a single active button.
|
2002-03-25 11:16:15 +00:00
|
|
|
void set(size_type value);
|
2002-10-23 08:31:10 +00:00
|
|
|
void set(FL_OBJECT * ob);
|
2000-08-14 09:44:53 +00:00
|
|
|
|
2002-10-23 08:31:10 +00:00
|
|
|
// Get the active button's value.
|
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
|