Remove all the cruft needed by the original MVC dialog code.

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@8578 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
Angus Leeming 2004-03-31 22:09:52 +00:00
parent 97e2756b9f
commit d2603b93c7
30 changed files with 33 additions and 1865 deletions

View File

@ -18,12 +18,10 @@ src/frontends/LyXView.C
src/frontends/controllers/ControlAboutlyx.C
src/frontends/controllers/ControlBibtex.C
src/frontends/controllers/ControlBox.C
src/frontends/controllers/ControlDocument.C
src/frontends/controllers/ControlExternal.C
src/frontends/controllers/ControlGraphics.C
src/frontends/controllers/ControlInclude.C
src/frontends/controllers/ControlLog.C
src/frontends/controllers/ControlPreamble.C
src/frontends/controllers/ControlPrefs.C
src/frontends/controllers/ControlPrint.C
src/frontends/controllers/ControlSpellchecker.C
@ -90,7 +88,6 @@ src/frontends/xforms/Alert_pimpl.C
src/frontends/xforms/ColorHandler.C
src/frontends/xforms/Dialogs.C
src/frontends/xforms/FormAboutlyx.C
src/frontends/xforms/FormBase.C
src/frontends/xforms/FormBibitem.C
src/frontends/xforms/FormBibtex.C
src/frontends/xforms/FormBox.C
@ -190,8 +187,6 @@ src/output_plaintext.C
src/paragraph.C
src/rowpainter.C
src/support/globbing.C
src/support/path_defines.C
src/tex2lyx/lengthcommon.C
src/text.C
src/text2.C
src/text3.C

View File

@ -68,13 +68,6 @@ Dialogs::Dialogs(LyXView & lyxview)
{
// Connect signals
redrawGUI().connect(boost::bind(&Dialogs::redraw, this));
hideSignal().connect(boost::bind(&Dialogs::hideSlot, this, _1, _2));
// All this is slated to go
init_pimpl();
// reduce the number of connections needed in
// dialogs by a simple connection here.
hideAllSignal.connect(hideBufferDependentSignal);
}
@ -185,7 +178,6 @@ void Dialogs::hideAll() const
for(; it != end; ++it) {
it->second->hide();
}
hideAllSignal();
}
@ -199,7 +191,6 @@ void Dialogs::hideBufferDependent() const
if (dialog->controller().isBufferDependent())
dialog->hide();
}
hideBufferDependentSignal();
}
@ -219,7 +210,6 @@ void Dialogs::updateBufferDependent(bool switched) const
dialog->RestoreButton();
}
}
updateBufferDependentSignal(switched);
}

View File

@ -28,8 +28,6 @@ class Dialogs : boost::noncopyable
public:
///
Dialogs(LyXView &);
///
~Dialogs();
/** Redraw all visible dialogs because, for example, the GUI colours
* have been re-mapped.
@ -45,13 +43,6 @@ public:
/// Are the tooltips on or off?
static bool tooltipsEnabled();
/// Signals slated to go
//@{
boost::signal0<void> hideAllSignal;
boost::signal0<void> hideBufferDependentSignal;
boost::signal1<void, bool> updateBufferDependentSignal;
//@}
/// Hide all visible dialogs
void hideAll() const;
/// Hide any dialogs that require a buffer for them to operate
@ -121,13 +112,6 @@ private:
///
std::map<std::string, DialogPtr> dialogs_;
/// the stuff below is slated to go...
void init_pimpl();
///
class Impl;
///
Impl * pimpl_;
};
#endif

View File

@ -1,3 +1,14 @@
2004-03-31 Angus Leeming <leeming@lyx.org>
* ControlButtons.[Ch]:
* ControlConnections.[Ch]:
* ControlDialog.{h,tmpl}:
* ControlDialog_impl.[Ch]:
* GUI.h:
* ViewBase.[Ch]: all removed.
* Makefile.am: adjusted to suit.
2004-03-31 Angus Leeming <leeming@lyx.org>
* ControlPreamble.[Ch]: converted to the dialog-based scheme.

View File

@ -1,84 +0,0 @@
/**
* \file ControlButtons.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 <config.h>
#include "ControlButtons.h"
#include "ButtonController.h"
#include "BCView.h"
#include "lyxrc.h"
ControlButtons::ControlButtons()
: emergency_exit_(false), is_closing_(false),
bc_ptr_(new ButtonController), view_ptr_(0)
{}
ControlButtons::~ControlButtons()
{}
void ControlButtons::ApplyButton()
{
apply();
bc().apply();
}
void ControlButtons::OKButton()
{
is_closing_ = true;
apply();
is_closing_ = false;
hide();
bc().ok();
}
void ControlButtons::CancelButton()
{
hide();
bc().cancel();
}
void ControlButtons::RestoreButton()
{
update();
bc().restore();
}
bool ControlButtons::IconifyWithMain() const
{
return lyxrc.dialogs_iconify_with_main;
}
ButtonController & ControlButtons::bc()
{
BOOST_ASSERT(bc_ptr_.get());
return *bc_ptr_.get();
}
ViewBase & ControlButtons::view()
{
BOOST_ASSERT(view_ptr_);
return *view_ptr_;
}
void ControlButtons::setView(ViewBase & v)
{
view_ptr_ = &v;
}

View File

@ -1,92 +0,0 @@
// -*- C++ -*-
/**
* \file ControlButtons.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.
*
* ControlButtons serves only to control the activation of the Ok, Apply, Cancel
* and Restore buttons on the View dialog.
*
* More generally, the class is part of a hierarchy of controller classes
* that together connect the GUI-dependent dialog to any appropriate
* signals and dispatches any changes to the kernel.
*
* These controllers have no knowledge of the actual instantiation of the
* GUI-dependent View and ButtonController, which should therefore
* be created elsewhere.
*
* Once created, the Controller will take care of their initialisation,
* management and, ultimately, destruction.
*/
#ifndef CONTROLBUTTONS_H
#define CONTROLBUTTONS_H
#include <boost/utility.hpp>
#include <boost/scoped_ptr.hpp>
class ViewBase;
class ButtonController;
/** Abstract base class for Controllers with a ButtonController.
*/
class ControlButtons : boost::noncopyable {
public:
///
ControlButtons();
///
virtual ~ControlButtons();
/** These functions are called by the view when the appropriate buttons
* are pressed.
*/
///
void ApplyButton();
///
void OKButton();
///
void CancelButton();
///
void RestoreButton();
/// Returns the user-specified iconification policy.
bool IconifyWithMain() const;
///
ButtonController & bc();
///
void setView(ViewBase &);
/** When Applying it's useful to know whether the dialog is about
to close or not (no point refreshing the display for example). */
bool isClosing() const { return is_closing_; }
protected:
///
ViewBase & view();
/// Get changed parameters and Dispatch them to the kernel.
virtual void apply() = 0;
/// Disconnect signals and hide View.
virtual void hide() = 0;
/// Update dialog before showing it.
virtual void update() = 0;
/** This flag can be set by one of the miriad the controller methods
to ensure that the dialog is shut down. */
bool emergency_exit_;
private:
///
bool is_closing_;
///
boost::scoped_ptr<ButtonController> bc_ptr_;
/// We do not own this pointer.
ViewBase * view_ptr_;
};
#endif // CONTROLBUTTONS_H

