karbon
karbon_part_iface.cc
00001 /* This file is part of the KDE project 00002 Copyright (C) 2002 Laurent Montel <lmontel@mandrakesoft.com> 00003 00004 This library is free software; you can redistribute it and/or 00005 modify it under the terms of the GNU Library General Public 00006 License as published by the Free Software Foundation; either 00007 version 2 of the License, or (at your option) any later version. 00008 00009 This library is distributed in the hope that it will be useful, 00010 but WITHOUT ANY WARRANTY; without even the implied warranty of 00011 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00012 Library General Public License for more details. 00013 00014 You should have received a copy of the GNU Library General Public License 00015 along with this library; see the file COPYING.LIB. If not, write to 00016 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 00017 * Boston, MA 02110-1301, USA. 00018 */ 00019 00020 00021 #include <dcopclient.h> 00022 00023 #include <kapplication.h> 00024 00025 #include "karbon_part.h" 00026 #include "karbon_part_iface.h" 00027 #include "vselection.h" 00028 #include "vlayer.h" 00029 00030 00031 KarbonPartIface::KarbonPartIface( KarbonPart* part ) 00032 : KoDocumentIface( part ) 00033 { 00034 m_part = part; 00035 } 00036 00037 void KarbonPartIface::selectAllObjects() 00038 { 00039 m_part->document().selection()->append(); 00040 } 00041 00042 void KarbonPartIface::deselectAllObjects() 00043 { 00044 m_part->document().selection()->clear(); 00045 } 00046 00047 bool KarbonPartIface::showStatusBar () const 00048 { 00049 return m_part->showStatusBar(); 00050 } 00051 00052 void KarbonPartIface::setShowStatusBar ( bool b ) 00053 { 00054 m_part->setShowStatusBar( b ); 00055 m_part->reorganizeGUI(); 00056 } 00057 00058 void KarbonPartIface::setUndoRedoLimit( int undo ) 00059 { 00060 m_part->setUndoRedoLimit( undo ); 00061 } 00062 00063 void KarbonPartIface::initConfig() 00064 { 00065 m_part->initConfig(); 00066 } 00067 00068 00069 void KarbonPartIface::clearHistory() 00070 { 00071 m_part->clearHistory(); 00072 } 00073 00074 00075 QString KarbonPartIface::unitName() const 00076 { 00077 return m_part->unitName(); 00078 } 00079 00080 QString 00081 KarbonPartIface::widthInUnits() 00082 { 00083 QString val = KoUnit::toUserStringValue( m_part->document().width(), m_part->unit() ); 00084 return QString( "%1%2" ).arg( val ).arg( m_part->unitName() ); 00085 } 00086 00087 QString 00088 KarbonPartIface::heightInUnits() 00089 { 00090 QString val = KoUnit::toUserStringValue( m_part->document().height(), m_part->unit() ); 00091 return QString( "%1%2" ).arg( val ).arg( m_part->unitName() ); 00092 } 00093 00094 double 00095 KarbonPartIface::width() 00096 { 00097 return m_part->document().width(); 00098 } 00099 00100 double 00101 KarbonPartIface::height() 00102 { 00103 return m_part->document().height(); 00104 } 00105 00106 int KarbonPartIface::nbLayer() const 00107 { 00108 return m_part->document().layers().count(); 00109 } 00110 00111 DCOPRef KarbonPartIface::activeLayer() 00112 { 00113 if( !m_part->document().activeLayer() ) 00114 return DCOPRef(); 00115 00116 return DCOPRef( kapp->dcopClient()->appId(), 00117 m_part->document().activeLayer()->dcopObject()->objId() ); 00118 } 00119