2002-01-09 14:40:34 +00:00
|
|
|
/**
|
|
|
|
* \file FormMathsStyle.C
|
2002-09-05 15:14:23 +00:00
|
|
|
* This file is part of LyX, the document processor.
|
|
|
|
* Licence details can be found in the file COPYING.
|
2002-01-09 14:40:34 +00:00
|
|
|
*
|
|
|
|
* \author Alejandro Aguilar Sierra
|
2002-09-05 14:10:50 +00:00
|
|
|
* \author Pablo De Napoli
|
|
|
|
* \author John Levon
|
2002-12-01 22:59:25 +00:00
|
|
|
* \author Angus Leeming
|
2002-09-05 14:10:50 +00:00
|
|
|
*
|
|
|
|
* Full author contact details are available in file CREDITS
|
2002-01-09 14:40:34 +00:00
|
|
|
* Adapted from FormMathsSpace martin.vermeer@hut.fi
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <config.h>
|
|
|
|
|
|
|
|
|
|
|
|
#include "FormMathsStyle.h"
|
2002-06-13 13:43:51 +00:00
|
|
|
#include "forms/form_maths_style.h"
|
2002-11-25 18:58:15 +00:00
|
|
|
#include "ControlMath.h"
|
|
|
|
#include "xformsBC.h"
|
2002-01-29 12:31:24 +00:00
|
|
|
|
2002-11-25 18:58:15 +00:00
|
|
|
#include "bmtable.h"
|
2002-06-13 13:43:51 +00:00
|
|
|
|
|
|
|
#include FORMS_H_LOCATION
|
|
|
|
|
2002-01-29 12:31:24 +00:00
|
|
|
#include "style.xbm"
|
|
|
|
#include "font.xbm"
|
|
|
|
|
|
|
|
char const * latex_mathstyle[] = {
|
|
|
|
"displaystyle", "textstyle", "scriptstyle", "scriptscriptstyle"
|
|
|
|
};
|
|
|
|
|
|
|
|
kb_action latex_mathfontcmds[] = {
|
|
|
|
LFUN_BOLD, LFUN_SANS, LFUN_ROMAN, LFUN_ITAL, LFUN_CODE,
|
2003-03-12 22:17:50 +00:00
|
|
|
LFUN_NOUN, LFUN_FRAK, LFUN_EMPH, LFUN_FREEFONT_APPLY, LFUN_DEFAULT
|
2002-01-29 12:31:24 +00:00
|
|
|
};
|
|
|
|
|
2002-01-09 14:40:34 +00:00
|
|
|
|
2002-11-25 18:58:15 +00:00
|
|
|
typedef FormCB<ControlMathSub, FormDB<FD_maths_style> > base_class;
|
2002-01-09 14:40:34 +00:00
|
|
|
|
2002-11-25 18:58:15 +00:00
|
|
|
FormMathsStyle::FormMathsStyle()
|
|
|
|
: base_class(_("Maths Styles & Fonts"), false),
|
2002-01-09 14:40:34 +00:00
|
|
|
style_(-1)
|
|
|
|
{}
|
|
|
|
|
|
|
|
|
|
|
|
void FormMathsStyle::build()
|
|
|
|
{
|
2002-06-13 13:43:51 +00:00
|
|
|
dialog_.reset(build_maths_style(this));
|
2002-01-09 14:40:34 +00:00
|
|
|
|
2002-01-29 12:31:24 +00:00
|
|
|
fl_set_bmtable_data(dialog_->bmtable_style1, 1, 1,
|
2002-03-21 16:59:12 +00:00
|
|
|
style1_width, style1_height, style1_bits);
|
2002-01-29 12:31:24 +00:00
|
|
|
fl_set_bmtable_maxitems(dialog_->bmtable_style1, 1);
|
2003-03-10 03:13:28 +00:00
|
|
|
bcview().addReadOnly(dialog_->bmtable_style1);
|
2002-01-09 14:40:34 +00:00
|
|
|
|
2002-01-29 12:31:24 +00:00
|
|
|
fl_set_bmtable_data(dialog_->bmtable_style2, 1, 3,
|
2002-03-21 16:59:12 +00:00
|
|
|
style2_width, style2_height, style2_bits);
|
2002-01-29 12:31:24 +00:00
|
|
|
fl_set_bmtable_maxitems(dialog_->bmtable_style2, 3);
|
2003-03-10 03:13:28 +00:00
|
|
|
bcview().addReadOnly(dialog_->bmtable_style2);
|
2002-01-09 14:40:34 +00:00
|
|
|
|
2002-01-29 12:31:24 +00:00
|
|
|
fl_set_bmtable_data(dialog_->bmtable_font1, 1, 5,
|
2002-03-21 16:59:12 +00:00
|
|
|
font1_width, font1_height, font1_bits);
|
2002-01-29 12:31:24 +00:00
|
|
|
fl_set_bmtable_maxitems(dialog_->bmtable_font1, 5);
|
2003-03-10 03:13:28 +00:00
|
|
|
bcview().addReadOnly(dialog_->bmtable_font1);
|
2002-01-29 12:31:24 +00:00
|
|
|
|
|
|
|
fl_set_bmtable_data(dialog_->bmtable_font2, 1, 3,
|
2002-03-21 16:59:12 +00:00
|
|
|
font2_width, font2_height, font2_bits);
|
2002-01-29 12:31:24 +00:00
|
|
|
fl_set_bmtable_maxitems(dialog_->bmtable_font2, 3);
|
2003-03-10 03:13:28 +00:00
|
|
|
bcview().addReadOnly(dialog_->bmtable_font2);
|
2002-01-29 12:31:24 +00:00
|
|
|
|
2003-03-10 03:13:28 +00:00
|
|
|
bcview().setCancel(dialog_->button_close);
|
2002-03-21 16:59:12 +00:00
|
|
|
}
|
2002-01-09 14:40:34 +00:00
|
|
|
|
|
|
|
|
|
|
|
void FormMathsStyle::apply()
|
|
|
|
{
|
2002-03-21 21:21:28 +00:00
|
|
|
if ((style_ >= 0) && (style_ < 4))
|
2002-11-25 18:58:15 +00:00
|
|
|
controller().insertSymbol(latex_mathstyle[style_]);
|
2002-03-21 21:21:28 +00:00
|
|
|
else if ((style_ >= 4) && (style_ < 14))
|
2002-11-25 18:58:15 +00:00
|
|
|
controller().dispatchFunc(latex_mathfontcmds[style_-4]);
|
2002-01-09 14:40:34 +00:00
|
|
|
}
|
|
|
|
|
2002-03-21 16:59:12 +00:00
|
|
|
|
2002-11-25 18:58:15 +00:00
|
|
|
ButtonPolicy::SMInput FormMathsStyle::input(FL_OBJECT * ob, long data)
|
2002-01-09 14:40:34 +00:00
|
|
|
{
|
2002-01-29 12:31:24 +00:00
|
|
|
style_ = fl_get_bmtable(ob);
|
2002-11-25 18:58:15 +00:00
|
|
|
if (style_ < 0) return ButtonPolicy::SMI_INVALID;
|
|
|
|
|
2002-03-21 21:21:28 +00:00
|
|
|
//if (ob == dialog_->bmtable_style1) style_ += 0;
|
2002-01-29 12:31:24 +00:00
|
|
|
if (ob == dialog_->bmtable_style2) style_ += 1;
|
|
|
|
if (ob == dialog_->bmtable_font1) style_ += 4;
|
|
|
|
if (ob == dialog_->bmtable_font2) style_ += 9;
|
|
|
|
if (data >= 12) style_ = short(data);
|
|
|
|
apply();
|
2002-11-25 18:58:15 +00:00
|
|
|
|
|
|
|
return ButtonPolicy::SMI_VALID;
|
2002-01-09 14:40:34 +00:00
|
|
|
}
|