• Skip to content
  • Skip to link menu
KDE 4.2 API Reference
  • KDE API Reference
  • kdeedu
  • Sitemap
  • Contact Us
 

kig

base_mode.cc

Go to the documentation of this file.
00001 // Copyright (C)  2002  Dominique Devriese <devriese@kde.org>
00002 
00003 // This program is free software; you can redistribute it and/or
00004 // modify it under the terms of the GNU General Public License
00005 // as published by the Free Software Foundation; either version 2
00006 // of the License, or (at your option) any later version.
00007 
00008 // This program is distributed in the hope that it will be useful,
00009 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00010 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00011 // GNU General Public License for more details.
00012 
00013 // You should have received a copy of the GNU General Public License
00014 // along with this program; if not, write to the Free Software
00015 // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
00016 // 02110-1301, USA.
00017 
00018 #include "base_mode.h"
00019 
00020 #include "popup.h"
00021 
00022 #include "../kig/kig_view.h"
00023 #include "../kig/kig_part.h"
00024 #include "../kig/kig_document.h"
00025 
00026 #include <qevent.h>
00027 #include <kcursor.h>
00028 
00029 BaseMode::BaseMode( KigPart& d )
00030   : KigMode( d )
00031 {
00032 }
00033 
00034 BaseMode::~BaseMode()
00035 {
00036 }
00037 
00038 void BaseMode::leftClicked( QMouseEvent* e, KigWidget* v )
00039 {
00040   // touch screens don't send a mouseMoved event before a click event,
00041   // apparently, so we simulate it.
00042   mouseMoved( e, v );
00043 
00044   // get rid of text still showing...
00045   v->updateCurPix();
00046   v->updateWidget();
00047 
00048   mplc = e->pos();
00049   moco = mdoc.document().whatAmIOn( v->fromScreen( mplc ), *v );
00050 
00051   if( moco.empty() )
00052   {
00053     // clicked on an empty spot --> we show the rectangle for
00054     // selecting stuff...
00055     dragRect( mplc, *v );
00056   }
00057   else
00058   {
00059     // the user clicked on some object.. --> this could either mean
00060     // that he/she wants to select the object or that he wants to
00061     // start moving it.  We assume nothing here, we wait till he
00062     // either moves some 4 pixels, or till he releases his mouse
00063     // button in leftReleased() or mouseMoved()...
00064   };
00065 }
00066 
00067 void BaseMode::leftMouseMoved( QMouseEvent* e, KigWidget* w )
00068 {
00069   if( !moco.empty() && ( mplc - e->pos() ).manhattanLength() > 3 )
00070     dragObject( moco, mplc, *w,
00071                 ( e->modifiers() & (Qt::ShiftModifier | Qt::ControlModifier ) ) != 0
00072       );
00073 }
00074 
00075 void BaseMode::leftReleased( QMouseEvent* e, KigWidget* v )
00076 {
00077   if( (mplc - e->pos()).manhattanLength() > 4 ) return;
00078 
00079   ObjectHolder* o = 0;
00080   bool keyCtrl = ( e->modifiers() & Qt::ControlModifier ) != 0;
00081   bool keyShift = ( e->modifiers() & Qt::ShiftModifier ) != 0;
00082   if ( ! moco.empty() )
00083   {
00084     if ( keyShift )
00085     {
00086       int id = ObjectChooserPopup::getObjectFromList( e->pos(), v, moco );
00087       if ( id >= 0 )
00088         o = moco[id];
00089     }
00090     else
00091       o = moco.front();
00092   }
00093   leftClickedObject( o, e->pos(), *v, keyCtrl );
00094 }
00095 
00096 void BaseMode::midClicked( QMouseEvent* e, KigWidget* v )
00097 {
00098   // get rid of text still showing...
00099   v->updateCurPix();
00100   v->updateWidget();
00101 
00102   mplc = e->pos();
00103   moco = mdoc.document().whatAmIOn( v->fromScreen( e->pos() ), *v );
00104 }
00105 
00106 void BaseMode::midReleased( QMouseEvent* e, KigWidget* v )
00107 {
00108   if( (e->pos() - mplc).manhattanLength() > 4 ) return;
00109 
00110   midClicked( mplc, *v );
00111 }
00112 
00113 void BaseMode::rightClicked( QMouseEvent* e, KigWidget* w )
00114 {
00115   // get rid of text still showing...
00116   w->updateCurPix();
00117   w->updateWidget();
00118   // set a normal cursor...
00119   w->setCursor( Qt::ArrowCursor );
00120 
00121   mplc = e->pos();
00122   moco = mdoc.document().whatAmIOn( w->fromScreen( mplc ), *w );
00123 
00124   rightClicked( moco, mplc, *w );
00125 }
00126 
00127 void BaseMode::mouseMoved( QMouseEvent* e, KigWidget* w )
00128 {
00129   std::vector<ObjectHolder*> os = mdoc.document().whatAmIOn( w->fromScreen( e->pos() ), *w );
00130   mouseMoved( os, e->pos(), *w, e->modifiers() & Qt::ShiftModifier );
00131 }
00132 
00133 void BaseMode::dragRect( const QPoint&, KigWidget& )
00134 {
00135 }
00136 
00137 void BaseMode::leftClickedObject( ObjectHolder*, const QPoint&,
00138                                   KigWidget&, bool )
00139 {
00140 }
00141 
00142 void BaseMode::dragObject( const std::vector<ObjectHolder*>&, const QPoint&,
00143                            KigWidget&, bool )
00144 {
00145 }
00146 
00147 void BaseMode::enableActions()
00148 {
00149   KigMode::enableActions();
00150 }
00151 
00152 std::vector<ObjectHolder*> BaseMode::oco()
00153 {
00154   return moco;
00155 }
00156 
00157 QPoint BaseMode::pointLocation()
00158 {
00159   return mplc;
00160 }

kig

Skip menu "kig"
  • Main Page
  • Namespace List
  • Class Hierarchy
  • Alphabetical List
  • Class List
  • File List
  • Namespace Members
  • Class Members

kdeedu

Skip menu "kdeedu"
  • kalzium
  • kanagram
  • kig
  •   lib
  • klettres
  • kstars
  • libkdeedu
  •   keduvocdocument
  •   docs
  •   src
  • parley
  •   stepcore
Generated for kdeedu by doxygen 1.5.4
This website is maintained by Adriaan de Groot and Allen Winter.
KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal