• Skip to content
  • Skip to link menu
Trinity API Reference
  • Trinity API Reference
  • twin/lib
 

twin/lib

  • twin
  • lib
kdecoration.cpp
1/*****************************************************************
2This file is part of the KDE project.
3
4Copyright (C) 2003 Lubos Lunak <l.lunak@kde.org>
5
6Permission is hereby granted, free of charge, to any person obtaining a
7copy of this software and associated documentation files (the "Software"),
8to deal in the Software without restriction, including without limitation
9the rights to use, copy, modify, merge, publish, distribute, sublicense,
10and/or sell copies of the Software, and to permit persons to whom the
11Software is furnished to do so, subject to the following conditions:
12
13The above copyright notice and this permission notice shall be included in
14all copies or substantial portions of the Software.
15
16THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
19THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
21FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
22DEALINGS IN THE SOFTWARE.
23******************************************************************/
24
25#include "kdecoration.h"
26
27#include <kdebug.h>
28#include <tqapplication.h>
29#include <tdeglobal.h>
30#include <assert.h>
31#if defined TQ_WS_X11 && ! defined K_WS_QTONLY
32#include <X11/Xlib.h>
33#include <fixx11h.h>
34#endif
35
36#include "kdecoration_p.h"
37#include "kdecorationfactory.h"
38
39KDecorationOptions* KDecoration::options_;
40
41KDecoration::KDecoration( KDecorationBridge* bridge, KDecorationFactory* factory )
42 : bridge_( bridge ),
43 w_( NULL ),
44 factory_( factory )
45 {
46 factory->addDecoration( this );
47 }
48
49KDecoration::~KDecoration()
50 {
51 factory()->removeDecoration( this );
52 delete w_;
53 }
54
55const KDecorationOptions* KDecoration::options()
56 {
57 return options_;
58 }
59
60void KDecoration::createMainWidget( TQt::WFlags flags )
61 {
62 // FRAME check flags?
63 setMainWidget( new TQWidget( initialParentWidget(), "decoration widget", initialWFlags() | flags ));
64 }
65
66void KDecoration::setMainWidget( TQWidget* w )
67 {
68 assert( w_ == NULL );
69 w_ = w;
70 w->setMouseTracking( true );
71 widget()->resize( geometry().size());
72 }
73
74TQWidget* KDecoration::initialParentWidget() const
75 {
76 return bridge_->initialParentWidget();
77 }
78
79TQt::WFlags KDecoration::initialWFlags() const
80 {
81 return bridge_->initialWFlags();
82 }
83
84bool KDecoration::isActive() const
85 {
86 return bridge_->isActive();
87 }
88
89bool KDecoration::isCloseable() const
90 {
91 return bridge_->isCloseable();
92 }
93
94bool KDecoration::isMaximizable() const
95 {
96 return bridge_->isMaximizable();
97 }
98
99KDecoration::MaximizeMode KDecoration::maximizeMode() const
100 {
101 return bridge_->maximizeMode();
102 }
103
104bool KDecoration::isMinimizable() const
105 {
106 return bridge_->isMinimizable();
107 }
108
109bool KDecoration::providesContextHelp() const
110 {
111 return bridge_->providesContextHelp();
112 }
113
114int KDecoration::desktop() const
115 {
116 return bridge_->desktop();
117 }
118
119bool KDecoration::isModal() const
120 {
121 return bridge_->isModal();
122 }
123
124bool KDecoration::isShadeable() const
125 {
126 return bridge_->isShadeable();
127 }
128
129bool KDecoration::isShade() const
130 {
131 return bridge_->isShade();
132 }
133
134bool KDecoration::isSetShade() const
135 {
136 return bridge_->isSetShade();
137 }
138
139bool KDecoration::keepAbove() const
140 {
141 return bridge_->keepAbove();
142 }
143
144bool KDecoration::keepBelow() const
145 {
146 return bridge_->keepBelow();
147 }
148
149bool KDecoration::isMovable() const
150 {
151 return bridge_->isMovable();
152 }
153
154bool KDecoration::isResizable() const
155 {
156 return bridge_->isResizable();
157 }
158
159NET::WindowType KDecoration::windowType( unsigned long supported_types ) const
160 { // this one is also duplicated in KDecorationFactory
161 return bridge_->windowType( supported_types );
162 }
163
164TQIconSet KDecoration::icon() const
165 {
166 return bridge_->icon();
167 }
168
169TQString KDecoration::caption() const
170 {
171 return bridge_->caption();
172 }
173
174void KDecoration::processMousePressEvent( TQMouseEvent* e )
175 {
176 return bridge_->processMousePressEvent( e );
177 }
178
179void KDecoration::showWindowMenu( const TQRect &pos )
180 {
181 bridge_->showWindowMenu( pos );
182 }
183
184void KDecoration::showWindowMenu( TQPoint pos )
185 {
186 bridge_->showWindowMenu( pos );
187 }
188
189void KDecoration::performWindowOperation( WindowOperation op )
190 {
191 bridge_->performWindowOperation( op );
192 }
193
194void KDecoration::setMask( const TQRegion& reg, int mode )
195 {
196 bridge_->setMask( reg, mode );
197 }
198
199void KDecoration::clearMask()
200 {
201 bridge_->setMask( TQRegion(), 0 );
202 }
203
204bool KDecoration::isPreview() const
205 {
206 return bridge_->isPreview();
207 }
208
209TQRect KDecoration::geometry() const
210 {
211 return bridge_->geometry();
212 }
213
214TQRect KDecoration::iconGeometry() const
215 {
216 return bridge_->iconGeometry();
217 }
218
219TQRegion KDecoration::unobscuredRegion( const TQRegion& r ) const
220 {
221 return bridge_->unobscuredRegion( r );
222 }
223
224TQWidget* KDecoration::workspaceWidget() const
225 {
226 return bridge_->workspaceWidget();
227 }
228
229WId KDecoration::windowId() const
230 {
231 return bridge_->windowId();
232 }
233
234void KDecoration::closeWindow()
235 {
236 bridge_->closeWindow();
237 }
238
239void KDecoration::maximize( ButtonState button )
240 {
241 performWindowOperation( options()->operationMaxButtonClick( button ));
242 }
243
244void KDecoration::maximize( MaximizeMode mode )
245 {
246 bridge_->maximize( mode );
247 }
248
249void KDecoration::minimize()
250 {
251 bridge_->minimize();
252 }
253
254void KDecoration::showContextHelp()
255 {
256 bridge_->showContextHelp();
257 }
258
259void KDecoration::setDesktop( int desktop )
260 {
261 bridge_->setDesktop( desktop );
262 }
263
264void KDecoration::toggleOnAllDesktops()
265 {
266 if( isOnAllDesktops())
267 setDesktop( bridge_->currentDesktop());
268 else
269 setDesktop( NET::OnAllDesktops );
270 }
271
272void KDecoration::titlebarDblClickOperation()
273 {
274 bridge_->titlebarDblClickOperation();
275 }
276
277void KDecoration::titlebarMouseWheelOperation( int delta )
278 {
279 bridge_->titlebarMouseWheelOperation( delta );
280 }
281
282void KDecoration::setShade( bool set )
283 {
284 bridge_->setShade( set );
285 }
286
287void KDecoration::setKeepAbove( bool set )
288 {
289 bridge_->setKeepAbove( set );
290 }
291
292void KDecoration::setKeepBelow( bool set )
293 {
294 bridge_->setKeepBelow( set );
295 }
296
297bool KDecoration::drawbound( const TQRect&, bool )
298 {
299 return false;
300 }
301
302bool KDecoration::animateMinimize( bool )
303 {
304 return false;
305 }
306
307bool KDecoration::windowDocked( Position )
308 {
309 return false;
310 }
311
312void KDecoration::helperShowHide( bool show )
313 {
314 bridge_->helperShowHide( show );
315 }
316
317void KDecoration::reset( unsigned long )
318 {
319 }
320
321void KDecoration::grabXServer()
322 {
323 bridge_->grabXServer( true );
324 }
325
326void KDecoration::ungrabXServer()
327 {
328 bridge_->grabXServer( false );
329 }
330
331KDecoration::Position KDecoration::mousePosition( const TQPoint& p ) const
332{
333 const int range = 16;
334 int bleft, bright, btop, bbottom;
335 borders( bleft, bright, btop, bbottom );
336 btop = KMIN( btop, 4 ); // otherwise whole titlebar would have resize cursor
337
338 Position m = PositionCenter;
339
340 if ( ( p.x() > bleft && p.x() < widget()->width() - bright )
341 && ( p.y() > btop && p.y() < widget()->height() - bbottom ) )
342 return PositionCenter;
343
344 if ( p.y() <= KMAX( range, btop ) && p.x() <= KMAX( range, bleft ))
345 m = PositionTopLeft;
346 else if ( p.y() >= widget()->height()- KMAX( range, bbottom )
347 && p.x() >= widget()->width()- KMAX( range, bright ))
348 m = PositionBottomRight;
349 else if ( p.y() >= widget()->height()- KMAX( range, bbottom ) && p.x() <= KMAX( range, bleft ))
350 m = PositionBottomLeft;
351 else if ( p.y() <= KMAX( range, btop ) && p.x() >= widget()->width()- KMAX( range, bright ))
352 m = PositionTopRight;
353 else if ( p.y() <= btop )
354 m = PositionTop;
355 else if ( p.y() >= widget()->height()-bbottom )
356 m = PositionBottom;
357 else if ( p.x() <= bleft )
358 m = PositionLeft;
359 else if ( p.x() >= widget()->width()-bright )
360 m = PositionRight;
361 else
362 m = PositionCenter;
363 return m;
364}
365
366KDecorationOptions::KDecorationOptions()
367 {
368 assert( KDecoration::options_ == NULL );
369 KDecoration::options_ = this;
370 }
371
372KDecorationOptions::~KDecorationOptions()
373 {
374 assert( KDecoration::options_ == this );
375 KDecoration::options_ = NULL;
376 }
377
378const TQColor& KDecorationOptions::color(ColorType type, bool active) const
379{
380 return(d->colors[type + (active ? 0 : NUM_COLORS)]);
381}
382
383const TQFont& KDecorationOptions::font(bool active, bool small) const
384{
385 if ( small )
386 return(active ? d->activeFontSmall : d->inactiveFontSmall);
387 else
388 return(active ? d->activeFont : d->inactiveFont);
389}
390
391const TQColorGroup& KDecorationOptions::colorGroup(ColorType type, bool active) const
392{
393 int idx = type + (active ? 0 : NUM_COLORS);
394 if(d->cg[idx])
395 return(*d->cg[idx]);
396 d->cg[idx] = new TQColorGroup(TQt::black, d->colors[idx], d->colors[idx].light(150),
397 d->colors[idx].dark(), d->colors[idx].dark(120),
398 TQt::black, TQApplication::palette().active().
399 base());
400 return(*d->cg[idx]);
401}
402
403bool KDecorationOptions::customButtonPositions() const
404{
405 return d->custom_button_positions;
406}
407
408TQString KDecorationOptions::titleButtonsLeft() const
409{
410 return d->title_buttons_left;
411}
412
413TQString KDecorationOptions::titleButtonsRight() const
414{
415 return d->title_buttons_right;
416}
417
418bool KDecorationOptions::showTooltips() const
419{
420 return d->show_tooltips;
421}
422
423KDecorationOptions::BorderSize KDecorationOptions::preferredBorderSize( KDecorationFactory* factory ) const
424{
425 assert( factory != NULL );
426 if( d->cached_border_size == BordersCount ) // invalid
427 d->cached_border_size = d->findPreferredBorderSize( d->border_size,
428 factory->borderSizes());
429 return d->cached_border_size;
430}
431
432bool KDecorationOptions::moveResizeMaximizedWindows() const
433{
434 return d->move_resize_maximized_windows;
435}
436
437KDecorationDefines::WindowOperation KDecorationOptions::operationMaxButtonClick( TQt::ButtonState button ) const
438 {
439 return button == TQt::RightButton? d->OpMaxButtonRightClick :
440 button == TQt::MidButton? d->OpMaxButtonMiddleClick :
441 d->OpMaxButtonLeftClick;
442 }
443
444#include "kdecoration.moc"
KDecorationDefines::WindowOperation
WindowOperation
Definition: kdecoration.h:79
KDecorationDefines::Position
Position
These values represent positions inside an area.
Definition: kdecoration.h:54
KDecorationDefines::ColorType
ColorType
Basic color types that should be recognized by all decoration styles.
Definition: kdecoration.h:113
KDecorationDefines::MaximizeMode
MaximizeMode
Maximize mode.
Definition: kdecoration.h:70
KDecorationDefines::BorderSize
BorderSize
Border size.
Definition: kdecoration.h:142
KDecorationOptions
This class holds various configuration settings for the decoration.
Definition: kdecoration.h:191
KDecorationOptions::color
const TQColor & color(ColorType type, bool active=true) const
Returns the color that should be used for the given part of the decoration.
Definition: kdecoration.cpp:378
KDecorationOptions::font
const TQFont & font(bool active=true, bool small=false) const
Returns the active or inactive decoration font.
Definition: kdecoration.cpp:383
KDecorationOptions::showTooltips
bool showTooltips() const
Definition: kdecoration.cpp:418
KDecorationOptions::customButtonPositions
bool customButtonPositions() const
Returns true if the style should use custom button positions The changed flags for this setting is Se...
Definition: kdecoration.cpp:403
KDecorationOptions::preferredBorderSize
BorderSize preferredBorderSize(KDecorationFactory *factory) const
The preferred border size selected by the user, e.g.
Definition: kdecoration.cpp:423
KDecorationOptions::titleButtonsRight
TQString titleButtonsRight() const
If customButtonPositions() returns true, titleButtonsRight returns which buttons should be on the rig...
Definition: kdecoration.cpp:413
KDecorationOptions::titleButtonsLeft
TQString titleButtonsLeft() const
If customButtonPositions() returns true, titleButtonsLeft returns which buttons should be on the left...
Definition: kdecoration.cpp:408
KDecorationOptions::colorGroup
const TQColorGroup & colorGroup(ColorType type, bool active=true) const
Returns a colorgroup using the given decoration color as the background.
Definition: kdecoration.cpp:391
KDecoration::processMousePressEvent
void processMousePressEvent(TQMouseEvent *e)
This function is the default handler for mouse events.
Definition: kdecoration.cpp:174
KDecoration::drawbound
virtual bool drawbound(const TQRect &geom, bool clear)
This function may be reimplemented to provide custom bound drawing for transparent moving or resizing...
Definition: kdecoration.cpp:297
KDecoration::options
static const KDecorationOptions * options()
Returns the KDecorationOptions object, which is used to access configuration settings for the decorat...
Definition: kdecoration.cpp:55
KDecoration::reset
virtual void reset(unsigned long changed)
This function is called to reset the decoration on settings changes.
Definition: kdecoration.cpp:317
KDecoration::isMinimizable
bool isMinimizable() const
Returns true if the decorated window can be minimized by the user.
Definition: kdecoration.cpp:104
KDecoration::KDecoration
KDecoration(KDecorationBridge *bridge, KDecorationFactory *factory)
Constructs a KDecoration object.
Definition: kdecoration.cpp:41
KDecoration::closeWindow
void closeWindow()
This function can be called by the decoration to request closing of the decorated window.
Definition: kdecoration.cpp:234
KDecoration::icon
TQIconSet icon() const
Returns an icon set with the decorated window's icon.
Definition: kdecoration.cpp:164
KDecoration::performWindowOperation
void performWindowOperation(WindowOperation op)
This function performs the given window operation.
Definition: kdecoration.cpp:189
KDecoration::workspaceWidget
TQWidget * workspaceWidget() const
Returns the main workspace widget.
Definition: kdecoration.cpp:224
KDecoration::isModal
bool isModal() const
Returns true if the decoration window is modal (usually a modal dialog).
Definition: kdecoration.cpp:119
KDecoration::setShade
void setShade(bool set)
Shades or unshades the decorated window.
Definition: kdecoration.cpp:282
KDecoration::maximizeMode
MaximizeMode maximizeMode() const
Returns the current maximization mode of the decorated window.
Definition: kdecoration.cpp:99
KDecoration::keepAbove
bool keepAbove() const
Returns true if the decorated window should be kept above other windows.
Definition: kdecoration.cpp:139
KDecoration::isPreview
bool isPreview() const
If this function returns true, the decorated window is used as a preview e.g.
Definition: kdecoration.cpp:204
KDecoration::caption
TQString caption() const
Returns the decorated window's caption that should be shown in the titlebar.
Definition: kdecoration.cpp:169
KDecoration::isShadeable
bool isShadeable() const
Returns true if the decorated window can be shaded.
Definition: kdecoration.cpp:124
KDecoration::isSetShade
bool isSetShade() const
Returns true if the decorated window was set to be shaded.
Definition: kdecoration.cpp:134
KDecoration::setDesktop
void setDesktop(int desktop)
Moves the window to the given desktop.
Definition: kdecoration.cpp:259
KDecoration::showWindowMenu
void showWindowMenu(const TQRect &pos)
This function invokes the window operations menu.
Definition: kdecoration.cpp:179
KDecoration::iconGeometry
TQRect iconGeometry() const
Returns the icon geometry for the window, i.e.
Definition: kdecoration.cpp:214
KDecoration::animateMinimize
virtual bool animateMinimize(bool minimize)
This function may be reimplemented to provide custom minimize/restore animations The reimplementation...
Definition: kdecoration.cpp:302
KDecoration::keepBelow
bool keepBelow() const
Returns true if the decorated window should be kept below other windows.
Definition: kdecoration.cpp:144
KDecoration::geometry
TQRect geometry() const
Returns the geometry of the decoration.
Definition: kdecoration.cpp:209
KDecoration::windowId
WId windowId() const
Returns the handle of the window that is being decorated.
Definition: kdecoration.cpp:229
KDecoration::unobscuredRegion
TQRegion unobscuredRegion(const TQRegion &r) const
Returns the intersection of the given region with the region left unobscured by the windows stacked a...
Definition: kdecoration.cpp:219
KDecoration::showContextHelp
void showContextHelp()
Start showing context help in the window (i.e.
Definition: kdecoration.cpp:254
KDecoration::isMaximizable
bool isMaximizable() const
Returns true if the decorated window can be maximized.
Definition: kdecoration.cpp:94
KDecoration::initialParentWidget
TQWidget * initialParentWidget() const
The parent widget that should be used for the main widget.
Definition: kdecoration.cpp:74
KDecoration::height
int height() const
Convenience function that returns the height of the decoration.
Definition: kdecoration.h:885
KDecoration::isActive
bool isActive() const
Returns true if the decorated window is currently active.
Definition: kdecoration.cpp:84
KDecoration::widget
TQWidget * widget()
Returns the main widget for the decoration.
Definition: kdecoration.h:860
KDecoration::setKeepAbove
void setKeepAbove(bool set)
Sets or reset keeping this window above others.
Definition: kdecoration.cpp:287
KDecoration::createMainWidget
void createMainWidget(TQt::WFlags flags=0)
Convenience functions that creates and sets a main widget as necessary.
Definition: kdecoration.cpp:60
KDecoration::factory
KDecorationFactory * factory() const
Returns the factory that created this decoration.
Definition: kdecoration.h:870
KDecoration::setKeepBelow
void setKeepBelow(bool set)
Sets or reset keeping this window below others.
Definition: kdecoration.cpp:292
KDecoration::minimize
void minimize()
Minimize the decorated window.
Definition: kdecoration.cpp:249
KDecoration::grabXServer
void grabXServer()
Performs X server grab.
Definition: kdecoration.cpp:321
KDecoration::ungrabXServer
void ungrabXServer()
Ungrabs X server (if the number of ungrab attempts matches the number of grab attempts).
Definition: kdecoration.cpp:326
KDecoration::titlebarDblClickOperation
void titlebarDblClickOperation()
This function performs the operation configured as titlebar double click operation.
Definition: kdecoration.cpp:272
KDecoration::initialWFlags
TQt::WFlags initialWFlags() const
The flags that should be used when creating the main widget.
Definition: kdecoration.cpp:79
KDecoration::providesContextHelp
bool providesContextHelp() const
Return true if the decorated window can show context help (i.e.
Definition: kdecoration.cpp:109
KDecoration::desktop
int desktop() const
Returns the number of the virtual desktop the decorated window is currently on (including NET::OnAllD...
Definition: kdecoration.cpp:114
KDecoration::helperShowHide
void helperShowHide(bool show)
This function is only allowed to be called once from animateMinimize().
Definition: kdecoration.cpp:312
KDecoration::isShade
bool isShade() const
Returns true if the decorated window is currently shaded.
Definition: kdecoration.cpp:129
KDecoration::isCloseable
bool isCloseable() const
Returns true if the decoration window can be closed by the user.
Definition: kdecoration.cpp:89
KDecoration::isMovable
bool isMovable() const
Returns true if the decorated window can be moved by the user.
Definition: kdecoration.cpp:149
KDecoration::isOnAllDesktops
bool isOnAllDesktops() const
Convenience function that returns true if the window is on all virtual desktops.
Definition: kdecoration.h:875
KDecoration::setMask
void setMask(const TQRegion &reg, int mode=0)
If the decoration is non-rectangular, this function needs to be called to set the shape of the decora...
Definition: kdecoration.cpp:194
KDecoration::isResizable
bool isResizable() const
Returns true if the decorated window can be resized by the user.
Definition: kdecoration.cpp:154
KDecoration::~KDecoration
virtual ~KDecoration()
Destroys the KDecoration.
Definition: kdecoration.cpp:49
KDecoration::titlebarMouseWheelOperation
void titlebarMouseWheelOperation(int delta)
This function performs the operation configured as titlebar wheel mouse operation.
Definition: kdecoration.cpp:277
KDecoration::toggleOnAllDesktops
void toggleOnAllDesktops()
This function toggles the on-all-desktops state of the decorated window.
Definition: kdecoration.cpp:264
KDecoration::windowType
NET::WindowType windowType(unsigned long supported_types) const
This function returns the window type of the decorated window.
Definition: kdecoration.cpp:159
KDecoration::mousePosition
virtual Position mousePosition(const TQPoint &p) const =0
This function should return mouse cursor position in the decoration.
Definition: kdecoration.cpp:331
KDecoration::width
int width() const
Convenience function that returns the width of the decoration.
Definition: kdecoration.h:880
KDecoration::borders
virtual void borders(int &left, int &right, int &top, int &bottom) const =0
This function should return the distance from each window side to the inner window.
KDecoration::setMainWidget
void setMainWidget(TQWidget *)
This should be the first function called in init() to specify the main widget of the decoration.
Definition: kdecoration.cpp:66
KDecoration::clearMask
void clearMask()
This convenience function resets the shape mask.
Definition: kdecoration.cpp:199

twin/lib

Skip menu "twin/lib"
  • Main Page
  • Class Hierarchy
  • Alphabetical List
  • Class List
  • File List
  • Class Members
  • Related Pages

twin/lib

Skip menu "twin/lib"
  • kate
  • libkonq
  • twin
  •   lib
Generated for twin/lib by doxygen 1.9.4
This website is maintained by Timothy Pearson.