~ubuntu-branches/ubuntu/gutsy/kdebase-workspace/gutsy-backports

« back to all changes in this revision

Viewing changes to kpager/ksharedpixmap.h

  • Committer: Bazaar Package Importer
  • Author(s): Jonathan Riddell
  • Date: 2007-09-05 20:45:14 UTC
  • Revision ID: james.westby@ubuntu.com-20070905204514-632hhspl0nvrc84i
Tags: upstream-3.93.0
ImportĀ upstreamĀ versionĀ 3.93.0

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* vi: ts=8 sts=4 sw=4
 
2
 *
 
3
 * This file is part of the KPager.
 
4
 * Copyright (C) 1999,2000 Geert Jansen <jansen@kde.org>
 
5
 *
 
6
 * This library is free software; you can redistribute it and/or
 
7
 * modify it under the terms of the GNU Library General Public
 
8
 * License as published by the Free Software Foundation; either
 
9
 * version 2 of the License, or (at your option) any later version.
 
10
 */
 
11
 
 
12
#ifndef KSHAREDPIXMAP_H
 
13
#define KSHAREDPIXMAP_H
 
14
 
 
15
#include <QtGui/QWidget>
 
16
 
 
17
class QPixmap;
 
18
class QString;
 
19
 
 
20
/**
 
21
 * Shared pixmap client.
 
22
 *
 
23
 * A shared pixmap is a pixmap that resides on the X server, is referenced
 
24
 * by a global id string, and can be accessed by all X clients.
 
25
 *
 
26
 * This class is a client class to shared pixmaps in KDE. You can use it
 
27
 * to copy (a part of) a shared pixmap into. KSharedPixmap provides a
 
28
 * member of type QPixmap (@see pixmap()) for that purpose.
 
29
 *
 
30
 * The server part of shared pixmaps is not implemented here. 
 
31
 * That part is provided by KPixmapServer, in the source file:
 
32
 * kdebase/kdesktop/pixmapserver.cc.
 
33
 *
 
34
 * An example: copy from a shared pixmap:
 
35
 * \code
 
36
 *   KSharedPixmap *pm = new KSharedPixmap;
 
37
 *   connect(pm, SIGNAL(done(bool)), SLOT(slotDone(bool)));
 
38
 *   pm->loadFromShared("My Pixmap");
 
39
 *
 
40
 *   // do something with the pixmap
 
41
 *   pm->pixmap() ...
 
42
 * \endcode
 
43
 *
 
44
 * @author Geert Jansen <jansen@kde.org>
 
45
 */
 
46
class KSharedPixmap : 
 
47
    public QWidget
 
48
{
 
49
    Q_OBJECT
 
50
 
 
51
public:
 
52
 
 
53
    /**
 
54
     * Construct an empty pixmap.
 
55
     */
 
56
    KSharedPixmap();
 
57
 
 
58
    /**
 
59
     * Destroys the pixmap.
 
60
     */
 
61
    ~KSharedPixmap();
 
62
 
 
63
    /**
 
64
     * Load from a shared pixmap reference. The signal done() is emitted
 
65
     * when the operation has finished.
 
66
     *
 
67
     * @param name The shared pixmap name.
 
68
     * @param rect If you pass a nonzero rectangle, a tile is generated which 
 
69
     * is able to fill up the specified rectangle completely. This is solely 
 
70
     * for optimization: in some cases the tile will be much smaller than the 
 
71
     * original pixmap. It reflects KSharedPixmap's original use: sharing
 
72
     * of the desktop background to achieve pseudo transparency.
 
73
     * @return True if the shared pixmap exists and loading has started
 
74
     * successfully, false otherwise.
 
75
     */
 
76
    bool loadFromShared(const QString & name, const QRect & rect=QRect());
 
77
 
 
78
    /**
 
79
     * Check whether a shared pixmap is available.
 
80
     *
 
81
     * @param name The shared pixmap name.
 
82
     * @return True if the shared pixmap is available, false otherwise.
 
83
     */
 
84
    bool isAvailable(const QString & name) const;
 
85
 
 
86
    /**
 
87
     * Gives access to the shared pixmap data.
 
88
     */
 
89
    QPixmap pixmap() const;
 
90
 
 
91
Q_SIGNALS:
 
92
    /** 
 
93
     * This signal is raised when a pixmap load operation has finished.
 
94
     *
 
95
     * @param success True if successful, false otherwise.
 
96
     */
 
97
    void done(bool success);
 
98
 
 
99
#ifdef Q_WS_X11
 
100
protected:
 
101
    bool x11Event(XEvent *);
 
102
#endif    
 
103
 
 
104
private:
 
105
    bool copy(const QString & id, const QRect & rect);
 
106
    void init();
 
107
 
 
108
    class KSharedPixmapPrivate;
 
109
    KSharedPixmapPrivate *d;
 
110
};
 
111
 
 
112
#endif
 
113