]> git.lyx.org Git - lyx.git/blob - src/frontends/xforms/FormMathsStyle.C
change some __GNUG_ to __GNUG__
[lyx.git] / src / frontends / xforms / FormMathsStyle.C
1 /**
2  * \file FormMathsStyle.C
3  * Copyright 2001 The LyX Team.
4  * See the file COPYING.
5  *
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
11  */
12
13 #include <config.h>
14
15 #ifdef __GNUG__
16 #pragma implementation
17 #endif
18
19 #include "FormMathsStyle.h"
20 #include "form_maths_style.h"
21 #include "bmtable.h"
22
23 #include "style.xbm"
24 #include "font.xbm"
25
26 #include "debug.h"
27
28 char const * latex_mathstyle[] = {
29         "displaystyle", "textstyle", "scriptstyle", "scriptscriptstyle"
30 };
31
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
35 };
36
37
38
39 FormMathsStyle::FormMathsStyle(LyXView * lv, Dialogs * d,
40                                FormMathsPanel const & p)
41         : FormMathsSub(lv, d, p, _("Maths Styles & Fonts"), false),
42           style_(-1)
43 {}
44
45
46 FL_FORM * FormMathsStyle::form() const
47 {
48         if (dialog_.get())
49                 return dialog_->form;
50         return 0;
51 }
52
53
54 void FormMathsStyle::build()
55 {
56         dialog_.reset(build_maths_style());
57
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);
62
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);
67
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);
72
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);
77
78         bc().setCancel(dialog_->button_close);
79 }
80
81
82 void FormMathsStyle::apply()
83 {
84         if ((style_ >= 0) && (style_ < 4))
85                 parent_.insertSymbol(latex_mathstyle[style_]);
86         else if ((style_ >= 4) && (style_ < 14))
87                 parent_.dispatchFunc(latex_mathfontcmds[style_ - 4]);
88 }
89
90
91 bool FormMathsStyle::input(FL_OBJECT * ob, long data)
92 {
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);
100         apply();
101         return true;
102 }