2 * \file ControlCharacter.cpp
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"
16 #include "BufferParams.h"
17 #include "bufferview_funcs.h"
18 #include "FuncRequest.h"
22 using lyx::bv_funcs::font2string;
28 ControlCharacter::ControlCharacter(Dialog & parent)
29 : Dialog::Controller(parent),
30 font_(0), toggleall_(false), reset_lang_(false)
34 bool ControlCharacter::initialiseParams(string const &)
36 // Do this the first time only.
38 font_.reset(new Font(Font::ALL_IGNORE));
40 // so that the user can press Ok
41 if (getFamily() != Font::IGNORE_FAMILY ||
42 getSeries() != Font::IGNORE_SERIES ||
43 getShape() != Font::IGNORE_SHAPE ||
44 getSize() != Font::IGNORE_SIZE ||
46 getColor() != Color::ignore ||
47 font_->language() != ignore_language)
48 dialog().setButtonsValid(true);
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(getLfun(), data));
71 Font::FONT_FAMILY ControlCharacter::getFamily() const
74 return Font::IGNORE_FAMILY;
75 return font_->family();
79 void ControlCharacter::setFamily(Font::FONT_FAMILY val)
81 font_->setFamily(val);
85 Font::FONT_SERIES ControlCharacter::getSeries() const
88 return Font::IGNORE_SERIES;
89 return font_->series();
93 void ControlCharacter::setSeries(Font::FONT_SERIES val)
95 font_->setSeries(val);
99 Font::FONT_SHAPE ControlCharacter::getShape() const
102 return Font::IGNORE_SHAPE;
103 return font_->shape();
107 void ControlCharacter::setShape(Font::FONT_SHAPE val)
109 font_->setShape(val);
113 Font::FONT_SIZE ControlCharacter::getSize() const
116 return Font::IGNORE_SIZE;
117 return font_->size();
121 void ControlCharacter::setSize(Font::FONT_SIZE val)
127 FONT_STATE ControlCharacter::getBar() const
132 if (font_->emph() == Font::TOGGLE)
135 if (font_->underbar() == Font::TOGGLE)
136 return UNDERBAR_TOGGLE;
138 if (font_->noun() == Font::TOGGLE)
141 if (font_->emph() == Font::IGNORE &&
142 font_->underbar() == Font::IGNORE &&
143 font_->noun() == Font::IGNORE)
150 void ControlCharacter::setBar(FONT_STATE val)
154 font_->setEmph(Font::IGNORE);
155 font_->setUnderbar(Font::IGNORE);
156 font_->setNoun(Font::IGNORE);
160 font_->setEmph(Font::TOGGLE);
163 case UNDERBAR_TOGGLE:
164 font_->setUnderbar(Font::TOGGLE);
168 font_->setNoun(Font::TOGGLE);
172 font_->setEmph(Font::INHERIT);
173 font_->setUnderbar(Font::INHERIT);
174 font_->setNoun(Font::INHERIT);
180 Color_color ControlCharacter::getColor() const
183 return Color::ignore;
185 return font_->color();
189 void ControlCharacter::setColor(Color_color val)
203 font_->setColor(val);
211 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);
225 else if (val == "reset") {
227 // Ignored in getLanguage, but needed for dispatchParams
228 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