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;
28 ControlCharacter::ControlCharacter(Dialog & parent)
29 : Dialog::Controller(parent),
30 font_(0), toggleall_(false)
34 bool ControlCharacter::initialiseParams(string const &)
36 // Do this the first time only.
38 font_.reset(new LyXFont(LyXFont::ALL_IGNORE));
40 // so that the user can press Ok
41 if (getFamily() != LyXFont::IGNORE_FAMILY ||
42 getSeries() != LyXFont::IGNORE_SERIES ||
43 getShape() != LyXFont::IGNORE_SHAPE ||
44 getSize() != LyXFont::IGNORE_SIZE ||
45 getBar() != frnt::IGNORE ||
46 getColor() != LColor::ignore ||
47 font_->language() != ignore_language)
48 dialog().bc().valid();
54 void ControlCharacter::clearParams()
58 void ControlCharacter::dispatchParams()
60 // Nothing to dispatch. (Can be called from the Toolbar.)
65 if (font2string(*font_.get(), toggleall_, data)) {
66 kernel().dispatch(FuncRequest(LFUN_FREEFONT_UPDATE, data));
71 LyXFont::FONT_FAMILY ControlCharacter::getFamily() const
74 return LyXFont::IGNORE_FAMILY;
75 return font_->family();
79 void ControlCharacter::setFamily(LyXFont::FONT_FAMILY val)
81 font_->setFamily(val);
85 LyXFont::FONT_SERIES ControlCharacter::getSeries() const
88 return LyXFont::IGNORE_SERIES;
89 return font_->series();
93 void ControlCharacter::setSeries(LyXFont::FONT_SERIES val)
95 font_->setSeries(val);
99 LyXFont::FONT_SHAPE ControlCharacter::getShape() const
102 return LyXFont::IGNORE_SHAPE;
103 return font_->shape();
107 void ControlCharacter::setShape(LyXFont::FONT_SHAPE val)
109 font_->setShape(val);
113 LyXFont::FONT_SIZE ControlCharacter::getSize() const
116 return LyXFont::IGNORE_SIZE;
117 return font_->size();
121 void ControlCharacter::setSize(LyXFont::FONT_SIZE val)
127 frnt::FONT_STATE ControlCharacter::getBar() const
132 if (font_->emph() == LyXFont::TOGGLE)
133 return frnt::EMPH_TOGGLE;
135 if (font_->underbar() == LyXFont::TOGGLE)
136 return frnt::UNDERBAR_TOGGLE;
138 if (font_->noun() == LyXFont::TOGGLE)
139 return frnt::NOUN_TOGGLE;
141 if (font_->emph() == LyXFont::IGNORE &&
142 font_->underbar() == LyXFont::IGNORE &&
143 font_->noun() == LyXFont::IGNORE)
146 return frnt::INHERIT;
150 void ControlCharacter::setBar(frnt::FONT_STATE val)
154 font_->setEmph(LyXFont::IGNORE);
155 font_->setUnderbar(LyXFont::IGNORE);
156 font_->setNoun(LyXFont::IGNORE);
159 case frnt::EMPH_TOGGLE:
160 font_->setEmph(LyXFont::TOGGLE);
163 case frnt::UNDERBAR_TOGGLE:
164 font_->setUnderbar(LyXFont::TOGGLE);
167 case frnt::NOUN_TOGGLE:
168 font_->setNoun(LyXFont::TOGGLE);
172 font_->setEmph(LyXFont::INHERIT);
173 font_->setUnderbar(LyXFont::INHERIT);
174 font_->setNoun(LyXFont::INHERIT);
180 LColor_color ControlCharacter::getColor() const
183 return LColor::ignore;
185 return font_->color();
189 void ControlCharacter::setColor(LColor_color val)
200 case LColor::magenta:
202 case LColor::inherit:
203 font_->setColor(val);
211 string ControlCharacter::getLanguage() const
213 if (font_.get() && font_->language())
214 return font_->language()->lang();
219 void ControlCharacter::setLanguage(string const & val)
222 font_->setLanguage(ignore_language);
224 else if (val == "reset")
225 font_->setLanguage(kernel().buffer().params().language);
228 font_->setLanguage(languages.getLanguage(val));
232 bool ControlCharacter::getToggleAll() const
238 void ControlCharacter::setToggleAll(bool t)