*
* \author Angus Leeming
*
- * Full author contact details are available in file CREDITS
+ * Full author contact details are available in file CREDITS.
*/
#include <config.h>
-
#include "ControlCharacter.h"
-
-#include "ViewBase.h"
-#include "ButtonControllerBase.h"
+#include "ButtonController.h"
#include "buffer.h"
-#include "bufferview_funcs.h" // ToggleAndShow
-#include "gettext.h"
+#include "bufferparams.h"
+#include "bufferview_funcs.h"
+#include "funcrequest.h"
#include "language.h"
+#include "LColor.h"
+
+using bv_funcs::font2string;
-#include "frontends/LyXView.h"
+using std::string;
+namespace lyx {
+namespace frontend {
-ControlCharacter::ControlCharacter(LyXView & lv, Dialogs & d)
- : ControlDialogBD(lv, d),
+ControlCharacter::ControlCharacter(Dialog & parent)
+ : Dialog::Controller(parent),
font_(0), toggleall_(false)
{}
-void ControlCharacter::setParams()
+bool ControlCharacter::initialiseParams(string const &)
{
- // Do this the first time only. Used as a flag for whether or not the
- // view has been built
+ // Do this the first time only.
if (!font_.get())
font_.reset(new LyXFont(LyXFont::ALL_IGNORE));
getSeries() != LyXFont::IGNORE_SERIES ||
getShape() != LyXFont::IGNORE_SHAPE ||
getSize() != LyXFont::IGNORE_SIZE ||
- getBar() != frnt::IGNORE ||
+ getBar() != IGNORE ||
getColor() != LColor::ignore ||
font_->language() != ignore_language)
- bc().valid();
+ dialog().bc().valid();
+
+ return true;
}
-void ControlCharacter::apply()
+void ControlCharacter::clearParams()
+{}
+
+
+void ControlCharacter::dispatchParams()
{
- // Nothing to apply. (Can be called from the Toolbar.)
+ // Nothing to dispatch. (Can be called from the Toolbar.)
if (!font_.get())
return;
- // Apply from the view if it's visible. Otherwise, use the stored values
- if (bufferIsAvailable())
- view().apply();
-
- toggleAndShow(bufferview(), *(font_.get()), toggleall_);
- lv_.view_state_changed();
- buffer()->markDirty();
- lv_.message(_("Character set"));
+ string data;
+ if (font2string(*font_.get(), toggleall_, data)) {
+ kernel().dispatch(FuncRequest(getLfun(), data));
+ }
}
}
-frnt::FONT_STATE ControlCharacter::getBar() const
+FONT_STATE ControlCharacter::getBar() const
{
if (!font_.get())
- return frnt::IGNORE;
+ return IGNORE;
if (font_->emph() == LyXFont::TOGGLE)
- return frnt::EMPH_TOGGLE;
+ return EMPH_TOGGLE;
if (font_->underbar() == LyXFont::TOGGLE)
- return frnt::UNDERBAR_TOGGLE;
+ return UNDERBAR_TOGGLE;
if (font_->noun() == LyXFont::TOGGLE)
- return frnt::NOUN_TOGGLE;
+ return NOUN_TOGGLE;
if (font_->emph() == LyXFont::IGNORE &&
font_->underbar() == LyXFont::IGNORE &&
font_->noun() == LyXFont::IGNORE)
- return frnt::IGNORE;
+ return IGNORE;
- return frnt::INHERIT;
+ return INHERIT;
}
-void ControlCharacter::setBar(frnt::FONT_STATE val)
+void ControlCharacter::setBar(FONT_STATE val)
{
switch (val) {
- case frnt::IGNORE:
+ case IGNORE:
font_->setEmph(LyXFont::IGNORE);
font_->setUnderbar(LyXFont::IGNORE);
font_->setNoun(LyXFont::IGNORE);
break;
- case frnt::EMPH_TOGGLE:
+ case EMPH_TOGGLE:
font_->setEmph(LyXFont::TOGGLE);
break;
- case frnt::UNDERBAR_TOGGLE:
+ case UNDERBAR_TOGGLE:
font_->setUnderbar(LyXFont::TOGGLE);
break;
- case frnt::NOUN_TOGGLE:
+ case NOUN_TOGGLE:
font_->setNoun(LyXFont::TOGGLE);
break;
- case frnt::INHERIT:
+ case INHERIT:
font_->setEmph(LyXFont::INHERIT);
font_->setUnderbar(LyXFont::INHERIT);
font_->setNoun(LyXFont::INHERIT);
}
-LColor::color ControlCharacter::getColor() const
+LColor_color ControlCharacter::getColor() const
{
if (!font_.get())
return LColor::ignore;
}
-void ControlCharacter::setColor(LColor::color val)
+void ControlCharacter::setColor(LColor_color val)
{
switch (val) {
case LColor::ignore:
font_->setLanguage(ignore_language);
else if (val == "reset")
- font_->setLanguage(buffer()->params.language);
+ font_->setLanguage(kernel().buffer().params().language);
else
font_->setLanguage(languages.getLanguage(val));
{
toggleall_ = t;
}
+
+} // namespace frontend
+} // namespace lyx