2 * \file ControlCharacter.C
3 * This file is part of LyX, the document processor.
4 * Licence details can be found in the file COPYING.
6 * \author Angus Leeming
8 * Full author contact details are available in file CREDITS.
13 #include "ControlCharacter.h"
14 #include "ButtonController.h"
17 #include "bufferparams.h"
18 #include "bufferview_funcs.h"
19 #include "funcrequest.h"
22 using bv_funcs::font2string;
25 ControlCharacter::ControlCharacter(Dialog & parent)
26 : Dialog::Controller(parent),
27 font_(0), toggleall_(false)
31 bool ControlCharacter::initialiseParams(string const &)
33 // Do this the first time only.
35 font_.reset(new LyXFont(LyXFont::ALL_IGNORE));
37 // so that the user can press Ok
38 if (getFamily() != LyXFont::IGNORE_FAMILY ||
39 getSeries() != LyXFont::IGNORE_SERIES ||
40 getShape() != LyXFont::IGNORE_SHAPE ||
41 getSize() != LyXFont::IGNORE_SIZE ||
42 getBar() != frnt::IGNORE ||
43 getColor() != LColor::ignore ||
44 font_->language() != ignore_language)
45 dialog().bc().valid();
51 void ControlCharacter::clearParams()
55 void ControlCharacter::dispatchParams()
57 // Nothing to dispatch. (Can be called from the Toolbar.)
62 if (font2string(*font_.get(), toggleall_, data)) {
63 kernel().dispatch(FuncRequest(LFUN_FREEFONT_UPDATE, data));
68 LyXFont::FONT_FAMILY ControlCharacter::getFamily() const
71 return LyXFont::IGNORE_FAMILY;
72 return font_->family();
76 void ControlCharacter::setFamily(LyXFont::FONT_FAMILY val)
78 font_->setFamily(val);
82 LyXFont::FONT_SERIES ControlCharacter::getSeries() const
85 return LyXFont::IGNORE_SERIES;
86 return font_->series();
90 void ControlCharacter::setSeries(LyXFont::FONT_SERIES val)
92 font_->setSeries(val);
96 LyXFont::FONT_SHAPE ControlCharacter::getShape() const
99 return LyXFont::IGNORE_SHAPE;
100 return font_->shape();
104 void ControlCharacter::setShape(LyXFont::FONT_SHAPE val)
106 font_->setShape(val);
110 LyXFont::FONT_SIZE ControlCharacter::getSize() const
113 return LyXFont::IGNORE_SIZE;
114 return font_->size();
118 void ControlCharacter::setSize(LyXFont::FONT_SIZE val)
124 frnt::FONT_STATE ControlCharacter::getBar() const
129 if (font_->emph() == LyXFont::TOGGLE)
130 return frnt::EMPH_TOGGLE;
132 if (font_->underbar() == LyXFont::TOGGLE)
133 return frnt::UNDERBAR_TOGGLE;
135 if (font_->noun() == LyXFont::TOGGLE)
136 return frnt::NOUN_TOGGLE;
138 if (font_->emph() == LyXFont::IGNORE &&
139 font_->underbar() == LyXFont::IGNORE &&
140 font_->noun() == LyXFont::IGNORE)
143 return frnt::INHERIT;
147 void ControlCharacter::setBar(frnt::FONT_STATE val)
151 font_->setEmph(LyXFont::IGNORE);
152 font_->setUnderbar(LyXFont::IGNORE);
153 font_->setNoun(LyXFont::IGNORE);
156 case frnt::EMPH_TOGGLE:
157 font_->setEmph(LyXFont::TOGGLE);
160 case frnt::UNDERBAR_TOGGLE:
161 font_->setUnderbar(LyXFont::TOGGLE);
164 case frnt::NOUN_TOGGLE:
165 font_->setNoun(LyXFont::TOGGLE);
169 font_->setEmph(LyXFont::INHERIT);
170 font_->setUnderbar(LyXFont::INHERIT);
171 font_->setNoun(LyXFont::INHERIT);
177 EnumLColor ControlCharacter::getColor() const
180 return LColor::ignore;
182 return font_->color();
186 void ControlCharacter::setColor(EnumLColor val)
197 case LColor::magenta:
199 case LColor::inherit:
200 font_->setColor(val);
208 string ControlCharacter::getLanguage() const
210 if (font_.get() && font_->language())
211 return font_->language()->lang();
216 void ControlCharacter::setLanguage(string const & val)
219 font_->setLanguage(ignore_language);
221 else if (val == "reset")
222 font_->setLanguage(kernel().buffer().params().language);
225 font_->setLanguage(languages.getLanguage(val));
229 bool ControlCharacter::getToggleAll() const
235 void ControlCharacter::setToggleAll(bool t)