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"
23 using bv_funcs::font2string;
26 ControlCharacter::ControlCharacter(Dialog & parent)
27 : Dialog::Controller(parent),
28 font_(0), toggleall_(false)
32 bool ControlCharacter::initialiseParams(string const &)
34 // Do this the first time only.
36 font_.reset(new LyXFont(LyXFont::ALL_IGNORE));
38 // so that the user can press Ok
39 if (getFamily() != LyXFont::IGNORE_FAMILY ||
40 getSeries() != LyXFont::IGNORE_SERIES ||
41 getShape() != LyXFont::IGNORE_SHAPE ||
42 getSize() != LyXFont::IGNORE_SIZE ||
43 getBar() != frnt::IGNORE ||
44 getColor() != LColor::ignore ||
45 font_->language() != ignore_language)
46 dialog().bc().valid();
52 void ControlCharacter::clearParams()
56 void ControlCharacter::dispatchParams()
58 // Nothing to dispatch. (Can be called from the Toolbar.)
63 if (font2string(*font_.get(), toggleall_, data)) {
64 kernel().dispatch(FuncRequest(LFUN_FREEFONT_UPDATE, data));
69 LyXFont::FONT_FAMILY ControlCharacter::getFamily() const
72 return LyXFont::IGNORE_FAMILY;
73 return font_->family();
77 void ControlCharacter::setFamily(LyXFont::FONT_FAMILY val)
79 font_->setFamily(val);
83 LyXFont::FONT_SERIES ControlCharacter::getSeries() const
86 return LyXFont::IGNORE_SERIES;
87 return font_->series();
91 void ControlCharacter::setSeries(LyXFont::FONT_SERIES val)
93 font_->setSeries(val);
97 LyXFont::FONT_SHAPE ControlCharacter::getShape() const
100 return LyXFont::IGNORE_SHAPE;
101 return font_->shape();
105 void ControlCharacter::setShape(LyXFont::FONT_SHAPE val)
107 font_->setShape(val);
111 LyXFont::FONT_SIZE ControlCharacter::getSize() const
114 return LyXFont::IGNORE_SIZE;
115 return font_->size();
119 void ControlCharacter::setSize(LyXFont::FONT_SIZE val)
125 frnt::FONT_STATE ControlCharacter::getBar() const
130 if (font_->emph() == LyXFont::TOGGLE)
131 return frnt::EMPH_TOGGLE;
133 if (font_->underbar() == LyXFont::TOGGLE)
134 return frnt::UNDERBAR_TOGGLE;
136 if (font_->noun() == LyXFont::TOGGLE)
137 return frnt::NOUN_TOGGLE;
139 if (font_->emph() == LyXFont::IGNORE &&
140 font_->underbar() == LyXFont::IGNORE &&
141 font_->noun() == LyXFont::IGNORE)
144 return frnt::INHERIT;
148 void ControlCharacter::setBar(frnt::FONT_STATE val)
152 font_->setEmph(LyXFont::IGNORE);
153 font_->setUnderbar(LyXFont::IGNORE);
154 font_->setNoun(LyXFont::IGNORE);
157 case frnt::EMPH_TOGGLE:
158 font_->setEmph(LyXFont::TOGGLE);
161 case frnt::UNDERBAR_TOGGLE:
162 font_->setUnderbar(LyXFont::TOGGLE);
165 case frnt::NOUN_TOGGLE:
166 font_->setNoun(LyXFont::TOGGLE);
170 font_->setEmph(LyXFont::INHERIT);
171 font_->setUnderbar(LyXFont::INHERIT);
172 font_->setNoun(LyXFont::INHERIT);
178 LColor_color ControlCharacter::getColor() const
181 return LColor::ignore;
183 return font_->color();
187 void ControlCharacter::setColor(LColor_color val)
198 case LColor::magenta:
200 case LColor::inherit:
201 font_->setColor(val);
209 string ControlCharacter::getLanguage() const
211 if (font_.get() && font_->language())
212 return font_->language()->lang();
217 void ControlCharacter::setLanguage(string const & val)
220 font_->setLanguage(ignore_language);
222 else if (val == "reset")
223 font_->setLanguage(kernel().buffer().params().language);
226 font_->setLanguage(languages.getLanguage(val));
230 bool ControlCharacter::getToggleAll() const
236 void ControlCharacter::setToggleAll(bool t)