]> git.lyx.org Git - lyx.git/blob - src/frontends/xforms/FormMathsStyle.C
Remove redundant files.
[lyx.git] / src / frontends / xforms / FormMathsStyle.C
1 /**
2  * \file FormMathsStyle.C
3  * This file is part of LyX, the document processor.
4  * Licence details can be found in the file COPYING.
5  *
6  * \author Alejandro Aguilar Sierra
7  * \author Pablo De Napoli
8  * \author John Levon
9  * \author Angus Leeming 
10  *
11  * Full author contact details are available in file CREDITS
12  * Adapted from FormMathsSpace martin.vermeer@hut.fi
13  */
14
15 #include <config.h>
16
17 #ifdef __GNUG__
18 #pragma implementation
19 #endif
20
21 #include "FormMathsStyle.h"
22 #include "forms/form_maths_style.h"
23 #include "bmtable.h"
24
25 #include "debug.h"
26
27 #include FORMS_H_LOCATION
28
29 #include "style.xbm"
30 #include "font.xbm"
31
32 char const * latex_mathstyle[] = {
33         "displaystyle", "textstyle", "scriptstyle", "scriptscriptstyle"
34 };
35
36 kb_action latex_mathfontcmds[] = {
37         LFUN_BOLD, LFUN_SANS, LFUN_ROMAN, LFUN_ITAL, LFUN_CODE,
38         LFUN_NOUN, LFUN_FRAK, LFUN_EMPH, LFUN_FREE, LFUN_DEFAULT
39 };
40
41
42
43 FormMathsStyle::FormMathsStyle(LyXView & lv, Dialogs & d,
44                                FormMathsPanel const & p)
45         : FormMathsSub(lv, d, p, _("Maths Styles & Fonts"), false),
46           style_(-1)
47 {}
48
49
50 FL_FORM * FormMathsStyle::form() const
51 {
52         if (dialog_.get())
53                 return dialog_->form;
54         return 0;
55 }
56
57
58 void FormMathsStyle::build()
59 {
60         dialog_.reset(build_maths_style(this));
61
62         fl_set_bmtable_data(dialog_->bmtable_style1, 1, 1,
63                             style1_width, style1_height, style1_bits);
64         fl_set_bmtable_maxitems(dialog_->bmtable_style1, 1);
65         bc().addReadOnly(dialog_->bmtable_style1);
66
67         fl_set_bmtable_data(dialog_->bmtable_style2, 1, 3,
68                             style2_width, style2_height, style2_bits);
69         fl_set_bmtable_maxitems(dialog_->bmtable_style2, 3);
70         bc().addReadOnly(dialog_->bmtable_style2);
71
72         fl_set_bmtable_data(dialog_->bmtable_font1, 1, 5,
73                             font1_width, font1_height, font1_bits);
74         fl_set_bmtable_maxitems(dialog_->bmtable_font1, 5);
75         bc().addReadOnly(dialog_->bmtable_font1);
76
77         fl_set_bmtable_data(dialog_->bmtable_font2, 1, 3,
78                             font2_width, font2_height, font2_bits);
79         fl_set_bmtable_maxitems(dialog_->bmtable_font2, 3);
80         bc().addReadOnly(dialog_->bmtable_font2);
81
82         bc().setCancel(dialog_->button_close);
83 }
84
85
86 void FormMathsStyle::apply()
87 {
88         if ((style_ >= 0) && (style_ < 4))
89                 parent_.insertSymbol(latex_mathstyle[style_]);
90         else if ((style_ >= 4) && (style_ < 14))
91                 parent_.dispatchFunc(latex_mathfontcmds[style_ - 4]);
92 }
93
94
95 bool FormMathsStyle::input(FL_OBJECT * ob, long data)
96 {
97         style_ = fl_get_bmtable(ob);
98         if (style_ < 0) return false;
99         //if (ob == dialog_->bmtable_style1) style_ += 0;
100         if (ob == dialog_->bmtable_style2) style_ += 1;
101         if (ob == dialog_->bmtable_font1)  style_ += 4;
102         if (ob == dialog_->bmtable_font2)  style_ += 9;
103         if (data >= 12) style_ = short(data);
104         apply();
105         return true;
106 }