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 #include <kdemacros.h>
00035 
00036 #define KWIN_EXPORT KDE_EXPORT
00037 
00038 class KDecorationOptionsPrivate;
00039 class KDecorationBridge;
00040 class KDecorationPrivate;
00041 class KDecorationFactory;
00042 
00048 class KWIN_EXPORT KDecorationDefines
00049 {
00050 public:
00054     enum Position
00055         { // without prefix, they'd conflict with Qt::TopLeft etc. :(
00056         PositionCenter         = 0x00,
00057         PositionLeft           = 0x01,
00058         PositionRight          = 0x02,
00059         PositionTop            = 0x04,
00060         PositionBottom         = 0x08,
00061         PositionTopLeft        = PositionLeft | PositionTop,
00062         PositionTopRight       = PositionRight | PositionTop,
00063         PositionBottomLeft     = PositionLeft | PositionBottom,
00064         PositionBottomRight    = PositionRight | PositionBottom
00065         };
00069     // these values are written to session files, don't change the order
00070     enum MaximizeMode
00071         {
00072     MaximizeRestore    = 0, 
00073     MaximizeVertical   = 1, 
00074     MaximizeHorizontal = 2, 
00075 
00076     MaximizeFull = MaximizeVertical | MaximizeHorizontal 
00077         };
00078 
00079     enum WindowOperation
00080         {
00081         MaximizeOp = 5000,
00082         RestoreOp,
00083         MinimizeOp,
00084         MoveOp,
00085         UnrestrictedMoveOp,
00086         ResizeOp,
00087         UnrestrictedResizeOp,
00088         CloseOp,
00089         OnAllDesktopsOp,
00090         ShadeOp,
00091         KeepAboveOp,
00092         KeepBelowOp,
00093         OperationsOp,
00094         WindowRulesOp,
00095         ToggleStoreSettingsOp = WindowRulesOp, 
00096         HMaximizeOp,
00097         VMaximizeOp,
00098         LowerOp,
00099         FullScreenOp,
00100         NoBorderOp,
00101         NoOp
00102         };
00108     enum ColorType
00109     {
00110     ColorTitleBar,   
00111     ColorTitleBlend, 
00112     ColorFont,       
00113     ColorButtonBg,   
00114     ColorFrame,      
00115     ColorHandle,     
00116     NUM_COLORS
00117     };
00118     
00123     enum
00124         {
00125         SettingDecoration = 1 << 0, 
00126         SettingColors     = 1 << 1, 
00127         SettingFont       = 1 << 2, 
00128         SettingButtons    = 1 << 3, 
00129         SettingTooltips   = 1 << 4, 
00130         SettingBorder     = 1 << 5  
00131         };
00132         
00137     enum BorderSize
00138         {
00139         BorderTiny,      
00140         BorderNormal,    
00141         BorderLarge,     
00142         BorderVeryLarge, 
00143         BorderHuge,      
00144         BorderVeryHuge,  
00145         BorderOversized, 
00146         BordersCount     
00147         };
00148 
00149     enum Ability { ABILITY_DUMMY = 10000000 };
00150 
00151     enum Requirement { REQUIREMENT_DUMMY = 1000000 };
00152 };    
00153 
00154 class KDecorationProvides
00155     : public KDecorationDefines
00156     {
00157     public:
00158         virtual bool provides( Requirement req ) = 0;
00159     };
00160 
00167 class KWIN_EXPORT KDecorationOptions : public KDecorationDefines
00168     {
00169 public:
00170     KDecorationOptions();
00171     virtual ~KDecorationOptions();
00179     const QColor& color(ColorType type, bool active=true) const;
00187     const QColorGroup& colorGroup(ColorType type, bool active=true) const;
00195     const QFont& font(bool active=true, bool small = false) const;
00203     bool customButtonPositions() const;
00223     // FRAME vice druhu tlacitek
00224     QString titleButtonsLeft() const;
00235     QString titleButtonsRight() const;
00236 
00241     bool showTooltips() const;
00242     
00253     BorderSize preferredBorderSize( KDecorationFactory* factory ) const;
00254 
00255     /*
00256      * When this functions returns false, moving and resizing of maximized windows
00257      * is not allowed, and therefore the decoration is allowed to turn off (some of)
00258      * its borders.
00259      * The changed flags for this setting is SettingButtons.
00260      */
00261     bool moveResizeMaximizedWindows() const;
00262 
00266     virtual unsigned long updateSettings() = 0; // returns SettingXYZ mask
00267 
00268 protected:
00272     KDecorationOptionsPrivate* d;
00273     };
00274 
00275 
00283 class KWIN_EXPORT KDecoration
00284     : public QObject, public KDecorationDefines
00285     {
00286     Q_OBJECT
00287     public:
00293     KDecoration( KDecorationBridge* bridge, KDecorationFactory* factory );
00297     virtual ~KDecoration();
00298     
00299     // requests from decoration
00300     
00305         static const KDecorationOptions* options();
00309     bool isActive() const;
00313     bool isCloseable() const;
00317     bool isMaximizable() const;
00323     MaximizeMode maximizeMode() const;
00327     bool isMinimizable() const;
00332         bool providesContextHelp() const;
00338         int desktop() const;
00343         bool isOnAllDesktops() const; // convenience
00347         bool isModal() const;
00351         bool isShadeable() const;
00360         bool isShade() const;
00368         bool isSetShade() const;
00372         bool keepAbove() const;
00376         bool keepBelow() const;
00380         bool isMovable() const;
00384         bool isResizable() const;
00408         NET::WindowType windowType( unsigned long supported_types ) const;
00412     QIconSet icon() const;
00416     QString caption() const;
00443     void showWindowMenu( const QRect &pos );
00444 
00448     void showWindowMenu( QPoint pos );
00453     void performWindowOperation( WindowOperation op );
00462         void setMask( const QRegion& reg, int mode = 0 );
00466         void clearMask(); // convenience
00472         bool isPreview() const;
00476         QRect geometry() const;
00482         QRect iconGeometry() const;
00491         QRegion unobscuredRegion( const QRegion& r ) const;
00496         QWidget* workspaceWidget() const;
00500         int width() const; // convenience
00504         int height() const;  // convenience
00510     void processMousePressEvent( QMouseEvent* e );
00511 
00512     // requests to decoration
00513 
00519         virtual void init() = 0; // called once right after created
00520     
00526     virtual Position mousePosition( const QPoint& p ) const = 0;
00527 
00540         // mustn't do any repaints, resizes or anything like that
00541     virtual void borders( int& left, int& right, int& top, int& bottom ) const = 0;
00549     virtual void resize( const QSize& s ) = 0;
00555     virtual QSize minimumSize() const = 0;
00560         virtual void activeChange() = 0;
00564         virtual void captionChange() = 0;
00568         virtual void iconChange() = 0;
00573         virtual void maximizeChange() = 0;
00579         virtual void desktopChange() = 0;
00584         virtual void shadeChange() = 0;
00585 #if KDE_IS_VERSION( 3, 90, 0 )
00586 #warning Redo all the XYZChange() virtuals as signals.
00587 #endif
00588     signals:
00593         void keepAboveChanged( bool );
00598         void keepBelowChanged( bool );
00599     public:
00613         virtual bool drawbound( const QRect& geom, bool clear );
00624         virtual bool animateMinimize( bool minimize );
00628         // TODO position will need also values for top+left+bottom etc. docking ?
00629         virtual bool windowDocked( Position side );
00636         virtual void reset( unsigned long changed );
00637 
00638     // special
00639 
00646         void setMainWidget( QWidget* );
00656         void createMainWidget( WFlags flags = 0 );
00660         QWidget* initialParentWidget() const;
00667         WFlags initialWFlags() const;
00674         void helperShowHide( bool show );
00678     QWidget* widget();
00682     const QWidget* widget() const;
00686         KDecorationFactory* factory() const;
00690         void grabXServer();
00694         void ungrabXServer();
00695     public slots:
00696     // requests from decoration
00697 
00705     void closeWindow();
00706         /*
00707          * Changes the maximize mode of the decorated window. This function should
00708          * be preferred to the other maximize() overload for reacting on clicks
00709          * on the maximize titlebar button.
00710          * NOTE: This function is new in KDE3.3. In order to support also KDE3.2,
00711          * it is recommended to use code like this:
00712          * \code
00713          * ButtonState button = ... ;
00714          * #if KDE_IS_VERSION( 3, 3, 0 )
00715          * maximize( button );
00716          * #else
00717          * if( button == MidButton )
00718      *     maximize( maximizeMode() ^ MaximizeVertical );
00719          * else if( button == RightButton )
00720          *     maximize( maximizeMode() ^ MaximizeHorizontal );
00721          * else
00722          *     maximize( maximizeMode() == MaximizeFull ? MaximizeRestore : MaximizeFull );
00723          * #endif
00724          * \endcode
00725          * @since 3.3
00726          */
00727 #if KDE_IS_VERSION( 3, 90, 0 )
00728 #warning Update the docs.
00729 #endif
00730         void maximize( ButtonState button );
00735     void maximize( MaximizeMode mode );
00739     void minimize();
00744         void showContextHelp();
00749         void setDesktop( int desktop );
00753         void toggleOnAllDesktops(); // convenience
00758         void titlebarDblClickOperation();
00763         void setShade( bool set );
00768         void setKeepAbove( bool set );
00773         void setKeepBelow( bool set );
00777         void emitKeepAboveChanged( bool above ) { emit keepAboveChanged( above ); }
00781         void emitKeepBelowChanged( bool below ) { emit keepBelowChanged( below ); }
00782     private:
00783     KDecorationBridge* bridge_;
00784     QWidget* w_;
00785         KDecorationFactory* factory_;
00786         friend class KDecorationOptions; // for options_
00787         static KDecorationOptions* options_;
00788         KDecorationPrivate* d;
00789     };
00790 
00791 inline
00792 KDecorationDefines::MaximizeMode operator^( KDecorationDefines::MaximizeMode m1, KDecorationDefines::MaximizeMode m2 )
00793     {
00794     return KDecorationDefines::MaximizeMode( int(m1) ^ int(m2) );
00795     }
00796 
00797 inline
00798 KDecorationDefines::MaximizeMode operator&( KDecorationDefines::MaximizeMode m1, KDecorationDefines::MaximizeMode m2 )
00799     {
00800     return KDecorationDefines::MaximizeMode( int(m1) & int(m2) );
00801     }
00802 
00803 inline
00804 KDecorationDefines::MaximizeMode operator|( KDecorationDefines::MaximizeMode m1, KDecorationDefines::MaximizeMode m2 )
00805     {
00806     return KDecorationDefines::MaximizeMode( int(m1) | int(m2) );
00807     }
00808 
00809 inline QWidget* KDecoration::widget()
00810     {
00811     return w_;
00812     }
00813 
00814 inline const QWidget* KDecoration::widget() const
00815     {
00816     return w_;
00817     }
00818 
00819 inline KDecorationFactory* KDecoration::factory() const
00820     {
00821     return factory_;
00822     }
00823 
00824 inline bool KDecoration::isOnAllDesktops() const
00825     {
00826     return desktop() == NET::OnAllDesktops;
00827     }
00828 
00829 inline int KDecoration::width() const
00830     {
00831     return geometry().width();
00832     }
00833     
00834 inline int KDecoration::height() const
00835     {
00836     return geometry().height();
00837     }
00838     
00839 #endif
KDE Logo
This file is part of the documentation for kwin Library Version 3.3.90.
Documentation copyright © 1996-2004 the KDE developers.
Generated on Tue Apr 5 03:59:39 2005 by doxygen 1.3.9.1 written by Dimitri van Heesch, © 1997-2003