kwin 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;
00357         bool isShade() const;
00365         bool isSetShade() const;
00369         bool keepAbove() const;
00373         bool keepBelow() const;
00377         bool isMovable() const;
00381         bool isResizable() const;
00405         NET::WindowType windowType( unsigned long supported_types ) const;
00409     QIconSet icon() const;
00413     QString caption() const;
00440     void showWindowMenu( const QRect &pos );
00441 
00445     void showWindowMenu( QPoint pos );
00450     void performWindowOperation( WindowOperation op );
00459         void setMask( const QRegion& reg, int mode = 0 );
00463         void clearMask(); // convenience
00469         bool isPreview() const;
00473         QRect geometry() const;
00479         QRect iconGeometry() const;
00488         QRegion unobscuredRegion( const QRegion& r ) const;
00493         QWidget* workspaceWidget() const;
00497         int width() const; // convenience
00501         int height() const;  // convenience
00507     void processMousePressEvent( QMouseEvent* e );
00508 
00509     // requests to decoration
00510 
00516         virtual void init() = 0; // called once right after created
00517     
00523     virtual Position mousePosition( const QPoint& p ) const = 0;
00524 
00537         // mustn't do any repaints, resizes or anything like that
00538     virtual void borders( int& left, int& right, int& top, int& bottom ) const = 0;
00546     virtual void resize( const QSize& s ) = 0;
00552     virtual QSize minimumSize() const = 0;
00557         virtual void activeChange() = 0;
00561         virtual void captionChange() = 0;
00565         virtual void iconChange() = 0;
00570         virtual void maximizeChange() = 0;
00576         virtual void desktopChange() = 0;
00581         virtual void shadeChange() = 0;
00582 #if KDE_IS_VERSION( 3, 90, 0 )
00583 #warning Redo all the XYZChange() virtuals as signals.
00584 #endif
00585     signals:
00590         void keepAboveChanged( bool );
00595         void keepBelowChanged( bool );
00596     public:
00610         virtual bool drawbound( const QRect& geom, bool clear );
00621         virtual bool animateMinimize( bool minimize );
00625         // TODO position will need also values for top+left+bottom etc. docking ?
00626         virtual bool windowDocked( Position side );
00633         virtual void reset( unsigned long changed );
00634 
00635     // special
00636 
00643         void setMainWidget( QWidget* );
00653         void createMainWidget( WFlags flags = 0 );
00657         QWidget* initialParentWidget() const;
00664         WFlags initialWFlags() const;
00671         void helperShowHide( bool show );
00675     QWidget* widget();
00679     const QWidget* widget() const;
00683         KDecorationFactory* factory() const;
00687         void grabXServer();
00691         void ungrabXServer();
00692     public slots:
00693     // requests from decoration
00694 
00702     void closeWindow();
00703         /*
00704          * Changes the maximize mode of the decorated window. This function should
00705          * be preferred to the other maximize() overload for reacting on clicks
00706          * on the maximize titlebar button.
00707          * NOTE: This function is new in KDE3.3. In order to support also KDE3.2,
00708          * it is recommended to use code like this:
00709          * \code
00710          * ButtonState button = ... ;
00711          * #if KDE_IS_VERSION( 3, 3, 0 )
00712          * maximize( button );
00713          * #else
00714          * if( button == MidButton )
00715      *     maximize( maximizeMode() ^ MaximizeVertical );
00716          * else if( button == RightButton )
00717          *     maximize( maximizeMode() ^ MaximizeHorizontal );
00718          * else
00719          *     maximize( maximizeMode() == MaximizeFull ? MaximizeRestore : MaximizeFull );
00720          * #endif
00721          * \endcode
00722          * @since 3.3
00723          */
00724 #if KDE_IS_VERSION( 3, 90, 0 )
00725 #warning Update the docs.
00726 #endif
00727         void maximize( ButtonState button );
00732     void maximize( MaximizeMode mode );
00736     void minimize();
00741         void showContextHelp();
00746         void setDesktop( int desktop );
00750         void toggleOnAllDesktops(); // convenience
00755         void titlebarDblClickOperation();
00760         void setShade( bool set );
00765         void setKeepAbove( bool set );
00770         void setKeepBelow( bool set );
00774         void emitKeepAboveChanged( bool above ) { emit keepAboveChanged( above ); }
00778         void emitKeepBelowChanged( bool below ) { emit keepBelowChanged( below ); }
00779     private:
00780     KDecorationBridge* bridge_;
00781     QWidget* w_;
00782         KDecorationFactory* factory_;
00783         friend class KDecorationOptions; // for options_
00784         static KDecorationOptions* options_;
00785         KDecorationPrivate* d;
00786     };
00787 
00788 inline
00789 KDecorationDefines::MaximizeMode operator^( KDecorationDefines::MaximizeMode m1, KDecorationDefines::MaximizeMode m2 )
00790     {
00791     return KDecorationDefines::MaximizeMode( int(m1) ^ int(m2) );
00792     }
00793 
00794 inline
00795 KDecorationDefines::MaximizeMode operator&( KDecorationDefines::MaximizeMode m1, KDecorationDefines::MaximizeMode m2 )
00796     {
00797     return KDecorationDefines::MaximizeMode( int(m1) & int(m2) );
00798     }
00799 
00800 inline
00801 KDecorationDefines::MaximizeMode operator|( KDecorationDefines::MaximizeMode m1, KDecorationDefines::MaximizeMode m2 )
00802     {
00803     return KDecorationDefines::MaximizeMode( int(m1) | int(m2) );
00804     }
00805 
00806 inline QWidget* KDecoration::widget()
00807     {
00808     return w_;
00809     }
00810 
00811 inline const QWidget* KDecoration::widget() const
00812     {
00813     return w_;
00814     }
00815 
00816 inline KDecorationFactory* KDecoration::factory() const
00817     {
00818     return factory_;
00819     }
00820 
00821 inline bool KDecoration::isOnAllDesktops() const
00822     {
00823     return desktop() == NET::OnAllDesktops;
00824     }
00825 
00826 inline int KDecoration::width() const
00827     {
00828     return geometry().width();
00829     }
00830     
00831 inline int KDecoration::height() const
00832     {
00833     return geometry().height();
00834     }
00835     
00836 #endif
KDE Logo
This file is part of the documentation for kwin Library Version 3.3.2.
Documentation copyright © 1996-2004 the KDE developers.
Generated on Sun Aug 20 13:39:11 2006 by doxygen 1.4.2 written by Dimitri van Heesch, © 1997-2003