1
/* This file is part of the KDE project
2
Copyright (C) 2001, 2002, 2003 The Karbon Developers
4
This library is free software; you can redistribute it and/or
5
modify it under the terms of the GNU Library General Public
6
License as published by the Free Software Foundation; either
7
version 2 of the License, or (at your option) any later version.
9
This library is distributed in the hope that it will be useful,
10
but WITHOUT ANY WARRANTY; without even the implied warranty of
11
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12
Library General Public License for more details.
14
You should have received a copy of the GNU Library General Public License
15
along with this library; see the file COPYING.LIB. If not, write to
16
the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
17
Boston, MA 02111-1307, USA.
25
#include "vcomposite.h"
26
#include "vdocument.h"
32
#include "vlayer_iface.h"
34
#include "vclipgroup.h"
38
VLayer::VLayer( VObject* parent, VState state )
39
: VGroup( parent, state )
42
// HACK : vlayer just shouldn't have fill/stroke at all
49
VLayer::VLayer( const VLayer& layer )
58
DCOPObject* VLayer::dcopObject()
61
m_dcop = new VLayerIface( this );
67
VLayer::draw( VPainter* painter, const KoRect* rect ) const
72
state() == hidden_locked )
77
VObjectListIterator itr = m_objects;
79
for ( ; itr.current(); ++itr )
80
itr.current()->draw( painter, rect );
84
VLayer::bringToFront( const VObject& object )
86
if( m_objects.getLast() == &object ) return;
88
m_objects.remove( &object );
90
m_objects.append( &object );
94
VLayer::upwards( const VObject& object )
96
if( m_objects.getLast() == &object ) return;
98
m_objects.remove( &object );
100
if( m_objects.current() != m_objects.getLast() )
103
m_objects.insert( m_objects.at(), &object );
106
m_objects.append( &object );
110
VLayer::downwards( const VObject& object )
112
if( m_objects.getFirst() == &object ) return;
114
int index = m_objects.find( &object );
115
bool bLast = m_objects.getLast() == &object;
116
m_objects.remove( index );
118
if( !bLast ) m_objects.prev();
120
m_objects.insert( m_objects.at(), &object );
124
VLayer::sendToBack( const VObject& object )
126
if( m_objects.getFirst() == &object ) return;
128
m_objects.remove( &object );
130
m_objects.prepend( &object );
134
VLayer::save( QDomElement& element ) const
136
QDomElement me = element.ownerDocument().createElement( "LAYER" );
137
element.appendChild( me );
139
if( state() == normal || state() == normal_locked || state() == VObject::selected )
140
me.setAttribute( "visible", 1 );
143
VObjectListIterator itr = m_objects;
144
for ( ; itr.current(); ++itr )
145
itr.current()->save( me );
151
VLayer::load( const QDomElement& element )
153
setState( element.attribute( "visible" ) == 0 ? hidden : normal );
154
VGroup::load( element );
159
VLayer::clone() const
161
return new VLayer( *this );
165
VLayer::accept( VVisitor& visitor )
167
visitor.visitVLayer( *this );