1 // Copyright (C) 2003 Dominique Devriese <devriese@kde.org>
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.
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.
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., 59 Temple Place - Suite 330, Boston, MA
20 #include "bogus_imp.h"
21 #include "../misc/kigpainter.h"
23 TextImp::TextImp( const QString
& text
, const Coordinate
& loc
, bool frame
)
24 : mtext( text
), mloc( loc
), mframe( frame
), mboundrect( Rect::invalidRect() )
28 TextImp
* TextImp::copy() const
30 return new TextImp( mtext
, mloc
);
37 Coordinate
TextImp::attachPoint() const
39 return Coordinate::invalidCoord();
42 ObjectImp
* TextImp::transform( const Transformation
& t
) const
44 Coordinate nloc
= t
.apply( mloc
);
45 return new TextImp( mtext
, nloc
, mframe
);
48 void TextImp::draw( KigPainter
& p
) const
50 mboundrect
= p
.simpleBoundingRect( mloc
, mtext
);
51 p
.drawTextFrame( mboundrect
, mtext
, mframe
);
54 bool TextImp::contains( const Coordinate
& p
, int, const KigWidget
& ) const
56 return mboundrect
.contains( p
);
59 bool TextImp::inRect( const Rect
& r
, int, const KigWidget
& ) const
61 return mboundrect
.intersects( r
);
64 bool TextImp::valid() const
69 const uint
TextImp::numberOfProperties() const
71 return Parent::numberOfProperties() + 1;
74 const QCStringList
TextImp::propertiesInternalNames() const
76 QCStringList ret
= Parent::propertiesInternalNames();
81 const QCStringList
TextImp::properties() const
83 QCStringList ret
= Parent::properties();
84 ret
<< I18N_NOOP( "Text" );
88 const ObjectImpType
* TextImp::impRequirementForProperty( uint which
) const
90 if ( which
< Parent::numberOfProperties() )
91 return Parent::impRequirementForProperty( which
);
92 return TextImp::stype();
95 const char* TextImp::iconForProperty( uint which
) const
97 if ( which
< Parent::numberOfProperties() )
98 return Parent::iconForProperty( which
);
99 else if ( which
== Parent::numberOfProperties() )
100 return "text"; // text
101 else assert( false );
105 ObjectImp
* TextImp::property( uint which
, const KigDocument
& w
) const
107 if ( which
< Parent::numberOfProperties() )
108 return Parent::property( which
, w
);
109 else if ( which
== Parent::numberOfProperties() )
110 return new StringImp( text() );
111 else assert( false );
112 return new InvalidImp
;
115 QString
TextImp::text() const
120 void TextImp::visit( ObjectImpVisitor
* vtor
) const
125 const Coordinate
TextImp::coordinate() const
130 bool TextImp::equals( const ObjectImp
& rhs
) const
132 return rhs
.inherits( TextImp::stype() ) &&
133 static_cast<const TextImp
&>( rhs
).coordinate() == coordinate() &&
134 static_cast<const TextImp
&>( rhs
).text() == text() &&
135 static_cast<const TextImp
&>( rhs
).hasFrame() == hasFrame();
138 bool TextImp::hasFrame() const
143 const ObjectImpType
* TextImp::stype()
145 static const ObjectImpType
t(
146 Parent::stype(), "label",
147 I18N_NOOP( "label" ),
148 I18N_NOOP( "Select this label" ),
149 I18N_NOOP( "Select label %1" ),
150 I18N_NOOP( "Remove a Label" ),
151 I18N_NOOP( "Add a Label" ),
152 I18N_NOOP( "Move a Label" ),
153 I18N_NOOP( "Attach to this label" ),
154 I18N_NOOP( "Show a Label" ),
155 I18N_NOOP( "Hide a Label" )
160 const ObjectImpType
* TextImp::type() const
162 return TextImp::stype();
165 bool TextImp::isPropertyDefinedOnOrThroughThisImp( uint which
) const
167 return Parent::isPropertyDefinedOnOrThroughThisImp( which
);
170 Rect
TextImp::surroundingRect() const