View File

@ -1,150 +0,0 @@
/**
* \file ControlConnections.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 <config.h>
#include "ControlConnections.h"
#include "ViewBase.h"
#include "buffer.h"
#include "BufferView.h"
#include "frontends/Dialogs.h"
#include "frontends/LyXView.h"
#include <boost/bind.hpp>
ControlConnectBase::ControlConnectBase(LyXView & lv, Dialogs & d)
: lv_(lv), d_(d)
{}
void ControlConnectBase::connect()
{
r_ = d_.redrawGUI().
connect(boost::bind(&ControlConnectBase::redraw, this));
}
void ControlConnectBase::disconnect()
{
h_.disconnect();
r_.disconnect();
}
void ControlConnectBase::redraw()
{
view().redraw();
}
bool ControlConnectBase::bufferIsReadonly() const
{
if (!lv_.buffer())
return true;
return lv_.buffer()->isReadonly();
}
bool ControlConnectBase::bufferIsAvailable() const
{
if (!lv_.view())
return false;
return lv_.view()->available();
}
BufferView * ControlConnectBase::bufferview()
{
return lv_.view().get();
}
BufferView const * ControlConnectBase::bufferview() const
{
return lv_.view().get();
}
Buffer * ControlConnectBase::buffer()
{
return lv_.buffer();
}
Buffer const & ControlConnectBase::buffer() const
{
return *lv_.buffer();
}
LyXFunc & ControlConnectBase::lyxfunc()
{
return lv_.getLyXFunc();
}
LyXFunc const & ControlConnectBase::lyxfunc() const
{
return lv_.getLyXFunc();
}
ControlConnectBase::DocTypes ControlConnectBase::docType() const
{
if (!lv_.buffer())
return LATEX;
if (lv_.buffer()->isLatex())
return LATEX;
else if (lv_.buffer()->isLiterate())
return LITERATE;
else if (lv_.buffer()->isLinuxDoc())
return LINUXDOC;
/* else if (lv_.buffer()->isDocBook()) */
return DOCBOOK;
}
ControlConnectBI::ControlConnectBI(LyXView & lv, Dialogs & d)
: ControlConnectBase(lv, d)
{}
void ControlConnectBI::connect()
{
h_ = d_.hideAllSignal.connect(boost::bind(&ControlConnectBI::hide, this));
ControlConnectBase::connect();
}
ControlConnectBD::ControlConnectBD(LyXView & lv, Dialogs & d)
: ControlConnectBase(lv, d)
{}
void ControlConnectBD::connect()
{
u_ = d_.updateBufferDependentSignal.
connect(boost::bind(&ControlConnectBD::updateSlot, this, _1));
h_ = d_.hideBufferDependentSignal.
connect(boost::bind(&ControlConnectBD::hide, this));
ControlConnectBase::connect();
}
void ControlConnectBD::disconnect()
{
u_.disconnect();
ControlConnectBase::disconnect();
}

