summaryrefslogtreecommitdiffstats
path: root/client/dominoclient.h
blob: 0bb39be6be68460d6041bc39cf6b376d886d3c65 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
/*
	Copyright (C) 2006 Michael Lentner <michaell@gmx.net>
	
	based on KDE2 Default KWin client:
	Copyright (C) 1999, 2001 Daniel Duley <mosfet@kde.org>
	Matthias Ettrich <ettrich@kde.org>
	Karol Szwed <gallium@kde.org>
	
	This library is free software; you can redistribute it and/or
	modify it under the terms of the GNU Library General Public
	License version 2 as published by the Free Software Foundation.
	
	This library is distributed in the hope that it will be useful,
	but WITHOUT ANY WARRANTY; without even the implied warranty of
	MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
	Library General Public License for more details.
	
	You should have received a copy of the GNU General Public License
	along with this library; if not, write to the Free Software
	Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA
*/

#ifndef _DOMINOCLIENT_H
#define _DOMINOCLIENT_H

#include <kcommondecoration.h>
#include <kdecorationfactory.h>
#include <tqlayout.h>

namespace Domino {

class DominoClient;
class TitleBar;

class DominoHandler: public TQObject, public KDecorationFactory
{
	public:
		DominoHandler();
		~DominoHandler();
				KDecoration* createDecoration( KDecorationBridge* b );
		bool reset( unsigned long changed );
		virtual bool supports( Ability ability );
		
		TQColor buttonContourColor;
		TQColor buttonMouseOverContourColor;
		TQColor buttonPressedContourColor;
		
		bool customButtonColor;
		TQColor buttonColor;
		bool customButtonIconColor;
		TQColor buttonIconColor;
		bool customBorderColor;
		TQColor borderColor;
		bool darkLines;
		
	private:
		unsigned long readConfig( bool update );
		void createPixmaps();
		void freePixmaps();

};


class DominoButton : public KCommonDecorationButton
{
	public:
		DominoButton(ButtonType type, DominoClient *parent, const char *name);
		~DominoButton();

		void reset(unsigned long changed);

	protected:
		void enterEvent(TQEvent *);
		void leaveEvent(TQEvent *);
		void drawButton(TQPainter *p);
		void drawButtonLabel(TQPainter*) {;}

		bool isMouseOver;
		DominoClient* client;
};


class DominoClient : public KCommonDecoration
{
	Q_OBJECT
	public:
		DominoClient( KDecorationBridge* b, KDecorationFactory* f );
		~DominoClient();

		virtual TQString visibleName() const;
		virtual TQString defaultButtonsLeft() const;
		virtual TQString defaultButtonsRight() const;
		virtual bool decorationBehaviour(DecorationBehaviour behaviour) const;
		virtual int layoutMetric(LayoutMetric lm, bool respectWindowState = true, const KCommonDecorationButton * = 0) const;
		virtual KCommonDecorationButton *createButton(ButtonType type);
		void borders( int& left, int& right, int& top, int& bottom ) const;
		
		void init();
		void reset( unsigned long changed );
		void resize( const TQSize& s );
		void updateMask();
		
		void updateWindowShape();
		void updateCaption();
		void shadeChange();
		void activeChange();
		void iconChange();
		
		TitleBar* titleBar;
		TQWidget* borderTopLeft;
		TQWidget* borderTopRight;
		TQWidget* borderBottomLeft;
		TQWidget* borderBottomRight;
		TQWidget* borderLeft;
		TQWidget* borderRight;
		TQWidget* borderBottom;
		TQGridLayout* mainlayout;
		TQButton* menuButton;
		
		void setPixmaps();
		bool titleBarMouseOver;
		bool globalMouseTracking;
		
	public slots:
		void slotShade();
		void menuButtonDestroyed();

	protected:
		bool eventFilter(TQObject*, TQEvent*);
		void paintEvent(TQPaintEvent*);
		void resizeEvent(TQResizeEvent*);
		void showEvent(TQShowEvent*);

	private:
		
		void createLayout();
};

class TitleBar : public TQWidget
{
	public:
		TitleBar(TQWidget* parent=0, const char* name=0) : TQWidget(parent, name) {}
		void enterEvent(TQEvent * e);
		bool eventFilter(TQObject*, TQEvent*);
		DominoClient* client;
};



void renderGradient(TQPainter *painter, TQRect &rect,
	    TQColor &c1, TQColor &c2, const char* name = 0);
TQColor alphaBlendColors(const TQColor &backgroundColor, const TQColor &foregroundColor, const int alpha);
TQImage tintImage(const TQImage &img, const TQColor &tintColor);
}

#endif