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

kig

  • sources
  • kde-4.12
  • kdeedu
  • kig
  • modes
dragrectmode.cc
Go to the documentation of this file.
1 // Copyright (C) 2002 Dominique Devriese <devriese@kde.org>
2 
3 // This program is free software; you can redistribute it and/or
4 // modify it under the terms of the GNU General Public License
5 // as published by the Free Software Foundation; either version 2
6 // of the License, or (at your option) any later version.
7 
8 // This program is distributed in the hope that it will be useful,
9 // but WITHOUT ANY WARRANTY; without even the implied warranty of
10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 // GNU General Public License for more details.
12 
13 // You should have received a copy of the GNU General Public License
14 // along with this program; if not, write to the Free Software
15 // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
16 // 02110-1301, USA.
17 
18 #include "dragrectmode.h"
19 
20 #include "../kig/kig_document.h"
21 #include "../kig/kig_part.h"
22 #include "../kig/kig_view.h"
23 #include "../misc/kigpainter.h"
24 
25 #include <qevent.h>
26 #include <qglobal.h>
27 #include <kaction.h>
28 
29 DragRectMode::DragRectMode( const QPoint& start, KigPart& d, KigWidget& w )
30  : KigMode( d ), mstart( start ), mnc( true ), mstartselected( true ),
31  mcancelled( false )
32 {
33  moved( start, w );
34 }
35 
36 DragRectMode::DragRectMode( KigPart& d, KigWidget& w )
37  : KigMode( d ), mnc( true ), mstartselected( false ),
38  mcancelled( false )
39 {
40  w.updateCurPix();
41  w.updateWidget();
42 }
43 
44 void DragRectMode::moved( const QPoint& p, KigWidget& w )
45 {
46  // update the rect...
47  w.updateCurPix();
48  std::vector<QRect> overlay;
49  if ( mstartselected )
50  {
51  KigPainter pt( w.screenInfo(), &w.curPix, mdoc.document() );
52  pt.drawFilledRect( QRect( p, mstart ) );
53  overlay = pt.overlay();
54  };
55  w.updateWidget( overlay );
56 }
57 
58 void DragRectMode::released( const QPoint& p, KigWidget& w, bool nc )
59 {
60  if ( mstartselected )
61  {
62  mrect = w.fromScreen( QRect( mstart, p ) );
63  mret = mdoc.document().whatIsInHere( mrect, w );
64  mnc = nc;
65 
66  mdoc.doneMode( this );
67  };
68 }
69 
70 void DragRectMode::enableActions()
71 {
72  KigMode::enableActions();
73 
74  mdoc.aCancelConstruction->setEnabled( true );
75 }
76 
77 std::vector<ObjectHolder*> DragRectMode::ret() const
78 {
79  return mret;
80 }
81 
82 bool DragRectMode::needClear() const
83 {
84  return mnc;
85 }
86 
87 void DragRectMode::moved( QMouseEvent* e, KigWidget& w )
88 {
89  moved( e->pos(), w );
90 }
91 
92 void DragRectMode::released( QMouseEvent* e, KigWidget& w )
93 {
94  released( e->pos(), w, ! ( e->modifiers() & ( Qt::ControlModifier | Qt::ShiftModifier ) ) );
95 }
96 
97 DragRectMode::~DragRectMode()
98 {
99 }
100 
101 void DragRectMode::mouseMoved( QMouseEvent* e, KigWidget* w )
102 {
103  moved( e, *w );
104 }
105 
106 void DragRectMode::leftMouseMoved( QMouseEvent* e, KigWidget* w )
107 {
108  moved( e, *w );
109 }
110 
111 void DragRectMode::midMouseMoved( QMouseEvent* e, KigWidget* w )
112 {
113  moved( e, *w );
114 }
115 
116 void DragRectMode::rightMouseMoved( QMouseEvent* e, KigWidget* w )
117 {
118  moved( e, *w );
119 }
120 
121 void DragRectMode::leftReleased( QMouseEvent* e, KigWidget* w )
122 {
123  released( e, *w );
124 }
125 
126 void DragRectMode::midReleased( QMouseEvent* e, KigWidget* w )
127 {
128  released( e, *w );
129 }
130 
131 void DragRectMode::rightReleased( QMouseEvent* e, KigWidget* w )
132 {
133  released( e, *w );
134 }
135 
136 Rect DragRectMode::rect() const
137 {
138  return mrect;
139 }
140 
141 void DragRectMode::clicked( const QMouseEvent* e, KigWidget& w )
142 {
143  clicked( e->pos(), w );
144 }
145 
146 void DragRectMode::leftClicked( QMouseEvent* e, KigWidget* w )
147 {
148  clicked( e, *w );
149 }
150 
151 void DragRectMode::midClicked( QMouseEvent* e, KigWidget* w )
152 {
153  clicked( e, *w );
154 }
155 
156 void DragRectMode::rightClicked( QMouseEvent* e, KigWidget* w )
157 {
158  clicked( e, *w );
159 }
160 
161 void DragRectMode::clicked( const QPoint& p, KigWidget& )
162 {
163  if ( !mstartselected )
164  {
165  mstartselected = true;
166  mstart = p;
167  };
168 }
169 
170 bool DragRectMode::cancelled() const
171 {
172  return mcancelled;
173 }
174 
175 void DragRectMode::cancelConstruction()
176 {
177  mcancelled = true;
178  mdoc.doneMode( this );
179 }
180 
KigDocument::whatIsInHere
std::vector< ObjectHolder * > whatIsInHere(const Rect &p, const KigWidget &)
Return a vector of objects that are in the given Rect.
Definition: kig_document.cc:91
DragRectMode::needClear
bool needClear() const
this returns false if the control or shift button were pressed when the mouse button was released...
Definition: dragrectmode.cc:82
Rect
This file is part of Kig, a KDE program for Interactive Geometry...
Definition: rect.h:34
KigPart::document
const KigDocument & document() const
Definition: kig_part.cpp:989
DragRectMode::cancelled
bool cancelled() const
whether the user cancelled the rect mode.
Definition: dragrectmode.cc:170
KigMode::enableActions
virtual void enableActions()
actions: we enable the actions we want when our mode is made active.
Definition: mode.cc:27
dragrectmode.h
KigMode::mdoc
KigPart & mdoc
Definition: mode.h:94
DragRectMode::ret
std::vector< ObjectHolder * > ret() const
this returns the selected objects.
Definition: dragrectmode.cc:77
KigMode
this is an ABC of a class containing the current "Mode" of the Kig document...
Definition: mode.h:37
DragRectMode::rect
Rect rect() const
this returns the selected rect.
Definition: dragrectmode.cc:136
KigWidget::screenInfo
const ScreenInfo & screenInfo() const
the part of the document we're currently showing i.e.
Definition: kig_view.cpp:272
DragRectMode::~DragRectMode
~DragRectMode()
Definition: dragrectmode.cc:97
KigPainter::drawFilledRect
void drawFilledRect(const QRect &)
draws a rect filled up with a pattern of cyan lines...
Definition: kigpainter.cpp:523
KigPainter
KigPainter is an extended QPainter.
Definition: kigpainter.h:51
DragRectMode::DragRectMode
DragRectMode(const QPoint &start, KigPart &d, KigWidget &w)
Definition: dragrectmode.cc:29
KigWidget::fromScreen
const Coordinate fromScreen(const QPoint &p)
Definition: kig_view.cpp:282
KigWidget
This class is the real widget showing the document.
Definition: kig_view.h:50
KigPart::doneMode
void doneMode(KigMode *)
Definition: kig_part.cpp:749
KigWidget::updateCurPix
void updateCurPix(const std::vector< QRect > &=std::vector< QRect >())
update curPix (bitBlt stillPix onto curPix..)
Definition: kig_view.cpp:187
KigWidget::curPix
QPixmap curPix
temporary, gets bitBlt'd (copied) onto the widget (to avoid flickering)
Definition: kig_view.h:84
KigWidget::updateWidget
void updateWidget(const std::vector< QRect > &=std::vector< QRect >())
this means bitBlting curPix on the actual widget...
Definition: kig_view.cpp:115
KigPart
This is a "Part".
Definition: kig_part.h:68
KigPart::aCancelConstruction
KAction * aCancelConstruction
Definition: kig_part.h:236
This file is part of the KDE documentation.
Documentation copyright © 1996-2014 The KDE developers.
Generated on Tue Oct 14 2014 22:35:39 by doxygen 1.8.7 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

kig

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

kdeedu API Reference

Skip menu "kdeedu API Reference"
  • Analitza
  •     lib
  • kalgebra
  • kalzium
  •   libscience
  • kanagram
  • kig
  •   lib
  • klettres
  • kstars
  • libkdeedu
  •   keduvocdocument
  • marble
  • parley
  • rocs
  •   App
  •   RocsCore
  •   VisualEditor
  •   stepcore

Search



Report problems with this website to our bug tracking system.
Contact the specific authors with questions and comments about the page contents.

KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal