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
14 #include "ControlCharacter.h"
17 #include "ButtonControllerBase.h"
20 #include "bufferview_funcs.h" // ToggleAndShow
24 #include "frontends/LyXView.h"
27 ControlCharacter::ControlCharacter(LyXView & lv, Dialogs & d)
28 : ControlDialogBD(lv, d),
29 font_(0), toggleall_(false)
33 void ControlCharacter::setParams()
35 // Do this the first time only. Used as a flag for whether or not the
36 // view has been built
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)
52 void ControlCharacter::apply()
54 // Nothing to apply. (Can be called from the Toolbar.)
58 // Apply from the view if it's visible. Otherwise, use the stored values
59 if (bufferIsAvailable())
62 toggleAndShow(bufferview(), *(font_.get()), toggleall_);
63 lv_.view_state_changed();
64 buffer()->markDirty();
65 lv_.message(_("Character set"));
69 LyXFont::FONT_FAMILY ControlCharacter::getFamily() const
72 return LyXFont::IGNORE_FAMILY;
73 return font_->family();
77 void ControlCharacter::setFamily(LyXFont::FONT_FAMILY val)
79 font_->setFamily(val);
83 LyXFont::FONT_SERIES ControlCharacter::getSeries() const
86 return LyXFont::IGNORE_SERIES;
87 return font_->series();
91 void ControlCharacter::setSeries(LyXFont::FONT_SERIES val)
93 font_->setSeries(val);
97 LyXFont::FONT_SHAPE ControlCharacter::getShape() const
100 return LyXFont::IGNORE_SHAPE;
101 return font_->shape();
105 void ControlCharacter::setShape(LyXFont::FONT_SHAPE val)
107 font_->setShape(val);
111 LyXFont::FONT_SIZE ControlCharacter::getSize() const
114 return LyXFont::IGNORE_SIZE;
115 return font_->size();
119 void ControlCharacter::setSize(LyXFont::FONT_SIZE val)
125 frnt::FONT_STATE ControlCharacter::getBar() const
130 if (font_->emph() == LyXFont::TOGGLE)
131 return frnt::EMPH_TOGGLE;
133 if (font_->underbar() == LyXFont::TOGGLE)
134 return frnt::UNDERBAR_TOGGLE;
136 if (font_->noun() == LyXFont::TOGGLE)
137 return frnt::NOUN_TOGGLE;
139 if (font_->emph() == LyXFont::IGNORE &&
140 font_->underbar() == LyXFont::IGNORE &&
141 font_->noun() == LyXFont::IGNORE)
144 return frnt::INHERIT;
148 void ControlCharacter::setBar(frnt::FONT_STATE val)
152 font_->setEmph(LyXFont::IGNORE);
153 font_->setUnderbar(LyXFont::IGNORE);
154 font_->setNoun(LyXFont::IGNORE);
157 case frnt::EMPH_TOGGLE:
158 font_->setEmph(LyXFont::TOGGLE);
161 case frnt::UNDERBAR_TOGGLE:
162 font_->setUnderbar(LyXFont::TOGGLE);
165 case frnt::NOUN_TOGGLE:
166 font_->setNoun(LyXFont::TOGGLE);
170 font_->setEmph(LyXFont::INHERIT);
171 font_->setUnderbar(LyXFont::INHERIT);
172 font_->setNoun(LyXFont::INHERIT);
178 LColor::color ControlCharacter::getColor() const
181 return LColor::ignore;
183 return font_->color();
187 void ControlCharacter::setColor(LColor::color val)
198 case LColor::magenta:
200 case LColor::inherit:
201 font_->setColor(val);
209 string ControlCharacter::getLanguage() const
211 if (font_.get() && font_->language())
212 return font_->language()->lang();
217 void ControlCharacter::setLanguage(string const & val)
220 font_->setLanguage(ignore_language);
222 else if (val == "reset")
223 font_->setLanguage(buffer()->params.language);
226 font_->setLanguage(languages.getLanguage(val));
230 bool ControlCharacter::getToggleAll() const
236 void ControlCharacter::setToggleAll(bool t)