Move 4 of the xforms math (sub) dialogs to the new scheme.

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@7178 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
Angus Leeming 2003-06-17 10:30:38 +00:00
parent 9e50499320
commit 8b5b727d52
20 changed files with 157 additions and 104 deletions

View File

@ -1,6 +1,10 @@
2003-06-17 Angus Leeming <leeming@lyx.org>
* ControlMath2.[Ch] (showDialog): new member function.
* ControlMath.[Ch] (showDialog):
* ControlMath2.[Ch] (showDialog, dispatchFunc): new member functions.
* ControlMath2.C: wrap all other calls to the kernel diapatcher into
dispatchFunc.
2003-06-12 Angus Leeming <leeming@lyx.org>

View File

@ -51,6 +51,12 @@ void ControlMath::insertSymbol(string const & sym, bool bs) const
}
void ControlMath::showDialog(string const & name) const
{
lv_.dispatch(FuncRequest(LFUN_DIALOG_SHOW, name));
}
void ControlMath::addDaughter(void * key, ViewBase * v,
BCView * bcview, ButtonPolicy * bcpolicy)
{

View File

@ -43,6 +43,8 @@ public:
BCView * bc, ButtonPolicy * bcpolicy);
///
void showDaughter(void *);
/// a request to launch dialog \param name.
void showDialog(string const & name) const;
private:
///

View File

@ -20,52 +20,57 @@ ControlMath2::ControlMath2(Dialog & dialog)
{}
void ControlMath2::dispatchFunc(kb_action action, string const & arg) const
{
kernel().dispatch(FuncRequest(action, arg));
}
void ControlMath2::dispatchInsert(string const & name) const
{
kernel().dispatch(FuncRequest(LFUN_INSERT_MATH, '\\' + name));
dispatchFunc(LFUN_INSERT_MATH, '\\' + name);
}
void ControlMath2::dispatchSubscript() const
{
kernel().dispatch(FuncRequest(LFUN_SUBSCRIPT));
dispatchFunc(LFUN_SUBSCRIPT);
}
void ControlMath2::dispatchSuperscript() const
{
kernel().dispatch(FuncRequest(LFUN_SUPERSCRIPT));
dispatchFunc(LFUN_SUPERSCRIPT);
}
void ControlMath2::dispatchCubeRoot() const
{
kernel().dispatch(FuncRequest(LFUN_INSERT_MATH, "\\root"));
kernel().dispatch(FuncRequest(LFUN_SELFINSERT, "3"));
kernel().dispatch(FuncRequest(LFUN_RIGHT));
dispatchFunc(LFUN_INSERT_MATH, "\\root");
dispatchFunc(LFUN_SELFINSERT, "3");
dispatchFunc(LFUN_RIGHT);
}
void ControlMath2::dispatchMatrix(string const & str) const
{
kernel().dispatch(FuncRequest(LFUN_INSERT_MATRIX, str));
dispatchFunc(LFUN_INSERT_MATRIX, str);
}
void ControlMath2::dispatchDelim(string const & str) const
{
kernel().dispatch(FuncRequest(LFUN_MATH_DELIM, str));
dispatchFunc(LFUN_MATH_DELIM, str);
}
void ControlMath2::dispatchToggleDisplay() const
{
kernel().dispatch(FuncRequest(LFUN_MATH_DISPLAY));
dispatchFunc(LFUN_MATH_DISPLAY);
}
void ControlMath2::showDialog(string const & name) const
{
kernel().dispatch(FuncRequest(LFUN_DIALOG_SHOW, name));
dispatchFunc(LFUN_DIALOG_SHOW, name);
}

View File

