From 1a0655a514d379e80609a4124bfe71d91929c519 Mon Sep 17 00:00:00 2001 From: Angus Leeming Date: Mon, 25 Nov 2002 18:58:15 +0000 Subject: [PATCH] * A controller-view split of the math panel and its daughter dialogs. * Get rid of FormBaseDeprecated. * Merge FormBase and FeedbackController. git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@5715 a592a061-630c-0410-9148-cb99ea01b6c8 --- src/frontends/controllers/ChangeLog | 7 + src/frontends/controllers/ControlDialog.h | 2 +- src/frontends/controllers/ControlMath.C | 98 ++++- src/frontends/controllers/ControlMath.h | 87 ++++- src/frontends/xforms/ChangeLog | 29 ++ src/frontends/xforms/Dialogs2.C | 2 +- src/frontends/xforms/Dialogs_impl.h | 21 +- src/frontends/xforms/FeedbackController.C | 191 ---------- src/frontends/xforms/FeedbackController.h | 77 ---- src/frontends/xforms/FormBase.C | 161 +++++++- src/frontends/xforms/FormBase.h | 51 ++- src/frontends/xforms/FormBaseDeprecated.C | 360 ------------------ src/frontends/xforms/FormBaseDeprecated.h | 189 --------- src/frontends/xforms/FormMathsBitmap.C | 146 ++++--- src/frontends/xforms/FormMathsBitmap.h | 79 ++-- src/frontends/xforms/FormMathsDeco.C | 25 +- src/frontends/xforms/FormMathsDeco.h | 28 +- src/frontends/xforms/FormMathsDelim.C | 36 +- src/frontends/xforms/FormMathsDelim.h | 27 +- src/frontends/xforms/FormMathsMatrix.C | 35 +- src/frontends/xforms/FormMathsMatrix.h | 29 +- src/frontends/xforms/FormMathsPanel.C | 138 +++---- src/frontends/xforms/FormMathsPanel.h | 90 +---- src/frontends/xforms/FormMathsSpace.C | 24 +- src/frontends/xforms/FormMathsSpace.h | 27 +- src/frontends/xforms/FormMathsStyle.C | 31 +- src/frontends/xforms/FormMathsStyle.h | 27 +- src/frontends/xforms/Makefile.am | 4 - src/frontends/xforms/forms/form_maths_deco.fd | 6 +- .../xforms/forms/form_maths_delim.fd | 10 +- .../xforms/forms/form_maths_matrix.fd | 14 +- .../xforms/forms/form_maths_panel.fd | 48 +-- .../xforms/forms/form_maths_space.fd | 18 +- .../xforms/forms/form_maths_style.fd | 14 +- 34 files changed, 793 insertions(+), 1338 deletions(-) delete mode 100644 src/frontends/xforms/FeedbackController.C delete mode 100644 src/frontends/xforms/FeedbackController.h delete mode 100644 src/frontends/xforms/FormBaseDeprecated.C delete mode 100644 src/frontends/xforms/FormBaseDeprecated.h diff --git a/src/frontends/controllers/ChangeLog b/src/frontends/controllers/ChangeLog index 1b59357705..42264b85dd 100644 --- a/src/frontends/controllers/ChangeLog +++ b/src/frontends/controllers/ChangeLog @@ -1,3 +1,10 @@ +2002-11-25 Angus Leeming + + * ControlDialog.h (hide, update): move from protected to public. + + * ControlMath.[Ch]: add controllers for the main math panel dialog and + for any daughter dialogs stored by the main panel. + 2002-11-21 Angus Leeming * ControlDocument.[Ch] (classApply): no longer returns bool. diff --git a/src/frontends/controllers/ControlDialog.h b/src/frontends/controllers/ControlDialog.h index e6a5e3657e..27b988a6f9 100644 --- a/src/frontends/controllers/ControlDialog.h +++ b/src/frontends/controllers/ControlDialog.h @@ -34,12 +34,12 @@ public: * Publicly accessible so that it can be invoked by the Dialogs class. */ virtual void show(); -protected: /// Hide the dialog. virtual void hide(); /// Update the dialog. virtual void update(); +protected: /// clean-up on hide. virtual void clearParams() {} /// set the params before show or update diff --git a/src/frontends/controllers/ControlMath.C b/src/frontends/controllers/ControlMath.C index 62fa32cc78..6004d5e1be 100644 --- a/src/frontends/controllers/ControlMath.C +++ b/src/frontends/controllers/ControlMath.C @@ -12,10 +12,106 @@ #include #include "ControlMath.h" +#include "ViewBase.h" + +#include "debug.h" +#include "funcrequest.h" + +#include "frontends/LyXView.h" #include "support/lstrings.h" #include "support/filetools.h" -#include "debug.h" + + +ControlMath::ControlMath(LyXView & lv, Dialogs & d) + : ControlDialogBD(lv, d) +{} + + +void ControlMath::apply() +{ + view().apply(); +} + + +void ControlMath::dispatchFunc(kb_action action, string const & arg) const +{ + lv_.dispatch(FuncRequest(action, arg)); +} + + +void ControlMath::insertSymbol(string const & sym, bool bs) const +{ + if (bs) + lv_.dispatch(FuncRequest(LFUN_INSERT_MATH, '\\' + sym)); + else + lv_.dispatch(FuncRequest(LFUN_INSERT_MATH, sym)); +} + + +void ControlMath::addDaughter(void * key, ViewBase * v, + ButtonControllerBase * bc) +{ + if (daughters_.find(key) != daughters_.end()) + return; + + daughters_[key] = DaughterPtr(new GUIMathSub(lv_, d_, *this, v, bc)); +} + + +void ControlMath::showDaughter(void * key) +{ + Store::iterator it = daughters_.find(key); + GUIMathSub * const new_active = + (it == daughters_.end()) ? 0 : it->second.get(); + + if (active_ != new_active) { + if (active_ ) + active_->controller().hide(); + active_ = new_active; + } + + if (active_) + active_->controller().show(); +} + + + +ControlMathSub::ControlMathSub(LyXView & lv, Dialogs & d, ControlMath const & p) + : ControlDialogBD(lv, d), + parent_(p) +{} + + +void ControlMathSub::apply() +{ + view().apply(); +} + + +void ControlMathSub::dispatchFunc(kb_action action, string const & arg) const +{ + parent_.dispatchFunc(action, arg); +} + + +void ControlMathSub::insertSymbol(string const & sym, bool bs) const +{ + parent_.insertSymbol(sym, bs); +} + + +GUIMathSub::GUIMathSub(LyXView & lv, Dialogs & d, + ControlMath const & p, + ViewBase * v, + ButtonControllerBase * bc) + : controller_(lv, d, p), bc_(bc), view_(v) +{ + controller_.setView(*view_); + controller_.setButtonController(*bc_); + view_->setController(controller_); +} + char const * function_names[] = { "arccos", "arcsin", "arctan", "arg", "bmod", diff --git a/src/frontends/controllers/ControlMath.h b/src/frontends/controllers/ControlMath.h index 2391a5f6ee..597ab179ec 100644 --- a/src/frontends/controllers/ControlMath.h +++ b/src/frontends/controllers/ControlMath.h @@ -6,6 +6,7 @@ * * \author Alejandro Aguilar Sierra * \author John Levon + * \author Angus Leeming * * Full author contact details are available in file CREDITS */ @@ -13,8 +14,92 @@ #ifndef CONTROL_MATH_H #define CONTROL_MATH_H +#include "commandtags.h" +#include "ControlDialog_impl.h" + +#include "ButtonController.h" +#include "ButtonPolicies.h" + #include "LString.h" - +#include +#include + + +class GUIMathSub; + + +class ControlMath : public ControlDialogBD { +public: + /// + ControlMath(LyXView &, Dialogs &); + + /// dispatch an LFUN + void dispatchFunc(kb_action act, string const & arg = string()) const; + /// dispatch a symbol insert + void insertSymbol(string const & sym, bool bs = true) const; + + /// + void addDaughter(void * key, ViewBase * v, ButtonControllerBase * bc); + /// + void showDaughter(void *); + +private: + /// + virtual void apply(); + + /// + typedef boost::shared_ptr DaughterPtr; + /// + typedef std::map Store; + + /** The store of all daughter dialogs. + * The map uses the button on the main panel to identify them. + */ + Store daughters_; + + /// A pointer to the currently active daughter dialog. + GUIMathSub * active_; +}; + + +class ControlMathSub : public ControlDialogBD { +public: + /// + ControlMathSub(LyXView &, Dialogs &, ControlMath const & p); + + /// dispatch an LFUN + void dispatchFunc(kb_action act, string const & arg = string()) const; + /// dispatch a symbol insert + void insertSymbol(string const & sym, bool bs = true) const; + +private: + /// + virtual void apply(); + /// + ControlMath const & parent_; +}; + + +class GUIMathSub { +public: + /// + GUIMathSub(LyXView & lv, Dialogs & d, + ControlMath const & p, + ViewBase * v, + ButtonControllerBase * bc); + /// + ControlMathSub & controller() { return controller_; } + +private: + /// + ControlMathSub controller_; + /// + boost::scoped_ptr bc_; + /// + boost::scoped_ptr view_; +}; + + extern char const * function_names[]; extern int const nr_function_names; extern char const * latex_arrow[]; diff --git a/src/frontends/xforms/ChangeLog b/src/frontends/xforms/ChangeLog index d617cf5a98..b2105f524c 100644 --- a/src/frontends/xforms/ChangeLog +++ b/src/frontends/xforms/ChangeLog @@ -1,3 +1,32 @@ +2002-11-25 Angus Leeming + + * Dialogs_impl.h: + * Dialogs2.C: no need to include math sub dialog header files. + Use standard MCV implementation of main math panel dialog. + + * FormBaseDeprecated.[Ch]: + * FeedbackController.[Ch]: removed. + + * FormBase.[Ch]: Merge the contents of FeedbackController into here + also. + (FormCB): make the controller methods publicly accessible. + + * forms/form_maths_deco.fd: + * forms/form_maths_delim.fd: + * forms/form_maths_matrix.fd: + * forms/form_maths_panel.fd: + * forms/form_maths_space.fd: + * forms/form_maths_style.fd: s/Deprecated// + + * FormMathsBitmap.[Ch]: + * FormMathsDeco.[Ch]: + * FormMathsDelim.[Ch]: + * FormMathsMatrix.[Ch]: + * FormMathsPanel.[Ch]: + * FormMathsSpace.[Ch]: + * FormMathsStyle.[Ch]: implement a Controller-View split of the math + dialogs. + 2002-11-22 Angus Leeming The first step towards a math dialog controller... diff --git a/src/frontends/xforms/Dialogs2.C b/src/frontends/xforms/Dialogs2.C index 2544acd6ac..4a2767a2ac 100644 --- a/src/frontends/xforms/Dialogs2.C +++ b/src/frontends/xforms/Dialogs2.C @@ -141,7 +141,7 @@ void Dialogs::showLogFile() void Dialogs::showMathPanel() { - pimpl_->mathpanel.show(); + pimpl_->mathpanel.controller().show(); } diff --git a/src/frontends/xforms/Dialogs_impl.h b/src/frontends/xforms/Dialogs_impl.h index d5852dbe5f..591682988a 100644 --- a/src/frontends/xforms/Dialogs_impl.h +++ b/src/frontends/xforms/Dialogs_impl.h @@ -87,26 +87,10 @@ #include "ControlShowFile.h" #include "FormShowFile.h" -#include "FormMathsBitmap.h" - +#include "ControlMath.h" #include "FormMathsPanel.h" #include "forms/form_maths_panel.h" -#include "FormMathsDeco.h" -#include "forms/form_maths_deco.h" - -#include "FormMathsDelim.h" -#include "forms/form_maths_delim.h" - -#include "FormMathsMatrix.h" -#include "forms/form_maths_matrix.h" - -#include "FormMathsSpace.h" -#include "forms/form_maths_space.h" - -#include "FormMathsStyle.h" -#include "forms/form_maths_style.h" - #include "ControlMinipage.h" #include "FormMinipage.h" #include "forms/form_minipage.h" @@ -225,7 +209,8 @@ IndexDialog; typedef GUI LogFileDialog; -typedef FormMathsPanel MathPanelDialog; +typedef GUI +MathPanelDialog; typedef GUI MinipageDialog; diff --git a/src/frontends/xforms/FeedbackController.C b/src/frontends/xforms/FeedbackController.C deleted file mode 100644 index 20602647d6..0000000000 --- a/src/frontends/xforms/FeedbackController.C +++ /dev/null @@ -1,191 +0,0 @@ -/** - * \file FeedbackController.C - * This file is part of LyX, the document processor. - * Licence details can be found in the file COPYING. - * - * \author Angus Leeming - * - * Full author contact details are available in file CREDITS - */ - -/* A common interface for posting feedback messages to a message widget in - * xforms. - * Derive FormBase and FormBaseDeprecated from it, so daughter classes of - * either can use the same interface. - */ - -#include - -#ifdef __GNUG__ -#pragma implementation -#endif - -#include "FeedbackController.h" -#include "gettext.h" // _() -#include "xforms_helpers.h" // formatted -#include "support/LAssert.h" - -#include "BoostFormat.h" - -#include FORMS_H_LOCATION - -FeedbackController::FeedbackController() - : warning_posted_(false), message_widget_(0) -{} - - -FeedbackController::~FeedbackController() -{} - - -void FeedbackController::setMessageWidget(FL_OBJECT * ob) -{ - lyx::Assert(ob && ob->objclass == FL_TEXT); - message_widget_ = ob; - fl_set_object_lsize(message_widget_, FL_NORMAL_SIZE); -} - - -// preemptive handler for feedback messages -void FeedbackController::MessageCB(FL_OBJECT * ob, int event) -{ - lyx::Assert(ob); - - switch (event) { - case FL_ENTER: - { - string const feedback = getFeedback(ob); - if (feedback.empty() && warning_posted_) - break; - - warning_posted_ = false; - postMessage(getFeedback(ob)); - break; - } - - case FL_LEAVE: - if (!warning_posted_) - clearMessage(); - break; - - default: - break; - } -} - -#if FL_VERSION > 0 || FL_REVISION >= 89 -extern "C" { - -void fl_show_tooltip(const char *, int, int); - -void fl_hide_tooltip(); - -} -#endif - -void FeedbackController::PrehandlerCB(FL_OBJECT * ob, int event, int key) -{ - lyx::Assert(ob); - - if (ob->objclass == FL_INPUT && event == FL_PUSH && key == 2) { - // Trigger an input event when pasting in an xforms input object - // using the middle mouse button. - InputCB(ob, 0); - return; - } - - - if (event != FL_ENTER && event != FL_LEAVE) - return; - - if (ob->objclass == FL_TABFOLDER) { - // This prehandler is used to work-around an xforms bug and - // ensures that the form->x, form->y coords of the active - // tabfolder are up to date. - - // The tabfolder itself can be very narrow, being just - // the visible border to the tabs. - // We thus use both FL_ENTER and FL_LEAVE as flags, - // in case the FL_ENTER event is not caught. - - FL_FORM * const folder = fl_get_active_folder(ob); - if (folder && folder->window) { - fl_get_winorigin(folder->window, - &(folder->x), &(folder->y)); - } - - } - - if (message_widget_) { - // Post feedback as the mouse enters the object, - // remove it as the mouse leaves. - MessageCB(ob, event); - } - -#if FL_VERSION > 0 || FL_REVISION >= 89 - // Tooltips are not displayed on browser widgets due to an xforms' bug. - // This is a work-around: - if (ob->objclass == FL_BROWSER) { - if (event == FL_ENTER && ob->tooltip && *(ob->tooltip)) { - fl_show_tooltip(ob->tooltip, ob->form->x + ob->x, - ob->form->y + ob->y + ob->h + 1); - } else if (event == FL_LEAVE) { - fl_hide_tooltip(); - } - } -#endif -} - - -void FeedbackController::postWarning(string const & warning) -{ - warning_posted_ = true; - postMessage(warning); -} - - -void FeedbackController::clearMessage() -{ - lyx::Assert(message_widget_); - - warning_posted_ = false; - - string const existing = message_widget_->label - ? message_widget_->label : string(); - if (existing.empty()) - return; - - // This trick is needed to get xforms to clear the label... - fl_set_object_label(message_widget_, ""); - fl_hide_object(message_widget_); -} - - -void FeedbackController::postMessage(string const & message) -{ - lyx::Assert(message_widget_); - - int const width = message_widget_->w - 10; - -#if USE_BOOST_FORMAT - boost::format fmter = warning_posted_ ? - boost::format(_("WARNING! %1$s")) : - boost::format("%1$s"); - fmter % message; - - string const str = formatted(fmter.str(), width, FL_NORMAL_SIZE); -#else - string const tmp = warning_posted_ ? - _("WARNING!") + string(" ") + message : - message; - - string const str = formatted(tmp, width, FL_NORMAL_SIZE); -#endif - - fl_set_object_label(message_widget_, str.c_str()); - FL_COLOR const label_color = warning_posted_ ? FL_RED : FL_LCOL; - fl_set_object_lcol(message_widget_, label_color); - - if (!message_widget_->visible) - fl_show_object(message_widget_); -} diff --git a/src/frontends/xforms/FeedbackController.h b/src/frontends/xforms/FeedbackController.h deleted file mode 100644 index 8d512a2841..0000000000 --- a/src/frontends/xforms/FeedbackController.h +++ /dev/null @@ -1,77 +0,0 @@ -// -*- C++ -*- -/** - * \file FeedbackController.h - * This file is part of LyX, the document processor. - * Licence details can be found in the file COPYING. - * - * \author Angus Leeming - * - * Full author contact details are available in file CREDITS - **/ - -/* A common interface for posting feedback messages to a message widget in - * xforms. - * Derive FormBase and FormBaseDeprecated from it, so daughter classes of - * either can interface tooltips in the same way. - */ - -#ifndef FEEDBACKCONTROLLER_H -#define FEEDBACKCONTROLLER_H - -#ifdef __GNUG__ -#pragma interface -#endif - -#include "forms_fwd.h" -#include "LString.h" - -class FeedbackController -{ -public: - /// - FeedbackController(); - /// - virtual ~FeedbackController(); - - /** Input callback function, invoked only by the xforms callback - interface. Is defined by FormBase, FormBaseDeprecated. */ - virtual void InputCB(FL_OBJECT *, long) = 0; - - /** Message callback function, invoked only by the xforms callback - interface */ - void MessageCB(FL_OBJECT *, int event); - - /** Prehandler callback function, invoked only by the xforms callback - interface */ - void PrehandlerCB(FL_OBJECT * ob, int event, int key); - -protected: - /** Pass the class a pointer to the message_widget so that it can - post the message */ - void setMessageWidget(FL_OBJECT * message_widget); - - /** Send the warning message from the daughter class to the - message_widget direct. The message will persist till the mouse - movesto a new object. */ - void postWarning(string const & warning); - /// Reset the message_widget_ - void clearMessage(); - -private: - /** Get the feedback message for ob. - Called if warning_posted_ == false. */ - virtual string const getFeedback(FL_OBJECT * /* ob */) - { return string(); } - - /// Post the feedback message for ob to message_widget_ - void postMessage(string const & message); - - /** Variable used to decide whether to remove the existing feedback - message or not (if it is in fact a warning) */ - bool warning_posted_; - - /// The widget to display the feedback - FL_OBJECT * message_widget_; -}; - -#endif // FEEDBACKCONTROLLER_H diff --git a/src/frontends/xforms/FormBase.C b/src/frontends/xforms/FormBase.C index 18b59ba018..f8f896a6ee 100644 --- a/src/frontends/xforms/FormBase.C +++ b/src/frontends/xforms/FormBase.C @@ -20,6 +20,10 @@ #include "xformsBC.h" #include "xforms_resize.h" #include "Tooltips.h" +#include "xforms_helpers.h" // formatted + +#include "gettext.h" // _() +#include "BoostFormat.h" #include "support/LAssert.h" #include "support/filetools.h" // LibFileSearch @@ -29,22 +33,28 @@ extern "C" { #if FL_VERSION > 0 || FL_REVISION >= 89 -// This should be in forms.h but isn't + +// These should be in forms.h but aren't +void fl_show_tooltip(const char *, int, int); + void fl_hide_tooltip(); + #endif // Callback function invoked by xforms when the dialog is closed by the -// window manager +// window manager. static int C_WMHideCB(FL_FORM * form, void *); -// Callback function invoked by the xforms pre- and post-handler routines +// Callback function invoked by the xforms pre-handler routine. static int C_PrehandlerCB(FL_OBJECT *, int, FL_Coord, FL_Coord, int, void *); } // extern "C" FormBase::FormBase(string const & t, bool allowResize) - : ViewBase(), minw_(0), minh_(0), allow_resize_(allowResize), + : ViewBase(), + warning_posted_(false), message_widget_(0), + minw_(0), minh_(0), allow_resize_(allowResize), title_(t), icon_pixmap_(0), icon_mask_(0), tooltips_(new Tooltips()) {} @@ -184,6 +194,14 @@ void FormBase::setPrehandler(FL_OBJECT * ob) } +void FormBase::setMessageWidget(FL_OBJECT * ob) +{ + lyx::Assert(ob && ob->objclass == FL_TEXT); + message_widget_ = ob; + fl_set_object_lsize(message_widget_, FL_NORMAL_SIZE); +} + + void FormBase::InputCB(FL_OBJECT * ob, long data) { // It is possible to set the choice to 0 when using the @@ -202,6 +220,141 @@ ButtonPolicy::SMInput FormBase::input(FL_OBJECT *, long) } +// preemptive handler for feedback messages +void FormBase::MessageCB(FL_OBJECT * ob, int event) +{ + lyx::Assert(ob); + + switch (event) { + case FL_ENTER: + { + string const feedback = getFeedback(ob); + if (feedback.empty() && warning_posted_) + break; + + warning_posted_ = false; + postMessage(getFeedback(ob)); + break; + } + + case FL_LEAVE: + if (!warning_posted_) + clearMessage(); + break; + + default: + break; + } +} + + +void FormBase::PrehandlerCB(FL_OBJECT * ob, int event, int key) +{ + lyx::Assert(ob); + + if (ob->objclass == FL_INPUT && event == FL_PUSH && key == 2) { + // Trigger an input event when pasting in an xforms input object + // using the middle mouse button. + InputCB(ob, 0); + return; + } + + + if (event != FL_ENTER && event != FL_LEAVE) + return; + + if (ob->objclass == FL_TABFOLDER) { + // This prehandler is used to work-around an xforms bug and + // ensures that the form->x, form->y coords of the active + // tabfolder are up to date. + + // The tabfolder itself can be very narrow, being just + // the visible border to the tabs. + // We thus use both FL_ENTER and FL_LEAVE as flags, + // in case the FL_ENTER event is not caught. + + FL_FORM * const folder = fl_get_active_folder(ob); + if (folder && folder->window) { + fl_get_winorigin(folder->window, + &(folder->x), &(folder->y)); + } + + } + + if (message_widget_) { + // Post feedback as the mouse enters the object, + // remove it as the mouse leaves. + MessageCB(ob, event); + } + +#if FL_VERSION > 0 || FL_REVISION >= 89 + // Tooltips are not displayed on browser widgets due to an xforms' bug. + // This is a work-around: + if (ob->objclass == FL_BROWSER) { + if (event == FL_ENTER && ob->tooltip && *(ob->tooltip)) { + fl_show_tooltip(ob->tooltip, ob->form->x + ob->x, + ob->form->y + ob->y + ob->h + 1); + } else if (event == FL_LEAVE) { + fl_hide_tooltip(); + } + } +#endif +} + + +void FormBase::postWarning(string const & warning) +{ + warning_posted_ = true; + postMessage(warning); +} + + +void FormBase::clearMessage() +{ + lyx::Assert(message_widget_); + + warning_posted_ = false; + + string const existing = message_widget_->label + ? message_widget_->label : string(); + if (existing.empty()) + return; + + // This trick is needed to get xforms to clear the label... + fl_set_object_label(message_widget_, ""); + fl_hide_object(message_widget_); +} + + +void FormBase::postMessage(string const & message) +{ + lyx::Assert(message_widget_); + +#if USE_BOOST_FORMAT + boost::format fmter = warning_posted_ ? + boost::format(_("WARNING! %1$s")) : + boost::format("%1$s"); + + int const width = message_widget_->w - 10; + string const str = formatted(boost::io::str(fmter % message), + width, FL_NORMAL_SIZE); +#else + string const tmp = warning_posted_ ? + _("WARNING!") + string(" ") + message : + message; + + string const str = formatted(tmp, width, FL_NORMAL_SIZE); +#endif + + fl_set_object_label(message_widget_, str.c_str()); + FL_COLOR const label_color = warning_posted_ ? FL_RED : FL_LCOL; + fl_set_object_lcol(message_widget_, label_color); + + if (!message_widget_->visible) + fl_show_object(message_widget_); +} + + namespace { FormBase * GetForm(FL_OBJECT * ob) diff --git a/src/frontends/xforms/FormBase.h b/src/frontends/xforms/FormBase.h index a7bc62951f..9fe1f6eba7 100644 --- a/src/frontends/xforms/FormBase.h +++ b/src/frontends/xforms/FormBase.h @@ -21,7 +21,6 @@ #include "ViewBase.h" #include "ButtonPolicies.h" -#include "FeedbackController.h" #include "forms_fwd.h" #include "LString.h" @@ -34,7 +33,7 @@ class Tooltips; /** This class is an XForms GUI base class. */ -class FormBase : public ViewBase, public FeedbackController +class FormBase : public ViewBase { public: /// @@ -42,11 +41,22 @@ public: /// virtual ~FormBase(); - /** input callback function. invoked only by the xforms callback - * interface + /** Input callback function. + * Invoked only by the xforms callback interface */ void InputCB(FL_OBJECT *, long); + /** Message callback function. + * Invoked only by the xforms callback interface + */ + void MessageCB(FL_OBJECT *, int event); + + /** Prehandler callback function. + * Invoked only by the xforms callback interface + */ + void PrehandlerCB(FL_OBJECT * ob, int event, int key); + + /// Tooltips & tooltips(); protected: @@ -65,6 +75,17 @@ protected: */ static void setPrehandler(FL_OBJECT * ob); + /** Pass the class a pointer to the message_widget so that it can + post the message */ + void setMessageWidget(FL_OBJECT * message_widget); + + /** Send the warning message from the daughter class to the + message_widget direct. The message will persist till the mouse + movesto a new object. */ + void postWarning(string const & warning); + /// Reset the message_widget_ + void clearMessage(); + /// xformsBC & bc(); @@ -84,6 +105,20 @@ private: */ void prepare_to_show(); + /** Get the feedback message for ob. + Called if warning_posted_ == false. */ + virtual string const getFeedback(FL_OBJECT * /* ob */) + { return string(); } + + /// Post the feedback message for ob to message_widget_ + void postMessage(string const & message); + + /** Variable used to decide whether to remove the existing feedback + message or not (if it is in fact a warning) */ + bool warning_posted_; + /// The widget to display the feedback + FL_OBJECT * message_widget_; + /// The dialog's minimum allowable dimensions. int minw_; /// @@ -131,13 +166,15 @@ FL_FORM * FormDB::form() const template class FormCB: public Base { -protected: - /// - FormCB(string const &, bool allowResize = true); +public: /// The parent controller Controller & controller(); /// Controller const & controller() const; + +protected: + /// + FormCB(string const &, bool allowResize = true); }; diff --git a/src/frontends/xforms/FormBaseDeprecated.C b/src/frontends/xforms/FormBaseDeprecated.C deleted file mode 100644 index 681e428843..0000000000 --- a/src/frontends/xforms/FormBaseDeprecated.C +++ /dev/null @@ -1,360 +0,0 @@ -/** - * \file FormBaseDeprecated.C - * This file is part of LyX, the document processor. - * Licence details can be found in the file COPYING. - * - * \author Angus Leeming - * - * Full author contact details are available in file CREDITS - */ - -#include - -#ifdef __GNUG__ -#pragma implementation -#endif - -#include "Dialogs.h" -#include "FormBaseDeprecated.h" -#include "xformsBC.h" -#include "xforms_resize.h" -#include "Tooltips.h" -#include FORMS_H_LOCATION - -#include "lyxrc.h" - -#include "frontends/LyXView.h" - -#include "support/LAssert.h" -#include "support/filetools.h" // LibFileSearch - -#include - -extern "C" { - -#if FL_VERSION > 0 || FL_REVISION >= 89 -// This should be in forms.h but isn't -void fl_hide_tooltip(); -#endif - -// Callback function invoked by xforms when the dialog is closed by the -// window manager -static int C_WMHideCB(FL_FORM *, void *); - -// Callback function invoked by the xforms pre- and post-handler routines -static int C_PrehandlerCB(FL_OBJECT *, int, FL_Coord, FL_Coord, int, void *); - -} // extern "C" - - -FormBaseDeprecated::FormBaseDeprecated(LyXView & lv, Dialogs & d, - string const & t, bool allowResize) - : lv_(lv), d_(d), title_(t), icon_pixmap_(0), icon_mask_(0), - minw_(0), minh_(0), allow_resize_(allowResize), - tooltips_(new Tooltips()) -{} - - -FormBaseDeprecated::~FormBaseDeprecated() -{ - if (icon_pixmap_) - XFreePixmap(fl_get_display(), icon_pixmap_); - - delete tooltips_; -} - - -Tooltips & FormBaseDeprecated::tooltips() -{ - return *tooltips_; -} - - -void FormBaseDeprecated::redraw() -{ - if (form() && form()->visible) - fl_redraw_form(form()); -} - - -void FormBaseDeprecated::connect() -{ - fl_set_form_minsize(form(), minw_, minh_); - r_ = d_.redrawGUI().connect(boost::bind(&FormBaseDeprecated::redraw, this)); -} - - -void FormBaseDeprecated::disconnect() -{ - h_.disconnect(); - r_.disconnect(); -} - - -void FormBaseDeprecated::prepare_to_show() -{ - build(); - - double const scale = get_scale_to_fit(form()); - if (scale > 1.001) - scale_form_horizontally(form(), scale); - - bc().refresh(); - - // work around dumb xforms sizing bug - minw_ = form()->w; - minh_ = form()->h; - - fl_set_form_atclose(form(), C_WMHideCB, 0); - - // set the title for the minimized form - if (!lyxrc.dialogs_iconify_with_main) - fl_winicontitle(form()->window, title_.c_str()); - - // assign an icon to the form - string const iconname = LibFileSearch("images", "lyx", "xpm"); - if (!iconname.empty()) { - unsigned int w, h; - icon_pixmap_ = fl_read_pixmapfile(fl_root, - iconname.c_str(), - &w, - &h, - &icon_mask_, - 0, 0, 0); - fl_set_form_icon(form(), icon_pixmap_, icon_mask_); - } -} - - -void FormBaseDeprecated::show() -{ - if (!form()) { - prepare_to_show(); - } - - // make sure the form is up to date. - fl_freeze_form(form()); - update(); - fl_unfreeze_form(form()); - - if (form()->visible) { - fl_raise_form(form()); - /* This XMapWindow() will hopefully ensure that - * iconified dialogs are de-iconified. Mad props - * out to those crazy Xlib guys for forgetting a - * XDeiconifyWindow(). At least WindowMaker, when - * being notified of the redirected MapRequest will - * specifically de-iconify. From source, fvwm2 seems - * to do the same. - */ - XMapWindow(fl_get_display(), form()->window); - } else { - connect(); - - // calls to fl_set_form_minsize/maxsize apply only to the next - // fl_show_form(), so this comes first. - fl_set_form_minsize(form(), minw_, minh_); - if (!allow_resize_) - fl_set_form_maxsize(form(), minw_, minh_); - - string const maximize_title = "LyX: " + title_; - int const iconify_policy = - lyxrc.dialogs_iconify_with_main ? FL_TRANSIENT : 0; - - fl_show_form(form(), - FL_PLACE_MOUSE | FL_FREE_SIZE, - iconify_policy, - maximize_title.c_str()); - } -} - - -void FormBaseDeprecated::hide() -{ -#if FL_VERSION > 0 || FL_REVISION >= 89 - // Does no harm if none is visible and ensures that the tooltip form - // is hidden should the dialog be closed from the keyboard. - fl_hide_tooltip(); -#endif - - // xforms sometimes tries to process a hint-type MotionNotify, and - // use XQueryPointer, without verifying if the window still exists. - // So we try to clear out motion events in the queue before the - // DestroyNotify - XSync(fl_get_display(), false); - - if (form() && form()->visible) { - // some dialogs might do things to the form first - // such as the nested tabfolder problem in Preferences - disconnect(); - fl_hide_form(form()); - } -} - - -void FormBaseDeprecated::setPrehandler(FL_OBJECT * ob) -{ - lyx::Assert(ob); - fl_set_object_prehandler(ob, C_PrehandlerCB); -} - - -void FormBaseDeprecated::WMHideCB() -{ - hide(); - bc().hide(); -} - - -void FormBaseDeprecated::ApplyCB() -{ - apply(); - bc().apply(); -} - - -void FormBaseDeprecated::OKCB() -{ - ok(); - bc().ok(); -} - - -void FormBaseDeprecated::CancelCB() -{ - cancel(); - bc().cancel(); -} - - -void FormBaseDeprecated::InputCB(FL_OBJECT * ob, long data) -{ - // It is possible to set the choice to 0 when using the - // keyboard shortcuts. This work-around deals with the problem. - if (ob && ob->objclass == FL_CHOICE && fl_get_choice(ob) < 1) { - fl_set_choice(ob, 1); - } - - bc().valid(input(ob, data)); -} - - -void FormBaseDeprecated::RestoreCB() -{ - bc().restore(); - restore(); -} - - -FormBaseBI::FormBaseBI(LyXView & lv, Dialogs & d, string const & t, - bool allowResize) - : FormBaseDeprecated(lv, d, t, allowResize) -{} - - -void FormBaseBI::connect() -{ - h_ = d_.hideAll.connect(boost::bind(&FormBaseBI::hide, this)); - FormBaseDeprecated::connect(); -} - - -FormBaseBD::FormBaseBD(LyXView & lv, Dialogs & d, string const & t, - bool allowResize) - : FormBaseDeprecated(lv, d, t, allowResize) -{} - - -void FormBaseBD::connect() -{ - u_ = d_.updateBufferDependent. - connect(boost::bind(&FormBaseBD::updateSlot, this, _1)); - h_ = d_.hideBufferDependent. - connect(boost::bind(&FormBaseBD::hide, this)); - FormBaseDeprecated::connect(); -} - - -void FormBaseBD::disconnect() -{ - u_.disconnect(); - FormBaseDeprecated::disconnect(); -} - - -namespace { - -FormBaseDeprecated * GetForm(FL_OBJECT * ob) -{ - lyx::Assert(ob && ob->form && ob->form->u_vdata); - FormBaseDeprecated * ptr = - static_cast(ob->form->u_vdata); - return ptr; -} - -} // namespace anon - - -extern "C" { - -void C_FormBaseDeprecatedApplyCB(FL_OBJECT * ob, long) -{ - GetForm(ob)->ApplyCB(); -} - - -void C_FormBaseDeprecatedOKCB(FL_OBJECT * ob, long) -{ - GetForm(ob)->OKCB(); -} - - -void C_FormBaseDeprecatedCancelCB(FL_OBJECT * ob, long) -{ - GetForm(ob)->CancelCB(); -} - - -void C_FormBaseDeprecatedInputCB(FL_OBJECT * ob, long d) -{ - GetForm(ob)->InputCB(ob, d); -} - - -void C_FormBaseDeprecatedRestoreCB(FL_OBJECT * ob, long) -{ - GetForm(ob)->RestoreCB(); -} - -static int C_WMHideCB(FL_FORM * form, void *) -{ - // Close the dialog cleanly, even if the WM is used to do so. - lyx::Assert(form && form->u_vdata); - FormBaseDeprecated * ptr = - static_cast(form->u_vdata); - ptr->WMHideCB(); - return FL_CANCEL; -} - -static int C_PrehandlerCB(FL_OBJECT * ob, int event, - FL_Coord, FL_Coord, int key, void *) -{ - // Note that the return value is important in the pre-emptive handler. - // Don't return anything other than 0. - lyx::Assert(ob); - - // Don't Assert this one, as it can happen quite naturally when things - // are being deleted in the d-tor. - //Assert(ob->form); - if (!ob->form) return 0; - - FormBaseDeprecated * ptr = - static_cast(ob->form->u_vdata); - - if (ptr) - ptr->PrehandlerCB(ob, event, key); - - return 0; -} - -} // extern "C" diff --git a/src/frontends/xforms/FormBaseDeprecated.h b/src/frontends/xforms/FormBaseDeprecated.h deleted file mode 100644 index a1cb3018f8..0000000000 --- a/src/frontends/xforms/FormBaseDeprecated.h +++ /dev/null @@ -1,189 +0,0 @@ -// -*- C++ -*- -/** - * \file FormBaseDeprecated.h - * This file is part of LyX, the document processor. - * Licence details can be found in the file COPYING. - * - * \author Angus Leeming - * - * Full author contact details are available in file CREDITS - */ - -/* A base class for those remaining xforms dialogs that haven't yet undergone - * the controller-view split. - * It is meant to be used solely as the parent class to FormBaseBI - * and FormBaseBD. - */ - -#ifndef FORMBASEDEPRECATED_H -#define FORMBASEDEPRECATED_H - -#ifdef __GNUG__ -#pragma interface -#endif - -#include "xformsBC.h" -#include "FeedbackController.h" -#include "forms_fwd.h" - -#include "LString.h" -#include -#include -#include // for Pixmap - -class Buffer; -class Dialogs; -class LyXView; -class Tooltips; - -class FormBaseDeprecated : boost::noncopyable, public FeedbackController -{ -public: - /// - FormBaseDeprecated(LyXView &, Dialogs &, string const &, bool); - /// - virtual ~FormBaseDeprecated(); - - /// Callback functions - void WMHideCB(); - /// - void ApplyCB(); - /// - void OKCB(); - /// - void CancelCB(); - /// - void InputCB(FL_OBJECT *, long); - /// - void RestoreCB(); - - Tooltips & tooltips(); - - /// Create the dialog if necessary, update it and display it. - virtual void show(); - /// Hide the dialog. - virtual void hide(); - -protected: // methods - - /// Pointer to the actual instantiation of the ButtonController. - virtual xformsBC & bc() = 0; - - /** Redraw the form (on receipt of a Signal indicating, for example, - * that the xform colors have been re-mapped). - * Must be virtual because dialogs with tabbed folders will need to - * redraw the form for each tab. - */ - virtual void redraw(); - - /// Update the dialog. - virtual void update() {} - /// Connect signals. Also perform any necessary initialisation. - virtual void connect(); - /// Disconnect signals. Also perform any necessary housekeeping. - virtual void disconnect(); - /// Build the dialog - virtual void build() = 0; - /** Filter the inputs on callback from xforms - * Return true if inputs are valid. - */ - virtual bool input(FL_OBJECT *, long) { - return true; - } - /// Apply from dialog (modify or create inset) - virtual void apply() {} - /// OK from dialog - virtual void ok() { - apply(); - hide(); - } - /// Cancel from dialog - virtual void cancel() { - hide(); - } - /// Restore from dialog - virtual void restore() { - update(); - } - /// Pointer to the actual instantiation of xform's form - virtual FL_FORM * form() const = 0; - - /** Prepare the way to: - * 1. display feedback as the mouse moves over ob. This feedback will - * typically be rather more verbose than just a tooltip. - * 2. activate the button controller after a paste with the middle - * mouse button. - */ - static void setPrehandler(FL_OBJECT * ob); - - /** Which LyXFunc do we use? - * We could modify Dialogs to have a visible LyXFunc* instead and - * save a couple of bytes per dialog. - */ - LyXView & lv_; - /// Used so we can get at the signals we have to connect to. - Dialogs & d_; - /// Hide connection. - boost::signals::connection h_; - /// Redraw connection. - boost::signals::connection r_; - /// dialog title, displayed by WM. - string title_; - -private: - /** Called on the first show() request, initialising various bits and - * pieces. - */ - void prepare_to_show(); - - /// Passed to the window manager to give a pretty little symbol ;-) - Pixmap icon_pixmap_; - /// - Pixmap icon_mask_; - /// The dialog's minimum allowable dimensions. - int minw_; - /// - int minh_; - /// Can the dialog be resized after it has been created? - bool allow_resize_; - /// - Tooltips * tooltips_; -}; - - -/** This class is an XForms GUI base class for Buffer Independent dialogs. - * Such dialogs do not require an update Connection although they may use - * an update() function which is also supported by restore(). - */ -class FormBaseBI : public FormBaseDeprecated { -protected: - /// Constructor - FormBaseBI(LyXView &, Dialogs &, string const &, - bool allowResize = true); - - /// Connect signals - virtual void connect(); -}; - - -/** This class is an XForms GUI base class for Buffer Dependent dialogs - */ -class FormBaseBD : public FormBaseDeprecated { -protected: - /// Constructor - FormBaseBD(LyXView &, Dialogs &, string const &, - bool allowResize = true); - - /// Connect signals - virtual void connect(); - /// Disconnect signals - virtual void disconnect(); - /// bool indicates if a buffer switch took place - virtual void updateSlot(bool) { update(); } - - /// Update connection. - boost::signals::connection u_; -}; - - -#endif // FORMBASEDEPRECATED_H diff --git a/src/frontends/xforms/FormMathsBitmap.C b/src/frontends/xforms/FormMathsBitmap.C index 518650e739..9b0595c46e 100644 --- a/src/frontends/xforms/FormMathsBitmap.C +++ b/src/frontends/xforms/FormMathsBitmap.C @@ -17,8 +17,10 @@ #endif #include "FormMathsBitmap.h" +#include "ControlMath.h" +#include "xformsBC.h" + #include "bmtable.h" -#include "debug.h" #include "forms_gettext.h" #include "gettext.h" #include "support/LAssert.h" @@ -26,20 +28,26 @@ #include XPM_H_LOCATION #include -#include + +extern "C" void C_FormBaseCancelCB(FL_OBJECT *, long); +extern "C" void C_FormBaseInputCB(FL_OBJECT *, long); using std::vector; -using std::endl; -using std::setw; using std::max; -extern "C" void C_FormBaseDeprecatedCancelCB(FL_OBJECT *, long); -extern "C" void C_FormBaseDeprecatedInputCB(FL_OBJECT *, long); -FormMathsBitmap::FormMathsBitmap(LyXView & lv, Dialogs & d, - FormMathsPanel const & p, string const & t, - vector const & l) - : FormMathsSub(lv, d, p, t, false), +FD_maths_bitmap::~FD_maths_bitmap() +{ + if (form->visible) fl_hide_form(form); + fl_free_form(form); +} + + +typedef FormCB > base_class; + + +FormMathsBitmap::FormMathsBitmap(string const & t, vector const & l) + : base_class(t, false), latex_(l), ww_(0), x_(0), y_(0), w_(0), h_(0) { ww_ = 2 * FL_abs(FL_BOUND_WIDTH); @@ -48,62 +56,74 @@ FormMathsBitmap::FormMathsBitmap(LyXView & lv, Dialogs & d, } -FormMathsBitmap::~FormMathsBitmap() +void FormMathsBitmap::addBitmap(int nt, int nx, int ny, int bw, int bh, + unsigned char const * data, bool vert) { - if (!form()) - return; + bitmaps_.push_back(BitmapStore(nt, nx, ny, bw, bh, data, vert)); - if (form()->visible) fl_hide_form(form()); - fl_free_form(form()); + int wx = bw + ww_ / 2; + int wy = bh + ww_ / 2; + wx += (wx % nx); + wy += (wy % ny); + + if (vert) { + y_ += wy + 8; + h_ = max(y_, h_); + w_ = max(x_ + wx + ww_, w_); + } else { + x_ += wx + 8; + w_ = max(x_, w_); + h_ = max(y_ + wy + ww_, h_); + } } - - -FL_FORM * FormMathsBitmap::form() const -{ - return form_.get(); -} - + void FormMathsBitmap::build() { lyx::Assert(bitmaps_.size() > 0); - h_+= 50; // Allow room for a Close button + h_+= 42; // Allow room for a Close button - form_.reset(fl_bgn_form(FL_UP_BOX, w_, h_), fl_free_form); - form_->u_vdata = this; + FD_maths_bitmap * fdui = new FD_maths_bitmap; + + fdui->form = fl_bgn_form(FL_UP_BOX, w_, h_); + fdui->form->u_vdata = this; fl_add_box(FL_UP_BOX, 0, 0, w_, h_, ""); + x_ = 0; y_ = 0; - for (vector::const_iterator it = bitmaps_.begin(); + int y_close = 0; + for (vector::const_iterator it = bitmaps_.begin(); it < bitmaps_.end(); ++it) { - FL_OBJECT * obj = it->get(); + FL_OBJECT * obj = buildBitmap(*it); - fl_add_object(form_.get(), obj); bc().addReadOnly(obj); - - y_ = max(y_, obj->y + obj->h); + y_close = max(y_close, obj->y + obj->h); } + bitmaps_.clear(); char const * const label = _("Close|^["); - x_ = (form_->w - 90) / 2; - y_ += 10; + x_ = (fdui->form->w - 90) / 2; + y_ = y_close + 10; FL_OBJECT * button_close = fl_add_button(FL_NORMAL_BUTTON, x_, y_, 90, 30, idex(_(label))); fl_set_button_shortcut(button_close, scex(_(label)), 1); fl_set_object_lsize(button_close, FL_NORMAL_SIZE); - fl_set_object_callback(button_close, C_FormBaseDeprecatedCancelCB, 0); + fl_set_object_callback(button_close, C_FormBaseCancelCB, 0); fl_end_form(); - bc().setCancel(button_close); + fdui->form->fdui = fdui; + + dialog_.reset(fdui); + bc().setCancel(dialog_->button_close); } -void FormMathsBitmap::addBitmap(int nt, int nx, int ny, int bw, int bh, - unsigned char const * data, bool vert) + +FL_OBJECT * FormMathsBitmap::buildBitmap(BitmapStore const & bmstore) { // Add a bitmap to a button panel: one bitmap per panel. // nt is the number of buttons and nx, ny the nr. of buttons @@ -116,41 +136,43 @@ void FormMathsBitmap::addBitmap(int nt, int nx, int ny, int bw, int bh, // // The scaling of the bitmap on top of the buttons will be // correct if the nx, ny values are given correctly. - int wx = bw + ww_ / 2; - int wy = bh + ww_ / 2; - wx += (wx % nx); - wy += (wy % ny); - FL_OBJECT * obj = fl_create_bmtable(1, x_, y_, wx, wy, ""); + int wx = bmstore.bw + ww_ / 2; + int wy = bmstore.bh + ww_ / 2; + wx += (wx % bmstore.nx); + wy += (wy % bmstore.ny); + + FL_OBJECT * obj = fl_add_bmtable(1, x_, y_, wx, wy, ""); fl_set_object_lcol(obj, FL_BLUE); fl_set_object_boxtype(obj, FL_UP_BOX); - fl_set_bmtable_data(obj, nx, ny, bw, bh, data); - fl_set_bmtable_maxitems(obj, nt); - fl_set_object_callback(obj, C_FormBaseDeprecatedInputCB, 0); + fl_set_bmtable_data(obj, bmstore.nx, bmstore.ny, bmstore.bw, bmstore.bh, + bmstore.data); + fl_set_bmtable_maxitems(obj, bmstore.nt); + fl_set_object_callback(obj, C_FormBaseInputCB, 0); - if (vert) { + if (bmstore.vert) { y_ += wy + 8; - h_ = max(y_, h_); - w_ = max(x_ + wx + ww_, w_); } else { x_ += wx + 8; - w_ = max(x_, w_); - h_ = max(y_ + wy + ww_, h_); } - bitmaps_.push_back(bm_ptr(obj, fl_free_object)); + return obj; } -int FormMathsBitmap::GetIndex(FL_OBJECT * ob) +int FormMathsBitmap::GetIndex(FL_OBJECT * ob_in) { int k = 0; - for (vector::const_iterator it = bitmaps_.begin(); - it < bitmaps_.end(); ++it) { - if (it->get() == ob) + + for (FL_OBJECT * ob = form()->first; ob; ob = ob->next) { + if (ob->objclass != FL_BMTABLE) + continue; + + if (ob == ob_in) return k + fl_get_bmtable(ob); else - k += fl_get_bmtable_maxitems(it->get()); + k += fl_get_bmtable_maxitems(ob); } + return -1; } @@ -159,22 +181,22 @@ void FormMathsBitmap::apply() { string::size_type const i = latex_chosen_.find(' '); if (i != string::npos) { - parent_.dispatchFunc(LFUN_MATH_MODE); - parent_.insertSymbol(latex_chosen_.substr(0,i)); - parent_.insertSymbol(latex_chosen_.substr(i + 1), false); + controller().dispatchFunc(LFUN_MATH_MODE); + controller().insertSymbol(latex_chosen_.substr(0,i)); + controller().insertSymbol(latex_chosen_.substr(i + 1), false); } else - parent_.insertSymbol(latex_chosen_); + controller().insertSymbol(latex_chosen_); } -bool FormMathsBitmap::input(FL_OBJECT * ob, long) +ButtonPolicy::SMInput FormMathsBitmap::input(FL_OBJECT * ob, long) { int const i = GetIndex(ob); if (i < 0) - return false; + return ButtonPolicy::SMI_INVALID; latex_chosen_ = latex_[i]; apply(); - return true; + return ButtonPolicy::SMI_VALID; } diff --git a/src/frontends/xforms/FormMathsBitmap.h b/src/frontends/xforms/FormMathsBitmap.h index e6ff7ace90..82f0e85422 100644 --- a/src/frontends/xforms/FormMathsBitmap.h +++ b/src/frontends/xforms/FormMathsBitmap.h @@ -14,35 +14,51 @@ #ifndef FORM_MATHSBITMAP_H #define FORM_MATHSBITMAP_H -#include "LString.h" -#include "FormMathsPanel.h" - -#include - -#include - #ifdef __GNUG__ #pragma interface #endif +#include "FormBase.h" +#include +#include + +struct BitmapStore +{ + BitmapStore(int nt_in, int nx_in, int ny_in, int bw_in, int bh_in, + unsigned char const * data_in, bool vert_in) + : nt(nt_in), nx(nx_in), ny(ny_in), bw(bw_in), bh(bh_in), + data(data_in), vert(vert_in) + {} + + int nt; + int nx; + int ny; + int bw; + int bh; + unsigned char const * data; + bool vert; +}; + + +struct FD_maths_bitmap +{ + ~FD_maths_bitmap(); + FL_FORM * form; + FL_OBJECT * button_close; +}; + + /** * This class provides an XForms implementation of a maths bitmap form. */ -class FormMathsBitmap : public FormMathsSub { - /// - friend class FormMathsPanel; +class ControlMathSub; + +class FormMathsBitmap : public FormCB > +{ public: /// - typedef boost::shared_ptr bm_ptr; - /// - typedef boost::shared_ptr fl_ptr; - - /// - FormMathsBitmap(LyXView &, Dialogs & d, FormMathsPanel const &, - string const &, std::vector const &); - /// - ~FormMathsBitmap(); + FormMathsBitmap(string const &, std::vector const &); /// void addBitmap(int, int, int, int, int, unsigned char const *, bool = true); @@ -51,24 +67,27 @@ private: /// int GetIndex(FL_OBJECT *); - /// Build the dialog - virtual void build(); - /// apply the data + /// virtual void apply(); - /// input handler - bool input(FL_OBJECT *, long); + /// + virtual void build(); + /// + virtual ButtonPolicy::SMInput input(FL_OBJECT *, long); + /// Not needed. + virtual void update() {} - /// Pointer to the actual instantiation of the xforms form - virtual FL_FORM * form() const; + /// + FL_OBJECT * buildBitmap(BitmapStore const & bmstore); /// The latex names associated with each symbol std::vector latex_; /// The latex name chosen string latex_chosen_; - /// Real GUI implementation - fl_ptr form_; - /// The bitmap tables - std::vector bitmaps_; + + /** Temporary store for bitmap data passed to addBitmap() + * but before the FL_OBJECT is created in build(). + */ + std::vector bitmaps_; /// Border width int ww_; diff --git a/src/frontends/xforms/FormMathsDeco.C b/src/frontends/xforms/FormMathsDeco.C index ec0c43a6fe..56e9a8f0c6 100644 --- a/src/frontends/xforms/FormMathsDeco.C +++ b/src/frontends/xforms/FormMathsDeco.C @@ -20,26 +20,21 @@ #include "ControlMath.h" #include "FormMathsDeco.h" #include "forms/form_maths_deco.h" +#include "xformsBC.h" + #include "bmtable.h" #include FORMS_H_LOCATION #include "deco.xbm" -FormMathsDeco::FormMathsDeco(LyXView & lv, Dialogs & d, - FormMathsPanel const & p) - : FormMathsSub(lv, d, p, _("Maths Decorations & Accents"), false) +typedef FormCB > base_class; + +FormMathsDeco::FormMathsDeco() + : base_class(_("Maths Decorations & Accents"), false) {} -FL_FORM * FormMathsDeco::form() const -{ - if (dialog_.get()) - return dialog_->form; - return 0; -} - - void FormMathsDeco::build() { dialog_.reset(build_maths_deco(this)); @@ -61,19 +56,19 @@ void FormMathsDeco::build() void FormMathsDeco::apply() { if (deco_ < nr_latex_deco) - parent_.insertSymbol(latex_deco[deco_]); + controller().insertSymbol(latex_deco[deco_]); } -bool FormMathsDeco::input(FL_OBJECT * ob, long) +ButtonPolicy::SMInput FormMathsDeco::input(FL_OBJECT * ob, long) { deco_ = fl_get_bmtable(ob); if (deco_ < 0) - return false; + return ButtonPolicy::SMI_INVALID; //if (ob == dialog_->bmtable_deco1) // deco_ += 0; if (ob == dialog_->bmtable_deco2) deco_ += 12; apply(); - return true; + return ButtonPolicy::SMI_VALID; } diff --git a/src/frontends/xforms/FormMathsDeco.h b/src/frontends/xforms/FormMathsDeco.h index ac17572a5e..8584aede8d 100644 --- a/src/frontends/xforms/FormMathsDeco.h +++ b/src/frontends/xforms/FormMathsDeco.h @@ -18,37 +18,31 @@ #pragma interface #endif -#include "FormMathsPanel.h" - -#include +#include "FormBase.h" +class ControlMathSub; struct FD_maths_deco; /** * This class provides an XForms implementation of the maths deco. */ -class FormMathsDeco : public FormMathsSub { +class FormMathsDeco : public FormCB > { public: /// - FormMathsDeco(LyXView &, Dialogs &, FormMathsPanel const &); + FormMathsDeco(); private: - /// Build the dialog - virtual void build(); - /// Apply from dialog (modify or create inset) + /// virtual void apply(); - /// Input selection: - virtual bool input(FL_OBJECT *, long); - - /// Pointer to the actual instantiation of the xforms form - virtual FL_FORM * form() const; - - // Real GUI implementation - boost::scoped_ptr dialog_; + /// + virtual void build(); + /// + virtual ButtonPolicy::SMInput input(FL_OBJECT *, long); + /// Not needed. + virtual void update() {} /// Current choice int deco_; - }; #endif // FORM_MATHSDECO_H diff --git a/src/frontends/xforms/FormMathsDelim.C b/src/frontends/xforms/FormMathsDelim.C index 743dab0817..2707032fa0 100644 --- a/src/frontends/xforms/FormMathsDelim.C +++ b/src/frontends/xforms/FormMathsDelim.C @@ -19,15 +19,11 @@ #include "FormMathsDelim.h" #include "forms/form_maths_delim.h" +#include "ControlMath.h" +#include "xformsBC.h" #include "bmtable.h" -#include "debug.h" -#include "funcrequest.h" -#include "lyxfunc.h" - -#include "frontends/LyXView.h" - #include "support/lstrings.h" #include "Lsstream.h" @@ -54,20 +50,14 @@ static char const * delim_values[] = { using std::endl; -FormMathsDelim::FormMathsDelim(LyXView & lv, Dialogs & d, - FormMathsPanel const & p) - : FormMathsSub(lv, d, p, _("Maths Delimiters"), false) + +typedef FormCB > base_class; + +FormMathsDelim::FormMathsDelim() + : base_class(_("Maths Delimiters"), false) {} -FL_FORM * FormMathsDelim::form() const -{ - if (dialog_.get()) - return dialog_->form; - return 0; -} - - void FormMathsDelim::build() { dialog_.reset(build_maths_delim(this)); @@ -102,11 +92,17 @@ void FormMathsDelim::apply() ostringstream os; os << delim_values[left] << ' ' << delim_values[right]; - parent_.dispatchFunc(LFUN_MATH_DELIM, STRCONV(os.str())); + controller().dispatchFunc(LFUN_MATH_DELIM, STRCONV(os.str())); } -bool FormMathsDelim::input(FL_OBJECT *, long) +void FormMathsDelim::update() +{ + bc().valid(); +} + + +ButtonPolicy::SMInput FormMathsDelim::input(FL_OBJECT *, long) { int left = int(dialog_->radio_left->u_ldata); int right= int(dialog_->radio_right->u_ldata); @@ -149,5 +145,5 @@ bool FormMathsDelim::input(FL_OBJECT *, long) dialog_->radio_left->u_ldata = left; dialog_->radio_right->u_ldata = right; - return true; + return ButtonPolicy::SMI_VALID; } diff --git a/src/frontends/xforms/FormMathsDelim.h b/src/frontends/xforms/FormMathsDelim.h index 7289a2d841..6ac0232a66 100644 --- a/src/frontends/xforms/FormMathsDelim.h +++ b/src/frontends/xforms/FormMathsDelim.h @@ -18,33 +18,28 @@ #pragma interface #endif -#include "FormMathsPanel.h" - -#include +#include "FormBase.h" +class ControlMathSub; struct FD_maths_delim; /** * This class provides an XForms implementation of the maths delim. */ -class FormMathsDelim : public FormMathsSub { +class FormMathsDelim : public FormCB > { public: /// - FormMathsDelim(LyXView &, Dialogs &, FormMathsPanel const &); + FormMathsDelim(); private: - /// Build the dialog - virtual void build(); - /// input handler - virtual bool input(FL_OBJECT *, long); - /// Apply from dialog (modify or create inset) + /// virtual void apply(); - - /// Pointer to the actual instantiation of the xforms form - virtual FL_FORM * form() const; - - // Real GUI implementation - boost::scoped_ptr dialog_; + /// + virtual void build(); + /// + virtual ButtonPolicy::SMInput input(FL_OBJECT *, long); + /// + virtual void update(); }; #endif // FORM_MATHSDELIM_H diff --git a/src/frontends/xforms/FormMathsMatrix.C b/src/frontends/xforms/FormMathsMatrix.C index 7d8f6996d0..2e1eda7ea2 100644 --- a/src/frontends/xforms/FormMathsMatrix.C +++ b/src/frontends/xforms/FormMathsMatrix.C @@ -19,11 +19,8 @@ #include "FormMathsMatrix.h" #include "forms/form_maths_matrix.h" - -#include "funcrequest.h" -#include "lyxfunc.h" - -#include "frontends/LyXView.h" +#include "ControlMath.h" +#include "xformsBC.h" #include "support/LAssert.h" #include "support/lyxalgo.h" // lyx::count @@ -59,20 +56,13 @@ extern "C" { } -FormMathsMatrix::FormMathsMatrix(LyXView & lv, Dialogs & d, - FormMathsPanel const & p) - : FormMathsSub(lv, d, p, _("Maths Matrix"), false) +typedef FormCB > base_class; + +FormMathsMatrix::FormMathsMatrix() + : base_class(_("Maths Matrix"), false) {} -FL_FORM * FormMathsMatrix::form() const -{ - if (dialog_.get()) - return dialog_->form; - return 0; -} - - void FormMathsMatrix::build() { dialog_.reset(build_maths_matrix(this)); @@ -105,15 +95,20 @@ void FormMathsMatrix::apply() ostringstream os; os << nx << ' ' << ny << ' ' << c << ' ' << sh; - parent_.dispatchFunc(LFUN_INSERT_MATRIX, STRCONV(os.str())); + controller().dispatchFunc(LFUN_INSERT_MATRIX, STRCONV(os.str())); } +void FormMathsMatrix::update() +{ + bc().valid(); +} -bool FormMathsMatrix::input(FL_OBJECT * ob, long) + +ButtonPolicy::SMInput FormMathsMatrix::input(FL_OBJECT * ob, long) { if (ob == dialog_->choice_valign || - ob == dialog_->slider_rows) return true; + ob == dialog_->slider_rows) return ButtonPolicy::SMI_VALID; int const nx = int(fl_get_slider_value(dialog_->slider_columns)+0.5); for (int i = 0; i < nx; ++i) @@ -123,7 +118,7 @@ bool FormMathsMatrix::input(FL_OBJECT * ob, long) fl_set_input(dialog_->input_halign, h_align_str); fl_redraw_object(dialog_->input_halign); - return true; + return ButtonPolicy::SMI_VALID; } diff --git a/src/frontends/xforms/FormMathsMatrix.h b/src/frontends/xforms/FormMathsMatrix.h index c54a6d51bb..f08fe69087 100644 --- a/src/frontends/xforms/FormMathsMatrix.h +++ b/src/frontends/xforms/FormMathsMatrix.h @@ -18,34 +18,31 @@ #pragma interface #endif -#include "FormMathsPanel.h" - -#include +#include "FormBase.h" +class ControlMathSub; struct FD_maths_matrix; /** * This class provides an XForms implementation of the maths matrix. */ -class FormMathsMatrix : public FormMathsSub { +class FormMathsMatrix : public FormCB > +{ public: - FormMathsMatrix(LyXView &, Dialogs &, FormMathsPanel const &); + /// + FormMathsMatrix(); /// int AlignFilter(char const *, int); private: - /// Build the dialog - virtual void build(); - /// input handler - virtual bool input(FL_OBJECT *, long); - /// Apply from dialog (modify or create inset) + /// virtual void apply(); - - /// Pointer to the actual instantiation of the xforms form - virtual FL_FORM * form() const; - - // Real GUI implementation - boost::scoped_ptr dialog_; + /// + virtual void build(); + /// + virtual ButtonPolicy::SMInput input(FL_OBJECT *, long); + /// + virtual void update(); }; #endif // FORM_MATHSMATRIX_H diff --git a/src/frontends/xforms/FormMathsPanel.C b/src/frontends/xforms/FormMathsPanel.C index 635f7a57dd..9487348f9b 100644 --- a/src/frontends/xforms/FormMathsPanel.C +++ b/src/frontends/xforms/FormMathsPanel.C @@ -18,17 +18,9 @@ #endif #include "ControlMath.h" - -#include "frontends/LyXView.h" #include "FormMathsPanel.h" #include "forms/form_maths_panel.h" -#include "funcrequest.h" - -#include "forms/form_maths_deco.h" -#include "forms/form_maths_delim.h" -#include "forms/form_maths_matrix.h" -#include "forms/form_maths_space.h" -#include "forms/form_maths_style.h" +#include "xformsBC.h" #include "FormMathsBitmap.h" #include "FormMathsDeco.h" @@ -37,8 +29,13 @@ #include "FormMathsSpace.h" #include "FormMathsStyle.h" +#include "forms/form_maths_deco.h" +#include "forms/form_maths_delim.h" +#include "forms/form_maths_matrix.h" +#include "forms/form_maths_space.h" +#include "forms/form_maths_style.h" + #include FORMS_H_LOCATION -#include #include "deco.xpm" #include "delim.xpm" @@ -66,29 +63,27 @@ #include "ams_ops.xbm" -FormMathsPanel::FormMathsPanel(LyXView & lv, Dialogs & d) - : FormBaseBD(lv, d, _("Maths Panel")), - active_(0), bc_(_("Close")) +typedef FormCB > base_class; + +FormMathsPanel::FormMathsPanel() + : base_class(_("Maths Panel")) {} -FL_FORM * FormMathsPanel::form() const -{ - return dialog_.get() ? dialog_->form : 0; -} - - -FormMathsBitmap * FormMathsPanel::addDaughter(FL_OBJECT * button, +FormMathsBitmap * FormMathsPanel::addDaughter(void * key, string const & title, char const * const * data, int size) { - char const * const * end = data + size; - FormMathsBitmap * bitmap = - new FormMathsBitmap(lv_, d_, *this, title, - std::vector(data, end)); - daughters_[button] = DaughterDialog(bitmap); - return bitmap; + char const * const * const end = data + size; + FormMathsBitmap * const view = + new FormMathsBitmap(title, std::vector(data, end)); + + typedef ButtonController BC; + BC * const bc = new BC; + + controller().addDaughter(key, view, bc); + return view; } @@ -121,16 +116,19 @@ void FormMathsPanel::build() fl_set_pixmap_data(dialog_->button_equation, const_cast(equation)); - daughters_[dialog_->button_deco] = - DaughterDialog(new FormMathsDeco(lv_, d_, *this)); - daughters_[dialog_->button_delim] = - DaughterDialog(new FormMathsDelim(lv_, d_, *this)); - daughters_[dialog_->button_matrix] = - DaughterDialog(new FormMathsMatrix(lv_, d_, *this)); - daughters_[dialog_->button_space] = - DaughterDialog(new FormMathsSpace(lv_, d_, *this)); - daughters_[dialog_->button_style] = - DaughterDialog(new FormMathsStyle(lv_, d_, *this)); + typedef ButtonController BC_ignorant; + typedef ButtonController BC_ok; + + controller().addDaughter(dialog_->button_deco, + new FormMathsDeco, new BC_ignorant); + controller().addDaughter(dialog_->button_delim, + new FormMathsDelim, new BC_ok); + controller().addDaughter(dialog_->button_matrix, + new FormMathsMatrix, new BC_ok); + controller().addDaughter(dialog_->button_space, + new FormMathsSpace, new BC_ignorant); + controller().addDaughter(dialog_->button_style, + new FormMathsStyle, new BC_ignorant); FormMathsBitmap * bitmap; bitmap = addDaughter(dialog_->button_arrow, _("Arrows"), @@ -198,24 +196,7 @@ void FormMathsPanel::build() } -void FormMathsPanel::showDaughter(FL_OBJECT * button) -{ - Store::iterator it = daughters_.find(button); - FormMathsSub * const new_active = - (it == daughters_.end()) ? 0 : it->second.get(); - - if (active_ != new_active) { - if (active_ && active_->isVisible()) - active_->hide(); - active_ = new_active; - } - - if (active_ && !active_->isVisible()) - active_->show(); -} - - -bool FormMathsPanel::input(FL_OBJECT * ob, long) +ButtonPolicy::SMInput FormMathsPanel::input(FL_OBJECT * ob, long) { if (ob == dialog_->button_arrow || ob == dialog_->button_boperator || @@ -234,59 +215,32 @@ bool FormMathsPanel::input(FL_OBJECT * ob, long) ob == dialog_->button_deco || ob == dialog_->button_space || ob == dialog_->button_style) { - showDaughter(ob); + controller().showDaughter(ob); } else if (ob == dialog_->button_super) { - dispatchFunc(LFUN_SUPERSCRIPT); + controller().dispatchFunc(LFUN_SUPERSCRIPT); } else if (ob == dialog_->button_sub) { - dispatchFunc(LFUN_SUBSCRIPT); + controller().dispatchFunc(LFUN_SUBSCRIPT); // } else if (ob == dialog_->???) { -// dispatchFunc(LFUN_SUBSCRIPT); -// dispatchFunc(LFUN_LEFT); -// dispatchFunc(LFUN_SUPERSCRIPT); +// controller().dispatchFunc(LFUN_SUBSCRIPT); +// controller().dispatchFunc(LFUN_LEFT); +// controller().dispatchFunc(LFUN_SUPERSCRIPT); } else if (ob == dialog_->button_equation) { - dispatchFunc(LFUN_MATH_DISPLAY); + controller().dispatchFunc(LFUN_MATH_DISPLAY); } else if (ob == dialog_->button_frac) { - insertSymbol("frac"); + controller().insertSymbol("frac"); } else if (ob == dialog_->button_sqrt) { - insertSymbol("sqrt"); + controller().insertSymbol("sqrt"); } else if (ob == dialog_->browser_funcs) { int const i = fl_get_browser(dialog_->browser_funcs) - 1; - insertSymbol(function_names[i]); + controller().insertSymbol(function_names[i]); } - return true; -} - - -void FormMathsPanel::insertSymbol(string const & sym, bool bs) const -{ - if (bs) - lv_.dispatch(FuncRequest(LFUN_INSERT_MATH, '\\' + sym)); - else - lv_.dispatch(FuncRequest(LFUN_INSERT_MATH, sym)); -} - - -void FormMathsPanel::dispatchFunc(kb_action action, string const & arg) const -{ - lv_.dispatch(FuncRequest(action, arg)); -} - - -FormMathsSub::FormMathsSub(LyXView & lv, Dialogs & d, FormMathsPanel const & p, - string const & t, bool allowResize) - : FormBaseBD(lv, d, t, allowResize), parent_(p), bc_(_("Close")) -{} - - -bool FormMathsSub::isVisible() const -{ - return form() ? form()->visible : false; + return ButtonPolicy::SMI_VALID; } diff --git a/src/frontends/xforms/FormMathsPanel.h b/src/frontends/xforms/FormMathsPanel.h index e1a4fd3853..f70c146867 100644 --- a/src/frontends/xforms/FormMathsPanel.h +++ b/src/frontends/xforms/FormMathsPanel.h @@ -14,104 +14,40 @@ #ifndef FORM_MATHSPANEL_H #define FORM_MATHSPANEL_H -#include "commandtags.h" - #ifdef __GNUG__ #pragma interface #endif -#include "FormBaseDeprecated.h" +#include "FormBase.h" -#include -#include - -class FormMathsBitmap; -class FormMathsSub; +class ControlMath; struct FD_maths_panel; +class FormMathsBitmap; /** * This class provides an XForms implementation of the maths panel. */ -class FormMathsPanel : public FormBaseBD { +class FormMathsPanel : public FormCB > { public: /// - FormMathsPanel(LyXView &, Dialogs &); - /// dispatch an LFUN: - void dispatchFunc(kb_action action, - string const & arg = string()) const; - /// dispatch a symbol insert - void insertSymbol(string const & sym, bool bs = true) const; + FormMathsPanel(); private: - /// Pointer to the actual instantiation of the ButtonController. - virtual xformsBC & bc(); + /// Not needed. + virtual void apply() {} + /// + virtual void update() {} - /// Build the dialog + /// virtual void build(); - /// input handler - virtual bool input(FL_OBJECT *, long); - - /// Pointer to the actual instantiation of the xforms form - virtual FL_FORM * form() const; - - // Real GUI implementation - boost::scoped_ptr dialog_; + /// + virtual ButtonPolicy::SMInput input(FL_OBJECT *, long); /** Add a bitmap dialog to the store of all daughters_ and * return a pointer to the dialog, so that bitmaps can be added to it. */ - FormMathsBitmap * addDaughter(FL_OBJECT * button, string const & title, + FormMathsBitmap * addDaughter(void * button, string const & title, char const * const * data, int size); - - /// - void showDaughter(FL_OBJECT *); - - /// - typedef boost::shared_ptr DaughterDialog; - typedef std::map Store; - - /** The store of all daughter dialogs. - * The map uses the button on the main panel to identify them. - */ - Store daughters_; - - /// A pointer to the currently active daughter dialog. - FormMathsSub * active_; - - /// The ButtonController. - ButtonController bc_; }; - -class FormMathsSub : public FormBaseBD { -public: - /// - FormMathsSub(LyXView &, Dialogs &, FormMathsPanel const &, - string const &, bool allowResize = true); - - /// - bool isVisible() const; - -protected: - /// Pointer to the actual instantiation of the ButtonController. - virtual xformsBC & bc(); - /// The parent Maths Panel - FormMathsPanel const & parent_; -private: - /// The ButtonController - ButtonController bc_; -}; - - -inline -xformsBC & FormMathsSub::bc() -{ - return bc_; -} - -inline -xformsBC & FormMathsPanel::bc() -{ - return bc_; -} #endif // FORM_MATHSPANEL_H diff --git a/src/frontends/xforms/FormMathsSpace.C b/src/frontends/xforms/FormMathsSpace.C index 19139bff1e..b22f11c2ed 100644 --- a/src/frontends/xforms/FormMathsSpace.C +++ b/src/frontends/xforms/FormMathsSpace.C @@ -19,25 +19,21 @@ #include "FormMathsSpace.h" #include "forms/form_maths_space.h" +#include "ControlMath.h" +#include "xformsBC.h" + #include FORMS_H_LOCATION extern char * latex_mathspace[]; -FormMathsSpace::FormMathsSpace(LyXView & lv, Dialogs & d, - FormMathsPanel const & p) - : FormMathsSub(lv, d, p, _("Maths Spacing"), false), +typedef FormCB > base_class; + +FormMathsSpace::FormMathsSpace() + : base_class(_("Maths Spacing"), false), space_(-1) {} -FL_FORM * FormMathsSpace::form() const -{ - if (dialog_.get()) - return dialog_->form; - return 0; -} - - void FormMathsSpace::build() { dialog_.reset(build_maths_space(this)); @@ -60,10 +56,10 @@ void FormMathsSpace::build() void FormMathsSpace::apply() { if (space_ >= 0) - parent_.insertSymbol(latex_mathspace[space_]); + controller().insertSymbol(latex_mathspace[space_]); } -bool FormMathsSpace::input(FL_OBJECT *, long data) +ButtonPolicy::SMInput FormMathsSpace::input(FL_OBJECT *, long data) { space_ = -1; @@ -71,5 +67,5 @@ bool FormMathsSpace::input(FL_OBJECT *, long data) space_ = short(data); apply(); } - return true; + return ButtonPolicy::SMI_VALID; } diff --git a/src/frontends/xforms/FormMathsSpace.h b/src/frontends/xforms/FormMathsSpace.h index b390cf3d6a..e7a784576e 100644 --- a/src/frontends/xforms/FormMathsSpace.h +++ b/src/frontends/xforms/FormMathsSpace.h @@ -18,33 +18,28 @@ #pragma interface #endif -#include "FormMathsPanel.h" - -#include +#include "FormBase.h" +class ControlMathSub; struct FD_maths_space; /** * This class provides an XForms implementation of the maths space. */ -class FormMathsSpace : public FormMathsSub { +class FormMathsSpace : public FormCB > { public: /// - FormMathsSpace(LyXView &, Dialogs &, FormMathsPanel const &); + FormMathsSpace(); private: - /// Build the dialog - virtual void build(); - /// input handler - virtual bool input(FL_OBJECT *, long); - /// Apply from dialog (modify or create inset) + /// virtual void apply(); - - /// Pointer to the actual instantiation of the xforms form - virtual FL_FORM * form() const; - - // Real GUI implementation - boost::scoped_ptr dialog_; + /// + virtual void build(); + /// + virtual ButtonPolicy::SMInput input(FL_OBJECT *, long); + /// Not needed. + virtual void update() {} /// The current choice. int space_; diff --git a/src/frontends/xforms/FormMathsStyle.C b/src/frontends/xforms/FormMathsStyle.C index 31c87871d0..0d784d23ef 100644 --- a/src/frontends/xforms/FormMathsStyle.C +++ b/src/frontends/xforms/FormMathsStyle.C @@ -20,9 +20,10 @@ #include "FormMathsStyle.h" #include "forms/form_maths_style.h" -#include "bmtable.h" +#include "ControlMath.h" +#include "xformsBC.h" -#include "debug.h" +#include "bmtable.h" #include FORMS_H_LOCATION @@ -39,22 +40,14 @@ kb_action latex_mathfontcmds[] = { }; +typedef FormCB > base_class; -FormMathsStyle::FormMathsStyle(LyXView & lv, Dialogs & d, - FormMathsPanel const & p) - : FormMathsSub(lv, d, p, _("Maths Styles & Fonts"), false), +FormMathsStyle::FormMathsStyle() + : base_class(_("Maths Styles & Fonts"), false), style_(-1) {} -FL_FORM * FormMathsStyle::form() const -{ - if (dialog_.get()) - return dialog_->form; - return 0; -} - - void FormMathsStyle::build() { dialog_.reset(build_maths_style(this)); @@ -86,21 +79,23 @@ void FormMathsStyle::build() void FormMathsStyle::apply() { if ((style_ >= 0) && (style_ < 4)) - parent_.insertSymbol(latex_mathstyle[style_]); + controller().insertSymbol(latex_mathstyle[style_]); else if ((style_ >= 4) && (style_ < 14)) - parent_.dispatchFunc(latex_mathfontcmds[style_ - 4]); + controller().dispatchFunc(latex_mathfontcmds[style_-4]); } -bool FormMathsStyle::input(FL_OBJECT * ob, long data) +ButtonPolicy::SMInput FormMathsStyle::input(FL_OBJECT * ob, long data) { style_ = fl_get_bmtable(ob); - if (style_ < 0) return false; + if (style_ < 0) return ButtonPolicy::SMI_INVALID; + //if (ob == dialog_->bmtable_style1) style_ += 0; if (ob == dialog_->bmtable_style2) style_ += 1; if (ob == dialog_->bmtable_font1) style_ += 4; if (ob == dialog_->bmtable_font2) style_ += 9; if (data >= 12) style_ = short(data); apply(); - return true; + + return ButtonPolicy::SMI_VALID; } diff --git a/src/frontends/xforms/FormMathsStyle.h b/src/frontends/xforms/FormMathsStyle.h index 20e4c955bc..0c15347da4 100644 --- a/src/frontends/xforms/FormMathsStyle.h +++ b/src/frontends/xforms/FormMathsStyle.h @@ -18,33 +18,28 @@ #pragma interface #endif -#include "FormMathsPanel.h" - -#include +#include "FormBase.h" +class ControlMathSub; struct FD_maths_style; /** * This class provides an XForms implementation of the maths style. */ -class FormMathsStyle : public FormMathsSub { +class FormMathsStyle : public FormCB > { public: /// - FormMathsStyle(LyXView &, Dialogs &, FormMathsPanel const &); + FormMathsStyle(); private: - /// Build the dialog - virtual void build(); - /// input handler - virtual bool input(FL_OBJECT *, long); - /// Apply from dialog (modify or create inset) + /// virtual void apply(); - - /// Pointer to the actual instantiation of the xforms form - virtual FL_FORM * form() const; - - // Real GUI implementation - boost::scoped_ptr dialog_; + /// + virtual void build(); + /// + virtual ButtonPolicy::SMInput input(FL_OBJECT *, long); + /// Not needed. + virtual void update() {} /// The current choice. int style_; diff --git a/src/frontends/xforms/Makefile.am b/src/frontends/xforms/Makefile.am index 6ca9df76d4..57cbad72be 100644 --- a/src/frontends/xforms/Makefile.am +++ b/src/frontends/xforms/Makefile.am @@ -54,8 +54,6 @@ libxforms_la_SOURCES = \ Dialogs_impl.h \ DropDown.h \ DropDown.C \ - FeedbackController.C \ - FeedbackController.h \ FileDialog.C \ FontInfo.C \ FontInfo.h \ @@ -65,8 +63,6 @@ libxforms_la_SOURCES = \ FormAboutlyx.h \ FormBase.C \ FormBase.h \ - FormBaseDeprecated.C \ - FormBaseDeprecated.h \ FormBibitem.C \ FormBibitem.h \ FormBibtex.C \ diff --git a/src/frontends/xforms/forms/form_maths_deco.fd b/src/frontends/xforms/forms/form_maths_deco.fd index b26e7b229e..9b26f613ec 100644 --- a/src/frontends/xforms/forms/form_maths_deco.fd +++ b/src/frontends/xforms/forms/form_maths_deco.fd @@ -46,7 +46,7 @@ shortcut: resize: FL_RESIZE_ALL gravity: FL_NoGravity FL_NoGravity name: bmtable_deco1 -callback: C_FormBaseDeprecatedInputCB +callback: C_FormBaseInputCB argument: 0 -------------------- @@ -64,7 +64,7 @@ shortcut: ^M resize: FL_RESIZE_ALL gravity: FL_NoGravity FL_NoGravity name: button_close -callback: C_FormBaseDeprecatedCancelCB +callback: C_FormBaseCancelCB argument: 0 -------------------- @@ -82,7 +82,7 @@ shortcut: resize: FL_RESIZE_ALL gravity: FL_NoGravity FL_NoGravity name: bmtable_deco2 -callback: C_FormBaseDeprecatedInputCB +callback: C_FormBaseInputCB argument: 0 ============================== diff --git a/src/frontends/xforms/forms/form_maths_delim.fd b/src/frontends/xforms/forms/form_maths_delim.fd index d543119de7..c70e672e9e 100644 --- a/src/frontends/xforms/forms/form_maths_delim.fd +++ b/src/frontends/xforms/forms/form_maths_delim.fd @@ -46,7 +46,7 @@ shortcut: resize: FL_RESIZE_ALL gravity: FL_NoGravity FL_NoGravity name: bmtable -callback: C_FormBaseDeprecatedInputCB +callback: C_FormBaseInputCB argument: 0 -------------------- @@ -64,7 +64,7 @@ shortcut: resize: FL_RESIZE_ALL gravity: FL_NoGravity FL_NoGravity name: button_close -callback: C_FormBaseDeprecatedCancelCB +callback: C_FormBaseCancelCB argument: 0 -------------------- @@ -82,7 +82,7 @@ shortcut: resize: FL_RESIZE_ALL gravity: FL_NoGravity FL_NoGravity name: button_pix -callback: C_FormBaseDeprecatedApplyCB +callback: C_FormBaseApplyCB argument: 0 -------------------- @@ -100,7 +100,7 @@ shortcut: resize: FL_RESIZE_ALL gravity: FL_NoGravity FL_NoGravity name: button_apply -callback: C_FormBaseDeprecatedApplyCB +callback: C_FormBaseApplyCB argument: 0 -------------------- @@ -118,7 +118,7 @@ shortcut: ^M resize: FL_RESIZE_ALL gravity: FL_NoGravity FL_NoGravity name: button_ok -callback: C_FormBaseDeprecatedOKCB +callback: C_FormBaseOKCB argument: 0 -------------------- diff --git a/src/frontends/xforms/forms/form_maths_matrix.fd b/src/frontends/xforms/forms/form_maths_matrix.fd index 401fc84beb..55da21b3c1 100644 --- a/src/frontends/xforms/forms/form_maths_matrix.fd +++ b/src/frontends/xforms/forms/form_maths_matrix.fd @@ -46,7 +46,7 @@ shortcut: resize: FL_RESIZE_ALL gravity: FL_NoGravity FL_NoGravity name: slider_rows -callback: C_FormBaseDeprecatedInputCB +callback: C_FormBaseInputCB argument: 0 bounds: 1 20 precision: 0 @@ -67,7 +67,7 @@ shortcut: resize: FL_RESIZE_ALL gravity: FL_NoGravity FL_NoGravity name: slider_columns -callback: C_FormBaseDeprecatedInputCB +callback: C_FormBaseInputCB argument: 0 bounds: 1 20 precision: 0 @@ -88,7 +88,7 @@ shortcut: resize: FL_RESIZE_ALL gravity: FL_NoGravity FL_NoGravity name: choice_valign -callback: C_FormBaseDeprecatedInputCB +callback: C_FormBaseInputCB argument: 0 -------------------- @@ -106,7 +106,7 @@ shortcut: resize: FL_RESIZE_ALL gravity: FL_NoGravity FL_NoGravity name: input_halign -callback: C_FormBaseDeprecatedInputCB +callback: C_FormBaseInputCB argument: 0 -------------------- @@ -124,7 +124,7 @@ shortcut: ^M resize: FL_RESIZE_ALL gravity: FL_NoGravity FL_NoGravity name: button_ok -callback: C_FormBaseDeprecatedOKCB +callback: C_FormBaseOKCB argument: 0 -------------------- @@ -142,7 +142,7 @@ shortcut: resize: FL_RESIZE_ALL gravity: FL_NoGravity FL_NoGravity name: button_apply -callback: C_FormBaseDeprecatedApplyCB +callback: C_FormBaseApplyCB argument: 0 -------------------- @@ -160,7 +160,7 @@ shortcut: resize: FL_RESIZE_ALL gravity: FL_NoGravity FL_NoGravity name: button_close -callback: C_FormBaseDeprecatedCancelCB +callback: C_FormBaseCancelCB argument: 0 ============================== diff --git a/src/frontends/xforms/forms/form_maths_panel.fd b/src/frontends/xforms/forms/form_maths_panel.fd index 27b81926fc..baac9816d1 100644 --- a/src/frontends/xforms/forms/form_maths_panel.fd +++ b/src/frontends/xforms/forms/form_maths_panel.fd @@ -46,7 +46,7 @@ shortcut: ^M resize: FL_RESIZE_NONE gravity: FL_SouthEast FL_SouthEast name: button_close -callback: C_FormBaseDeprecatedCancelCB +callback: C_FormBaseCancelCB argument: 0 -------------------- @@ -64,7 +64,7 @@ shortcut: resize: FL_RESIZE_ALL gravity: FL_NoGravity FL_SouthEast name: browser_funcs -callback: C_FormBaseDeprecatedInputCB +callback: C_FormBaseInputCB argument: h_pref: FL_OFF @@ -83,7 +83,7 @@ shortcut: resize: FL_RESIZE_ALL gravity: FL_NoGravity FL_NoGravity name: button_greek -callback: C_FormBaseDeprecatedInputCB +callback: C_FormBaseInputCB argument: -------------------- @@ -101,7 +101,7 @@ shortcut: resize: FL_RESIZE_ALL gravity: FL_NoGravity FL_NoGravity name: button_arrow -callback: C_FormBaseDeprecatedInputCB +callback: C_FormBaseInputCB argument: -------------------- @@ -119,7 +119,7 @@ shortcut: resize: FL_RESIZE_ALL gravity: FL_NoGravity FL_NoGravity name: button_boperator -callback: C_FormBaseDeprecatedInputCB +callback: C_FormBaseInputCB argument: -------------------- @@ -137,7 +137,7 @@ shortcut: resize: FL_RESIZE_ALL gravity: FL_NoGravity FL_NoGravity name: button_brelats -callback: C_FormBaseDeprecatedInputCB +callback: C_FormBaseInputCB argument: -------------------- @@ -155,7 +155,7 @@ shortcut: resize: FL_RESIZE_ALL gravity: FL_NoGravity FL_NoGravity name: button_misc -callback: C_FormBaseDeprecatedInputCB +callback: C_FormBaseInputCB argument: -------------------- @@ -173,7 +173,7 @@ shortcut: resize: FL_RESIZE_ALL gravity: FL_NoGravity FL_NoGravity name: button_equation -callback: C_FormBaseDeprecatedInputCB +callback: C_FormBaseInputCB argument: -------------------- @@ -191,7 +191,7 @@ shortcut: resize: FL_RESIZE_ALL gravity: FL_NoGravity FL_NoGravity name: button_sqrt -callback: C_FormBaseDeprecatedInputCB +callback: C_FormBaseInputCB argument: -------------------- @@ -209,7 +209,7 @@ shortcut: resize: FL_RESIZE_ALL gravity: FL_NoGravity FL_NoGravity name: button_frac -callback: C_FormBaseDeprecatedInputCB +callback: C_FormBaseInputCB argument: -------------------- @@ -227,7 +227,7 @@ shortcut: resize: FL_RESIZE_ALL gravity: FL_NoGravity FL_NoGravity name: button_delim -callback: C_FormBaseDeprecatedInputCB +callback: C_FormBaseInputCB argument: -------------------- @@ -245,7 +245,7 @@ shortcut: resize: FL_RESIZE_ALL gravity: FL_NoGravity FL_NoGravity name: button_matrix -callback: C_FormBaseDeprecatedInputCB +callback: C_FormBaseInputCB argument: -------------------- @@ -263,7 +263,7 @@ shortcut: resize: FL_RESIZE_ALL gravity: FL_NoGravity FL_NoGravity name: button_deco -callback: C_FormBaseDeprecatedInputCB +callback: C_FormBaseInputCB argument: -------------------- @@ -281,7 +281,7 @@ shortcut: resize: FL_RESIZE_ALL gravity: FL_NoGravity FL_NoGravity name: button_space -callback: C_FormBaseDeprecatedInputCB +callback: C_FormBaseInputCB argument: -------------------- @@ -299,7 +299,7 @@ shortcut: resize: FL_RESIZE_ALL gravity: FL_NoGravity FL_NoGravity name: button_dots -callback: C_FormBaseDeprecatedInputCB +callback: C_FormBaseInputCB argument: -------------------- @@ -317,7 +317,7 @@ shortcut: resize: FL_RESIZE_ALL gravity: FL_NoGravity FL_NoGravity name: button_varsize -callback: C_FormBaseDeprecatedInputCB +callback: C_FormBaseInputCB argument: -------------------- @@ -335,7 +335,7 @@ shortcut: resize: FL_RESIZE_ALL gravity: FL_NoGravity FL_NoGravity name: button_sub -callback: C_FormBaseDeprecatedInputCB +callback: C_FormBaseInputCB argument: -------------------- @@ -353,7 +353,7 @@ shortcut: resize: FL_RESIZE_ALL gravity: FL_NoGravity FL_NoGravity name: button_super -callback: C_FormBaseDeprecatedInputCB +callback: C_FormBaseInputCB argument: -------------------- @@ -371,7 +371,7 @@ shortcut: resize: FL_RESIZE_ALL gravity: FL_NoGravity FL_NoGravity name: button_style -callback: C_FormBaseDeprecatedInputCB +callback: C_FormBaseInputCB argument: -------------------- @@ -389,7 +389,7 @@ shortcut: resize: FL_RESIZE_ALL gravity: FL_NoGravity FL_NoGravity name: button_ams_arrows -callback: C_FormBaseDeprecatedInputCB +callback: C_FormBaseInputCB argument: -------------------- @@ -407,7 +407,7 @@ shortcut: resize: FL_RESIZE_ALL gravity: FL_NoGravity FL_NoGravity name: button_ams_brel -callback: C_FormBaseDeprecatedInputCB +callback: C_FormBaseInputCB argument: -------------------- @@ -425,7 +425,7 @@ shortcut: resize: FL_RESIZE_ALL gravity: FL_NoGravity FL_NoGravity name: button_ams_nrel -callback: C_FormBaseDeprecatedInputCB +callback: C_FormBaseInputCB argument: -------------------- @@ -443,7 +443,7 @@ shortcut: resize: FL_RESIZE_ALL gravity: FL_NoGravity FL_NoGravity name: button_ams_ops -callback: C_FormBaseDeprecatedInputCB +callback: C_FormBaseInputCB argument: -------------------- @@ -461,7 +461,7 @@ shortcut: resize: FL_RESIZE_ALL gravity: FL_NoGravity FL_NoGravity name: button_ams_misc -callback: C_FormBaseDeprecatedInputCB +callback: C_FormBaseInputCB argument: ============================== diff --git a/src/frontends/xforms/forms/form_maths_space.fd b/src/frontends/xforms/forms/form_maths_space.fd index aebd6f7d25..095de37096 100644 --- a/src/frontends/xforms/forms/form_maths_space.fd +++ b/src/frontends/xforms/forms/form_maths_space.fd @@ -64,7 +64,7 @@ shortcut: resize: FL_RESIZE_ALL gravity: FL_NoGravity FL_NoGravity name: button_negative -callback: C_FormBaseDeprecatedInputCB +callback: C_FormBaseInputCB argument: 0 -------------------- @@ -82,7 +82,7 @@ shortcut: resize: FL_RESIZE_ALL gravity: FL_NoGravity FL_NoGravity name: button_negmedspace -callback: C_FormBaseDeprecatedInputCB +callback: C_FormBaseInputCB argument: 1 -------------------- @@ -100,7 +100,7 @@ shortcut: resize: FL_RESIZE_ALL gravity: FL_NoGravity FL_NoGravity name: button_negthickspace -callback: C_FormBaseDeprecatedInputCB +callback: C_FormBaseInputCB argument: 2 -------------------- @@ -118,7 +118,7 @@ shortcut: resize: FL_RESIZE_ALL gravity: FL_NoGravity FL_NoGravity name: button_thick -callback: C_FormBaseDeprecatedInputCB +callback: C_FormBaseInputCB argument: 5 -------------------- @@ -136,7 +136,7 @@ shortcut: resize: FL_RESIZE_ALL gravity: FL_NoGravity FL_NoGravity name: button_twoquadratin -callback: C_FormBaseDeprecatedInputCB +callback: C_FormBaseInputCB argument: 7 -------------------- @@ -172,7 +172,7 @@ shortcut: ^M resize: FL_RESIZE_ALL gravity: FL_NoGravity FL_NoGravity name: button_close -callback: C_FormBaseDeprecatedCancelCB +callback: C_FormBaseCancelCB argument: 0 -------------------- @@ -190,7 +190,7 @@ shortcut: resize: FL_RESIZE_ALL gravity: FL_NoGravity FL_NoGravity name: button_quadratin -callback: C_FormBaseDeprecatedInputCB +callback: C_FormBaseInputCB argument: 6 -------------------- @@ -208,7 +208,7 @@ shortcut: resize: FL_RESIZE_ALL gravity: FL_NoGravity FL_NoGravity name: button_thin -callback: C_FormBaseDeprecatedInputCB +callback: C_FormBaseInputCB argument: 3 -------------------- @@ -226,7 +226,7 @@ shortcut: resize: FL_RESIZE_ALL gravity: FL_NoGravity FL_NoGravity name: button_medium -callback: C_FormBaseDeprecatedInputCB +callback: C_FormBaseInputCB argument: 4 ============================== diff --git a/src/frontends/xforms/forms/form_maths_style.fd b/src/frontends/xforms/forms/form_maths_style.fd index 7262178d85..c47a63a612 100644 --- a/src/frontends/xforms/forms/form_maths_style.fd +++ b/src/frontends/xforms/forms/form_maths_style.fd @@ -46,7 +46,7 @@ shortcut: resize: FL_RESIZE_ALL gravity: FL_NoGravity FL_NoGravity name: bmtable_font2 -callback: C_FormBaseDeprecatedInputCB +callback: C_FormBaseInputCB argument: 0 -------------------- @@ -64,7 +64,7 @@ shortcut: resize: FL_RESIZE_ALL gravity: FL_NoGravity FL_NoGravity name: bmtable_style1 -callback: C_FormBaseDeprecatedInputCB +callback: C_FormBaseInputCB argument: 0 -------------------- @@ -82,7 +82,7 @@ shortcut: ^M resize: FL_RESIZE_ALL gravity: FL_NoGravity FL_NoGravity name: button_close -callback: C_FormBaseDeprecatedCancelCB +callback: C_FormBaseCancelCB argument: 0 -------------------- @@ -100,7 +100,7 @@ shortcut: resize: FL_RESIZE_ALL gravity: FL_NoGravity FL_NoGravity name: bmtable_style2 -callback: C_FormBaseDeprecatedInputCB +callback: C_FormBaseInputCB argument: 0 -------------------- @@ -118,7 +118,7 @@ shortcut: resize: FL_RESIZE_ALL gravity: FL_NoGravity FL_NoGravity name: bmtable_font1 -callback: C_FormBaseDeprecatedInputCB +callback: C_FormBaseInputCB argument: 0 -------------------- @@ -136,7 +136,7 @@ shortcut: resize: FL_RESIZE_ALL gravity: FL_NoGravity FL_NoGravity name: button_reset -callback: C_FormBaseDeprecatedInputCB +callback: C_FormBaseInputCB argument: 13 -------------------- @@ -154,7 +154,7 @@ shortcut: resize: FL_RESIZE_ALL gravity: FL_NoGravity FL_NoGravity name: button_textrm -callback: C_FormBaseDeprecatedInputCB +callback: C_FormBaseInputCB argument: 12 ==============================