2002-10-09 08:59:02 +00:00
|
|
|
/**
|
2002-11-12 10:12:06 +00:00
|
|
|
* \file BulletsModule.C
|
2002-10-09 08:59:02 +00:00
|
|
|
* This file is part of LyX, the document processor.
|
|
|
|
* Licence details can be found in the file COPYING.
|
|
|
|
*
|
|
|
|
* \author Edwin Leuven
|
|
|
|
*
|
|
|
|
* Full author contact details are available in file CREDITS
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <config.h>
|
2002-12-17 20:37:13 +00:00
|
|
|
#include "qt_helpers.h"
|
2002-10-09 08:59:02 +00:00
|
|
|
|
|
|
|
#ifdef __GNUG__
|
|
|
|
#pragma implementation
|
|
|
|
#endif
|
|
|
|
|
2002-12-16 22:24:33 +00:00
|
|
|
#include <functional> // for operator %
|
|
|
|
|
|
|
|
#include <qinputdialog.h>
|
2002-10-09 08:59:02 +00:00
|
|
|
#include <qpopupmenu.h>
|
|
|
|
#include <qpixmap.h>
|
|
|
|
#include <qtoolbutton.h>
|
2002-12-16 22:24:33 +00:00
|
|
|
#include <qlistview.h>
|
2002-11-12 10:12:06 +00:00
|
|
|
#include <qcombobox.h>
|
2002-12-16 22:24:33 +00:00
|
|
|
#include <qlabel.h>
|
2002-10-09 08:59:02 +00:00
|
|
|
#include "BulletsModule.h"
|
2002-12-16 22:24:33 +00:00
|
|
|
#include "Bullet.h"
|
2002-10-09 08:59:02 +00:00
|
|
|
#include "ui/BulletsModuleBase.h"
|
|
|
|
#include "QBrowseBox.h"
|
2002-11-08 00:09:00 +00:00
|
|
|
#include "support/filetools.h"
|
2002-10-20 01:48:28 +00:00
|
|
|
|
|
|
|
BulletsModule::BulletsModule(QWidget * parent, char const * name, WFlags fl)
|
2002-12-16 22:24:33 +00:00
|
|
|
: BulletsModuleBase(parent, name, fl)
|
2002-10-09 08:59:02 +00:00
|
|
|
{
|
2002-12-16 22:24:33 +00:00
|
|
|
for (int iter = 0; iter < 4; ++iter) {
|
|
|
|
bullets_[iter] = ITEMIZE_DEFAULTS[iter];
|
|
|
|
}
|
|
|
|
|
2002-11-08 00:09:00 +00:00
|
|
|
QPopupMenu * pm = new QPopupMenu(this);
|
2002-12-01 22:59:25 +00:00
|
|
|
|
2002-10-20 01:48:28 +00:00
|
|
|
QPopupMenu * pm1 = new QPopupMenu(pm);
|
|
|
|
QPopupMenu * pm2 = new QPopupMenu(pm);
|
2002-11-08 00:09:00 +00:00
|
|
|
QPopupMenu * pm3 = new QPopupMenu(pm);
|
|
|
|
QPopupMenu * pm4 = new QPopupMenu(pm);
|
|
|
|
QPopupMenu * pm5 = new QPopupMenu(pm);
|
|
|
|
QPopupMenu * pm6 = new QPopupMenu(pm);
|
|
|
|
|
2002-11-12 10:12:06 +00:00
|
|
|
standard_ = new QBrowseBox(6, 6, pm1);
|
|
|
|
maths_ = new QBrowseBox(6, 6, pm2);
|
|
|
|
ding1_ = new QBrowseBox(6, 6, pm3);
|
|
|
|
ding2_ = new QBrowseBox(6, 6, pm4);
|
|
|
|
ding3_ = new QBrowseBox(6, 6, pm5);
|
|
|
|
ding4_ = new QBrowseBox(6, 6, pm6);
|
2002-11-08 00:09:00 +00:00
|
|
|
|
2002-11-12 10:12:06 +00:00
|
|
|
pm1->insertItem(standard_);
|
|
|
|
pm2->insertItem(maths_);
|
|
|
|
pm3->insertItem(ding1_);
|
|
|
|
pm4->insertItem(ding2_);
|
|
|
|
pm5->insertItem(ding3_);
|
|
|
|
pm6->insertItem(ding4_);
|
2002-10-20 01:48:28 +00:00
|
|
|
|
|
|
|
pm->insertItem("Standard", pm1);
|
|
|
|
pm->insertItem("Maths", pm2);
|
2002-11-08 00:09:00 +00:00
|
|
|
pm->insertItem("Ding 1",pm3);
|
|
|
|
pm->insertItem("Ding 2",pm4);
|
|
|
|
pm->insertItem("Ding 3",pm5);
|
|
|
|
pm->insertItem("Ding 4",pm6);
|
2002-12-16 22:24:33 +00:00
|
|
|
pm->insertItem("Custom...", this, SLOT(setCustom()));
|
2002-10-20 01:48:28 +00:00
|
|
|
|
2002-12-16 22:24:33 +00:00
|
|
|
setbulletTB->setPopup(pm);
|
2002-11-08 00:09:00 +00:00
|
|
|
|
|
|
|
// insert pixmaps
|
|
|
|
string bmfile;
|
|
|
|
bmfile = LibFileSearch("images", "standard", "xpm");
|
2002-12-17 20:37:13 +00:00
|
|
|
standard_->insertItem(QPixmap(toqstr(bmfile)));
|
2002-12-01 22:59:25 +00:00
|
|
|
|
2002-11-08 00:09:00 +00:00
|
|
|
bmfile = LibFileSearch("images", "amssymb", "xpm");
|
2002-12-17 20:37:13 +00:00
|
|
|
maths_->insertItem(QPixmap(toqstr(bmfile)));
|
2002-11-08 00:09:00 +00:00
|
|
|
|
|
|
|
bmfile = LibFileSearch("images", "psnfss1", "xpm");
|
2002-12-17 20:37:13 +00:00
|
|
|
ding1_->insertItem(QPixmap(toqstr(bmfile)));
|
2002-11-08 00:09:00 +00:00
|
|
|
|
|
|
|
bmfile = LibFileSearch("images", "psnfss2", "xpm");
|
2002-12-17 20:37:13 +00:00
|
|
|
ding2_->insertItem(QPixmap(toqstr(bmfile)));
|
2002-11-08 00:09:00 +00:00
|
|
|
|
|
|
|
bmfile = LibFileSearch("images", "psnfss3", "xpm");
|
2002-12-17 20:37:13 +00:00
|
|
|
ding3_->insertItem(QPixmap(toqstr(bmfile)));
|
2002-11-08 00:09:00 +00:00
|
|
|
|
|
|
|
bmfile = LibFileSearch("images", "psnfss4", "xpm");
|
2002-12-17 20:37:13 +00:00
|
|
|
ding4_->insertItem(QPixmap(toqstr(bmfile)));
|
2002-10-20 01:48:28 +00:00
|
|
|
|
2002-11-12 10:12:06 +00:00
|
|
|
connect(standard_, SIGNAL(selected(int, int)),
|
|
|
|
this, SLOT(standard(int, int)));
|
2002-10-20 01:48:28 +00:00
|
|
|
|
2002-11-12 10:12:06 +00:00
|
|
|
connect(maths_, SIGNAL(selected(int, int)),
|
|
|
|
this, SLOT(maths(int, int)));
|
2002-12-01 22:59:25 +00:00
|
|
|
|
2002-11-12 10:12:06 +00:00
|
|
|
connect(ding1_, SIGNAL(selected(int, int)),
|
|
|
|
this, SLOT(ding1(int, int)));
|
2002-12-01 22:59:25 +00:00
|
|
|
|
2002-11-12 10:12:06 +00:00
|
|
|
connect(ding2_, SIGNAL(selected(int, int)),
|
|
|
|
this, SLOT(ding2(int, int)));
|
2002-12-01 22:59:25 +00:00
|
|
|
|
2002-11-12 10:12:06 +00:00
|
|
|
connect(ding3_, SIGNAL(selected(int, int)),
|
|
|
|
this, SLOT(ding3(int, int)));
|
2002-12-01 22:59:25 +00:00
|
|
|
|
2002-11-12 10:12:06 +00:00
|
|
|
connect(ding4_, SIGNAL(selected(int, int)),
|
|
|
|
this, SLOT(ding4(int, int)));
|
2002-12-01 22:59:25 +00:00
|
|
|
|
2002-12-16 22:24:33 +00:00
|
|
|
// update the view
|
|
|
|
for (int iter = 0; iter < 4; ++iter) {
|
|
|
|
setBullet(iter,bullets_[iter]);
|
|
|
|
}
|
|
|
|
activeitem_ = bulletsLV->firstChild();
|
|
|
|
activebullet_ = &bullets_[0];
|
|
|
|
}
|
2002-12-01 22:59:25 +00:00
|
|
|
|
|
|
|
|
2002-12-16 22:24:33 +00:00
|
|
|
BulletsModule::~BulletsModule()
|
|
|
|
{
|
|
|
|
}
|
2002-12-01 22:59:25 +00:00
|
|
|
|
|
|
|
|
2002-12-16 22:24:33 +00:00
|
|
|
QPixmap BulletsModule::getPixmap(int font, int character)
|
|
|
|
{
|
|
|
|
int col = character%6;
|
|
|
|
int row = (character - col)/6;
|
|
|
|
switch(font) {
|
|
|
|
case 0:
|
|
|
|
return standard_->pixmap(row,col);
|
|
|
|
case 1:
|
|
|
|
return maths_->pixmap(row,col);
|
|
|
|
case 2:
|
|
|
|
return ding1_->pixmap(row,col);
|
|
|
|
case 3:
|
|
|
|
return ding2_->pixmap(row,col);
|
|
|
|
case 4:
|
|
|
|
return ding3_->pixmap(row,col);
|
|
|
|
case 5:
|
|
|
|
return ding4_->pixmap(row,col);
|
|
|
|
default:
|
|
|
|
return standard_->pixmap(row,col);
|
|
|
|
}
|
2002-10-09 08:59:02 +00:00
|
|
|
}
|
|
|
|
|
2002-10-20 01:48:28 +00:00
|
|
|
|
2002-12-16 22:24:33 +00:00
|
|
|
QListViewItem * BulletsModule::getItem(int level)
|
2002-10-09 08:59:02 +00:00
|
|
|
{
|
2002-12-16 22:24:33 +00:00
|
|
|
QListViewItemIterator it(bulletsLV->firstChild());
|
|
|
|
for(int i=0; i<level; ++i) {
|
|
|
|
++it;
|
|
|
|
}
|
|
|
|
return it.current();
|
2002-10-09 08:59:02 +00:00
|
|
|
}
|
|
|
|
|
2002-12-16 22:24:33 +00:00
|
|
|
|
|
|
|
void BulletsModule::setActive(int level)
|
2002-11-12 10:12:06 +00:00
|
|
|
{
|
2002-12-16 22:24:33 +00:00
|
|
|
activeitem_ = getItem(level);
|
|
|
|
activebullet_ = &bullets_[level];
|
2002-11-12 10:12:06 +00:00
|
|
|
}
|
|
|
|
|
2002-12-16 22:24:33 +00:00
|
|
|
|
|
|
|
void BulletsModule::setActive(QListViewItem * item)
|
2002-11-12 10:12:06 +00:00
|
|
|
{
|
2002-12-16 22:24:33 +00:00
|
|
|
activeitem_ = item;
|
|
|
|
activebullet_ = &bullets_[item->depth()];
|
2002-11-12 10:12:06 +00:00
|
|
|
}
|
|
|
|
|
2002-12-16 22:24:33 +00:00
|
|
|
|
|
|
|
void BulletsModule::setBullet(int font, int character)
|
2002-11-12 10:12:06 +00:00
|
|
|
{
|
2002-12-16 22:24:33 +00:00
|
|
|
activeitem_->setText(0,"");
|
|
|
|
activeitem_->setPixmap(0,getPixmap(font,character));
|
|
|
|
|
|
|
|
activebullet_->setFont(font);
|
|
|
|
activebullet_->setCharacter(character);
|
2002-11-12 10:12:06 +00:00
|
|
|
}
|
2002-10-20 01:48:28 +00:00
|
|
|
|
2002-12-16 22:24:33 +00:00
|
|
|
|
|
|
|
void BulletsModule::setBullet(string text)
|
2002-10-09 08:59:02 +00:00
|
|
|
{
|
2002-12-17 20:37:13 +00:00
|
|
|
activeitem_->setPixmap(0, QPixmap());
|
|
|
|
activeitem_->setText(0, toqstr(text));
|
2002-12-16 22:24:33 +00:00
|
|
|
|
|
|
|
activebullet_->setText(text);
|
2002-10-09 08:59:02 +00:00
|
|
|
}
|
|
|
|
|
2002-12-16 22:24:33 +00:00
|
|
|
|
|
|
|
void BulletsModule::setBullet(int level, const Bullet & bullet)
|
2002-11-12 10:12:06 +00:00
|
|
|
{
|
2002-12-16 22:24:33 +00:00
|
|
|
setActive(level);
|
|
|
|
bullets_[level] = bullet;
|
|
|
|
// set size
|
|
|
|
setSize(bullet.getSize()+1);
|
|
|
|
// set pixmap
|
|
|
|
if (bullet.getFont()!=-1) {
|
|
|
|
setBullet(bullet.getFont(),
|
|
|
|
bullet.getCharacter());
|
|
|
|
} else {
|
|
|
|
setBullet(bullet.getText());
|
|
|
|
}
|
2002-11-12 10:12:06 +00:00
|
|
|
}
|
2002-10-20 01:48:28 +00:00
|
|
|
|
2002-12-16 22:24:33 +00:00
|
|
|
|
|
|
|
Bullet BulletsModule::getBullet(int level)
|
2002-10-09 08:59:02 +00:00
|
|
|
{
|
2002-12-16 22:24:33 +00:00
|
|
|
return bullets_[level];
|
2002-10-09 08:59:02 +00:00
|
|
|
}
|
2002-11-12 10:12:06 +00:00
|
|
|
|
2002-12-16 22:24:33 +00:00
|
|
|
|
|
|
|
void BulletsModule::setSize(int size)
|
2002-11-12 10:12:06 +00:00
|
|
|
{
|
2002-12-16 22:24:33 +00:00
|
|
|
activeitem_->setText(1,bulletsizeCO->text(size));
|
|
|
|
activebullet_->setSize(size-1);
|
2002-11-12 10:12:06 +00:00
|
|
|
}
|
|
|
|
|
2002-12-16 22:24:33 +00:00
|
|
|
|
|
|
|
void BulletsModule::standard(int row, int col)
|
2002-11-12 10:12:06 +00:00
|
|
|
{
|
2002-12-16 22:24:33 +00:00
|
|
|
setBullet(0,6*row + col);
|
2002-11-12 10:12:06 +00:00
|
|
|
}
|
|
|
|
|
2002-12-16 22:24:33 +00:00
|
|
|
void BulletsModule::maths(int row, int col)
|
|
|
|
{
|
|
|
|
setBullet(1,6*row + col);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void BulletsModule::ding1(int row, int col)
|
|
|
|
{
|
|
|
|
setBullet(2,6*row + col);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void BulletsModule::ding2(int row, int col)
|
2002-11-12 10:12:06 +00:00
|
|
|
{
|
2002-12-16 22:24:33 +00:00
|
|
|
setBullet(3,6*row + col);
|
2002-11-12 10:12:06 +00:00
|
|
|
}
|
|
|
|
|
2002-12-16 22:24:33 +00:00
|
|
|
|
|
|
|
void BulletsModule::ding3(int row, int col)
|
|
|
|
{
|
|
|
|
setBullet(4,6*row + col);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void BulletsModule::ding4(int row, int col)
|
|
|
|
{
|
|
|
|
setBullet(5,6*row + col);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void BulletsModule::setCustom()
|
2002-11-12 10:12:06 +00:00
|
|
|
{
|
2002-12-16 22:24:33 +00:00
|
|
|
bool ok = FALSE;
|
|
|
|
QString text = QInputDialog::getText(
|
2002-12-17 20:37:13 +00:00
|
|
|
qt_( "Bullets" ),
|
|
|
|
qt_( "Enter a custom bullet" ),
|
2002-12-16 22:24:33 +00:00
|
|
|
QLineEdit::Normal,
|
|
|
|
QString::null, &ok, this );
|
2002-12-18 14:13:16 +00:00
|
|
|
|
|
|
|
if (ok) {
|
|
|
|
activeitem_->setPixmap(0,QPixmap());
|
|
|
|
activeitem_->setText(0,text);
|
|
|
|
activebullet_->setText(fromqstr(text));
|
|
|
|
activebullet_->setFont(-1);
|
|
|
|
}
|
2002-11-12 10:12:06 +00:00
|
|
|
}
|