• Skip to content
  • Skip to link menu
Trinity API Reference
  • Trinity API Reference
  • kwin/lib
 

kwin/lib

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 <tqcolor.h>
00029 #include <tqfont.h>
00030 #include <tqobject.h>
00031 #include <tqiconset.h>
00032 #include <netwm_def.h>
00033 #include <kdeversion.h>
00034 
00035 class KDecorationOptionsPrivate;
00036 class KDecorationBridge;
00037 class KDecorationPrivate;
00038 class KDecorationFactory;
00039 
00040 #define KWIN_EXPORT KDE_EXPORT
00041 
00047 class KWIN_EXPORT KDecorationDefines
00048 {
00049 public:
00053     enum Position
00054         { // without prefix, they'd conflict with Qt::TopLeft etc. :(
00055         PositionCenter         = 0x00,
00056         PositionLeft           = 0x01,
00057         PositionRight          = 0x02,
00058         PositionTop            = 0x04,
00059         PositionBottom         = 0x08,
00060         PositionTopLeft        = PositionLeft | PositionTop,
00061         PositionTopRight       = PositionRight | PositionTop,
00062         PositionBottomLeft     = PositionLeft | PositionBottom,
00063         PositionBottomRight    = PositionRight | PositionBottom
00064         };
00068     // these values are written to session files, don't change the order
00069     enum MaximizeMode
00070         {
00071     MaximizeRestore    = 0, 
00072     MaximizeVertical   = 1, 
00073     MaximizeHorizontal = 2, 
00074 
00075     MaximizeFull = MaximizeVertical | MaximizeHorizontal 
00076         };
00077 
00078     enum WindowOperation
00079         {
00080         MaximizeOp = 5000,
00081         RestoreOp,
00082         MinimizeOp,
00083         MoveOp,
00084         UnrestrictedMoveOp,
00085         ResizeOp,
00086         UnrestrictedResizeOp,
00087         CloseOp,
00088         OnAllDesktopsOp,
00089         ShadeOp,
00090         KeepAboveOp,
00091         KeepBelowOp,
00092         OperationsOp,
00093         WindowRulesOp,
00094         ToggleStoreSettingsOp = WindowRulesOp, 
00095         HMaximizeOp,
00096         VMaximizeOp,
00097         LowerOp,
00098         FullScreenOp,
00099         NoBorderOp,
00100         NoOp,
00101         SetupWindowShortcutOp,
00102         ApplicationRulesOp,    
00103         ShadowOp               
00104         };
00110     enum ColorType
00111     {
00112     ColorTitleBar,   
00113     ColorTitleBlend, 
00114     ColorFont,       
00115     ColorButtonBg,   
00116     ColorFrame,      
00117     ColorHandle,     
00118     NUM_COLORS
00119     };
00120 
00125     enum
00126         {
00127         SettingDecoration = 1 << 0, 
00128         SettingColors     = 1 << 1, 
00129         SettingFont       = 1 << 2, 
00130         SettingButtons    = 1 << 3, 
00131         SettingTooltips   = 1 << 4, 
00132         SettingBorder     = 1 << 5  
00133         };
00134 
00139     enum BorderSize
00140         {
00141         BorderTiny,      
00142         BorderNormal,    
00143         BorderLarge,     
00144         BorderVeryLarge, 
00145         BorderHuge,      
00146         BorderVeryHuge,  
00147         BorderOversized, 
00148         BordersCount     
00149         };
00150 
00155     enum Ability
00156         {
00157         AbilityAnnounceButtons = 0, 
00158         AbilityButtonMenu = 1000,   
00159         AbilityButtonOnAllDesktops = 1001, 
00160         AbilityButtonSpacer = 1002, 
00161         AbilityButtonHelp = 1003,   
00162         AbilityButtonMinimize = 1004,  
00163         AbilityButtonMaximize = 1005, 
00164         AbilityButtonClose = 1006, 
00165         AbilityButtonAboveOthers = 1007, 
00166         AbilityButtonBelowOthers = 1008, 
00167         AbilityButtonShade = 1009, 
00168         AbilityButtonResize = 1010, 
00169         ABILITY_DUMMY = 10000000
00170         };
00171 
00172     enum Requirement { REQUIREMENT_DUMMY = 1000000 };
00173 };    
00174 
00175 class KDecorationProvides
00176     : public KDecorationDefines
00177     {
00178     public:
00179         virtual bool provides( Requirement req ) = 0;
00180     };
00181 
00188 class KWIN_EXPORT KDecorationOptions : public KDecorationDefines
00189     {
00190 public:
00191     KDecorationOptions();
00192     virtual ~KDecorationOptions();
00200     const TQColor& color(ColorType type, bool active=true) const;
00208     const TQColorGroup& colorGroup(ColorType type, bool active=true) const;
00216     const TQFont& font(bool active=true, bool small = false) const;
00224     bool customButtonPositions() const;
00246     TQString titleButtonsLeft() const;
00258     TQString titleButtonsRight() const;
00259 
00264     bool showTooltips() const;
00265 
00276     BorderSize preferredBorderSize( KDecorationFactory* factory ) const;
00277 
00278     /*
00279      * When this functions returns false, moving and resizing of maximized windows
00280      * is not allowed, and therefore the decoration is allowed to turn off (some of)
00281      * its borders.
00282      * The changed flags for this setting is SettingButtons.
00283      */
00284     bool moveResizeMaximizedWindows() const;
00285 
00289     WindowOperation operationMaxButtonClick( TQt::ButtonState button ) const;
00290 
00294     virtual unsigned long updateSettings() = 0; // returns SettingXYZ mask
00295 
00296 protected:
00300     KDecorationOptionsPrivate* d;
00301     };
00302 
00303 
00311 class KWIN_EXPORT KDecoration
00312     : public TQObject, public KDecorationDefines
00313     {
00314     Q_OBJECT
00315     public:
00321     KDecoration( KDecorationBridge* bridge, KDecorationFactory* factory );
00325     virtual ~KDecoration();
00326 
00327     // requests from decoration
00328 
00333         static const KDecorationOptions* options();
00337     bool isActive() const;
00341     bool isCloseable() const;
00345     bool isMaximizable() const;
00351     MaximizeMode maximizeMode() const;
00355     bool isMinimizable() const;
00360         bool providesContextHelp() const;
00366         int desktop() const;
00371         bool isOnAllDesktops() const; // convenience
00375         bool isModal() const;
00379         bool isShadeable() const;
00388         bool isShade() const;
00396         bool isSetShade() const;
00400         bool keepAbove() const;
00404         bool keepBelow() const;
00408         bool isMovable() const;
00412         bool isResizable() const;
00436         NET::WindowType windowType( unsigned long supported_types ) const;
00440     TQIconSet icon() const;
00444     TQString caption() const;
00471     void showWindowMenu( const TQRect &pos );
00472 
00476     void showWindowMenu( TQPoint pos );
00481     void performWindowOperation( WindowOperation op );
00490         void setMask( const TQRegion& reg, int mode = 0 );
00494         void clearMask(); // convenience
00500         bool isPreview() const;
00504         TQRect geometry() const;
00510         TQRect iconGeometry() const;
00519         TQRegion unobscuredRegion( const TQRegion& r ) const;
00524         TQWidget* workspaceWidget() const;
00538         WId windowId() const;
00542         int width() const; // convenience
00546         int height() const;  // convenience
00552     void processMousePressEvent( TQMouseEvent* e );
00553 
00554     // requests to decoration
00555 
00561         virtual void init() = 0; // called once right after created
00562     
00568     virtual Position mousePosition( const TQPoint& p ) const = 0;
00569 
00582         // mustn't do any repaints, resizes or anything like that
00583     virtual void borders( int& left, int& right, int& top, int& bottom ) const = 0;
00591     virtual void resize( const TQSize& s ) = 0;
00597     virtual TQSize minimumSize() const = 0;
00602         virtual void activeChange() = 0;
00606         virtual void captionChange() = 0;
00610         virtual void iconChange() = 0;
00615         virtual void maximizeChange() = 0;
00621         virtual void desktopChange() = 0;
00626         virtual void shadeChange() = 0;
00627 #if KDE_IS_VERSION( 3, 90, 0 )
00628 #warning Redo all the XYZChange() virtuals as signals.
00629 #endif
00630     signals:
00635         void keepAboveChanged( bool );
00640         void keepBelowChanged( bool );
00641     public:
00655         virtual bool drawbound( const TQRect& geom, bool clear );
00666         virtual bool animateMinimize( bool minimize );
00670         // TODO position will need also values for top+left+bottom etc. docking ?
00671         virtual bool windowDocked( Position side );
00678         virtual void reset( unsigned long changed );
00679 
00680     // special
00681 
00688         void setMainWidget( TQWidget* );
00698         void createMainWidget( TQt::WFlags flags = 0 );
00702         TQWidget* initialParentWidget() const;
00709         TQt::WFlags initialWFlags() const;
00716         void helperShowHide( bool show );
00720     TQWidget* widget();
00724     const TQWidget* widget() const;
00728         KDecorationFactory* factory() const;
00732         void grabXServer();
00736         void ungrabXServer();
00737     public slots:
00738     // requests from decoration
00739 
00747     void closeWindow();
00748         /*
00749          * Changes the maximize mode of the decorated window. This function should
00750          * be preferred to the other maximize() overload for reacting on clicks
00751          * on the maximize titlebar button.
00752          * NOTE: This function is new in KDE3.3. In order to support also KDE3.2,
00753          * it is recommended to use code like this:
00754          * \code
00755          * ButtonState button = ... ;
00756          * #if KDE_IS_VERSION( 3, 3, 0 )
00757          * maximize( button );
00758          * #else
00759          * if( button == MidButton )
00760      *     maximize( maximizeMode() ^ MaximizeVertical );
00761          * else if( button == RightButton )
00762          *     maximize( maximizeMode() ^ MaximizeHorizontal );
00763          * else
00764          *     maximize( maximizeMode() == MaximizeFull ? MaximizeRestore : MaximizeFull );
00765          * #endif
00766          * \endcode
00767          * @since 3.3
00768          */
00769 #if KDE_IS_VERSION( 3, 90, 0 )
00770 #warning Update the docs.
00771 #endif
00772         void maximize( ButtonState button );
00777     void maximize( MaximizeMode mode );
00781     void minimize();
00786         void showContextHelp();
00791         void setDesktop( int desktop );
00795         void toggleOnAllDesktops(); // convenience
00800         void titlebarDblClickOperation();
00807         void titlebarMouseWheelOperation( int delta );
00812         void setShade( bool set );
00817         void setKeepAbove( bool set );
00822         void setKeepBelow( bool set );
00826         void emitKeepAboveChanged( bool above ) { emit keepAboveChanged( above ); }
00830         void emitKeepBelowChanged( bool below ) { emit keepBelowChanged( below ); }
00831     private:
00832     KDecorationBridge* bridge_;
00833     TQWidget* w_;
00834         KDecorationFactory* factory_;
00835         friend class KDecorationOptions; // for options_
00836         static KDecorationOptions* options_;
00837         KDecorationPrivate* d;
00838     };
00839 
00840 inline
00841 KDecorationDefines::MaximizeMode operator^( KDecorationDefines::MaximizeMode m1, KDecorationDefines::MaximizeMode m2 )
00842     {
00843     return KDecorationDefines::MaximizeMode( int(m1) ^ int(m2) );
00844     }
00845 
00846 inline
00847 KDecorationDefines::MaximizeMode operator&( KDecorationDefines::MaximizeMode m1, KDecorationDefines::MaximizeMode m2 )
00848     {
00849     return KDecorationDefines::MaximizeMode( int(m1) & int(m2) );
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 TQWidget* KDecoration::widget()
00859     {
00860     return w_;
00861     }
00862 
00863 inline const TQWidget* KDecoration::widget() const
00864     {
00865     return w_;
00866     }
00867 
00868 inline KDecorationFactory* KDecoration::factory() const
00869     {
00870     return factory_;
00871     }
00872 
00873 inline bool KDecoration::isOnAllDesktops() const
00874     {
00875     return desktop() == NET::OnAllDesktops;
00876     }
00877 
00878 inline int KDecoration::width() const
00879     {
00880     return geometry().width();
00881     }
00882     
00883 inline int KDecoration::height() const
00884     {
00885     return geometry().height();
00886     }
00887     
00888 #endif

kwin/lib

Skip menu "kwin/lib"
  • Main Page
  • Class Hierarchy
  • Alphabetical List
  • Class List
  • File List
  • Class Members
  • Related Pages

kwin/lib

Skip menu "kwin/lib"
  • kate
  • kwin
  •   lib
  • libkonq
Generated for kwin/lib by doxygen 1.7.1
This website is maintained by Timothy Pearson.
KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. |