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"
23 ControlCharacter::ControlCharacter(Dialog & parent)
24 : Dialog::Controller(parent),
25 font_(0), toggleall_(false)
29 void 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();
47 void ControlCharacter::clearParams()
51 void ControlCharacter::dispatchParams()
53 // Nothing to dispatch. (Can be called from the Toolbar.)
58 if (font2string(*font_.get(), toggleall_, data)) {
59 kernel().dispatch(FuncRequest(LFUN_FREEFONT_UPDATE, data));
64 LyXFont::FONT_FAMILY ControlCharacter::getFamily() const
67 return LyXFont::IGNORE_FAMILY;
68 return font_->family();
72 void ControlCharacter::setFamily(LyXFont::FONT_FAMILY val)
74 font_->setFamily(val);
78 LyXFont::FONT_SERIES ControlCharacter::getSeries() const
81 return LyXFont::IGNORE_SERIES;
82 return font_->series();
86 void ControlCharacter::setSeries(LyXFont::FONT_SERIES val)
88 font_->setSeries(val);
92 LyXFont::FONT_SHAPE ControlCharacter::getShape() const
95 return LyXFont::IGNORE_SHAPE;
96 return font_->shape();
100 void ControlCharacter::setShape(LyXFont::FONT_SHAPE val)
102 font_->setShape(val);
106 LyXFont::FONT_SIZE ControlCharacter::getSize() const
109 return LyXFont::IGNORE_SIZE;
110 return font_->size();
114 void ControlCharacter::setSize(LyXFont::FONT_SIZE val)
120 frnt::FONT_STATE ControlCharacter::getBar() const
125 if (font_->emph() == LyXFont::TOGGLE)
126 return frnt::EMPH_TOGGLE;
128 if (font_->underbar() == LyXFont::TOGGLE)
129 return frnt::UNDERBAR_TOGGLE;
131 if (font_->noun() == LyXFont::TOGGLE)
132 return frnt::NOUN_TOGGLE;
134 if (font_->emph() == LyXFont::IGNORE &&
135 font_->underbar() == LyXFont::IGNORE &&
136 font_->noun() == LyXFont::IGNORE)
139 return frnt::INHERIT;
143 void ControlCharacter::setBar(frnt::FONT_STATE val)
147 font_->setEmph(LyXFont::IGNORE);
148 font_->setUnderbar(LyXFont::IGNORE);
149 font_->setNoun(LyXFont::IGNORE);
152 case frnt::EMPH_TOGGLE:
153 font_->setEmph(LyXFont::TOGGLE);
156 case frnt::UNDERBAR_TOGGLE:
157 font_->setUnderbar(LyXFont::TOGGLE);
160 case frnt::NOUN_TOGGLE:
161 font_->setNoun(LyXFont::TOGGLE);
165 font_->setEmph(LyXFont::INHERIT);
166 font_->setUnderbar(LyXFont::INHERIT);
167 font_->setNoun(LyXFont::INHERIT);
173 LColor::color ControlCharacter::getColor() const
176 return LColor::ignore;
178 return font_->color();
182 void ControlCharacter::setColor(LColor::color val)
193 case LColor::magenta:
195 case LColor::inherit:
196 font_->setColor(val);
204 string ControlCharacter::getLanguage() const
206 if (font_.get() && font_->language())
207 return font_->language()->lang();
212 void ControlCharacter::setLanguage(string const & val)
215 font_->setLanguage(ignore_language);
217 else if (val == "reset")
218 font_->setLanguage(kernel().buffer()->params.language);
221 font_->setLanguage(languages.getLanguage(val));
225 bool ControlCharacter::getToggleAll() const
231 void ControlCharacter::setToggleAll(bool t)