+++ /dev/null
-/**
- * \file ControlCharacter.cpp
- * This file is part of LyX, the document processor.
- * Licence details can be found in the file COPYING.
- *
- * \author Angus Leeming
- *
- * Full author contact details are available in file CREDITS.
- */
-
-#include <config.h>
-
-#include "ControlCharacter.h"
-
-#include "Buffer.h"
-#include "BufferParams.h"
-#include "FuncRequest.h"
-#include "Language.h"
-#include "Color.h"
-
-using std::string;
-
-namespace lyx {
-namespace frontend {
-
-ControlCharacter::ControlCharacter(Dialog & parent)
- : Controller(parent), font_(Font::ALL_IGNORE),
- toggleall_(false), reset_lang_(false)
-{}
-
-
-bool ControlCharacter::initialiseParams(string const &)
-{
- // so that the user can press Ok
- if (getFamily() != Font::IGNORE_FAMILY
- || getSeries() != Font::IGNORE_SERIES
- || getShape() != Font::IGNORE_SHAPE
- || getSize() != Font::IGNORE_SIZE
- || getBar() != IGNORE
- || getColor() != Color::ignore
- || font_.language() != ignore_language)
- dialog().setButtonsValid(true);
-
- return true;
-}
-
-
-void ControlCharacter::dispatchParams()
-{
- dispatch(FuncRequest(getLfun(), font_.toString(toggleall_)));
-}
-
-
-Font::FONT_FAMILY ControlCharacter::getFamily() const
-{
- return font_.family();
-}
-
-
-void ControlCharacter::setFamily(Font::FONT_FAMILY val)
-{
- font_.setFamily(val);
-}
-
-
-Font::FONT_SERIES ControlCharacter::getSeries() const
-{
- return font_.series();
-}
-
-
-void ControlCharacter::setSeries(Font::FONT_SERIES val)
-{
- font_.setSeries(val);
-}
-
-
-Font::FONT_SHAPE ControlCharacter::getShape() const
-{
- return font_.shape();
-}
-
-
-void ControlCharacter::setShape(Font::FONT_SHAPE val)
-{
- font_.setShape(val);
-}
-
-
-Font::FONT_SIZE ControlCharacter::getSize() const
-{
- return font_.size();
-}
-
-
-void ControlCharacter::setSize(Font::FONT_SIZE val)
-{
- font_.setSize(val);
-}
-
-
-FONT_STATE ControlCharacter::getBar() const
-{
- if (font_.emph() == Font::TOGGLE)
- return EMPH_TOGGLE;
-
- if (font_.underbar() == Font::TOGGLE)
- return UNDERBAR_TOGGLE;
-
- if (font_.noun() == Font::TOGGLE)
- return NOUN_TOGGLE;
-
- if (font_.emph() == Font::IGNORE
- && font_.underbar() == Font::IGNORE
- && font_.noun() == Font::IGNORE)
- return IGNORE;
-
- return INHERIT;
-}
-
-
-void ControlCharacter::setBar(FONT_STATE val)
-{
- switch (val) {
- case IGNORE:
- font_.setEmph(Font::IGNORE);
- font_.setUnderbar(Font::IGNORE);
- font_.setNoun(Font::IGNORE);
- break;
-
- case EMPH_TOGGLE:
- font_.setEmph(Font::TOGGLE);
- break;
-
- case UNDERBAR_TOGGLE:
- font_.setUnderbar(Font::TOGGLE);
- break;
-
- case NOUN_TOGGLE:
- font_.setNoun(Font::TOGGLE);
- break;
-
- case INHERIT:
- font_.setEmph(Font::INHERIT);
- font_.setUnderbar(Font::INHERIT);
- font_.setNoun(Font::INHERIT);
- break;
- }
-}
-
-
-Color_color ControlCharacter::getColor() const
-{
- return font_.color();
-}
-
-
-void ControlCharacter::setColor(Color_color val)
-{
- switch (val) {
- case Color::ignore:
- case Color::none:
- case Color::black:
- case Color::white:
- case Color::red:
- case Color::green:
- case Color::blue:
- case Color::cyan:
- case Color::magenta:
- case Color::yellow:
- case Color::inherit:
- font_.setColor(val);
- break;
- default:
- break;
- }
-}
-
-
-string ControlCharacter::getLanguage() const
-{
- if (reset_lang_)
- return "reset";
- if (font_.language())
- return font_.language()->lang();
- return "ignore";
-}
-
-
-void ControlCharacter::setLanguage(string const & val)
-{
- if (val == "ignore")
- font_.setLanguage(ignore_language);
- else if (val == "reset") {
- reset_lang_ = true;
- // Ignored in getLanguage, but needed for dispatchParams
- font_.setLanguage(buffer().params().language);
- } else {
- font_.setLanguage(languages.getLanguage(val));
- }
-}
-
-
-bool ControlCharacter::getToggleAll() const
-{
- return toggleall_;
-}
-
-
-void ControlCharacter::setToggleAll(bool t)
-{
- toggleall_ = t;
-}
-
-} // namespace frontend
-} // namespace lyx
+++ /dev/null
-// -*- C++ -*-
-/**
- * \file ControlCharacter.h
- * This file is part of LyX, the document processor.
- * Licence details can be found in the file COPYING.
- *
- * \author Angus Leeming
- *
- * Full author contact details are available in file CREDITS.
- */
-
-#ifndef CONTROLCHARACTER_H
-#define CONTROLCHARACTER_H
-
-#include "Dialog.h"
-#include "Font.h"
-
-namespace lyx {
-
-class Color_color;
-
-namespace frontend {
-
-enum FONT_STATE {
- ///
- IGNORE,
- ///
- EMPH_TOGGLE,
- ///
- UNDERBAR_TOGGLE,
- ///
- NOUN_TOGGLE,
- ///
- INHERIT
-};
-
-class ControlCharacter : public Controller
-{
-public:
- ///
- ControlCharacter(Dialog &);
- ///
- virtual bool initialiseParams(std::string const & data);
- ///
- virtual void clearParams() {}
- ///
- virtual void dispatchParams();
- ///
- virtual bool isBufferDependent() const { return true; }
- ///
- virtual kb_action getLfun() const { return LFUN_FONT_FREE_UPDATE; }
-
- ///
- void setFamily(Font::FONT_FAMILY);
- ///
- void setSeries(Font::FONT_SERIES);
- ///
- void setShape(Font::FONT_SHAPE);
- ///
- void setSize(Font::FONT_SIZE);
- ///
- void setBar(FONT_STATE);
- ///
- void setColor(Color_color);
- ///
- void setLanguage(std::string const &);
- ///
- void setToggleAll(bool);
-
- ///
- Font::FONT_FAMILY getFamily() const;
- ///
- Font::FONT_SERIES getSeries() const;
- ///
- Font::FONT_SHAPE getShape() const;
- ///
- Font::FONT_SIZE getSize() const;
- ///
- FONT_STATE getBar() const;
- ///
- Color_color getColor() const;
- ///
- std::string getLanguage() const;
- ///
- bool getToggleAll() const;
-private:
- ///
- Font font_;
- ///
- bool toggleall_;
- /// If true the language should be reset.
- /// If false the language of font_ is used.
- bool reset_lang_;
-};
-
-} // namespace frontend
-} // namespace lyx
-
-#endif // CONTROLCHARACTER_H
SOURCEFILES = \
Dialog.cpp \
ButtonPolicy.cpp \
- ControlCharacter.cpp \
ControlCitation.cpp \
ControlCommand.cpp \
ControlCommandBuffer.cpp \
HEADERFILES = \
ButtonPolicy.h \
- ControlCharacter.h \
ControlCitation.h \
ControlCommand.h \
ControlCommandBuffer.h \
#include "DialogView.h"
#include "DockView.h"
#include "GuiBibitem.h"
-#include "GuiCharacter.h"
#include "GuiCitation.h"
#include "GuiDelimiter.h"
#include "GuiDocument.h"
} else if (name == "changes") {
dialog = createGuiChanges(lyxview_);
} else if (name == "character") {
- dialog = new GuiCharacterDialog(lyxview_);
+ dialog = createGuiCharacter(lyxview_);
} else if (name == "citation") {
dialog = new GuiCitationDialog(lyxview_);
} else if (name == "document") {
* This file is part of LyX, the document processor.
* Licence details can be found in the file COPYING.
*
+ * \author Angus Leeming
* \author Edwin Leuven
* \author John Levon
*
#include "GuiCharacter.h"
-#include "ControlCharacter.h"
#include "qt_helpers.h"
#include "Color.h"
#include "Font.h"
+#include "Buffer.h"
+#include "BufferParams.h"
+#include "FuncRequest.h"
+#include "Language.h"
+#include "Color.h"
#include <QCloseEvent>
using std::vector;
+using std::string;
+
namespace lyx {
namespace frontend {
}
-GuiCharacterDialog::GuiCharacterDialog(LyXView & lv)
- : GuiDialog(lv, "character")
+GuiCharacter::GuiCharacter(LyXView & lv)
+ : GuiDialog(lv, "character"), Controller(this), font_(Font::ALL_IGNORE),
+ toggleall_(false), reset_lang_(false)
{
setupUi(this);
- setController(new ControlCharacter(*this));
+ setController(this, false);
setViewTitle(_("Text Style"));
connect(okPB, SIGNAL(clicked()), this, SLOT(slotOK()));
}
-ControlCharacter & GuiCharacterDialog::controller()
-{
- return static_cast<ControlCharacter &>(GuiDialog::controller());
-}
-
-
-void GuiCharacterDialog::change_adaptor()
+void GuiCharacter::change_adaptor()
{
changed();
}
-void GuiCharacterDialog::closeEvent(QCloseEvent * e)
+void GuiCharacter::closeEvent(QCloseEvent * e)
{
slotClose();
GuiDialog::closeEvent(e);
}
-void GuiCharacterDialog::updateContents()
+void GuiCharacter::updateContents()
+{
+ familyCO->setCurrentIndex(findPos2nd(family, getFamily()));
+ seriesCO->setCurrentIndex(findPos2nd(series, getSeries()));
+ shapeCO->setCurrentIndex(findPos2nd(shape, getShape()));
+ sizeCO->setCurrentIndex(findPos2nd(size, getSize()));
+ miscCO->setCurrentIndex(findPos2nd(bar, getBar()));
+ colorCO->setCurrentIndex(findPos2nd(color, getColor()));
+ langCO->setCurrentIndex(findPos2nd(language, getLanguage()));
+
+ toggleallCB->setChecked(getToggleAll());
+}
+
+
+void GuiCharacter::applyView()
+{
+ setFamily(family[familyCO->currentIndex()].second);
+ setSeries(series[seriesCO->currentIndex()].second);
+ setShape(shape[shapeCO->currentIndex()].second);
+ setSize(size[sizeCO->currentIndex()].second);
+ setBar(bar[miscCO->currentIndex()].second);
+ setColor(color[colorCO->currentIndex()].second);
+ setLanguage(language[langCO->currentIndex()].second);
+
+ setToggleAll(toggleallCB->isChecked());
+}
+
+
+bool GuiCharacter::initialiseParams(string const &)
+{
+ // so that the user can press Ok
+ if (getFamily() != Font::IGNORE_FAMILY
+ || getSeries() != Font::IGNORE_SERIES
+ || getShape() != Font::IGNORE_SHAPE
+ || getSize() != Font::IGNORE_SIZE
+ || getBar() != IGNORE
+ || getColor() != Color::ignore
+ || font_.language() != ignore_language)
+ dialog().setButtonsValid(true);
+
+ return true;
+}
+
+
+void GuiCharacter::dispatchParams()
+{
+ dispatch(FuncRequest(getLfun(), font_.toString(toggleall_)));
+}
+
+
+Font::FONT_FAMILY GuiCharacter::getFamily() const
+{
+ return font_.family();
+}
+
+
+void GuiCharacter::setFamily(Font::FONT_FAMILY val)
+{
+ font_.setFamily(val);
+}
+
+
+Font::FONT_SERIES GuiCharacter::getSeries() const
+{
+ return font_.series();
+}
+
+
+void GuiCharacter::setSeries(Font::FONT_SERIES val)
+{
+ font_.setSeries(val);
+}
+
+
+Font::FONT_SHAPE GuiCharacter::getShape() const
+{
+ return font_.shape();
+}
+
+
+void GuiCharacter::setShape(Font::FONT_SHAPE val)
{
- ControlCharacter const & ctrl = controller();
+ font_.setShape(val);
+}
+
+
+Font::FONT_SIZE GuiCharacter::getSize() const
+{
+ return font_.size();
+}
+
+
+void GuiCharacter::setSize(Font::FONT_SIZE val)
+{
+ font_.setSize(val);
+}
+
+
+FontState GuiCharacter::getBar() const
+{
+ if (font_.emph() == Font::TOGGLE)
+ return EMPH_TOGGLE;
+
+ if (font_.underbar() == Font::TOGGLE)
+ return UNDERBAR_TOGGLE;
+
+ if (font_.noun() == Font::TOGGLE)
+ return NOUN_TOGGLE;
+
+ if (font_.emph() == Font::IGNORE
+ && font_.underbar() == Font::IGNORE
+ && font_.noun() == Font::IGNORE)
+ return IGNORE;
+
+ return INHERIT;
+}
+
+
+void GuiCharacter::setBar(FontState val)
+{
+ switch (val) {
+ case IGNORE:
+ font_.setEmph(Font::IGNORE);
+ font_.setUnderbar(Font::IGNORE);
+ font_.setNoun(Font::IGNORE);
+ break;
+
+ case EMPH_TOGGLE:
+ font_.setEmph(Font::TOGGLE);
+ break;
+
+ case UNDERBAR_TOGGLE:
+ font_.setUnderbar(Font::TOGGLE);
+ break;
+
+ case NOUN_TOGGLE:
+ font_.setNoun(Font::TOGGLE);
+ break;
+
+ case INHERIT:
+ font_.setEmph(Font::INHERIT);
+ font_.setUnderbar(Font::INHERIT);
+ font_.setNoun(Font::INHERIT);
+ break;
+ }
+}
- familyCO->setCurrentIndex(findPos2nd(family, ctrl.getFamily()));
- seriesCO->setCurrentIndex(findPos2nd(series, ctrl.getSeries()));
- shapeCO->setCurrentIndex(findPos2nd(shape, ctrl.getShape()));
- sizeCO->setCurrentIndex(findPos2nd(size, ctrl.getSize()));
- miscCO->setCurrentIndex(findPos2nd(bar, ctrl.getBar()));
- colorCO->setCurrentIndex(findPos2nd(color, ctrl.getColor()));
- langCO->setCurrentIndex(findPos2nd(language, ctrl.getLanguage()));
- toggleallCB->setChecked(ctrl.getToggleAll());
+Color_color GuiCharacter::getColor() const
+{
+ return font_.color();
}
-void GuiCharacterDialog::applyView()
+void GuiCharacter::setColor(Color_color val)
{
- ControlCharacter & ctrl = controller();
+ switch (val) {
+ case Color::ignore:
+ case Color::none:
+ case Color::black:
+ case Color::white:
+ case Color::red:
+ case Color::green:
+ case Color::blue:
+ case Color::cyan:
+ case Color::magenta:
+ case Color::yellow:
+ case Color::inherit:
+ font_.setColor(val);
+ break;
+ default:
+ break;
+ }
+}
- ctrl.setFamily(family[familyCO->currentIndex()].second);
- ctrl.setSeries(series[seriesCO->currentIndex()].second);
- ctrl.setShape(shape[shapeCO->currentIndex()].second);
- ctrl.setSize(size[sizeCO->currentIndex()].second);
- ctrl.setBar(bar[miscCO->currentIndex()].second);
- ctrl.setColor(color[colorCO->currentIndex()].second);
- ctrl.setLanguage(language[langCO->currentIndex()].second);
- ctrl.setToggleAll(toggleallCB->isChecked());
+string GuiCharacter::getLanguage() const
+{
+ if (reset_lang_)
+ return "reset";
+ if (font_.language())
+ return font_.language()->lang();
+ return "ignore";
}
+
+void GuiCharacter::setLanguage(string const & val)
+{
+ if (val == "ignore")
+ font_.setLanguage(ignore_language);
+ else if (val == "reset") {
+ reset_lang_ = true;
+ // Ignored in getLanguage, but needed for dispatchParams
+ font_.setLanguage(buffer().params().language);
+ } else {
+ font_.setLanguage(languages.getLanguage(val));
+ }
+}
+
+
+bool GuiCharacter::getToggleAll() const
+{
+ return toggleall_;
+}
+
+
+void GuiCharacter::setToggleAll(bool t)
+{
+ toggleall_ = t;
+}
+
+
+Dialog * createGuiCharacter(LyXView & lv) { return new GuiCharacter(lv); }
+
+
} // namespace frontend
} // namespace lyx
* This file is part of LyX, the document processor.
* Licence details can be found in the file COPYING.
*
+ * \author Angus Leeming
* \author Edwin Leuven
* \author John Levon
*
#define GUICHARACTER_H
#include "GuiDialog.h"
-#include "ControlCharacter.h"
#include "ui_CharacterUi.h"
#include "frontend_helpers.h" // for LanguagePair
+#include "Font.h"
#include <vector>
+
namespace lyx {
+
+class Color_color;
+
namespace frontend {
+enum FontState {
+ ///
+ IGNORE,
+ ///
+ EMPH_TOGGLE,
+ ///
+ UNDERBAR_TOGGLE,
+ ///
+ NOUN_TOGGLE,
+ ///
+ INHERIT
+};
+
typedef std::pair<QString, Font::FONT_FAMILY> FamilyPair;
typedef std::pair<QString, Font::FONT_SERIES> SeriesPair;
typedef std::pair<QString, Font::FONT_SHAPE> ShapePair;
typedef std::pair<QString, Font::FONT_SIZE> SizePair;
-typedef std::pair<QString, FONT_STATE> BarPair;
+typedef std::pair<QString, FontState> BarPair;
typedef std::pair<QString, Color_color> ColorPair;
-class GuiCharacterDialog : public GuiDialog, public Ui::CharacterUi
+class GuiCharacter : public GuiDialog, public Ui::CharacterUi, public Controller
{
Q_OBJECT
public:
- GuiCharacterDialog(LyXView & lv);
+ GuiCharacter(LyXView & lv);
protected Q_SLOTS:
void change_adaptor();
private:
void closeEvent(QCloseEvent * e);
/// parent controller
- ControlCharacter & controller();
+ Controller & controller() { return *this; }
/// Apply changes
void applyView();
/// update
std::vector<BarPair> bar;
std::vector<ColorPair> color;
std::vector<LanguagePair> language;
+
+ ///
+ bool initialiseParams(std::string const & data);
+ ///
+ void clearParams() {}
+ ///
+ void dispatchParams();
+ ///
+ bool isBufferDependent() const { return true; }
+ ///
+ kb_action getLfun() const { return LFUN_FONT_FREE_UPDATE; }
+
+ ///
+ void setFamily(Font::FONT_FAMILY);
+ ///
+ void setSeries(Font::FONT_SERIES);
+ ///
+ void setShape(Font::FONT_SHAPE);
+ ///
+ void setSize(Font::FONT_SIZE);
+ ///
+ void setBar(FontState);
+ ///
+ void setColor(Color_color);
+ ///
+ void setLanguage(std::string const &);
+ ///
+ void setToggleAll(bool);
+
+ ///
+ Font::FONT_FAMILY getFamily() const;
+ ///
+ Font::FONT_SERIES getSeries() const;
+ ///
+ Font::FONT_SHAPE getShape() const;
+ ///
+ Font::FONT_SIZE getSize() const;
+ ///
+ FontState getBar() const;
+ ///
+ Color_color getColor() const;
+ ///
+ std::string getLanguage() const;
+ ///
+ bool getToggleAll() const;
+private:
+ ///
+ Font font_;
+ ///
+ bool toggleall_;
+ /// If true the language should be reset.
+ /// If false the language of font_ is used.
+ bool reset_lang_;
};
} // namespace frontend