• 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
  • objects
object_holder.cc
Go to the documentation of this file.
1 // Copyright (C) 2003 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 "object_holder.h"
19 
20 #include "bogus_imp.h"
21 #include "object_calcer.h"
22 #include "object_drawer.h"
23 
24 #include "../misc/coordinate.h"
25 
26 ObjectHolder::ObjectHolder( ObjectCalcer* calcer )
27  : mcalcer( calcer ), mdrawer( new ObjectDrawer ), mnamecalcer( 0 )
28 {
29 }
30 
31 ObjectHolder::ObjectHolder( ObjectCalcer* calcer, ObjectDrawer* drawer,
32  ObjectConstCalcer* namecalcer )
33  : mcalcer( calcer ), mdrawer( drawer ), mnamecalcer( namecalcer )
34 {
35  assert( !namecalcer || namecalcer->imp()->inherits( StringImp::stype() ) );
36 }
37 
38 ObjectHolder::ObjectHolder( ObjectCalcer* calcer, ObjectDrawer* drawer )
39  : mcalcer( calcer ), mdrawer( drawer ), mnamecalcer( 0 )
40 {
41 }
42 
43 ObjectHolder::~ObjectHolder()
44 {
45  delete mdrawer;
46 }
47 
48 const ObjectImp* ObjectHolder::imp() const
49 {
50  return mcalcer->imp();
51 }
52 
53 const ObjectCalcer* ObjectHolder::calcer() const
54 {
55  return mcalcer.get();
56 }
57 
58 const ObjectDrawer* ObjectHolder::drawer() const
59 {
60  return mdrawer;
61 }
62 
63 const ObjectConstCalcer* ObjectHolder::nameCalcer() const
64 {
65  return mnamecalcer.get();
66 }
67 
68 void ObjectHolder::setDrawer( ObjectDrawer* d )
69 {
70  delete switchDrawer( d );
71 }
72 
73 void ObjectHolder::calc( const KigDocument& d )
74 {
75  mcalcer->calc( d );
76 }
77 
78 void ObjectHolder::draw( KigPainter& p, bool selected ) const
79 {
80  mdrawer->draw( *imp(), p, selected );
81 }
82 
83 bool ObjectHolder::contains( const Coordinate& pt, const KigWidget& w, bool nv ) const
84 {
85  return mdrawer->contains( *imp(), pt, w, nv );
86 }
87 
88 bool ObjectHolder::inRect( const Rect& r, const KigWidget& w ) const
89 {
90  return mdrawer->inRect( *imp(), r, w );
91 }
92 
93 ObjectCalcer* ObjectHolder::calcer()
94 {
95  return mcalcer.get();
96 }
97 
98 ObjectDrawer* ObjectHolder::drawer()
99 {
100  return mdrawer;
101 }
102 
103 ObjectConstCalcer* ObjectHolder::nameCalcer()
104 {
105  return mnamecalcer.get();
106 }
107 
108 const Coordinate ObjectHolder::moveReferencePoint() const
109 {
110  return mcalcer->moveReferencePoint();
111 }
112 
113 void ObjectHolder::move( const Coordinate& to, const KigDocument& doc )
114 {
115  mcalcer->move( to, doc );
116 }
117 
118 bool ObjectHolder::canMove() const
119 {
120  return mcalcer->canMove();
121 }
122 
123 bool ObjectHolder::isFreelyTranslatable() const
124 {
125  return mcalcer->isFreelyTranslatable();
126 }
127 
128 ObjectDrawer* ObjectHolder::switchDrawer( ObjectDrawer* d )
129 {
130  ObjectDrawer* tmp = mdrawer;
131  mdrawer = d;
132  return tmp;
133 }
134 
135 bool ObjectHolder::shown( ) const
136 {
137  return mdrawer->shown( );
138 }
139 
140 const QString ObjectHolder::name() const
141 {
142  if ( mnamecalcer )
143  {
144  assert( mnamecalcer->imp()->inherits( StringImp::stype() ) );
145  return static_cast<const StringImp*>( mnamecalcer->imp() )->data();
146  }
147  else
148  return QString();
149 }
150 
151 void ObjectHolder::setNameCalcer( ObjectConstCalcer* namecalcer )
152 {
153  assert( !mnamecalcer );
154  mnamecalcer = namecalcer;
155 }
156 
157 QString ObjectHolder::selectStatement() const
158 {
159  const QString n = name();
160  if ( n.isEmpty() )
161  return i18n( imp()->type()->selectStatement() );
162  else
163  return i18n( imp()->type()->selectNameStatement(), n );
164 }
ObjectCalcer::isFreelyTranslatable
virtual bool isFreelyTranslatable() const
Returns whether this ObjectCalcer can be translated at any position in the coordinate plane...
Definition: object_calcer.cc:265
ObjectImp::inherits
bool inherits(const ObjectImpType *t) const
Returns true if this ObjectImp inherits the ObjectImp type represented by t.
Definition: object_imp.cc:279
ObjectConstCalcer::imp
const ObjectImp * imp() const
Returns the ObjectImp of this ObjectCalcer.
Definition: object_calcer.cc:65
ObjectCalcer::moveReferencePoint
virtual Coordinate moveReferencePoint() const
In order to support simultaneously moving objects that are in different locations, we need for each object a location that it is assumed to be at, at the moment the moving starts.
Definition: object_calcer.cc:270
ObjectHolder::shown
bool shown() const
Returns whether this object is shown.
Definition: object_holder.cc:135
ObjectCalcer::move
virtual void move(const Coordinate &to, const KigDocument &doc)
This is the method that does the real moving work.
Definition: object_calcer.cc:276
ObjectHolder::isFreelyTranslatable
bool isFreelyTranslatable() const
This call is simply forwarded to the ObjectCalcer.
Definition: object_holder.cc:123
StringImp
This ObjectImp is a BogusImp containing only a string value.
Definition: bogus_imp.h:167
object_drawer.h
ObjectConstCalcer
This is an ObjectCalcer that keeps an ObjectImp, and never calculates a new one.
Definition: object_calcer.h:232
ObjectDrawer::shown
bool shown() const
returns whether the object this ObjectDrawer is responsible for will be drawn or not.
Definition: object_drawer.cc:52
Rect
This file is part of Kig, a KDE program for Interactive Geometry...
Definition: rect.h:34
ObjectDrawer::inRect
bool inRect(const ObjectImp &imp, const Rect &r, const KigWidget &w) const
returns whether the object imp is in the rectangle r .
Definition: object_drawer.cc:164
ObjectDrawer::draw
void draw(const ObjectImp &imp, KigPainter &p, bool selected) const
Draw the object imp on kigpainter p .
Definition: object_drawer.cc:29
ObjectHolder::drawer
const ObjectDrawer * drawer() const
Definition: object_holder.cc:58
ObjectHolder::nameCalcer
const ObjectConstCalcer * nameCalcer() const
Definition: object_holder.cc:63
ObjectHolder::name
const QString name() const
returns a null QString if no name is set.
Definition: object_holder.cc:140
Coordinate
The Coordinate class is the basic class representing a 2D location by its x and y components...
Definition: coordinate.h:33
ObjectHolder::calc
void calc(const KigDocument &)
Make our ObjectCalcer recalculate its ObjectImp.
Definition: object_holder.cc:73
ObjectHolder::~ObjectHolder
~ObjectHolder()
Definition: object_holder.cc:43
ObjectImp::type
virtual const ObjectImpType * type() const =0
Returns the lowermost ObjectImpType that this object is an instantiation of.
ObjectHolder::setDrawer
void setDrawer(ObjectDrawer *d)
Set the ObjectDrawer of this ObjectHolder to d , the old ObjectDrawer is deleted. ...
Definition: object_holder.cc:68
KigPainter
KigPainter is an extended QPainter.
Definition: kigpainter.h:51
bogus_imp.h
ObjectImpType::selectStatement
const char * selectStatement() const
Returns a translatable string of the form "Select this %1".
Definition: object_imp.cc:245
ObjectCalcer
An ObjectCalcer is an object that represents an algorithm for calculating an ObjectImp from other Obj...
Definition: object_calcer.h:66
ObjectHolder::canMove
bool canMove() const
This call is simply forwarded to the ObjectCalcer.
Definition: object_holder.cc:118
ObjectCalcer::calc
virtual void calc(const KigDocument &)=0
Makes the ObjectCalcer recalculate its ObjectImp from its parents.
KigWidget
This class is the real widget showing the document.
Definition: kig_view.h:50
ObjectDrawer::contains
bool contains(const ObjectImp &imp, const Coordinate &pt, const KigWidget &w, bool nv=false) const
returns whether the object imp contains coordinate p .
Definition: object_drawer.cc:46
ObjectHolder::setNameCalcer
void setNameCalcer(ObjectConstCalcer *namecalcer)
Setting the namecalcer is only allowed if previously none was set.
Definition: object_holder.cc:151
object_calcer.h
ObjectHolder::imp
const ObjectImp * imp() const
Definition: object_holder.cc:48
ObjectHolder::calcer
const ObjectCalcer * calcer() const
Definition: object_holder.cc:53
ObjectHolder::selectStatement
QString selectStatement() const
Return a statement saying something like "select this segment" or "select segment ab" depending on wh...
Definition: object_holder.cc:157
ObjectHolder::contains
bool contains(const Coordinate &p, const KigWidget &w, bool nv=false) const
Returns whether this object contains the point p .
Definition: object_holder.cc:83
ObjectDrawer
A class holding some information about how a certain object is drawn on the window.
Definition: object_drawer.h:47
ObjectHolder::draw
void draw(KigPainter &p, bool selected) const
Draw this object on the given KigPainter.
Definition: object_holder.cc:78
ObjectHolder::moveReferencePoint
const Coordinate moveReferencePoint() const
This call is simply forwarded to the ObjectCalcer.
Definition: object_holder.cc:108
ObjectHolder::switchDrawer
ObjectDrawer * switchDrawer(ObjectDrawer *d)
Set the ObjectDrawer of this ObjectHolder to d , the old ObjectDrawer is not deleted, but returned.
Definition: object_holder.cc:128
ObjectCalcer::canMove
virtual bool canMove() const
Returns whether this ObjectCalcer supports moving.
Definition: object_calcer.cc:260
KigDocument
KigDocument is the class holding the real data in a Kig document.
Definition: kig_document.h:36
StringImp::stype
static const ObjectImpType * stype()
Returns the ObjectImpType representing the StringImp type.
Definition: bogus_imp.cc:220
ObjectHolder::ObjectHolder
ObjectHolder(ObjectCalcer *calcer, ObjectDrawer *drawer, ObjectConstCalcer *namecalcer)
Construct a new ObjectHolder with a given ObjectCalcer and ObjectDrawer, with a given name calcer...
Definition: object_holder.cc:31
ObjectCalcer::imp
virtual const ObjectImp * imp() const =0
Returns the ObjectImp of this ObjectCalcer.
ObjectImp
The ObjectImp class represents the behaviour of an object after it is calculated. ...
Definition: object_imp.h:226
object_holder.h
ObjectHolder::move
void move(const Coordinate &to, const KigDocument &)
This call is simply forwarded to the ObjectCalcer.
Definition: object_holder.cc:113
myboost::intrusive_ptr::get
T * get() const
Definition: boost_intrusive_pointer.hpp:122
ObjectHolder::inRect
bool inRect(const Rect &r, const KigWidget &w) const
Returns whether this object is in the rectangle r .
Definition: object_holder.cc:88
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