2001-03-05 12:04:43 +00:00
|
|
|
/**
|
2001-08-19 13:25:15 +00:00
|
|
|
* \file QCharacter.C
|
2002-09-24 13:57:09 +00:00
|
|
|
* This file is part of LyX, the document processor.
|
|
|
|
* Licence details can be found in the file COPYING.
|
2001-03-05 12:04:43 +00:00
|
|
|
*
|
2002-09-24 13:57:09 +00:00
|
|
|
* \author Edwin Leuven
|
|
|
|
* \author John Levon
|
|
|
|
*
|
2003-08-23 00:17:00 +00:00
|
|
|
* Full author contact details are available in file CREDITS.
|
2001-03-05 12:04:43 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include <config.h>
|
|
|
|
|
2003-09-29 10:50:51 +00:00
|
|
|
#include "debug.h"
|
2003-09-05 16:18:57 +00:00
|
|
|
#include "QCharacter.h"
|
2001-08-26 17:49:42 +00:00
|
|
|
#include "ControlCharacter.h"
|
|
|
|
#include "QCharacterDialog.h"
|
|
|
|
#include "Qt2BC.h"
|
2002-09-24 13:57:09 +00:00
|
|
|
|
2002-12-17 20:37:13 +00:00
|
|
|
#include "qt_helpers.h"
|
2002-09-24 13:57:09 +00:00
|
|
|
|
2001-08-26 17:49:42 +00:00
|
|
|
#include <qpushbutton.h>
|
2003-09-07 21:25:37 +00:00
|
|
|
#include <qcheckbox.h>
|
|
|
|
#include <qcombobox.h>
|
2001-03-05 12:04:43 +00:00
|
|
|
|
2003-09-16 09:01:15 +00:00
|
|
|
#include "LColor.h"
|
|
|
|
|
2003-09-09 22:13:45 +00:00
|
|
|
using frnt::BarPair;
|
|
|
|
using frnt::ColorPair;
|
|
|
|
using frnt::FamilyPair;
|
|
|
|
using frnt::getBarData;
|
|
|
|
using frnt::getColorData;
|
|
|
|
using frnt::getFamilyData;
|
|
|
|
using frnt::getLanguageData;
|
|
|
|
using frnt::getSeriesData;
|
|
|
|
using frnt::getShapeData;
|
|
|
|
using frnt::getSizeData;
|
|
|
|
using frnt::LanguagePair;
|
|
|
|
using frnt::SeriesPair;
|
|
|
|
using frnt::ShapePair;
|
|
|
|
using frnt::SizePair;
|
2002-09-24 13:57:09 +00:00
|
|
|
|
2001-08-26 17:49:42 +00:00
|
|
|
using std::vector;
|
2002-03-21 21:21:28 +00:00
|
|
|
|
2003-09-09 22:13:45 +00:00
|
|
|
|
2003-03-12 22:17:50 +00:00
|
|
|
typedef QController<ControlCharacter, QView<QCharacterDialog> > base_class;
|
2002-03-21 21:21:28 +00:00
|
|
|
|
2002-10-20 01:48:28 +00:00
|
|
|
|
2003-03-12 22:17:50 +00:00
|
|
|
QCharacter::QCharacter(Dialog & parent)
|
2003-05-22 15:42:50 +00:00
|
|
|
: base_class(parent, _("LyX: Change Text Style"))
|
2001-03-05 12:04:43 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2001-08-26 17:49:42 +00:00
|
|
|
void QCharacter::build_dialog()
|
2001-03-05 12:04:43 +00:00
|
|
|
{
|
2001-08-26 17:49:42 +00:00
|
|
|
dialog_.reset(new QCharacterDialog(this));
|
|
|
|
|
|
|
|
family = getFamilyData();
|
|
|
|
series = getSeriesData();
|
|
|
|
shape = getShapeData();
|
|
|
|
size = getSizeData();
|
|
|
|
bar = getBarData();
|
|
|
|
color = getColorData();
|
2002-06-19 03:38:44 +00:00
|
|
|
language = getLanguageData(true);
|
2001-08-26 17:49:42 +00:00
|
|
|
|
|
|
|
for (vector<FamilyPair>::const_iterator cit = family.begin();
|
|
|
|
cit != family.end(); ++cit) {
|
2002-12-17 20:37:13 +00:00
|
|
|
dialog_->familyCO->insertItem(toqstr(cit->first), -1);
|
2001-08-26 17:49:42 +00:00
|
|
|
}
|
2002-10-20 01:48:28 +00:00
|
|
|
|
2001-08-26 17:49:42 +00:00
|
|
|
for (vector<SeriesPair>::const_iterator cit = series.begin();
|
|
|
|
cit != series.end(); ++cit) {
|
2002-12-17 20:37:13 +00:00
|
|
|
dialog_->seriesCO->insertItem(toqstr(cit->first), -1);
|
2001-08-26 17:49:42 +00:00
|
|
|
}
|
|
|
|
for (vector<ShapePair>::const_iterator cit = shape.begin();
|
|
|
|
cit != shape.end(); ++cit) {
|
2002-12-17 20:37:13 +00:00
|
|
|
dialog_->shapeCO->insertItem(toqstr(cit->first), -1);
|
2001-08-26 17:49:42 +00:00
|
|
|
}
|
|
|
|
for (vector<SizePair>::const_iterator cit = size.begin();
|
|
|
|
cit != size.end(); ++cit) {
|
2002-12-17 20:37:13 +00:00
|
|
|
dialog_->sizeCO->insertItem(toqstr(cit->first), -1);
|
2001-08-26 17:49:42 +00:00
|
|
|
}
|
|
|
|
for (vector<BarPair>::const_iterator cit = bar.begin();
|
|
|
|
cit != bar.end(); ++cit) {
|
2002-12-17 20:37:13 +00:00
|
|
|
dialog_->miscCO->insertItem(toqstr(cit->first), -1);
|
2001-08-26 17:49:42 +00:00
|
|
|
}
|
|
|
|
for (vector<ColorPair>::const_iterator cit = color.begin();
|
|
|
|
cit != color.end(); ++cit) {
|
2002-12-17 20:37:13 +00:00
|
|
|
dialog_->colorCO->insertItem(toqstr(cit->first), -1);
|
2001-08-26 17:49:42 +00:00
|
|
|
}
|
2002-04-30 00:26:16 +00:00
|
|
|
for (vector<LanguagePair>::const_iterator cit = language.begin();
|
2001-08-26 17:49:42 +00:00
|
|
|
cit != language.end(); ++cit) {
|
2002-12-17 20:37:13 +00:00
|
|
|
dialog_->langCO->insertItem(toqstr(cit->first), -1);
|
2001-08-26 17:49:42 +00:00
|
|
|
}
|
2002-03-21 21:21:28 +00:00
|
|
|
|
2003-03-10 03:13:28 +00:00
|
|
|
bcview().setOK(dialog_->okPB);
|
|
|
|
bcview().setApply(dialog_->applyPB);
|
|
|
|
bcview().setCancel(dialog_->closePB);
|
|
|
|
bcview().addReadOnly(dialog_->familyCO);
|
|
|
|
bcview().addReadOnly(dialog_->seriesCO);
|
|
|
|
bcview().addReadOnly(dialog_->sizeCO);
|
|
|
|
bcview().addReadOnly(dialog_->shapeCO);
|
|
|
|
bcview().addReadOnly(dialog_->miscCO);
|
|
|
|
bcview().addReadOnly(dialog_->langCO);
|
|
|
|
bcview().addReadOnly(dialog_->colorCO);
|
|
|
|
bcview().addReadOnly(dialog_->toggleallCB);
|
|
|
|
bcview().addReadOnly(dialog_->autoapplyCB);
|
2001-03-05 12:04:43 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2001-08-26 17:49:42 +00:00
|
|
|
namespace {
|
2002-03-21 21:21:28 +00:00
|
|
|
|
2001-08-26 17:49:42 +00:00
|
|
|
template<class A, class B>
|
|
|
|
int findPos2nd(vector<std::pair<A,B> > const & vec, B const & val)
|
2001-03-05 12:04:43 +00:00
|
|
|
{
|
2002-10-19 10:32:57 +00:00
|
|
|
typedef typename vector<std::pair<A, B> >::const_iterator
|
|
|
|
const_iterator;
|
|
|
|
|
|
|
|
const_iterator cit = vec.begin();
|
2001-08-26 17:49:42 +00:00
|
|
|
for (; cit != vec.end(); ++cit) {
|
|
|
|
if (cit->second == val)
|
2002-03-21 21:21:28 +00:00
|
|
|
return int(cit - vec.begin());
|
2001-08-26 17:49:42 +00:00
|
|
|
}
|
|
|
|
return 0;
|
2001-03-05 12:04:43 +00:00
|
|
|
}
|
2002-03-21 21:21:28 +00:00
|
|
|
|
2001-08-26 17:49:42 +00:00
|
|
|
} // namespace anon
|
2002-03-21 21:21:28 +00:00
|
|
|
|
|
|
|
|
2001-08-26 17:49:42 +00:00
|
|
|
void QCharacter::update_contents()
|
2001-03-05 12:04:43 +00:00
|
|
|
{
|
2002-10-20 01:48:28 +00:00
|
|
|
ControlCharacter const & ctrl = controller();
|
|
|
|
|
|
|
|
dialog_->familyCO->setCurrentItem(findPos2nd(family,
|
|
|
|
ctrl.getFamily()));
|
|
|
|
dialog_->seriesCO->setCurrentItem(findPos2nd(series,
|
|
|
|
ctrl.getSeries()));
|
|
|
|
dialog_->shapeCO->setCurrentItem(findPos2nd(shape, ctrl.getShape()));
|
|
|
|
dialog_->sizeCO->setCurrentItem(findPos2nd(size, ctrl.getSize()));
|
|
|
|
dialog_->miscCO->setCurrentItem(findPos2nd(bar, ctrl.getBar()));
|
|
|
|
dialog_->colorCO->setCurrentItem(findPos2nd(color, ctrl.getColor()));
|
|
|
|
dialog_->langCO->setCurrentItem(findPos2nd(language,
|
|
|
|
ctrl.getLanguage()));
|
|
|
|
|
|
|
|
dialog_->toggleallCB->setChecked(ctrl.getToggleAll());
|
2001-03-05 12:04:43 +00:00
|
|
|
}
|
|
|
|
|
2002-03-21 21:21:28 +00:00
|
|
|
|
2001-08-26 17:49:42 +00:00
|
|
|
void QCharacter::apply()
|
2001-03-05 12:04:43 +00:00
|
|
|
{
|
2002-10-20 01:48:28 +00:00
|
|
|
ControlCharacter & ctrl = controller();
|
|
|
|
|
|
|
|
ctrl.setFamily(family[dialog_->familyCO->currentItem()].second);
|
|
|
|
ctrl.setSeries(series[dialog_->seriesCO->currentItem()].second);
|
|
|
|
ctrl.setShape(shape[dialog_->shapeCO->currentItem()].second);
|
|
|
|
ctrl.setSize(size[dialog_->sizeCO->currentItem()].second);
|
|
|
|
ctrl.setBar(bar[dialog_->miscCO->currentItem()].second);
|
|
|
|
ctrl.setColor(color[dialog_->colorCO->currentItem()].second);
|
|
|
|
ctrl.setLanguage(language[dialog_->langCO->currentItem()].second);
|
|
|
|
|
|
|
|
ctrl.setToggleAll(dialog_->toggleallCB->isChecked());
|
2001-03-05 12:04:43 +00:00
|
|
|
}
|