chalk

kis_image_iface.cpp
1/*
2 * This file is part of the KDE project
3 *
4 * Copyright (C) 2002 Laurent Montel <lmontel@mandrakesoft.com>
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
19*/
20#include <tdeapplication.h>
21
22#include "kis_image_iface.h"
23#include "kis_types.h"
24#include "kis_image.h"
25#include "kis_paint_device.h"
26#include "kis_paint_device_iface.h"
27#include <dcopclient.h>
28
29KisImageIface::KisImageIface( KisImage * img )
30 : DCOPObject(img->name().utf8())
31{
32 m_img = img;
33}
34
35int KisImageIface::height() const
36{
37 return m_img->height();
38}
39
40int KisImageIface::width() const
41{
42 return m_img->width();
43}
44
45void KisImageIface::setName(const TQString& name)
46{
47 m_img->setName( name );
48}
49
50void KisImageIface::rotateCCW()
51{
52 // XXX: Add progress display if there is a view
53 m_img->rotate(270, 0);
54}
55
56void KisImageIface::rotateCW()
57{
58 // XXX: Add progressdisplay if there is a view
59 m_img->rotate(90, 0);
60}
61
62void KisImageIface::rotate180()
63{
64 // XXX: Add progressdisplay if there is a view
65 m_img->rotate(180, 0);
66}
67
68void KisImageIface::rotate(double angle)
69{
70 // XXX: Add progressdisplay if there is a view
71 angle *= M_PI/180;
72 m_img->rotate(angle, 0);
73}
74
75DCOPRef KisImageIface::activeDevice()
76{
77 KisPaintDeviceSP dev = m_img->activeDevice();
78
79 if( !dev )
80 return DCOPRef();
81 else
82 return DCOPRef( kapp->dcopClient()->appId(),
83 dev->dcopObject()->objId(),
84 "KisPaintDeviceIface");
85
86}
87
88DCOPRef KisImageIface::colorSpace() const
89{
90 KisColorSpace * cs = m_img->colorSpace();
91 if ( !cs )
92 return DCOPRef();
93 else
94 return DCOPRef( kapp->dcopClient()->appId(),
95 cs->dcopObject()->objId(),
96 "KisColorSpaceIface" );
97}