Implemented controller-view split for minipage and preamble popups.

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@1838 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
Angus Leeming 2001-03-27 16:03:28 +00:00
parent 94add86953
commit c44d76deae
22 changed files with 423 additions and 256 deletions

View File

@ -1,8 +1,10 @@
2001-03-27 Angus Leeming <a.leeming@ic.ac.uk> 2001-03-27 Angus Leeming <a.leeming@ic.ac.uk>
* ControlMinipage.[Ch]:
* ControlPreamble.[Ch]:
* ControlPrint.[Ch]: * ControlPrint.[Ch]:
* ControlSplash.[Ch]: new files; controller for the Print popup and * ControlSplash.[Ch]: new files; controller for the Minipage, Preamble
Splash screen respectively. and Print popups and Splash screen, respectively.
* ViewBase.h (ViewSplash): new base class for GUI-specific Splash * ViewBase.h (ViewSplash): new base class for GUI-specific Splash
screens. screens.

View File

@ -23,12 +23,10 @@
#include "buffer.h" #include "buffer.h"
#include "insets/inseterror.h" #include "insets/inseterror.h"
using SigC::slot;
ControlError::ControlError(LyXView & lv, Dialogs & d) ControlError::ControlError(LyXView & lv, Dialogs & d)
: ControlInset<InsetError, string>(lv, d) : ControlInset<InsetError, string>(lv, d)
{ {
d_.showError.connect(slot(this, &ControlError::showInset)); d_.showError.connect(SigC::slot(this, &ControlError::showInset));
} }
string const ControlError::getParams(InsetError const & inset) string const ControlError::getParams(InsetError const & inset)

View File

@ -0,0 +1,70 @@
/* This file is part of
* ======================================================
*
* LyX, The Document Processor
*
* Copyright 2001 The LyX Team.
*
* ======================================================
*
* \author Juergen Vigna, jug@sad.it
* \author Angus Leeming, a.leeming@ic.ac.uk
*/
#include <config.h>
#ifdef __GNUG__
#pragma implementation
#endif
#include "ControlMinipage.h"
#include "Dialogs.h"
#include "LyXView.h"
#include "buffer.h"
using SigC::slot;
ControlMinipage::ControlMinipage(LyXView & lv, Dialogs & d)
: ControlInset<InsetMinipage, MinipageParams>(lv, d)
{
d_.showMinipage.connect(slot(this, &ControlMinipage::showInset));
d_.updateMinipage.connect(slot(this, &ControlMinipage::showInset));
}
void ControlMinipage::applyParamsToInset()
{
inset()->width(params().width);
inset()->widthp(params().widthp);
inset()->pos(params().pos);
}
void ControlMinipage::applyParamsNoInset()
{
}
MinipageParams const ControlMinipage::getParams(InsetMinipage const & inset)
{
return MinipageParams(inset);
}
MinipageParams::MinipageParams()
: widthp(0), pos(InsetMinipage::top)
{}
MinipageParams::MinipageParams(InsetMinipage const & inset)
: width(inset.width()), widthp(inset.widthp()), pos(inset.pos())
{}
bool MinipageParams::operator==(MinipageParams const & o) const
{
return (width == o.width && widthp == o.widthp && pos == o.pos);
}
bool MinipageParams::operator!=(MinipageParams const & o) const
{
return !(*this == o);
}

View File

@ -0,0 +1,71 @@
/* This file is part of
* ======================================================
*
* LyX, The Document Processor
*
* Copyright 2001 The LyX Team.
*
*======================================================
*
* \file ControlMinipage.h
* \author Juergen Vigna, jug@sad.it
* \author Angus Leeming, a.leeming@ic.ac.uk
*/
#ifndef CONTROLMINIPAGE_H
#define CONTROLMINIPAGE_H
#ifdef __GNUG__
#pragma interface
#endif
#include "ControlInset.h"
#include "insets/insetminipage.h" // InsetMinipage::Position
/** This should be moved back into insetminipage.h and InsetMinipage should
contain an instance of it. */
struct MinipageParams {
///
MinipageParams();
///
MinipageParams(InsetMinipage const &);
///
bool operator==(MinipageParams const &) const;
///
bool operator!=(MinipageParams const &) const;
///
string width;
///
int widthp;
///
InsetMinipage::Position pos;
};
class InsetMinipage;
class MinipageParams;
/** A controller for Minipage dialogs.
*/
class ControlMinipage : public ControlInset<InsetMinipage, MinipageParams> {
public:
///
ControlMinipage(LyXView &, Dialogs &);
private:
/// Dispatch the changed parameters to the kernel.
virtual void applyParamsToInset();
///
virtual void applyParamsNoInset();
///
virtual void clearDaughterParams() {}
/// get the parameters from the string passed to createInset.
virtual MinipageParams const getParams(string const &)
{ return MinipageParams(); }
/// get the parameters from the inset passed to showInset.
virtual MinipageParams const getParams(InsetMinipage const &);
};
#endif

View File

@ -0,0 +1,63 @@
/**
* \file FormPreamble.C
* Copyright 2001 The LyX Team.
* See the file COPYING.
*
* \author Edwin Leuven, leuven@fee.uva.nl
*/
#include <config.h>
#ifdef __GNUG__
#pragma implementation
#endif
#include "ControlPreamble.h"
#include "LyXView.h"
#include "Dialogs.h"
#include "buffer.h"
#include "lyxrc.h"
#include "Liason.h"
ControlPreamble::ControlPreamble(LyXView & lv, Dialogs & d)
: ControlDialog<ControlConnectBD>(lv, d)
{
d_.showPreamble.connect(SigC::slot(this, &ControlPreamble::show));
}
void ControlPreamble::apply()
{
if (!lv_.view()->available())
return;
view().apply();
lv_.buffer()->params.preamble = params();
lv_.buffer()->markDirty();
Liason::setMinibuffer(&lv_, _("LaTeX preamble set"));
}
string & ControlPreamble::params() const
{
Assert(params_);
return *params_;
}
void ControlPreamble::setParams()
{
if (params_) delete params_;
params_ = new string(lv_.buffer()->params.preamble);
}
void ControlPreamble::clearParams()
{
if (params_) {
delete params_;
params_ = 0;
}
}