View File

@ -1,147 +0,0 @@
// -*- C++ -*-
/**
* \file ControlConnections.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.
*
* ControlConnections.h contains the definition of three controller classes,
* ControlConnectBase, ControlConnectBI and ControlConnectBD.
*
* Together they control the connection/disconnection of signals with the LyX
* kernel. Controllers of individual dialogs interacting with the kernel through
* signals/slots will all be derived from ControlConnectBI or ControlConnectBD.
*
* A dialog is classed as "Buffer Dependent" if its contents change with the
* buffer (document). An example would be the Citation dialog. Such a dialog
* would be derived, therefore, from ControlConnectBD.
*
* Conversely, a dialog is "Buffer Independent" if its contents do not change
* when the buffer changes. An example would be the Copyright dialog. Such a
* dialog is therefore derived from ControlConnectBI.
*
*/
#ifndef CONTROLCONNECTIONS_H
#define CONTROLCONNECTIONS_H
#include "ControlButtons.h"
#include <boost/signals/connection.hpp>
class Buffer;
class BufferView;
class Dialogs;
class LyXView;
class LyXFunc;
/** Base class to control connection/disconnection of signals with the LyX
kernel. It is meant to be used solely as the parent class to
ControlConnectBI and ControlConnectBD.
*/
class ControlConnectBase : public ControlButtons {
public:
///
enum DocTypes {
///
LATEX,
///
LITERATE,
///
LINUXDOC,
///
DOCBOOK
};
///
ControlConnectBase(LyXView &, Dialogs &);
/// The View may need to know if the buffer is read-only.
bool bufferIsReadonly() const;
///
DocTypes docType() const;
protected:
/// True if the dialog depends on the buffer, else false.
virtual bool isBufferDependent() const = 0;
/// Connect signals
virtual void connect();
/// Disconnect signals
virtual void disconnect();
/** Redraw the dialog (on receipt of a Signal indicating, for example,
its colors have been re-mapped).
*/
void redraw();
/// a wrapper for BufferView::avaliable()
bool bufferIsAvailable() const;
/// a wrapper for LyXView::view()
BufferView * bufferview();
///
BufferView const * bufferview() const;
/// a wrapper for LyXView::buffer()
Buffer * buffer();
///
Buffer const & buffer() const;
/// a wrapper for LyXView::getLyXFunc()
LyXFunc & lyxfunc();
///
LyXFunc const & lyxfunc() const;
///
LyXView & lv_;
/// Contains the signals we have to connect to.
Dialogs & d_;
/// Hide connection.
boost::signals::connection h_;
/// Redraw connection.
boost::signals::connection r_;
};
/** Base class to control connection/disconnection of signals with the LyX
kernel for Buffer Independent dialogs.
Such dialogs do not require an update Connection although they may use
an update() function which is also supported by the Restore button.
*/
class ControlConnectBI : public ControlConnectBase {
public:
///
ControlConnectBI(LyXView &, Dialogs &);
protected:
///
virtual bool isBufferDependent() const { return false; }
/// Connect signals
virtual void connect();
};
/** Base class to control connection/disconnection of signals with the LyX
kernel for Buffer Dependent dialogs.
*/
class ControlConnectBD : public ControlConnectBase {
public:
///
ControlConnectBD(LyXView &, Dialogs &);
protected:
///
virtual bool isBufferDependent() const { return true; }
/// Connect signals
virtual void connect();
/// Disconnect signals
virtual void disconnect();
private:
/** Slot connected to update signal.
Bool indicates if a buffer switch took place.
Default behaviour is to ignore this and simply update().
*/
virtual void updateSlot(bool) { update(); }
/// Update connection.
boost::signals::connection u_;
};
#endif // CONTROLCONNECTIONS_H

View File

@ -1,52 +0,0 @@
// -*- C++ -*-
/**
* \file ControlDialog.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.
*
* ControlDialog is to be used as a parent class for dialogs that are not
* views onto parameters of insets. (An ugly description I know, but I hope
* the meaning is clear! Can anyone do any better?) Examples would be the
* Document and Paragraph dialogs.
*/
#ifndef CONTROLDIALOG_H
#define CONTROLDIALOG_H
class LyXView;
class Dialogs;
/** Base class to control connection/disconnection of signals with the LyX
kernel for dialogs NOT used with insets.
The Base class will be either ControlConnectBI or ControlConnectBD.
*/
template <class Base>
class ControlDialog : public Base {
public:
///
ControlDialog(LyXView &, Dialogs &);
/** Show the dialog.
* Publicly accessible so that it can be invoked by the Dialogs class.
*/
virtual void show();
/// 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
virtual void setParams() {}
private:
/// is the dialog built ?
bool dialog_built_;
};
#endif // CONTROLDIALOG_H

View File

