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
This commit is contained in:
Angus Leeming 2001-03-23 18:46:11 +00:00
parent 9705be9f1b
commit 127265cc83
18 changed files with 162 additions and 138 deletions

View File

@ -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.

View File

@ -1,4 +1,3 @@
// -*- C++ -*-
/* This file is part of
* ======================================================
*

View File

@ -1,4 +1,3 @@
// -*- C++ -*-
/* This file is part of
* ======================================================
*

View File

@ -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;
}

View File

@ -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<Inset, Params>::hide()
delete params_;
params_ = 0;
}
inset_ = 0;
clearDaughterParams();
ih_.disconnect();
disconnect();
view().hide();
}
@ -171,9 +169,9 @@ void ControlInset<Inset, Params>::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<Inset, Params>::updateSlot(bool switched)
}
template <class Inset, class Params>
void ControlInset<Inset, Params>::disconnect()
{
inset_ = 0;
ih_.disconnect();
ControlConnectBD::disconnect();
}
template <class Inset, class Params>
void ControlInset<Inset, Params>::connectInset(Inset * inset)
{
@ -229,13 +218,4 @@ void ControlInset<Inset, Params>::connectInset(Inset * inset)
}
connect();
}
template <class Inset, class Params>
void ControlInset<Inset, Params>::disconnectInset()
{
ih_.disconnect();
}
#endif // CONTROLINSET_H

View File

@ -0,0 +1,35 @@
/* This file is part of
* ======================================================
*
* LyX, The Document Processor
*
* Copyright 2001 The LyX Team.
*
* ======================================================
*
* \file ControlUrl.C
* \author Angus Leeming <a.leeming@ic.ac.uk>
*/
#include <config.h>
#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));
}

View File

@ -0,0 +1,36 @@
/* This file is part of
* ======================================================
*
* LyX, The Document Processor
*
* Copyright 2001 The LyX Team.
*
* ======================================================
*
* \file ControlUrl.h
* \author Angus Leeming <a.leeming@ic.ac.uk>
*/
#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

View File

@ -151,6 +151,20 @@ public:
};
/** Specialization for Url dialog
*/
class ControlUrl;
template <class GUIview, class GUIbc>
class GUIUrl :
public GUI<ControlUrl, GUIview, NoRepeatedApplyReadOnlyPolicy, GUIbc> {
public:
///
GUIUrl(LyXView & lv, Dialogs & d)
: GUI<ControlUrl, GUIview, NoRepeatedApplyReadOnlyPolicy, GUIbc>(lv, d) {}
};
/** Specialization for VCLog dialog
*/
class ControlVCLog;

View File

@ -39,6 +39,8 @@ libcontrollers_la_SOURCES=\
ControlInset.h \
ControlLog.C \
ControlLog.h \
ControlUrl.C \
ControlUrl.h \
ControlVCLog.C \
ControlVCLog.h \
GUI.h \

View File

@ -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.

View File

@ -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<FormError, xformsBC>(*lv, *this));
add(new GUIInclude<FormInclude, xformsBC>(*lv, *this));
add(new GUILog<FormLog, xformsBC>(*lv, *this));
add(new GUIUrl<FormUrl, xformsBC>(*lv, *this));
add(new GUIVCLog<FormVCLog, xformsBC>(*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

View File

@ -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__

View File

@ -1,4 +1,3 @@
// -*- C++ -*-
/**
* \file FormBibitem.h
* Copyright 2001 the LyX Team

View File

@ -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 <config.h>
#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<ControlUrl, FormDB<FD_form_url> > 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");
}

View File

@ -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 <boost/smart_ptr.hpp>
#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<ControlUrl, FormDB<FD_form_url> > {
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<FD_form_url> dialog_;
/// The ButtonController
ButtonController<NoRepeatedApplyReadOnlyPolicy, xformsBC> bc_;
};
inline
xformsBC & FormUrl::bc()
{
return bc_;
}
#endif
#endif // FORMURL_H

View File

@ -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;

View File

@ -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 ****/

View File

@ -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
==============================