You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
181 lines
3.8 KiB
181 lines
3.8 KiB
15 years ago
|
// Copyright (C) 2002 Dominique Devriese <devriese@kde.org>
|
||
|
|
||
|
// This program is free software; you can redistribute it and/or
|
||
|
// modify it under the terms of the GNU General Public License
|
||
|
// as published by the Free Software Foundation; either version 2
|
||
|
// of the License, or (at your option) any later version.
|
||
|
|
||
|
// This program 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 General Public License for more details.
|
||
|
|
||
|
// You should have received a copy of the GNU General Public License
|
||
|
// along with this program; if not, write to the Free Software
|
||
|
// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
|
||
|
// 02110-1301, USA.
|
||
|
|
||
|
#include "dragrectmode.h"
|
||
|
|
||
|
#include "../kig/kig_document.h"
|
||
|
#include "../kig/kig_part.h"
|
||
|
#include "../kig/kig_view.h"
|
||
|
#include "../misc/kigpainter.h"
|
||
|
|
||
15 years ago
|
#include <tqevent.h>
|
||
|
#include <tqglobal.h>
|
||
12 years ago
|
#include <tdeaction.h>
|
||
15 years ago
|
|
||
15 years ago
|
DragRectMode::DragRectMode( const TQPoint& start, KigPart& d, KigWidget& w )
|
||
15 years ago
|
: KigMode( d ), mstart( start ), mnc( true ), mstartselected( true ),
|
||
|
mcancelled( false )
|
||
|
{
|
||
|
moved( start, w );
|
||
|
}
|
||
|
|
||
|
DragRectMode::DragRectMode( KigPart& d, KigWidget& w )
|
||
|
: KigMode( d ), mnc( true ), mstartselected( false ),
|
||
|
mcancelled( false )
|
||
|
{
|
||
|
w.updateCurPix();
|
||
|
w.updateWidget();
|
||
|
}
|
||
|
|
||
15 years ago
|
void DragRectMode::moved( const TQPoint& p, KigWidget& w )
|
||
15 years ago
|
{
|
||
|
// update the rect...
|
||
|
w.updateCurPix();
|
||
15 years ago
|
std::vector<TQRect> overlay;
|
||
15 years ago
|
if ( mstartselected )
|
||
|
{
|
||
14 years ago
|
KigPainter pt( w.screenInfo(), TQT_TQPAINTDEVICE(&w.curPix), mdoc.document() );
|
||
15 years ago
|
pt.drawFilledRect( TQRect( p, mstart ) );
|
||
15 years ago
|
overlay = pt.overlay();
|
||
|
};
|
||
|
w.updateWidget( overlay );
|
||
|
}
|
||
|
|
||
15 years ago
|
void DragRectMode::released( const TQPoint& p, KigWidget& w, bool nc )
|
||
15 years ago
|
{
|
||
|
if ( mstartselected )
|
||
|
{
|
||
15 years ago
|
mrect = w.fromScreen( TQRect( mstart, p ) );
|
||
15 years ago
|
mret = mdoc.document().whatIsInHere( mrect, w );
|
||
|
mnc = nc;
|
||
|
|
||
|
mdoc.doneMode( this );
|
||
|
};
|
||
|
}
|
||
|
|
||
|
void DragRectMode::enableActions()
|
||
|
{
|
||
|
KigMode::enableActions();
|
||
|
|
||
|
mdoc.aCancelConstruction->setEnabled( true );
|
||
|
}
|
||
|
|
||
|
std::vector<ObjectHolder*> DragRectMode::ret() const
|
||
|
{
|
||
|
return mret;
|
||
|
}
|
||
|
|
||
|
bool DragRectMode::needClear() const
|
||
|
{
|
||
|
return mnc;
|
||
|
}
|
||
|
|
||
15 years ago
|
void DragRectMode::moved( TQMouseEvent* e, KigWidget& w )
|
||
15 years ago
|
{
|
||
|
moved( e->pos(), w );
|
||
|
}
|
||
|
|
||
15 years ago
|
void DragRectMode::released( TQMouseEvent* e, KigWidget& w )
|
||
15 years ago
|
{
|
||
|
released( e->pos(), w, ! ( e->state() & ( ControlButton | ShiftButton ) ) );
|
||
|
}
|
||
|
|
||
|
DragRectMode::~DragRectMode()
|
||
|
{
|
||
|
}
|
||
|
|
||
15 years ago
|
void DragRectMode::mouseMoved( TQMouseEvent* e, KigWidget* w )
|
||
15 years ago
|
{
|
||
|
moved( e, *w );
|
||
|
}
|
||
|
|
||
15 years ago
|
void DragRectMode::leftMouseMoved( TQMouseEvent* e, KigWidget* w )
|
||
15 years ago
|
{
|
||
|
moved( e, *w );
|
||
|
}
|
||
|
|
||
15 years ago
|
void DragRectMode::midMouseMoved( TQMouseEvent* e, KigWidget* w )
|
||
15 years ago
|
{
|
||
|
moved( e, *w );
|
||
|
}
|
||
|
|
||
15 years ago
|
void DragRectMode::rightMouseMoved( TQMouseEvent* e, KigWidget* w )
|
||
15 years ago
|
{
|
||
|
moved( e, *w );
|
||
|
}
|
||
|
|
||
15 years ago
|
void DragRectMode::leftReleased( TQMouseEvent* e, KigWidget* w )
|
||
15 years ago
|
{
|
||
|
released( e, *w );
|
||
|
}
|
||
|
|
||
15 years ago
|
void DragRectMode::midReleased( TQMouseEvent* e, KigWidget* w )
|
||
15 years ago
|
{
|
||
|
released( e, *w );
|
||
|
}
|
||
|
|
||
15 years ago
|
void DragRectMode::rightReleased( TQMouseEvent* e, KigWidget* w )
|
||
15 years ago
|
{
|
||
|
released( e, *w );
|
||
|
}
|
||
|
|
||
|
Rect DragRectMode::rect() const
|
||
|
{
|
||
|
return mrect;
|
||
|
}
|
||
|
|
||
15 years ago
|
void DragRectMode::clicked( const TQMouseEvent* e, KigWidget& w )
|
||
15 years ago
|
{
|
||
|
clicked( e->pos(), w );
|
||
|
}
|
||
|
|
||
15 years ago
|
void DragRectMode::leftClicked( TQMouseEvent* e, KigWidget* w )
|
||
15 years ago
|
{
|
||
|
clicked( e, *w );
|
||
|
}
|
||
|
|
||
15 years ago
|
void DragRectMode::midClicked( TQMouseEvent* e, KigWidget* w )
|
||
15 years ago
|
{
|
||
|
clicked( e, *w );
|
||
|
}
|
||
|
|
||
15 years ago
|
void DragRectMode::rightClicked( TQMouseEvent* e, KigWidget* w )
|
||
15 years ago
|
{
|
||
|
clicked( e, *w );
|
||
|
}
|
||
|
|
||
15 years ago
|
void DragRectMode::clicked( const TQPoint& p, KigWidget& )
|
||
15 years ago
|
{
|
||
|
if ( !mstartselected )
|
||
|
{
|
||
|
mstartselected = true;
|
||
|
mstart = p;
|
||
|
};
|
||
|
}
|
||
|
|
||
|
bool DragRectMode::cancelled() const
|
||
|
{
|
||
|
return mcancelled;
|
||
|
}
|
||
|
|
||
|
void DragRectMode::cancelConstruction()
|
||
|
{
|
||
|
mcancelled = true;
|
||
|
mdoc.doneMode( this );
|
||
|
}
|
||
|
|