• Skip to content
  • Skip to link menu
KDE 4.2 API Reference
  • KDE API Reference
  • API Reference
  • Sitemap
  • Contact Us
 

KWinLibraries

kdecoration.h

Go to the documentation of this file.
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 <QtGui/QColor>
00029 #include <QtGui/QFont>
00030 #include <QtCore/QObject>
00031 #include <QtGui/QIcon>
00032 #include <netwm_def.h>
00033 #include <QtGui/QMouseEvent>
00034 
00035 #define KWIN_EXPORT KDE_EXPORT
00036 
00037 class KConfig;
00038 
00044 class KDecorationOptionsPrivate;
00045 class KDecorationBridge;
00046 class KDecorationPrivate;
00047 class KDecorationFactory;
00048 
00053 class KWIN_EXPORT KDecorationDefines
00054 {
00055 public:
00059     enum Position
00060         { // without prefix, they'd conflict with Qt::TopLeftCorner etc. :(
00061         PositionCenter         = 0x00,
00062         PositionLeft           = 0x01,
00063         PositionRight          = 0x02,
00064         PositionTop            = 0x04,
00065         PositionBottom         = 0x08,
00066         PositionTopLeft        = PositionLeft | PositionTop,
00067         PositionTopRight       = PositionRight | PositionTop,
00068         PositionBottomLeft     = PositionLeft | PositionBottom,
00069         PositionBottomRight    = PositionRight | PositionBottom
00070         };
00074     // these values are written to session files, don't change the order
00075     enum MaximizeMode
00076         {
00077         MaximizeRestore    = 0, 
00078         MaximizeVertical   = 1, 
00079         MaximizeHorizontal = 2, 
00080 
00081         MaximizeFull = MaximizeVertical | MaximizeHorizontal
00082         };
00083 
00084     enum WindowOperation
00085         {
00086         MaximizeOp = 5000,
00087         RestoreOp,
00088         MinimizeOp,
00089         MoveOp,
00090         UnrestrictedMoveOp,
00091         ResizeOp,
00092         UnrestrictedResizeOp,
00093         CloseOp,
00094         OnAllDesktopsOp,
00095         ShadeOp,
00096         KeepAboveOp,
00097         KeepBelowOp,
00098         OperationsOp,
00099         WindowRulesOp,
00100         ToggleStoreSettingsOp = WindowRulesOp, 
00101         HMaximizeOp,
00102         VMaximizeOp,
00103         LowerOp,
00104         FullScreenOp,
00105         NoBorderOp,
00106         NoOp,
00107         SetupWindowShortcutOp,
00108         ApplicationRulesOp
00109         };
00115     enum ColorType
00116         {
00117         ColorTitleBar,   
00118         ColorTitleBlend, 
00119         ColorFont,       
00120         ColorButtonBg,   
00121         ColorFrame,      
00122         ColorHandle,     
00123         NUM_COLORS       
00124         };
00125 
00130     enum
00131         {
00132         SettingDecoration = 1 << 0, 
00133         SettingColors     = 1 << 1, 
00134         SettingFont       = 1 << 2, 
00135         SettingButtons    = 1 << 3, 
00136         SettingTooltips   = 1 << 4, 
00137         SettingBorder     = 1 << 5  
00138         };
00139 
00144     enum BorderSize
00145         {
00146         BorderTiny,      
00147         BorderNormal,    
00148         BorderLarge,     
00149         BorderVeryLarge, 
00150         BorderHuge,      
00151         BorderVeryHuge,  
00152         BorderOversized, 
00153         BordersCount     
00154         };
00155 
00160     enum Ability
00161         {
00162         // announce
00163         AbilityAnnounceButtons = 0, 
00164         AbilityAnnounceColors = 1, 
00165         // buttons
00166         AbilityButtonMenu = 1000,   
00167         AbilityButtonOnAllDesktops = 1001, 
00168         AbilityButtonSpacer = 1002, 
00169         AbilityButtonHelp = 1003,   
00170         AbilityButtonMinimize = 1004,  
00171         AbilityButtonMaximize = 1005, 
00172         AbilityButtonClose = 1006, 
00173         AbilityButtonAboveOthers = 1007, 
00174         AbilityButtonBelowOthers = 1008, 
00175         AbilityButtonShade = 1009, 
00176         AbilityButtonResize = 1010, 
00177         // colors
00178         AbilityColorTitleBack = 2000, 
00179         ABILITYCOLOR_FIRST = AbilityColorTitleBack, 
00180         AbilityColorTitleFore = 2001, 
00181         AbilityColorTitleBlend = 2002, 
00182         AbilityColorFrame = 2010, 
00183         AbilityColorHandle = 2011, 
00184         AbilityColorButtonBack = 2020, 
00185         AbilityColorButtonFore = 2021, 
00186         ABILITYCOLOR_END, 
00187         // compositing
00188         AbilityCompositingShadow = 3000, 
00189         // TODO colors for individual button types
00190         ABILITY_DUMMY = 10000000
00191         };
00192 
00193     enum Requirement { REQUIREMENT_DUMMY = 1000000 };
00194 };
00195 
00199 enum ShadowType
00200     {
00201     ShadowBorderedActive = 0, 
00202     ShadowBorderedInactive, 
00203     ShadowBorderlessActive, 
00204     ShadowBorderlessInactive, 
00205     ShadowOther 
00206     };
00207 
00208 class KDecorationProvides
00209     : public KDecorationDefines
00210     {
00211     public:
00212         virtual ~KDecorationProvides(){}
00213         virtual bool provides( Requirement req ) = 0;
00214     };
00215 
00221 class KWIN_EXPORT KDecorationOptions : public KDecorationDefines
00222     {
00223 public:
00224     KDecorationOptions();
00225     virtual ~KDecorationOptions();
00231     unsigned long updateSettings( KConfig* config );
00239     QColor color(ColorType type, bool active=true) const;
00247     QPalette palette(ColorType type, bool active=true) const;
00255     QFont font(bool active=true, bool small = false) const;
00263     bool customButtonPositions() const;
00285     QString titleButtonsLeft() const;
00289     static QString defaultTitleButtonsLeft();
00301     QString titleButtonsRight() const;
00305     static QString defaultTitleButtonsRight();
00310     bool showTooltips() const;
00311 
00322     BorderSize preferredBorderSize( KDecorationFactory* factory ) const;
00323 
00324     /*
00325     * When this functions returns false, moving and resizing of maximized windows
00326     * is not allowed, and therefore the decoration is allowed to turn off (some of)
00327     * its borders.
00328     * The changed flags for this setting is SettingButtons.
00329     */
00330     bool moveResizeMaximizedWindows() const;
00331 
00335     WindowOperation operationMaxButtonClick( Qt::MouseButtons button ) const;
00336 
00340     virtual unsigned long updateSettings() = 0; // returns SettingXYZ mask
00341 
00342 protected:
00344     void setOpMaxButtonLeftClick( WindowOperation op );
00346     void setOpMaxButtonRightClick( WindowOperation op );
00348     void setOpMaxButtonMiddleClick( WindowOperation op );
00350     void setBorderSize( BorderSize bs );
00352     void setCustomButtonPositions( bool b );
00354     void setTitleButtonsLeft( const QString& b );
00356     void setTitleButtonsRight( const QString& b );
00357 private:
00361     KDecorationOptionsPrivate* d;
00362     };
00363 
00364 
00371 class KWIN_EXPORT KDecoration
00372     : public QObject, public KDecorationDefines
00373     {
00374     Q_OBJECT
00375     public:
00381         KDecoration( KDecorationBridge* bridge, KDecorationFactory* factory );
00385         virtual ~KDecoration();
00386 
00387         // requests from decoration
00388 
00393         static const KDecorationOptions* options();
00397         bool isActive() const;
00401         bool isCloseable() const;
00405         bool isMaximizable() const;
00411         MaximizeMode maximizeMode() const;
00415         bool isMinimizable() const;
00420         bool providesContextHelp() const;
00426         int desktop() const;
00431         bool isOnAllDesktops() const; // convenience
00435         bool isModal() const;
00439         bool isShadeable() const;
00448         bool isShade() const;
00456         bool isSetShade() const;
00460         bool keepAbove() const;
00464         bool keepBelow() const;
00468         bool isMovable() const;
00472         bool isResizable() const;
00496         NET::WindowType windowType( unsigned long supported_types ) const;
00500         QIcon icon() const;
00504         QString caption() const;
00531         void showWindowMenu( const QRect &pos );
00532 
00536         void showWindowMenu( QPoint pos );
00541         void performWindowOperation( WindowOperation op );
00550         void setMask( const QRegion& reg, int mode = 0 );
00554         void clearMask(); // convenience
00560         bool isPreview() const;
00564         QRect geometry() const;
00570         QRect iconGeometry() const;
00579         QRegion unobscuredRegion( const QRegion& r ) const;
00592         WId windowId() const;
00596         int width() const; // convenience
00600         int height() const;  // convenience
00606         void processMousePressEvent( QMouseEvent* e );
00607 
00608         // requests to decoration
00609 
00615         virtual void init() = 0; // called once right after created
00616 
00622         virtual Position mousePosition( const QPoint& p ) const = 0;
00623 
00636         // mustn't do any repaints, resizes or anything like that
00637         virtual void borders( int& left, int& right, int& top, int& bottom ) const = 0;
00645         virtual void resize( const QSize& s ) = 0;
00651         virtual QSize minimumSize() const = 0;
00656         virtual void activeChange() = 0;
00660         virtual void captionChange() = 0;
00664         virtual void iconChange() = 0;
00669         virtual void maximizeChange() = 0;
00675         virtual void desktopChange() = 0;
00680         virtual void shadeChange() = 0;
00681     Q_SIGNALS:
00685         void keepAboveChanged( bool );
00689         void keepBelowChanged( bool );
00690     public:
00719         virtual bool drawbound( const QRect& geom, bool clear );
00723         // TODO position will need also values for top+left+bottom etc. docking ?
00724         virtual bool windowDocked( Position side );
00731         virtual void reset( unsigned long changed );
00732 
00733         // special
00734 
00741         void setMainWidget( QWidget* );
00751         void createMainWidget( Qt::WFlags flags = 0 );
00755         QWidget* initialParentWidget() const;
00762         Qt::WFlags initialWFlags() const;
00766         QWidget* widget();
00770         const QWidget* widget() const;
00774         KDecorationFactory* factory() const;
00778         void grabXServer();
00782         void ungrabXServer();
00783     public Q_SLOTS:
00784         // requests from decoration
00785 
00793         void closeWindow();
00799         void maximize( Qt::MouseButtons button );
00804         void maximize( MaximizeMode mode );
00808         void minimize();
00813         void showContextHelp();
00818         void setDesktop( int desktop );
00822         void toggleOnAllDesktops(); // convenience
00827         void titlebarDblClickOperation();
00833         void titlebarMouseWheelOperation( int delta );
00838         void setShade( bool set );
00843         void setKeepAbove( bool set );
00848         void setKeepBelow( bool set );
00852         void emitKeepAboveChanged( bool above );
00856         void emitKeepBelowChanged( bool below );
00857     private:
00858         KDecorationBridge* bridge_;
00859         QWidget* w_;
00860         KDecorationFactory* factory_;
00861         friend class KDecorationOptions; // for options_
00862         friend class KDecorationUnstable; // for bridge_
00863         static KDecorationOptions* options_;
00864         KDecorationPrivate* d;
00865     };
00866 
00870 class KWIN_EXPORT KDecorationUnstable
00871     : public KDecoration
00872     {
00873     Q_OBJECT
00874     public:
00875         KDecorationUnstable( KDecorationBridge* bridge, KDecorationFactory* factory );
00876         virtual ~KDecorationUnstable();
00877 
00883         virtual QList<QRect> shadowQuads( ShadowType type ) const;
00887         virtual double shadowOpacity( ShadowType type ) const;
00891         virtual double shadowBrightness( ShadowType type ) const;
00895         virtual double shadowSaturation( ShadowType type ) const;
00896 
00900         void repaintShadow();
00905         bool compositingActive() const;
00910         bool shadowsActive() const;
00914         double opacity() const;
00915     };
00916 
00917 inline
00918 KDecorationDefines::MaximizeMode operator^( KDecorationDefines::MaximizeMode m1, KDecorationDefines::MaximizeMode m2 )
00919     {
00920     return KDecorationDefines::MaximizeMode( int(m1) ^ int(m2) );
00921     }
00922 
00923 inline
00924 KDecorationDefines::MaximizeMode operator&( KDecorationDefines::MaximizeMode m1, KDecorationDefines::MaximizeMode m2 )
00925     {
00926     return KDecorationDefines::MaximizeMode( int(m1) & int(m2) );
00927     }
00928 
00929 inline
00930 KDecorationDefines::MaximizeMode operator|( KDecorationDefines::MaximizeMode m1, KDecorationDefines::MaximizeMode m2 )
00931     {
00932     return KDecorationDefines::MaximizeMode( int(m1) | int(m2) );
00933     }
00934 
00935 inline QWidget* KDecoration::widget()
00936     {
00937     return w_;
00938     }
00939 
00940 inline const QWidget* KDecoration::widget() const
00941     {
00942     return w_;
00943     }
00944 
00945 inline KDecorationFactory* KDecoration::factory() const
00946     {
00947     return factory_;
00948     }
00949 
00950 inline bool KDecoration::isOnAllDesktops() const
00951     {
00952     return desktop() == NET::OnAllDesktops;
00953     }
00954 
00955 inline int KDecoration::width() const
00956     {
00957     return geometry().width();
00958     }
00959 
00960 inline int KDecoration::height() const
00961     {
00962     return geometry().height();
00963     }
00964 
00967 #endif

KWinLibraries

Skip menu "KWinLibraries"
  • Main Page
  • Modules
  • Namespace List
  • Class Hierarchy
  • Alphabetical List
  • Class List
  • File List
  • Namespace Members
  • Class Members
  • Related Pages

API Reference

Skip menu "API Reference"
  • KWin
  •   KWin Libraries
  • Libraries
  •   libkworkspace
  •   libsolidcontrol
  •   libtaskmanager
  • Plasma
  •   Animators
  •   Applets
  •   Engines
  • Solid Modules
Generated for API Reference by doxygen 1.5.7
This website is maintained by Adriaan de Groot and Allen Winter.
KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal