X-Git-Url: https://git.lyx.org/gitweb/?a=blobdiff_plain;f=src%2Ffrontends%2Fcontrollers%2FButtonController.h;h=43f7b041a6f13e1cc3abbead0e597366d3277208;hb=a61a18e2a0d7b91dd364b2d7c4a91800a4c1cec9;hp=ed18f63cbf9f3ea13f87147dfe3c3173e198b0c6;hpb=58d99b4a97b85a750704cf84c9639b408117271c;p=lyx.git diff --git a/src/frontends/controllers/ButtonController.h b/src/frontends/controllers/ButtonController.h index ed18f63cbf..43f7b041a6 100644 --- a/src/frontends/controllers/ButtonController.h +++ b/src/frontends/controllers/ButtonController.h @@ -1,13 +1,9 @@ -/* This file is part of - * ====================================================== - * - * LyX, The Document Processor - * - * Copyright 2000-2001 The LyX Team. - * - * ====================================================== - * +// -*- C++ -*- +/* * \file ButtonController.h + * Copyright 2002 the LyX Team + * Read the file COPYING + * * \author Allan Rae, rae@lyx.org * \author Angus Leeming, a.leeming@ic.ac.uk * \author Baruch Even, baruch.even@writeme.com @@ -16,8 +12,16 @@ #ifndef BUTTONCONTROLLER_H #define BUTTONCONTROLLER_H + +#include "ButtonControllerBase.h" +#include "gettext.h" #include +/** A templatised instantiation of the ButtonController requiring the + * gui-frontend widgets. + * The template declarations are in ButtonController.tmpl, which should + * be #included in the gui-frontend BC class, see e.g. xforms/xformsBC.C + */ template class GuiBC : public ButtonControllerBase { @@ -32,14 +36,16 @@ public: /// void setCancel(Button * obj) { cancel_ = obj; } /// - void setUndoAll(Button * obj) { undo_all_ = obj; } + void setRestore(Button * obj) { restore_ = obj; } /// void addReadOnly(Widget * obj) { read_only_.push_back(obj); } /// void eraseReadOnly() { read_only_.clear(); } - /// Refresh the widgets status. + /// Refresh the status of the Ok, Apply, Restore, Cancel buttons. void refresh(); + /// Refresh the status of any widgets in the read_only list + void refreshReadOnly(); private: /// Enable/Disable a widget @@ -51,58 +57,14 @@ private: Button * okay_; Button * apply_; - Button * undo_all_; Button * cancel_; + Button * restore_; typedef std::list Widgets; Widgets read_only_; }; -template -GuiBC::GuiBC(string const & cancel, string const & close) - : ButtonControllerBase(cancel, close) - , okay_(0), apply_(0), cancel_(0), undo_all_(0) -{} - - -template -void GuiBC::refresh() -{ - if (okay_) { - bool const enabled = bp().buttonStatus(ButtonPolicy::OKAY); - setButtonEnabled(okay_, enabled); - } - if (apply_) { - bool const enabled = bp().buttonStatus(ButtonPolicy::APPLY); - setButtonEnabled(apply_, enabled); - } - if (undo_all_) { - bool const enabled = bp().buttonStatus(ButtonPolicy::UNDO_ALL); - setButtonEnabled(undo_all_, enabled); - } - if (cancel_) { - bool const enabled = bp().buttonStatus(ButtonPolicy::CANCEL); - if (enabled) - setButtonLabel(cancel_, cancel_label_); - else - setButtonLabel(cancel_, close_label_); - } - - // Enable/Disable read-only handled widgets. - if (!read_only_.empty()) { - bool const enable = !bp().isReadOnly(); - - Widgets::const_iterator end = read_only_.end(); - Widgets::const_iterator iter = read_only_.begin(); - for (; iter != end; ++iter) { - setWidgetEnabled(*iter, enable); - } - } - -} - - template class ButtonController: public GUIBC { @@ -119,10 +81,4 @@ protected: }; -template -ButtonController::ButtonController(string const & cancel, - string const & close) - : GUIBC(cancel, close) -{} - #endif // BUTTONCONTROLLER_H