1
/* This file is part of the KDE project
2
Made by Tomislav Lukman (tomislav.lukman@ck.tel.hr)
3
Copyright (C) 2002, The Karbon Developers
5
This library is free software; you can redistribute it and/or
6
modify it under the terms of the GNU Library General Public
7
License as published by the Free Software Foundation; either
8
version 2 of the License, or (at your option) any later version.
10
This library is distributed in the hope that it will be useful,
11
but WITHOUT ANY WARRANTY; without even the implied warranty of
12
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13
Library General Public License for more details.
15
You should have received a copy of the GNU Library General Public License
16
along with this library; see the file COPYING.LIB. If not, write to
17
the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
18
Boston, MA 02111-1307, USA.
21
#include <qhbuttongroup.h>
24
#include <qpushbutton.h>
27
#include <kiconloader.h>
29
#include <koMainWindow.h>
31
#include "koUnitWidgets.h"
33
#include "karbon_part.h"
34
#include "karbon_view.h"
36
#include "vcolorslider.h"
37
#include "vselection.h"
38
#include "vstrokecmd.h"
40
#include "vstrokedocker.h"
42
VStrokeDocker::VStrokeDocker( KarbonPart* part, KarbonView* parent, const char* /*name*/ )
43
: VDocker( parent->shell() ), m_part ( part ), m_view( parent )
45
setCaption( i18n( "Stroke Properties" ) );
48
mainWidget = new QWidget( this );
49
QGridLayout *mainLayout = new QGridLayout( mainWidget, 4, 2 );
51
QLabel* widthLabel = new QLabel( i18n ( "Width:" ), mainWidget );
52
mainLayout->addWidget( widthLabel, 0, 0 );
53
m_setLineWidth = new KoUnitDoubleSpinBox( mainWidget, 0.0, 1000.0, 0.5, 1.0, KoUnit::U_PT, 1 );
54
mainLayout->addWidget ( m_setLineWidth, 0, 1 );
55
connect( m_setLineWidth, SIGNAL( valueChanged( double ) ), this, SLOT( widthChanged() ) );
57
QLabel* capLabel = new QLabel( i18n ( "Cap:" ), mainWidget );
58
mainLayout->addWidget( capLabel, 1, 0 );
59
m_capGroup = new QHButtonGroup( mainWidget );
60
m_capGroup->setFrameShape( NoFrame );
61
m_capGroup->setInsideMargin( 1 );
62
m_capGroup->setExclusive( true );
63
button = new QPushButton( "", m_capGroup );
64
button->setPixmap( SmallIcon( "cap_butt" ) );
65
button->setToggleButton( true );
66
m_capGroup->insert( button );
67
button = new QPushButton( "", m_capGroup );
68
button->setPixmap( SmallIcon( "cap_round" ) );
69
button->setToggleButton( true );
70
m_capGroup->insert( button );
71
button = new QPushButton( "", m_capGroup );
72
button->setPixmap( SmallIcon( "cap_square" ) );
73
button->setToggleButton( true );
74
m_capGroup->insert( button );
75
mainLayout->addWidget( m_capGroup, 1, 1 );
76
connect( m_capGroup, SIGNAL( clicked( int ) ), this, SLOT( slotCapChanged( int ) ) );
78
QLabel* joinLabel = new QLabel( i18n ( "Join:" ), mainWidget );
79
mainLayout->addWidget( joinLabel, 2, 0 );
81
m_joinGroup = new QHButtonGroup( mainWidget );
82
m_joinGroup->setFrameShape( NoFrame );
83
m_joinGroup->setInsideMargin( 1 );
84
m_joinGroup->setExclusive( true );
85
button = new QPushButton( "", m_joinGroup );
86
button->setPixmap( SmallIcon( "join_miter" ) );
87
button->setToggleButton( true );
88
m_joinGroup->insert( button );
89
button = new QPushButton( "", m_joinGroup );
90
button->setPixmap( SmallIcon( "join_round" ) );
91
button->setToggleButton( true );
92
m_joinGroup->insert( button );
93
button = new QPushButton( "", m_joinGroup );
94
button->setPixmap( SmallIcon( "join_bevel" ) );
95
button->setToggleButton( true );
96
m_joinGroup->insert( button );
97
mainLayout->addWidget( m_joinGroup, 2, 1 );
98
connect( m_joinGroup, SIGNAL( clicked( int ) ), this, SLOT( slotJoinChanged( int ) ) );
100
mainLayout->activate();
101
setWidget( mainWidget );
106
void VStrokeDocker::updateCanvas()
108
if( m_part && m_part->document().selection()->objects().count() > 0 )
109
m_part->addCommand( new VStrokeCmd( &m_part->document(), &m_stroke ), true );
112
void VStrokeDocker::slotCapChanged( int ID )
117
m_stroke.setLineCap( VStroke::capRound ); break;
119
m_stroke.setLineCap( VStroke::capSquare ); break;
121
m_stroke.setLineCap( VStroke::capButt );
126
void VStrokeDocker::slotJoinChanged( int ID )
131
m_stroke.setLineJoin( VStroke::joinRound ); break;
133
m_stroke.setLineJoin( VStroke::joinBevel ); break;
135
m_stroke.setLineJoin( VStroke::joinMiter );
140
void VStrokeDocker::updateDocker()
142
disconnect( m_setLineWidth, SIGNAL( valueChanged( double ) ), this, SLOT( widthChanged() ) );
143
disconnect( m_capGroup, SIGNAL( clicked( int ) ), this, SLOT( slotCapChanged( int ) ) );
144
disconnect( m_joinGroup, SIGNAL( clicked( int ) ), this, SLOT( slotJoinChanged( int ) ) );
146
switch( m_stroke.lineCap() )
148
case VStroke::capRound:
149
m_capGroup->setButton( 1 ); break;
150
case VStroke::capSquare:
151
m_capGroup->setButton( 2 ); break;
153
m_capGroup->setButton( 0 );
156
switch( m_stroke.lineJoin() )
158
case VStroke::joinRound:
159
m_joinGroup->setButton( 1 ); break;
160
case VStroke::joinBevel:
161
m_joinGroup->setButton( 2 ); break;
163
m_joinGroup->setButton( 0 );
166
m_setLineWidth->setValue( m_stroke.lineWidth() );
168
connect( m_setLineWidth, SIGNAL( valueChanged( double ) ), this, SLOT( widthChanged() ) );
169
connect( m_capGroup, SIGNAL( clicked( int ) ), this, SLOT( slotCapChanged( int ) ) );
170
connect( m_joinGroup, SIGNAL( clicked( int ) ), this, SLOT( slotJoinChanged( int ) ) );
173
void VStrokeDocker::widthChanged()
175
m_stroke.setLineWidth( m_setLineWidth->value() );
179
void VStrokeDocker::setStroke( const VStroke &stroke )
185
#include "vstrokedocker.moc"