2001-03-21 13:27:03 +00:00
|
|
|
/**
|
|
|
|
* \file ControlCharacter.C
|
|
|
|
* Copyright 2001 The LyX Team.
|
|
|
|
* See the file COPYING.
|
|
|
|
*
|
|
|
|
* \author Angus Leeming, a.leeming@.ac.uk
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <vector>
|
|
|
|
|
2001-03-21 19:14:09 +00:00
|
|
|
#ifdef __GNUG__
|
2001-03-21 13:27:03 +00:00
|
|
|
#pragma implementation
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#include <config.h>
|
|
|
|
|
2001-04-26 18:40:38 +00:00
|
|
|
#include "ViewBase.h"
|
|
|
|
#include "ButtonControllerBase.h"
|
2001-03-21 13:27:03 +00:00
|
|
|
#include "ControlCharacter.h"
|
2001-03-28 12:59:29 +00:00
|
|
|
#include "buffer.h"
|
2001-03-21 13:27:03 +00:00
|
|
|
#include "Dialogs.h"
|
|
|
|
#include "Liason.h"
|
|
|
|
#include "LyXView.h"
|
2001-03-28 12:59:29 +00:00
|
|
|
#include "bufferview_funcs.h" // ToggleAndShow
|
2001-04-05 12:26:41 +00:00
|
|
|
#include "gettext.h"
|
|
|
|
#include "language.h"
|
2001-03-21 13:27:03 +00:00
|
|
|
|
|
|
|
using Liason::setMinibuffer;
|
|
|
|
using SigC::slot;
|
|
|
|
using std::vector;
|
|
|
|
|
|
|
|
ControlCharacter::ControlCharacter(LyXView & lv, Dialogs & d)
|
2001-03-22 11:24:36 +00:00
|
|
|
: ControlDialog<ControlConnectBD>(lv, d),
|
|
|
|
font_(0), toggleall_(false)
|
2001-03-21 13:27:03 +00:00
|
|
|
{
|
2001-03-27 10:44:14 +00:00
|
|
|
d_.showLayoutCharacter.connect(slot(this, &ControlCharacter::show));
|
|
|
|
d_.setUserFreeFont.connect(slot(this, &ControlCharacter::apply));
|
2001-03-21 13:27:03 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2001-03-22 11:24:36 +00:00
|
|
|
void ControlCharacter::setParams()
|
2001-03-21 13:27:03 +00:00
|
|
|
{
|
|
|
|
if (font_) delete font_;
|
|
|
|
font_ = new LyXFont(LyXFont::ALL_IGNORE);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2001-03-22 11:24:36 +00:00
|
|
|
void ControlCharacter::clearParams()
|
2001-03-21 13:27:03 +00:00
|
|
|
{
|
|
|
|
if (font_) {
|
|
|
|
delete font_;
|
|
|
|
font_ = 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void ControlCharacter::apply()
|
|
|
|
{
|
|
|
|
if (!lv_.view()->available())
|
|
|
|
return;
|
|
|
|
|
|
|
|
view().apply();
|
|
|
|
|
|
|
|
ToggleAndShow(lv_.view(), *font_, toggleall_);
|
|
|
|
lv_.view()->setState();
|
|
|
|
lv_.buffer()->markDirty();
|
|
|
|
setMinibuffer(&lv_, _("Character set"));
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void ControlCharacter::setFamily(LyXFont::FONT_FAMILY val)
|
|
|
|
{
|
|
|
|
font_->setFamily(val);
|
|
|
|
}
|
|
|
|
|
|
|
|
void ControlCharacter::setSeries(LyXFont::FONT_SERIES val)
|
|
|
|
{
|
|
|
|
font_->setSeries(val);
|
|
|
|
}
|
|
|
|
|
|
|
|
void ControlCharacter::setShape(LyXFont::FONT_SHAPE val)
|
|
|
|
{
|
|
|
|
font_->setShape(val);
|
|
|
|
}
|
|
|
|
|
|
|
|
void ControlCharacter::setSize(LyXFont::FONT_SIZE val)
|
|
|
|
{
|
|
|
|
font_->setSize(val);
|
|
|
|
}
|
|
|
|
|
2001-03-28 12:59:29 +00:00
|
|
|
void ControlCharacter::setBar(character::FONT_STATE val)
|
2001-03-21 13:27:03 +00:00
|
|
|
{
|
|
|
|
switch (val) {
|
2001-03-28 12:59:29 +00:00
|
|
|
case character::IGNORE:
|
2001-03-21 13:27:03 +00:00
|
|
|
font_->setEmph(LyXFont::IGNORE);
|
|
|
|
font_->setUnderbar(LyXFont::IGNORE);
|
|
|
|
font_->setNoun(LyXFont::IGNORE);
|
|
|
|
font_->setLatex(LyXFont::IGNORE);
|
|
|
|
break;
|
|
|
|
|
2001-03-28 12:59:29 +00:00
|
|
|
case character::EMPH_TOGGLE:
|
2001-03-21 13:27:03 +00:00
|
|
|
font_->setEmph(LyXFont::TOGGLE);
|
|
|
|
break;
|
|
|
|
|
2001-03-28 12:59:29 +00:00
|
|
|
case character::UNDERBAR_TOGGLE:
|
2001-03-21 13:27:03 +00:00
|
|
|
font_->setUnderbar(LyXFont::TOGGLE);
|
|
|
|
break;
|
|
|
|
|
2001-03-28 12:59:29 +00:00
|
|
|
case character::NOUN_TOGGLE:
|
2001-03-21 13:27:03 +00:00
|
|
|
font_->setNoun(LyXFont::TOGGLE);
|
|
|
|
break;
|
|
|
|
|
2001-03-28 12:59:29 +00:00
|
|
|
case character::LATEX_TOGGLE:
|
2001-03-21 13:27:03 +00:00
|
|
|
font_->setLatex(LyXFont::TOGGLE);
|
|
|
|
break;
|
|
|
|
|
2001-03-28 12:59:29 +00:00
|
|
|
case character::INHERIT:
|
2001-03-21 13:27:03 +00:00
|
|
|
font_->setEmph(LyXFont::INHERIT);
|
|
|
|
font_->setUnderbar(LyXFont::INHERIT);
|
|
|
|
font_->setNoun(LyXFont::INHERIT);
|
|
|
|
font_->setLatex(LyXFont::INHERIT);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void ControlCharacter::setColor(LColor::color val)
|
|
|
|
{
|
|
|
|
switch (val) {
|
|
|
|
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:
|
|
|
|
font_->setColor(val);
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void ControlCharacter::setLanguage(string const & val)
|
|
|
|
{
|
|
|
|
if (val == _("No change"))
|
|
|
|
font_->setLanguage(ignore_language);
|
|
|
|
|
|
|
|
else if ( val == _("Reset"))
|
|
|
|
font_->setLanguage(lv_.buffer()->params.language);
|
|
|
|
|
|
|
|
else
|
|
|
|
font_->setLanguage(languages.getLanguage(val));
|
|
|
|
}
|
|
|
|
|
|
|
|
void ControlCharacter::setToggleAll(bool t)
|
|
|
|
{
|
|
|
|
toggleall_ = t;
|
|
|
|
}
|