kdecoration.cpp
00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025 #include "kdecoration.h"
00026
00027 #include <kdebug.h>
00028 #include <qapplication.h>
00029 #include <assert.h>
00030 #if defined Q_WS_X11 && ! defined K_WS_QTONLY
00031 #include <X11/Xlib.h>
00032 #include <fixx11h.h>
00033 #endif
00034
00035 #include "kdecoration_p.h"
00036 #include "kdecorationfactory.h"
00037
00038 KDecorationOptions* KDecoration::options_;
00039
00040 KDecoration::KDecoration( KDecorationBridge* bridge, KDecorationFactory* factory )
00041 : bridge_( bridge ),
00042 w_( NULL ),
00043 factory_( factory )
00044 {
00045 factory->addDecoration( this );
00046 }
00047
00048 KDecoration::~KDecoration()
00049 {
00050 factory()->removeDecoration( this );
00051 delete w_;
00052 }
00053
00054 const KDecorationOptions* KDecoration::options()
00055 {
00056 return options_;
00057 }
00058
00059 void KDecoration::createMainWidget( WFlags flags )
00060 {
00061
00062 setMainWidget( new QWidget( initialParentWidget(), "decoration widget", initialWFlags() | flags ));
00063 }
00064
00065 void KDecoration::setMainWidget( QWidget* w )
00066 {
00067 assert( w_ == NULL );
00068 w_ = w;
00069 w->setMouseTracking( true );
00070 widget()->resize( geometry().size());
00071 }
00072
00073 QWidget* KDecoration::initialParentWidget() const
00074 {
00075 return bridge_->initialParentWidget();
00076 }
00077
00078 Qt::WFlags KDecoration::initialWFlags() const
00079 {
00080 return bridge_->initialWFlags();
00081 }
00082
00083 bool KDecoration::isActive() const
00084 {
00085 return bridge_->isActive();
00086 }
00087
00088 bool KDecoration::isCloseable() const
00089 {
00090 return bridge_->isCloseable();
00091 }
00092
00093 bool KDecoration::isMaximizable() const
00094 {
00095 return bridge_->isMaximizable();
00096 }
00097
00098 KDecoration::MaximizeMode KDecoration::maximizeMode() const
00099 {
00100 return bridge_->maximizeMode();
00101 }
00102
00103 bool KDecoration::isMinimizable() const
00104 {
00105 return bridge_->isMinimizable();
00106 }
00107
00108 bool KDecoration::providesContextHelp() const
00109 {
00110 return bridge_->providesContextHelp();
00111 }
00112
00113 int KDecoration::desktop() const
00114 {
00115 return bridge_->desktop();
00116 }
00117
00118 bool KDecoration::isModal() const
00119 {
00120 return bridge_->isModal();
00121 }
00122
00123 bool KDecoration::isShadeable() const
00124 {
00125 return bridge_->isShadeable();
00126 }
00127
00128 bool KDecoration::isShade() const
00129 {
00130 return bridge_->isShade();
00131 }
00132
00133 bool KDecoration::isSetShade() const
00134 {
00135 return bridge_->isSetShade();
00136 }
00137
00138 bool KDecoration::keepAbove() const
00139 {
00140 return bridge_->keepAbove();
00141 }
00142
00143 bool KDecoration::keepBelow() const
00144 {
00145 return bridge_->keepBelow();
00146 }
00147
00148 bool KDecoration::isMovable() const
00149 {
00150 return bridge_->isMovable();
00151 }
00152
00153 bool KDecoration::isResizable() const
00154 {
00155 return bridge_->isResizable();
00156 }
00157
00158 NET::WindowType KDecoration::windowType( unsigned long supported_types ) const
00159 {
00160 return bridge_->windowType( supported_types );
00161 }
00162
00163 QIconSet KDecoration::icon() const
00164 {
00165 return bridge_->icon();
00166 }
00167
00168 QString KDecoration::caption() const
00169 {
00170 return bridge_->caption();
00171 }
00172
00173 void KDecoration::processMousePressEvent( QMouseEvent* e )
00174 {
00175 return bridge_->processMousePressEvent( e );
00176 }
00177
00178 void KDecoration::showWindowMenu( QPoint pos )
00179 {
00180 bridge_->showWindowMenu( pos );
00181 }
00182
00183 void KDecoration::performWindowOperation( WindowOperation op )
00184 {
00185 bridge_->performWindowOperation( op );
00186 }
00187
00188 void KDecoration::setMask( const QRegion& reg, int mode )
00189 {
00190 bridge_->setMask( reg, mode );
00191 }
00192
00193 void KDecoration::clearMask()
00194 {
00195 bridge_->setMask( QRegion(), 0 );
00196 }
00197
00198 bool KDecoration::isPreview() const
00199 {
00200 return bridge_->isPreview();
00201 }
00202
00203 QRect KDecoration::geometry() const
00204 {
00205 return bridge_->geometry();
00206 }
00207
00208 QRect KDecoration::iconGeometry() const
00209 {
00210 return bridge_->iconGeometry();
00211 }
00212
00213 QRegion KDecoration::unobscuredRegion( const QRegion& r ) const
00214 {
00215 return bridge_->unobscuredRegion( r );
00216 }
00217
00218 QWidget* KDecoration::workspaceWidget() const
00219 {
00220 return bridge_->workspaceWidget();
00221 }
00222
00223 void KDecoration::closeWindow()
00224 {
00225 bridge_->closeWindow();
00226 }
00227
00228 void KDecoration::maximize( MaximizeMode mode )
00229 {
00230 bridge_->maximize( mode );
00231 }
00232
00233 void KDecoration::minimize()
00234 {
00235 bridge_->minimize();
00236 }
00237
00238 void KDecoration::showContextHelp()
00239 {
00240 bridge_->showContextHelp();
00241 }
00242
00243 void KDecoration::setDesktop( int desktop )
00244 {
00245 bridge_->setDesktop( desktop );
00246 }
00247
00248 void KDecoration::toggleOnAllDesktops()
00249 {
00250 if( isOnAllDesktops())
00251 setDesktop( bridge_->currentDesktop());
00252 else
00253 setDesktop( NET::OnAllDesktops );
00254 }
00255
00256 void KDecoration::titlebarDblClickOperation()
00257 {
00258 bridge_->titlebarDblClickOperation();
00259 }
00260
00261 void KDecoration::setShade( bool set )
00262 {
00263 bridge_->setShade( set );
00264 }
00265
00266 void KDecoration::setKeepAbove( bool set )
00267 {
00268 bridge_->setKeepAbove( set );
00269 }
00270
00271 void KDecoration::setKeepBelow( bool set )
00272 {
00273 bridge_->setKeepBelow( set );
00274 }
00275
00276 bool KDecoration::drawbound( const QRect&, bool )
00277 {
00278 return false;
00279 }
00280
00281 bool KDecoration::animateMinimize( bool )
00282 {
00283 return false;
00284 }
00285
00286 bool KDecoration::windowDocked( Position )
00287 {
00288 return false;
00289 }
00290
00291 void KDecoration::helperShowHide( bool show )
00292 {
00293 bridge_->helperShowHide( show );
00294 }
00295
00296 void KDecoration::reset( unsigned long )
00297 {
00298 }
00299
00300 void KDecoration::grabXServer()
00301 {
00302 bridge_->grabXServer( true );
00303 }
00304
00305 void KDecoration::ungrabXServer()
00306 {
00307 bridge_->grabXServer( false );
00308 }
00309
00310 KDecoration::Position KDecoration::mousePosition( const QPoint& p ) const
00311 {
00312 const int range = 16;
00313 const int border = 4;
00314
00315 Position m = PositionCenter;
00316
00317
00318 if ( ( p.x() > border && p.x() < widget()->width() - border )
00319 && ( p.y() > border && p.y() < widget()->height() - border ) )
00320 return PositionCenter;
00321
00322 if ( p.y() <= range && p.x() <= range)
00323 m = PositionTopLeft;
00324 else if ( p.y() >= widget()->height()-range && p.x() >= widget()->width()-range)
00325 m = PositionBottomRight;
00326 else if ( p.y() >= widget()->height()-range && p.x() <= range)
00327 m = PositionBottomLeft;
00328 else if ( p.y() <= range && p.x() >= widget()->width()-range)
00329 m = PositionTopRight;
00330 else if ( p.y() <= border )
00331 m = PositionTop;
00332 else if ( p.y() >= widget()->height()-border )
00333 m = PositionBottom;
00334 else if ( p.x() <= border )
00335 m = PositionLeft;
00336 else if ( p.x() >= widget()->width()-border )
00337 m = PositionRight;
00338 else
00339 m = PositionCenter;
00340 return m;
00341 }
00342
00343 KDecorationOptions::KDecorationOptions()
00344 {
00345 assert( KDecoration::options_ == NULL );
00346 KDecoration::options_ = this;
00347 }
00348
00349 KDecorationOptions::~KDecorationOptions()
00350 {
00351 assert( KDecoration::options_ == this );
00352 KDecoration::options_ = NULL;
00353 }
00354
00355 const QColor& KDecorationOptions::color(ColorType type, bool active) const
00356 {
00357 return(d->colors[type + (active ? 0 : NUM_COLORS)]);
00358 }
00359
00360 const QFont& KDecorationOptions::font(bool active, bool small) const
00361 {
00362 if ( small )
00363 return(active ? d->activeFontSmall : d->inactiveFontSmall);
00364 else
00365 return(active ? d->activeFont : d->inactiveFont);
00366 }
00367
00368 const QColorGroup& KDecorationOptions::colorGroup(ColorType type, bool active) const
00369 {
00370 int idx = type + (active ? 0 : NUM_COLORS);
00371 if(d->cg[idx])
00372 return(*d->cg[idx]);
00373 d->cg[idx] = new QColorGroup(Qt::black, d->colors[idx], d->colors[idx].light(150),
00374 d->colors[idx].dark(), d->colors[idx].dark(120),
00375 Qt::black, QApplication::palette().active().
00376 base());
00377 return(*d->cg[idx]);
00378 }
00379
00380 bool KDecorationOptions::customButtonPositions() const
00381 {
00382 return d->custom_button_positions;
00383 }
00384
00385 QString KDecorationOptions::titleButtonsLeft() const
00386 {
00387 return d->title_buttons_left;
00388 }
00389
00390 QString KDecorationOptions::titleButtonsRight() const
00391 {
00392 return d->title_buttons_right;
00393 }
00394
00395 bool KDecorationOptions::showTooltips() const
00396 {
00397 return d->show_tooltips;
00398 }
00399
00400 KDecorationOptions::BorderSize KDecorationOptions::preferredBorderSize( KDecorationFactory* factory ) const
00401 {
00402 assert( factory != NULL );
00403 if( d->cached_border_size == BordersCount )
00404 d->cached_border_size = d->findPreferredBorderSize( d->border_size,
00405 factory->borderSizes());
00406 return d->cached_border_size;
00407 }
00408
00409 bool KDecorationOptions::moveResizeMaximizedWindows() const
00410 {
00411 return d->move_resize_maximized_windows;
00412 }
00413
00414 #include "kdecoration.moc"
This file is part of the documentation for kwin Library Version 3.2.1.
Documentation copyright © 1996-2004 the KDE developers.
Generated on Fri Mar 5 04:41:13 2004 by
doxygen 1.3.6-20040222 written by
Dimitri van Heesch, © 1997-2003