From 127265cc83051c6161973c97abd2b8152a0a9d87 Mon Sep 17 00:00:00 2001 From: Angus Leeming Date: Fri, 23 Mar 2001 18:46:11 +0000 Subject: [PATCH] controller-view split for Url popup. Something has gone wrong with the creation of new insets from the menu, but this commit squashes a couple of minor bugs. git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@1818 a592a061-630c-0410-9148-cb99ea01b6c8 --- src/frontends/controllers/ChangeLog | 5 +- src/frontends/controllers/ControlBibitem.C | 1 - src/frontends/controllers/ControlBibitem.h | 1 - src/frontends/controllers/ControlCommand.C | 4 ++ src/frontends/controllers/ControlInset.h | 30 ++------- src/frontends/controllers/ControlUrl.C | 35 ++++++++++ src/frontends/controllers/ControlUrl.h | 36 +++++++++++ src/frontends/controllers/GUI.h | 14 ++++ src/frontends/controllers/Makefile.am | 2 + src/frontends/xforms/ChangeLog | 4 +- src/frontends/xforms/Dialogs.C | 6 +- src/frontends/xforms/FormBibitem.C | 4 +- src/frontends/xforms/FormBibitem.h | 1 - src/frontends/xforms/FormUrl.C | 75 ++++++---------------- src/frontends/xforms/FormUrl.h | 44 +++++-------- src/frontends/xforms/form_url.C | 14 ++-- src/frontends/xforms/form_url.h | 10 +-- src/frontends/xforms/forms/form_url.fd | 14 ++-- 18 files changed, 162 insertions(+), 138 deletions(-) create mode 100644 src/frontends/controllers/ControlUrl.C create mode 100644 src/frontends/controllers/ControlUrl.h diff --git a/src/frontends/controllers/ChangeLog b/src/frontends/controllers/ChangeLog index 84638ba95d..1845361549 100644 --- a/src/frontends/controllers/ChangeLog +++ b/src/frontends/controllers/ChangeLog @@ -14,8 +14,9 @@ * lots of files. Moved protected stuff into private where possible. * ControlError.[Ch]: - * ControlInclude.[Ch]: new files; controllers for the LaTeX error and - Include popups, respectively. + * ControlInclude.[Ch]: + * ControlUrl.[Ch]: new files; controllers for the LaTeX error, + Include and Url popups, respectively. * GUI.h: * Makefile.am: associated changes. diff --git a/src/frontends/controllers/ControlBibitem.C b/src/frontends/controllers/ControlBibitem.C index 3e27790510..65993c134a 100644 --- a/src/frontends/controllers/ControlBibitem.C +++ b/src/frontends/controllers/ControlBibitem.C @@ -1,4 +1,3 @@ -// -*- C++ -*- /* This file is part of * ====================================================== * diff --git a/src/frontends/controllers/ControlBibitem.h b/src/frontends/controllers/ControlBibitem.h index 6a852cbe09..ab4cffdffe 100644 --- a/src/frontends/controllers/ControlBibitem.h +++ b/src/frontends/controllers/ControlBibitem.h @@ -1,4 +1,3 @@ -// -*- C++ -*- /* This file is part of * ====================================================== * diff --git a/src/frontends/controllers/ControlCommand.C b/src/frontends/controllers/ControlCommand.C index d95c53bf2e..fbb1388325 100644 --- a/src/frontends/controllers/ControlCommand.C +++ b/src/frontends/controllers/ControlCommand.C @@ -49,8 +49,12 @@ void ControlCommand::applyParamsToInset() void ControlCommand::applyParamsNoInset() { + std::cerr << "1" << std::endl; if (action_ == LFUN_NOACTION) return; + std::cerr << "2" << std::endl; + lv_.getLyXFunc()->Dispatch(action_, params().getAsString()); + std::cerr << "3" << std::endl; } diff --git a/src/frontends/controllers/ControlInset.h b/src/frontends/controllers/ControlInset.h index 7ca3a902f6..fea95371c8 100644 --- a/src/frontends/controllers/ControlInset.h +++ b/src/frontends/controllers/ControlInset.h @@ -72,10 +72,6 @@ private: void show(Params const &); /// Connect signals void connectInset(Inset * = 0); - /// Disconnect signals - virtual void disconnect(); - /// - void disconnectInset(); /// pointer to the inset passed through connectInset Inset * inset_; @@ -140,9 +136,11 @@ void ControlInset::hide() delete params_; params_ = 0; } + inset_ = 0; clearDaughterParams(); + ih_.disconnect(); disconnect(); view().hide(); } @@ -171,9 +169,9 @@ void ControlInset::apply() view().apply(); - if (inset_ && params() != getParams(*inset_)) - applyParamsToInset(); - else if (!inset_) + if (inset_) { + if (params() != getParams(*inset_)) applyParamsToInset(); + } else applyParamsNoInset(); } @@ -204,15 +202,6 @@ void ControlInset::updateSlot(bool switched) } -template -void ControlInset::disconnect() -{ - inset_ = 0; - ih_.disconnect(); - ControlConnectBD::disconnect(); -} - - template void ControlInset::connectInset(Inset * inset) { @@ -229,13 +218,4 @@ void ControlInset::connectInset(Inset * inset) } connect(); } - - -template -void ControlInset::disconnectInset() -{ - ih_.disconnect(); -} - - #endif // CONTROLINSET_H diff --git a/src/frontends/controllers/ControlUrl.C b/src/frontends/controllers/ControlUrl.C new file mode 100644 index 0000000000..435880b76b --- /dev/null +++ b/src/frontends/controllers/ControlUrl.C @@ -0,0 +1,35 @@ +/* This file is part of + * ====================================================== + * + * LyX, The Document Processor + * + * Copyright 2001 The LyX Team. + * + * ====================================================== + * + * \file ControlUrl.C + * \author Angus Leeming + */ + +#include + +#ifdef __GNUG__ +#pragma implementation +#endif + +#include "Dialogs.h" +#include "ControlUrl.h" +#include "Dialogs.h" +#include "LyXView.h" +#include "buffer.h" + +#include "lyxfunc.h" + +using SigC::slot; + +ControlUrl::ControlUrl(LyXView & lv, Dialogs & d) + : ControlCommand(lv, d, LFUN_INSERT_URL) +{ + d_.showUrl.connect(slot(this, &ControlUrl::showInset)); + d_.createUrl.connect(slot(this, &ControlUrl::createInset)); +} diff --git a/src/frontends/controllers/ControlUrl.h b/src/frontends/controllers/ControlUrl.h new file mode 100644 index 0000000000..de6eebc67a --- /dev/null +++ b/src/frontends/controllers/ControlUrl.h @@ -0,0 +1,36 @@ +/* This file is part of + * ====================================================== + * + * LyX, The Document Processor + * + * Copyright 2001 The LyX Team. + * + * ====================================================== + * + * \file ControlUrl.h + * \author Angus Leeming + */ + +#ifndef CONTROLURL_H +#define CONTROLURL_H + +#ifdef __GNUG__ +#pragma interface +#endif + +#include "ControlCommand.h" + +/** This class provides an XForms implementation of the FormUrl Dialog. + */ +class ControlUrl : public ControlCommand +{ +public: + /// + ControlUrl(LyXView &, Dialogs &); + +private: + /// not needed. + virtual void clearDaughterParams() {} +}; + +#endif // CONTROLURL_H diff --git a/src/frontends/controllers/GUI.h b/src/frontends/controllers/GUI.h index cfa4bc5c87..5e966a7a9a 100644 --- a/src/frontends/controllers/GUI.h +++ b/src/frontends/controllers/GUI.h @@ -151,6 +151,20 @@ public: }; +/** Specialization for Url dialog + */ +class ControlUrl; + +template +class GUIUrl : + public GUI { +public: + /// + GUIUrl(LyXView & lv, Dialogs & d) + : GUI(lv, d) {} +}; + + /** Specialization for VCLog dialog */ class ControlVCLog; diff --git a/src/frontends/controllers/Makefile.am b/src/frontends/controllers/Makefile.am index fb219a4424..a09ad13ca5 100644 --- a/src/frontends/controllers/Makefile.am +++ b/src/frontends/controllers/Makefile.am @@ -39,6 +39,8 @@ libcontrollers_la_SOURCES=\ ControlInset.h \ ControlLog.C \ ControlLog.h \ + ControlUrl.C \ + ControlUrl.h \ ControlVCLog.C \ ControlVCLog.h \ GUI.h \ diff --git a/src/frontends/xforms/ChangeLog b/src/frontends/xforms/ChangeLog index 095baae307..9d5a69da4b 100644 --- a/src/frontends/xforms/ChangeLog +++ b/src/frontends/xforms/ChangeLog @@ -3,7 +3,9 @@ * FormError.[Ch]: * form_error.fd: * FormInclude.[Ch]: - * form_include.fd: implemented controller-view split. + * form_include.fd: + * FormUrl.[Ch]: + * form_url.fd: implemented controller-view split. * Dialogs.C: associated changes. diff --git a/src/frontends/xforms/Dialogs.C b/src/frontends/xforms/Dialogs.C index c34f73c976..b6a691f996 100644 --- a/src/frontends/xforms/Dialogs.C +++ b/src/frontends/xforms/Dialogs.C @@ -28,6 +28,7 @@ #include "ControlError.h" #include "ControlInclude.h" #include "ControlLog.h" +#include "ControlUrl.h" #include "ControlVCLog.h" #include "GUI.h" @@ -42,6 +43,7 @@ #include "form_credits.h" #include "form_error.h" #include "form_include.h" +#include "form_url.h" #include "FormBibitem.h" #include "FormBibtex.h" @@ -52,6 +54,7 @@ #include "FormError.h" #include "FormInclude.h" #include "FormLog.h" +#include "FormUrl.h" #include "FormVCLog.h" #include "FormDocument.h" @@ -69,7 +72,6 @@ #include "FormTabular.h" #include "FormTabularCreate.h" #include "FormToc.h" -#include "FormUrl.h" #include "FormMinipage.h" // Signal enabling all visible popups to be redrawn if so desired. @@ -89,6 +91,7 @@ Dialogs::Dialogs(LyXView * lv) add(new GUIError(*lv, *this)); add(new GUIInclude(*lv, *this)); add(new GUILog(*lv, *this)); + add(new GUIUrl(*lv, *this)); add(new GUIVCLog(*lv, *this)); add(new FormDocument(lv, this)); @@ -106,7 +109,6 @@ Dialogs::Dialogs(LyXView * lv) add(new FormTabular(lv, this)); add(new FormTabularCreate(lv, this)); add(new FormToc(lv, this)); - add(new FormUrl(lv, this)); add(new FormMinipage(lv, this)); // reduce the number of connections needed in diff --git a/src/frontends/xforms/FormBibitem.C b/src/frontends/xforms/FormBibitem.C index f37487573f..9584cedc3b 100644 --- a/src/frontends/xforms/FormBibitem.C +++ b/src/frontends/xforms/FormBibitem.C @@ -3,8 +3,8 @@ * Copyright 2001 the LyX Team * Read the file COPYING * - * \author Angus Leeming - * \author John Levon + * \author Angus Leeming, a.leeming@ic.ac.uk + * \author John Levon, moz@compsoc.man.ac.uk */ #ifdef __GNUG__ diff --git a/src/frontends/xforms/FormBibitem.h b/src/frontends/xforms/FormBibitem.h index 82e1326d79..bbbba2169c 100644 --- a/src/frontends/xforms/FormBibitem.h +++ b/src/frontends/xforms/FormBibitem.h @@ -1,4 +1,3 @@ -// -*- C++ -*- /** * \file FormBibitem.h * Copyright 2001 the LyX Team diff --git a/src/frontends/xforms/FormUrl.C b/src/frontends/xforms/FormUrl.C index 78b2cad0f0..bcea437694 100644 --- a/src/frontends/xforms/FormUrl.C +++ b/src/frontends/xforms/FormUrl.C @@ -1,56 +1,34 @@ -// -*- C++ -*- -/* This file is part of +/* \file FormUrl.C + * This file is part of * ====================================================== * * LyX, The Document Processor * - * Copyright 2000 The LyX Team. + * Copyright 2000-2001 The LyX Team. * * ====================================================== + * + * \author Angus Leeming, a.leeming@ic.ac.uk */ #include -#include FORMS_H_LOCATION - #ifdef __GNUG__ #pragma implementation #endif -#include "Dialogs.h" +#include "xformsBC.h" +#include "ControlUrl.h" #include "FormUrl.h" -#include "LyXView.h" -#include "buffer.h" #include "form_url.h" -#include "lyxfunc.h" -using SigC::slot; +typedef FormCB > base_class; -FormUrl::FormUrl(LyXView * lv, Dialogs * d) - : FormCommand(lv, d, _("Url")) -{ - // let the dialog be shown - // These are permanent connections so we won't bother - // storing a copy because we won't be disconnecting. - d->showUrl.connect(slot(this, &FormUrl::showInset)); - d->createUrl.connect(slot(this, &FormUrl::createInset)); -} +FormUrl::FormUrl(ControlUrl & c) + : base_class(c, _("Url")) +{} -FL_FORM * FormUrl::form() const -{ - if (dialog_.get()) return dialog_->form; - return 0; -} - - -void FormUrl::connect() -{ - fl_set_form_maxsize(form(), 2 * minw_, minh_); - FormCommand::connect(); -} - - void FormUrl::build() { dialog_.reset(build_url()); @@ -73,38 +51,25 @@ void FormUrl::build() void FormUrl::update() { - fl_set_input(dialog_->url, params.getContents().c_str()); - fl_set_input(dialog_->name, params.getOptions().c_str()); + fl_set_input(dialog_->url, + controller().params().getContents().c_str()); + fl_set_input(dialog_->name, + controller().params().getOptions().c_str()); - if (params.getCmdName() == "url") + if (controller().params().getCmdName() == "url") fl_set_button(dialog_->radio_html, 0); else fl_set_button(dialog_->radio_html, 1); - - bc().readOnly(lv_->buffer()->isReadonly()); } void FormUrl::apply() { - if (lv_->buffer()->isReadonly()) return; - - params.setContents(fl_get_input(dialog_->url)); - params.setOptions(fl_get_input(dialog_->name)); + controller().params().setContents(fl_get_input(dialog_->url)); + controller().params().setOptions(fl_get_input(dialog_->name)); if (fl_get_button(dialog_->radio_html)) - params.setCmdName("htmlurl"); + controller().params().setCmdName("htmlurl"); else - params.setCmdName("url"); - - if (inset_ != 0) { - // Only update if contents have changed - if (params != inset_->params()) { - inset_->setParams(params); - lv_->view()->updateInset(inset_, true); - } - } else { - lv_->getLyXFunc()->Dispatch(LFUN_INSERT_URL, - params.getAsString()); - } + controller().params().setCmdName("url"); } diff --git a/src/frontends/xforms/FormUrl.h b/src/frontends/xforms/FormUrl.h index 0fb7915d41..951ab9070b 100644 --- a/src/frontends/xforms/FormUrl.h +++ b/src/frontends/xforms/FormUrl.h @@ -1,58 +1,44 @@ -// -*- C++ -*- -/* This file is part of +/* \file FormUrl.h + * This file is part of * ====================================================== * * LyX, The Document Processor * - * Copyright 2000 The LyX Team. + * Copyright 2000-2001 The LyX Team. * * ====================================================== + * + * \author Angus Leeming, a.leeming@.ac.uk */ #ifndef FORMURL_H #define FORMURL_H -#include - #ifdef __GNUG__ #pragma interface #endif -#include "FormInset.h" +#include "FormBase.h" +class ControlUrl; struct FD_form_url; -/** This class provides an XForms implementation of the FormUrl Dialog. +/** This class provides an XForms implementation of the Url Dialog. */ -class FormUrl : public FormCommand { +class FormUrl : public FormCB > { public: /// - FormUrl(LyXView *, Dialogs *); + FormUrl(ControlUrl &); + private: - /// Pointer to the actual instantiation of the ButtonController. - virtual xformsBC & bc(); - /// Connect signals etc. Set form's max size. - virtual void connect(); + /// Apply from dialog (modify or create inset) + virtual void apply(); /// Build the dialog virtual void build(); /// Update dialog before showing it virtual void update(); - /// Apply from dialog (modify or create inset) - virtual void apply(); - /// Pointer to the actual instantiation of the xforms form - virtual FL_FORM * form() const; - /// + /// Filter the inputs on callback from xforms FD_form_url * build_url(); - /// Real GUI implementation. - boost::scoped_ptr dialog_; - /// The ButtonController - ButtonController bc_; }; - -inline -xformsBC & FormUrl::bc() -{ - return bc_; -} -#endif +#endif // FORMURL_H diff --git a/src/frontends/xforms/form_url.C b/src/frontends/xforms/form_url.C index c91a362d24..4d5e4b002e 100644 --- a/src/frontends/xforms/form_url.C +++ b/src/frontends/xforms/form_url.C @@ -33,7 +33,7 @@ FD_form_url * FormUrl::build_url() fl_set_object_lsize(obj, FL_NORMAL_SIZE); fl_set_object_gravity(obj, FL_NorthWest, FL_NorthEast); fl_set_object_resize(obj, FL_RESIZE_X); - fl_set_object_callback(obj, C_FormBaseDeprecatedInputCB, 0); + fl_set_object_callback(obj, C_FormBaseInputCB, 0); { char const * const dummy = N_("Name|#N"); fdui->name = obj = fl_add_input(FL_NORMAL_INPUT, 70, 90, 440, 30, idex(_(dummy))); @@ -42,7 +42,7 @@ FD_form_url * FormUrl::build_url() fl_set_object_lsize(obj, FL_NORMAL_SIZE); fl_set_object_gravity(obj, FL_NorthWest, FL_NorthEast); fl_set_object_resize(obj, FL_RESIZE_X); - fl_set_object_callback(obj, C_FormBaseDeprecatedInputCB, 0); + fl_set_object_callback(obj, C_FormBaseInputCB, 0); { char const * const dummy = N_("HTML type|#H"); fdui->radio_html = obj = fl_add_checkbutton(FL_PUSH_BUTTON, 480, 10, 30, 30, idex(_(dummy))); @@ -52,7 +52,7 @@ FD_form_url * FormUrl::build_url() fl_set_object_lalign(obj, FL_ALIGN_LEFT); fl_set_object_gravity(obj, FL_NorthWest, FL_NorthEast); fl_set_object_resize(obj, FL_RESIZE_X); - fl_set_object_callback(obj, C_FormBaseDeprecatedInputCB, 0); + fl_set_object_callback(obj, C_FormBaseInputCB, 0); { char const * const dummy = N_("Cancel|^["); fdui->button_cancel = obj = fl_add_button(FL_NORMAL_BUTTON, 410, 130, 100, 30, idex(_(dummy))); @@ -60,10 +60,10 @@ FD_form_url * FormUrl::build_url() } fl_set_object_lsize(obj, FL_NORMAL_SIZE); fl_set_object_gravity(obj, FL_SouthEast, FL_SouthEast); - fl_set_object_callback(obj, C_FormBaseDeprecatedCancelCB, 0); + fl_set_object_callback(obj, C_FormBaseCancelCB, 0); fdui->button_ok = obj = fl_add_button(FL_RETURN_BUTTON, 190, 130, 100, 30, _("OK")); fl_set_object_gravity(obj, FL_SouthEast, FL_SouthEast); - fl_set_object_callback(obj, C_FormBaseDeprecatedOKCB, 0); + fl_set_object_callback(obj, C_FormBaseOKCB, 0); { char const * const dummy = N_("Apply|#A"); fdui->button_apply = obj = fl_add_button(FL_NORMAL_BUTTON, 300, 130, 100, 30, idex(_(dummy))); @@ -71,7 +71,7 @@ FD_form_url * FormUrl::build_url() } fl_set_object_lsize(obj, FL_NORMAL_SIZE); fl_set_object_gravity(obj, FL_SouthEast, FL_SouthEast); - fl_set_object_callback(obj, C_FormBaseDeprecatedApplyCB, 0); + fl_set_object_callback(obj, C_FormBaseApplyCB, 0); { char const * const dummy = N_("Restore|#R"); fdui->button_restore = obj = fl_add_button(FL_NORMAL_BUTTON, 10, 130, 100, 30, idex(_(dummy))); @@ -79,7 +79,7 @@ FD_form_url * FormUrl::build_url() } fl_set_object_lsize(obj, FL_NORMAL_SIZE); fl_set_object_gravity(obj, FL_SouthEast, FL_SouthEast); - fl_set_object_callback(obj, C_FormBaseDeprecatedRestoreCB, 0); + fl_set_object_callback(obj, C_FormBaseRestoreCB, 0); fl_end_form(); fdui->form->fdui = fdui; diff --git a/src/frontends/xforms/form_url.h b/src/frontends/xforms/form_url.h index b6221726eb..79bb426856 100644 --- a/src/frontends/xforms/form_url.h +++ b/src/frontends/xforms/form_url.h @@ -5,11 +5,11 @@ #define FD_form_url_h_ /** Callbacks, globals and object handlers **/ -extern "C" void C_FormBaseDeprecatedInputCB(FL_OBJECT *, long); -extern "C" void C_FormBaseDeprecatedCancelCB(FL_OBJECT *, long); -extern "C" void C_FormBaseDeprecatedOKCB(FL_OBJECT *, long); -extern "C" void C_FormBaseDeprecatedApplyCB(FL_OBJECT *, long); -extern "C" void C_FormBaseDeprecatedRestoreCB(FL_OBJECT *, long); +extern "C" void C_FormBaseInputCB(FL_OBJECT *, long); +extern "C" void C_FormBaseCancelCB(FL_OBJECT *, long); +extern "C" void C_FormBaseOKCB(FL_OBJECT *, long); +extern "C" void C_FormBaseApplyCB(FL_OBJECT *, long); +extern "C" void C_FormBaseRestoreCB(FL_OBJECT *, long); /**** Forms and Objects ****/ diff --git a/src/frontends/xforms/forms/form_url.fd b/src/frontends/xforms/forms/form_url.fd index 84730de145..7fa732da88 100644 --- a/src/frontends/xforms/forms/form_url.fd +++ b/src/frontends/xforms/forms/form_url.fd @@ -45,7 +45,7 @@ shortcut: resize: FL_RESIZE_X gravity: FL_NorthWest FL_NorthEast name: url -callback: C_FormBaseDeprecatedInputCB +callback: C_FormBaseInputCB argument: 0 -------------------- @@ -63,7 +63,7 @@ shortcut: resize: FL_RESIZE_X gravity: FL_NorthWest FL_NorthEast name: name -callback: C_FormBaseDeprecatedInputCB +callback: C_FormBaseInputCB argument: 0 -------------------- @@ -81,7 +81,7 @@ shortcut: resize: FL_RESIZE_X gravity: FL_NorthWest FL_NorthEast name: radio_html -callback: C_FormBaseDeprecatedInputCB +callback: C_FormBaseInputCB argument: 0 -------------------- @@ -99,7 +99,7 @@ shortcut: resize: FL_RESIZE_NONE gravity: FL_SouthEast FL_SouthEast name: button_cancel -callback: C_FormBaseDeprecatedCancelCB +callback: C_FormBaseCancelCB argument: 0 -------------------- @@ -117,7 +117,7 @@ shortcut: ^M resize: FL_RESIZE_ALL gravity: FL_SouthEast FL_SouthEast name: button_ok -callback: C_FormBaseDeprecatedOKCB +callback: C_FormBaseOKCB argument: 0 -------------------- @@ -135,7 +135,7 @@ shortcut: resize: FL_RESIZE_NONE gravity: FL_SouthEast FL_SouthEast name: button_apply -callback: C_FormBaseDeprecatedApplyCB +callback: C_FormBaseApplyCB argument: 0 -------------------- @@ -153,7 +153,7 @@ shortcut: resize: FL_RESIZE_NONE gravity: FL_SouthEast FL_SouthEast name: button_restore -callback: C_FormBaseDeprecatedRestoreCB +callback: C_FormBaseRestoreCB argument: 0 ==============================