View File

@ -0,0 +1,40 @@
/**
* \file ControlPreamble.h
* Copyright 2001 The LyX Team.
* See the file COPYING.
*
* \author Edwin Leuven, leuven@fee.uva.nl
*/
#ifndef CONTROLPREAMBLE_H
#define CONTROLPREAMBLE_H
#ifdef __GNUG__
#pragma interface
#endif
#include "ControlDialogs.h"
/** A controller for Preamble dialogs.
*/
class ControlPreamble : public ControlDialog<ControlConnectBD> {
public:
///
ControlPreamble(LyXView &, Dialogs &);
///
string & params() const;
private:
/// Get changed parameters and Dispatch them to the kernel.
virtual void apply();
/// set the params before show or update.
virtual void setParams();
/// clean-up on hide.
virtual void clearParams();
///
string * params_;
};
#endif // CONTROLPREAMBLE_H

View File

@ -69,6 +69,8 @@ void ControlPrint::setParams()
{ {
if (params_) delete params_; if (params_) delete params_;
params_ = new PrinterParams(getPrinterParams(lv_.buffer())); params_ = new PrinterParams(getPrinterParams(lv_.buffer()));
bc().valid(); // so that the user can press Ok
} }

View File

@ -168,6 +168,34 @@ public:
}; };
/** Specialization for Minipage dialog
*/
class ControlMinipage;
template <class GUIview, class GUIbc>
class GUIMinipage :
public GUI<ControlMinipage, GUIview, OkApplyCancelReadOnlyPolicy, GUIbc> {
public:
///
GUIMinipage(LyXView & lv, Dialogs & d)
: GUI<ControlMinipage, GUIview, OkApplyCancelReadOnlyPolicy, GUIbc>(lv, d) {}
};
/** Specialization for Preamble dialog
*/
class ControlPreamble;
template <class GUIview, class GUIbc>
class GUIPreamble :
public GUI<ControlPreamble, GUIview, NoRepeatedApplyReadOnlyPolicy, GUIbc> {
public:
///
GUIPreamble(LyXView & lv, Dialogs & d)
: GUI<ControlPreamble, GUIview, NoRepeatedApplyReadOnlyPolicy, GUIbc>(lv, d) {}
};
/** Specialization for Print dialog /** Specialization for Print dialog
*/ */
class ControlPrint; class ControlPrint;

View File

@ -40,6 +40,10 @@ libcontrollers_la_SOURCES=\
ControlInset.h \ ControlInset.h \
ControlLog.C \ ControlLog.C \
ControlLog.h \ ControlLog.h \
ControlMinipage.C \
ControlMinipage.h \
ControlPreamble.C \
ControlPreamble.h \
ControlPrint.C \ ControlPrint.C \
ControlPrint.h \ ControlPrint.h \
ControlRef.C \ ControlRef.C \

View File

@ -1,5 +1,7 @@
2001-03-27 Angus Leeming <a.leeming@ic.ac.uk> 2001-03-27 Angus Leeming <a.leeming@ic.ac.uk>
* FormMinipage.[Ch]:
* forms/form_minipage.fd:
* FormPrint.[Ch]: * FormPrint.[Ch]:
* forms/form_print.fd: * forms/form_print.fd:
* FormSplash.[Ch]: implemented controller-view split. * FormSplash.[Ch]: implemented controller-view split.
@ -8,6 +10,8 @@
2001-03-26 Angus Leeming <a.leeming@ic.ac.uk> 2001-03-26 Angus Leeming <a.leeming@ic.ac.uk>
* FormPreamble.[Ch]:
* forms/form_preamble.fd:
* FormRef.[Ch]: * FormRef.[Ch]:
* forms/form_ref.fd: * forms/form_ref.fd:
* FormSearch.[Ch]: * FormSearch.[Ch]:

View File

