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
|
/*****************************************************************
kwin - the KDE window manager
Copyright (C) 1999, 2000 Matthias Ettrich <ettrich@kde.org>
******************************************************************/
#ifndef STDCLIENT_H
#define STDCLIENT_H
#include <qlayout.h>
#include <qvariant.h>
#include <kdecoration.h>
#include <kdecorationfactory.h>
#include <qtoolbutton.h>
class QLabel;
class QSpacerItem;
namespace KDE1 {
enum ButtonType {
ButtonMenu=0,
ButtonSticky,
ButtonMinimize,
ButtonMaximize,
ButtonClose,
ButtonHelp,
ButtonTypeCount
};
class StdClient : public KDecoration
{
Q_OBJECT
public:
StdClient( KDecorationBridge* b, KDecorationFactory* f );
~StdClient();
void init();
QSize minimumSize() const;
void borders( int& left, int& right, int& top, int& bottom ) const;
void reset( unsigned long mask );
void resize( const QSize& s );
void shadeChange() {};
Position mousePosition( const QPoint& p ) const { return KDecoration::mousePosition( p ); }
protected:
bool eventFilter( QObject* o, QEvent* e );
void resizeEvent( QResizeEvent* );
void paintEvent( QPaintEvent* );
void mouseDoubleClickEvent( QMouseEvent * );
void wheelEvent( QWheelEvent * );
void captionChange();
void iconChange();
void maximizeChange();
void desktopChange();
void activeChange();
private:
void addButtons(QBoxLayout* hb, const QString& buttons);
private slots:
void menuButtonPressed();
void maxButtonClicked( ButtonState );
private:
QToolButton* button[ButtonTypeCount];
QSpacerItem* titlebar;
};
class StdToolClient : public KDecoration
{
Q_OBJECT
public:
StdToolClient( KDecorationBridge* b, KDecorationFactory* f );
~StdToolClient();
void init();
QSize minimumSize() const;
void borders( int& left, int& right, int& top, int& bottom ) const;
void reset( unsigned long mask );
void resize( const QSize& s );
void shadeChange() {};
void activeChange() {};
void iconChange() {};
void maximizeChange() {};
void desktopChange() {};
Position mousePosition( const QPoint& p ) const { return KDecoration::mousePosition( p ); }
protected:
bool eventFilter( QObject* o, QEvent* e );
void resizeEvent( QResizeEvent* );
void paintEvent( QPaintEvent* );
void mouseDoubleClickEvent( QMouseEvent * );
void wheelEvent( QWheelEvent * );
void captionChange();
private:
QToolButton* closeBtn;
QSpacerItem* titlebar;
};
/*
Like QToolButton, but provides a clicked(ButtonState) signals that
has the last pressed mouse button as argument
*/
class ThreeButtonButton: public QToolButton
{
Q_OBJECT
public:
ThreeButtonButton ( QWidget *parent = 0, const char* name = 0 )
: QToolButton( parent, name )
{
connect( this, SIGNAL( clicked() ), this, SLOT( handleClicked() ) );
setCursor( arrowCursor );
}
~ThreeButtonButton () {}
signals:
void clicked( ButtonState );
protected:
void mousePressEvent( QMouseEvent* e )
{
last_button = e->button();
QMouseEvent me ( e->type(), e->pos(), e->globalPos(), LeftButton, e->state() );
QToolButton::mousePressEvent( &me );
}
void mouseReleaseEvent( QMouseEvent* e )
{
QMouseEvent me ( e->type(), e->pos(), e->globalPos(), LeftButton, e->state() );
QToolButton::mouseReleaseEvent( &me );
}
private slots:
void handleClicked()
{
emit clicked( last_button );
}
private:
ButtonState last_button;
};
class StdFactory : public KDecorationFactory
{
public:
StdFactory();
~StdFactory();
KDecoration* createDecoration( KDecorationBridge* b );
bool reset( unsigned long mask );
virtual bool supports( Ability ability );
};
}
#endif
|