From b8105d810fc2c14ff8566cbc3c689be00d1c0f06 Mon Sep 17 00:00:00 2001 From: Angus Leeming Date: Sat, 16 Jun 2001 14:48:12 +0000 Subject: [PATCH] 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 --- src/frontends/controllers/ButtonController.h | 3 + src/frontends/controllers/ChangeLog | 5 ++ src/frontends/gnome/ChangeLog | 4 ++ src/frontends/gnome/gnomeBC.h | 3 - src/frontends/qt2/ChangeLog | 7 ++ src/frontends/qt2/FormCitationDialogImpl.C | 3 +- src/frontends/qt2/qt2BC.C | 53 ++++---------- src/frontends/qt2/qt2BC.h | 72 +++++--------------- src/frontends/xforms/ChangeLog | 4 ++ src/frontends/xforms/xformsBC.h | 3 - 10 files changed, 56 insertions(+), 101 deletions(-) diff --git a/src/frontends/controllers/ButtonController.h b/src/frontends/controllers/ButtonController.h index 8b4725976c..62e9d18974 100644 --- a/src/frontends/controllers/ButtonController.h +++ b/src/frontends/controllers/ButtonController.h @@ -19,6 +19,9 @@ #include +#include "gettext.h" +#include "ButtonControllerBase.h" + template class GuiBC : public ButtonControllerBase { diff --git a/src/frontends/controllers/ChangeLog b/src/frontends/controllers/ChangeLog index 105e445ac1..4255c0d63c 100644 --- a/src/frontends/controllers/ChangeLog +++ b/src/frontends/controllers/ChangeLog @@ -1,3 +1,8 @@ +2001-06-16 Angus Leeming + + * ButtonController.h: move some included header files out of the + frontends and into here. + 2001-06-15 Angus Leeming * ControlCharacter.C (c-tor): cosmetic name change of signal. diff --git a/src/frontends/gnome/ChangeLog b/src/frontends/gnome/ChangeLog index bb411c2f6f..242e349e91 100644 --- a/src/frontends/gnome/ChangeLog +++ b/src/frontends/gnome/ChangeLog @@ -1,3 +1,7 @@ +2001-06-16 Angus Leeming + + * gnomeBC.h: clean-up of included files. + 2001-06-14 Angus Leeming * FileDialog.C: diff --git a/src/frontends/gnome/gnomeBC.h b/src/frontends/gnome/gnomeBC.h index 42c4e528b8..1b7f200736 100644 --- a/src/frontends/gnome/gnomeBC.h +++ b/src/frontends/gnome/gnomeBC.h @@ -14,13 +14,10 @@ #ifndef GNOMEBC_H #define GNOMEBC_H -#include - #ifdef __GNUG__ #pragma interface #endif -#include "ButtonControllerBase.h" #include "ButtonController.h" namespace Gtk { diff --git a/src/frontends/qt2/ChangeLog b/src/frontends/qt2/ChangeLog index 67bff5a584..76669d5d32 100644 --- a/src/frontends/qt2/ChangeLog +++ b/src/frontends/qt2/ChangeLog @@ -1,3 +1,10 @@ +2001-06-16 Angus Leeming + + * FormCitationDialogImpl.C: added using directive. + + * qt2BC.[Ch]: qt2BC now derives from GuiBC. + No idea why this wasn't done ages ago! + 2001-06-15 Angus Leeming * FormCharacter.C: diff --git a/src/frontends/qt2/FormCitationDialogImpl.C b/src/frontends/qt2/FormCitationDialogImpl.C index ddc96173b8..bf616e0658 100644 --- a/src/frontends/qt2/FormCitationDialogImpl.C +++ b/src/frontends/qt2/FormCitationDialogImpl.C @@ -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 @@ -24,6 +24,7 @@ using std::vector; using std::find; +using std::max; /* * Constructs a FormCitationDialogImpl which is a child of 'parent', with the diff --git a/src/frontends/qt2/qt2BC.C b/src/frontends/qt2/qt2BC.C index 5a862ab15d..4e44a77e36 100644 --- a/src/frontends/qt2/qt2BC.C +++ b/src/frontends/qt2/qt2BC.C @@ -18,48 +18,23 @@ #include qt2BC::qt2BC(string const & cancel, string const & close) - : ButtonControllerBase(cancel, close), - okay_(0), apply_(0), cancel_(0), restore_(0), read_only_() + : GuiBC(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; + obj->setEnabled(enabled); +} + - for (std::list::iterator iter = read_only_.begin(); - iter != read_only_.end(); ++iter) { - (*iter)->setEnabled( enable ); - } - } +void qt2BC::setWidgetEnabled(QWidget * obj, bool enabled) +{ + obj->setEnabled(enabled); +} + + +void qt2BC::setButtonLabel(QButton * obj, string const & label) +{ + obj->setText(label.c_str()); } diff --git a/src/frontends/qt2/qt2BC.h b/src/frontends/qt2/qt2BC.h index 8d6a602ab4..832a8c9984 100644 --- a/src/frontends/qt2/qt2BC.h +++ b/src/frontends/qt2/qt2BC.h @@ -1,90 +1,52 @@ // -*- C++ -*- /* This file is part of - * ====================================================== + * ====================================================== * * 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 - * Non-xforms-specific code stripped-out and placed in a base class by - * Angus Leeming + * \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 - #ifdef __GNUG__ #pragma interface #endif +#include "ButtonController.h" + class QWidget; class QButton; -#include -#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 { 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()); - } +private: + /// Updates the button sensitivity (enabled/disabled) + void setButtonEnabled(QButton *, bool enabled); - /* Action Functions */ - /// force a refresh of the buttons - virtual void refresh(); + /// Updates the widget sensitivity (enabled/disabled) + void setWidgetEnabled(QWidget *, bool enabled); -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 read_only_; + /// Set the label on the button + void setButtonLabel(QButton *, string const & label); }; -#endif // XFORMSBC_H +#endif // QT2BC_H diff --git a/src/frontends/xforms/ChangeLog b/src/frontends/xforms/ChangeLog index c41894d9c2..61f895737d 100644 --- a/src/frontends/xforms/ChangeLog +++ b/src/frontends/xforms/ChangeLog @@ -1,3 +1,7 @@ +2001-06-16 Angus Leeming + + * xformsBC.h: clean-up of included files. + 2001-06-15 Angus Leeming * FormDocument.C: diff --git a/src/frontends/xforms/xformsBC.h b/src/frontends/xforms/xformsBC.h index f631a76eea..21c5ac831c 100644 --- a/src/frontends/xforms/xformsBC.h +++ b/src/frontends/xforms/xformsBC.h @@ -18,14 +18,11 @@ #define XFORMSBC_H #include FORMS_H_LOCATION -#include #ifdef __GNUG__ #pragma interface #endif -#include "gettext.h" -#include "ButtonControllerBase.h" #include "ButtonController.h" class xformsBC : public GuiBC -- 2.39.5