@ -28,6 +28,8 @@
#include "ControlError.h" #include "ControlError.h"
#include "ControlInclude.h" #include "ControlInclude.h"
#include "ControlLog.h" #include "ControlLog.h"
#include "ControlMinipage.h"
#include "ControlPreamble.h"
#include "ControlPrint.h" #include "ControlPrint.h"
#include "ControlRef.h" #include "ControlRef.h"
#include "ControlSearch.h" #include "ControlSearch.h"
@ -48,6 +50,8 @@
#include "form_credits.h" #include "form_credits.h"
#include "form_error.h" #include "form_error.h"
#include "form_include.h" #include "form_include.h"
#include "form_minipage.h"
#include "form_preamble.h"
#include "form_print.h" #include "form_print.h"
#include "form_ref.h" #include "form_ref.h"
#include "form_search.h" #include "form_search.h"
@ -64,6 +68,8 @@
#include "FormError.h" #include "FormError.h"
#include "FormInclude.h" #include "FormInclude.h"
#include "FormLog.h" #include "FormLog.h"
#include "FormMinipage.h"
#include "FormPreamble.h"
#include "FormPrint.h" #include "FormPrint.h"
#include "FormRef.h" #include "FormRef.h"
#include "FormSearch.h" #include "FormSearch.h"
@ -78,11 +84,9 @@
#include "FormIndex.h" #include "FormIndex.h"
#include "FormMathsPanel.h" #include "FormMathsPanel.h"
#include "FormParagraph.h" #include "FormParagraph.h"
#include "FormPreamble.h"
#include "FormPreferences.h" #include "FormPreferences.h"
#include "FormTabular.h" #include "FormTabular.h"
#include "FormToc.h" #include "FormToc.h"
#include "FormMinipage.h"
// Signal enabling all visible popups to be redrawn if so desired. // Signal enabling all visible popups to be redrawn if so desired.
// E.g., when the GUI colours have been remapped. // E.g., when the GUI colours have been remapped.
@ -101,6 +105,8 @@ Dialogs::Dialogs(LyXView * lv)
add(new GUIError<FormError, xformsBC>(*lv, *this)); add(new GUIError<FormError, xformsBC>(*lv, *this));
add(new GUIInclude<FormInclude, xformsBC>(*lv, *this)); add(new GUIInclude<FormInclude, xformsBC>(*lv, *this));
add(new GUILog<FormLog, xformsBC>(*lv, *this)); add(new GUILog<FormLog, xformsBC>(*lv, *this));
add(new GUIMinipage<FormMinipage, xformsBC>(*lv, *this));
add(new GUIPreamble<FormPreamble, xformsBC>(*lv, *this));
add(new GUIPrint<FormPrint, xformsBC>(*lv, *this)); add(new GUIPrint<FormPrint, xformsBC>(*lv, *this));
add(new GUIRef<FormRef, xformsBC>(*lv, *this)); add(new GUIRef<FormRef, xformsBC>(*lv, *this));
add(new GUISearch<FormSearch, xformsBC>(*lv, *this)); add(new GUISearch<FormSearch, xformsBC>(*lv, *this));
@ -114,11 +120,9 @@ Dialogs::Dialogs(LyXView * lv)
add(new FormIndex(lv, this)); add(new FormIndex(lv, this));
add(new FormMathsPanel(lv, this)); add(new FormMathsPanel(lv, this));
add(new FormParagraph(lv, this)); add(new FormParagraph(lv, this));
add(new FormPreamble(lv, this));
add(new FormPreferences(lv, this)); add(new FormPreferences(lv, this));
add(new FormTabular(lv, this)); add(new FormTabular(lv, this));
add(new FormToc(lv, this)); add(new FormToc(lv, this));
add(new FormMinipage(lv, this));
// reduce the number of connections needed in // reduce the number of connections needed in
// dialogs by a simple connection here. // dialogs by a simple connection here.

View File

@ -25,7 +25,7 @@ class Combox;
struct FD_form_character; struct FD_form_character;
/** /**
* This class provides an XForms implementation of the FormCharacter Dialog. * This class provides an XForms implementation of the Character Dialog.
* The character dialog allows users to change the character settings * The character dialog allows users to change the character settings
* in their documents. * in their documents.
*/ */
@ -36,12 +36,12 @@ public:
FormCharacter(ControlCharacter &); FormCharacter(ControlCharacter &);
private: private:
/// Build the popup
virtual void build();
/// Apply from popup /// Apply from popup
virtual void apply(); virtual void apply();
/// Build the popup
virtual void build();
/// Nothing to update... /// Nothing to update...
virtual void update() {} virtual void update() {}

View File

