3 * Copyright (c) 2003 Lubos Lunak <l.lunak@kde.org>
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
20 #ifndef KWINDECORATION_PREVIEW_H
21 #define KWINDECORATION_PREVIEW_H
25 #include <QMouseEvent>
27 #include <QResizeEvent>
28 #include <kdecoration.h>
29 #include <kdecorationbridge.h>
30 #include <kdecoration_plugins_p.h>
34 class KDecorationPreviewBridge
;
35 class KDecorationPreviewOptions
;
37 class KDecorationPreview
42 // Note: Windows can't be added or removed without making changes to
43 // the code, since parts of it assume there's just an active
44 // and an inactive window.
45 enum Windows
{ Inactive
= 0, Active
, NumWindows
};
47 KDecorationPreview( QWidget
* parent
= NULL
);
48 virtual ~KDecorationPreview();
49 bool recreateDecoration( KDecorationPlugins
* plugin
);
51 void disablePreview();
52 void setPreviewMask( const QRegion
&, int, bool );
53 QRegion
unobscuredRegion( bool, const QRegion
& ) const;
54 QRect
windowGeometry( bool ) const;
55 void setTempBorderSize(KDecorationPlugins
* plugin
, KDecorationDefines::BorderSize size
);
56 void setTempButtons(KDecorationPlugins
* plugin
, bool customEnabled
, const QString
&left
, const QString
&right
);
58 virtual void resizeEvent( QResizeEvent
* );
60 void positionPreviews();
61 KDecorationPreviewOptions
* options
;
62 KDecorationPreviewBridge
* bridge
[NumWindows
];
63 KDecoration
* deco
[NumWindows
];
68 class KDecorationPreviewBridge
69 : public KDecorationBridgeUnstable
72 KDecorationPreviewBridge( KDecorationPreview
* preview
, bool active
);
73 virtual bool isActive() const;
74 virtual bool isCloseable() const;
75 virtual bool isMaximizable() const;
76 virtual MaximizeMode
maximizeMode() const;
77 virtual bool isMinimizable() const;
78 virtual bool providesContextHelp() const;
79 virtual int desktop() const;
80 virtual bool isModal() const;
81 virtual bool isShadeable() const;
82 virtual bool isShade() const;
83 virtual bool isSetShade() const;
84 virtual bool keepAbove() const;
85 virtual bool keepBelow() const;
86 virtual bool isMovable() const;
87 virtual bool isResizable() const;
88 virtual NET::WindowType
windowType( unsigned long supported_types
) const;
89 virtual QIcon
icon() const;
90 virtual QString
caption() const;
91 virtual void processMousePressEvent( QMouseEvent
* );
92 virtual void showWindowMenu( const QRect
&);
93 virtual void showWindowMenu( const QPoint
& );
94 virtual void performWindowOperation( WindowOperation
);
95 virtual void setMask( const QRegion
&, int );
96 virtual bool isPreview() const;
97 virtual QRect
geometry() const;
98 virtual QRect
iconGeometry() const;
99 virtual QRegion
unobscuredRegion( const QRegion
& r
) const;
100 virtual WId
windowId() const;
101 virtual void closeWindow();
102 virtual void maximize( MaximizeMode mode
);
103 virtual void minimize();
104 virtual void showContextHelp();
105 virtual void setDesktop( int desktop
);
106 virtual void titlebarDblClickOperation();
107 virtual void titlebarMouseWheelOperation( int delta
);
108 virtual void setShade( bool set
);
109 virtual void setKeepAbove( bool );
110 virtual void setKeepBelow( bool );
111 virtual int currentDesktop() const;
112 virtual QWidget
* initialParentWidget() const;
113 virtual Qt::WFlags
initialWFlags() const;
114 virtual void grabXServer( bool grab
);
116 virtual void repaintShadow();
117 virtual bool compositingActive() const;
118 virtual bool shadowsActive() const;
119 virtual double opacity() const;
121 KDecorationPreview
* preview
;
125 class KDecorationPreviewOptions
126 : public KDecorationOptions
129 KDecorationPreviewOptions();
130 virtual ~KDecorationPreviewOptions();
131 virtual unsigned long updateSettings();
133 void setCustomBorderSize(BorderSize size
);
134 void setCustomTitleButtonsEnabled(bool enabled
);
135 void setCustomTitleButtons(const QString
&left
, const QString
&right
);
138 BorderSize customBorderSize
;
139 bool customButtonsChanged
;
141 QString customTitleButtonsLeft
;
142 QString customTitleButtonsRight
;
145 class KDecorationPreviewPlugins
146 : public KDecorationPlugins
149 KDecorationPreviewPlugins(const KSharedConfigPtr
&cfg
);
150 virtual bool provides( Requirement
);
153 inline KDecorationPreviewPlugins::KDecorationPreviewPlugins(const KSharedConfigPtr
&cfg
)
154 : KDecorationPlugins( cfg
)