krita

kis_paint_device_iface.cc

00001 /*
00002  *  This file is part of the KDE project
00003  *
00004  *  Copyright (C) 2005 Boudewijn Rempt <boud@valdyas.org>
00005  *
00006  *  This program is free software; you can redistribute it and/or modify
00007  *  it under the terms of the GNU General Public License as published by
00008  *  the Free Software Foundation; either version 2 of the License, or
00009  *  (at your option) any later version.
00010  *
00011  *  This program is distributed in the hope that it will be useful,
00012  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
00013  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00014  *  GNU General Public License for more details.
00015  *
00016  *  You should have received a copy of the GNU General Public License
00017  *  along with this program; if not, write to the Free Software
00018  *  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
00019 */
00020 #include <kapplication.h>
00021 
00022 #include <dcopclient.h>
00023 
00024 #include "kis_paint_device_iface.h"
00025 #include "kis_colorspace_iface.h"
00026 #include "kis_colorspace.h"
00027 
00028 #include "kis_paint_device.h"
00029 
00030 KisPaintDeviceIface::KisPaintDeviceIface( KisPaintDevice * parent )
00031     : DCOPObject("paintdevice")
00032 {
00033     m_parent = parent;
00034 }
00035 
00036 Q_INT32 KisPaintDeviceIface::pixelSize() const
00037 {
00038     return m_parent->pixelSize();
00039 }
00040 
00041 Q_INT32 KisPaintDeviceIface::nChannels() const
00042 {
00043     return m_parent->nChannels();
00044 }
00045 
00046 QByteArray KisPaintDeviceIface::readBytes(Q_INT32 x, Q_INT32 y, Q_INT32 w, Q_INT32 h)
00047 {
00048     QByteArray b (w * h * m_parent->pixelSize());
00049 
00050     m_parent->readBytes((Q_UINT8*)b.data(), x, y, w, h);
00051     return b;
00052 }
00053 
00054 void KisPaintDeviceIface::writeBytes(QByteArray bytes, Q_INT32 x, Q_INT32 y, Q_INT32 w, Q_INT32 h)
00055 {
00056     m_parent->writeBytes((Q_UINT8*)bytes.data(), x, y, w, h);
00057 }
00058 
00059 DCOPRef KisPaintDeviceIface::colorSpace() const
00060 {
00061     KisColorSpace * cs = m_parent->colorSpace();
00062     if ( !cs )
00063         return DCOPRef();
00064     else
00065         return DCOPRef( kapp->dcopClient()->appId(),
00066                         cs->dcopObject()->objId(),
00067                         "KisColorSpaceIface" );
00068 }
00069 
00070 void KisPaintDeviceIface::setColorSpace(DCOPRef)
00071 {
00072     // XXX: Figure out how to get the correct object from
00073     //      the dcopref
00074 }
KDE Home | KDE Accessibility Home | Description of Access Keys