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 <leeming@lyx.org>
10 * Adapted from FormMathsSpace martin.vermeer@hut.fi
16 #pragma implementation
19 #include "FormMathsStyle.h"
20 #include "forms/form_maths_style.h"
25 #include FORMS_H_LOCATION
30 char const * latex_mathstyle[] = {
31 "displaystyle", "textstyle", "scriptstyle", "scriptscriptstyle"
34 kb_action latex_mathfontcmds[] = {
35 LFUN_BOLD, LFUN_SANS, LFUN_ROMAN, LFUN_ITAL, LFUN_CODE,
36 LFUN_NOUN, LFUN_FRAK, LFUN_EMPH, LFUN_FREE, LFUN_DEFAULT
41 FormMathsStyle::FormMathsStyle(LyXView & lv, Dialogs & d,
42 FormMathsPanel const & p)
43 : FormMathsSub(lv, d, p, _("Maths Styles & Fonts"), false),
48 FL_FORM * FormMathsStyle::form() const
56 void FormMathsStyle::build()
58 dialog_.reset(build_maths_style(this));
60 fl_set_bmtable_data(dialog_->bmtable_style1, 1, 1,
61 style1_width, style1_height, style1_bits);
62 fl_set_bmtable_maxitems(dialog_->bmtable_style1, 1);
63 bc().addReadOnly(dialog_->bmtable_style1);
65 fl_set_bmtable_data(dialog_->bmtable_style2, 1, 3,
66 style2_width, style2_height, style2_bits);
67 fl_set_bmtable_maxitems(dialog_->bmtable_style2, 3);
68 bc().addReadOnly(dialog_->bmtable_style2);
70 fl_set_bmtable_data(dialog_->bmtable_font1, 1, 5,
71 font1_width, font1_height, font1_bits);
72 fl_set_bmtable_maxitems(dialog_->bmtable_font1, 5);
73 bc().addReadOnly(dialog_->bmtable_font1);
75 fl_set_bmtable_data(dialog_->bmtable_font2, 1, 3,
76 font2_width, font2_height, font2_bits);
77 fl_set_bmtable_maxitems(dialog_->bmtable_font2, 3);
78 bc().addReadOnly(dialog_->bmtable_font2);
80 bc().setCancel(dialog_->button_close);
84 void FormMathsStyle::apply()
86 if ((style_ >= 0) && (style_ < 4))
87 parent_.insertSymbol(latex_mathstyle[style_]);
88 else if ((style_ >= 4) && (style_ < 14))
89 parent_.dispatchFunc(latex_mathfontcmds[style_ - 4]);
93 bool FormMathsStyle::input(FL_OBJECT * ob, long data)
95 style_ = fl_get_bmtable(ob);
96 if (style_ < 0) return false;
97 //if (ob == dialog_->bmtable_style1) style_ += 0;
98 if (ob == dialog_->bmtable_style2) style_ += 1;
99 if (ob == dialog_->bmtable_font1) style_ += 4;
100 if (ob == dialog_->bmtable_font2) style_ += 9;
101 if (data >= 12) style_ = short(data);