@ -1,15 +1,14 @@
// -*- C++ -*-
/* This file is part of /* This file is part of
* ====================================================== * ======================================================
* *
* LyX, The Document Processor * LyX, The Document Processor
* *
* Copyright 2000 The LyX Team. * Copyright 2001 The LyX Team.
* *
* ====================================================== * ======================================================
*/ *
/* FormMinipage.C * \file FormMinipage.C
* FormMinipage Interface Class Implementation * \author Juergen Vigna, jug@sad.it
*/ */
#include <config.h> #include <config.h>
@ -18,105 +17,65 @@
#pragma implementation #pragma implementation
#endif #endif
#include "xformsBC.h"
#include "ControlMinipage.h"
#include "FormMinipage.h" #include "FormMinipage.h"
#include "form_minipage.h" #include "form_minipage.h"
#include "Dialogs.h"
#include "LyXView.h"
#include "buffer.h"
#include "insets/insetminipage.h"
#include "support/lstrings.h" #include "support/lstrings.h"
FormMinipage::FormMinipage(LyXView * lv, Dialogs * d) typedef FormCB<ControlMinipage, FormDB<FD_form_minipage> > base_class;
: FormInset(lv, d, _("Minipage Options")),
inset_(0)
{
// let the dialog be shown
// This is a permanent connection so we won't bother
// storing a copy because we won't be disconnecting.
d->showMinipage.connect(SigC::slot(this, &FormMinipage::showInset));
d->updateMinipage.connect(SigC::slot(this, &FormMinipage::updateInset));
}
FormMinipage::FormMinipage(ControlMinipage & c)
: base_class(c, _("Minipage Options"))
{}
FL_FORM * FormMinipage::form() const
{
if (dialog_.get())
return dialog_->form;
return 0;
}
void FormMinipage::connect()
{
bc().valid(true);
FormBaseBD::connect();
}
void FormMinipage::showInset(InsetMinipage * inset)
{
if (inset == 0) return;
// If connected to another inset, disconnect from it.
if (inset_ != inset) {
ih_.disconnect();
ih_ = inset->hideDialog.connect(SigC::slot(this, &FormMinipage::hide));
inset_ = inset;
}
show();
}
void FormMinipage::updateInset(InsetMinipage * inset)
{
if (inset == 0 || inset_ == 0) return;
// If connected to another inset, disconnect from it.
if (inset_ != inset) {
ih_.disconnect();
ih_ = inset->hideDialog.connect(SigC::slot(this, &FormMinipage::hide));
inset_ = inset;
}
update();
}
void FormMinipage::build() void FormMinipage::build()
{ {
dialog_.reset(build_minipage()); dialog_.reset(build_minipage());
fl_set_input_return(dialog_->input_width, FL_RETURN_CHANGED); fl_set_input_return(dialog_->input_width, FL_RETURN_CHANGED);
fl_set_input_return(dialog_->input_widthp, FL_RETURN_CHANGED); fl_set_input_return(dialog_->input_widthp, FL_RETURN_CHANGED);
// Manage the ok, apply and cancel/close buttons // Manage the ok, apply and cancel/close buttons
bc().setOK(dialog_->button_ok); bc().setOK(dialog_->button_ok);
bc().setApply(dialog_->button_apply); bc().setApply(dialog_->button_apply);
bc().setCancel(dialog_->button_cancel); bc().setCancel(dialog_->button_cancel);
bc().refresh(); bc().setUndoAll(dialog_->button_restore);
bc().addReadOnly(dialog_->input_width);
bc().addReadOnly(dialog_->input_widthp);
bc().addReadOnly(dialog_->radio_top);
bc().addReadOnly(dialog_->radio_middle);
bc().addReadOnly(dialog_->radio_bottom);
bc().refresh();
} }
void FormMinipage::apply() void FormMinipage::apply()
{ {
#if 0 controller().params().width = fl_get_input(dialog_->input_width);
int ysize = int(fl_get_slider_value(dialog_->slider_columns) + 0.5); controller().params().widthp =
int xsize = int(fl_get_slider_value(dialog_->slider_rows) + 0.5); strToInt(fl_get_input(dialog_->input_widthp));
string tmp = tostr(xsize) + " " + tostr(ysize); if (fl_get_button(dialog_->radio_top))
lv_->getLyXFunc()->Dispatch(LFUN_INSET_TABULAR, tmp); controller().params().pos = InsetMinipage::top;
#endif else if (fl_get_button(dialog_->radio_middle))
controller().params().pos = InsetMinipage::center;
else
controller().params().pos = InsetMinipage::bottom;
} }
void FormMinipage::update() void FormMinipage::update()
{ {
if (!inset_) fl_set_input(dialog_->input_width,
return; controller().params().width.c_str());
fl_set_input(dialog_->input_width, inset_->width().c_str()); fl_set_input(dialog_->input_widthp,
fl_set_input(dialog_->input_widthp, tostr(inset_->widthp()).c_str()); tostr(controller().params().widthp).c_str());
switch (inset_->pos()) { switch (controller().params().pos) {
case InsetMinipage::top: case InsetMinipage::top:
fl_set_button(dialog_->radio_top, 1); fl_set_button(dialog_->radio_top, 1);
break; break;
@ -127,5 +86,4 @@ void FormMinipage::update()
fl_set_button(dialog_->radio_bottom, 1); fl_set_button(dialog_->radio_bottom, 1);
break; break;
} }
bc().readOnly(lv_->buffer()->isReadonly());
} }

View File

@ -1,77 +1,51 @@
// -*- C++ -*-
/* This file is part of /* This file is part of
* ====================================================== * ======================================================
* *
* LyX, The Document Processor * LyX, The Document Processor
* *
* Copyright 1995 Matthias Ettrich * Copyright 2001 The LyX Team.
* Copyright 1995-2000 The LyX Team.
* *
*======================================================*/ *======================================================
/* FormMinipage.h *
* FormMinipage Interface Class * \file FormMinipage.h
* \author Juergen Vigna, jug@sad.it
*/ */
#ifndef FORMMINIPAGE_H #ifndef FORMMINIPAGE_H
#define FORMMINIPAGE_H #define FORMMINIPAGE_H
#include <boost/smart_ptr.hpp>
#ifdef __GNUG__ #ifdef __GNUG__
#pragma interface #pragma interface
#endif #endif
#include "FormInset.h" #include "FormBase.h"
#include "xformsBC.h"
class LyXView; class LyXView;
class Dialogs; class Dialogs;
class InsetMinipage; class InsetMinipage;
struct FD_form_minipage; struct FD_form_minipage;
/** This class provides an XForms implementation of the FormMinipage /** This class provides an XForms implementation of the Minipage
Dialog. Dialog.
*/ */
class FormMinipage : public FormInset { class ControlMinipage;
struct FD_form_minipage;
class FormMinipage : public FormCB<ControlMinipage, FormDB<FD_form_minipage> > {
public: public:
/// #FormMinipage x(LyXView ..., Dialogs ...);# ///
FormMinipage(LyXView *, Dialogs *); FormMinipage(ControlMinipage &);
private: private:
/// Pointer to the actual instantiation of the ButtonController. /// Set the Params variable for the Controller.
virtual xformsBC & bc();
/// Connect signals etc.
virtual void connect();
/// Slot launching dialog to an existing inset
void showInset(InsetMinipage *);
/// Slot launching dialog to an existing inset
void updateInset(InsetMinipage *);
/// Apply from dialog
virtual void apply(); virtual void apply();
/// Update dialog before showing it /// Build the dialog.
virtual void update();
/// Pointer to the actual instantiation of the xforms form
virtual FL_FORM * form() const;
/// Build the dialog
virtual void build(); virtual void build();
/// Update dialog before/whilst showing it.
virtual void update();
/// /// Fdesign generated method
FD_form_minipage * build_minipage(); FD_form_minipage * build_minipage();
/// Real GUI implementation.
boost::scoped_ptr<FD_form_minipage> dialog_;
/// The ButtonController
ButtonController<OkApplyCancelReadOnlyPolicy, xformsBC> bc_;
/// pointer to the inset passed through showInset
InsetMinipage * inset_;
}; };
#endif // FORMMINIPAGE_H
inline
xformsBC & FormMinipage::bc()
{
return bc_;
}
#endif

