kwin/lib Library API Documentation

kdecoration.h

00001 /***************************************************************** 00002 This file is part of the KDE project. 00003 00004 Copyright (C) 2003 Lubos Lunak <l.lunak@kde.org> 00005 00006 Permission is hereby granted, free of charge, to any person obtaining a 00007 copy of this software and associated documentation files (the "Software"), 00008 to deal in the Software without restriction, including without limitation 00009 the rights to use, copy, modify, merge, publish, distribute, sublicense, 00010 and/or sell copies of the Software, and to permit persons to whom the 00011 Software is furnished to do so, subject to the following conditions: 00012 00013 The above copyright notice and this permission notice shall be included in 00014 all copies or substantial portions of the Software. 00015 00016 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 00017 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 00018 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 00019 THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 00020 LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 00021 FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 00022 DEALINGS IN THE SOFTWARE. 00023 ******************************************************************/ 00024 00025 #ifndef KDECORATION_H 00026 #define KDECORATION_H 00027 00028 #include <qcolor.h> 00029 #include <qfont.h> 00030 #include <qobject.h> 00031 #include <qiconset.h> 00032 #include <netwm_def.h> 00033 #include <kdeversion.h> 00034 00035 class KDecorationOptionsPrivate; 00036 class KDecorationBridge; 00037 class KDecorationPrivate; 00038 class KDecorationFactory; 00039 00045 class KDecorationDefines 00046 { 00047 public: 00051 enum Position 00052 { // without prefix, they'd conflict with Qt::TopLeft etc. :( 00053 PositionCenter = 0x00, 00054 PositionLeft = 0x01, 00055 PositionRight = 0x02, 00056 PositionTop = 0x04, 00057 PositionBottom = 0x08, 00058 PositionTopLeft = PositionLeft | PositionTop, 00059 PositionTopRight = PositionRight | PositionTop, 00060 PositionBottomLeft = PositionLeft | PositionBottom, 00061 PositionBottomRight = PositionRight | PositionBottom 00062 }; 00066 // these values are written to session files, don't change the order 00067 enum MaximizeMode 00068 { 00069 MaximizeRestore = 0, 00070 MaximizeVertical = 1, 00071 MaximizeHorizontal = 2, 00072 00073 MaximizeFull = MaximizeVertical | MaximizeHorizontal 00074 }; 00075 00076 enum WindowOperation 00077 { 00078 MaximizeOp = 5000, 00079 RestoreOp, 00080 MinimizeOp, 00081 MoveOp, 00082 UnrestrictedMoveOp, 00083 ResizeOp, 00084 UnrestrictedResizeOp, 00085 CloseOp, 00086 OnAllDesktopsOp, 00087 ShadeOp, 00088 KeepAboveOp, 00089 KeepBelowOp, 00090 OperationsOp, 00091 WindowRulesOp, 00092 ToggleStoreSettingsOp = WindowRulesOp, 00093 HMaximizeOp, 00094 VMaximizeOp, 00095 LowerOp, 00096 FullScreenOp, 00097 NoBorderOp, 00098 NoOp 00099 }; 00105 enum ColorType 00106 { 00107 ColorTitleBar, 00108 ColorTitleBlend, 00109 ColorFont, 00110 ColorButtonBg, 00111 ColorFrame, 00112 ColorHandle, 00113 NUM_COLORS 00114 }; 00115 00120 enum 00121 { 00122 SettingDecoration = 1 << 0, 00123 SettingColors = 1 << 1, 00124 SettingFont = 1 << 2, 00125 SettingButtons = 1 << 3, 00126 SettingTooltips = 1 << 4, 00127 SettingBorder = 1 << 5 00128 }; 00129 00134 enum BorderSize 00135 { 00136 BorderTiny, 00137 BorderNormal, 00138 BorderLarge, 00139 BorderVeryLarge, 00140 BorderHuge, 00141 BorderVeryHuge, 00142 BorderOversized, 00143 BordersCount 00144 }; 00145 00146 enum Ability { ABILITY_DUMMY = 10000000 }; 00147 00148 enum Requirement { REQUIREMENT_DUMMY = 1000000 }; 00149 }; 00150 00151 class KDecorationProvides 00152 : public KDecorationDefines 00153 { 00154 public: 00155 virtual bool provides( Requirement req ) = 0; 00156 }; 00157 00164 class KDecorationOptions : public KDecorationDefines 00165 { 00166 public: 00167 KDecorationOptions(); 00168 virtual ~KDecorationOptions(); 00176 const QColor& color(ColorType type, bool active=true) const; 00184 const QColorGroup& colorGroup(ColorType type, bool active=true) const; 00192 const QFont& font(bool active=true, bool small = false) const; 00200 bool customButtonPositions() const; 00220 // FRAME vice druhu tlacitek 00221 QString titleButtonsLeft() const; 00232 QString titleButtonsRight() const; 00233 00238 bool showTooltips() const; 00239 00250 BorderSize preferredBorderSize( KDecorationFactory* factory ) const; 00251 00252 /* 00253 * When this functions returns false, moving and resizing of maximized windows 00254 * is not allowed, and therefore the decoration is allowed to turn off (some of) 00255 * its borders. 00256 * The changed flags for this setting is SettingButtons. 00257 */ 00258 bool moveResizeMaximizedWindows() const; 00259 00263 virtual unsigned long updateSettings() = 0; // returns SettingXYZ mask 00264 00265 protected: 00269 KDecorationOptionsPrivate* d; 00270 }; 00271 00272 00280 class KDecoration 00281 : public QObject, public KDecorationDefines 00282 { 00283 Q_OBJECT 00284 public: 00290 KDecoration( KDecorationBridge* bridge, KDecorationFactory* factory ); 00294 virtual ~KDecoration(); 00295 00296 // requests from decoration 00297 00302 static const KDecorationOptions* options(); 00306 bool isActive() const; 00310 bool isCloseable() const; 00314 bool isMaximizable() const; 00320 MaximizeMode maximizeMode() const; 00324 bool isMinimizable() const; 00329 bool providesContextHelp() const; 00335 int desktop() const; 00340 bool isOnAllDesktops() const; // convenience 00344 bool isModal() const; 00348 bool isShadeable() const; 00355 bool isShade() const; 00363 bool isSetShade() const; 00367 bool keepAbove() const; 00371 bool keepBelow() const; 00375 bool isMovable() const; 00379 bool isResizable() const; 00403 NET::WindowType windowType( unsigned long supported_types ) const; 00407 QIconSet icon() const; 00411 QString caption() const; 00438 void showWindowMenu( const QRect &pos ); 00439 00443 void showWindowMenu( QPoint pos ); 00448 void performWindowOperation( WindowOperation op ); 00457 void setMask( const QRegion& reg, int mode = 0 ); 00461 void clearMask(); // convenience 00467 bool isPreview() const; 00471 QRect geometry() const; 00477 QRect iconGeometry() const; 00486 QRegion unobscuredRegion( const QRegion& r ) const; 00491 QWidget* workspaceWidget() const; 00495 int width() const; // convenience 00499 int height() const; // convenience 00505 void processMousePressEvent( QMouseEvent* e ); 00506 00507 // requests to decoration 00508 00514 virtual void init() = 0; // called once right after created 00515 00521 virtual Position mousePosition( const QPoint& p ) const = 0; 00522 00535 // mustn't do any repaints, resizes or anything like that 00536 virtual void borders( int& left, int& right, int& top, int& bottom ) const = 0; 00544 virtual void resize( const QSize& s ) = 0; 00550 virtual QSize minimumSize() const = 0; 00555 virtual void activeChange() = 0; 00559 virtual void captionChange() = 0; 00563 virtual void iconChange() = 0; 00568 virtual void maximizeChange() = 0; 00574 virtual void desktopChange() = 0; 00579 virtual void shadeChange() = 0; 00580 #if KDE_IS_VERSION( 3, 90, 0 ) 00581 #warning Redo all the XYZChange() virtuals as signals. 00582 #endif 00583 signals: 00588 void keepAboveChanged( bool ); 00593 void keepBelowChanged( bool ); 00594 public: 00605 virtual bool drawbound( const QRect& geom, bool clear ); 00616 virtual bool animateMinimize( bool minimize ); 00620 // TODO position will need also values for top+left+bottom etc. docking ? 00621 virtual bool windowDocked( Position side ); 00628 virtual void reset( unsigned long changed ); 00629 00630 // special 00631 00638 void setMainWidget( QWidget* ); 00648 void createMainWidget( WFlags flags = 0 ); 00652 QWidget* initialParentWidget() const; 00659 WFlags initialWFlags() const; 00666 void helperShowHide( bool show ); 00670 QWidget* widget(); 00674 const QWidget* widget() const; 00678 KDecorationFactory* factory() const; 00682 void grabXServer(); 00686 void ungrabXServer(); 00687 public slots: 00688 // requests from decoration 00689 00697 void closeWindow(); 00698 /* 00699 * Changes the maximize mode of the decorated window. This function should 00700 * be preferred to the other maximize() overload for reacting on clicks 00701 * on the maximize titlebar button. 00702 * NOTE: This function is new in KDE3.3. In order to support also KDE3.2, 00703 * it is recommended to use code like this: 00704 * \code 00705 * ButtonState button = ... ; 00706 * #if KDE_IS_VERSION( 3, 3, 0 ) 00707 * maximize( button ); 00708 * #else 00709 * if( button == MidButton ) 00710 * maximize( maximizeMode() ^ MaximizeVertical ); 00711 * else if( button == RightButton ) 00712 * maximize( maximizeMode() ^ MaximizeHorizontal ); 00713 * else 00714 * maximize( maximizeMode() == MaximizeFull ? MaximizeRestore : MaximizeFull ); 00715 * #endif 00716 * \endcode 00717 * @since 3.3 00718 */ 00719 #if KDE_IS_VERSION( 3, 90, 0 ) 00720 #warning Update the docs. 00721 #endif 00722 void maximize( ButtonState button ); 00727 void maximize( MaximizeMode mode ); 00731 void minimize(); 00736 void showContextHelp(); 00741 void setDesktop( int desktop ); 00745 void toggleOnAllDesktops(); // convenience 00750 void titlebarDblClickOperation(); 00755 void setShade( bool set ); 00760 void setKeepAbove( bool set ); 00765 void setKeepBelow( bool set ); 00769 void emitKeepAboveChanged( bool above ) { emit keepAboveChanged( above ); } 00773 void emitKeepBelowChanged( bool below ) { emit keepBelowChanged( below ); } 00774 private: 00775 KDecorationBridge* bridge_; 00776 QWidget* w_; 00777 KDecorationFactory* factory_; 00778 friend class KDecorationOptions; // for options_ 00779 static KDecorationOptions* options_; 00780 KDecorationPrivate* d; 00781 }; 00782 00783 inline 00784 KDecorationDefines::MaximizeMode operator^( KDecorationDefines::MaximizeMode m1, KDecorationDefines::MaximizeMode m2 ) 00785 { 00786 return KDecorationDefines::MaximizeMode( int(m1) ^ int(m2) ); 00787 } 00788 00789 inline 00790 KDecorationDefines::MaximizeMode operator&( KDecorationDefines::MaximizeMode m1, KDecorationDefines::MaximizeMode m2 ) 00791 { 00792 return KDecorationDefines::MaximizeMode( int(m1) & int(m2) ); 00793 } 00794 00795 inline 00796 KDecorationDefines::MaximizeMode operator|( KDecorationDefines::MaximizeMode m1, KDecorationDefines::MaximizeMode m2 ) 00797 { 00798 return KDecorationDefines::MaximizeMode( int(m1) | int(m2) ); 00799 } 00800 00801 inline QWidget* KDecoration::widget() 00802 { 00803 return w_; 00804 } 00805 00806 inline const QWidget* KDecoration::widget() const 00807 { 00808 return w_; 00809 } 00810 00811 inline KDecorationFactory* KDecoration::factory() const 00812 { 00813 return factory_; 00814 } 00815 00816 inline bool KDecoration::isOnAllDesktops() const 00817 { 00818 return desktop() == NET::OnAllDesktops; 00819 } 00820 00821 inline int KDecoration::width() const 00822 { 00823 return geometry().width(); 00824 } 00825 00826 inline int KDecoration::height() const 00827 { 00828 return geometry().height(); 00829 } 00830 00831 #endif
KDE Logo
This file is part of the documentation for kwin/lib Library Version 3.3.0.
Documentation copyright © 1996-2004 the KDE developers.
Generated on Fri Aug 13 21:47:07 2004 by doxygen 1.3.8 written by Dimitri van Heesch, © 1997-2003