1
/***************************************************************************
2
* Copyright (C) 2004 by Stephen Allewell *
3
* stephen@mirramar.fsnet.co.uk *
5
* This program is free software; you can redistribute it and/or modify *
6
* it under the terms of the GNU General Public License as published by *
7
* the Free Software Foundation; either version 2 of the License, or *
8
* (at your option) any later version. *
9
***************************************************************************/
12
#include <qlineedit.h>
14
#include <qpushbutton.h>
16
#include <kfontcombo.h>
17
#include <kapplication.h>
18
#include "texttooldialog.h"
21
TextToolDialog::TextToolDialog(QWidget* parent) : TextToolDlg(parent,"TextToolDlg",true)
23
connect(TextTool_Text,SIGNAL(textChanged(const QString&)),this,SLOT(slotTextChanged(const QString&)));
24
connect(TextTool_Help,SIGNAL(clicked()),this,SLOT(slotContextHelp()));
25
connect(TextTool_Font,SIGNAL(highlighted(int)),this,SLOT(slotFontSelected(int)));
26
connect(TextTool_Size,SIGNAL(valueChanged(int)),this,SLOT(slotSizeChanged(int)));
27
TextTool_Font->setCurrentItem(1);
29
TextTool_OK->setEnabled(false);
32
TextToolDialog::~TextToolDialog()
37
QByteArray TextToolDialog::pattern()
39
QPixmap *pm = new QPixmap(1000,100,1);
40
QPainter *p = new QPainter;
44
f.setPixelSize(m_size);
46
p->setPen(QPen(Qt::color0,1));
47
QRect br = p->boundingRect(0,0,1000,100,AlignAuto,m_text);
49
m_height = br.height();
51
pm->resize(m_width,m_height);
55
p->setPen(QPen(Qt::color1,1));
56
p->drawText(0,0,m_width,m_height,AlignCenter,m_text);
59
QByteArray a(m_width*m_height);
60
im = pm->convertToImage();
61
for (int y = 0 ; y < m_height ; y++)
62
for (int x = 0 ; x < m_width ; x++)
63
a[y*m_width+x] = ((im.pixelIndex(x,y))?1:0);
69
void TextToolDialog::accept()
71
m_font = TextTool_Font->currentFont();
72
m_text = TextTool_Text->text();
73
m_size = TextTool_Size->value();
76
TextToolDlg::accept();
79
int TextToolDialog::boundingWidth()
84
int TextToolDialog::boundingHeight()
89
void TextToolDialog::slotContextHelp()
91
kapp->invokeHelp("TextDialog");
94
void TextToolDialog::slotTextChanged(const QString& s)
96
TextTool_OK->setEnabled(!s.isEmpty());
99
void TextToolDialog::slotFontSelected(int)
101
QFont f = TextTool_Text->font();
102
f.setFamily(TextTool_Font->currentFont());
103
TextTool_Text->setFont(f);
106
void TextToolDialog::slotSizeChanged(int s)
108
QFont f = TextTool_Text->font();
110
TextTool_Text->setFont(f);