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.
161 lines
4.0 KiB
161 lines
4.0 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 "base_mode.h"
|
||
|
|
||
|
#include "popup.h"
|
||
|
|
||
|
#include "../kig/kig_view.h"
|
||
|
#include "../kig/kig_part.h"
|
||
|
#include "../kig/kig_document.h"
|
||
|
|
||
15 years ago
|
#include <tqevent.h>
|
||
15 years ago
|
#include <kcursor.h>
|
||
|
|
||
|
BaseMode::BaseMode( KigPart& d )
|
||
|
: KigMode( d )
|
||
|
{
|
||
|
}
|
||
|
|
||
|
BaseMode::~BaseMode()
|
||
|
{
|
||
|
}
|
||
|
|
||
15 years ago
|
void BaseMode::leftClicked( TQMouseEvent* e, KigWidget* v )
|
||
15 years ago
|
{
|
||
|
// touch screens don't send a mouseMoved event before a click event,
|
||
14 years ago
|
// apparently, so we simulate it.
|
||
15 years ago
|
mouseMoved( e, v );
|
||
|
|
||
|
// get rid of text still showing...
|
||
|
v->updateCurPix();
|
||
|
v->updateWidget();
|
||
|
|
||
|
mplc = e->pos();
|
||
12 years ago
|
moco = mdoc.document().whatAmIOn( v->fromScreen( mplc ), *v );
|
||
15 years ago
|
|
||
12 years ago
|
if( moco.empty() )
|
||
15 years ago
|
{
|
||
|
// clicked on an empty spot --> we show the rectangle for
|
||
|
// selecting stuff...
|
||
|
dragRect( mplc, *v );
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
// the user clicked on some object.. --> this could either mean
|
||
|
// that he/she wants to select the object or that he wants to
|
||
|
// start moving it. We assume nothing here, we wait till he
|
||
|
// either moves some 4 pixels, or till he releases his mouse
|
||
|
// button in leftReleased() or mouseMoved()...
|
||
|
};
|
||
|
}
|
||
|
|
||
15 years ago
|
void BaseMode::leftMouseMoved( TQMouseEvent* e, KigWidget* w )
|
||
15 years ago
|
{
|
||
12 years ago
|
if( !moco.empty() && ( mplc - e->pos() ).manhattanLength() > 3 )
|
||
|
dragObject( moco, mplc, *w,
|
||
15 years ago
|
( e->state() & (ShiftButton | ControlButton ) ) != 0
|
||
|
);
|
||
|
}
|
||
|
|
||
15 years ago
|
void BaseMode::leftReleased( TQMouseEvent* e, KigWidget* v )
|
||
15 years ago
|
{
|
||
|
if( (mplc - e->pos()).manhattanLength() > 4 ) return;
|
||
|
|
||
|
ObjectHolder* o = 0;
|
||
|
bool keyCtrl = ( e->state() & ControlButton ) != 0;
|
||
|
bool keyShift = ( e->state() & ShiftButton ) != 0;
|
||
12 years ago
|
if ( ! moco.empty() )
|
||
15 years ago
|
{
|
||
|
if ( keyShift )
|
||
|
{
|
||
12 years ago
|
int id = ObjectChooserPopup::getObjectFromList( e->pos(), v, moco );
|
||
15 years ago
|
if ( id >= 0 )
|
||
12 years ago
|
o = moco[id];
|
||
15 years ago
|
}
|
||
|
else
|
||
12 years ago
|
o = moco.front();
|
||
15 years ago
|
}
|
||
|
leftClickedObject( o, e->pos(), *v, keyCtrl );
|
||
|
}
|
||
|
|
||
15 years ago
|
void BaseMode::midClicked( TQMouseEvent* e, KigWidget* v )
|
||
15 years ago
|
{
|
||
|
// get rid of text still showing...
|
||
|
v->updateCurPix();
|
||
|
v->updateWidget();
|
||
|
|
||
|
mplc = e->pos();
|
||
12 years ago
|
moco = mdoc.document().whatAmIOn( v->fromScreen( e->pos() ), *v );
|
||
15 years ago
|
}
|
||
|
|
||
15 years ago
|
void BaseMode::midReleased( TQMouseEvent* e, KigWidget* v )
|
||
15 years ago
|
{
|
||
|
if( (e->pos() - mplc).manhattanLength() > 4 ) return;
|
||
|
|
||
|
midClicked( mplc, *v );
|
||
|
}
|
||
|
|
||
15 years ago
|
void BaseMode::rightClicked( TQMouseEvent* e, KigWidget* w )
|
||
15 years ago
|
{
|
||
|
// get rid of text still showing...
|
||
|
w->updateCurPix();
|
||
|
w->updateWidget();
|
||
|
// set a normal cursor...
|
||
|
w->setCursor( KCursor::arrowCursor() );
|
||
|
|
||
|
mplc = e->pos();
|
||
12 years ago
|
moco = mdoc.document().whatAmIOn( w->fromScreen( mplc ), *w );
|
||
15 years ago
|
|
||
12 years ago
|
rightClicked( moco, mplc, *w );
|
||
15 years ago
|
}
|
||
|
|
||
15 years ago
|
void BaseMode::mouseMoved( TQMouseEvent* e, KigWidget* w )
|
||
15 years ago
|
{
|
||
|
std::vector<ObjectHolder*> os = mdoc.document().whatAmIOn( w->fromScreen( e->pos() ), *w );
|
||
14 years ago
|
mouseMoved( os, e->pos(), *w, e->state() & TQt::ShiftButton );
|
||
15 years ago
|
}
|
||
|
|
||
15 years ago
|
void BaseMode::dragRect( const TQPoint&, KigWidget& )
|
||
15 years ago
|
{
|
||
|
}
|
||
|
|
||
15 years ago
|
void BaseMode::leftClickedObject( ObjectHolder*, const TQPoint&,
|
||
15 years ago
|
KigWidget&, bool )
|
||
|
{
|
||
|
}
|
||
|
|
||
15 years ago
|
void BaseMode::dragObject( const std::vector<ObjectHolder*>&, const TQPoint&,
|
||
15 years ago
|
KigWidget&, bool )
|
||
|
{
|
||
|
}
|
||
|
|
||
|
void BaseMode::enableActions()
|
||
|
{
|
||
|
KigMode::enableActions();
|
||
|
}
|
||
|
|
||
|
std::vector<ObjectHolder*> BaseMode::oco()
|
||
|
{
|
||
12 years ago
|
return moco;
|
||
15 years ago
|
}
|
||
|
|
||
15 years ago
|
TQPoint BaseMode::pointLocation()
|
||
15 years ago
|
{
|
||
|
return mplc;
|
||
|
}
|