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
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
|
#include "test.h"
#include <tqtooltip.h>
#include <tdeglobal.h>
#include <kdebug.h>
namespace KWinTest
{
Decoration::Decoration( KDecorationBridge* bridge, KDecorationFactory* factory )
: KDecoration( bridge, factory ),
button( NULL )
{
}
void Decoration::init()
{
createMainWidget();
widget()->setEraseColor( red );
widget()->installEventFilter( this );
if( isCloseable())
{
button = new TQPushButton( widget());
button->show();
button->setCursor( tqarrowCursor );
button->move( 0, 0 );
connect( button, TQT_SIGNAL( clicked()), TQT_SLOT( closeWindow()));
TQToolTip::add( button, "Zelva Mana" );
}
}
Decoration::MousePosition Decoration::mousePosition( const TQPoint& p ) const
{
const int range = 16;
const int border = 4;
MousePosition m = Nowhere;
int width = widget()->width();
int height = widget()->height();
if ( ( p.x() > border && p.x() < width - border )
&& ( p.y() > border && p.y() < height - border ) )
return Center;
if ( p.y() <= range && p.x() <= range)
m = TopLeft2;
else if ( p.y() >= height-range && p.x() >= width-range)
m = BottomRight2;
else if ( p.y() >= height-range && p.x() <= range)
m = BottomLeft2;
else if ( p.y() <= range && p.x() >= width-range)
m = TopRight2;
else if ( p.y() <= border )
m = Top;
else if ( p.y() >= height-border )
m = Bottom;
else if ( p.x() <= border )
m = Left;
else if ( p.x() >= width-border )
m = Right;
else
m = Center;
return m;
}
void Decoration::borders( int& left, int& right, int& top, int& bottom ) const
{
if( options()->preferredBorderSize( factory()) == BorderTiny )
{
left = right = bottom = 1;
top = 5;
}
else
{
left = right = options()->preferredBorderSize( factory()) * 5;
top = options()->preferredBorderSize( factory()) * 10;
bottom = options()->preferredBorderSize( factory()) * 2;
}
if( isShade())
bottom = 0;
if( ( maximizeMode() & MaximizeHorizontal ) && !options()->moveResizeMaximizedWindows())
left = right = 0;
if( ( maximizeMode() & MaximizeVertical ) && !options()->moveResizeMaximizedWindows())
bottom = 0;
}
void Decoration::reset( unsigned long )
{
}
void Decoration::resize( const TQSize& s )
{
widget()->resize( s );
}
TQSize Decoration::minimumSize() const
{
return TQSize( 100, 50 );
}
bool Decoration::eventFilter( TQObject* o, TQEvent* e )
{
if( o == widget())
{
switch( e->type())
{
case TQEvent::MouseButtonPress:
{ // FRAME
processMousePressEvent( TQT_TQMOUSEEVENT( e ));
return true;
}
case TQEvent::Show:
break;
case TQEvent::Hide:
break;
default:
break;
}
}
return false;
}
}
#include <tqapplication.h>
#include <tqpainter.h>
#include <X11/Xlib.h>
#include <math.h>
#include <unistd.h>
namespace KWinTest
{
// taken from riscos
bool Decoration::animateMinimize(bool iconify)
{
int style = 1;
switch (style) {
case 1:
{
// Double twisting double back, with pike ;)
if (!iconify) // No animation for restore.
return true;
// Go away quick.
helperShowHide( false );
tqApp->syncX();
TQRect r = iconGeometry();
if (!r.isValid())
return true;
// Algorithm taken from Window Maker (http://www.windowmaker.org)
int sx = geometry().x();
int sy = geometry().y();
int sw = width();
int sh = height();
int dx = r.x();
int dy = r.y();
int dw = r.width();
int dh = r.height();
double steps = 12;
double xstep = double((dx-sx)/steps);
double ystep = double((dy-sy)/steps);
double wstep = double((dw-sw)/steps);
double hstep = double((dh-sh)/steps);
double cx = sx;
double cy = sy;
double cw = sw;
double ch = sh;
double finalAngle = 3.14159265358979323846;
double delta = finalAngle / steps;
TQPainter p( workspaceWidget());
p.setRasterOp(TQt::NotROP);
for (double angle = 0; ; angle += delta) {
if (angle > finalAngle)
angle = finalAngle;
double dx = (cw / 10) - ((cw / 5) * sin(angle));
double dch = (ch / 2) * cos(angle);
double midy = cy + (ch / 2);
TQPoint p1(int(cx + dx), int(midy - dch));
TQPoint p2(int(cx + cw - dx), p1.y());
TQPoint p3(int(cx + dw + dx), int(midy + dch));
TQPoint p4(int(cx - dx), p3.y());
grabXServer();
p.drawLine(p1, p2);
p.drawLine(p2, p3);
p.drawLine(p3, p4);
p.drawLine(p4, p1);
p.flush();
usleep(500);
p.drawLine(p1, p2);
p.drawLine(p2, p3);
p.drawLine(p3, p4);
p.drawLine(p4, p1);
ungrabXServer();
// FRAME tqApp->processEvents(); // FRAME ???
cx += xstep;
cy += ystep;
cw += wstep;
ch += hstep;
if (angle >= finalAngle)
break;
}
}
break;
case 2:
{
// KVirc style ? Maybe. For qwertz.
if (!iconify) // No animation for restore.
return true;
// Go away quick.
helperShowHide( false );
tqApp->syncX();
int stepCount = 12;
TQRect r(geometry());
int dx = r.width() / (stepCount * 2);
int dy = r.height() / (stepCount * 2);
TQPainter p( workspaceWidget());
p.setRasterOp(TQt::NotROP);
for (int step = 0; step < stepCount; step++) {
r.moveBy(dx, dy);
r.setWidth(r.width() - 2 * dx);
r.setHeight(r.height() - 2 * dy);
grabXServer();
p.drawRect(r);
p.flush();
usleep(200);
p.drawRect(r);
ungrabXServer();
// FRAME tqApp->processEvents();
}
}
break;
default:
{
TQRect icongeom = iconGeometry();
if (!icongeom.isValid())
return true;
TQRect wingeom = geometry();
TQPainter p( workspaceWidget());
p.setRasterOp(TQt::NotROP);
#if 0
if (iconify)
p.setClipRegion(
TQRegion( workspaceWidget()->rect()) - wingeom
);
#endif
grabXServer();
p.drawLine(wingeom.bottomRight(), icongeom.bottomRight());
p.drawLine(wingeom.bottomLeft(), icongeom.bottomLeft());
p.drawLine(wingeom.topLeft(), icongeom.topLeft());
p.drawLine(wingeom.topRight(), icongeom.topRight());
p.flush();
tqApp->syncX();
usleep(30000);
p.drawLine(wingeom.bottomRight(), icongeom.bottomRight());
p.drawLine(wingeom.bottomLeft(), icongeom.bottomLeft());
p.drawLine(wingeom.topLeft(), icongeom.topLeft());
p.drawLine(wingeom.topRight(), icongeom.topRight());
ungrabXServer();
}
break;
}
return true;
}
KDecoration* Factory::createDecoration( KDecorationBridge* bridge )
{
NET::WindowType type = windowType( SUPPORTED_WINDOW_TYPES_MASK, bridge );
if( type == NET::Dialog )
;
return new Decoration( bridge, this );
}
bool Factory::reset( unsigned long changed )
{
resetDecorations( changed );
return false;
}
} // namespace
extern "C"
{
KDE_EXPORT KDecorationFactory *create_factory()
{
return new KWinTest::Factory();
}
}
#include "test.moc"
|