/**
* \file ControlCharacter.C
- * Copyright 2001 The LyX Team.
- * See the file COPYING.
+ * This file is part of LyX, the document processor.
+ * Licence details can be found in the file COPYING.
*
- * \author Angus Leeming, a.leeming@.ac.uk
+ * \author Angus Leeming
+ *
+ * Full author contact details are available in file CREDITS.
*/
-#include <vector>
-
-#ifdef __GNUG__
-#pragma implementation
-#endif
-
#include <config.h>
-#include "ViewBase.h"
-#include "ButtonControllerBase.h"
#include "ControlCharacter.h"
+#include "ButtonController.h"
+
#include "buffer.h"
-#include "Dialogs.h"
-#include "Liason.h"
-#include "LyXView.h"
-#include "bufferview_funcs.h" // ToggleAndShow
-#include "gettext.h"
+#include "bufferparams.h"
+#include "bufferview_funcs.h"
+#include "funcrequest.h"
#include "language.h"
-#include "BufferView.h"
+#include "LColor.h"
+
+using bv_funcs::font2string;
-using Liason::setMinibuffer;
-using SigC::slot;
-using std::vector;
+using std::string;
+namespace lyx {
+namespace frontend {
-ControlCharacter::ControlCharacter(LyXView & lv, Dialogs & d)
- : ControlDialog<ControlConnectBD>(lv, d),
+ControlCharacter::ControlCharacter(Dialog & parent)
+ : Dialog::Controller(parent),
font_(0), toggleall_(false)
-{
- d_.showCharacter.connect(slot(this, &ControlCharacter::show));
- d_.setUserFreeFont.connect(slot(this, &ControlCharacter::apply));
-}
+{}
-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() != character::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 (lv_.view()->available())
- view().apply();
-
- toggleAndShow(lv_.view(), *(font_.get()), toggleall_);
- lv_.view()->setState();
- lv_.buffer()->markDirty();
- setMinibuffer(&lv_, _("Character set"));
+ string data;
+ if (font2string(*font_.get(), toggleall_, data)) {
+ kernel().dispatch(FuncRequest(getLfun(), data));
+ }
}
LyXFont::FONT_FAMILY ControlCharacter::getFamily() const
{
- if (font_.get())
- return font_->family();
- return LyXFont::IGNORE_FAMILY;
+ if (!font_.get())
+ return LyXFont::IGNORE_FAMILY;
+ return font_->family();
}
LyXFont::FONT_SERIES ControlCharacter::getSeries() const
{
- if (font_.get())
- return font_->series();
- return LyXFont::IGNORE_SERIES;
+ if (!font_.get())
+ return LyXFont::IGNORE_SERIES;
+ return font_->series();
}
LyXFont::FONT_SHAPE ControlCharacter::getShape() const
{
- if (font_.get())
- return font_->shape();
- return LyXFont::IGNORE_SHAPE;
+ if (!font_.get())
+ return LyXFont::IGNORE_SHAPE;
+ return font_->shape();
}
LyXFont::FONT_SIZE ControlCharacter::getSize() const
{
- if (font_.get())
- return font_->size();
- return LyXFont::IGNORE_SIZE;
+ if (!font_.get())
+ return LyXFont::IGNORE_SIZE;
+ return font_->size();
}
}
-character::FONT_STATE ControlCharacter::getBar() const
+FONT_STATE ControlCharacter::getBar() const
{
- if (font_.get()) {
- if (font_->emph() != LyXFont::IGNORE)
- return character::EMPH_TOGGLE;
+ if (!font_.get())
+ return IGNORE;
- else if (font_->underbar() != LyXFont::IGNORE)
- return character::UNDERBAR_TOGGLE;
+ if (font_->emph() == LyXFont::TOGGLE)
+ return EMPH_TOGGLE;
- else if (font_->noun() != LyXFont::IGNORE)
- return character::NOUN_TOGGLE;
- }
- return character::IGNORE;
+ if (font_->underbar() == LyXFont::TOGGLE)
+ return UNDERBAR_TOGGLE;
+
+ if (font_->noun() == LyXFont::TOGGLE)
+ return NOUN_TOGGLE;
+
+ if (font_->emph() == LyXFont::IGNORE &&
+ font_->underbar() == LyXFont::IGNORE &&
+ font_->noun() == LyXFont::IGNORE)
+ return IGNORE;
+
+ return INHERIT;
}
-void ControlCharacter::setBar(character::FONT_STATE val)
+void ControlCharacter::setBar(FONT_STATE val)
{
switch (val) {
- case character::IGNORE:
+ case IGNORE:
font_->setEmph(LyXFont::IGNORE);
font_->setUnderbar(LyXFont::IGNORE);
font_->setNoun(LyXFont::IGNORE);
break;
- case character::EMPH_TOGGLE:
+ case EMPH_TOGGLE:
font_->setEmph(LyXFont::TOGGLE);
break;
- case character::UNDERBAR_TOGGLE:
+ case UNDERBAR_TOGGLE:
font_->setUnderbar(LyXFont::TOGGLE);
break;
- case character::NOUN_TOGGLE:
+ case NOUN_TOGGLE:
font_->setNoun(LyXFont::TOGGLE);
break;
- case character::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
{
- LColor::color col = LColor::ignore;
-
- if (font_.get()) {
- switch (font_->color()) {
- case LColor::ignore:
- case LColor::none:
- case LColor::black:
- case LColor::white:
- case LColor::red:
- case LColor::green:
- case LColor::blue:
- case LColor::cyan:
- case LColor::magenta:
- case LColor::yellow:
- case LColor::inherit:
- break;
- default:
- col = font_->color();
- break;
- }
- }
+ if (!font_.get())
+ return LColor::ignore;
- return col;
+ return font_->color();
}
-void ControlCharacter::setColor(LColor::color val)
+void ControlCharacter::setColor(LColor_color val)
{
switch (val) {
case LColor::ignore:
{
if (font_.get() && font_->language())
return font_->language()->lang();
- return _("No change");
+ return "ignore";
}
void ControlCharacter::setLanguage(string const & val)
{
- if (val == _("No change"))
+ if (val == "ignore")
font_->setLanguage(ignore_language);
- else if ( val == _("Reset"))
- font_->setLanguage(lv_.buffer()->params.language);
+ else if (val == "reset")
+ font_->setLanguage(kernel().buffer().params().language);
else
font_->setLanguage(languages.getLanguage(val));
{
toggleall_ = t;
}
+
+} // namespace frontend
+} // namespace lyx