View File

@ -8,83 +8,52 @@
#include <config.h> #include <config.h>
#include FORMS_H_LOCATION
#ifdef __GNUG__ #ifdef __GNUG__
#pragma implementation #pragma implementation
#endif #endif
#include "form_preamble.h" #include "xformsBC.h"
#include "ControlPreamble.h"
#include "FormPreamble.h" #include "FormPreamble.h"
#include "Dialogs.h" #include "form_preamble.h"
#include "Liason.h"
#include "LyXView.h"
#include "buffer.h"
#include "gettext.h"
#include "xforms_helpers.h" #include "xforms_helpers.h"
using Liason::setMinibuffer; typedef FormCB<ControlPreamble, FormDB<FD_form_preamble> > base_class;
using SigC::slot;
FormPreamble::FormPreamble(LyXView * lv, Dialogs * d) FormPreamble::FormPreamble(ControlPreamble & c)
: FormBaseBD(lv, d, _("LaTeX preamble")) : base_class(c, _("LaTeX preamble"))
{ {}
// let the popup be shown
// This is a permanent connection so we won't bother
// storing a copy because we won't be disconnecting.
d->showPreamble.connect(slot(this, &FormPreamble::show));
}
FL_FORM * FormPreamble::form() const
{
if (dialog_.get()) return dialog_->form;
return 0;
}
void FormPreamble::build() void FormPreamble::build()
{ {
dialog_.reset(build_preamble()); dialog_.reset(build_preamble());
fl_set_input_return(dialog_->input_preamble, FL_RETURN_CHANGED); fl_set_input_return(dialog_->input_preamble, FL_RETURN_CHANGED);
// Manage the ok, apply and cancel/close buttons
bc().setOK(dialog_->button_ok); // Manage the ok, apply and cancel/close buttons
bc().setApply(dialog_->button_apply); bc().setOK(dialog_->button_ok);
bc().setCancel(dialog_->button_cancel); bc().setApply(dialog_->button_apply);
bc().addReadOnly(dialog_->input_preamble); bc().setCancel(dialog_->button_cancel);
bc().refresh(); bc().addReadOnly(dialog_->input_preamble);
bc().refresh();
} }
void FormPreamble::apply() void FormPreamble::apply()
{ {
if (!lv_->view()->available() || !dialog_.get()) controller().params() = fl_get_input(dialog_->input_preamble);
return;
// is this needed?:
// lv_->view()->update(BufferView::SELECT | BufferView::FITCUR | BufferView::CHANGE);
lv_->buffer()->params.preamble = fl_get_input(dialog_->input_preamble);
lv_->buffer()->markDirty();
setMinibuffer(lv_, _("LaTeX preamble set"));
} }
void FormPreamble::update() void FormPreamble::update()
{ {
if (!dialog_.get()) fl_set_input(dialog_->input_preamble, controller().params().c_str());
return;
fl_set_input(dialog_->input_preamble,lv_->buffer()->params.preamble.c_str()); bool const enable = (!controller().isReadonly());
setEnabled(dialog_->input_preamble, enable);
bool const enable = (! lv_->buffer()->isReadonly()); setEnabled(dialog_->button_ok, enable);
setEnabled(dialog_->input_preamble, enable); setEnabled(dialog_->button_apply, enable);
setEnabled(dialog_->button_ok, enable);
setEnabled(dialog_->button_apply, enable);
// need this?
// bc().readOnly(lv_->buffer()->isReadonly());
} }

View File

@ -1,4 +1,3 @@
// -*- C++ -*-
/** /**
* \file FormPreamble.h * \file FormPreamble.h
* Copyright 2001 The LyX Team. * Copyright 2001 The LyX Team.
@ -10,51 +9,32 @@
#ifndef FORMPREAMBLE_H #ifndef FORMPREAMBLE_H
#define FORMPREAMBLE_H #define FORMPREAMBLE_H
#include <boost/smart_ptr.hpp>
#ifdef __GNUG__ #ifdef __GNUG__
#pragma interface #pragma interface
#endif #endif
#include "FormBaseDeprecated.h" #include "FormBase.h"
class ControlPreamble;
struct FD_form_preamble; struct FD_form_preamble;
/** This class provides an XForms implementation of the FormPreamble Dialog. /** This class provides an XForms implementation of the Preamble Dialog.
*/ */
class FormPreamble : public FormBaseBD { class FormPreamble : public FormCB<ControlPreamble, FormDB<FD_form_preamble> > {
public: public:
/// ///
FormPreamble(LyXView *, Dialogs *); FormPreamble(ControlPreamble &);
private: private:
/// Pointer to the actual instantiation of the ButtonController.
virtual xformsBC & bc();
/// Filter the inputs
// virtual bool input(FL_OBJECT *, long);
/// Build the popup
virtual void build();
/// Apply from popup /// Apply from popup
virtual void apply(); virtual void apply();
/// Build the popup
virtual void build();
/// Update the popup. /// Update the popup.
virtual void update(); virtual void update();
///
virtual FL_FORM * form() const;
/// Fdesign generated method /// Fdesign generated method
FD_form_preamble * build_preamble(); FD_form_preamble * build_preamble();
/// Real GUI implementation.
boost::scoped_ptr<FD_form_preamble> dialog_;
/// The ButtonController
ButtonController<NoRepeatedApplyReadOnlyPolicy, xformsBC> bc_;
}; };
inline #endif // FORMPREAMBLE_H
xformsBC & FormPreamble::bc()
{
return bc_;
}
#endif

