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.
573 lines
17 KiB
573 lines
17 KiB
15 years ago
|
// Copyright (C) 2003 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 "construct_mode.h"
|
||
|
|
||
|
#include "../objects/object_factory.h"
|
||
|
#include "../objects/object_drawer.h"
|
||
|
#include "../objects/text_type.h"
|
||
|
#include "../objects/text_imp.h"
|
||
|
#include "../objects/bogus_imp.h"
|
||
|
#include "../objects/point_imp.h"
|
||
|
#include "../misc/argsparser.h"
|
||
|
|
||
|
#include "../kig/kig_document.h"
|
||
|
#include "../kig/kig_part.h"
|
||
|
#include "../kig/kig_view.h"
|
||
|
#include "../misc/object_constructor.h"
|
||
|
#include "../misc/coordinate_system.h"
|
||
|
#include "../misc/kigpainter.h"
|
||
|
#include "../misc/calcpaths.h"
|
||
|
|
||
|
#include "popup.h"
|
||
|
|
||
|
#include <kcursor.h>
|
||
12 years ago
|
#include <tdeaction.h>
|
||
15 years ago
|
|
||
|
#include <algorithm>
|
||
|
#include <functional>
|
||
|
|
||
|
static void redefinePoint( ObjectTypeCalcer* mpt, const Coordinate& c, KigDocument& doc, const KigWidget& w )
|
||
|
{
|
||
|
ObjectFactory::instance()->redefinePoint( mpt, c, doc, w );
|
||
|
mpt->calc( doc );
|
||
|
}
|
||
|
|
||
|
BaseConstructMode::BaseConstructMode( KigPart& d )
|
||
|
: BaseMode( d )
|
||
|
{
|
||
|
mpt = ObjectFactory::instance()->fixedPointCalcer( Coordinate( 0, 0 ) );
|
||
|
mpt->calc( d.document() );
|
||
|
mcursor = ObjectFactory::instance()->cursorPointCalcer( Coordinate( 0, 0 ) );
|
||
|
mcursor->calc( d.document() );
|
||
|
// mcursorholder = new ObjectHolder( mcursor );
|
||
|
}
|
||
|
|
||
|
BaseConstructMode::~BaseConstructMode()
|
||
|
{
|
||
|
delete mcursor;
|
||
|
// delete mcursorholder;
|
||
|
}
|
||
|
|
||
15 years ago
|
void BaseConstructMode::leftReleased( TQMouseEvent* e, KigWidget* v )
|
||
15 years ago
|
{
|
||
|
if( (pointLocation() - e->pos()).manhattanLength() > 4 ) return;
|
||
|
|
||
|
ObjectHolder* o = 0;
|
||
|
bool keyCtrlOrShift = ( e->state() & ( ControlButton | ShiftButton) ) != 0;
|
||
12 years ago
|
std::vector<ObjectHolder*> moco = oco();
|
||
|
if ( ! moco.empty() )
|
||
15 years ago
|
{
|
||
|
std::vector<ObjectHolder*> goodargs;
|
||
12 years ago
|
if ( !moco.empty() )
|
||
15 years ago
|
{
|
||
|
std::vector<ObjectHolder*>::const_iterator it;
|
||
14 years ago
|
std::vector<ObjectCalcer*> testargs = getCalcers( mparents );
|
||
12 years ago
|
for ( std::vector<ObjectHolder*>::const_iterator i = moco.begin(); i != moco.end(); ++i )
|
||
15 years ago
|
{
|
||
14 years ago
|
it = std::find( mparents.begin(), mparents.end(), *i );
|
||
15 years ago
|
bool newdup =
|
||
14 years ago
|
( it == mparents.end() ) ||
|
||
|
isAlreadySelectedOK( testargs, it - mparents.begin() );
|
||
15 years ago
|
if ( newdup )
|
||
|
{
|
||
|
testargs.push_back( ( *i )->calcer() );
|
||
|
if ( wantArgs( testargs, mdoc.document(), *v ) )
|
||
|
goodargs.push_back( *i );
|
||
|
testargs.pop_back();
|
||
|
}
|
||
|
}
|
||
|
int id = ObjectChooserPopup::getObjectFromList( e->pos(), v, goodargs );
|
||
|
if ( id >= 0 )
|
||
|
o = goodargs[id];
|
||
|
}
|
||
|
}
|
||
|
leftClickedObject( o, e->pos(), *v, keyCtrlOrShift );
|
||
|
KigMode::leftReleased( e, v );
|
||
|
}
|
||
|
|
||
|
void BaseConstructMode::leftClickedObject(
|
||
15 years ago
|
ObjectHolder* o, const TQPoint& p, KigWidget& w, bool )
|
||
15 years ago
|
{
|
||
14 years ago
|
std::vector<ObjectHolder*>::iterator it = std::find( mparents.begin(), mparents.end(), o );
|
||
|
std::vector<ObjectCalcer*> nargs = getCalcers( mparents );
|
||
15 years ago
|
//
|
||
|
// mp: duplicationchecked controls whether the arguments list is
|
||
|
// free of duplications or if a duplication is safe (asking this to
|
||
|
// the Constructor class through the "isAlreadySelectedOK" method).
|
||
|
//
|
||
|
bool duplicationchecked =
|
||
14 years ago
|
( it == mparents.end() ) ||
|
||
|
isAlreadySelectedOK( nargs, it - mparents.begin() );
|
||
15 years ago
|
if ( o && duplicationchecked )
|
||
|
{
|
||
|
nargs.push_back( o->calcer() );
|
||
|
if ( wantArgs( nargs, mdoc.document(), w ) )
|
||
|
{
|
||
|
selectObject( o, w );
|
||
|
return;
|
||
|
}
|
||
|
}
|
||
|
|
||
14 years ago
|
nargs = getCalcers( mparents );
|
||
15 years ago
|
nargs.push_back( mpt.get() );
|
||
|
if ( wantArgs( nargs, mdoc.document(), w ) )
|
||
|
{
|
||
|
// add mpt to the document..
|
||
|
ObjectHolder* n = new ObjectHolder( mpt.get() );
|
||
|
mdoc.addObject( n );
|
||
|
selectObject( n, w );
|
||
|
// get a new mpt for our further use..
|
||
|
mpt = ObjectFactory::instance()->sensiblePointCalcer( w.fromScreen( p ), mdoc.document(), w );
|
||
|
mpt->calc( mdoc.document() );
|
||
|
return;
|
||
|
}
|
||
|
|
||
14 years ago
|
nargs = getCalcers( mparents );
|
||
15 years ago
|
nargs.push_back( mcursor );
|
||
|
|
||
|
if ( wantArgs( nargs, mdoc.document(), w ) )
|
||
|
{
|
||
|
// DON'T add mpt to the document..
|
||
|
// the objectholder has been constructed once and for all
|
||
|
// when entering construction mode, and delete in the
|
||
|
// destructor.
|
||
|
ObjectHolder* n = new ObjectHolder( mcursor );
|
||
|
selectObject( n, w );
|
||
|
mcursor = ObjectFactory::instance()->cursorPointCalcer( w.fromScreen( p ) );
|
||
|
// mcursor = ObjectFactory::instance()->sensiblePointCalcer( w.fromScreen( p ), mdoc.document(), w );
|
||
|
mcursor->calc( mdoc.document() );
|
||
|
delete n;
|
||
|
}
|
||
|
}
|
||
|
|
||
15 years ago
|
void BaseConstructMode::midClicked( const TQPoint& p, KigWidget& w )
|
||
15 years ago
|
{
|
||
14 years ago
|
std::vector<ObjectCalcer*> args = getCalcers( mparents );
|
||
15 years ago
|
args.push_back( mpt.get() );
|
||
|
if ( wantArgs( args, mdoc.document(), w ) )
|
||
|
{
|
||
|
ObjectHolder* n = new ObjectHolder( mpt.get() );
|
||
|
mdoc.addObject( n );
|
||
|
|
||
|
selectObject( n, w );
|
||
|
|
||
|
mpt = ObjectFactory::instance()->sensiblePointCalcer( w.fromScreen( p ), mdoc.document(), w );
|
||
|
mpt->calc( mdoc.document() );
|
||
|
}
|
||
|
}
|
||
|
|
||
15 years ago
|
void BaseConstructMode::rightClicked( const std::vector<ObjectHolder*>&, const TQPoint&, KigWidget& )
|
||
15 years ago
|
{
|
||
|
// TODO ?
|
||
|
}
|
||
|
|
||
15 years ago
|
void BaseConstructMode::mouseMoved( const std::vector<ObjectHolder*>& os, const TQPoint& p,
|
||
15 years ago
|
KigWidget& w, bool shiftpressed )
|
||
|
{
|
||
14 years ago
|
mdoc.emitStatusBarText( selectStatement( getCalcers( mparents ), w ) );
|
||
15 years ago
|
|
||
|
w.updateCurPix();
|
||
14 years ago
|
KigPainter pter( w.screenInfo(), TQT_TQPAINTDEVICE(&w.curPix), mdoc.document() );
|
||
15 years ago
|
|
||
|
Coordinate ncoord = w.fromScreen( p );
|
||
|
if ( shiftpressed )
|
||
|
ncoord = mdoc.document().coordinateSystem().snapToGrid( ncoord, w );
|
||
|
|
||
|
redefinePoint( mpt.get(), ncoord, mdoc.document(), w );
|
||
|
mcursor->move( ncoord, mdoc.document() );
|
||
|
mcursor->calc( mdoc.document() );
|
||
|
|
||
14 years ago
|
std::vector<ObjectCalcer*> args = getCalcers( mparents );
|
||
15 years ago
|
bool duplicationchecked = false;
|
||
|
std::vector<ObjectHolder*> goodargs;
|
||
|
if ( ! os.empty() )
|
||
|
{
|
||
|
std::vector<ObjectHolder*>::const_iterator it;
|
||
14 years ago
|
std::vector<ObjectCalcer*> testargs = getCalcers( mparents );
|
||
15 years ago
|
for ( std::vector<ObjectHolder*>::const_iterator i = os.begin(); i != os.end(); ++i )
|
||
|
{
|
||
14 years ago
|
it = std::find( mparents.begin(), mparents.end(), *i );
|
||
15 years ago
|
bool newdup =
|
||
14 years ago
|
( it == mparents.end() ) ||
|
||
|
isAlreadySelectedOK( args, it - mparents.begin() );
|
||
15 years ago
|
if ( newdup )
|
||
|
{
|
||
|
testargs.push_back( ( *i )->calcer() );
|
||
|
if ( wantArgs( testargs, mdoc.document(), w ) )
|
||
|
goodargs.push_back( *i );
|
||
|
testargs.pop_back();
|
||
|
}
|
||
|
duplicationchecked |= newdup;
|
||
|
}
|
||
|
}
|
||
|
bool calcnow = ( goodargs.size() == 1 ) || ( ( goodargs.size() > 0 ) && ( goodargs.front()->imp()->inherits( PointImp::stype() ) ) );
|
||
|
if ( calcnow )
|
||
|
{
|
||
|
args.push_back( goodargs.front()->calcer() );
|
||
|
}
|
||
|
|
||
|
if ( !os.empty() && duplicationchecked && calcnow )
|
||
|
{
|
||
|
handlePrelim( args, p, pter, w );
|
||
|
|
||
|
w.setCursor( KCursor::handCursor() );
|
||
|
}
|
||
|
else
|
||
|
{
|
||
14 years ago
|
std::vector<ObjectCalcer*> args = getCalcers( mparents );
|
||
15 years ago
|
args.push_back( mpt.get() );
|
||
14 years ago
|
std::vector<ObjectCalcer*> argscursor = getCalcers( mparents );
|
||
15 years ago
|
argscursor.push_back( mcursor );
|
||
|
bool text = true;
|
||
|
if ( wantArgs( args, mdoc.document(), w ) )
|
||
|
{
|
||
|
ObjectDrawer d;
|
||
|
d.draw( *mpt->imp(), pter, true );
|
||
|
|
||
|
handlePrelim( args, p, pter, w );
|
||
|
|
||
|
w.setCursor( KCursor::handCursor() );
|
||
|
}
|
||
|
else if ( wantArgs( argscursor, mdoc.document(), w ) )
|
||
|
{
|
||
|
ObjectDrawer d;
|
||
|
// d.draw( *mcursor->imp(), pter, true );
|
||
|
|
||
|
handlePrelim( argscursor, p, pter, w );
|
||
|
|
||
|
w.setCursor( KCursor::crossCursor() );
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
w.setCursor( KCursor::arrowCursor() );
|
||
|
text = false;
|
||
|
}
|
||
|
if ( !text && ( goodargs.size() > 1 ) )
|
||
|
{
|
||
15 years ago
|
TQString strwhich = i18n( "Which object?" );
|
||
15 years ago
|
mdoc.emitStatusBarText( strwhich );
|
||
|
|
||
15 years ago
|
TQPoint textloc = p;
|
||
15 years ago
|
textloc.setX( textloc.x() + 15 );
|
||
|
pter.drawTextStd( textloc, strwhich );
|
||
|
|
||
|
w.setCursor( KCursor::handCursor() );
|
||
|
}
|
||
|
}
|
||
|
w.updateWidget( pter.overlay() );
|
||
|
}
|
||
|
|
||
|
void BaseConstructMode::selectObject( ObjectHolder* o, KigWidget& w )
|
||
|
{
|
||
14 years ago
|
mparents.push_back( o );
|
||
|
std::vector<ObjectCalcer*> args = getCalcers( mparents );
|
||
15 years ago
|
|
||
|
if ( wantArgs( args, mdoc.document(), w ) == ArgsParser::Complete )
|
||
|
{
|
||
|
handleArgs( args, w );
|
||
|
};
|
||
|
|
||
14 years ago
|
w.redrawScreen( mparents );
|
||
15 years ago
|
}
|
||
|
|
||
|
PointConstructMode::PointConstructMode( KigPart& d )
|
||
|
: BaseMode( d )
|
||
|
{
|
||
|
// we add the data objects to the document cause
|
||
|
// ObjectFactory::redefinePoint does that too, and this way, we can
|
||
|
// depend on them already being known by the doc when we add the
|
||
|
// mpt..
|
||
|
mpt = ObjectFactory::instance()->fixedPointCalcer( Coordinate() );
|
||
|
mpt->calc( d.document() );
|
||
|
|
||
|
mdoc.emitStatusBarText( i18n( "Click the location where you want to place the new point, or the curve that you want to attach it to..." ) );
|
||
|
}
|
||
|
|
||
|
PointConstructMode::~PointConstructMode()
|
||
|
{
|
||
|
}
|
||
|
|
||
|
void PointConstructMode::leftClickedObject(
|
||
15 years ago
|
ObjectHolder*, const TQPoint&, KigWidget& w, bool )
|
||
15 years ago
|
{
|
||
|
mdoc.addObject( new ObjectHolder( mpt.get() ) );
|
||
|
w.redrawScreen( std::vector<ObjectHolder*>() );
|
||
|
|
||
14 years ago
|
mdoc.emitStatusBarText( TQString() );
|
||
15 years ago
|
mdoc.doneMode( this );
|
||
|
}
|
||
|
|
||
15 years ago
|
void PointConstructMode::midClicked( const TQPoint& p, KigWidget& w )
|
||
15 years ago
|
{
|
||
|
leftClickedObject( 0, p, w, true );
|
||
|
}
|
||
|
|
||
15 years ago
|
void PointConstructMode::rightClicked( const std::vector<ObjectHolder*>&, const TQPoint&,
|
||
15 years ago
|
KigWidget& )
|
||
|
{
|
||
|
// TODO ?
|
||
|
}
|
||
|
|
||
|
void PointConstructMode::mouseMoved(
|
||
|
const std::vector<ObjectHolder*>&,
|
||
15 years ago
|
const TQPoint& p,
|
||
15 years ago
|
KigWidget& w,
|
||
|
bool shiftpressed )
|
||
|
{
|
||
|
w.updateCurPix();
|
||
14 years ago
|
KigPainter pter( w.screenInfo(), TQT_TQPAINTDEVICE(&w.curPix), mdoc.document() );
|
||
15 years ago
|
|
||
|
Coordinate ncoord = w.fromScreen( p );
|
||
|
if ( shiftpressed )
|
||
|
ncoord = mdoc.document().coordinateSystem().snapToGrid( ncoord, w );
|
||
|
|
||
|
redefinePoint( mpt.get(), ncoord, mdoc.document(), w );
|
||
|
|
||
|
ObjectDrawer d;
|
||
|
d.draw( *mpt->imp(), pter, true );
|
||
|
w.setCursor( KCursor::blankCursor() );
|
||
|
|
||
|
w.updateWidget( pter.overlay() );
|
||
|
}
|
||
|
|
||
|
void BaseConstructMode::enableActions()
|
||
|
{
|
||
|
BaseMode::enableActions();
|
||
|
|
||
|
mdoc.aCancelConstruction->setEnabled( true );
|
||
|
}
|
||
|
|
||
|
void BaseConstructMode::cancelConstruction()
|
||
|
{
|
||
|
finish();
|
||
|
}
|
||
|
|
||
|
void PointConstructMode::enableActions()
|
||
|
{
|
||
|
BaseMode::enableActions();
|
||
|
|
||
|
mdoc.aCancelConstruction->setEnabled( true );
|
||
|
}
|
||
|
|
||
|
void PointConstructMode::cancelConstruction()
|
||
|
{
|
||
|
mdoc.doneMode( this );
|
||
|
}
|
||
|
|
||
|
void BaseConstructMode::selectObjects( const std::vector<ObjectHolder*>& os, KigWidget& w )
|
||
|
{
|
||
|
for ( std::vector<ObjectHolder*>::const_iterator i = os.begin(); i != os.end(); ++i )
|
||
|
{
|
||
14 years ago
|
std::vector<ObjectCalcer*> args = getCalcers( mparents );
|
||
15 years ago
|
assert( wantArgs( args, mdoc.document(), w ) != ArgsParser::Complete );
|
||
|
selectObject( *i, w );
|
||
|
};
|
||
|
}
|
||
|
|
||
15 years ago
|
void ConstructMode::handlePrelim( const std::vector<ObjectCalcer*>& args, const TQPoint& p, KigPainter& pter, KigWidget& w )
|
||
15 years ago
|
{
|
||
4 years ago
|
// set the text next to the arrow cursor like in modes/normal.cpp
|
||
15 years ago
|
TQPoint textloc = p;
|
||
15 years ago
|
textloc.setX( textloc.x() + 15 );
|
||
|
|
||
|
mctor->handlePrelim( pter, args, mdoc.document(), w );
|
||
|
|
||
15 years ago
|
TQString o = mctor->useText( *args.back(), args, mdoc.document(), w );
|
||
15 years ago
|
pter.drawTextStd( textloc, o );
|
||
|
}
|
||
|
|
||
|
int ConstructMode::isAlreadySelectedOK( const std::vector<ObjectCalcer*>& os,
|
||
|
const int& pos )
|
||
|
{
|
||
|
return mctor->isAlreadySelectedOK( os, pos );
|
||
|
}
|
||
|
|
||
|
int ConstructMode::wantArgs( const std::vector<ObjectCalcer*>& os, KigDocument& d, KigWidget& w )
|
||
|
{
|
||
|
return mctor->wantArgs( os, d, w );
|
||
|
}
|
||
|
|
||
|
void BaseConstructMode::finish()
|
||
|
{
|
||
|
mdoc.doneMode( this );
|
||
|
}
|
||
|
|
||
|
ConstructMode::ConstructMode( KigPart& d, const ObjectConstructor* ctor )
|
||
|
: BaseConstructMode( d ), mctor( ctor )
|
||
|
{
|
||
|
}
|
||
|
|
||
|
ConstructMode::~ConstructMode()
|
||
|
{
|
||
|
}
|
||
|
|
||
|
// does a test result have a frame by default ?
|
||
|
static const bool test_has_frame_dflt = true;
|
||
|
|
||
15 years ago
|
void TestConstructMode::handlePrelim( const std::vector<ObjectCalcer*>& os, const TQPoint& p, KigPainter& pter, KigWidget& w )
|
||
15 years ago
|
{
|
||
|
Args args;
|
||
|
std::transform( os.begin(), os.end(), std::back_inserter( args ),
|
||
|
std::mem_fun( &ObjectCalcer::imp ) );
|
||
|
|
||
|
// usetext
|
||
15 years ago
|
TQString usetext = i18n( mtype->argsParser().usetext( args.back(), args ).c_str() );
|
||
|
TQPoint textloc = p;
|
||
15 years ago
|
textloc.setX( textloc.x() + 15 );
|
||
|
pter.drawTextStd( textloc, usetext );
|
||
|
|
||
|
// test result
|
||
|
ObjectImp* data = mtype->calc( args, mdoc.document() );
|
||
|
if ( ! data->valid() ) return;
|
||
|
assert( data->inherits( TestResultImp::stype() ) );
|
||
15 years ago
|
TQString outputtext = static_cast<TestResultImp*>( data )->data();
|
||
|
TextImp ti( outputtext, w.fromScreen( p + TQPoint( - 40, 30 ) ), test_has_frame_dflt );
|
||
15 years ago
|
ti.draw( pter );
|
||
|
|
||
|
delete data;
|
||
|
}
|
||
|
|
||
|
TestConstructMode::TestConstructMode( KigPart& d, const ArgsParserObjectType* type )
|
||
|
: BaseConstructMode( d ), mtype( type )
|
||
|
{
|
||
|
}
|
||
|
|
||
|
TestConstructMode::~TestConstructMode()
|
||
|
{
|
||
|
}
|
||
|
|
||
|
void ConstructMode::handleArgs( const std::vector<ObjectCalcer*>& args, KigWidget& w )
|
||
|
{
|
||
|
mctor->handleArgs( args, mdoc, w );
|
||
|
finish();
|
||
|
}
|
||
|
|
||
|
int TestConstructMode::isAlreadySelectedOK( const std::vector<ObjectCalcer*>&,
|
||
|
const int& )
|
||
|
{
|
||
|
return false;
|
||
|
}
|
||
|
|
||
|
int TestConstructMode::wantArgs( const std::vector<ObjectCalcer*>& os, KigDocument&, KigWidget& )
|
||
|
{
|
||
|
return mtype->argsParser().check( os );
|
||
|
}
|
||
|
|
||
|
void TestConstructMode::handleArgs( const std::vector<ObjectCalcer*>& args, KigWidget& )
|
||
|
{
|
||
|
mresult = new ObjectTypeCalcer( mtype, args );
|
||
|
mresult->calc( mdoc.document() );
|
||
|
mdoc.emitStatusBarText( i18n( "Now select the location for the result label." ) );
|
||
|
}
|
||
|
|
||
15 years ago
|
void TestConstructMode::leftClickedObject( ObjectHolder* o, const TQPoint& p,
|
||
15 years ago
|
KigWidget& w, bool ctrlOrShiftDown )
|
||
|
{
|
||
|
if ( mresult ) {
|
||
15 years ago
|
TQPoint qloc = p + TQPoint( -40, 0 );
|
||
15 years ago
|
Coordinate loc = w.fromScreen( qloc );
|
||
|
|
||
14 years ago
|
std::vector<ObjectCalcer*> parents;
|
||
|
parents.push_back( new ObjectConstCalcer( new IntImp( test_has_frame_dflt ) ) );
|
||
|
parents.push_back( new ObjectConstCalcer( new PointImp( loc ) ) );
|
||
13 years ago
|
parents.push_back( new ObjectConstCalcer( new StringImp( TQString::fromLatin1( "%1" ) ) ) );
|
||
15 years ago
|
assert( mresult->imp()->inherits( TestResultImp::stype() ) );
|
||
14 years ago
|
parents.push_back(
|
||
15 years ago
|
new ObjectPropertyCalcer(
|
||
14 years ago
|
mresult.get(), mresult->imp()->propertiesInternalNames().findIndex( "test-result" ) ) );
|
||
14 years ago
|
parents.back()->calc( mdoc.document() );
|
||
15 years ago
|
|
||
14 years ago
|
ObjectCalcer* ret = new ObjectTypeCalcer( TextType::instance(), parents );
|
||
15 years ago
|
ret->calc( mdoc.document() );
|
||
|
mdoc.addObject( new ObjectHolder( ret ) );
|
||
|
|
||
|
w.unsetCursor();
|
||
14 years ago
|
mdoc.emitStatusBarText( TQString() );
|
||
15 years ago
|
|
||
|
finish();
|
||
|
}
|
||
|
else
|
||
|
BaseConstructMode::leftClickedObject( o, p, w, ctrlOrShiftDown );
|
||
|
}
|
||
|
|
||
15 years ago
|
void TestConstructMode::midClicked( const TQPoint& p, KigWidget& w )
|
||
15 years ago
|
{
|
||
|
if ( mresult ) {
|
||
|
// nothing to be done here, really
|
||
|
}
|
||
|
else
|
||
|
BaseConstructMode::midClicked( p, w );
|
||
|
}
|
||
|
|
||
15 years ago
|
void TestConstructMode::rightClicked( const std::vector<ObjectHolder*>& oco, const TQPoint& p, KigWidget& w )
|
||
15 years ago
|
{
|
||
|
if ( mresult ) {
|
||
|
// nothing to be done here, really
|
||
|
}
|
||
|
else
|
||
|
BaseConstructMode::rightClicked( oco, p, w );
|
||
|
}
|
||
|
|
||
15 years ago
|
void TestConstructMode::mouseMoved( const std::vector<ObjectHolder*>& os, const TQPoint& p, KigWidget& w, bool shiftPressed )
|
||
15 years ago
|
{
|
||
|
if ( mresult ) {
|
||
|
w.setCursor( KCursor::blankCursor() );
|
||
|
|
||
|
w.updateCurPix();
|
||
14 years ago
|
KigPainter pter( w.screenInfo(), TQT_TQPAINTDEVICE(&w.curPix), mdoc.document() );
|
||
15 years ago
|
|
||
15 years ago
|
TQPoint qloc = p + TQPoint( -40, 0 );
|
||
15 years ago
|
Coordinate loc = w.fromScreen( qloc );
|
||
|
assert( dynamic_cast<const TestResultImp*>( mresult->imp() ) );
|
||
|
TextImp ti( static_cast<const TestResultImp*>( mresult->imp() )->data(), loc, test_has_frame_dflt );
|
||
|
ObjectDrawer d;
|
||
|
d.draw( ti, pter, false );
|
||
|
|
||
|
|
||
|
w.updateWidget( pter.overlay() );
|
||
|
}
|
||
|
else
|
||
|
BaseConstructMode::mouseMoved( os, p, w, shiftPressed );
|
||
|
}
|
||
|
|
||
15 years ago
|
TQString ConstructMode::selectStatement( const std::vector<ObjectCalcer*>& args, const KigWidget& w )
|
||
15 years ago
|
{
|
||
|
return mctor->selectStatement( args, mdoc.document(), w );
|
||
|
}
|
||
|
|
||
15 years ago
|
TQString TestConstructMode::selectStatement( const std::vector<ObjectCalcer*>& sel, const KigWidget& )
|
||
15 years ago
|
{
|
||
|
using namespace std;
|
||
|
Args args;
|
||
|
transform( sel.begin(), sel.end(), back_inserter( args ), mem_fun( &ObjectCalcer::imp ) );
|
||
|
|
||
|
std::string ret = mtype->argsParser().selectStatement( args );
|
||
14 years ago
|
if ( ret.empty() ) return TQString();
|
||
15 years ago
|
return i18n( ret.c_str() );
|
||
|
}
|
||
|
|
||
|
void PointConstructMode::redrawScreen( KigWidget* w )
|
||
|
{
|
||
|
w->redrawScreen( std::vector<ObjectHolder*>() );
|
||
|
}
|
||
|
|
||
|
void BaseConstructMode::redrawScreen( KigWidget* w )
|
||
|
{
|
||
|
w->redrawScreen( std::vector<ObjectHolder*>() );
|
||
|
}
|