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
|
|
|
|
*
|
|
|
|
* Full author contact details are available in file CREDITS
|
2001-03-05 12:04:43 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include <config.h>
|
|
|
|
|
2002-09-24 13:57:09 +00:00
|
|
|
#ifdef __GNUG__
|
|
|
|
#pragma implementation
|
|
|
|
#endif
|
2001-03-05 12:04:43 +00:00
|
|
|
|
2001-08-26 17:49:42 +00:00
|
|
|
#include "ControlCharacter.h"
|
|
|
|
#include "QCharacterDialog.h"
|
|
|
|
#include "QCharacter.h"
|
|
|
|
#include "Qt2BC.h"
|
2002-09-24 13:57:09 +00:00
|
|
|
|
|
|
|
#include "gettext.h"
|
|
|
|
#include "support/lstrings.h"
|
|
|
|
|
2001-08-26 17:49:42 +00:00
|
|
|
#include <qcombobox.h>
|
|
|
|
#include <qcheckbox.h>
|
|
|
|
#include <qpushbutton.h>
|
2001-03-05 12:04:43 +00:00
|
|
|
|
2002-09-24 13:57:09 +00:00
|
|
|
#include <vector>
|
|
|
|
|
2002-04-30 00:26:16 +00:00
|
|
|
using namespace frnt;
|
2001-08-26 17:49:42 +00:00
|
|
|
using std::vector;
|
2002-03-21 21:21:28 +00:00
|
|
|
|
2001-08-26 17:49:42 +00:00
|
|
|
typedef Qt2CB<ControlCharacter, Qt2DB<QCharacterDialog> > base_class;
|
2002-03-21 21:21:28 +00:00
|
|
|
|
2002-08-12 14:28:43 +00:00
|
|
|
QCharacter::QCharacter()
|
|
|
|
: base_class(_("Character"))
|
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) {
|
|
|
|
dialog_->familyCO->insertItem(cit->first.c_str(), -1);
|
|
|
|
}
|
|
|
|
for (vector<SeriesPair>::const_iterator cit = series.begin();
|
|
|
|
cit != series.end(); ++cit) {
|
|
|
|
dialog_->seriesCO->insertItem(cit->first.c_str(), -1);
|
|
|
|
}
|
|
|
|
for (vector<ShapePair>::const_iterator cit = shape.begin();
|
|
|
|
cit != shape.end(); ++cit) {
|
|
|
|
dialog_->shapeCO->insertItem(cit->first.c_str(), -1);
|
|
|
|
}
|
|
|
|
for (vector<SizePair>::const_iterator cit = size.begin();
|
|
|
|
cit != size.end(); ++cit) {
|
|
|
|
dialog_->sizeCO->insertItem(cit->first.c_str(), -1);
|
|
|
|
}
|
|
|
|
for (vector<BarPair>::const_iterator cit = bar.begin();
|
|
|
|
cit != bar.end(); ++cit) {
|
|
|
|
dialog_->miscCO->insertItem(cit->first.c_str(), -1);
|
|
|
|
}
|
|
|
|
for (vector<ColorPair>::const_iterator cit = color.begin();
|
|
|
|
cit != color.end(); ++cit) {
|
|
|
|
dialog_->colorCO->insertItem(cit->first.c_str(), -1);
|
|
|
|
}
|
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-04-30 00:26:16 +00:00
|
|
|
dialog_->langCO->insertItem(cit->first.c_str(), -1);
|
2001-08-26 17:49:42 +00:00
|
|
|
}
|
2002-03-21 21:21:28 +00:00
|
|
|
|
2001-08-26 17:49:42 +00:00
|
|
|
bc().setOK(dialog_->okPB);
|
|
|
|
bc().setApply(dialog_->applyPB);
|
|
|
|
bc().setCancel(dialog_->closePB);
|
|
|
|
bc().addReadOnly(dialog_->familyCO);
|
|
|
|
bc().addReadOnly(dialog_->seriesCO);
|
|
|
|
bc().addReadOnly(dialog_->sizeCO);
|
|
|
|
bc().addReadOnly(dialog_->shapeCO);
|
|
|
|
bc().addReadOnly(dialog_->miscCO);
|
|
|
|
bc().addReadOnly(dialog_->langCO);
|
|
|
|
bc().addReadOnly(dialog_->colorCO);
|
|
|
|
bc().addReadOnly(dialog_->toggleallCB);
|
|
|
|
bc().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
|
|
|
{
|
2001-08-26 17:49:42 +00:00
|
|
|
vector<std::pair<A,B> >::const_iterator cit = vec.begin();
|
|
|
|
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
|
|
|
{
|
2001-08-26 17:49:42 +00:00
|
|
|
dialog_->familyCO->setCurrentItem(findPos2nd(family, controller().getFamily()));
|
|
|
|
dialog_->seriesCO->setCurrentItem(findPos2nd(series, controller().getSeries()));
|
|
|
|
dialog_->shapeCO->setCurrentItem(findPos2nd(shape, controller().getShape()));
|
|
|
|
dialog_->sizeCO->setCurrentItem(findPos2nd(size, controller().getSize()));
|
|
|
|
dialog_->miscCO->setCurrentItem(findPos2nd(bar, controller().getBar()));
|
|
|
|
dialog_->colorCO->setCurrentItem(findPos2nd(color, controller().getColor()));
|
2002-04-30 00:26:16 +00:00
|
|
|
dialog_->langCO->setCurrentItem(findPos2nd(language, controller().getLanguage()));
|
2001-08-26 17:49:42 +00:00
|
|
|
|
|
|
|
dialog_->toggleallCB->setChecked(controller().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
|
|
|
{
|
2001-08-26 17:49:42 +00:00
|
|
|
controller().setFamily(family[dialog_->familyCO->currentItem()].second);
|
|
|
|
controller().setSeries(series[dialog_->seriesCO->currentItem()].second);
|
|
|
|
controller().setShape(shape[dialog_->shapeCO->currentItem()].second);
|
|
|
|
controller().setSize(size[dialog_->sizeCO->currentItem()].second);
|
|
|
|
controller().setBar(bar[dialog_->miscCO->currentItem()].second);
|
|
|
|
controller().setColor(color[dialog_->colorCO->currentItem()].second);
|
2002-04-30 00:26:16 +00:00
|
|
|
controller().setLanguage(language[dialog_->langCO->currentItem()].second);
|
2002-03-21 21:21:28 +00:00
|
|
|
|
2001-08-26 17:49:42 +00:00
|
|
|
controller().setToggleAll(dialog_->toggleallCB->isChecked());
|
2001-03-05 12:04:43 +00:00
|
|
|
}
|