chalk

kis_multi_bool_filter_widget.cpp
1/*
2 * Copyright (c) 2005 Michael Thaler <michael.thaler@physik.tu-muenchen.de>
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 2 of the License, or
7 * (at your option) any later version.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
17 */
18
19#include "kis_multi_bool_filter_widget.h"
20
21#include <tqlabel.h>
22#include <tqlayout.h>
23#include <tqcheckbox.h>
24
25#include <tdelocale.h>
26
27KisBoolWidgetParam::KisBoolWidgetParam( bool ninitvalue, TQString nlabel, TQString nname) :
28 initvalue(ninitvalue),
29 label(nlabel),
30 name(nname)
31{
32
33}
34
35KisMultiBoolFilterWidget::KisMultiBoolFilterWidget(TQWidget * parent, const char * name, const char * caption, vKisBoolWidgetParam iwparam) :
36 KisFilterConfigWidget( parent, name )
37{
38 TQ_INT32 m_nbboolWidgets = iwparam.size();
39
40 this->setCaption(caption);
41
42 TQVBoxLayout *widgetLayout = new TQVBoxLayout(this, m_nbboolWidgets + 1);
43
44 m_boolWidgets = new TQCheckBox*[ m_nbboolWidgets ];
45
46 for( TQ_INT32 i = 0; i < m_nbboolWidgets; ++i)
47 {
48 m_boolWidgets[i] = new TQCheckBox( this, iwparam[i].name.ascii());
49 m_boolWidgets[i]->setChecked( iwparam[i].initvalue );
50 m_boolWidgets[i]->setText( iwparam[i].label );
51 connect(m_boolWidgets[i], TQ_SIGNAL(toggled( bool ) ), TQ_SIGNAL(sigPleaseUpdatePreview()));
52 widgetLayout->add( m_boolWidgets[i]);
53 }
54// TQSpacerItem * sp = new TQSpacerItem(1, 1);
55 widgetLayout->addStretch();
56}
57
58
59void KisMultiBoolFilterWidget::setConfiguration(KisFilterConfiguration * config)
60{
61
62 for (int i = 0; i < m_nbboolWidgets; ++i) {
63 double val = config->getBool(m_boolWidgets[i]->name());
64 m_boolWidgets[i]->setChecked(val);
65 }
66}
67
68#include "kis_multi_bool_filter_widget.moc"
A KisFilterConfiguration is the serializable representation of the filter parameters.