mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-11-22 18:08:10 +00:00
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:
parent
94add86953
commit
c44d76deae
@ -1,8 +1,10 @@
|
||||
2001-03-27 Angus Leeming <a.leeming@ic.ac.uk>
|
||||
|
||||
* ControlMinipage.[Ch]:
|
||||
* ControlPreamble.[Ch]:
|
||||
* ControlPrint.[Ch]:
|
||||
* ControlSplash.[Ch]: new files; controller for the Print popup and
|
||||
Splash screen respectively.
|
||||
* ControlSplash.[Ch]: new files; controller for the Minipage, Preamble
|
||||
and Print popups and Splash screen, respectively.
|
||||
|
||||
* ViewBase.h (ViewSplash): new base class for GUI-specific Splash
|
||||
screens.
|
||||
|
@ -23,12 +23,10 @@
|
||||
#include "buffer.h"
|
||||
#include "insets/inseterror.h"
|
||||
|
||||
using SigC::slot;
|
||||
|
||||
ControlError::ControlError(LyXView & lv, Dialogs & 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)
|
||||
|
70
src/frontends/controllers/ControlMinipage.C
Normal file
70
src/frontends/controllers/ControlMinipage.C
Normal 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);
|
||||
}
|
71
src/frontends/controllers/ControlMinipage.h
Normal file
71
src/frontends/controllers/ControlMinipage.h
Normal 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
|
63
src/frontends/controllers/ControlPreamble.C
Normal file
63
src/frontends/controllers/ControlPreamble.C
Normal 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;
|
||||
}
|
||||
}
|
40
src/frontends/controllers/ControlPreamble.h
Normal file
40
src/frontends/controllers/ControlPreamble.h
Normal 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
|
@ -69,6 +69,8 @@ void ControlPrint::setParams()
|
||||
{
|
||||
if (params_) delete params_;
|
||||
params_ = new PrinterParams(getPrinterParams(lv_.buffer()));
|
||||
|
||||
bc().valid(); // so that the user can press Ok
|
||||
}
|
||||
|
||||
|
||||
|
@ -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
|
||||
*/
|
||||
class ControlPrint;
|
||||
|
@ -40,6 +40,10 @@ libcontrollers_la_SOURCES=\
|
||||
ControlInset.h \
|
||||
ControlLog.C \
|
||||
ControlLog.h \
|
||||
ControlMinipage.C \
|
||||
ControlMinipage.h \
|
||||
ControlPreamble.C \
|
||||
ControlPreamble.h \
|
||||
ControlPrint.C \
|
||||
ControlPrint.h \
|
||||
ControlRef.C \
|
||||
|
@ -1,5 +1,7 @@
|
||||
2001-03-27 Angus Leeming <a.leeming@ic.ac.uk>
|
||||
|
||||
* FormMinipage.[Ch]:
|
||||
* forms/form_minipage.fd:
|
||||
* FormPrint.[Ch]:
|
||||
* forms/form_print.fd:
|
||||
* FormSplash.[Ch]: implemented controller-view split.
|
||||
@ -8,6 +10,8 @@
|
||||
|
||||
2001-03-26 Angus Leeming <a.leeming@ic.ac.uk>
|
||||
|
||||
* FormPreamble.[Ch]:
|
||||
* forms/form_preamble.fd:
|
||||
* FormRef.[Ch]:
|
||||
* forms/form_ref.fd:
|
||||
* FormSearch.[Ch]:
|
||||
|
@ -28,6 +28,8 @@
|
||||
#include "ControlError.h"
|
||||
#include "ControlInclude.h"
|
||||
#include "ControlLog.h"
|
||||
#include "ControlMinipage.h"
|
||||
#include "ControlPreamble.h"
|
||||
#include "ControlPrint.h"
|
||||
#include "ControlRef.h"
|
||||
#include "ControlSearch.h"
|
||||
@ -48,6 +50,8 @@
|
||||
#include "form_credits.h"
|
||||
#include "form_error.h"
|
||||
#include "form_include.h"
|
||||
#include "form_minipage.h"
|
||||
#include "form_preamble.h"
|
||||
#include "form_print.h"
|
||||
#include "form_ref.h"
|
||||
#include "form_search.h"
|
||||
@ -64,6 +68,8 @@
|
||||
#include "FormError.h"
|
||||
#include "FormInclude.h"
|
||||
#include "FormLog.h"
|
||||
#include "FormMinipage.h"
|
||||
#include "FormPreamble.h"
|
||||
#include "FormPrint.h"
|
||||
#include "FormRef.h"
|
||||
#include "FormSearch.h"
|
||||
@ -78,11 +84,9 @@
|
||||
#include "FormIndex.h"
|
||||
#include "FormMathsPanel.h"
|
||||
#include "FormParagraph.h"
|
||||
#include "FormPreamble.h"
|
||||
#include "FormPreferences.h"
|
||||
#include "FormTabular.h"
|
||||
#include "FormToc.h"
|
||||
#include "FormMinipage.h"
|
||||
|
||||
// Signal enabling all visible popups to be redrawn if so desired.
|
||||
// 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 GUIInclude<FormInclude, 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 GUIRef<FormRef, 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 FormMathsPanel(lv, this));
|
||||
add(new FormParagraph(lv, this));
|
||||
add(new FormPreamble(lv, this));
|
||||
add(new FormPreferences(lv, this));
|
||||
add(new FormTabular(lv, this));
|
||||
add(new FormToc(lv, this));
|
||||
add(new FormMinipage(lv, this));
|
||||
|
||||
// reduce the number of connections needed in
|
||||
// dialogs by a simple connection here.
|
||||
|
@ -25,7 +25,7 @@ class Combox;
|
||||
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
|
||||
* in their documents.
|
||||
*/
|
||||
@ -36,12 +36,12 @@ public:
|
||||
FormCharacter(ControlCharacter &);
|
||||
private:
|
||||
|
||||
/// Build the popup
|
||||
virtual void build();
|
||||
|
||||
/// Apply from popup
|
||||
virtual void apply();
|
||||
|
||||
/// Build the popup
|
||||
virtual void build();
|
||||
|
||||
/// Nothing to update...
|
||||
virtual void update() {}
|
||||
|
||||
|
@ -1,15 +1,14 @@
|
||||
// -*- C++ -*-
|
||||
/* This file is part of
|
||||
* ======================================================
|
||||
*
|
||||
* LyX, The Document Processor
|
||||
*
|
||||
* Copyright 2000 The LyX Team.
|
||||
* Copyright 2001 The LyX Team.
|
||||
*
|
||||
* ======================================================
|
||||
*/
|
||||
/* FormMinipage.C
|
||||
* FormMinipage Interface Class Implementation
|
||||
*
|
||||
* \file FormMinipage.C
|
||||
* \author Juergen Vigna, jug@sad.it
|
||||
*/
|
||||
|
||||
#include <config.h>
|
||||
@ -18,105 +17,65 @@
|
||||
#pragma implementation
|
||||
#endif
|
||||
|
||||
#include "xformsBC.h"
|
||||
#include "ControlMinipage.h"
|
||||
#include "FormMinipage.h"
|
||||
#include "form_minipage.h"
|
||||
#include "Dialogs.h"
|
||||
#include "LyXView.h"
|
||||
#include "buffer.h"
|
||||
#include "insets/insetminipage.h"
|
||||
#include "support/lstrings.h"
|
||||
|
||||
FormMinipage::FormMinipage(LyXView * lv, Dialogs * d)
|
||||
: 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));
|
||||
}
|
||||
typedef FormCB<ControlMinipage, FormDB<FD_form_minipage> > base_class;
|
||||
|
||||
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()
|
||||
{
|
||||
dialog_.reset(build_minipage());
|
||||
dialog_.reset(build_minipage());
|
||||
|
||||
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_width, FL_RETURN_CHANGED);
|
||||
fl_set_input_return(dialog_->input_widthp, FL_RETURN_CHANGED);
|
||||
|
||||
// Manage the ok, apply and cancel/close buttons
|
||||
bc().setOK(dialog_->button_ok);
|
||||
bc().setApply(dialog_->button_apply);
|
||||
bc().setCancel(dialog_->button_cancel);
|
||||
bc().refresh();
|
||||
// Manage the ok, apply and cancel/close buttons
|
||||
bc().setOK(dialog_->button_ok);
|
||||
bc().setApply(dialog_->button_apply);
|
||||
bc().setCancel(dialog_->button_cancel);
|
||||
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()
|
||||
{
|
||||
#if 0
|
||||
int ysize = int(fl_get_slider_value(dialog_->slider_columns) + 0.5);
|
||||
int xsize = int(fl_get_slider_value(dialog_->slider_rows) + 0.5);
|
||||
controller().params().width = fl_get_input(dialog_->input_width);
|
||||
controller().params().widthp =
|
||||
strToInt(fl_get_input(dialog_->input_widthp));
|
||||
|
||||
string tmp = tostr(xsize) + " " + tostr(ysize);
|
||||
lv_->getLyXFunc()->Dispatch(LFUN_INSET_TABULAR, tmp);
|
||||
#endif
|
||||
if (fl_get_button(dialog_->radio_top))
|
||||
controller().params().pos = InsetMinipage::top;
|
||||
else if (fl_get_button(dialog_->radio_middle))
|
||||
controller().params().pos = InsetMinipage::center;
|
||||
else
|
||||
controller().params().pos = InsetMinipage::bottom;
|
||||
}
|
||||
|
||||
|
||||
void FormMinipage::update()
|
||||
{
|
||||
if (!inset_)
|
||||
return;
|
||||
fl_set_input(dialog_->input_width, inset_->width().c_str());
|
||||
fl_set_input(dialog_->input_widthp, tostr(inset_->widthp()).c_str());
|
||||
fl_set_input(dialog_->input_width,
|
||||
controller().params().width.c_str());
|
||||
fl_set_input(dialog_->input_widthp,
|
||||
tostr(controller().params().widthp).c_str());
|
||||
|
||||
switch (inset_->pos()) {
|
||||
switch (controller().params().pos) {
|
||||
case InsetMinipage::top:
|
||||
fl_set_button(dialog_->radio_top, 1);
|
||||
break;
|
||||
@ -127,5 +86,4 @@ void FormMinipage::update()
|
||||
fl_set_button(dialog_->radio_bottom, 1);
|
||||
break;
|
||||
}
|
||||
bc().readOnly(lv_->buffer()->isReadonly());
|
||||
}
|
||||
|
@ -1,77 +1,51 @@
|
||||
// -*- C++ -*-
|
||||
/* This file is part of
|
||||
* ======================================================
|
||||
*
|
||||
* LyX, The Document Processor
|
||||
*
|
||||
* Copyright 1995 Matthias Ettrich
|
||||
* Copyright 1995-2000 The LyX Team.
|
||||
* Copyright 2001 The LyX Team.
|
||||
*
|
||||
*======================================================*/
|
||||
/* FormMinipage.h
|
||||
* FormMinipage Interface Class
|
||||
*======================================================
|
||||
*
|
||||
* \file FormMinipage.h
|
||||
* \author Juergen Vigna, jug@sad.it
|
||||
*/
|
||||
|
||||
#ifndef FORMMINIPAGE_H
|
||||
#define FORMMINIPAGE_H
|
||||
|
||||
#include <boost/smart_ptr.hpp>
|
||||
|
||||
#ifdef __GNUG__
|
||||
#pragma interface
|
||||
#endif
|
||||
|
||||
#include "FormInset.h"
|
||||
#include "xformsBC.h"
|
||||
#include "FormBase.h"
|
||||
|
||||
class LyXView;
|
||||
class Dialogs;
|
||||
class InsetMinipage;
|
||||
struct FD_form_minipage;
|
||||
|
||||
/** This class provides an XForms implementation of the FormMinipage
|
||||
/** This class provides an XForms implementation of the Minipage
|
||||
Dialog.
|
||||
*/
|
||||
class FormMinipage : public FormInset {
|
||||
class ControlMinipage;
|
||||
struct FD_form_minipage;
|
||||
|
||||
class FormMinipage : public FormCB<ControlMinipage, FormDB<FD_form_minipage> > {
|
||||
public:
|
||||
/// #FormMinipage x(LyXView ..., Dialogs ...);#
|
||||
FormMinipage(LyXView *, Dialogs *);
|
||||
///
|
||||
FormMinipage(ControlMinipage &);
|
||||
|
||||
private:
|
||||
/// Pointer to the actual instantiation of the ButtonController.
|
||||
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
|
||||
/// Set the Params variable for the Controller.
|
||||
virtual void apply();
|
||||
/// Update dialog before showing it
|
||||
virtual void update();
|
||||
/// Pointer to the actual instantiation of the xforms form
|
||||
virtual FL_FORM * form() const;
|
||||
/// Build the dialog
|
||||
/// Build the dialog.
|
||||
virtual void build();
|
||||
/// Update dialog before/whilst showing it.
|
||||
virtual void update();
|
||||
|
||||
///
|
||||
/// Fdesign generated method
|
||||
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_;
|
||||
};
|
||||
|
||||
|
||||
inline
|
||||
xformsBC & FormMinipage::bc()
|
||||
{
|
||||
return bc_;
|
||||
}
|
||||
#endif
|
||||
#endif // FORMMINIPAGE_H
|
||||
|
@ -8,83 +8,52 @@
|
||||
|
||||
#include <config.h>
|
||||
|
||||
#include FORMS_H_LOCATION
|
||||
|
||||
#ifdef __GNUG__
|
||||
#pragma implementation
|
||||
#endif
|
||||
|
||||
#include "form_preamble.h"
|
||||
#include "xformsBC.h"
|
||||
#include "ControlPreamble.h"
|
||||
#include "FormPreamble.h"
|
||||
#include "Dialogs.h"
|
||||
#include "Liason.h"
|
||||
#include "LyXView.h"
|
||||
#include "buffer.h"
|
||||
#include "gettext.h"
|
||||
#include "form_preamble.h"
|
||||
#include "xforms_helpers.h"
|
||||
|
||||
using Liason::setMinibuffer;
|
||||
using SigC::slot;
|
||||
typedef FormCB<ControlPreamble, FormDB<FD_form_preamble> > base_class;
|
||||
|
||||
FormPreamble::FormPreamble(LyXView * lv, Dialogs * d)
|
||||
: FormBaseBD(lv, d, _("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;
|
||||
}
|
||||
FormPreamble::FormPreamble(ControlPreamble & c)
|
||||
: base_class(c, _("LaTeX preamble"))
|
||||
{}
|
||||
|
||||
|
||||
void FormPreamble::build()
|
||||
{
|
||||
dialog_.reset(build_preamble());
|
||||
dialog_.reset(build_preamble());
|
||||
|
||||
fl_set_input_return(dialog_->input_preamble, FL_RETURN_CHANGED);
|
||||
// Manage the ok, apply and cancel/close buttons
|
||||
bc().setOK(dialog_->button_ok);
|
||||
bc().setApply(dialog_->button_apply);
|
||||
bc().setCancel(dialog_->button_cancel);
|
||||
bc().addReadOnly(dialog_->input_preamble);
|
||||
bc().refresh();
|
||||
fl_set_input_return(dialog_->input_preamble, FL_RETURN_CHANGED);
|
||||
|
||||
// Manage the ok, apply and cancel/close buttons
|
||||
bc().setOK(dialog_->button_ok);
|
||||
bc().setApply(dialog_->button_apply);
|
||||
bc().setCancel(dialog_->button_cancel);
|
||||
bc().addReadOnly(dialog_->input_preamble);
|
||||
bc().refresh();
|
||||
}
|
||||
|
||||
|
||||
void FormPreamble::apply()
|
||||
{
|
||||
if (!lv_->view()->available() || !dialog_.get())
|
||||
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"));
|
||||
controller().params() = fl_get_input(dialog_->input_preamble);
|
||||
}
|
||||
|
||||
|
||||
void FormPreamble::update()
|
||||
{
|
||||
if (!dialog_.get())
|
||||
return;
|
||||
fl_set_input(dialog_->input_preamble, controller().params().c_str());
|
||||
|
||||
fl_set_input(dialog_->input_preamble,lv_->buffer()->params.preamble.c_str());
|
||||
|
||||
bool const enable = (! lv_->buffer()->isReadonly());
|
||||
setEnabled(dialog_->input_preamble, enable);
|
||||
setEnabled(dialog_->button_ok, enable);
|
||||
setEnabled(dialog_->button_apply, enable);
|
||||
|
||||
// need this?
|
||||
// bc().readOnly(lv_->buffer()->isReadonly());
|
||||
bool const enable = (!controller().isReadonly());
|
||||
setEnabled(dialog_->input_preamble, enable);
|
||||
setEnabled(dialog_->button_ok, enable);
|
||||
setEnabled(dialog_->button_apply, enable);
|
||||
}
|
||||
|
||||
|
||||
|
@ -1,4 +1,3 @@
|
||||
// -*- C++ -*-
|
||||
/**
|
||||
* \file FormPreamble.h
|
||||
* Copyright 2001 The LyX Team.
|
||||
@ -10,51 +9,32 @@
|
||||
#ifndef FORMPREAMBLE_H
|
||||
#define FORMPREAMBLE_H
|
||||
|
||||
#include <boost/smart_ptr.hpp>
|
||||
|
||||
#ifdef __GNUG__
|
||||
#pragma interface
|
||||
#endif
|
||||
|
||||
#include "FormBaseDeprecated.h"
|
||||
#include "FormBase.h"
|
||||
|
||||
class ControlPreamble;
|
||||
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:
|
||||
///
|
||||
FormPreamble(LyXView *, Dialogs *);
|
||||
FormPreamble(ControlPreamble &);
|
||||
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
|
||||
virtual void apply();
|
||||
/// Build the popup
|
||||
virtual void build();
|
||||
/// Update the popup.
|
||||
virtual void update();
|
||||
///
|
||||
virtual FL_FORM * form() const;
|
||||
|
||||
/// Fdesign generated method
|
||||
FD_form_preamble * build_preamble();
|
||||
|
||||
/// Real GUI implementation.
|
||||
boost::scoped_ptr<FD_form_preamble> dialog_;
|
||||
/// The ButtonController
|
||||
ButtonController<NoRepeatedApplyReadOnlyPolicy, xformsBC> bc_;
|
||||
};
|
||||
|
||||
|
||||
inline
|
||||
xformsBC & FormPreamble::bc()
|
||||
{
|
||||
return bc_;
|
||||
}
|
||||
#endif
|
||||
#endif // FORMPREAMBLE_H
|
||||
|
@ -35,7 +35,7 @@ FD_form_minipage * FormMinipage::build_minipage()
|
||||
fl_set_button_shortcut(obj, scex(_(dummy)), 1);
|
||||
}
|
||||
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
|
||||
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_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"));
|
||||
fl_set_object_lsize(obj, FL_NORMAL_SIZE);
|
||||
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_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");
|
||||
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_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");
|
||||
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_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();
|
||||
|
||||
{
|
||||
@ -83,24 +83,24 @@ FD_form_minipage * FormMinipage::build_minipage()
|
||||
fl_set_button_shortcut(obj, scex(_(dummy)), 1);
|
||||
}
|
||||
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");
|
||||
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_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"));
|
||||
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");
|
||||
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_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();
|
||||
|
||||
fdui->form->fdui = fdui;
|
||||
|
@ -5,11 +5,11 @@
|
||||
#define FD_form_minipage_h_
|
||||
|
||||
/** Callbacks, globals and object handlers **/
|
||||
extern "C" void C_FormBaseDeprecatedInputCB(FL_OBJECT *, long);
|
||||
extern "C" void C_FormBaseDeprecatedCancelCB(FL_OBJECT *, long);
|
||||
extern "C" void C_FormBaseDeprecatedApplyCB(FL_OBJECT *, long);
|
||||
extern "C" void C_FormBaseDeprecatedOKCB(FL_OBJECT *, long);
|
||||
extern "C" void C_FormBaseDeprecatedRestoreCB(FL_OBJECT *, long);
|
||||
extern "C" void C_FormBaseInputCB(FL_OBJECT *, long);
|
||||
extern "C" void C_FormBaseCancelCB(FL_OBJECT *, long);
|
||||
extern "C" void C_FormBaseApplyCB(FL_OBJECT *, long);
|
||||
extern "C" void C_FormBaseOKCB(FL_OBJECT *, long);
|
||||
extern "C" void C_FormBaseRestoreCB(FL_OBJECT *, long);
|
||||
|
||||
|
||||
/**** Forms and Objects ****/
|
||||
|
@ -32,7 +32,7 @@ FD_form_preamble * FormPreamble::build_preamble()
|
||||
}
|
||||
fl_set_object_lsize(obj, FL_NORMAL_SIZE);
|
||||
fl_set_object_gravity(obj, FL_SouthEast, FL_SouthEast);
|
||||
fl_set_object_callback(obj, C_FormBaseDeprecatedOKCB, 0);
|
||||
fl_set_object_callback(obj, C_FormBaseOKCB, 0);
|
||||
{
|
||||
char const * const dummy = N_("Apply|#A");
|
||||
fdui->button_apply = obj = fl_add_button(FL_NORMAL_BUTTON, 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_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|^[");
|
||||
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_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, "");
|
||||
fl_set_object_lsize(obj, FL_NORMAL_SIZE);
|
||||
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();
|
||||
|
||||
fdui->form->fdui = fdui;
|
||||
|
@ -5,10 +5,10 @@
|
||||
#define FD_form_preamble_h_
|
||||
|
||||
/** Callbacks, globals and object handlers **/
|
||||
extern "C" void C_FormBaseDeprecatedOKCB(FL_OBJECT *, long);
|
||||
extern "C" void C_FormBaseDeprecatedApplyCB(FL_OBJECT *, long);
|
||||
extern "C" void C_FormBaseDeprecatedCancelCB(FL_OBJECT *, long);
|
||||
extern "C" void C_FormBaseDeprecatedInputCB(FL_OBJECT *, long);
|
||||
extern "C" void C_FormBaseOKCB(FL_OBJECT *, long);
|
||||
extern "C" void C_FormBaseApplyCB(FL_OBJECT *, long);
|
||||
extern "C" void C_FormBaseCancelCB(FL_OBJECT *, long);
|
||||
extern "C" void C_FormBaseInputCB(FL_OBJECT *, long);
|
||||
|
||||
|
||||
/**** Forms and Objects ****/
|
||||
|
@ -81,7 +81,7 @@ shortcut:
|
||||
resize: FL_RESIZE_ALL
|
||||
gravity: FL_NoGravity FL_NoGravity
|
||||
name: input_width
|
||||
callback: C_FormBaseDeprecatedInputCB
|
||||
callback: C_FormBaseInputCB
|
||||
argument: 0
|
||||
|
||||
--------------------
|
||||
@ -99,7 +99,7 @@ shortcut:
|
||||
resize: FL_RESIZE_ALL
|
||||
gravity: FL_NoGravity FL_NoGravity
|
||||
name: input_widthp
|
||||
callback: C_FormBaseDeprecatedInputCB
|
||||
callback: C_FormBaseInputCB
|
||||
argument: 0
|
||||
|
||||
--------------------
|
||||
@ -171,7 +171,7 @@ shortcut:
|
||||
resize: FL_RESIZE_ALL
|
||||
gravity: FL_NoGravity FL_NoGravity
|
||||
name: radio_top
|
||||
callback: C_FormBaseDeprecatedInputCB
|
||||
callback: C_FormBaseInputCB
|
||||
argument: 0
|
||||
|
||||
--------------------
|
||||
@ -189,7 +189,7 @@ shortcut:
|
||||
resize: FL_RESIZE_ALL
|
||||
gravity: FL_NoGravity FL_NoGravity
|
||||
name: radio_middle
|
||||
callback: C_FormBaseDeprecatedInputCB
|
||||
callback: C_FormBaseInputCB
|
||||
argument: 0
|
||||
|
||||
--------------------
|
||||
@ -207,7 +207,7 @@ shortcut:
|
||||
resize: FL_RESIZE_ALL
|
||||
gravity: FL_NoGravity FL_NoGravity
|
||||
name: radio_bottom
|
||||
callback: C_FormBaseDeprecatedInputCB
|
||||
callback: C_FormBaseInputCB
|
||||
argument: 0
|
||||
|
||||
--------------------
|
||||
@ -243,7 +243,7 @@ shortcut:
|
||||
resize: FL_RESIZE_ALL
|
||||
gravity: FL_NoGravity FL_NoGravity
|
||||
name: button_cancel
|
||||
callback: C_FormBaseDeprecatedCancelCB
|
||||
callback: C_FormBaseCancelCB
|
||||
argument: 0
|
||||
|
||||
--------------------
|
||||
@ -261,7 +261,7 @@ shortcut:
|
||||
resize: FL_RESIZE_ALL
|
||||
gravity: FL_NoGravity FL_NoGravity
|
||||
name: button_apply
|
||||
callback: C_FormBaseDeprecatedApplyCB
|
||||
callback: C_FormBaseApplyCB
|
||||
argument: 0
|
||||
|
||||
--------------------
|
||||
@ -279,7 +279,7 @@ shortcut: ^M
|
||||
resize: FL_RESIZE_ALL
|
||||
gravity: FL_NoGravity FL_NoGravity
|
||||
name: button_ok
|
||||
callback: C_FormBaseDeprecatedOKCB
|
||||
callback: C_FormBaseOKCB
|
||||
argument: 0
|
||||
|
||||
--------------------
|
||||
@ -297,7 +297,7 @@ shortcut:
|
||||
resize: FL_RESIZE_ALL
|
||||
gravity: FL_NoGravity FL_NoGravity
|
||||
name: button_restore
|
||||
callback: C_FormBaseDeprecatedRestoreCB
|
||||
callback: C_FormBaseRestoreCB
|
||||
argument: 0
|
||||
|
||||
==============================
|
||||
|
@ -46,7 +46,7 @@ shortcut:
|
||||
resize: FL_RESIZE_NONE
|
||||
gravity: FL_SouthEast FL_SouthEast
|
||||
name: button_ok
|
||||
callback: C_FormBaseDeprecatedOKCB
|
||||
callback: C_FormBaseOKCB
|
||||
argument: 0
|
||||
|
||||
--------------------
|
||||
@ -64,7 +64,7 @@ shortcut:
|
||||
resize: FL_RESIZE_NONE
|
||||
gravity: FL_SouthEast FL_SouthEast
|
||||
name: button_apply
|
||||
callback: C_FormBaseDeprecatedApplyCB
|
||||
callback: C_FormBaseApplyCB
|
||||
argument: 0
|
||||
|
||||
--------------------
|
||||
@ -82,7 +82,7 @@ shortcut:
|
||||
resize: FL_RESIZE_NONE
|
||||
gravity: FL_SouthEast FL_SouthEast
|
||||
name: button_cancel
|
||||
callback: C_FormBaseDeprecatedCancelCB
|
||||
callback: C_FormBaseCancelCB
|
||||
argument: 0
|
||||
|
||||
--------------------
|
||||
@ -100,7 +100,7 @@ shortcut:
|
||||
resize: FL_RESIZE_ALL
|
||||
gravity: FL_NorthWest FL_SouthEast
|
||||
name: input_preamble
|
||||
callback: C_FormBaseDeprecatedInputCB
|
||||
callback: C_FormBaseInputCB
|
||||
argument:
|
||||
|
||||
==============================
|
||||
|
Loading…
Reference in New Issue
Block a user