Clean-up of the button controller.

The Qt frontend now compiles again.


git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@2131 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
Angus Leeming 2001-06-16 14:48:12 +00:00
parent 0e7b7c2125
commit b8105d810f
10 changed files with 58 additions and 103 deletions

View File

@ -19,6 +19,9 @@
#include <list>
#include "gettext.h"
#include "ButtonControllerBase.h"
template <class Button, class Widget>
class GuiBC : public ButtonControllerBase
{

View File

@ -1,3 +1,8 @@
2001-06-16 Angus Leeming <a.leeming@ic.ac.uk>
* ButtonController.h: move some included header files out of the
frontends and into here.
2001-06-15 Angus Leeming <a.leeming@ic.ac.uk>
* ControlCharacter.C (c-tor): cosmetic name change of signal.

View File

@ -1,3 +1,7 @@
2001-06-16 Angus Leeming <a.leeming@ic.ac.uk>
* gnomeBC.h: clean-up of included files.
2001-06-14 Angus Leeming <a.leeming@ic.ac.uk>
* FileDialog.C:

View File

@ -14,13 +14,10 @@
#ifndef GNOMEBC_H
#define GNOMEBC_H
#include <list>
#ifdef __GNUG__
#pragma interface
#endif
#include "ButtonControllerBase.h"
#include "ButtonController.h"
namespace Gtk {

View File

@ -1,3 +1,10 @@
2001-06-16 Angus Leeming <a.leeming@ic.ac.uk>
* FormCitationDialogImpl.C: added using directive.
* qt2BC.[Ch]: qt2BC now derives from GuiBC<QButton, QWidget>.
No idea why this wasn't done ages ago!
2001-06-15 Angus Leeming <a.leeming@ic.ac.uk>
* FormCharacter.C:

View File

@ -1,5 +1,5 @@
/**
* $Id: FormCitationDialogImpl.C,v 1.7 2001/06/05 17:05:51 lasgouttes Exp $
* $Id: FormCitationDialogImpl.C,v 1.8 2001/06/16 14:48:12 leeming Exp $
*/
#include <config.h>
@ -24,6 +24,7 @@
using std::vector;
using std::find;
using std::max;
/*
* Constructs a FormCitationDialogImpl which is a child of 'parent', with the

View File

@ -18,48 +18,23 @@
#include <qbutton.h>
qt2BC::qt2BC(string const & cancel, string const & close)
: ButtonControllerBase(cancel, close),
okay_(0), apply_(0), cancel_(0), restore_(0), read_only_()
: GuiBC<QButton, QWidget>(cancel, close)
{}
void qt2BC::refresh()
void qt2BC::setButtonEnabled(QButton * obj, bool enabled)
{
if (okay_) {
if (bp().buttonStatus(ButtonPolicy::OKAY)) {
okay_->setEnabled( true );
} else {
okay_->setEnabled( false );
}
}
if (apply_) {
if (bp().buttonStatus(ButtonPolicy::APPLY)) {
apply_->setEnabled( true );
} else {
apply_->setEnabled( false );
}
}
if (restore_) {
if (bp().buttonStatus(ButtonPolicy::RESTORE)) {
restore_->setEnabled( true );
} else {
restore_->setEnabled( false );
}
}
if (cancel_) {
if (bp().buttonStatus(ButtonPolicy::CANCEL)) {
cancel_->setText( cancel_label_.c_str() );
} else {
cancel_->setText( close_label_.c_str() );
}
}
if (!read_only_.empty()) {
bool enable = true;
if (bp().isReadOnly()) enable = false;
for (std::list<QWidget *>::iterator iter = read_only_.begin();
iter != read_only_.end(); ++iter) {
(*iter)->setEnabled( enable );
}
}
obj->setEnabled(enabled);
}
void qt2BC::setWidgetEnabled(QWidget * obj, bool enabled)
{
obj->setEnabled(enabled);
}
void qt2BC::setButtonLabel(QButton * obj, string const & label)
{
obj->setText(label.c_str());
}

View File

@ -4,87 +4,49 @@
*
* LyX, The Document Processor
*
* Copyright 1995 Matthias Ettrich
* Copyright 1995-2000 The LyX Team.
* Copyright 2000-2001 The LyX Team.
*
* This file Copyright 2000
* Allan Rae
* ======================================================
*
* Author: Allan Rae <rae@lyx.org>
* Non-xforms-specific code stripped-out and placed in a base class by
* Angus Leeming <a.leeming@ic.ac.uk>
* \file qt2BC.h
* \author Allan Rae, rae@lyx.org
* \author Angus Leeming, a.leeming@ic.ac.uk
* \author Baruch Even, baruch.even@writeme.com
*/
#ifndef QT2BC_H
#define QT2BC_H
#include <list>
#ifdef __GNUG__
#pragma interface
#endif
#include "ButtonController.h"
class QWidget;
class QButton;
#include <boost/utility.hpp>
#include "ButtonControllerBase.h"
#include "ButtonController.h"
/** General purpose button controller for up to four buttons.
Controls the activation of the OK, Apply and Cancel buttons.
Actually supports 4 buttons in all and it's up to the user to decide on
the activation policy and which buttons correspond to which output of the
state machine.
*/
class qt2BC : public ButtonControllerBase
class qt2BC : public GuiBC<QButton, QWidget>
{
public:
///
qt2BC(string const &, string const &);
/* Initialise Button Functions */
/// Call refresh() when finished setting the buttons.
void setOK(QButton * obj) {
okay_ = obj;
}
///
void setApply(QButton * obj) {
apply_ = obj;
}
///
void setCancel(QButton * obj) {
cancel_ = obj;
}
///
void setRestore(QButton * obj) {
restore_ = obj;
}
///
void addReadOnly(QWidget * obj) {
read_only_.push_front(obj);
}
///
void eraseReadOnly() {
read_only_.erase(read_only_.begin(), read_only_.end());
}
/* Action Functions */
/// force a refresh of the buttons
virtual void refresh();
private:
///
QButton * okay_;
///
QButton * apply_;
///
QButton * cancel_;
///
QButton * restore_;
/// List of items to be deactivated when in one of the read-only states
std::list<QWidget *> read_only_;
/// Updates the button sensitivity (enabled/disabled)
void setButtonEnabled(QButton *, bool enabled);
/// Updates the widget sensitivity (enabled/disabled)
void setWidgetEnabled(QWidget *, bool enabled);
/// Set the label on the button
void setButtonLabel(QButton *, string const & label);
};
#endif // XFORMSBC_H
#endif // QT2BC_H

View File

@ -1,3 +1,7 @@
2001-06-16 Angus Leeming <a.leeming@ic.ac.uk>
* xformsBC.h: clean-up of included files.
2001-06-15 Angus Leeming <a.leeming@ic.ac.uk>
* FormDocument.C:

View File

@ -18,14 +18,11 @@
#define XFORMSBC_H
#include FORMS_H_LOCATION
#include <list>
#ifdef __GNUG__
#pragma interface
#endif
#include "gettext.h"
#include "ButtonControllerBase.h"
#include "ButtonController.h"
class xformsBC : public GuiBC<FL_OBJECT, FL_OBJECT>