2 * \file FormMathsStyle.C
3 * Copyright 2001 The LyX Team.
4 * See the file COPYING.
6 * \author Alejandro Aguilar Sierra
7 * \author Pablo De Napoli, pdenapo@dm.uba.ar
8 * \author John Levon, moz@compsoc.man.ac.uk
9 * \author Angus Leeming, a.leeming@ic.ac.uk
10 * Adapted from FormMathsSpace martin.vermeer@hut.fi
16 #pragma implementation
19 #include "FormMathsStyle.h"
20 #include "form_maths_style.h"
28 char const * latex_mathstyle[] = {
29 "displaystyle", "textstyle", "scriptstyle", "scriptscriptstyle"
32 kb_action latex_mathfontcmds[] = {
33 LFUN_BOLD, LFUN_SANS, LFUN_ROMAN, LFUN_ITAL, LFUN_CODE,
34 LFUN_NOUN, LFUN_FRAK, LFUN_EMPH, LFUN_FREE, LFUN_DEFAULT
39 FormMathsStyle::FormMathsStyle(LyXView * lv, Dialogs * d,
40 FormMathsPanel const & p)
41 : FormMathsSub(lv, d, p, _("Maths Styles & Fonts"), false),
46 FL_FORM * FormMathsStyle::form() const
54 void FormMathsStyle::build()
56 dialog_.reset(build_maths_style());
58 fl_set_bmtable_data(dialog_->bmtable_style1, 1, 1,
59 style1_width, style1_height, style1_bits);
60 fl_set_bmtable_maxitems(dialog_->bmtable_style1, 1);
61 bc().addReadOnly(dialog_->bmtable_style1);
63 fl_set_bmtable_data(dialog_->bmtable_style2, 1, 3,
64 style2_width, style2_height, style2_bits);
65 fl_set_bmtable_maxitems(dialog_->bmtable_style2, 3);
66 bc().addReadOnly(dialog_->bmtable_style2);
68 fl_set_bmtable_data(dialog_->bmtable_font1, 1, 5,
69 font1_width, font1_height, font1_bits);
70 fl_set_bmtable_maxitems(dialog_->bmtable_font1, 5);
71 bc().addReadOnly(dialog_->bmtable_font1);
73 fl_set_bmtable_data(dialog_->bmtable_font2, 1, 3,
74 font2_width, font2_height, font2_bits);
75 fl_set_bmtable_maxitems(dialog_->bmtable_font2, 3);
76 bc().addReadOnly(dialog_->bmtable_font2);
78 bc().setCancel(dialog_->button_cancel);
82 void FormMathsStyle::apply()
84 if ((style_ >= 0) && (style_ < 4))
85 parent_.insertSymbol(latex_mathstyle[style_]);
87 if ((style_ >= 4) && (style_ < 14))
88 parent_.dispatchFunc(latex_mathfontcmds[style_ - 4]);
91 bool FormMathsStyle::input(FL_OBJECT * ob, long data)
93 style_ = fl_get_bmtable(ob);
94 if (style_ < 0) return false;
95 //if (ob == dialog_->bmtable_style1) style_ += 0;
96 if (ob == dialog_->bmtable_style2) style_ += 1;
97 if (ob == dialog_->bmtable_font1) style_ += 4;
98 if (ob == dialog_->bmtable_font2) style_ += 9;
99 if (data >= 12) style_ = short(data);