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

KWinLibraries

kcommondecoration.h

Go to the documentation of this file.
00001 /*
00002   This file is part of the KDE project.
00003 
00004   Copyright (C) 2005 Sandro Giessl <sandro@giessl.com>
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 KCOMMONDECORATION_H
00026 #define KCOMMONDECORATION_H
00027 
00028 #include <QtGui/QAbstractButton>
00029 #include "kdecoration.h"
00030 
00034 class KDecorationBridge;
00035 class KDecorationFactory;
00036 
00037 enum ButtonType {
00038     HelpButton=0,
00039     MaxButton,
00040     MinButton,
00041     CloseButton,
00042     MenuButton,
00043     OnAllDesktopsButton,
00044     AboveButton,
00045     BelowButton,
00046     ShadeButton,
00047     NumButtons
00048 };
00049 
00050 class KCommonDecorationButton;
00051 
00052 class KCommonDecorationButtonPrivate;
00053 class KCommonDecorationPrivate;
00054 class KCommonDecorationWrapper;
00055 
00065 class KWIN_EXPORT KCommonDecoration : public QObject, public KDecorationDefines
00066 {
00067     Q_OBJECT
00068 
00069     public:
00070         KCommonDecoration(KDecorationBridge* bridge, KDecorationFactory* factory);
00071         virtual ~KCommonDecoration();
00072 
00106         enum LayoutMetric
00107         {
00108             LM_BorderLeft,
00109             LM_BorderRight,
00110             LM_BorderBottom,
00111             LM_TitleHeight,
00112             LM_TitleBorderLeft,
00113             LM_TitleBorderRight,
00114             LM_TitleEdgeLeft,
00115             LM_TitleEdgeRight,
00116             LM_TitleEdgeTop,
00117             LM_TitleEdgeBottom,
00118             LM_ButtonWidth,
00119             LM_ButtonHeight,
00120             LM_ButtonSpacing,
00121             LM_ExplicitButtonSpacer,
00122             LM_ButtonMarginTop
00123         };
00124 
00125         enum DecorationBehaviour
00126         {
00127             DB_MenuClose, 
00128             DB_WindowMask, 
00129             DB_ButtonHide  
00130         };
00131 
00132         enum WindowCorner
00133         {
00134             WC_TopLeft,
00135             WC_TopRight,
00136             WC_BottomLeft,
00137             WC_BottomRight
00138         };
00139 
00143         virtual QString visibleName() const = 0;
00149         virtual QString defaultButtonsLeft() const;
00155         virtual QString defaultButtonsRight() const;
00156 
00161         virtual bool decorationBehaviour(DecorationBehaviour behaviour) const;
00162 
00170         virtual int layoutMetric(LayoutMetric lm, bool respectWindowState = true, const KCommonDecorationButton *button = 0) const;
00171 
00176         virtual KCommonDecorationButton *createButton(ButtonType type) = 0;
00177 
00181         virtual QRegion cornerShape(WindowCorner corner);
00182 
00190         virtual void updateWindowShape();
00191 
00195         virtual void paintEvent(QPaintEvent *e) = 0;
00196 
00201         virtual void updateCaption();
00202 
00203         int buttonsLeftWidth() const;
00204         int buttonsRightWidth() const;
00205 
00209         void updateLayout() const;
00213         void updateButtons() const;
00217         void resetButtons() const;
00218 
00223         bool isToolWindow() const;
00228          QRect titleRect() const;
00229 
00230     public:
00234         virtual void init();
00238         virtual void reset( unsigned long changed );
00239         virtual void borders( int& left, int& right, int& top, int& bottom ) const;
00240         virtual void show();
00241         virtual void resize(const QSize& s);
00242         virtual QSize minimumSize() const;
00243         virtual void maximizeChange();
00244         virtual void desktopChange();
00245         virtual void shadeChange();
00246         virtual void iconChange();
00247         virtual void activeChange();
00248         virtual void captionChange();
00249     public Q_SLOTS:
00250         void keepAboveChange(bool above);
00251         void keepBelowChange(bool below);
00252         void slotMaximize();
00253         void slotShade();
00254         void slotKeepAbove();
00255         void slotKeepBelow();
00256         void menuButtonPressed();
00257         void menuButtonReleased();
00258     public:
00259         virtual Position mousePosition(const QPoint &point) const;
00260 
00261         virtual bool eventFilter( QObject* o, QEvent* e );
00262         virtual void resizeEvent(QResizeEvent *e);
00263         virtual void mouseDoubleClickEvent(QMouseEvent *e);
00264         virtual void wheelEvent(QWheelEvent *e);
00265 
00266         // *** wrap everything from KDecoration *** //
00267         // reimplementing from KDecoration (wrapped)
00268         virtual bool drawbound( const QRect& geom, bool clear );
00269         virtual bool windowDocked( Position side );
00270         // wrap everything KDecoration provides
00271         static const KDecorationOptions* options();
00272         bool isActive() const;
00273         bool isCloseable() const;
00274         bool isMaximizable() const;
00275         MaximizeMode maximizeMode() const;
00276         bool isMinimizable() const;
00277         bool providesContextHelp() const;
00278         int desktop() const;
00279         bool isOnAllDesktops() const; // convenience
00280         bool isModal() const;
00281         bool isShadeable() const;
00282         bool isShade() const;
00283         bool isSetShade() const;
00284         bool keepAbove() const;
00285         bool keepBelow() const;
00286         bool isMovable() const;
00287         bool isResizable() const;
00288         NET::WindowType windowType( unsigned long supported_types ) const;
00289         QIcon icon() const;
00290         QString caption() const;
00291         void showWindowMenu( const QRect &pos );
00292         void showWindowMenu( QPoint pos );
00293         void performWindowOperation( WindowOperation op );
00294         void setMask( const QRegion& reg, int mode = 0 );
00295         void clearMask(); // convenience
00296         bool isPreview() const;
00297         QRect geometry() const;
00298         QRect iconGeometry() const;
00299         QRegion unobscuredRegion( const QRegion& r ) const;
00300         WId windowId() const;
00301         int width() const; // convenience
00302         int height() const;  // convenience
00303         void processMousePressEvent( QMouseEvent* e );
00304     Q_SIGNALS:
00305         void keepAboveChanged( bool );
00306         void keepBelowChanged( bool );
00307     public:
00308         void setMainWidget( QWidget* );
00309         void createMainWidget( Qt::WFlags flags = 0 );
00310         QWidget* initialParentWidget() const;
00311         Qt::WFlags initialWFlags() const;
00312         QWidget* widget();
00313         const QWidget* widget() const;
00314         KDecorationFactory* factory() const;
00315         void grabXServer();
00316         void ungrabXServer();
00317     public Q_SLOTS:
00318         void closeWindow();
00319         void maximize( Qt::MouseButtons button );
00320         void maximize( MaximizeMode mode );
00321         void minimize();
00322         void showContextHelp();
00323         void setDesktop( int desktop );
00324         void toggleOnAllDesktops(); // convenience
00325         void titlebarDblClickOperation();
00326         void titlebarMouseWheelOperation( int delta );
00327         void setShade( bool set );
00328         void setKeepAbove( bool set );
00329         void setKeepBelow( bool set );
00330         // *** end of wrapping of everything from KDecoration *** //
00331     public:
00332         // access the KDecoration wrapper
00333         const KDecoration* decoration() const;
00334         KDecoration* decoration();
00335 
00336     private:
00337         void resetLayout();
00338 
00339         void moveWidget(int x, int y, QWidget *widget) const;
00340         void resizeWidget(int w, int h, QWidget *widget) const;
00341 
00342         typedef QVector <KCommonDecorationButton*> ButtonContainer; 
00343         int buttonContainerWidth(const ButtonContainer &btnContainer, bool countHidden = false) const;
00344         void addButtons(ButtonContainer &btnContainer, const QString& buttons, bool isLeft);
00345 
00346         KCommonDecorationButton *m_button[NumButtons];
00347 
00348         ButtonContainer m_buttonsLeft;
00349         ButtonContainer m_buttonsRight;
00350 
00351         QWidget *m_previewWidget;
00352 
00353         // button hiding for small windows
00354         void calcHiddenButtons();
00355         int btnHideMinWidth;
00356         int btnHideLastWidth;
00357 
00358         bool closing; // for menu doubleclick closing...
00359 
00360         KCommonDecorationWrapper* wrapper;
00361 
00362         KCommonDecorationPrivate *d;
00363 };
00364 
00368 class KWIN_EXPORT KCommonDecorationButton : public QAbstractButton
00369 {
00370     Q_OBJECT
00371 
00372     friend class KCommonDecoration;
00373 
00374     public:
00375         KCommonDecorationButton(ButtonType type, KCommonDecoration *parent);
00376         virtual ~KCommonDecorationButton();
00377 
00381         enum
00382         {
00383             ManualReset     = 1 << 0, 
00384             SizeChange      = 1 << 1, 
00385             ToggleChange    = 1 << 2, 
00386             StateChange     = 1 << 3, 
00387             IconChange      = 1 << 4, 
00388             DecorationReset = 1 << 5  
00389         };
00393         virtual void reset(unsigned long changed) = 0;
00397         KCommonDecoration *decoration() const;
00402         ButtonType type() const;
00403 
00407         bool isLeft() const;
00408 
00412         void setRealizeButtons(int btns);
00416         void setSize(const QSize &s);
00420         void setTipText(const QString &tip);
00424         Qt::MouseButtons lastMousePress() const { return m_lastMouse; }
00425 
00426         QSize sizeHint() const;
00427 
00428     protected:
00429         void setToggleButton(bool toggle);
00430         void setOn(bool on);
00431         void setLeft(bool left);
00432         void mousePressEvent(QMouseEvent *e);
00433         void mouseReleaseEvent(QMouseEvent *e);
00434 
00435     private:
00436         KCommonDecoration *m_decoration;
00437         ButtonType m_type;
00438         int m_realizeButtons;
00439         QSize m_size;
00440         Qt::MouseButtons m_lastMouse;
00441 
00442         bool m_isLeft;
00443 
00444         KCommonDecorationButtonPrivate *d;
00445 };
00446 
00449 #endif // KCOMMONDECORATION_H
00450 
00451 // kate: space-indent on; indent-width 4; mixedindent off; indent-mode cstyle;

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