2 * \file ControlCharacter.cpp
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"
23 using lyx::bv_funcs::font2string;
29 ControlCharacter::ControlCharacter(Dialog & parent)
30 : Dialog::Controller(parent),
31 font_(0), toggleall_(false), reset_lang_(false)
35 bool ControlCharacter::initialiseParams(string const &)
37 // Do this the first time only.
39 font_.reset(new Font(Font::ALL_IGNORE));
41 // so that the user can press Ok
42 if (getFamily() != Font::IGNORE_FAMILY ||
43 getSeries() != Font::IGNORE_SERIES ||
44 getShape() != Font::IGNORE_SHAPE ||
45 getSize() != Font::IGNORE_SIZE ||
47 getColor() != Color::ignore ||
48 font_->language() != ignore_language)
49 dialog().bc().valid();
55 void ControlCharacter::clearParams()
59 void ControlCharacter::dispatchParams()
61 // Nothing to dispatch. (Can be called from the Toolbar.)
66 if (font2string(*font_.get(), toggleall_, data)) {
67 kernel().dispatch(FuncRequest(getLfun(), data));
72 Font::FONT_FAMILY ControlCharacter::getFamily() const
75 return Font::IGNORE_FAMILY;
76 return font_->family();
80 void ControlCharacter::setFamily(Font::FONT_FAMILY val)
82 font_->setFamily(val);
86 Font::FONT_SERIES ControlCharacter::getSeries() const
89 return Font::IGNORE_SERIES;
90 return font_->series();
94 void ControlCharacter::setSeries(Font::FONT_SERIES val)
96 font_->setSeries(val);
100 Font::FONT_SHAPE ControlCharacter::getShape() const
103 return Font::IGNORE_SHAPE;
104 return font_->shape();
108 void ControlCharacter::setShape(Font::FONT_SHAPE val)
110 font_->setShape(val);
114 Font::FONT_SIZE ControlCharacter::getSize() const
117 return Font::IGNORE_SIZE;
118 return font_->size();
122 void ControlCharacter::setSize(Font::FONT_SIZE val)
128 FONT_STATE ControlCharacter::getBar() const
133 if (font_->emph() == Font::TOGGLE)
136 if (font_->underbar() == Font::TOGGLE)
137 return UNDERBAR_TOGGLE;
139 if (font_->noun() == Font::TOGGLE)
142 if (font_->emph() == Font::IGNORE &&
143 font_->underbar() == Font::IGNORE &&
144 font_->noun() == Font::IGNORE)
151 void ControlCharacter::setBar(FONT_STATE val)
155 font_->setEmph(Font::IGNORE);
156 font_->setUnderbar(Font::IGNORE);
157 font_->setNoun(Font::IGNORE);
161 font_->setEmph(Font::TOGGLE);
164 case UNDERBAR_TOGGLE:
165 font_->setUnderbar(Font::TOGGLE);
169 font_->setNoun(Font::TOGGLE);
173 font_->setEmph(Font::INHERIT);
174 font_->setUnderbar(Font::INHERIT);
175 font_->setNoun(Font::INHERIT);
181 Color_color ControlCharacter::getColor() const
184 return Color::ignore;
186 return font_->color();
190 void ControlCharacter::setColor(Color_color val)
204 font_->setColor(val);
212 string ControlCharacter::getLanguage() const
216 if (font_.get() && font_->language())
217 return font_->language()->lang();
222 void ControlCharacter::setLanguage(string const & val)
225 font_->setLanguage(ignore_language);
226 else if (val == "reset") {
228 // Ignored in getLanguage, but needed for dispatchParams
229 font_->setLanguage(kernel().buffer().params().language);
231 font_->setLanguage(languages.getLanguage(val));
235 bool ControlCharacter::getToggleAll() const
241 void ControlCharacter::setToggleAll(bool t)
246 } // namespace frontend