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;
30 ControlCharacter::ControlCharacter(Dialog & parent)
31 : Dialog::Controller(parent),
32 font_(0), toggleall_(false)
36 bool ControlCharacter::initialiseParams(string const &)
38 // Do this the first time only.
40 font_.reset(new LyXFont(LyXFont::ALL_IGNORE));
42 // so that the user can press Ok
43 if (getFamily() != LyXFont::IGNORE_FAMILY ||
44 getSeries() != LyXFont::IGNORE_SERIES ||
45 getShape() != LyXFont::IGNORE_SHAPE ||
46 getSize() != LyXFont::IGNORE_SIZE ||
48 getColor() != LColor::ignore ||
49 font_->language() != ignore_language)
50 dialog().bc().valid();
56 void ControlCharacter::clearParams()
60 void ControlCharacter::dispatchParams()
62 // Nothing to dispatch. (Can be called from the Toolbar.)
67 if (font2string(*font_.get(), toggleall_, data)) {
68 kernel().dispatch(FuncRequest(LFUN_FREEFONT_UPDATE, data));
73 LyXFont::FONT_FAMILY ControlCharacter::getFamily() const
76 return LyXFont::IGNORE_FAMILY;
77 return font_->family();
81 void ControlCharacter::setFamily(LyXFont::FONT_FAMILY val)
83 font_->setFamily(val);
87 LyXFont::FONT_SERIES ControlCharacter::getSeries() const
90 return LyXFont::IGNORE_SERIES;
91 return font_->series();
95 void ControlCharacter::setSeries(LyXFont::FONT_SERIES val)
97 font_->setSeries(val);
101 LyXFont::FONT_SHAPE ControlCharacter::getShape() const
104 return LyXFont::IGNORE_SHAPE;
105 return font_->shape();
109 void ControlCharacter::setShape(LyXFont::FONT_SHAPE val)
111 font_->setShape(val);
115 LyXFont::FONT_SIZE ControlCharacter::getSize() const
118 return LyXFont::IGNORE_SIZE;
119 return font_->size();
123 void ControlCharacter::setSize(LyXFont::FONT_SIZE val)
129 FONT_STATE ControlCharacter::getBar() const
134 if (font_->emph() == LyXFont::TOGGLE)
137 if (font_->underbar() == LyXFont::TOGGLE)
138 return UNDERBAR_TOGGLE;
140 if (font_->noun() == LyXFont::TOGGLE)
143 if (font_->emph() == LyXFont::IGNORE &&
144 font_->underbar() == LyXFont::IGNORE &&
145 font_->noun() == LyXFont::IGNORE)
152 void ControlCharacter::setBar(FONT_STATE val)
156 font_->setEmph(LyXFont::IGNORE);
157 font_->setUnderbar(LyXFont::IGNORE);
158 font_->setNoun(LyXFont::IGNORE);
162 font_->setEmph(LyXFont::TOGGLE);
165 case UNDERBAR_TOGGLE:
166 font_->setUnderbar(LyXFont::TOGGLE);
170 font_->setNoun(LyXFont::TOGGLE);
174 font_->setEmph(LyXFont::INHERIT);
175 font_->setUnderbar(LyXFont::INHERIT);
176 font_->setNoun(LyXFont::INHERIT);
182 LColor_color ControlCharacter::getColor() const
185 return LColor::ignore;
187 return font_->color();
191 void ControlCharacter::setColor(LColor_color val)
202 case LColor::magenta:
204 case LColor::inherit:
205 font_->setColor(val);
213 string ControlCharacter::getLanguage() const
215 if (font_.get() && font_->language())
216 return font_->language()->lang();
221 void ControlCharacter::setLanguage(string const & val)
224 font_->setLanguage(ignore_language);
226 else if (val == "reset")
227 font_->setLanguage(kernel().buffer().params().language);
230 font_->setLanguage(languages.getLanguage(val));
234 bool ControlCharacter::getToggleAll() const
240 void ControlCharacter::setToggleAll(bool t)
245 } // namespace frontend