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 "bufferview_funcs.h"
18 #include "funcrequest.h"
21 using namespace bv_funcs;
23 ControlCharacter::ControlCharacter(Dialog & parent)
24 : Dialog::Controller(parent),
25 font_(0), toggleall_(false)
29 bool ControlCharacter::initialiseParams(string const &)
31 // Do this the first time only.
33 font_.reset(new LyXFont(LyXFont::ALL_IGNORE));
35 // so that the user can press Ok
36 if (getFamily() != LyXFont::IGNORE_FAMILY ||
37 getSeries() != LyXFont::IGNORE_SERIES ||
38 getShape() != LyXFont::IGNORE_SHAPE ||
39 getSize() != LyXFont::IGNORE_SIZE ||
40 getBar() != frnt::IGNORE ||
41 getColor() != LColor::ignore ||
42 font_->language() != ignore_language)
43 dialog().bc().valid();
49 void ControlCharacter::clearParams()
53 void ControlCharacter::dispatchParams()
55 // Nothing to dispatch. (Can be called from the Toolbar.)
60 if (font2string(*font_.get(), toggleall_, data)) {
61 kernel().dispatch(FuncRequest(LFUN_FREEFONT_UPDATE, data));
66 LyXFont::FONT_FAMILY ControlCharacter::getFamily() const
69 return LyXFont::IGNORE_FAMILY;
70 return font_->family();
74 void ControlCharacter::setFamily(LyXFont::FONT_FAMILY val)
76 font_->setFamily(val);
80 LyXFont::FONT_SERIES ControlCharacter::getSeries() const
83 return LyXFont::IGNORE_SERIES;
84 return font_->series();
88 void ControlCharacter::setSeries(LyXFont::FONT_SERIES val)
90 font_->setSeries(val);
94 LyXFont::FONT_SHAPE ControlCharacter::getShape() const
97 return LyXFont::IGNORE_SHAPE;
98 return font_->shape();
102 void ControlCharacter::setShape(LyXFont::FONT_SHAPE val)
104 font_->setShape(val);
108 LyXFont::FONT_SIZE ControlCharacter::getSize() const
111 return LyXFont::IGNORE_SIZE;
112 return font_->size();
116 void ControlCharacter::setSize(LyXFont::FONT_SIZE val)
122 frnt::FONT_STATE ControlCharacter::getBar() const
127 if (font_->emph() == LyXFont::TOGGLE)
128 return frnt::EMPH_TOGGLE;
130 if (font_->underbar() == LyXFont::TOGGLE)
131 return frnt::UNDERBAR_TOGGLE;
133 if (font_->noun() == LyXFont::TOGGLE)
134 return frnt::NOUN_TOGGLE;
136 if (font_->emph() == LyXFont::IGNORE &&
137 font_->underbar() == LyXFont::IGNORE &&
138 font_->noun() == LyXFont::IGNORE)
141 return frnt::INHERIT;
145 void ControlCharacter::setBar(frnt::FONT_STATE val)
149 font_->setEmph(LyXFont::IGNORE);
150 font_->setUnderbar(LyXFont::IGNORE);
151 font_->setNoun(LyXFont::IGNORE);
154 case frnt::EMPH_TOGGLE:
155 font_->setEmph(LyXFont::TOGGLE);
158 case frnt::UNDERBAR_TOGGLE:
159 font_->setUnderbar(LyXFont::TOGGLE);
162 case frnt::NOUN_TOGGLE:
163 font_->setNoun(LyXFont::TOGGLE);
167 font_->setEmph(LyXFont::INHERIT);
168 font_->setUnderbar(LyXFont::INHERIT);
169 font_->setNoun(LyXFont::INHERIT);
175 LColor::color ControlCharacter::getColor() const
178 return LColor::ignore;
180 return font_->color();
184 void ControlCharacter::setColor(LColor::color val)
195 case LColor::magenta:
197 case LColor::inherit:
198 font_->setColor(val);
206 string ControlCharacter::getLanguage() const
208 if (font_.get() && font_->language())
209 return font_->language()->lang();
214 void ControlCharacter::setLanguage(string const & val)
217 font_->setLanguage(ignore_language);
219 else if (val == "reset")
220 font_->setLanguage(kernel().buffer().params.language);
223 font_->setLanguage(languages.getLanguage(val));
227 bool ControlCharacter::getToggleAll() const
233 void ControlCharacter::setToggleAll(bool t)