diff options
author | Michele Calgaro <[email protected]> | 2021-05-23 20:48:35 +0900 |
---|---|---|
committer | Michele Calgaro <[email protected]> | 2021-05-29 15:16:28 +0900 |
commit | 8b78a8791bc539bcffe7159f9d9714d577cb3d7d (patch) | |
tree | 1328291f966f19a22d7b13657d3f01a588eb1083 /chalk/ui/kis_autobrush.cpp | |
parent | 95834e2bdc5e01ae1bd21ac0dfa4fa1d2417fae9 (diff) | |
download | koffice-8b78a8791bc539bcffe7159f9d9714d577cb3d7d.tar.gz koffice-8b78a8791bc539bcffe7159f9d9714d577cb3d7d.zip |
Renaming of files in preparation for code style tools.
Signed-off-by: Michele Calgaro <[email protected]>
Diffstat (limited to 'chalk/ui/kis_autobrush.cpp')
-rw-r--r-- | chalk/ui/kis_autobrush.cpp | 177 |
1 files changed, 177 insertions, 0 deletions
diff --git a/chalk/ui/kis_autobrush.cpp b/chalk/ui/kis_autobrush.cpp new file mode 100644 index 00000000..c7127928 --- /dev/null +++ b/chalk/ui/kis_autobrush.cpp @@ -0,0 +1,177 @@ +/* + * Copyright (c) 2004 Cyrille Berger <[email protected]> + * + * 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 "kis_autobrush.h" +#include <KoImageResource.h> +#include <kdebug.h> +#include <tqspinbox.h> +#include <tqtoolbutton.h> +#include <tqimage.h> +#include <tqcombobox.h> +#include <tqlabel.h> + + +KisAutobrush::KisAutobrush(TQWidget *parent, const char* name, const TQString& caption) : KisWdgAutobrush(parent, name) +{ + setCaption(caption); + + m_linkSize = true; + m_linkFade = true; + + linkFadeToggled(m_linkSize); + linkSizeToggled(m_linkFade); + + connect(bnLinkSize, TQT_SIGNAL(toggled(bool)), this, TQT_SLOT(linkSizeToggled( bool ))); + connect(bnLinkFade, TQT_SIGNAL(toggled(bool)), this, TQT_SLOT(linkFadeToggled( bool ))); + + connect((TQObject*)comboBoxShape, TQT_SIGNAL(activated(int)), this, TQT_SLOT(paramChanged())); + spinBoxWidth->setMinValue(1); + connect(spinBoxWidth,TQT_SIGNAL(valueChanged(int)),this,TQT_SLOT(spinBoxWidthChanged(int))); + spinBoxHeight->setMinValue(1); + connect(spinBoxHeight,TQT_SIGNAL(valueChanged(int)),this,TQT_SLOT(spinBoxHeightChanged(int))); + spinBoxHorizontal->setMinValue(0); + connect(spinBoxHorizontal,TQT_SIGNAL(valueChanged(int)),this,TQT_SLOT(spinBoxHorizontalChanged(int))); + spinBoxVertical->setMinValue(0); + connect(spinBoxVertical,TQT_SIGNAL(valueChanged(int)),this,TQT_SLOT(spinBoxVerticalChanged(int))); + + m_brsh = new TQImage(1,1,32); + TQ_CHECK_PTR(m_brsh); + + paramChanged(); + + + connect(brushPreview, TQT_SIGNAL(clicked()), TQT_SLOT(paramChanged())); + +} + +void KisAutobrush::resizeEvent ( TQResizeEvent * ) +{ + brushPreview->setMinimumHeight(brushPreview->width()); // dirty hack ! + brushPreview->setMaximumHeight(brushPreview->width()); // dirty hack ! +} + +void KisAutobrush::activate() +{ + paramChanged(); +} + +void KisAutobrush::paramChanged() +{ + TQ_INT32 fh = TQMIN( spinBoxWidth->value()/2, spinBoxHorizontal->value() ) ; + TQ_INT32 fv = TQMIN( spinBoxHeight->value()/2, spinBoxVertical->value() ); + KisAutobrushShape* kas; + + if(comboBoxShape->currentItem() == 0) // use index compare instead of comparing a translatable string + { + kas = new KisAutobrushCircleShape(spinBoxWidth->value(), spinBoxHeight->value(), fh, fv); + TQ_CHECK_PTR(kas); + + } else { + kas = new KisAutobrushRectShape(spinBoxWidth->value(), spinBoxHeight->value(), fh, fv); + TQ_CHECK_PTR(kas); + + } + kas->createBrush(m_brsh); + + TQPixmap p; + TQImage pi(*m_brsh); + double coeff = 1.0; + int bPw = brushPreview->width()-3; + if(pi.width() > bPw) + { + coeff = bPw /(double)pi.width(); + } + int bPh = brushPreview->height()-3; + if(pi.height() > coeff * bPh) + { + coeff = bPh /(double)pi.height(); + } + if( coeff < 1.0) + { + pi = pi.smoothScale( (int)(coeff * pi.width()) , (int)(coeff * pi.height())); + } + + p.convertFromImage(pi); + brushPreview->setPixmap(p); + KisAutobrushResource * resource = new KisAutobrushResource(*m_brsh); + TQ_CHECK_PTR(resource); + + emit(activatedResource(resource)); + delete kas; +} +void KisAutobrush::spinBoxWidthChanged(int a) +{ + spinBoxHorizontal->setMaxValue(a/2); + if(m_linkSize) + { + spinBoxHeight->setValue(a); + spinBoxVertical->setMaxValue(a/2); + } + this->paramChanged(); +} +void KisAutobrush::spinBoxHeightChanged(int a) +{ + spinBoxVertical->setMaxValue(a/2); + if(m_linkSize) + { + spinBoxWidth->setValue(a); + spinBoxHorizontal->setMaxValue(a/2); + } + this->paramChanged(); +} +void KisAutobrush::spinBoxHorizontalChanged(int a) +{ + if(m_linkFade) + spinBoxVertical->setValue(a); + this->paramChanged(); +} +void KisAutobrush::spinBoxVerticalChanged(int a) +{ + if(m_linkFade) + spinBoxHorizontal->setValue(a); + this->paramChanged(); +} + +void KisAutobrush::linkSizeToggled(bool b) +{ + m_linkSize = b; + + KoImageResource kir; + if (b) { + bnLinkSize->setPixmap(kir.chain()); + } + else { + bnLinkSize->setPixmap(kir.chainBroken()); + } +} + +void KisAutobrush::linkFadeToggled(bool b) +{ + m_linkFade = b; + + KoImageResource kir; + if (b) { + bnLinkFade->setPixmap(kir.chain()); + } + else { + bnLinkFade->setPixmap(kir.chainBroken()); + } +} + + +#include "kis_autobrush.moc" |