chalk

kis_dlg_layer_properties.cpp
1/*
2 * Copyright (c) 2005 Boudewijn Rempt <boud@valdyas.org>
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#include <limits.h>
19#include <tqlabel.h>
20#include <tqlayout.h>
21#include <tqgroupbox.h>
22#include <tqslider.h>
23#include <tqstring.h>
24#include <klineedit.h>
25#include <tdelocale.h>
26#include <kpushbutton.h>
27#include <knuminput.h>
28#include "kis_global.h"
29#include "squeezedcombobox.h"
30#include "wdglayerproperties.h"
31#include "kis_dlg_layer_properties.h"
32#include "kis_cmb_composite.h"
33#include "kis_cmb_idlist.h"
34#include "kis_profile.h"
35#include "kis_int_spinbox.h"
36#include "kis_colorspace.h"
37
38KisDlgLayerProperties::KisDlgLayerProperties(const TQString& deviceName,
39 TQ_INT32 opacity,
40 const KisCompositeOp& compositeOp,
41 const KisColorSpace * colorSpace,
42 TQWidget *parent, const char *name, WFlags f)
43 : super(parent, name, f, name, Ok | Cancel)
44{
45 m_page = new WdgLayerProperties(this);
46 m_page->layout()->setMargin(0);
47
48 opacity = int((opacity * 100.0) / 255 + 0.5);
49
50 setCaption(i18n("Layer Properties"));
51 setMainWidget(m_page);
52
53 m_page->editName->setText(deviceName);
54 connect( m_page->editName, TQ_SIGNAL( textChanged ( const TQString & ) ), this, TQ_SLOT( slotNameChanged( const TQString & ) ) );
55
56 m_page->cmbColorSpaces->setCurrent(colorSpace->id());
57 m_page->cmbColorSpaces->setEnabled(false);
58
59 TQString profilename;
60 if (KisProfile* profile = const_cast<KisColorSpace *>(colorSpace)->getProfile())
61 profilename = profile->productName();
62 m_page->cmbProfile->insertItem(profilename);
63 m_page->cmbProfile->setEnabled(false);
64
65 m_page->intOpacity->setRange(0, 100, 13);
66 m_page->intOpacity->setValue(opacity);
67
68 m_page->cmbComposite->setCompositeOpList(colorSpace->userVisiblecompositeOps());
69 m_page->cmbComposite->setCurrentItem(compositeOp);
70
71 slotNameChanged( m_page->editName->text() );
72}
73
74KisDlgLayerProperties::~KisDlgLayerProperties()
75{
76}
77
78void KisDlgLayerProperties::slotNameChanged( const TQString &_text )
79{
80 enableButtonOK( !_text.isEmpty() );
81}
82
83TQString KisDlgLayerProperties::getName() const
84{
85 return m_page->editName->text();
86}
87
88int KisDlgLayerProperties::getOpacity() const
89{
90 TQ_INT32 opacity = m_page->intOpacity->value();
91
92 if (!opacity)
93 return 0;
94
95 opacity = int((opacity * 255.0) / 100 + 0.5);
96 if(opacity>255)
97 opacity=255;
98 return opacity;
99}
100
101KisCompositeOp KisDlgLayerProperties::getCompositeOp() const
102{
103 return m_page->cmbComposite->currentItem();
104}
105
106#include "kis_dlg_layer_properties.moc"
A colorspace is the definition of a certain color model in Chalk.
virtual KisCompositeOpList userVisiblecompositeOps() const =0
Returns the list of user-visible composite ops supported by this colourspace.
virtual KisID id() const =0
Chalk definition for use in .kra files and internally: unchanging name + i18n'able description.