@ -1,82 +0,0 @@
// -*- C++ -*-
/**
* \file ControlDialog.tmpl
* 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
*
* ControlDialog is a base class and so these templatised methods will be
* instantiated if this file is #included in the derived classes' .C file.
*/
#include "ControlDialog.h"
#include "ButtonController.h"
#include "ViewBase.h"
template <class Base>
ControlDialog<Base>::ControlDialog(LyXView & lv, Dialogs & d)
: Base(lv, d), dialog_built_(false)
{}
template <class Base>
void ControlDialog<Base>::show()
{
if (this->isBufferDependent() && !this->bufferIsAvailable())
return;
this->connect();
if (!dialog_built_) {
this->view().build();
dialog_built_ = true;
}
setParams();
if (this->emergency_exit_) {
hide();
return;
}
this->bc().readOnly(this->bufferIsReadonly());
this->view().show();
// The widgets may not be valid, so refresh the button controller
this->bc().refresh();
}
template <class Base>
void ControlDialog<Base>::update()
{
if (this->isBufferDependent() && !this->bufferIsAvailable())
return;
setParams();
if (this->emergency_exit_) {
hide();
return;
}
this->bc().readOnly(this->bufferIsReadonly());
this->view().update();
// The widgets may not be valid, so refresh the button controller
this->bc().refresh();
}
template <class Base>
void ControlDialog<Base>::hide()
{
this->emergency_exit_ = false;
clearParams();
this->disconnect();
this->view().hide();
}

View File

@ -1,24 +0,0 @@
/**
* \file ControlDialog_impl.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 <config.h>
#include "ControlDialog_impl.h"
#include "ControlDialog.tmpl"
ControlDialogBD::ControlDialogBD(LyXView & lv, Dialogs & d)
: ControlDialog<ControlConnectBD>(lv, d)
{}
ControlDialogBI::ControlDialogBI(LyXView & lv, Dialogs & d)
: ControlDialog<ControlConnectBI>(lv, d)
{}

View File

@ -1,39 +0,0 @@
// -*- C++ -*-
/**
* \file ControlDialog_impl.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.
*
* Instatiate the two possible instantiations of the ControlDialog template
* class, thus reducing file dependencies enormously.
*/
#ifndef CONTROLDIALOG_IMPL_H
#define CONTROLDIALOG_IMPL_H
#include "ControlDialog.h"
#include "ControlConnections.h"
class Dialogs;
class LyXView;
class ControlDialogBD : public ControlDialog<ControlConnectBD> {
public:
///
ControlDialogBD(LyXView &, Dialogs &);
};
class ControlDialogBI : public ControlDialog<ControlConnectBI> {
public:
///
ControlDialogBI(LyXView &, Dialogs &);
};
#endif // CONTROLDIALOG_IMPL_H

View File

@ -1,52 +0,0 @@
// -*- C++ -*-
/**
* \file GUI.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.
*/
#ifndef GUI_H
#define GUI_H
#include <boost/utility.hpp>
class LyXView;
class Dialogs;
/** This class makes a whole out of the disparate parts of a dialog.
*/
template <typename Controller, typename GUIview,
typename Policy, typename GUIbc>
class GUI : boost::noncopyable {
public:
///
GUI(LyXView & lv, Dialogs & d);
///
Controller & controller() { return controller_; }
///
Controller const & controller() const { return controller_; }
private:
///
Controller controller_;
///
GUIview view_;
};
template <typename Controller, typename GUIview,
typename Policy, typename GUIbc>
GUI<Controller, GUIview, Policy, GUIbc>::GUI(LyXView & lv, Dialogs & d)
: controller_(lv, d),
view_()
{
controller_.setView(view_);
view_.setController(controller_);
controller_.bc().view(new GUIbc(controller_.bc()));
controller_.bc().bp(new Policy);
}
#endif // GUI_H

View File

@ -1,6 +1,6 @@
include $(top_srcdir)/config/common.am
EXTRA_DIST = BCView.tmpl ControlDialog.tmpl
EXTRA_DIST = BCView.tmpl
INCLUDES = -I$(top_srcdir)/src $(BOOST_INCLUDES)
@ -29,8 +29,6 @@ libcontrollers_la_SOURCES= \
ControlAboutlyx.h \
ControlBibtex.C \
ControlBibtex.h \
ControlButtons.C \
ControlButtons.h \
ControlBox.C \
ControlBox.h \
ControlBranch.C \
@ -45,11 +43,6 @@ libcontrollers_la_SOURCES= \
ControlCommand.h \
ControlCommandBuffer.C \
ControlCommandBuffer.h \
ControlConnections.C \
ControlConnections.h \
ControlDialog.h \
ControlDialog_impl.C \
ControlDialog_impl.h \
ControlDocument.C \
ControlDocument.h \
ControlErrorList.C \
@ -102,8 +95,5 @@ libcontrollers_la_SOURCES= \
ControlVSpace.h \
ControlWrap.C \
ControlWrap.h \
GUI.h \
ViewBase.h \
ViewBase.C \
helper_funcs.C \
helper_funcs.h

View File

