Commit a096c8a4 authored by Cyrille Berger's avatar Cyrille Berger

- readd TextBrush for those like me who needs/wants it (it's a compilation...

- readd TextBrush for those like me who needs/wants it (it's a compilation option you need to define HAVE_TEXT_BRUSH to enable it)

svn path=/trunk/koffice/; revision=490562
parent 8168ba72
......@@ -66,6 +66,7 @@ libkritaui_la_SOURCES = \
kis_ruler.cc \
kis_selection_manager.cc \
kis_selection_options.cc \
kis_text_brush.cc \
kis_tool.cc \
kis_tool_dummy.cc \
kis_tool_freehand.cc \
......@@ -97,7 +98,8 @@ libkritaui_la_SOURCES = \
wdgselectionoptions.ui \
wdgshapeoptions.ui \
wdgpressuresettings.ui \
wdgcustombrush.ui
wdgcustombrush.ui \
wdgtextbrush.ui
noinst_HEADERS = \
imageviewer.h \
......
......@@ -57,7 +57,9 @@
#include "kis_config.h"
#include "kis_paintop_box.h"
#include "kis_custom_brush.h"
#ifdef HAVE_TEXT_BRUSH
#include "kis_text_brush.h"
#endif
KisPopupFrame::KisPopupFrame(QWidget * parent, const char* name)
: QPopupMenu(parent, name)
{
......@@ -238,6 +240,13 @@ void KisControlFrame::createBrushesChooser(KisView * view)
m_brushesTab -> addTab( customBrushes, i18n("Custom Brush"));
connect(customBrushes, SIGNAL(activatedResource(KisResource*)),
m_view, SLOT(brushActivated(KisResource*)));
#ifdef HAVE_TEXT_BRUSH
KisTextBrush* textBrushes = new KisTextBrush(m_brushesTab, "textbrush",
i18n("Text Brush")/*, m_view*/);
m_brushesTab -> addTab( textBrushes, i18n("Text Brush"));
connect(textBrushes, SIGNAL(activatedResource(KisResource*)),
m_view, SLOT(brushActivated(KisResource*)));
#endif
m_brushChooser->setFont(m_font);
m_brushMediator = new KisResourceMediator( m_brushChooser, this);
......
/*
* Copyright (c) 2004 Cyrille Berger <cberger@cberger.net>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
#include <qfontmetrics.h>
#include <qpainter.h>
#include <qspinbox.h>
#include <qcheckbox.h>
#include <qlabel.h>
#include <kfontdialog.h>
#include <klineedit.h>
#include "kis_text_brush.h"
void KisTextBrushResource::updateBrush()
{
QFontMetrics metric(m_font);
int w = metric.width(m_txt);
int h = metric.height();
QPixmap px(w,h);
QPainter p;
p.begin(&px);
p.setFont( m_font );
p.fillRect(0,0, w, h, Qt::white);
p.setPen(Qt::black);
p.drawText(0, metric.ascent(), m_txt );
p.end();
setImage(px.convertToImage ());
}
KisTextBrush::KisTextBrush(QWidget *parent, const char* name, const QString& caption)
: KisWdgTextBrush(parent, name),
m_textBrushResource(new KisTextBrushResource())
{
setCaption(caption);
connect((QObject*)lineEdit, SIGNAL(textChanged(const QString&)), this, SLOT(rebuildTextBrush()));
connect((QObject*)bnFont, SIGNAL(clicked()), this, SLOT(getFont()));
m_font = font();
rebuildTextBrush();
}
void KisTextBrush::getFont()
{
KFontDialog::getFont( m_font, false/*, QWidget* parent! */ );
rebuildTextBrush();
}
void KisTextBrush::rebuildTextBrush()
{
lblFont -> setText(QString(m_font.family() + ", %1").arg(m_font.pointSize()));
lblFont -> setFont(m_font);
m_textBrushResource->setFont(m_font);
m_textBrushResource->setText(lineEdit->text());
m_textBrushResource->updateBrush();
emit(activatedResource(m_textBrushResource));
}
#include "kis_text_brush.moc"
/*
* Copyright (c) 2004 Cyrille Berger <cberger@cberger.net>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
#ifndef _KIS_TEXT_BRUSH_H_
#define _KIS_TEXT_BRUSH_H_
#include "wdgtextbrush.h"
#include "kis_brush.h"
class KisTextBrushResource : public KisBrush
{
public:
KisTextBrushResource() : KisBrush("")
{
setBrushType(MASK);
}
KisTextBrushResource(const QString& txt, const QFont& font) : KisBrush("")
{
setFont(font);
setText(txt);
updateBrush();
setBrushType(MASK);
};
public:
virtual bool load() { return false; };
void setText(const QString& txt) { m_txt = txt; };
void setFont(const QFont& font) { m_font = font; };
void updateBrush();
private:
QFont m_font;
QString m_txt;
};
class KisTextBrush : public KisWdgTextBrush
{
Q_OBJECT
public:
KisTextBrush(QWidget *parent, const char* name, const QString& caption);
signals:
void activatedResource(KisResource *r);
private slots:
void rebuildTextBrush();
void getFont();
private:
KisTextBrushResource* m_textBrushResource;
QFont m_font;
};
#endif
<!DOCTYPE UI><UI version="3.3" stdsetdef="1">
<class>KisWdgTextBrush</class>
<widget class="QWidget">
<property name="name">
<cstring>KisWdgTextBrush</cstring>
</property>
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>317</width>
<height>89</height>
</rect>
</property>
<property name="caption">
<string>Text</string>
</property>
<grid>
<property name="name">
<cstring>unnamed</cstring>
</property>
<widget class="QLayoutWidget" row="0" column="0">
<property name="name">
<cstring>layout3</cstring>
</property>
<vbox>
<property name="name">
<cstring>unnamed</cstring>
</property>
<widget class="QLayoutWidget">
<property name="name">
<cstring>layout9</cstring>
</property>
<hbox>
<property name="name">
<cstring>unnamed</cstring>
</property>
<widget class="QLabel">
<property name="name">
<cstring>labelText</cstring>
</property>
<property name="text">
<string>Text:</string>
</property>
</widget>
<widget class="KLineEdit">
<property name="name">
<cstring>lineEdit</cstring>
</property>
<property name="minimumSize">
<size>
<width>120</width>
<height>0</height>
</size>
</property>
<property name="font">
<font>
</font>
</property>
<property name="text">
<string>The Quick Brown Fox Jumps Over The Lazy Dog</string>
</property>
</widget>
</hbox>
</widget>
<widget class="QLayoutWidget">
<property name="name">
<cstring>layout10</cstring>
</property>
<hbox>
<property name="name">
<cstring>unnamed</cstring>
</property>
<widget class="QLabel">
<property name="name">
<cstring>lblFont</cstring>
</property>
<property name="sizePolicy">
<sizepolicy>
<hsizetype>5</hsizetype>
<vsizetype>5</vsizetype>
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Font:</string>
</property>
</widget>
<widget class="QToolButton">
<property name="name">
<cstring>bnFont</cstring>
</property>
<property name="sizePolicy">
<sizepolicy>
<hsizetype>0</hsizetype>
<vsizetype>0</vsizetype>
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>...</string>
</property>
<property name="accel">
<string></string>
</property>
</widget>
</hbox>
</widget>
</vbox>
</widget>
<spacer row="0" column="1">
<property name="name">
<cstring>spacer1</cstring>
</property>
<property name="orientation">
<enum>Horizontal</enum>
</property>
<property name="sizeType">
<enum>Minimum</enum>
</property>
<property name="sizeHint">
<size>
<width>121</width>
<height>20</height>
</size>
</property>
</spacer>
<spacer row="1" column="0">
<property name="name">
<cstring>spacer2</cstring>
</property>
<property name="orientation">
<enum>Vertical</enum>
</property>
<property name="sizeType">
<enum>Minimum</enum>
</property>
<property name="sizeHint">
<size>
<width>20</width>
<height>31</height>
</size>
</property>
</spacer>
</grid>
</widget>
<customwidgets>
</customwidgets>
<slots>
<slot access="private">boldButtonClicked()</slot>
</slots>
<layoutdefaults spacing="6" margin="11"/>
<includehints>
<includehint>klineedit.h</includehint>
</includehints>
</UI>
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment