Pass and store references to LyXView and Dialogs, not pointers in the

FormBaseDeprecated-derived classes.


git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@5000 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
Angus Leeming 2002-08-15 16:34:48 +00:00
parent 555abe1948
commit 5fab05e48a
14 changed files with 87 additions and 144 deletions

View File

@ -40,7 +40,6 @@ libfrontends_la_SOURCES = \
WorkAreaFactory.h \
font_metrics.h \
guiapi.h \
guiapi.C \
key_state.h \
lyx_gui.h \
mouse_state.h \

View File

@ -2,6 +2,8 @@
* lots: changed my email address to leeming@lyx.org.
* GUI.h: return it to private derivation from boost::noncopyable.
2002-08-14 Angus Leeming <leeming@lyx.org>
* GUI.h: public derivation from boost::noncopyable.

View File

@ -4,7 +4,7 @@
* Copyright 2001 The LyX Team.
* See the file COPYING.
*
* \author Angus Leeming <a.leeming@ic.ac.uk>
* \author Angus Leeming <leeming@lyx.org>
*/
#ifndef GUI_H
@ -18,7 +18,7 @@
*/
template <typename Controller, typename GUIview,
typename Policy, typename GUIbc>
class GUI : public boost::noncopyable {
class GUI : boost::noncopyable {
public:
///
GUI(LyXView & lv, Dialogs & d);

0
src/frontends/guiapi.C Normal file
View File

View File

@ -2,6 +2,19 @@
* lots: changed my email address to leeming@lyx.org.
* FormBaseDeprecated.[Ch]: return it to private derivation from
boost::noncopyable.
* FormBaseDeprecated.[Ch]:
* FormDocument.[Ch]:
* FormInset.[Ch]:
* FormMaths*.[Ch]:
* FormPreferences.[Ch]:
* FormTabular.[Ch]:
pass and store references to LyXView and Dialogs, not pointers.
* FormInset.[Ch]: remove class FormCommand.
2002-08-14 Angus Leeming <leeming@lyx.org>
* FormBaseDeprecated.h: public derivation from boost::noncopyable.

View File

@ -3,7 +3,7 @@
* Copyright 2000-2001 The LyX Team.
* See the file COPYING.
*
* \author Angus Leeming, a.leeming@ic.ac.uk
* \author Angus Leeming <leeming@lyx.org>
*/
#include <config.h>
@ -39,14 +39,12 @@ static int C_PrehandlerCB(FL_OBJECT *, int, FL_Coord, FL_Coord, int, void *);
} // extern "C"
FormBaseDeprecated::FormBaseDeprecated(LyXView * lv, Dialogs * d,
FormBaseDeprecated::FormBaseDeprecated(LyXView & lv, Dialogs & d,
string const & t, bool allowResize)
: lv_(lv), d_(d), title_(t),
minw_(0), minh_(0), allow_resize_(allowResize),
tooltips_(new Tooltips())
{
lyx::Assert(lv && d);
}
{}
FormBaseDeprecated::~FormBaseDeprecated()
@ -71,7 +69,7 @@ void FormBaseDeprecated::redraw()
void FormBaseDeprecated::connect()
{
fl_set_form_minsize(form(), minw_, minh_);
r_ = d_->redrawGUI.connect(boost::bind(&FormBaseDeprecated::redraw, this));
r_ = d_.redrawGUI.connect(boost::bind(&FormBaseDeprecated::redraw, this));
}
@ -205,7 +203,7 @@ void FormBaseDeprecated::RestoreCB()
}
FormBaseBI::FormBaseBI(LyXView * lv, Dialogs * d, string const & t,
FormBaseBI::FormBaseBI(LyXView & lv, Dialogs & d, string const & t,
bool allowResize)
: FormBaseDeprecated(lv, d, t, allowResize)
{}
@ -213,12 +211,12 @@ FormBaseBI::FormBaseBI(LyXView * lv, Dialogs * d, string const & t,
void FormBaseBI::connect()
{
h_ = d_->hideAll.connect(boost::bind(&FormBaseBI::hide, this));
h_ = d_.hideAll.connect(boost::bind(&FormBaseBI::hide, this));
FormBaseDeprecated::connect();
}
FormBaseBD::FormBaseBD(LyXView * lv, Dialogs * d, string const & t,
FormBaseBD::FormBaseBD(LyXView & lv, Dialogs & d, string const & t,
bool allowResize)
: FormBaseDeprecated(lv, d, t, allowResize)
{}
@ -226,9 +224,9 @@ FormBaseBD::FormBaseBD(LyXView * lv, Dialogs * d, string const & t,
void FormBaseBD::connect()
{
u_ = d_->updateBufferDependent.
u_ = d_.updateBufferDependent.
connect(boost::bind(&FormBaseBD::updateSlot, this, _1));
h_ = d_->hideBufferDependent.
h_ = d_.hideBufferDependent.
connect(boost::bind(&FormBaseBD::hide, this));
FormBaseDeprecated::connect();
}

View File

@ -4,7 +4,7 @@
* Copyright 2000-2002 the LyX Team
* Read the file COPYING
*
* \author Angus Leeming, a.leeming@ic.ac.uk
* \author Angus Leeming <leeming@lyx.org>
*/
/* A base class for those remaining xforms dialogs that haven't yet undergone
@ -34,11 +34,11 @@ class Dialogs;
class LyXView;
class Tooltips;
class FormBaseDeprecated : public boost::noncopyable, public FeedbackController
class FormBaseDeprecated : boost::noncopyable, public FeedbackController
{
public:
///
FormBaseDeprecated(LyXView *, Dialogs *, string const &, bool);
FormBaseDeprecated(LyXView &, Dialogs &, string const &, bool);
///
virtual ~FormBaseDeprecated();
@ -118,9 +118,9 @@ protected: // methods
* We could modify Dialogs to have a visible LyXFunc* instead and
* save a couple of bytes per dialog.
*/
LyXView * lv_;
LyXView & lv_;
/// Used so we can get at the signals we have to connect to.
Dialogs * d_;
Dialogs & d_;
/// Hide connection.
boost::signals::connection h_;
/// Redraw connection.
@ -147,7 +147,7 @@ private:
class FormBaseBI : public FormBaseDeprecated {
protected:
/// Constructor
FormBaseBI(LyXView *, Dialogs *, string const &,
FormBaseBI(LyXView &, Dialogs &, string const &,
bool allowResize = true);
/// Connect signals
@ -160,7 +160,7 @@ protected:
class FormBaseBD : public FormBaseDeprecated {
protected:
/// Constructor
FormBaseBD(LyXView *, Dialogs *, string const &,
FormBaseBD(LyXView &, Dialogs &, string const &,
bool allowResize = true);
/// Connect signals

View File

@ -56,7 +56,7 @@ using std::bind2nd;
using Liason::setMinibuffer;
using std::vector;
FormDocument::FormDocument(LyXView * lv, Dialogs * d)
FormDocument::FormDocument(LyXView & lv, Dialogs & d)
: FormBaseBD(lv, d, _("Document Layout")),
ActCell(0), Confirmed(0),
current_bullet_panel(0), current_bullet_depth(0), fbullet(0)
@ -341,7 +341,7 @@ void FormDocument::build()
void FormDocument::apply()
{
if (!lv_->view()->available() || !dialog_.get())
if (!lv_.view()->available() || !dialog_.get())
return;
bool redo = class_apply();
@ -351,17 +351,17 @@ void FormDocument::apply()
bullets_apply();
if (redo) {
lv_->view()->redoCurrentBuffer();
lv_.view()->redoCurrentBuffer();
}
lv_->buffer()->markDirty();
setMinibuffer(lv_, _("Document layout set"));
lv_.buffer()->markDirty();
setMinibuffer(&lv_, _("Document layout set"));
}
void FormDocument::cancel()
{
// this avoids confusion when reopening
BufferParams & param = lv_->buffer()->params;
BufferParams & param = lv_.buffer()->params;
param.temp_bullets[0] = param.user_defined_bullets[0];
param.temp_bullets[1] = param.user_defined_bullets[1];
param.temp_bullets[2] = param.user_defined_bullets[2];
@ -377,7 +377,7 @@ void FormDocument::update()
checkReadOnly();
BufferParams const & params = lv_->buffer()->params;
BufferParams const & params = lv_.buffer()->params;
class_update(params);
paper_update(params);
@ -481,12 +481,12 @@ bool FormDocument::input(FL_OBJECT * ob, long)
language_apply(params);
options_apply(params);
bullets_apply(params);
params.preamble = lv_->buffer()->params.preamble;
params.preamble = lv_.buffer()->params.preamble;
saveParamsAsDefault(params);
}
if (ob == dialog_->button_reset_defaults) {
BufferParams params = lv_->buffer()->params;
BufferParams params = lv_.buffer()->params;
params.textclass = combo_doc_class->get() - 1;
params.useClassDefaults();
UpdateLayoutDocument(params);
@ -735,7 +735,7 @@ bool FormDocument::class_apply(BufferParams &params)
bool FormDocument::class_apply()
{
BufferParams &params = lv_->buffer()->params;
BufferParams &params = lv_.buffer()->params;
unsigned int const old_class = params.textclass;
@ -746,11 +746,11 @@ bool FormDocument::class_apply()
if (textclasslist[params.textclass].load()) {
// successfully loaded
redo = true;
setMinibuffer(lv_, _("Converting document to new document class..."));
setMinibuffer(&lv_, _("Converting document to new document class..."));
int ret = CutAndPaste::SwitchLayoutsBetweenClasses(
old_class, params.textclass,
&*(lv_->buffer()->paragraphs.begin()),
lv_->buffer()->params);
&*(lv_.buffer()->paragraphs.begin()),
lv_.buffer()->params);
if (ret) {
string s;
if (ret == 1) {
@ -833,7 +833,7 @@ void FormDocument::paper_apply(BufferParams & params)
void FormDocument::paper_apply()
{
paper_apply(lv_->buffer()->params);
paper_apply(lv_.buffer()->params);
}
@ -876,8 +876,8 @@ bool FormDocument::language_apply(BufferParams & params)
if (old_language != new_language
&& old_language->RightToLeft() == new_language->RightToLeft()
&& !lv_->buffer()->isMultiLingual())
lv_->buffer()->changeLanguage(old_language, new_language);
&& !lv_.buffer()->isMultiLingual())
lv_.buffer()->changeLanguage(old_language, new_language);
if (old_language != new_language) {
redo = true;
@ -892,7 +892,7 @@ bool FormDocument::language_apply(BufferParams & params)
bool FormDocument::language_apply()
{
return language_apply(lv_->buffer()->params);
return language_apply(lv_.buffer()->params);
}
@ -923,14 +923,14 @@ bool FormDocument::options_apply(BufferParams & params)
bool FormDocument::options_apply()
{
return options_apply(lv_->buffer()->params);
return options_apply(lv_.buffer()->params);
}
void FormDocument::bullets_apply(BufferParams & params)
{
/* update the bullet settings */
BufferParams & buf_params = lv_->buffer()->params;
BufferParams & buf_params = lv_.buffer()->params;
// a little bit of loop unrolling
params.user_defined_bullets[0] = buf_params.temp_bullets[0];
@ -942,7 +942,7 @@ void FormDocument::bullets_apply(BufferParams & params)
void FormDocument::bullets_apply()
{
bullets_apply(lv_->buffer()->params);
bullets_apply(lv_.buffer()->params);
}
void FormDocument::UpdateClassParams(BufferParams const & params)
@ -1203,7 +1203,7 @@ void FormDocument::bullets_update(BufferParams const & params)
(XpmVersion==4 && XpmRevision<7)))
return;
bool const isLinuxDoc = lv_->buffer()->isLinuxDoc();
bool const isLinuxDoc = lv_.buffer()->isLinuxDoc();
setEnabled(fbullet, !isLinuxDoc);
if (isLinuxDoc) return;
@ -1218,7 +1218,7 @@ void FormDocument::bullets_update(BufferParams const & params)
void FormDocument::checkReadOnly()
{
if (bc().readOnly(lv_->buffer()->isReadonly())) {
if (bc().readOnly(lv_.buffer()->isReadonly())) {
combo_doc_class->deactivate();
combo_language->deactivate();
postWarning(_("Document is read-only."
@ -1300,7 +1300,7 @@ bool FormDocument::CheckDocumentInput(FL_OBJECT * ob, long)
void FormDocument::ChoiceBulletSize(FL_OBJECT * ob, long /*data*/)
{
BufferParams & param = lv_->buffer()->params;
BufferParams & param = lv_.buffer()->params;
// convert from 1-6 range to -1-4
param.temp_bullets[current_bullet_depth].setSize(fl_get_choice(ob) - 2);
@ -1311,7 +1311,7 @@ void FormDocument::ChoiceBulletSize(FL_OBJECT * ob, long /*data*/)
void FormDocument::InputBulletLaTeX(FL_OBJECT *, long)
{
BufferParams & param = lv_->buffer()->params;
BufferParams & param = lv_.buffer()->params;
param.temp_bullets[current_bullet_depth].
setText(fl_get_input(bullets_->input_bullet_latex));
@ -1328,7 +1328,7 @@ void FormDocument::BulletDepth(FL_OBJECT * ob)
/* */
/* I'm inclined to just go with 3 and 4 at the moment and */
/* maybe try to support the others later */
BufferParams & param = lv_->buffer()->params;
BufferParams & param = lv_.buffer()->params;
int data = 0;
if (ob == bullets_->radio_bullet_depth_1)
@ -1413,7 +1413,7 @@ void FormDocument::BulletBMTable(FL_OBJECT * ob, long /*data*/)
/* to that extracted from the current chosen position of the BMTable */
/* Don't forget to free the button's old pixmap first. */
BufferParams & param = lv_->buffer()->params;
BufferParams & param = lv_.buffer()->params;
int bmtable_button = fl_get_bmtable(ob);
/* try to keep the button held down till another is pushed */
@ -1430,13 +1430,13 @@ void FormDocument::CheckChoiceClass(FL_OBJECT * ob, long)
if (!ob)
ob = class_->choice_doc_class;
lv_->prohibitInput();
lv_.prohibitInput();
unsigned int tc = combo_doc_class->get() - 1;
if (textclasslist[tc].load()) {
// we use a copy of the bufferparams because we do not
// want to modify them yet.
BufferParams params = lv_->buffer()->params;
BufferParams params = lv_.buffer()->params;
if (lyxrc.auto_reset_options) {
params.textclass = tc;
@ -1454,9 +1454,9 @@ void FormDocument::CheckChoiceClass(FL_OBJECT * ob, long)
Alert::alert(_("Conversion Errors!"),
_("Unable to switch to new document class."),
_("Reverting to original document class."));
combo_doc_class->select(int(lv_->buffer()->params.textclass) + 1);
combo_doc_class->select(int(lv_.buffer()->params.textclass) + 1);
}
lv_->allowInput();
lv_.allowInput();
}

View File

@ -35,7 +35,7 @@ struct FD_document_bullet;
*/
class FormDocument : public FormBaseBD {
public:
FormDocument(LyXView *, Dialogs *);
FormDocument(LyXView &, Dialogs &);
///
static void ComboInputCB(int, void *, Combox *);
private:

View File

@ -3,7 +3,7 @@
* Copyright 2000-2001 The LyX Team.
* See the file COPYING.
*
* \author Angus Leeming, a.leeming@ic.ac.uk
* \author Angus Leeming <leeming@lyx.org>
*/
#include <config.h>
@ -14,24 +14,22 @@
#pragma implementation
#endif
#include "Dialogs.h"
#include "frontends/LyXView.h"
#include "FormInset.h"
#include "xformsBC.h"
#include "insets/insetcommand.h"
#include "frontends/Dialogs.h"
#include <boost/bind.hpp>
FormInset::FormInset(LyXView * lv, Dialogs * d, string const & t)
FormInset::FormInset(LyXView & lv, Dialogs & d, string const & t)
: FormBaseBD(lv, d, t)
{}
void FormInset::connect()
{
u_ = d_->updateBufferDependent.
u_ = d_.updateBufferDependent.
connect(boost::bind(&FormInset::updateSlot, this, _1));
h_ = d_->hideBufferDependent.
h_ = d_.hideBufferDependent.
connect(boost::bind(&FormInset::hide, this));
FormBaseDeprecated::connect();
}
@ -51,46 +49,3 @@ void FormInset::updateSlot(bool switched)
else
update();
}
FormCommand::FormCommand(LyXView * lv, Dialogs * d, string const & t)
: FormInset(lv, d, t),
inset_(0)
{}
void FormCommand::disconnect()
{
inset_ = 0;
params = InsetCommandParams(string());
FormInset::disconnect();
}
void FormCommand::showInset(InsetCommand * inset)
{
if (inset == 0) return; // maybe we should Assert this?
// If connected to another inset, disconnect from it.
if (inset_)
ih_.disconnect();
inset_ = inset;
params = inset->params();
ih_ = inset->hideDialog.connect(boost::bind(&FormCommand::hide, this));
show();
}
void FormCommand::createInset(string const & arg)
{
if (inset_) {
ih_.disconnect();
inset_ = 0;
}
params.setFromString(arg);
if (!arg.empty())
bc().valid(); // so that the user can press Ok
show();
}

View File

@ -4,7 +4,7 @@
* Copyright 2000-2001 the LyX Team
* Read the file COPYING
*
* \author Angus Leeming, a.leeming@ic.ac.uk
* \author Angus Leeming <leeming@lyx.org>
*/
/* A base class for dialogs connected to insets. This class is temporary in that
@ -30,7 +30,7 @@ class InsetCommand;
class FormInset : public FormBaseBD {
protected:
/// Constructor
FormInset(LyXView *, Dialogs *, string const &);
FormInset(LyXView &, Dialogs &, string const &);
/// Connect signals. Also perform any necessary initialisation.
virtual void connect();
@ -44,27 +44,4 @@ protected:
boost::signals::connection ih_;
};
/** This class is an XForms GUI base class to insets derived from
InsetCommand
*/
class FormCommand : public FormInset {
protected:
/// Constructor
FormCommand(LyXView *, Dialogs *, string const &);
/// Disconnect signals. Also perform any necessary housekeeping.
virtual void disconnect();
/// Slot launching dialog to (possibly) create a new inset
void createInset(string const &);
/// Slot launching dialog to an existing inset
void showInset(InsetCommand *);
/// pointer to the inset passed through showInset
InsetCommand * inset_;
/// the nitty-griity. What is modified and passed back
InsetCommandParams params;
};
#endif

View File

@ -3,7 +3,7 @@
* Copyright 2000-2001 The LyX Team.
* See the file COPYING.
*
* \author Angus Leeming, a.leeming@ic.ac.uk
* \author Angus Leeming <leeming@lyx.org>
*/
#include <config.h>
@ -72,7 +72,7 @@ Converters local_converters;
FormPreferences::FormPreferences(LyXView & lv, Dialogs & d)
: FormBaseBI(&lv, &d, _("Preferences"), false),
: FormBaseBI(lv, d, _("Preferences"), false),
colors_(*this), converters_(*this), inputs_misc_(*this),
formats_(*this), interface_(*this), language_(*this),
lnf_misc_(*this), outputs_misc_(*this), paths_(*this),
@ -132,7 +132,7 @@ void FormPreferences::ok()
colors_.modifiedXformsPrefs = !XformsColor::write(filename);
}
lv_->dispatch(FuncRequest(LFUN_SAVEPREFERENCES));
lv_.dispatch(FuncRequest(LFUN_SAVEPREFERENCES));
}
@ -415,7 +415,7 @@ void FormPreferences::Colors::apply()
setCursorColor(GUI_COLOR_CURSOR);
}
}
parent_.lv_->getDialogs().redrawGUI();
parent_.lv_.getDialogs().redrawGUI();
}
// Now do the same for the LyX LColors...
@ -437,7 +437,7 @@ void FormPreferences::Colors::apply()
string const s = lcolor.getLyXName(lc) + string(" ") +
hexname;
parent_.lv_->dispatch(FuncRequest(LFUN_SET_COLOR, s));
parent_.lv_.dispatch(FuncRequest(LFUN_SET_COLOR, s));
}
}
}
@ -744,7 +744,7 @@ void FormPreferences::Colors::LoadBrowserLyX()
<< "\". Set to \"black\"!" << endl;
string const arg = lcolor.getLyXName(lc) + " black";
parent_.lv_->dispatch(FuncRequest(LFUN_SET_COLOR, arg));
parent_.lv_.dispatch(FuncRequest(LFUN_SET_COLOR, arg));
continue;
}
@ -2556,7 +2556,7 @@ void FormPreferences::ScreenFonts::apply() const
if (changed) {
// Now update the buffers
// Can anything below here affect the redraw process?
parent_.lv_->dispatch(FuncRequest(LFUN_SCREEN_FONT_UPDATE));
parent_.lv_.dispatch(FuncRequest(LFUN_SCREEN_FONT_UPDATE));
}
}
@ -2979,7 +2979,7 @@ void FormPreferences::browse(FL_OBJECT * inpt,
// Show the file browser dialog
string const new_filename =
browseFile(lv_, filename, title, pattern, dir1, dir2);
browseFile(&lv_, filename, title, pattern, dir1, dir2);
// Save the filename to the dialog
if (new_filename != filename && !new_filename.empty()) {

View File

@ -39,7 +39,7 @@ using std::remove_if;
FormTabular::FormTabular(LyXView & lv, Dialogs & d)
: FormInset(&lv, &d, _("Tabular Layout")),
: FormInset(lv, d, _("Tabular Layout")),
inset_(0), actCell_(-1), closing_(false)
{
}
@ -246,7 +246,7 @@ void FormTabular::update()
cell_options_->choice_value_mcolumn_width,
pwidth, default_unit);
if (!lv_->buffer()->isReadonly()) {
if (!lv_.buffer()->isReadonly()) {
setEnabled(cell_options_->input_special_multialign, true);
setEnabled(cell_options_->input_mcolumn_width, true);
setEnabled(cell_options_->choice_value_mcolumn_width, true);
@ -322,7 +322,7 @@ void FormTabular::update()
special = tabular->GetAlignSpecial(cell, LyXTabular::SET_SPECIAL_COLUMN);
fl_set_input(column_options_->input_special_alignment, special.c_str());
bool const isReadonly = lv_->buffer()->isReadonly();
bool const isReadonly = lv_.buffer()->isReadonly();
setEnabled(column_options_->input_special_alignment, !isReadonly);
pwidth = tabular->GetColumnPWidth(cell);
@ -548,7 +548,7 @@ bool FormTabular::input(FL_OBJECT * ob, long)
}
// No point in processing directives that you can't do anything with
// anyhow, so exit now if the buffer is read-only.
if (lv_->buffer()->isReadonly()) {
if (lv_.buffer()->isReadonly()) {
update();
return false;
}
@ -557,7 +557,7 @@ bool FormTabular::input(FL_OBJECT * ob, long)
string const str =
getLengthFromWidgets(column_options_->input_column_width,
column_options_->choice_value_column_width);
inset_->tabularFeatures(lv_->view().get(), LyXTabular::SET_PWIDTH, str);
inset_->tabularFeatures(lv_.view().get(), LyXTabular::SET_PWIDTH, str);
//check if the input is valid
string const input =
@ -576,7 +576,7 @@ bool FormTabular::input(FL_OBJECT * ob, long)
string const str =
getLengthFromWidgets(cell_options_->input_mcolumn_width,
cell_options_->choice_value_mcolumn_width);
inset_->tabularFeatures(lv_->view().get(), LyXTabular::SET_MPWIDTH, str);
inset_->tabularFeatures(lv_.view().get(), LyXTabular::SET_MPWIDTH, str);
//check if the input is valid
string const input =
@ -689,7 +689,7 @@ bool FormTabular::input(FL_OBJECT * ob, long)
else
return false;
inset_->tabularFeatures(lv_->view().get(), num, special);
inset_->tabularFeatures(lv_.view().get(), num, special);
update();
return true;

View File

@ -143,7 +143,6 @@ libxforms_la_SOURCES = \
FormUrl.h \
FormVCLog.C \
FormVCLog.h \
guiapi.C \
LyXKeySymFactory.C \
LyXScreenFactory.C \
MathsSymbols.C \