@ -1,60 +0,0 @@
/**
* \file ViewBase.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 <config.h>
#include "ViewBase.h"
#include "ControlButtons.h"
using std::string;
ViewBase::ViewBase(string const & t)
: controller_ptr_(0), title_(t)
{}
void ViewBase::setController(ControlButtons & c)
{
controller_ptr_ = &c;
}
void ViewBase::setTitle(string const & newtitle)
{
title_ = newtitle;
}
string const & ViewBase::getTitle() const
{
return title_;
}
ControlButtons & ViewBase::getController()
{
BOOST_ASSERT(controller_ptr_);
return *controller_ptr_;
}
ControlButtons const & ViewBase::getController() const
{
BOOST_ASSERT(controller_ptr_);
return *controller_ptr_;
}
ButtonController & ViewBase::bc()
{
return getController().bc();
}

View File

@ -1,75 +0,0 @@
// -*- C++ -*-
/**
* \file ViewBase.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.
*/
#ifndef VIEWBASE_H
#define VIEWBASE_H
class ControlButtons;
class ButtonController;
#include <boost/utility.hpp>
#include <string>
class ViewBase : boost::noncopyable {
public:
///
ViewBase(std::string const &);
///
virtual ~ViewBase() {}
/// Apply changes to LyX data from dialog.
virtual void apply() = 0;
/// build the dialog
virtual void build() = 0;
/// Hide the dialog.
virtual void hide() = 0;
/// Redraw the dialog (e.g. if the colors have been remapped).
virtual void redraw() {}
/// Create the dialog if necessary, update it and display it.
virtual void show() = 0;
/// Update dialog before/whilst showing it.
virtual void update() = 0;
///
virtual bool isVisible() const = 0;
/** Defaults to nothing. Can be used by the controller, however, to
* indicate to the view that something has changed and that the
* dialog therefore needs updating.
*/
virtual void partialUpdate(int) {}
/** This should be set by the GUI class that owns both the controller
* and the view
*/
void setController(ControlButtons &);
///
ControlButtons & getController();
///
ControlButtons const & getController() const;
///
ButtonController & bc();
/// sets the title of the dialog (window caption)
void setTitle(std::string const &);
/// gets the title of the dialog
std::string const & getTitle() const;
protected:
/// We don't own this.
ControlButtons * controller_ptr_;
private:
std::string title_;
};
#endif // VIEWBASE_H

View File

@ -1,3 +1,9 @@
2004-03-31 Angus Leeming <leeming@lyx.org>
* GViewBase.C: remove mention of ControlButtons.h.
* Makefile.am: remove mention of xforms' Dialogs2.lo, FormBase.lo.
2004-03-31 Angus Leeming <leeming@lyx.org>
* Dialogs.C (build): added preamble dialog.

View File

@ -12,7 +12,6 @@
#include <gtkmm.h>
#include "GViewBase.h"
#include "ControlButtons.h"
#include "support/filetools.h"
using std::string;

View File

@ -77,9 +77,7 @@ xforms_objects = \
../xforms/ColorHandler.lo \
../xforms/Color.lo \
../xforms/combox.lo \
../xforms/Dialogs2.lo \
../xforms/fdesign_base.lo \
../xforms/FormBase.lo \
../xforms/FormBibitem.lo \
../xforms/FormBibtex.lo \
../xforms/FormBox.lo \

View File

@ -1,3 +1,11 @@
2004-03-31 Angus Leeming <leeming@lyx.org>
* Dialogs2.C:
* Qt2Base.[Ch]: removed.
* Makefile.am:
* Makefile.dialogs: adjusted to suit.
2004-03-31 Angus Leeming <leeming@lyx.org>
* Dialogs.C (build): added "preamble" as a symonym for "document".

View File

@ -1,31 +0,0 @@
/**
* \file qt2/Dialogs2.C
* Copyright 1995 Matthias Ettrich
* This file is part of LyX, the document processor.
* Licence details can be found in the file COPYING.
*
* \author Allan Rae
* \author Angus Leeming
*
* Full author contact details are available in file CREDITS.
*/
#include <config.h>
#include "Dialogs.h"
struct Dialogs::Impl {
Impl(LyXView &, Dialogs &) {}
};
void Dialogs::init_pimpl()
{
pimpl_ = new Impl(lyxview_, *this);
}
Dialogs::~Dialogs()
{
delete pimpl_;
}

View File

@ -21,7 +21,6 @@ libqt2_la_SOURCES = \
QDialogView.h \
Alert_pimpl.C \
Dialogs.C \
Dialogs2.C \
FileDialog.C \
LyXKeySymFactory.C \
LyXScreenFactory.C \

View File

@ -113,7 +113,6 @@ MOCFILES = \
qsetborder.C qsetborder.h \
QShowFileDialog.C QShowFileDialog.h \
QSpellcheckerDialog.C QSpellcheckerDialog.h \
Qt2Base.C Qt2Base.h \
QDialogView.C QDialogView.h \
QTabularCreateDialog.C QTabularCreateDialog.h \
QTabularDialog.C QTabularDialog.h \

View File

