24#include "karbon_part.h"
25#include "karbon_view.h"
27#include "vcomposite.h"
30#include "vpainterfactory.h"
32#include "vshapetool.h"
33#include "vselection.h"
36VShapeTool::VShapeTool( KarbonView *view,
const char *name,
bool polar )
46VShapeTool::~VShapeTool()
52VShapeTool::contextHelp()
54 TQString s = i18n(
"<qt><b>Shape tool</b><br>" );
55 s += i18n(
"<i>Click and drag</i> to place your own shape.<br>" );
56 s += i18n(
"<i>Click</i> to place a shape using the tool properties values.</qt>" );
64 view()->setCursor( *m_cursor );
65 view()->part()->document().selection()->showHandle(
true );
69VShapeTool::statusText()
77 VPainter* painter = view()->painterFactory()->editpainter();
78 painter->setRasterOp( TQt::NotROP );
80 VPath* composite = shape();
87VShapeTool::mouseButtonPress()
96VShapeTool::mouseButtonRelease()
104 VPath* composite = shape(
true );
108 VShapeCmd* cmd =
new VShapeCmd(
109 &view()->part()->document(),
110 uiname(), composite, icon() );
112 view()->part()->addCommand( cmd,
true );
117 m_isCentered =
false;
121VShapeTool::mouseDrag()
133VShapeTool::mouseDragRelease()
137 VShapeCmd* cmd =
new VShapeCmd(
138 &view()->part()->document(),
139 uiname(), shape(), icon() );
141 view()->part()->addCommand( cmd,
true );
144 m_isCentered =
false;
148VShapeTool::mouseDragShiftPressed()
161VShapeTool::mouseDragCtrlPressed()
174VShapeTool::mouseDragShiftReleased()
187VShapeTool::mouseDragCtrlReleased()
192 m_isCentered =
false;
207 m_isCentered =
false;
214 m_isSquare = shiftPressed();
215 m_isCentered = ctrlPressed();
217 KoPoint _first = view()->canvasWidget()->snapToGrid( first() );
218 KoPoint _last = view()->canvasWidget()->snapToGrid( last() );
225 ( _last.x() - _first.x() ) * ( _last.x() - _first.x() ) +
226 ( _last.y() - _first.y() ) * ( _last.y() - _first.y() ) );
229 m_d2 = atan2( _last.y() - _first.y(), _last.x() - _first.x() );
232 m_d2 -= VGlobal::pi_2;
239 m_d1 = _last.x() - _first.x();
240 m_d2 = _last.y() - _first.y();
242 const int m_sign1 = VGlobal::sign( m_d1 );
244 const int m_sign2 = VGlobal::sign( -m_d2 );
262 _first.x() - ( m_sign1 == -1 ? m_d1 : 0.0 ) );
265 _first.y() + ( m_sign2 == -1 ? m_d2 : 0.0 ) );
269 m_p.setX( m_p.x() - m_sign1 * tqRound( m_d1 * 0.5 ) );
270 m_p.setY( m_p.y() + m_sign2 * tqRound( m_d2 * 0.5 ) );
@ CrossHair
unthemed crosshair cursor
static TQCursor createCursor(CursorType type)
Creates a predefined cursor of the specified type.
virtual void setState(const VState state)
Sets the state to a specified new state.
@ edit
visible, active and is currently manipulated by a tool
A composite path consists of one or many subpaths.
virtual void draw(VPainter *painter, const KoRect *rect=0L) const
Draw the object to a painting device.
virtual const KoRect & boundingBox() const
Calculates the tightest bounding box around the object.