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 
00034 class KDecorationOptionsPrivate;
00035 class KDecorationBridge;
00036 class KDecorationPrivate;
00037 class KDecorationFactory;
00038 
00043 class KDecorationDefines
00044 {
00045 public:
00049     enum Position
00050         { // without prefix, they'd conflict with Qt::TopLeft etc. :(
00051         PositionCenter         = 0x00,
00052         PositionLeft           = 0x01,
00053         PositionRight          = 0x02,
00054         PositionTop            = 0x04,
00055         PositionBottom         = 0x08,
00056         PositionTopLeft        = PositionLeft | PositionTop,
00057         PositionTopRight       = PositionRight | PositionTop,
00058         PositionBottomLeft     = PositionLeft | PositionBottom,
00059         PositionBottomRight    = PositionRight | PositionBottom
00060         };
00064     // these values are written to session files, don't change the order
00065     enum MaximizeMode
00066         {
00067     MaximizeRestore    = 0, 
00068     MaximizeVertical   = 1, 
00069     MaximizeHorizontal = 2, 
00070 
00071     MaximizeFull = MaximizeVertical | MaximizeHorizontal 
00072         };
00073 
00074     enum WindowOperation
00075         {
00076         MaximizeOp = 5000,
00077         RestoreOp,
00078         MinimizeOp,
00079         MoveOp,
00080         UnrestrictedMoveOp,
00081         ResizeOp,
00082         UnrestrictedResizeOp,
00083         CloseOp,
00084         OnAllDesktopsOp,
00085         ShadeOp,
00086         KeepAboveOp,
00087         KeepBelowOp,
00088         OperationsOp,
00089         ToggleStoreSettingsOp,
00090         HMaximizeOp,
00091         VMaximizeOp,
00092         LowerOp,
00093         FullScreenOp,
00094         NoBorderOp,
00095         NoOp
00096         };
00102     enum ColorType
00103     {
00104     ColorTitleBar,   
00105     ColorTitleBlend, 
00106     ColorFont,       
00107     ColorButtonBg,   
00108     ColorFrame,      
00109     ColorHandle,     
00110     NUM_COLORS
00111     };
00112     
00117     enum
00118         {
00119         SettingDecoration = 1 << 0, 
00120         SettingColors     = 1 << 1, 
00121         SettingFont       = 1 << 2, 
00122         SettingButtons    = 1 << 3, 
00123         SettingTooltips   = 1 << 4, 
00124         SettingBorder     = 1 << 5  
00125         };
00126         
00131     enum BorderSize
00132         {
00133         BorderTiny,      
00134         BorderNormal,    
00135         BorderLarge,     
00136         BorderVeryLarge, 
00137         BorderHuge,      
00138         BorderVeryHuge,  
00139         BorderOversized, 
00140         BordersCount     
00141         };
00142 
00143     enum Ability { ABILITY_DUMMY = 10000000 };
00144 
00145     enum Requirement { REQUIREMENT_DUMMY = 1000000 };
00146 };    
00147 
00148 class KDecorationProvides
00149     : public KDecorationDefines
00150     {
00151     public:
00152         virtual bool provides( Requirement req ) = 0;
00153     };
00154 
00160 class KDecorationOptions : public KDecorationDefines
00161     {
00162 public:
00163     KDecorationOptions();
00164     virtual ~KDecorationOptions();
00172     const QColor& color(ColorType type, bool active=true) const;
00180     const QColorGroup& colorGroup(ColorType type, bool active=true) const;
00188     const QFont& font(bool active=true, bool small = false) const;
00196     bool customButtonPositions() const;
00213     // FRAME vice druhu tlacitek
00214     QString titleButtonsLeft() const;
00225     QString titleButtonsRight() const;
00226 
00231     bool showTooltips() const;
00232     
00243     BorderSize preferredBorderSize( KDecorationFactory* factory ) const;
00244 
00245     /*
00246      * When this functions returns false, moving and resizing of maximized windows
00247      * is not allowed, and therefore the decoration is allowed to turn off (some of)
00248      * its borders.
00249      * The changed flags for this setting is SettingButtons.
00250      */
00251     bool moveResizeMaximizedWindows() const;
00252 
00256     virtual unsigned long updateSettings() = 0; // returns SettingXYZ mask
00257 
00258 protected:
00262     KDecorationOptionsPrivate* d;
00263     };
00264 
00265 
00272 class KDecoration
00273     : public QObject, public KDecorationDefines
00274     {
00275     Q_OBJECT
00276     public:
00282     KDecoration( KDecorationBridge* bridge, KDecorationFactory* factory );
00286     virtual ~KDecoration();
00287     
00288     // requests from decoration
00289     
00294         static const KDecorationOptions* options();
00298     bool isActive() const;
00302     bool isCloseable() const;
00306     bool isMaximizable() const;
00312     MaximizeMode maximizeMode() const;
00316     bool isMinimizable() const;
00321         bool providesContextHelp() const;
00327         int desktop() const;
00332         bool isOnAllDesktops() const; // convenience
00336         bool isModal() const;
00340         bool isShadeable() const;
00347         bool isShade() const;
00355         bool isSetShade() const;
00359         bool keepAbove() const;
00363         bool keepBelow() const;
00367         bool isMovable() const;
00371         bool isResizable() const;
00395         NET::WindowType windowType( unsigned long supported_types ) const;
00399     QIconSet icon() const;
00403     QString caption() const;
00420     void showWindowMenu( QPoint pos );
00425     void performWindowOperation( WindowOperation op );
00434         void setMask( const QRegion& reg, int mode = 0 );
00438         void clearMask(); // convenience
00444         bool isPreview() const;
00448         QRect geometry() const;
00454         QRect iconGeometry() const;
00463         QRegion unobscuredRegion( const QRegion& r ) const;
00468         QWidget* workspaceWidget() const;
00472         int width() const; // convenience
00476         int height() const;  // convenience
00482     void processMousePressEvent( QMouseEvent* e );
00483 
00484     // requests to decoration
00485 
00491         virtual void init() = 0; // called once right after created
00492     
00498     virtual Position mousePosition( const QPoint& p ) const = 0;
00499 
00512         // mustn't do any repaints, resizes or anything like that
00513     virtual void borders( int& left, int& right, int& top, int& bottom ) const = 0;
00521     virtual void resize( const QSize& s ) = 0;
00527     virtual QSize minimumSize() const = 0;
00532         virtual void activeChange() = 0;
00536         virtual void captionChange() = 0;
00540         virtual void iconChange() = 0;
00545         virtual void maximizeChange() = 0;
00551         virtual void desktopChange() = 0;
00556         virtual void shadeChange() = 0;
00567         virtual bool drawbound( const QRect& geom, bool clear );
00578         virtual bool animateMinimize( bool minimize );
00582         // TODO position will need also values for top+left+bottom etc. docking ?
00583         virtual bool windowDocked( Position side );
00590         virtual void reset( unsigned long changed );
00591 
00592     // special
00593 
00600         void setMainWidget( QWidget* );
00610         void createMainWidget( WFlags flags = 0 );
00614         QWidget* initialParentWidget() const;
00621         WFlags initialWFlags() const;
00628         void helperShowHide( bool show );
00632     QWidget* widget();
00636     const QWidget* widget() const;
00640         KDecorationFactory* factory() const;
00644         void grabXServer();
00648         void ungrabXServer();
00649     public slots:
00650     // requests from decoration
00651 
00659     void closeWindow();
00664     void maximize( MaximizeMode mode );
00668     void minimize();
00673         void showContextHelp();
00674         void setDesktop( int desktop );
00678         void toggleOnAllDesktops(); // convenience
00683         void titlebarDblClickOperation();
00688         void setShade( bool set );
00693         void setKeepAbove( bool set );
00698         void setKeepBelow( bool set );
00699     private:
00700     KDecorationBridge* bridge_;
00701     QWidget* w_;
00702         KDecorationFactory* factory_;
00703         friend class KDecorationOptions; // for options_
00704         static KDecorationOptions* options_;
00705         KDecorationPrivate* d;
00706     };
00707 
00708 inline
00709 KDecorationDefines::MaximizeMode operator^( KDecorationDefines::MaximizeMode m1, KDecorationDefines::MaximizeMode m2 )
00710     {
00711     return KDecorationDefines::MaximizeMode( int(m1) ^ int(m2) );
00712     }
00713 
00714 inline
00715 KDecorationDefines::MaximizeMode operator&( KDecorationDefines::MaximizeMode m1, KDecorationDefines::MaximizeMode m2 )
00716     {
00717     return KDecorationDefines::MaximizeMode( int(m1) & int(m2) );
00718     }
00719 
00720 inline
00721 KDecorationDefines::MaximizeMode operator|( KDecorationDefines::MaximizeMode m1, KDecorationDefines::MaximizeMode m2 )
00722     {
00723     return KDecorationDefines::MaximizeMode( int(m1) | int(m2) );
00724     }
00725 
00726 inline QWidget* KDecoration::widget()
00727     {
00728     return w_;
00729     }
00730 
00731 inline const QWidget* KDecoration::widget() const
00732     {
00733     return w_;
00734     }
00735 
00736 inline KDecorationFactory* KDecoration::factory() const
00737     {
00738     return factory_;
00739     }
00740 
00741 inline bool KDecoration::isOnAllDesktops() const
00742     {
00743     return desktop() == NET::OnAllDesktops;
00744     }
00745 
00746 inline int KDecoration::width() const
00747     {
00748     return geometry().width();
00749     }
00750     
00751 inline int KDecoration::height() const
00752     {
00753     return geometry().height();
00754     }
00755     
00756 #endif
KDE Logo
This file is part of the documentation for kwin/lib Library Version 3.2.2.
Documentation copyright © 1996-2004 the KDE developers.
Generated on Sun Apr 11 13:44:55 2004 by doxygen 1.3.6-20040222 written by Dimitri van Heesch, © 1997-2003