@ -1,109 +0,0 @@
/**
* \file Qt2Base.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 <config.h>
#include "debug.h"
#include "qt_helpers.h"
#include "Qt2Base.h"
#include "Qt2BC.h"
#include "ButtonController.h"
#include "ControlButtons.h"
using std::string;
Qt2Base::Qt2Base(string const & t)
: ViewBase(t), updating_(false)
{}
Qt2BC & Qt2Base::bcview()
{
return static_cast<Qt2BC &>(bc().view());
// return dynamic_cast<Qt2BC &>(bc());
}
bool Qt2Base::isVisible() const
{
return form() && form()->isVisible();
}
void Qt2Base::show()
{
if (!form()) {
build();
}
form()->setMinimumSize(form()->sizeHint());
update(); // make sure its up-to-date
form()->setCaption(toqstr(getTitle()));
if (form()->isVisible()) {
form()->raise();
} else {
form()->show();
}
}
void Qt2Base::hide()
{
if (form() && form()->isVisible())
form()->hide();
}
bool Qt2Base::isValid()
{
return true;
}
void Qt2Base::changed()
{
if (updating_)
return;
bc().valid(isValid());
}
void Qt2Base::slotWMHide()
{
getController().CancelButton();
}
void Qt2Base::slotApply()
{
getController().ApplyButton();
}
void Qt2Base::slotOK()
{
getController().OKButton();
}
void Qt2Base::slotClose()
{
getController().CancelButton();
}
void Qt2Base::slotRestore()
{
getController().RestoreButton();
}

View File

@ -1,181 +0,0 @@
// -*- C++ -*-
/**
* \file Qt2Base.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.
*/
#ifndef QT2BASE_H
#define QT2BASE_H
#include "ViewBase.h"
#include <boost/scoped_ptr.hpp>
#include <qapplication.h>
#include <qdialog.h>
#include <qobject.h>
class Qt2BC;
/** This class is an Qt2 GUI base class.
*/
class Qt2Base : public QObject, public ViewBase {
Q_OBJECT
public:
///
Qt2Base(std::string const &);
///
virtual ~Qt2Base() {}
protected:
/// build the actual dialog
virtual void build_dialog() = 0;
/// Hide the dialog.
virtual void hide();
/// Create the dialog if necessary, update it and display it.
virtual void show();
/// update the dialog's contents
virtual void update_contents() = 0;
///
virtual bool isVisible() const;
/// the dialog has changed contents
virtual void changed();
/// is the dialog currently valid ?
virtual bool isValid();
///
Qt2BC & bcview();
/// are we updating ?
bool updating_;
protected slots:
// dialog closed from WM
void slotWMHide();
// Restore button clicked
void slotRestore();
// OK button clicked
void slotOK();
// Apply button clicked
void slotApply();
// Close button clicked
void slotClose();
private:
/// Pointer to the actual instantiation of the Qt dialog
virtual QDialog * form() const = 0;
};
template <class Dialog>
class Qt2DB: public Qt2Base {
protected:
Qt2DB(std::string const &);
/// update the dialog
virtual void update();
/// Build the dialog
virtual void build();
/// Pointer to the actual instantiation of the Qt dialog
virtual QDialog * form() const;
/// Real GUI implementation.
boost::scoped_ptr<Dialog> dialog_;
};
template <class Dialog>
Qt2DB<Dialog>::Qt2DB(std::string const & t)
: Qt2Base(t)
{}
template <class Dialog>
QDialog * Qt2DB<Dialog>::form() const
{
return dialog_.get();
}
template <class Dialog>
void Qt2DB<Dialog>::update()
{
form()->setUpdatesEnabled(false);
// protect the BC from unwarranted state transitions
qApp->processEvents();
updating_ = true;
update_contents();
qApp->processEvents();
updating_ = false;
form()->setUpdatesEnabled(true);
form()->update();
}
template <class Dialog>
void Qt2DB<Dialog>::build()
{
// protect the BC from unwarranted state transitions
qApp->processEvents();
updating_ = true;
build_dialog();
qApp->processEvents();
updating_ = false;
}
template <class Controller, class Base>
class Qt2CB: public Base
{
public:
bool readOnly() const {
return controller().bufferIsReadonly();
}
/// The parent controller
Controller & controller();
/// The parent controller
Controller const & controller() const;
protected:
///
Qt2CB(std::string const &);
};
template <class Controller, class Base>
Qt2CB<Controller, Base>::Qt2CB(std::string const & t)
: Base(t)
{}
template <class Controller, class Base>
Controller & Qt2CB<Controller, Base>::controller()
{
return static_cast<Controller &>(this->getController());
}
template <class Controller, class Base>
Controller const & Qt2CB<Controller, Base>::controller() const
{
return static_cast<Controller const &>(this->getController());
}
#endif // FORMBASE_H

View File

@ -1,3 +1,10 @@
2004-03-31 Angus Leeming <leeming@lyx.org>
* Dialogs2.C:
* FormBase.[Ch]: removed.
* Makefile.am: adjusted to suit.
2004-03-31 Angus Leeming <leeming@lyx.org>
* forms/form_search.fd: s/C_FormBase/C_FormDialogView_/ and thereby

View File

