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"
22 using namespace bv_funcs;
24 ControlCharacter::ControlCharacter(Dialog & parent)
25 : Dialog::Controller(parent),
26 font_(0), toggleall_(false)
30 bool ControlCharacter::initialiseParams(string const &)
32 // Do this the first time only.
34 font_.reset(new LyXFont(LyXFont::ALL_IGNORE));
36 // so that the user can press Ok
37 if (getFamily() != LyXFont::IGNORE_FAMILY ||
38 getSeries() != LyXFont::IGNORE_SERIES ||
39 getShape() != LyXFont::IGNORE_SHAPE ||
40 getSize() != LyXFont::IGNORE_SIZE ||
41 getBar() != frnt::IGNORE ||
42 getColor() != LColor::ignore ||
43 font_->language() != ignore_language)
44 dialog().bc().valid();
50 void ControlCharacter::clearParams()
54 void ControlCharacter::dispatchParams()
56 // Nothing to dispatch. (Can be called from the Toolbar.)
61 if (font2string(*font_.get(), toggleall_, data)) {
62 kernel().dispatch(FuncRequest(LFUN_FREEFONT_UPDATE, data));
67 LyXFont::FONT_FAMILY ControlCharacter::getFamily() const
70 return LyXFont::IGNORE_FAMILY;
71 return font_->family();
75 void ControlCharacter::setFamily(LyXFont::FONT_FAMILY val)
77 font_->setFamily(val);
81 LyXFont::FONT_SERIES ControlCharacter::getSeries() const
84 return LyXFont::IGNORE_SERIES;
85 return font_->series();
89 void ControlCharacter::setSeries(LyXFont::FONT_SERIES val)
91 font_->setSeries(val);
95 LyXFont::FONT_SHAPE ControlCharacter::getShape() const
98 return LyXFont::IGNORE_SHAPE;
99 return font_->shape();
103 void ControlCharacter::setShape(LyXFont::FONT_SHAPE val)
105 font_->setShape(val);
109 LyXFont::FONT_SIZE ControlCharacter::getSize() const
112 return LyXFont::IGNORE_SIZE;
113 return font_->size();
117 void ControlCharacter::setSize(LyXFont::FONT_SIZE val)
123 frnt::FONT_STATE ControlCharacter::getBar() const
128 if (font_->emph() == LyXFont::TOGGLE)
129 return frnt::EMPH_TOGGLE;
131 if (font_->underbar() == LyXFont::TOGGLE)
132 return frnt::UNDERBAR_TOGGLE;
134 if (font_->noun() == LyXFont::TOGGLE)
135 return frnt::NOUN_TOGGLE;
137 if (font_->emph() == LyXFont::IGNORE &&
138 font_->underbar() == LyXFont::IGNORE &&
139 font_->noun() == LyXFont::IGNORE)
142 return frnt::INHERIT;
146 void ControlCharacter::setBar(frnt::FONT_STATE val)
150 font_->setEmph(LyXFont::IGNORE);
151 font_->setUnderbar(LyXFont::IGNORE);
152 font_->setNoun(LyXFont::IGNORE);
155 case frnt::EMPH_TOGGLE:
156 font_->setEmph(LyXFont::TOGGLE);
159 case frnt::UNDERBAR_TOGGLE:
160 font_->setUnderbar(LyXFont::TOGGLE);
163 case frnt::NOUN_TOGGLE:
164 font_->setNoun(LyXFont::TOGGLE);
168 font_->setEmph(LyXFont::INHERIT);
169 font_->setUnderbar(LyXFont::INHERIT);
170 font_->setNoun(LyXFont::INHERIT);
176 LColor::color ControlCharacter::getColor() const
179 return LColor::ignore;
181 return font_->color();
185 void ControlCharacter::setColor(LColor::color val)
196 case LColor::magenta:
198 case LColor::inherit:
199 font_->setColor(val);
207 string ControlCharacter::getLanguage() const
209 if (font_.get() && font_->language())
210 return font_->language()->lang();
215 void ControlCharacter::setLanguage(string const & val)
218 font_->setLanguage(ignore_language);
220 else if (val == "reset")
221 font_->setLanguage(kernel().buffer()->params.language);
224 font_->setLanguage(languages.getLanguage(val));
228 bool ControlCharacter::getToggleAll() const
234 void ControlCharacter::setToggleAll(bool t)