27#include <karbon_part.h>
28#include <karbon_part.h>
29#include <karbon_view.h>
30#include <karbon_view.h>
31#include <render/vpainter.h>
32#include <render/vpainterfactory.h>
33#include <core/vcursor.h>
35VZoomTool::VZoomTool(KarbonView *view ):
VTool( view,
"tool_zoom_plugin" )
42VZoomTool::~VZoomTool()
48VZoomTool::contextHelp()
50 TQString s = i18n(
"<qt><b>Zoom tool:</b><br>" );
51 s += i18n(
"<i>Click and drag</i> to zoom into a rectangular area.<br>" );
52 s += i18n(
"<i>Right click</i> to zoom out of canvas.<br>" );
53 s += i18n(
"<i>Pressing +/- keys</i><br>to zoom into/out of canvas." );
61 view()->setCursor( *m_plusCursor );
65VZoomTool::statusText()
67 return i18n(
"Zoom Tool" );
71VZoomTool::deactivate()
78 VPainter *painter = view()->painterFactory()->editpainter();
79 painter->setRasterOp( TQt::NotROP );
83 painter->setPen( TQt::DotLine );
85 painter->moveTo( KoPoint( first().x(), first().y() ) );
86 painter->lineTo( KoPoint( m_current.x(), first().y() ) );
87 painter->lineTo( KoPoint( m_current.x(), m_current.y() ) );
88 painter->lineTo( KoPoint( first().x(), m_current.y() ) );
89 painter->lineTo( KoPoint( first().x(), first().y() ) );
90 painter->strokePath();
95VZoomTool::mouseButtonPress()
105VZoomTool::rightMouseButtonRelease()
107 view()->setZoomAt( view()->zoom() * 0.75, last() );
111VZoomTool::mouseButtonRelease()
113 view()->setZoomAt( view()->zoom() * 1.5, last() );
117VZoomTool::mouseDrag()
127VZoomTool::mouseDragRelease()
129 KoRect rect( first().x(), first().y(), last().x() - first().x(), last().y() - first().y() );
130 rect = rect.normalize();
131 view()->setViewportRect( rect );
135VZoomTool::keyReleased( TQt::Key key )
137 double zoomChange = 0;
138 if( key == TQt::Key_Minus )
140 else if( key == TQt::Key_Plus )
143 if( zoomChange != 0 )
145 view()->setZoomAt( view()->zoom() * zoomChange );
158VZoomTool::setup( TDEActionCollection *collection )
160 m_action =
static_cast<TDERadioAction *
>(collection -> action( name() ) );
164 m_action =
new TDERadioAction( i18n(
"Zoom Tool" ),
"14_zoom", TQt::SHIFT+TQt::Key_H,
this, TQ_SLOT( activate() ), collection, name() );
165 m_action->setToolTip( i18n(
"Zoom" ) );
166 m_action->setExclusiveGroup(
"misc" );
static TQCursor createCursor(CursorType type)
Creates a predefined cursor of the specified type.