@ -16,6 +16,7 @@
#include "Dialog.h"
#include "lfuns.h" // for kb_action
class ControlMath2 : public Dialog::Controller {
@ -27,6 +28,8 @@ public:
virtual void dispatchParams() {}
virtual bool isBufferDependent() const { return true; }
/// dispatch an LFUN
void dispatchFunc(kb_action action, string const & arg = string()) const;
/// Insert a math symbol into the doc.
void dispatchInsert(string const & name) const;
/// Insert a subscript.

View File

@ -1,3 +1,17 @@
2003-06-17 Angus Leeming <leeming@lyx.org>
* FormMathsDelim.[Ch]:
* forms/form_maths_delim.fd:
* FormMathsMatrix.[Ch]:
* forms/form_maths_matrix.fd:
* FormMathsPanel.C:
* FormMathsSpace.[Ch]:
* forms/form_maths_space.fd:
* FormMathsStyle.[Ch]:
* forms/form_maths_style.fd:
* Dialogs.C: convert FormMathsDelim, FormMathsMatrix, FormMathsSpace and
FormMathsStyle to the new Dialog-based scheme.
2003-06-12 Angus Leeming <leeming@lyx.org>
* FormExternal.C (input): do not activate Ok, Apply when clicking on

View File

@ -29,6 +29,7 @@
#include "ControlGraphics.h"
#include "ControlInclude.h"
#include "ControlLog.h"
#include "ControlMath2.h"
#include "ControlMinipage.h"
#include "ControlParagraph.h"
#include "ControlRef.h"
@ -53,6 +54,10 @@
#include "FormGraphics.h"
#include "FormInclude.h"
#include "FormLog.h"
#include "FormMathsDelim.h"
#include "FormMathsMatrix.h"
#include "FormMathsSpace.h"
#include "FormMathsStyle.h"
#include "FormMinipage.h"
#include "FormParagraph.h"
#include "FormRef.h"
@ -76,7 +81,11 @@
namespace {
char const * const dialognames[] = { "about", "bibitem", "bibtex", "changes", "character", "citation", "error", "errorlist" , "ert", "external", "file", "float", "graphics", "include", "index", "label", "log", "minipage", "paragraph", "ref", "tabular", "tabularcreate",
char const * const dialognames[] = { "about", "bibitem", "bibtex", "changes",
"character", "citation", "error", "errorlist" , "ert", "external", "file",
"float", "graphics", "include", "index", "label", "log",
"mathdelimiter", "mathmatrix", "mathspace", "mathstyle",
"minipage", "paragraph", "ref", "tabular", "tabularcreate",
#ifdef HAVE_LIBAIKSAURUS
"thesaurus",
@ -185,6 +194,22 @@ Dialog * Dialogs::build(string const & name)
dialog->setController(new ControlLog(*dialog));
dialog->setView(new FormLog(*dialog));
dialog->bc().bp(new OkCancelPolicy);
} else if (name == "mathdelimiter") {
dialog->setController(new ControlMath2(*dialog));
dialog->setView(new FormMathsDelim(*dialog));
dialog->bc().bp(new OkApplyCancelReadOnlyPolicy);
} else if (name == "mathmatrix") {
dialog->setController(new ControlMath2(*dialog));
dialog->setView(new FormMathsMatrix(*dialog));
dialog->bc().bp(new OkApplyCancelReadOnlyPolicy);
} else if (name == "mathspace") {
dialog->setController(new ControlMath2(*dialog));
dialog->setView(new FormMathsSpace(*dialog));
dialog->bc().bp(new IgnorantPolicy);
} else if (name == "mathstyle") {
dialog->setController(new ControlMath2(*dialog));
dialog->setView(new FormMathsStyle(*dialog));
dialog->bc().bp(new IgnorantPolicy);
} else if (name == "minipage") {
dialog->setController(new ControlMinipage(*dialog));
dialog->setView(new FormMinipage(*dialog));

View File

@ -16,7 +16,7 @@
#include "FormMathsDelim.h"
#include "forms/form_maths_delim.h"
#include "ControlMath.h"
#include "ControlMath2.h"
#include "xformsBC.h"
#include "ButtonController.h"
@ -49,10 +49,10 @@ static char const * delim_values[] = {
using std::endl;
typedef FormCB<ControlMathSub, FormDB<FD_maths_delim> > base_class;
typedef FormController<ControlMath2, FormView<FD_maths_delim> > base_class;
FormMathsDelim::FormMathsDelim()
: base_class(_("Math Delimiters"), false)
FormMathsDelim::FormMathsDelim(Dialog & parent)
: base_class(parent, _("Math Delimiters"), false)
{}
@ -90,7 +90,7 @@ void FormMathsDelim::apply()
ostringstream os;
os << delim_values[left] << ' ' << delim_values[right];
controller().dispatchFunc(LFUN_MATH_DELIM, STRCONV(os.str()));
controller().dispatchDelim(STRCONV(os.str()));
}

View File

@ -15,18 +15,20 @@
#define FORM_MATHSDELIM_H
#include "FormBase.h"
#include "FormDialogView.h"
class ControlMathSub;
class ControlMath2;
struct FD_maths_delim;
/**
* This class provides an XForms implementation of the maths delim.
*/
class FormMathsDelim : public FormCB<ControlMathSub, FormDB<FD_maths_delim> > {
class FormMathsDelim
: public FormController<ControlMath2, FormView<FD_maths_delim> > {
public:
///
FormMathsDelim();
FormMathsDelim(Dialog &);
private:
///

View File

@ -16,7 +16,7 @@
#include "FormMathsMatrix.h"
#include "forms/form_maths_matrix.h"
#include "ControlMath.h"
#include "ControlMath2.h"
#include "xformsBC.h"
#include "ButtonController.h"
@ -54,10 +54,10 @@ extern "C" {
}
typedef FormCB<ControlMathSub, FormDB<FD_maths_matrix> > base_class;
typedef FormController<ControlMath2, FormView<FD_maths_matrix> > base_class;
FormMathsMatrix::FormMathsMatrix()
: base_class(_("Math Matrix"), false)
FormMathsMatrix::FormMathsMatrix(Dialog & parent)
: base_class(parent, _("Math Matrix"), false)
{}
@ -94,7 +94,7 @@ void FormMathsMatrix::apply()
ostringstream os;
os << nx << ' ' << ny << ' ' << c << ' ' << sh;
controller().dispatchFunc(LFUN_INSERT_MATRIX, STRCONV(os.str()));
controller().dispatchMatrix(STRCONV(os.str()));
}

View File

@ -15,19 +15,20 @@
#define FORM_MATHSMATRIX_H
#include "FormBase.h"
#include "FormDialogView.h"
class ControlMathSub;
class ControlMath2;
struct FD_maths_matrix;
/**
* This class provides an XForms implementation of the maths matrix.
*/
class FormMathsMatrix : public FormCB<ControlMathSub, FormDB<FD_maths_matrix> >
{
class FormMathsMatrix
: public FormController<ControlMath2, FormView<FD_maths_matrix> > {
public:
///
FormMathsMatrix();
FormMathsMatrix(Dialog &);
///
int AlignFilter(char const *, int);

View File

@ -20,10 +20,6 @@
#include "xformsBC.h"
#include "FormMathsBitmap.h"
#include "FormMathsDelim.h"
#include "FormMathsMatrix.h"
#include "FormMathsSpace.h"
#include "FormMathsStyle.h"
#include "forms/form_maths_delim.h"
#include "forms/form_maths_matrix.h"
@ -111,23 +107,6 @@ void FormMathsPanel::build()
fl_set_pixmap_data(dialog_->button_equation,
const_cast<char**>(equation));
controller().addDaughter(dialog_->button_delim,
new FormMathsDelim,
new xformsBC(controller().bc()),
new OkApplyCancelReadOnlyPolicy);
controller().addDaughter(dialog_->button_matrix,
new FormMathsMatrix,
new xformsBC(controller().bc()),
new OkApplyCancelReadOnlyPolicy);
controller().addDaughter(dialog_->button_space,
new FormMathsSpace,
new xformsBC(controller().bc()),
new IgnorantPolicy);
controller().addDaughter(dialog_->button_style,
new FormMathsStyle,
new xformsBC(controller().bc()),
new IgnorantPolicy);
FormMathsBitmap * bitmap;
bitmap = addDaughter(dialog_->button_deco,
_("Maths Decorations & Accents"),
@ -212,13 +191,21 @@ ButtonPolicy::SMInput FormMathsPanel::input(FL_OBJECT * ob, long)
ob == dialog_->button_ams_brel ||
ob == dialog_->button_ams_nrel ||
ob == dialog_->button_ams_ops ||
ob == dialog_->button_delim ||
ob == dialog_->button_matrix ||
ob == dialog_->button_deco ||
ob == dialog_->button_space ||
ob == dialog_->button_style) {
ob == dialog_->button_deco) {
controller().showDaughter(ob);
} else if (ob == dialog_->button_delim) {
controller().showDialog("mathdelimiter");
} else if (ob == dialog_->button_matrix) {
controller().showDialog("mathmatrix");
} else if (ob == dialog_->button_space) {
controller().showDialog("mathspace");
} else if (ob == dialog_->button_style) {
controller().showDialog("mathstyle");
} else if (ob == dialog_->button_super) {
controller().dispatchFunc(LFUN_SUPERSCRIPT);

View File

@ -16,17 +16,17 @@
#include "FormMathsSpace.h"
#include "forms/form_maths_space.h"
#include "ControlMath.h"
#include "ControlMath2.h"
#include "xformsBC.h"
#include "lyx_forms.h"
extern char * latex_mathspace[];
typedef FormCB<ControlMathSub, FormDB<FD_maths_space> > base_class;
typedef FormController<ControlMath2, FormView<FD_maths_space> > base_class;
FormMathsSpace::FormMathsSpace()
: base_class(_("Math Spacing"), false),
FormMathsSpace::FormMathsSpace(Dialog & parent)
: base_class(parent, _("Math Spacing"), false),
space_(-1)
{}
@ -53,7 +53,7 @@ void FormMathsSpace::build()
void FormMathsSpace::apply()
{
if (space_ >= 0)
controller().insertSymbol(latex_mathspace[space_]);
controller().dispatchInsert(latex_mathspace[space_]);
}
ButtonPolicy::SMInput FormMathsSpace::input(FL_OBJECT *, long data)

View File

@ -15,18 +15,20 @@
#define FORM_MATHSSPACE_H
#include "FormBase.h"
#include "FormDialogView.h"
class ControlMathSub;
class ControlMath2;
struct FD_maths_space;
/**
* This class provides an XForms implementation of the maths space.
*/
class FormMathsSpace : public FormCB<ControlMathSub, FormDB<FD_maths_space> > {
class FormMathsSpace
: public FormController<ControlMath2, FormView<FD_maths_space> > {
public:
///
FormMathsSpace();
FormMathsSpace(Dialog &);
private:
///

View File

@ -17,7 +17,7 @@
#include "FormMathsStyle.h"
#include "forms/form_maths_style.h"
#include "ControlMath.h"
#include "ControlMath2.h"
#include "xformsBC.h"
#include "bmtable.h"
@ -37,10 +37,10 @@ kb_action latex_mathfontcmds[] = {
};
typedef FormCB<ControlMathSub, FormDB<FD_maths_style> > base_class;
typedef FormController<ControlMath2, FormView<FD_maths_style> > base_class;
FormMathsStyle::FormMathsStyle()
: base_class(_("Math Styles & Fonts"), false),
FormMathsStyle::FormMathsStyle(Dialog & parent)
: base_class(parent, _("Math Styles & Fonts"), false),
style_(-1)
{}
@ -76,7 +76,7 @@ void FormMathsStyle::build()
void FormMathsStyle::apply()
{
if ((style_ >= 0) && (style_ < 4))
controller().insertSymbol(latex_mathstyle[style_]);
controller().dispatchInsert(latex_mathstyle[style_]);
else if ((style_ >= 4) && (style_ < 14))
controller().dispatchFunc(latex_mathfontcmds[style_-4]);
}

View File

@ -15,18 +15,20 @@
#define FORM_MATHSSTYLE_H
#include "FormBase.h"
#include "FormDialogView.h"
class ControlMathSub;
class ControlMath2;
struct FD_maths_style;
/**
* This class provides an XForms implementation of the maths style.
*/
class FormMathsStyle : public FormCB<ControlMathSub, FormDB<FD_maths_style> > {
class FormMathsStyle
: public FormController<ControlMath2, FormView<FD_maths_style> > {
public:
///
FormMathsStyle();
FormMathsStyle(Dialog &);
private:
///

View File

@ -46,7 +46,7 @@ shortcut:
resize: FL_RESIZE_ALL
gravity: FL_NoGravity FL_NoGravity
name: bmtable
callback: C_FormBaseInputCB
callback: C_FormDialogView_InputCB
argument: 0
--------------------
@ -64,7 +64,7 @@ shortcut:
resize: FL_RESIZE_ALL
gravity: FL_NoGravity FL_NoGravity
name: button_close
callback: C_FormBaseCancelCB
callback: C_FormDialogView_CancelCB
argument: 0
--------------------
@ -82,7 +82,7 @@ shortcut:
resize: FL_RESIZE_ALL
gravity: FL_NoGravity FL_NoGravity
name: button_pix
callback: C_FormBaseApplyCB
callback: C_FormDialogView_ApplyCB
argument: 0
--------------------
@ -100,7 +100,7 @@ shortcut:
resize: FL_RESIZE_ALL
gravity: FL_NoGravity FL_NoGravity
name: button_apply
callback: C_FormBaseApplyCB
callback: C_FormDialogView_ApplyCB
argument: 0
--------------------
@ -118,7 +118,7 @@ shortcut: ^M
resize: FL_RESIZE_ALL
gravity: FL_NoGravity FL_NoGravity
name: button_ok
callback: C_FormBaseOKCB
callback: C_FormDialogView_OKCB
argument: 0
--------------------

View File

@ -46,7 +46,7 @@ shortcut:
resize: FL_RESIZE_ALL
gravity: FL_NoGravity FL_NoGravity
name: slider_rows
callback: C_FormBaseInputCB
callback: C_FormDialogView_InputCB
argument: 0
bounds: 1 20
precision: 0
@ -67,7 +67,7 @@ shortcut:
resize: FL_RESIZE_ALL
gravity: FL_NoGravity FL_NoGravity
name: slider_columns
callback: C_FormBaseInputCB
callback: C_FormDialogView_InputCB
argument: 0
bounds: 1 20
precision: 0
@ -88,7 +88,7 @@ shortcut:
resize: FL_RESIZE_ALL
gravity: FL_NoGravity FL_NoGravity
name: choice_valign
callback: C_FormBaseInputCB
callback: C_FormDialogView_InputCB
argument: 0
--------------------
@ -106,7 +106,7 @@ shortcut:
resize: FL_RESIZE_ALL
gravity: FL_NoGravity FL_NoGravity
name: input_halign
callback: C_FormBaseInputCB
callback: C_FormDialogView_InputCB
argument: 0
--------------------
@ -124,7 +124,7 @@ shortcut: ^M
resize: FL_RESIZE_ALL
gravity: FL_NoGravity FL_NoGravity
name: button_ok
callback: C_FormBaseOKCB
callback: C_FormDialogView_OKCB
argument: 0
--------------------
@ -142,7 +142,7 @@ shortcut:
resize: FL_RESIZE_ALL
gravity: FL_NoGravity FL_NoGravity
name: button_apply
callback: C_FormBaseApplyCB
callback: C_FormDialogView_ApplyCB
argument: 0
--------------------
@ -160,7 +160,7 @@ shortcut:
resize: FL_RESIZE_ALL
gravity: FL_NoGravity FL_NoGravity
name: button_close
callback: C_FormBaseCancelCB
callback: C_FormDialogView_CancelCB
argument: 0
==============================

View File

@ -64,7 +64,7 @@ shortcut:
resize: FL_RESIZE_ALL
gravity: FL_NoGravity FL_NoGravity
name: button_negative
callback: C_FormBaseInputCB
callback: C_FormDialogView_InputCB
argument: 0
--------------------
@ -82,7 +82,7 @@ shortcut:
resize: FL_RESIZE_ALL
gravity: FL_NoGravity FL_NoGravity
name: button_negmedspace
callback: C_FormBaseInputCB
callback: C_FormDialogView_InputCB
argument: 1
--------------------
@ -100,7 +100,7 @@ shortcut:
resize: FL_RESIZE_ALL
gravity: FL_NoGravity FL_NoGravity
name: button_negthickspace
callback: C_FormBaseInputCB
callback: C_FormDialogView_InputCB
argument: 2
--------------------
@ -118,7 +118,7 @@ shortcut:
resize: FL_RESIZE_ALL
gravity: FL_NoGravity FL_NoGravity
name: button_thick
callback: C_FormBaseInputCB
callback: C_FormDialogView_InputCB
argument: 5
--------------------
@ -136,7 +136,7 @@ shortcut:
resize: FL_RESIZE_ALL
gravity: FL_NoGravity FL_NoGravity
name: button_twoquadratin
callback: C_FormBaseInputCB
callback: C_FormDialogView_InputCB
argument: 7
--------------------
@ -172,7 +172,7 @@ shortcut: ^M
resize: FL_RESIZE_ALL
gravity: FL_NoGravity FL_NoGravity
name: button_close
callback: C_FormBaseCancelCB
callback: C_FormDialogView_CancelCB
argument: 0
--------------------
@ -190,7 +190,7 @@ shortcut:
resize: FL_RESIZE_ALL
gravity: FL_NoGravity FL_NoGravity
name: button_quadratin
callback: C_FormBaseInputCB
callback: C_FormDialogView_InputCB
argument: 6
--------------------
@ -208,7 +208,7 @@ shortcut:
resize: FL_RESIZE_ALL
gravity: FL_NoGravity FL_NoGravity
name: button_thin
callback: C_FormBaseInputCB
callback: C_FormDialogView_InputCB
argument: 3
--------------------
@ -226,7 +226,7 @@ shortcut:
resize: FL_RESIZE_ALL
gravity: FL_NoGravity FL_NoGravity
name: button_medium
callback: C_FormBaseInputCB
callback: C_FormDialogView_InputCB
argument: 4
==============================

View File

@ -46,7 +46,7 @@ shortcut:
resize: FL_RESIZE_ALL
gravity: FL_NoGravity FL_NoGravity
name: bmtable_font2
callback: C_FormBaseInputCB
callback: C_FormDialogView_InputCB
argument: 0
--------------------
@ -64,7 +64,7 @@ shortcut:
resize: FL_RESIZE_ALL
gravity: FL_NoGravity FL_NoGravity
name: bmtable_style1
callback: C_FormBaseInputCB
callback: C_FormDialogView_InputCB
argument: 0
--------------------
@ -82,7 +82,7 @@ shortcut: ^M
resize: FL_RESIZE_ALL
gravity: FL_NoGravity FL_NoGravity
name: button_close
callback: C_FormBaseCancelCB
callback: C_FormDialogView_CancelCB
argument: 0
--------------------
@ -100,7 +100,7 @@ shortcut:
resize: FL_RESIZE_ALL
gravity: FL_NoGravity FL_NoGravity
name: bmtable_style2
callback: C_FormBaseInputCB
callback: C_FormDialogView_InputCB
argument: 0
--------------------
@ -118,7 +118,7 @@ shortcut:
resize: FL_RESIZE_ALL
gravity: FL_NoGravity FL_NoGravity
name: bmtable_font1
callback: C_FormBaseInputCB
callback: C_FormDialogView_InputCB
argument: 0
--------------------
@ -136,7 +136,7 @@ shortcut:
resize: FL_RESIZE_ALL
gravity: FL_NoGravity FL_NoGravity
name: button_reset
callback: C_FormBaseInputCB
callback: C_FormDialogView_InputCB
argument: 13
--------------------
@ -154,7 +154,7 @@ shortcut:
resize: FL_RESIZE_ALL
gravity: FL_NoGravity FL_NoGravity
name: button_textrm
callback: C_FormBaseInputCB
callback: C_FormDialogView_InputCB
argument: 12
==============================