Convert FormMathsBitmap to the new scheme.

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@7179 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
Angus Leeming 2003-06-17 12:15:58 +00:00
parent 8b5b727d52
commit 256064c765
6 changed files with 245 additions and 162 deletions

View File

@ -1,16 +1,17 @@
2003-06-17 Angus Leeming <leeming@lyx.org>
* FormMathsBitmap.[Ch]:
* FormMathsDelim.[Ch]:
* forms/form_maths_delim.fd:
* FormMathsMatrix.[Ch]:
* forms/form_maths_matrix.fd:
* FormMathsPanel.C:
* FormMathsPanel.[Ch]:
* 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.
* Dialogs.C: convert FormMathsBitmap, FormMathsDelim, FormMathsMatrix,
FormMathsSpace and FormMathsStyle to the new Dialog-based scheme.
2003-06-12 Angus Leeming <leeming@lyx.org>

View File

@ -54,6 +54,7 @@
#include "FormGraphics.h"
#include "FormInclude.h"
#include "FormLog.h"
#include "FormMathsBitmap.h"
#include "FormMathsDelim.h"
#include "FormMathsMatrix.h"
#include "FormMathsSpace.h"
@ -78,12 +79,40 @@
#include "xformsBC.h"
#include "ButtonController.h"
#include "arrows.xbm"
#include "bop.xbm"
#include "brel.xbm"
#include "deco.xbm"
#include "dots.xbm"
#include "greek.xbm"
#include "misc.xbm"
#include "varsz.xbm"
#include "ams_misc.xbm"
#include "ams_arrows.xbm"
#include "ams_rel.xbm"
#include "ams_nrel.xbm"
#include "ams_ops.xbm"
#include <vector>
namespace {
FormMathsBitmap * createFormBitmap(Dialog & parent, string const & title,
char const * const * data, int size)
{
char const * const * const end = data + size;
return new FormMathsBitmap(parent, title, std::vector<string>(data, end));
}
char const * const dialognames[] = { "about", "bibitem", "bibtex", "changes",
"character", "citation", "error", "errorlist" , "ert", "external", "file",
"float", "graphics", "include", "index", "label", "log",
"mathaccents", "matharrows", "mathoperators", "mathrelations", "mathgreek",
"mathmisc", "mathdots", "mathbigoperators", "mathamsmisc",
"mathamsarrows", "mathamsrelations", "mathamsnegatedrelations", "mathamsoperators",
"mathdelimiter", "mathmatrix", "mathspace", "mathstyle",
"minipage", "paragraph", "ref", "tabular", "tabularcreate",
@ -105,7 +134,6 @@ private:
char const * name_;
};
} // namespace anon
@ -194,6 +222,167 @@ Dialog * Dialogs::build(string const & name)
dialog->setController(new ControlLog(*dialog));
dialog->setView(new FormLog(*dialog));
dialog->bc().bp(new OkCancelPolicy);
} else if (name == "mathaccents") {
FormMathsBitmap * bitmap =
createFormBitmap(*dialog, _("Maths Decorations & Accents"),
latex_deco, nr_latex_deco);
bitmap->addBitmap(
BitmapStore(12, 3, 4, deco1_width, deco1_height, deco1_bits, true));
bitmap->addBitmap(
BitmapStore(10, 4, 3, deco2_width, deco2_height, deco2_bits, true));
dialog->setController(new ControlMath2(*dialog));
dialog->setView(bitmap);
dialog->bc().bp(new IgnorantPolicy);
} else if (name == "matharrows") {
FormMathsBitmap * bitmap =
createFormBitmap(*dialog, _("Arrows"), latex_arrow, nr_latex_arrow);
bitmap->addBitmap(
BitmapStore(20, 5, 4, arrow_width, arrow_height, arrow_bits, true));
bitmap->addBitmap(
BitmapStore(7, 2, 4, larrow_width, larrow_height, larrow_bits, false));
bitmap->addBitmap(
BitmapStore(4, 2, 2, darrow_width, darrow_height, darrow_bits, true));
dialog->setController(new ControlMath2(*dialog));
dialog->setView(bitmap);
dialog->bc().bp(new IgnorantPolicy);
} else if (name == "mathoperators") {
FormMathsBitmap * bitmap =
createFormBitmap(*dialog, _("Binary Ops"),
latex_bop, nr_latex_bop);
bitmap->addBitmap(
BitmapStore(31, 4, 8, bop_width, bop_height, bop_bits, true));
dialog->setController(new ControlMath2(*dialog));
dialog->setView(bitmap);
dialog->bc().bp(new IgnorantPolicy);
} else if (name == "mathrelations") {
FormMathsBitmap * bitmap =
createFormBitmap(*dialog, _("Binary Relations"),
latex_brel, nr_latex_brel);
bitmap->addBitmap(
BitmapStore(35, 4, 9, brel_width, brel_height, brel_bits, true));
dialog->setController(new ControlMath2(*dialog));
dialog->setView(bitmap);
dialog->bc().bp(new IgnorantPolicy);
} else if (name == "mathgreek") {
FormMathsBitmap * bitmap =
createFormBitmap(*dialog, _("Greek"),
latex_greek, nr_latex_greek);
bitmap->addBitmap(
BitmapStore(11, 6, 2, Greek_width, Greek_height, Greek_bits, true));
bitmap->addBitmap(
BitmapStore(28, 7, 4, greek_width, greek_height, greek_bits, true));
dialog->setController(new ControlMath2(*dialog));
dialog->setView(bitmap);
dialog->bc().bp(new IgnorantPolicy);
} else if (name == "mathmisc") {
FormMathsBitmap * bitmap =
createFormBitmap(*dialog, _("Misc"),
latex_misc, nr_latex_misc);
bitmap->addBitmap(
BitmapStore(29, 5, 6, misc_width, misc_height, misc_bits, true));
bitmap->addBitmap(
BitmapStore(5, 5, 1, misc4_width, misc4_height, misc4_bits, true));
bitmap->addBitmap(
BitmapStore(6, 3, 2, misc2_width, misc2_height, misc2_bits, false));
bitmap->addBitmap(
BitmapStore(4, 2, 2, misc3_width, misc3_height, misc3_bits, true));
dialog->setController(new ControlMath2(*dialog));
dialog->setView(bitmap);
dialog->bc().bp(new IgnorantPolicy);
} else if (name == "mathdots") {
FormMathsBitmap * bitmap =
createFormBitmap(*dialog, _("Dots"),
latex_dots, nr_latex_dots);
bitmap->addBitmap(
BitmapStore(4, 4, 1, dots_width, dots_height, dots_bits, true));
dialog->setController(new ControlMath2(*dialog));
dialog->setView(bitmap);
dialog->bc().bp(new IgnorantPolicy);
} else if (name == "mathbigoperators") {
FormMathsBitmap * bitmap =
createFormBitmap(*dialog, _("Big Operators"),
latex_varsz, nr_latex_varsz);
bitmap->addBitmap(
BitmapStore(14, 3, 5, varsz_width, varsz_height, varsz_bits, true));
dialog->setController(new ControlMath2(*dialog));
dialog->setView(bitmap);
dialog->bc().bp(new IgnorantPolicy);
} else if (name == "mathamsmisc") {
FormMathsBitmap * bitmap =
createFormBitmap(*dialog, _("AMS Misc"),
latex_ams_misc, nr_latex_ams_misc);
bitmap->addBitmap(
BitmapStore(9, 5, 2, ams1_width, ams1_height, ams1_bits, true));
bitmap->addBitmap(
BitmapStore(26, 3, 9, ams7_width, ams7_height, ams7_bits, true));
dialog->setController(new ControlMath2(*dialog));
dialog->setView(bitmap);
dialog->bc().bp(new IgnorantPolicy);
} else if (name == "mathamsarrows") {
FormMathsBitmap * bitmap =
createFormBitmap(*dialog, _("AMS Arrows"),
latex_ams_arrows, nr_latex_ams_arrows);
bitmap->addBitmap(
BitmapStore(32, 3, 11, ams2_width, ams2_height, ams2_bits, true));
bitmap->addBitmap(
BitmapStore(6, 3, 2, ams3_width, ams3_height, ams3_bits, true));
dialog->setController(new ControlMath2(*dialog));
dialog->setView(bitmap);
dialog->bc().bp(new IgnorantPolicy);
} else if (name == "mathamsrelations") {
FormMathsBitmap * bitmap =
createFormBitmap(*dialog, _("AMS Relations"),
latex_ams_rel, nr_latex_ams_rel);
bitmap->addBitmap(
BitmapStore(66, 6, 11, ams_rel_width, ams_rel_height, ams_rel_bits, true));
dialog->setController(new ControlMath2(*dialog));
dialog->setView(bitmap);
dialog->bc().bp(new IgnorantPolicy);
} else if (name == "mathamsnegatedrelations") {
FormMathsBitmap * bitmap =
createFormBitmap(*dialog, _("AMS Negated Rel"),
latex_ams_nrel, nr_latex_ams_nrel);
bitmap->addBitmap(
BitmapStore(51, 6, 9, ams_nrel_width, ams_nrel_height, ams_nrel_bits, true));
dialog->setController(new ControlMath2(*dialog));
dialog->setView(bitmap);
dialog->bc().bp(new IgnorantPolicy);
} else if (name == "mathamsoperators") {
FormMathsBitmap * bitmap =
createFormBitmap(*dialog, _("AMS Operators"),
latex_ams_ops, nr_latex_ams_ops);
bitmap->addBitmap(
BitmapStore(23, 3, 8, ams_ops_width, ams_ops_height, ams_ops_bits, true));
dialog->setController(new ControlMath2(*dialog));
dialog->setView(bitmap);
dialog->bc().bp(new IgnorantPolicy);
} else if (name == "mathdelimiter") {
dialog->setController(new ControlMath2(*dialog));
dialog->setView(new FormMathsDelim(*dialog));

View File

@ -14,7 +14,7 @@
#include "FormMathsBitmap.h"
#include "ControlMath.h"
#include "ControlMath2.h"
#include "xformsBC.h"
#include "bmtable.h"
@ -26,8 +26,8 @@
#include <algorithm>
extern "C" void C_FormBaseCancelCB(FL_OBJECT *, long);
extern "C" void C_FormBaseInputCB(FL_OBJECT *, long);
extern "C" void C_FormDialogView_CancelCB(FL_OBJECT *, long);
extern "C" void C_FormDialogView_InputCB(FL_OBJECT *, long);
using std::vector;
using std::max;
@ -40,11 +40,11 @@ FD_maths_bitmap::~FD_maths_bitmap()
}
typedef FormCB<ControlMathSub, FormDB<FD_maths_bitmap> > base_class;
typedef FormController<ControlMath2, FormView<FD_maths_bitmap> > base_class;
FormMathsBitmap::FormMathsBitmap(string const & t, vector<string> const & l)
: base_class(t, false),
FormMathsBitmap::FormMathsBitmap(Dialog & parent, string const & t, vector<string> const & l)
: base_class(parent, t, false),
latex_(l), ww_(0), x_(0), y_(0), w_(0), h_(0)
{
ww_ = 2 * FL_abs(FL_BOUND_WIDTH);
@ -53,17 +53,16 @@ FormMathsBitmap::FormMathsBitmap(string const & t, vector<string> const & l)
}
void FormMathsBitmap::addBitmap(int nt, int nx, int ny, int bw, int bh,
unsigned char const * data, bool vert)
void FormMathsBitmap::addBitmap(BitmapStore const & bm)
{
bitmaps_.push_back(BitmapStore(nt, nx, ny, bw, bh, data, vert));
bitmaps_.push_back(bm);
int wx = bw + ww_ / 2;
int wy = bh + ww_ / 2;
wx += (wx % nx);
wy += (wy % ny);
int wx = bm.bw + ww_ / 2;
int wy = bm.bh + ww_ / 2;
wx += (wx % bm.nx);
wy += (wy % bm.ny);
if (vert) {
if (bm.vert) {
y_ += wy + 8;
h_ = max(y_, h_);
w_ = max(x_ + wx + ww_, w_);
@ -109,14 +108,13 @@ void FormMathsBitmap::build()
idex(label).c_str());
fl_set_button_shortcut(fdui->button_close, scex(label).c_str(), 1);
fl_set_object_lsize(fdui->button_close, FL_NORMAL_SIZE);
fl_set_object_callback(fdui->button_close, C_FormBaseCancelCB, 0);
fl_set_object_callback(fdui->button_close, C_FormDialogView_CancelCB, 0);
fl_end_form();
fdui->form->fdui = fdui;
dialog_.reset(fdui);
bcview().setCancel(dialog_->button_close);
}
@ -145,7 +143,7 @@ FL_OBJECT * FormMathsBitmap::buildBitmap(BitmapStore const & bmstore)
fl_set_bmtable_data(obj, bmstore.nx, bmstore.ny, bmstore.bw, bmstore.bh,
bmstore.data);
fl_set_bmtable_maxitems(obj, bmstore.nt);
fl_set_object_callback(obj, C_FormBaseInputCB, 0);
fl_set_object_callback(obj, C_FormDialogView_InputCB, 0);
if (bmstore.vert) {
y_ += wy + 8;
@ -180,10 +178,10 @@ void FormMathsBitmap::apply()
string::size_type const i = latex_chosen_.find(' ');
if (i != string::npos) {
controller().dispatchFunc(LFUN_MATH_MODE);
controller().insertSymbol(latex_chosen_.substr(0,i));
controller().insertSymbol(latex_chosen_.substr(i + 1), false);
controller().dispatchInsert(latex_chosen_.substr(0,i));
controller().dispatchInsert('\\' + latex_chosen_.substr(i + 1));
} else
controller().insertSymbol(latex_chosen_);
controller().dispatchInsert(latex_chosen_);
}

View File

@ -15,10 +15,11 @@
#define FORM_MATHSBITMAP_H
#include "FormBase.h"
#include "FormDialogView.h"
#include <boost/shared_ptr.hpp>
#include <vector>
struct BitmapStore
{
BitmapStore(int nt_in, int nx_in, int ny_in, int bw_in, int bh_in,
@ -49,16 +50,15 @@ struct FD_maths_bitmap
* This class provides an XForms implementation of a maths bitmap form.
*/
class ControlMathSub;
class ControlMath2;
class FormMathsBitmap : public FormCB<ControlMathSub, FormDB<FD_maths_bitmap> >
{
class FormMathsBitmap
: public FormController<ControlMath2, FormView<FD_maths_bitmap> > {
public:
///
FormMathsBitmap(string const &, std::vector<string> const &);
FormMathsBitmap(Dialog &, string const &, std::vector<string> const &);
///
void addBitmap(int, int, int, int, int, unsigned char const *,
bool = true);
void addBitmap(BitmapStore const &);
private:
///

View File

@ -19,13 +19,6 @@
#include "forms/form_maths_panel.h"
#include "xformsBC.h"
#include "FormMathsBitmap.h"
#include "forms/form_maths_delim.h"
#include "forms/form_maths_matrix.h"
#include "forms/form_maths_space.h"
#include "forms/form_maths_style.h"
#include "lyx_forms.h"
#include "deco.xpm"
@ -39,21 +32,6 @@
#include "sub.xpm"
#include "super.xpm"
#include "arrows.xbm"
#include "bop.xbm"
#include "brel.xbm"
#include "deco.xbm"
#include "dots.xbm"
#include "greek.xbm"
#include "misc.xbm"
#include "varsz.xbm"
#include "ams_misc.xbm"
#include "ams_arrows.xbm"
#include "ams_rel.xbm"
#include "ams_nrel.xbm"
#include "ams_ops.xbm"
typedef FormCB<ControlMath, FormDB<FD_maths_panel> > base_class;
@ -62,22 +40,6 @@ FormMathsPanel::FormMathsPanel()
{}
FormMathsBitmap * FormMathsPanel::addDaughter(void * key,
string const & title,
char const * const * data,
int size)
{
char const * const * const end = data + size;
FormMathsBitmap * const view =
new FormMathsBitmap(title, std::vector<string>(data, end));
controller().addDaughter(key, view,
new xformsBC(controller().bc()),
new IgnorantPolicy);
return view;
}
void FormMathsPanel::build()
{
dialog_.reset(build_maths_panel(this));
@ -106,103 +68,43 @@ void FormMathsPanel::build()
const_cast<char**>(matrix));
fl_set_pixmap_data(dialog_->button_equation,
const_cast<char**>(equation));
FormMathsBitmap * bitmap;
bitmap = addDaughter(dialog_->button_deco,
_("Maths Decorations & Accents"),
latex_deco, nr_latex_deco);
bitmap->addBitmap(12, 3, 4, deco1_width, deco1_height, deco1_bits);
bitmap->addBitmap(10, 4, 3, deco2_width, deco2_height, deco2_bits);
bitmap = addDaughter(dialog_->button_arrow, _("Arrows"),
latex_arrow, nr_latex_arrow);
bitmap->addBitmap(20, 5, 4, arrow_width, arrow_height, arrow_bits);
bitmap->addBitmap(7, 2, 4, larrow_width, larrow_height, larrow_bits,
false);
bitmap->addBitmap(4, 2, 2, darrow_width, darrow_height, darrow_bits);
bitmap = addDaughter(dialog_->button_boperator, _("Binary Ops"),
latex_bop, nr_latex_bop);
bitmap->addBitmap(31, 4, 8, bop_width, bop_height, bop_bits);
bitmap = addDaughter(dialog_->button_brelats, _("Bin Relations"),
latex_brel, nr_latex_brel);
bitmap->addBitmap(35, 4, 9, brel_width, brel_height, brel_bits);
bitmap = addDaughter(dialog_->button_greek, _("Greek"),
latex_greek, nr_latex_greek);
bitmap->addBitmap(11, 6, 2, Greek_width, Greek_height, Greek_bits);
bitmap->addBitmap(28, 7, 4, greek_width, greek_height, greek_bits);
bitmap = addDaughter(dialog_->button_misc,_("Misc"),
latex_misc, nr_latex_misc);
bitmap->addBitmap(29, 5, 6, misc_width, misc_height, misc_bits);
bitmap->addBitmap(5, 5, 1, misc4_width, misc4_height, misc4_bits);
bitmap->addBitmap(6, 3, 2, misc2_width, misc2_height, misc2_bits,
false);
bitmap->addBitmap(4, 2, 2, misc3_width, misc3_height, misc3_bits);
bitmap = addDaughter(dialog_->button_dots, _("Dots"),
latex_dots, nr_latex_dots);
bitmap->addBitmap(4, 4, 1, dots_width, dots_height, dots_bits);
bitmap = addDaughter(dialog_->button_varsize, _("Big Operators"),
latex_varsz, nr_latex_varsz);
bitmap->addBitmap(14, 3, 5, varsz_width, varsz_height, varsz_bits);
bitmap = addDaughter(dialog_->button_ams_misc, _("AMS Misc"),
latex_ams_misc, nr_latex_ams_misc);
bitmap->addBitmap(9, 5, 2, ams1_width, ams1_height, ams1_bits);
bitmap->addBitmap(26, 3, 9, ams7_width, ams7_height, ams7_bits);
bitmap = addDaughter(dialog_->button_ams_arrows, _("AMS Arrows"),
latex_ams_arrows, nr_latex_ams_arrows);
bitmap->addBitmap(32, 3, 11, ams2_width, ams2_height, ams2_bits);
bitmap->addBitmap(6, 3, 2, ams3_width, ams3_height, ams3_bits);
bitmap = addDaughter(dialog_->button_ams_brel, _("AMS Relations"),
latex_ams_rel, nr_latex_ams_rel);
bitmap->addBitmap(66, 6, 11, ams_rel_width, ams_rel_height,
ams_rel_bits);
bitmap = addDaughter(dialog_->button_ams_nrel, _("AMS Negated Rel"),
latex_ams_nrel, nr_latex_ams_nrel);
bitmap->addBitmap(51, 6, 9, ams_nrel_width, ams_nrel_height,
ams_nrel_bits);
bitmap = addDaughter(dialog_->button_ams_ops, _("AMS Operators"),
latex_ams_ops, nr_latex_ams_ops);
bitmap->addBitmap(23, 3, 8, ams_ops_width, ams_ops_height,
ams_ops_bits);
}
ButtonPolicy::SMInput FormMathsPanel::input(FL_OBJECT * ob, long)
{
if (ob == dialog_->button_arrow ||
ob == dialog_->button_boperator ||
ob == dialog_->button_brelats ||
ob == dialog_->button_greek ||
ob == dialog_->button_misc ||
ob == dialog_->button_dots ||
ob == dialog_->button_varsize ||
ob == dialog_->button_ams_misc ||
ob == dialog_->button_ams_arrows ||
ob == dialog_->button_ams_brel ||
ob == dialog_->button_ams_nrel ||
ob == dialog_->button_ams_ops ||
ob == dialog_->button_deco) {
controller().showDaughter(ob);
if (ob == dialog_->button_arrow) {
controller().showDialog("matharrows");
} else if (ob == dialog_->button_deco) {
controller().showDialog("mathaccents");
} else if (ob == dialog_->button_boperator) {
controller().showDialog("mathoperators");
} else if (ob == dialog_->button_brelats) {
controller().showDialog("mathrelations");
} else if (ob == dialog_->button_greek) {
controller().showDialog("mathgreek");
} else if (ob == dialog_->button_misc) {
controller().showDialog("mathmisc");
} else if (ob == dialog_->button_dots) {
controller().showDialog("mathdots");
} else if (ob == dialog_->button_varsize) {
controller().showDialog("mathbigoperators");
} else if (ob == dialog_->button_ams_misc) {
controller().showDialog("mathamsmisc");
} else if (ob == dialog_->button_ams_arrows) {
controller().showDialog("mathamsarrows");
} else if (ob == dialog_->button_ams_brel) {
controller().showDialog("mathamsrelations");
} else if (ob == dialog_->button_ams_nrel) {
controller().showDialog("mathamsnegatedrelations");
} else if (ob == dialog_->button_ams_ops) {
controller().showDialog("mathamsoperators");
} 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");

View File

@ -19,7 +19,6 @@
class ControlMath;
struct FD_maths_panel;
class FormMathsBitmap;
/**
* This class provides an XForms implementation of the maths panel.
@ -39,12 +38,6 @@ private:
virtual void build();
///
virtual ButtonPolicy::SMInput input(FL_OBJECT *, long);
/** Add a bitmap dialog to the store of all daughters_ and
* return a pointer to the dialog, so that bitmaps can be added to it.
*/
FormMathsBitmap * addDaughter(void * button, string const & title,
char const * const * data, int size);
};
#endif // FORM_MATHSPANEL_H