@ -1,30 +0,0 @@
/**
* \file xforms/Dialogs2.C
* This file is part of LyX, the document processor.
* Licence details can be found in the file COPYING.
*
* \author Allan Rae
* \author Angus Leeming
*
* Full author contact details are available in file CREDITS.
*/
#include <config.h>
#include "Dialogs.h"
struct Dialogs::Impl {
Impl(LyXView &, Dialogs &) {}
};
void Dialogs::init_pimpl()
{
pimpl_ = new Impl(lyxview_, *this);
}
Dialogs::~Dialogs()
{
delete pimpl_;
}

View File

@ -1,411 +0,0 @@
/**
* \file FormBase.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 <config.h>
#include "FormBase.h"
#include "Tooltips.h"
#include "xforms_helpers.h" // formatted
#include "xforms_resize.h"
#include "xformsBC.h"
#include "controllers/ButtonController.h"
#include "controllers/ControlButtons.h"
#include "support/filetools.h" // LibFileSearch
#include "support/lstrings.h"
#include "lyx_forms.h"
using lyx::support::bformat;
using lyx::support::LibFileSearch;
using std::string;
extern "C" {
#if FL_VERSION == 0 || (FL_REVISION == 0 && FL_FIXLEVEL == 0)
// 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.
static int C_WMHideCB(FL_FORM * form, void *);
// 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(t),
warning_posted_(false), message_widget_(0),
minw_(0), minh_(0), allow_resize_(allowResize),
icon_pixmap_(0), icon_mask_(0),
tooltips_(new Tooltips)
{}
FormBase::~FormBase()
{
if (icon_pixmap_)
XFreePixmap(fl_get_display(), icon_pixmap_);
delete tooltips_;
}
bool FormBase::isVisible() const
{
return form() && form()->visible;
}
Tooltips & FormBase::tooltips()
{
return *tooltips_;
}
void FormBase::redraw()
{
if (form() && form()->visible)
fl_redraw_form(form());
}
xformsBC & FormBase::bcview()
{
return static_cast<xformsBC &>(bc().view());
}
void FormBase::prepare_to_show()
{
double const scale = get_scale_to_fit(form());
if (scale > 1.001)
scale_form_horizontally(form(), scale);
// 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 (!getController().IconifyWithMain())
fl_winicontitle(form()->window, getTitle().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 FormBase::show()
{
// build() is/should be called from the controller, so form() should
// always exist.
BOOST_ASSERT(form());
// we use minw_ to flag whether the dialog has ever been shown.
// In turn, prepare_to_show() initialises various bits 'n' pieces
// (including minw_).
if (minw_ == 0) {
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 {
// 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: " + getTitle();
int const iconify_policy =
getController().IconifyWithMain() ? FL_TRANSIENT : 0;
fl_show_form(form(),
FL_PLACE_MOUSE | FL_FREE_SIZE,
iconify_policy,
maximize_title.c_str());
}
}
void FormBase::hide()
{
// 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)
fl_hide_form(form());
}
void FormBase::setPrehandler(FL_OBJECT * ob)
{
BOOST_ASSERT(ob);
fl_set_object_prehandler(ob, C_PrehandlerCB);
}
void FormBase::setMessageWidget(FL_OBJECT * ob)
{
BOOST_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
// 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().input(input(ob, data));
}
ButtonPolicy::SMInput FormBase::input(FL_OBJECT *, long)
{
return ButtonPolicy::SMI_VALID;
}
// preemptive handler for feedback messages
void FormBase::MessageCB(FL_OBJECT * ob, int event)
{
BOOST_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)
{
BOOST_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 (message_widget_) {
switch (event) {
case FL_ENTER:
case FL_LEAVE:
// Post feedback as the mouse enters the object,
// remove it as the mouse leaves.
MessageCB(ob, event);
break;
}
}
#if FL_VERSION == 0 || (FL_REVISION == 0 && FL_FIXLEVEL == 0)
// Tooltips are not displayed on browser widgets due to an xforms' bug.
// This is a work-around:
if (ob->objclass == FL_BROWSER) {
switch (event) {
case FL_ENTER:
if (ob->tooltip && *(ob->tooltip)) {
int const x = ob->form->x + ob->x;
int const y = ob->form->y + ob->y + ob->h + 1;
fl_show_tooltip(ob->tooltip, x, y);
}
break;
case FL_LEAVE:
case FL_PUSH:
case FL_KEYPRESS:
fl_hide_tooltip();
break;
}
}
#endif
}
void FormBase::postWarning(string const & warning)
{
warning_posted_ = true;
postMessage(warning);
}
void FormBase::clearMessage()
{
BOOST_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)
{
BOOST_ASSERT(message_widget_);
int const width = message_widget_->w - 10;
string const tmp = warning_posted_ ?
bformat(_("WARNING! %1$s"), message) :
message;
string const str = formatted(tmp, width, FL_NORMAL_SIZE);
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)
{
BOOST_ASSERT(ob && ob->form && ob->form->u_vdata);
FormBase * ptr = static_cast<FormBase *>(ob->form->u_vdata);
return ptr;
}
} // namespace anon
extern "C" {
void C_FormBaseApplyCB(FL_OBJECT * ob, long)
{
GetForm(ob)->getController().ApplyButton();
}
void C_FormBaseOKCB(FL_OBJECT * ob, long)
{
GetForm(ob)->getController().OKButton();
}
void C_FormBaseCancelCB(FL_OBJECT * ob, long)
{
FormBase * form = GetForm(ob);
form->getController().CancelButton();
}
void C_FormBaseRestoreCB(FL_OBJECT * ob, long)
{
GetForm(ob)->getController().RestoreButton();
}
void C_FormBaseInputCB(FL_OBJECT * ob, long d)
{
GetForm(ob)->InputCB(ob, d);
}
static int C_WMHideCB(FL_FORM * form, void *)
{
// Close the dialog cleanly, even if the WM is used to do so.
BOOST_ASSERT(form && form->u_vdata);
FormBase * ptr = static_cast<FormBase *>(form->u_vdata);
ptr->getController().CancelButton();
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.
BOOST_ASSERT(ob);
// Don't Assert this one, as it can happen quite naturally when things
// are being deleted in the d-tor.
//BOOST_ASSERT(ob->form);
if (!ob->form) return 0;
FormBase * ptr = static_cast<FormBase *>(ob->form->u_vdata);
if (ptr)
ptr->PrehandlerCB(ob, event, key);
return 0;
}
} // extern "C"

View File

@ -1,196 +0,0 @@
// -*- C++ -*-
/**
* \file FormBase.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 the MCV-ed xforms dialogs.
*/
#ifndef FORMBASE_H
#define FORMBASE_H
#include "ViewBase.h"
#include "ButtonPolicies.h"
#include "forms_fwd.h"
#include <boost/scoped_ptr.hpp>
#include <X11/Xlib.h> // for Pixmap
class xformsBC;
class Tooltips;
/** This class is an XForms GUI base class.
*/
class FormBase : public ViewBase
{
public:
///
FormBase(std::string const &, bool allowResize);
///
virtual ~FormBase();
/** 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:
/// Build the dialog
virtual void build() = 0;
/// Hide the dialog.
virtual void hide();
/// Create the dialog if necessary, update it and display it.
virtual void show();
///
virtual bool isVisible() const;
/** 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);
/** 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(std::string const & warning);
/// Reset the message_widget_
void clearMessage();
///
xformsBC & bcview();
private:
/// Pointer to the actual instantiation of xform's form
virtual FL_FORM * form() const = 0;
/// Filter the inputs on callback from xforms
virtual ButtonPolicy::SMInput input(FL_OBJECT *, long);
/** Redraw the form (on receipt of a Signal indicating, for example,
* that the xform colors have been re-mapped).
*/
virtual void redraw();
/** Called on the first show() request, initialising various bits and
* pieces.
*/
void prepare_to_show();
/** Get the feedback message for ob.
Called if warning_posted_ == false. */
virtual std::string const getFeedback(FL_OBJECT * /* ob */)
{ return std::string(); }
/// Post the feedback message for ob to message_widget_
void postMessage(std::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_;
///
int minh_;
/// Can the dialog be resized after it has been created?
bool allow_resize_;
/// Passed to the window manager to give a pretty little symbol ;-)
Pixmap icon_pixmap_;
///
Pixmap icon_mask_;
///
Tooltips * tooltips_;
};
template <class Dialog>
class FormDB: public FormBase
{
protected:
///
FormDB(std::string const &, bool allowResize=true);
/// Pointer to the actual instantiation of xform's form
virtual FL_FORM * form() const;
/// Real GUI implementation.
boost::scoped_ptr<Dialog> dialog_;
};
template <class Dialog>
FormDB<Dialog>::FormDB(std::string const & t, bool allowResize)
: FormBase(t, allowResize)
{}
template <class Dialog>
FL_FORM * FormDB<Dialog>::form() const
{
return dialog_.get() ? dialog_->form : 0;
}
template <class Controller, class Base>
class FormCB: public Base
{
public:
/// The parent controller
Controller & controller();
///
Controller const & controller() const;
protected:
///
FormCB(std::string const &, bool allowResize = true);
};
template <class Controller, class Base>
FormCB<Controller, Base>::FormCB(std::string const & t, bool allowResize)
: Base(t, allowResize)
{}
template <class Controller, class Base>
Controller & FormCB<Controller, Base>::controller()
{
return static_cast<Controller &>(this->getController());
}
template <class Controller, class Base>
Controller const & FormCB<Controller, Base>::controller() const
{
return static_cast<Controller const &>(this->getController());
}
#endif // FORMBASE_H

View File

@ -56,7 +56,6 @@ libxforms_la_SOURCES = \
ColorHandler.C \
ColorHandler.h \
Dialogs.C \
Dialogs2.C \
FileDialog.C \
FontInfo.C \
FontInfo.h \
@ -64,8 +63,6 @@ libxforms_la_SOURCES = \
FormFiledialog.C \
FormAboutlyx.C \
FormAboutlyx.h \
FormBase.C \
FormBase.h \
FormDialogView.C \
FormDialogView.h \
FormBibitem.C \