View File

@ -35,7 +35,7 @@ FD_form_minipage * FormMinipage::build_minipage()
fl_set_button_shortcut(obj, scex(_(dummy)), 1); fl_set_button_shortcut(obj, scex(_(dummy)), 1);
} }
fl_set_object_lsize(obj, FL_NORMAL_SIZE); fl_set_object_lsize(obj, FL_NORMAL_SIZE);
fl_set_object_callback(obj, C_FormBaseDeprecatedInputCB, 0); fl_set_object_callback(obj, C_FormBaseInputCB, 0);
{ {
// xgettext:no-c-format // xgettext:no-c-format
char const * const dummy = N_("or %|#o"); char const * const dummy = N_("or %|#o");
@ -43,7 +43,7 @@ FD_form_minipage * FormMinipage::build_minipage()
fl_set_button_shortcut(obj, scex(_(dummy)), 1); fl_set_button_shortcut(obj, scex(_(dummy)), 1);
} }
fl_set_object_lsize(obj, FL_NORMAL_SIZE); fl_set_object_lsize(obj, FL_NORMAL_SIZE);
fl_set_object_callback(obj, C_FormBaseDeprecatedInputCB, 0); fl_set_object_callback(obj, C_FormBaseInputCB, 0);
obj = fl_add_text(FL_NORMAL_TEXT, 30, 10, 100, 20, _("Width")); obj = fl_add_text(FL_NORMAL_TEXT, 30, 10, 100, 20, _("Width"));
fl_set_object_lsize(obj, FL_NORMAL_SIZE); fl_set_object_lsize(obj, FL_NORMAL_SIZE);
fl_set_object_lalign(obj, FL_ALIGN_LEFT|FL_ALIGN_INSIDE); fl_set_object_lalign(obj, FL_ALIGN_LEFT|FL_ALIGN_INSIDE);
@ -60,21 +60,21 @@ FD_form_minipage * FormMinipage::build_minipage()
fl_set_button_shortcut(obj, scex(_(dummy)), 1); fl_set_button_shortcut(obj, scex(_(dummy)), 1);
} }
fl_set_object_lsize(obj, FL_NORMAL_SIZE); fl_set_object_lsize(obj, FL_NORMAL_SIZE);
fl_set_object_callback(obj, C_FormBaseDeprecatedInputCB, 0); fl_set_object_callback(obj, C_FormBaseInputCB, 0);
{ {
char const * const dummy = N_("Middle|#d"); char const * const dummy = N_("Middle|#d");
fdui->radio_middle = obj = fl_add_checkbutton(FL_RADIO_BUTTON, 249, 60, 152, 30, idex(_(dummy))); fdui->radio_middle = obj = fl_add_checkbutton(FL_RADIO_BUTTON, 249, 60, 152, 30, idex(_(dummy)));
fl_set_button_shortcut(obj, scex(_(dummy)), 1); fl_set_button_shortcut(obj, scex(_(dummy)), 1);
} }
fl_set_object_lsize(obj, FL_NORMAL_SIZE); fl_set_object_lsize(obj, FL_NORMAL_SIZE);
fl_set_object_callback(obj, C_FormBaseDeprecatedInputCB, 0); fl_set_object_callback(obj, C_FormBaseInputCB, 0);
{ {
char const * const dummy = N_("Bottom|#B"); char const * const dummy = N_("Bottom|#B");
fdui->radio_bottom = obj = fl_add_checkbutton(FL_RADIO_BUTTON, 249, 90, 152, 30, idex(_(dummy))); fdui->radio_bottom = obj = fl_add_checkbutton(FL_RADIO_BUTTON, 249, 90, 152, 30, idex(_(dummy)));
fl_set_button_shortcut(obj, scex(_(dummy)), 1); fl_set_button_shortcut(obj, scex(_(dummy)), 1);
} }
fl_set_object_lsize(obj, FL_NORMAL_SIZE); fl_set_object_lsize(obj, FL_NORMAL_SIZE);
fl_set_object_callback(obj, C_FormBaseDeprecatedInputCB, 0); fl_set_object_callback(obj, C_FormBaseInputCB, 0);
fl_end_group(); fl_end_group();
{ {
@ -83,24 +83,24 @@ FD_form_minipage * FormMinipage::build_minipage()
fl_set_button_shortcut(obj, scex(_(dummy)), 1); fl_set_button_shortcut(obj, scex(_(dummy)), 1);
} }
fl_set_object_lsize(obj, FL_NORMAL_SIZE); fl_set_object_lsize(obj, FL_NORMAL_SIZE);
fl_set_object_callback(obj, C_FormBaseDeprecatedCancelCB, 0); fl_set_object_callback(obj, C_FormBaseCancelCB, 0);
{ {
char const * const dummy = N_("Apply|#A"); char const * const dummy = N_("Apply|#A");
fdui->button_apply = obj = fl_add_button(FL_NORMAL_BUTTON, 230, 130, 90, 30, idex(_(dummy))); fdui->button_apply = obj = fl_add_button(FL_NORMAL_BUTTON, 230, 130, 90, 30, idex(_(dummy)));
fl_set_button_shortcut(obj, scex(_(dummy)), 1); fl_set_button_shortcut(obj, scex(_(dummy)), 1);
} }
fl_set_object_lsize(obj, FL_NORMAL_SIZE); fl_set_object_lsize(obj, FL_NORMAL_SIZE);
fl_set_object_callback(obj, C_FormBaseDeprecatedApplyCB, 0); fl_set_object_callback(obj, C_FormBaseApplyCB, 0);
fdui->button_ok = obj = fl_add_button(FL_RETURN_BUTTON, 130, 130, 90, 30, _("OK")); fdui->button_ok = obj = fl_add_button(FL_RETURN_BUTTON, 130, 130, 90, 30, _("OK"));
fl_set_object_lsize(obj, FL_NORMAL_SIZE); fl_set_object_lsize(obj, FL_NORMAL_SIZE);
fl_set_object_callback(obj, C_FormBaseDeprecatedOKCB, 0); fl_set_object_callback(obj, C_FormBaseOKCB, 0);
{ {
char const * const dummy = N_("Restore|#R"); char const * const dummy = N_("Restore|#R");
fdui->button_restore = obj = fl_add_button(FL_NORMAL_BUTTON, 10, 130, 90, 30, idex(_(dummy))); fdui->button_restore = obj = fl_add_button(FL_NORMAL_BUTTON, 10, 130, 90, 30, idex(_(dummy)));
fl_set_button_shortcut(obj, scex(_(dummy)), 1); fl_set_button_shortcut(obj, scex(_(dummy)), 1);
} }
fl_set_object_lsize(obj, FL_NORMAL_SIZE); fl_set_object_lsize(obj, FL_NORMAL_SIZE);
fl_set_object_callback(obj, C_FormBaseDeprecatedRestoreCB, 0); fl_set_object_callback(obj, C_FormBaseRestoreCB, 0);
fl_end_form(); fl_end_form();
fdui->form->fdui = fdui; fdui->form->fdui = fdui;

