19#include "kis_autobrush.h"
20#include <KoImageResource.h>
23#include <tqtoolbutton.h>
25#include <tqcombobox.h>
29KisAutobrush::KisAutobrush(TQWidget *parent,
const char* name,
const TQString& caption) : KisWdgAutobrush(parent, name)
36 linkFadeToggled(m_linkSize);
37 linkSizeToggled(m_linkFade);
39 connect(bnLinkSize, TQ_SIGNAL(toggled(
bool)),
this, TQ_SLOT(linkSizeToggled(
bool )));
40 connect(bnLinkFade, TQ_SIGNAL(toggled(
bool)),
this, TQ_SLOT(linkFadeToggled(
bool )));
42 connect((TQObject*)comboBoxShape, TQ_SIGNAL(activated(
int)),
this, TQ_SLOT(paramChanged()));
43 spinBoxWidth->setMinValue(1);
44 connect(spinBoxWidth,TQ_SIGNAL(valueChanged(
int)),
this,TQ_SLOT(spinBoxWidthChanged(
int)));
45 spinBoxHeight->setMinValue(1);
46 connect(spinBoxHeight,TQ_SIGNAL(valueChanged(
int)),
this,TQ_SLOT(spinBoxHeightChanged(
int)));
47 spinBoxHorizontal->setMinValue(0);
48 connect(spinBoxHorizontal,TQ_SIGNAL(valueChanged(
int)),
this,TQ_SLOT(spinBoxHorizontalChanged(
int)));
49 spinBoxVertical->setMinValue(0);
50 connect(spinBoxVertical,TQ_SIGNAL(valueChanged(
int)),
this,TQ_SLOT(spinBoxVerticalChanged(
int)));
52 m_brsh =
new TQImage(1,1,32);
58 connect(brushPreview, TQ_SIGNAL(clicked()), TQ_SLOT(paramChanged()));
62void KisAutobrush::resizeEvent ( TQResizeEvent * )
64 brushPreview->setMinimumHeight(brushPreview->width());
65 brushPreview->setMaximumHeight(brushPreview->width());
68void KisAutobrush::activate()
73void KisAutobrush::paramChanged()
75 TQ_INT32 fh = TQMIN( spinBoxWidth->value()/2, spinBoxHorizontal->value() ) ;
76 TQ_INT32 fv = TQMIN( spinBoxHeight->value()/2, spinBoxVertical->value() );
77 KisAutobrushShape* kas;
79 if(comboBoxShape->currentItem() == 0)
81 kas =
new KisAutobrushCircleShape(spinBoxWidth->value(), spinBoxHeight->value(), fh, fv);
85 kas =
new KisAutobrushRectShape(spinBoxWidth->value(), spinBoxHeight->value(), fh, fv);
89 kas->createBrush(m_brsh);
94 int bPw = brushPreview->width()-3;
97 coeff = bPw /(double)pi.width();
99 int bPh = brushPreview->height()-3;
100 if(pi.height() > coeff * bPh)
102 coeff = bPh /(double)pi.height();
106 pi = pi.smoothScale( (
int)(coeff * pi.width()) , (
int)(coeff * pi.height()));
109 p.convertFromImage(pi);
110 brushPreview->setPixmap(p);
111 KisAutobrushResource * resource =
new KisAutobrushResource(*m_brsh);
112 TQ_CHECK_PTR(resource);
114 emit(activatedResource(resource));
117void KisAutobrush::spinBoxWidthChanged(
int a)
119 spinBoxHorizontal->setMaxValue(a/2);
122 spinBoxHeight->setValue(a);
123 spinBoxVertical->setMaxValue(a/2);
125 this->paramChanged();
127void KisAutobrush::spinBoxHeightChanged(
int a)
129 spinBoxVertical->setMaxValue(a/2);
132 spinBoxWidth->setValue(a);
133 spinBoxHorizontal->setMaxValue(a/2);
135 this->paramChanged();
137void KisAutobrush::spinBoxHorizontalChanged(
int a)
140 spinBoxVertical->setValue(a);
141 this->paramChanged();
143void KisAutobrush::spinBoxVerticalChanged(
int a)
146 spinBoxHorizontal->setValue(a);
147 this->paramChanged();
150void KisAutobrush::linkSizeToggled(
bool b)
156 bnLinkSize->setPixmap(kir.chain());
159 bnLinkSize->setPixmap(kir.chainBroken());
163void KisAutobrush::linkFadeToggled(
bool b)
169 bnLinkFade->setPixmap(kir.chain());
172 bnLinkFade->setPixmap(kir.chainBroken());
177#include "kis_autobrush.moc"