~ubuntu-branches/ubuntu/utopic/kde-workspace/utopic-proposed

« back to all changes in this revision

Viewing changes to kwin/libkdecorations/kdecorationfactory.h

  • Committer: Bazaar Package Importer
  • Author(s): Michał Zając
  • Date: 2011-07-09 08:31:15 UTC
  • Revision ID: james.westby@ubuntu.com-20110709083115-ohyxn6z93mily9fc
Tags: upstream-4.6.90
Import upstream version 4.6.90

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*****************************************************************
 
2
This file is part of the KDE project.
 
3
 
 
4
Copyright (C) 2003 Lubos Lunak <l.lunak@kde.org>
 
5
 
 
6
Permission is hereby granted, free of charge, to any person obtaining a
 
7
copy of this software and associated documentation files (the "Software"),
 
8
to deal in the Software without restriction, including without limitation
 
9
the rights to use, copy, modify, merge, publish, distribute, sublicense,
 
10
and/or sell copies of the Software, and to permit persons to whom the
 
11
Software is furnished to do so, subject to the following conditions:
 
12
 
 
13
The above copyright notice and this permission notice shall be included in
 
14
all copies or substantial portions of the Software.
 
15
 
 
16
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 
17
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 
18
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
 
19
THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 
20
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
 
21
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
 
22
DEALINGS IN THE SOFTWARE.
 
23
******************************************************************/
 
24
 
 
25
#ifndef KDECORATIONFACTORY_H
 
26
#define KDECORATIONFACTORY_H
 
27
 
 
28
#include "kdecoration.h"
 
29
 
 
30
/** @addtogroup kdecoration */
 
31
/** @{ */
 
32
 
 
33
class KDecoration;
 
34
class KDecorationBridge;
 
35
class KDecorationFactoryPrivate;
 
36
 
 
37
class KWIN_EXPORT KDecorationFactory
 
38
    : public KDecorationDefines
 
39
{
 
40
public:
 
41
    /**
 
42
     * Constructor. Called after loading the decoration plugin. All global
 
43
     * initialization of the plugin should be done in the factory constructor.
 
44
     */
 
45
    KDecorationFactory();
 
46
    /**
 
47
     * Destructor. Called before unloading the decoration plugin. All global
 
48
     * cleanup of the plugin should be done in the factory destructor.
 
49
     */
 
50
    virtual ~KDecorationFactory();
 
51
    /**
 
52
     * This function must be reimplemented to create decoration objects.
 
53
     * The argument should be passed to the KDecoration constructor, the second
 
54
     * KDecoration argument should be this factory object.
 
55
     */
 
56
    virtual KDecoration* createDecoration(KDecorationBridge* bridge) = 0;
 
57
    /**
 
58
     * This function is called when the configuration settings changed.
 
59
     * The argument specifies what has changed, using the SettingXXX masks.
 
60
     * It should be determined whether the decorations need to be completely
 
61
     * remade, in which case true should be returned, or whether only e.g.
 
62
     * a repaint will be sufficient, in which case false should be returned,
 
63
     * and resetDecorations() can be called to reset all decoration objects.
 
64
     * Note that true should be returned only when really necessary.
 
65
     */
 
66
    virtual bool reset(unsigned long changed);   // returns true if the decoration needs to be recreated
 
67
 
 
68
    /**
 
69
     * Reimplement this function if your decoration supports more border sizes than
 
70
     * the default one (BorderNormal). The returned list must contain all supported
 
71
     * sizes, ordered from the smallest to the largest one. By default, only
 
72
     * BorderNormal is returned.
 
73
     */
 
74
    virtual QList< BorderSize > borderSizes() const;
 
75
 
 
76
    virtual bool supports(Ability ability) const = 0;
 
77
 
 
78
    virtual void checkRequirements(KDecorationProvides* provides);
 
79
    /**
 
80
     * Returns the KDecorationOptions object, which is used to access
 
81
     * configuration settings for the decoration.
 
82
     */
 
83
    const KDecorationOptions* options(); // convenience
 
84
    /**
 
85
     * Returns true if the given decoration object still exists. This is necessary
 
86
     * e.g. when calling KDecoration::showWindowMenu(), which may cause the decoration
 
87
     * to be destroyed. Note that this function is reliable only if called immediately
 
88
     * after such actions.
 
89
     */
 
90
    bool exists(const KDecoration* deco) const;
 
91
    /**
 
92
     * @internal
 
93
     */
 
94
    void addDecoration(KDecoration*);
 
95
    /**
 
96
     * @internal
 
97
     */
 
98
    void removeDecoration(KDecoration*);
 
99
protected:
 
100
    /**
 
101
     * Convenience function that calls KDecoration::reset() for all decoration
 
102
     * objects.
 
103
     */
 
104
    void resetDecorations(unsigned long changed);   // convenience
 
105
    /**
 
106
     * This function has the same functionality like KDecoration::windowType().
 
107
     * It can be used in createDecoration() to return different KDecoration
 
108
     * inherited classes depending on the window type, as at that time
 
109
     * KDecoration::windowType() is not available yet. The additional argument
 
110
     * is the one passed to createDecoration().
 
111
     */
 
112
    NET::WindowType windowType(unsigned long supported_types, KDecorationBridge* bridge) const;
 
113
private:
 
114
    QList< KDecoration* > _decorations;
 
115
    KDecorationFactoryPrivate* d;
 
116
};
 
117
 
 
118
/**
 
119
 * @warning THIS CLASS IS UNSTABLE!
 
120
 * Keep all decoration class names in sync. E.g. KDecorationFactory2 and KDecoration2.
 
121
 */
 
122
class KWIN_EXPORT KDecorationFactoryUnstable
 
123
    : public KDecorationFactory
 
124
{
 
125
};
 
126
 
 
127
inline const KDecorationOptions* KDecorationFactory::options()
 
128
{
 
129
    return KDecoration::options();
 
130
}
 
131
 
 
132
/** @} */
 
133
 
 
134
#endif