View File

@ -5,11 +5,11 @@
#define FD_form_minipage_h_ #define FD_form_minipage_h_
/** Callbacks, globals and object handlers **/ /** Callbacks, globals and object handlers **/
extern "C" void C_FormBaseDeprecatedInputCB(FL_OBJECT *, long); extern "C" void C_FormBaseInputCB(FL_OBJECT *, long);
extern "C" void C_FormBaseDeprecatedCancelCB(FL_OBJECT *, long); extern "C" void C_FormBaseCancelCB(FL_OBJECT *, long);
extern "C" void C_FormBaseDeprecatedApplyCB(FL_OBJECT *, long); extern "C" void C_FormBaseApplyCB(FL_OBJECT *, long);
extern "C" void C_FormBaseDeprecatedOKCB(FL_OBJECT *, long); extern "C" void C_FormBaseOKCB(FL_OBJECT *, long);
extern "C" void C_FormBaseDeprecatedRestoreCB(FL_OBJECT *, long); extern "C" void C_FormBaseRestoreCB(FL_OBJECT *, long);
/**** Forms and Objects ****/ /**** Forms and Objects ****/

View File

@ -32,7 +32,7 @@ FD_form_preamble * FormPreamble::build_preamble()
} }
fl_set_object_lsize(obj, FL_NORMAL_SIZE); fl_set_object_lsize(obj, FL_NORMAL_SIZE);
fl_set_object_gravity(obj, FL_SouthEast, FL_SouthEast); 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"); char const * const dummy = N_("Apply|#A");
fdui->button_apply = obj = fl_add_button(FL_NORMAL_BUTTON, 160, 380, 100, 30, idex(_(dummy))); fdui->button_apply = obj = fl_add_button(FL_NORMAL_BUTTON, 160, 380, 100, 30, idex(_(dummy)));
@ -40,7 +40,7 @@ FD_form_preamble * FormPreamble::build_preamble()
} }
fl_set_object_lsize(obj, FL_NORMAL_SIZE); fl_set_object_lsize(obj, FL_NORMAL_SIZE);
fl_set_object_gravity(obj, FL_SouthEast, FL_SouthEast); 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_("Cancel|^["); char const * const dummy = N_("Cancel|^[");
fdui->button_cancel = obj = fl_add_button(FL_NORMAL_BUTTON, 270, 380, 100, 30, idex(_(dummy))); fdui->button_cancel = obj = fl_add_button(FL_NORMAL_BUTTON, 270, 380, 100, 30, idex(_(dummy)));
@ -48,11 +48,11 @@ FD_form_preamble * FormPreamble::build_preamble()
} }
fl_set_object_lsize(obj, FL_NORMAL_SIZE); fl_set_object_lsize(obj, FL_NORMAL_SIZE);
fl_set_object_gravity(obj, FL_SouthEast, FL_SouthEast); 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->input_preamble = obj = fl_add_input(FL_MULTILINE_INPUT, 10, 10, 360, 360, ""); fdui->input_preamble = obj = fl_add_input(FL_MULTILINE_INPUT, 10, 10, 360, 360, "");
fl_set_object_lsize(obj, FL_NORMAL_SIZE); fl_set_object_lsize(obj, FL_NORMAL_SIZE);
fl_set_object_gravity(obj, FL_NorthWest, FL_SouthEast); fl_set_object_gravity(obj, FL_NorthWest, FL_SouthEast);
fl_set_object_callback(obj, C_FormBaseDeprecatedInputCB, 0); fl_set_object_callback(obj, C_FormBaseInputCB, 0);
fl_end_form(); fl_end_form();
fdui->form->fdui = fdui; fdui->form->fdui = fdui;

View File

@ -5,10 +5,10 @@
#define FD_form_preamble_h_ #define FD_form_preamble_h_
/** Callbacks, globals and object handlers **/ /** Callbacks, globals and object handlers **/
extern "C" void C_FormBaseDeprecatedOKCB(FL_OBJECT *, long); extern "C" void C_FormBaseOKCB(FL_OBJECT *, long);
extern "C" void C_FormBaseDeprecatedApplyCB(FL_OBJECT *, long); extern "C" void C_FormBaseApplyCB(FL_OBJECT *, long);
extern "C" void C_FormBaseDeprecatedCancelCB(FL_OBJECT *, long); extern "C" void C_FormBaseCancelCB(FL_OBJECT *, long);
extern "C" void C_FormBaseDeprecatedInputCB(FL_OBJECT *, long); extern "C" void C_FormBaseInputCB(FL_OBJECT *, long);
/**** Forms and Objects ****/ /**** Forms and Objects ****/

