• Skip to content
  • Skip to link menu
KDE 4.1 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         // TODO colors for individual button types
00188         ABILITY_DUMMY = 10000000
00189         };
00190 
00191     enum Requirement { REQUIREMENT_DUMMY = 1000000 };
00192 };
00193 
00194 class KDecorationProvides
00195     : public KDecorationDefines
00196     {
00197     public:
00198         virtual ~KDecorationProvides(){}
00199         virtual bool provides( Requirement req ) = 0;
00200     };
00201 
00207 class KWIN_EXPORT KDecorationOptions : public KDecorationDefines
00208     {
00209 public:
00210     KDecorationOptions();
00211     virtual ~KDecorationOptions();
00217     unsigned long updateSettings( KConfig* config );
00225     QColor color(ColorType type, bool active=true) const;
00233     QPalette palette(ColorType type, bool active=true) const;
00241     QFont font(bool active=true, bool small = false) const;
00249     bool customButtonPositions() const;
00271     QString titleButtonsLeft() const;
00275     static QString defaultTitleButtonsLeft();
00287     QString titleButtonsRight() const;
00291     static QString defaultTitleButtonsRight();
00296     bool showTooltips() const;
00297 
00308     BorderSize preferredBorderSize( KDecorationFactory* factory ) const;
00309 
00310     /*
00311      * When this functions returns false, moving and resizing of maximized windows
00312      * is not allowed, and therefore the decoration is allowed to turn off (some of)
00313      * its borders.
00314      * The changed flags for this setting is SettingButtons.
00315      */
00316     bool moveResizeMaximizedWindows() const;
00317 
00321     WindowOperation operationMaxButtonClick( Qt::MouseButtons button ) const;
00322 
00326     virtual unsigned long updateSettings() = 0; // returns SettingXYZ mask
00327 
00328 protected:
00330     void setOpMaxButtonLeftClick( WindowOperation op );
00332     void setOpMaxButtonRightClick( WindowOperation op );
00334     void setOpMaxButtonMiddleClick( WindowOperation op );
00336     void setBorderSize( BorderSize bs );
00338     void setCustomButtonPositions( bool b );
00340     void setTitleButtonsLeft( const QString& b );
00342     void setTitleButtonsRight( const QString& b );
00343 private:
00347     KDecorationOptionsPrivate* d;
00348     };
00349 
00350 
00357 class KWIN_EXPORT KDecoration
00358     : public QObject, public KDecorationDefines
00359     {
00360     Q_OBJECT
00361     public:
00367     KDecoration( KDecorationBridge* bridge, KDecorationFactory* factory );
00371     virtual ~KDecoration();
00372 
00373     // requests from decoration
00374 
00379         static const KDecorationOptions* options();
00383     bool isActive() const;
00387     bool isCloseable() const;
00391     bool isMaximizable() const;
00397     MaximizeMode maximizeMode() const;
00401     bool isMinimizable() const;
00406         bool providesContextHelp() const;
00412         int desktop() const;
00417         bool isOnAllDesktops() const; // convenience
00421         bool isModal() const;
00425         bool isShadeable() const;
00434         bool isShade() const;
00442         bool isSetShade() const;
00446         bool keepAbove() const;
00450         bool keepBelow() const;
00454         bool isMovable() const;
00458         bool isResizable() const;
00482         NET::WindowType windowType( unsigned long supported_types ) const;
00486     QIcon icon() const;
00490     QString caption() const;
00517     void showWindowMenu( const QRect &pos );
00518 
00522     void showWindowMenu( QPoint pos );
00527     void performWindowOperation( WindowOperation op );
00536         void setMask( const QRegion& reg, int mode = 0 );
00540         void clearMask(); // convenience
00546         bool isPreview() const;
00550         QRect geometry() const;
00556         QRect iconGeometry() const;
00565         QRegion unobscuredRegion( const QRegion& r ) const;
00578         WId windowId() const;
00582         int width() const; // convenience
00586         int height() const;  // convenience
00592     void processMousePressEvent( QMouseEvent* e );
00593 
00594     // requests to decoration
00595 
00601         virtual void init() = 0; // called once right after created
00602 
00608     virtual Position mousePosition( const QPoint& p ) const = 0;
00609 
00622         // mustn't do any repaints, resizes or anything like that
00623     virtual void borders( int& left, int& right, int& top, int& bottom ) const = 0;
00631     virtual void resize( const QSize& s ) = 0;
00637     virtual QSize minimumSize() const = 0;
00642         virtual void activeChange() = 0;
00646         virtual void captionChange() = 0;
00650         virtual void iconChange() = 0;
00655         virtual void maximizeChange() = 0;
00661         virtual void desktopChange() = 0;
00666         virtual void shadeChange() = 0;
00667     Q_SIGNALS:
00671         void keepAboveChanged( bool );
00675         void keepBelowChanged( bool );
00676     public:
00705         virtual bool drawbound( const QRect& geom, bool clear );
00709         // TODO position will need also values for top+left+bottom etc. docking ?
00710         virtual bool windowDocked( Position side );
00717         virtual void reset( unsigned long changed );
00718 
00719     // special
00720 
00727         void setMainWidget( QWidget* );
00737         void createMainWidget( Qt::WFlags flags = 0 );
00741         QWidget* initialParentWidget() const;
00748     Qt::WFlags initialWFlags() const;
00752     QWidget* widget();
00756     const QWidget* widget() const;
00760         KDecorationFactory* factory() const;
00764         void grabXServer();
00768         void ungrabXServer();
00769     public Q_SLOTS:
00770     // requests from decoration
00771 
00779     void closeWindow();
00780         /*
00781          * Changes the maximize mode of the decorated window. This function should
00782          * be preferred to the other maximize() overload for reacting on clicks
00783          * on the maximize titlebar button.
00784          */
00785         void maximize( Qt::MouseButtons button );
00790     void maximize( MaximizeMode mode );
00794     void minimize();
00799         void showContextHelp();
00804         void setDesktop( int desktop );
00808         void toggleOnAllDesktops(); // convenience
00813         void titlebarDblClickOperation();
00819         void titlebarMouseWheelOperation( int delta );
00824         void setShade( bool set );
00829         void setKeepAbove( bool set );
00834         void setKeepBelow( bool set );
00838         void emitKeepAboveChanged( bool above );
00842         void emitKeepBelowChanged( bool below );
00843     private:
00844     KDecorationBridge* bridge_;
00845     QWidget* w_;
00846         KDecorationFactory* factory_;
00847         friend class KDecorationOptions; // for options_
00848         static KDecorationOptions* options_;
00849         KDecorationPrivate* d;
00850     };
00851 
00852 inline
00853 KDecorationDefines::MaximizeMode operator^( KDecorationDefines::MaximizeMode m1, KDecorationDefines::MaximizeMode m2 )
00854     {
00855     return KDecorationDefines::MaximizeMode( int(m1) ^ int(m2) );
00856     }
00857 
00858 inline
00859 KDecorationDefines::MaximizeMode operator&( KDecorationDefines::MaximizeMode m1, KDecorationDefines::MaximizeMode m2 )
00860     {
00861     return KDecorationDefines::MaximizeMode( int(m1) & int(m2) );
00862     }
00863 
00864 inline
00865 KDecorationDefines::MaximizeMode operator|( KDecorationDefines::MaximizeMode m1, KDecorationDefines::MaximizeMode m2 )
00866     {
00867     return KDecorationDefines::MaximizeMode( int(m1) | int(m2) );
00868     }
00869 
00870 inline QWidget* KDecoration::widget()
00871     {
00872     return w_;
00873     }
00874 
00875 inline const QWidget* KDecoration::widget() const
00876     {
00877     return w_;
00878     }
00879 
00880 inline KDecorationFactory* KDecoration::factory() const
00881     {
00882     return factory_;
00883     }
00884 
00885 inline bool KDecoration::isOnAllDesktops() const
00886     {
00887     return desktop() == NET::OnAllDesktops;
00888     }
00889 
00890 inline int KDecoration::width() const
00891     {
00892     return geometry().width();
00893     }
00894 
00895 inline int KDecoration::height() const
00896     {
00897     return geometry().height();
00898     }
00899 
00902 #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
  •   libplasma
  •   libsolidcontrol
  •   libtaskmanager
  • Plasma
  •   Animators
  •   Applets
  •   Engines
  • Solid Modules
Generated for API Reference by doxygen 1.5.4
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