1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
|
/* This file is part of the KDE project
Made by Tomislav Lukman ([email protected])
Copyright (C) 2002, The Karbon Developers
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This library 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
Library General Public License for more details.
You should have received a copy of the GNU Library General Public License
along with this library; see the file COPYING.LIB. If not, write to
the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
* Boston, MA 02110-1301, USA.
*/
#include <tqhbuttongroup.h>
#include <tqlabel.h>
#include <tqlayout.h>
#include <tqpushbutton.h>
#include <tqwidget.h>
#include <tqtooltip.h>
#include <kiconloader.h>
#include <tdelocale.h>
#include <KoMainWindow.h>
#include "KoUnitWidgets.h"
#include "karbon_part.h"
#include "karbon_view.h"
#include "vstroke.h"
#include "vselection.h"
#include "vstrokecmd.h"
#include "vstrokedocker.h"
VStrokeDocker::VStrokeDocker( KarbonPart* part, KarbonView* parent, const char* /*name*/ )
: TQWidget(), m_part ( part ), m_view( parent )
{
setCaption( i18n( "Stroke Properties" ) );
TQPushButton *button;
TQGridLayout *mainLayout = new TQGridLayout( this, 4, 2 );
TQLabel* widthLabel = new TQLabel( i18n ( "stroke width", "Width:" ), this );
mainLayout->addWidget( widthLabel, 0, 0 );
// set min/max/step and value in points, then set actual unit
m_setLineWidth = new KoUnitDoubleSpinBox( this, 0.0, 1000.0, 0.5, 1.0, KoUnit::U_PT, 2 );
m_setLineWidth->setUnit( part->unit() );
TQToolTip::add( m_setLineWidth, i18n( "Set line width of actual selection" ) );
mainLayout->addWidget ( m_setLineWidth, 0, 1 );
connect( m_setLineWidth, TQT_SIGNAL( valueChanged( double ) ), this, TQT_SLOT( widthChanged() ) );
TQLabel* capLabel = new TQLabel( i18n ( "Cap:" ), this );
mainLayout->addWidget( capLabel, 1, 0 );
m_capGroup = new TQHButtonGroup( this );
m_capGroup->setFrameShape( TQFrame::NoFrame );
m_capGroup->setInsideMargin( 1 );
m_capGroup->setExclusive( true );
button = new TQPushButton( "", m_capGroup );
button->setPixmap( SmallIcon( "cap_butt" ) );
button->setToggleButton( true );
TQToolTip::add( button, i18n( "Butt cap" ) );
m_capGroup->insert( button );
button = new TQPushButton( "", m_capGroup );
button->setPixmap( SmallIcon( "cap_round" ) );
button->setToggleButton( true );
TQToolTip::add( button, i18n( "Round cap" ) );
m_capGroup->insert( button );
button = new TQPushButton( "", m_capGroup );
button->setPixmap( SmallIcon( "cap_square" ) );
button->setToggleButton( true );
TQToolTip::add( button, i18n( "Square cap" ) );
m_capGroup->insert( button );
mainLayout->addWidget( m_capGroup, 1, 1 );
connect( m_capGroup, TQT_SIGNAL( clicked( int ) ), this, TQT_SLOT( slotCapChanged( int ) ) );
TQLabel* joinLabel = new TQLabel( i18n ( "Join:" ), this );
mainLayout->addWidget( joinLabel, 2, 0 );
m_joinGroup = new TQHButtonGroup( this );
m_joinGroup->setFrameShape( TQFrame::NoFrame );
m_joinGroup->setInsideMargin( 1 );
m_joinGroup->setExclusive( true );
button = new TQPushButton( "", m_joinGroup );
button->setPixmap( SmallIcon( "join_miter" ) );
button->setToggleButton( true );
TQToolTip::add( button, i18n( "Miter join" ) );
m_joinGroup->insert( button );
button = new TQPushButton( "", m_joinGroup );
button->setPixmap( SmallIcon( "join_round" ) );
button->setToggleButton( true );
TQToolTip::add( button, i18n( "Round join" ) );
m_joinGroup->insert( button );
button = new TQPushButton( "", m_joinGroup );
button->setPixmap( SmallIcon( "join_bevel" ) );
button->setToggleButton( true );
TQToolTip::add( button, i18n( "Bevel join" ) );
m_joinGroup->insert( button );
mainLayout->addWidget( m_joinGroup, 2, 1 );
connect( m_joinGroup, TQT_SIGNAL( clicked( int ) ), this, TQT_SLOT( slotJoinChanged( int ) ) );
mainLayout->setRowStretch( 3, 1 );
mainLayout->setColStretch( 1, 1 );
mainLayout->activate();
updateDocker();
}
void VStrokeDocker::updateCanvas()
{
if( m_part && m_part->document().selection()->objects().count() > 0 )
m_part->addCommand( new VStrokeCmd( &m_part->document(), &m_stroke ), true );
}
void VStrokeDocker::slotCapChanged( int ID )
{
switch( ID )
{
case 1:
m_stroke.setLineCap( VStroke::capRound ); break;
case 2:
m_stroke.setLineCap( VStroke::capSquare ); break;
default:
m_stroke.setLineCap( VStroke::capButt );
}
updateCanvas();
}
void VStrokeDocker::slotJoinChanged( int ID )
{
switch( ID )
{
case 1:
m_stroke.setLineJoin( VStroke::joinRound ); break;
case 2:
m_stroke.setLineJoin( VStroke::joinBevel ); break;
default:
m_stroke.setLineJoin( VStroke::joinMiter );
}
updateCanvas();
}
void VStrokeDocker::updateDocker()
{
disconnect( m_setLineWidth, TQT_SIGNAL( valueChanged( double ) ), this, TQT_SLOT( widthChanged() ) );
disconnect( m_capGroup, TQT_SIGNAL( clicked( int ) ), this, TQT_SLOT( slotCapChanged( int ) ) );
disconnect( m_joinGroup, TQT_SIGNAL( clicked( int ) ), this, TQT_SLOT( slotJoinChanged( int ) ) );
switch( m_stroke.lineCap() )
{
case VStroke::capRound:
m_capGroup->setButton( 1 ); break;
case VStroke::capSquare:
m_capGroup->setButton( 2 ); break;
default:
m_capGroup->setButton( 0 );
}
switch( m_stroke.lineJoin() )
{
case VStroke::joinRound:
m_joinGroup->setButton( 1 ); break;
case VStroke::joinBevel:
m_joinGroup->setButton( 2 ); break;
default:
m_joinGroup->setButton( 0 );
}
m_setLineWidth->changeValue( m_stroke.lineWidth() );
connect( m_setLineWidth, TQT_SIGNAL( valueChanged( double ) ), this, TQT_SLOT( widthChanged() ) );
connect( m_capGroup, TQT_SIGNAL( clicked( int ) ), this, TQT_SLOT( slotCapChanged( int ) ) );
connect( m_joinGroup, TQT_SIGNAL( clicked( int ) ), this, TQT_SLOT( slotJoinChanged( int ) ) );
}
void VStrokeDocker::widthChanged()
{
m_stroke.setLineWidth( m_setLineWidth->value() );
updateCanvas();
}
void VStrokeDocker::setStroke( const VStroke &stroke )
{
if( &stroke )
m_stroke = stroke;
else
m_stroke = VStroke();
updateDocker();
}
void VStrokeDocker::setUnit( KoUnit::Unit unit )
{
disconnect( m_setLineWidth, TQT_SIGNAL( valueChanged( double ) ), this, TQT_SLOT( widthChanged() ) );
disconnect( m_capGroup, TQT_SIGNAL( clicked( int ) ), this, TQT_SLOT( slotCapChanged( int ) ) );
disconnect( m_joinGroup, TQT_SIGNAL( clicked( int ) ), this, TQT_SLOT( slotJoinChanged( int ) ) );
m_setLineWidth->setUnit( unit );
connect( m_setLineWidth, TQT_SIGNAL( valueChanged( double ) ), this, TQT_SLOT( widthChanged() ) );
connect( m_capGroup, TQT_SIGNAL( clicked( int ) ), this, TQT_SLOT( slotCapChanged( int ) ) );
connect( m_joinGroup, TQT_SIGNAL( clicked( int ) ), this, TQT_SLOT( slotJoinChanged( int ) ) );
}
#include "vstrokedocker.moc"
|