View File

@ -81,7 +81,7 @@ shortcut:
resize: FL_RESIZE_ALL resize: FL_RESIZE_ALL
gravity: FL_NoGravity FL_NoGravity gravity: FL_NoGravity FL_NoGravity
name: input_width name: input_width
callback: C_FormBaseDeprecatedInputCB callback: C_FormBaseInputCB
argument: 0 argument: 0
-------------------- --------------------
@ -99,7 +99,7 @@ shortcut:
resize: FL_RESIZE_ALL resize: FL_RESIZE_ALL
gravity: FL_NoGravity FL_NoGravity gravity: FL_NoGravity FL_NoGravity
name: input_widthp name: input_widthp
callback: C_FormBaseDeprecatedInputCB callback: C_FormBaseInputCB
argument: 0 argument: 0
-------------------- --------------------
@ -171,7 +171,7 @@ shortcut:
resize: FL_RESIZE_ALL resize: FL_RESIZE_ALL
gravity: FL_NoGravity FL_NoGravity gravity: FL_NoGravity FL_NoGravity
name: radio_top name: radio_top
callback: C_FormBaseDeprecatedInputCB callback: C_FormBaseInputCB
argument: 0 argument: 0
-------------------- --------------------
@ -189,7 +189,7 @@ shortcut:
resize: FL_RESIZE_ALL resize: FL_RESIZE_ALL
gravity: FL_NoGravity FL_NoGravity gravity: FL_NoGravity FL_NoGravity
name: radio_middle name: radio_middle
callback: C_FormBaseDeprecatedInputCB callback: C_FormBaseInputCB
argument: 0 argument: 0
-------------------- --------------------
@ -207,7 +207,7 @@ shortcut:
resize: FL_RESIZE_ALL resize: FL_RESIZE_ALL
gravity: FL_NoGravity FL_NoGravity gravity: FL_NoGravity FL_NoGravity
name: radio_bottom name: radio_bottom
callback: C_FormBaseDeprecatedInputCB callback: C_FormBaseInputCB
argument: 0 argument: 0
-------------------- --------------------
@ -243,7 +243,7 @@ shortcut:
resize: FL_RESIZE_ALL resize: FL_RESIZE_ALL
gravity: FL_NoGravity FL_NoGravity gravity: FL_NoGravity FL_NoGravity
name: button_cancel name: button_cancel
callback: C_FormBaseDeprecatedCancelCB callback: C_FormBaseCancelCB
argument: 0 argument: 0
-------------------- --------------------
@ -261,7 +261,7 @@ shortcut:
resize: FL_RESIZE_ALL resize: FL_RESIZE_ALL
gravity: FL_NoGravity FL_NoGravity gravity: FL_NoGravity FL_NoGravity
name: button_apply name: button_apply
callback: C_FormBaseDeprecatedApplyCB callback: C_FormBaseApplyCB
argument: 0 argument: 0
-------------------- --------------------
@ -279,7 +279,7 @@ shortcut: ^M
resize: FL_RESIZE_ALL resize: FL_RESIZE_ALL
gravity: FL_NoGravity FL_NoGravity gravity: FL_NoGravity FL_NoGravity
name: button_ok name: button_ok
callback: C_FormBaseDeprecatedOKCB callback: C_FormBaseOKCB
argument: 0 argument: 0
-------------------- --------------------
@ -297,7 +297,7 @@ shortcut:
resize: FL_RESIZE_ALL resize: FL_RESIZE_ALL
gravity: FL_NoGravity FL_NoGravity gravity: FL_NoGravity FL_NoGravity
name: button_restore name: button_restore
callback: C_FormBaseDeprecatedRestoreCB callback: C_FormBaseRestoreCB
argument: 0 argument: 0
============================== ==============================

View File

@ -46,7 +46,7 @@ shortcut:
resize: FL_RESIZE_NONE resize: FL_RESIZE_NONE
gravity: FL_SouthEast FL_SouthEast gravity: FL_SouthEast FL_SouthEast
name: button_ok name: button_ok
callback: C_FormBaseDeprecatedOKCB callback: C_FormBaseOKCB
argument: 0 argument: 0
-------------------- --------------------
@ -64,7 +64,7 @@ shortcut:
resize: FL_RESIZE_NONE resize: FL_RESIZE_NONE
gravity: FL_SouthEast FL_SouthEast gravity: FL_SouthEast FL_SouthEast
name: button_apply name: button_apply
callback: C_FormBaseDeprecatedApplyCB callback: C_FormBaseApplyCB
argument: 0 argument: 0
-------------------- --------------------
@ -82,7 +82,7 @@ shortcut:
resize: FL_RESIZE_NONE resize: FL_RESIZE_NONE
gravity: FL_SouthEast FL_SouthEast gravity: FL_SouthEast FL_SouthEast
name: button_cancel name: button_cancel
callback: C_FormBaseDeprecatedCancelCB callback: C_FormBaseCancelCB
argument: 0 argument: 0
-------------------- --------------------
@ -100,7 +100,7 @@ shortcut:
resize: FL_RESIZE_ALL resize: FL_RESIZE_ALL
gravity: FL_NorthWest FL_SouthEast gravity: FL_NorthWest FL_SouthEast
name: input_preamble name: input_preamble
callback: C_FormBaseDeprecatedInputCB callback: C_FormBaseInputCB
argument: argument:
============================== ==============================