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

kwin/lib

kcommondecoration.h

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 <tqbutton.h>
00029 #include <tqvaluevector.h>
00030 
00031 #include "kdecoration.h"
00032 
00033 class KDecorationBridge;
00034 class KDecorationFactory;
00035 
00036 enum ButtonType {
00037     HelpButton=0,
00038     MaxButton,
00039     MinButton,
00040     CloseButton,
00041     MenuButton,
00042     OnAllDesktopsButton,
00043     AboveButton,
00044     BelowButton,
00045     ShadeButton,
00046     NumButtons
00047 };
00048 
00049 class KCommonDecorationButton;
00050 
00051 class KCommonDecorationButtonPrivate;
00052 class KCommonDecorationPrivate;
00053 
00059 class KWIN_EXPORT KCommonDecoration : public KDecoration
00060 {
00061     Q_OBJECT
00062 
00063     public:
00064         KCommonDecoration(KDecorationBridge* bridge, KDecorationFactory* factory);
00065         virtual ~KCommonDecoration();
00066 
00100         enum LayoutMetric
00101         {
00102             LM_BorderLeft,
00103             LM_BorderRight,
00104             LM_BorderBottom,
00105             LM_TitleHeight,
00106             LM_TitleBorderLeft,
00107             LM_TitleBorderRight,
00108             LM_TitleEdgeLeft,
00109             LM_TitleEdgeRight,
00110             LM_TitleEdgeTop,
00111             LM_TitleEdgeBottom,
00112             LM_ButtonWidth,
00113             LM_ButtonHeight,
00114             LM_ButtonSpacing,
00115             LM_ExplicitButtonSpacer,
00116             LM_ButtonMarginTop,
00117             LM_RightButtonsMarginTop
00118         };
00119 
00120         enum DecorationBehaviour
00121         {
00122             DB_MenuClose, 
00123             DB_WindowMask, 
00124             DB_ButtonHide  
00125         };
00126 
00127         enum WindowCorner
00128         {
00129             WC_TopLeft,
00130             WC_TopRight,
00131             WC_BottomLeft,
00132             WC_BottomRight
00133         };
00134 
00138         virtual TQString visibleName() const = 0;
00144         virtual TQString defaultButtonsLeft() const = 0;
00150         virtual TQString defaultButtonsRight() const = 0;
00151 
00156         virtual bool decorationBehaviour(DecorationBehaviour behaviour) const;
00157 
00165         virtual int layoutMetric(LayoutMetric lm, bool respectWindowState = true, const KCommonDecorationButton *button = 0) const;
00166 
00171         virtual KCommonDecorationButton *createButton(ButtonType type) = 0;
00172 
00176         virtual TQRegion cornerShape(WindowCorner corner);
00177 
00185         virtual void updateWindowShape();
00186 
00190         virtual void paintEvent(TQPaintEvent *e) = 0;
00191 
00196         virtual void updateCaption();
00197 
00198         int buttonsLeftWidth() const;
00199         int buttonsRightWidth() const;
00200 
00204         void updateLayout() const;
00208         void updateButtons() const;
00212         void resetButtons() const;
00213 
00218         bool isToolWindow() const;
00223          TQRect titleRect() const;
00224 
00225     public:
00229         virtual void init();
00233         virtual void reset( unsigned long changed );
00234         virtual void borders( int& left, int& right, int& top, int& bottom ) const;
00235         virtual void show();
00236         virtual void resize(const TQSize& s);
00237         virtual TQSize minimumSize() const;
00238         virtual void maximizeChange();
00239         virtual void desktopChange();
00240         virtual void shadeChange();
00241         virtual void iconChange();
00242         virtual void activeChange();
00243         virtual void captionChange();
00244     public slots:
00245         void keepAboveChange(bool above);
00246         void keepBelowChange(bool below);
00247         void slotMaximize();
00248         void slotShade();
00249         void slotKeepAbove();
00250         void slotKeepBelow();
00251         void menuButtonPressed();
00252         void menuButtonReleased();
00253     public:
00254         virtual Position mousePosition(const TQPoint &point) const;
00255 
00256         virtual bool eventFilter( TQObject* o, TQEvent* e );
00257         virtual void resizeEvent(TQResizeEvent *e);
00258         virtual void mouseDoubleClickEvent(TQMouseEvent *e);
00259         virtual void wheelEvent(TQWheelEvent *e);
00260 
00261     private:
00262         void resetLayout();
00263 
00264         void moveWidget(int x, int y, TQWidget *widget) const;
00265         void resizeWidget(int w, int h, TQWidget *widget) const;
00266 
00267         typedef TQValueVector <KCommonDecorationButton*> ButtonContainer; 
00268         int buttonContainerWidth(const ButtonContainer &btnContainer, bool countHidden = false) const;
00269         bool isModalSystemNotification();
00270         void addButtons(ButtonContainer &btnContainer, const TQString& buttons, bool isLeft);
00271 
00272         KCommonDecorationButton *m_button[NumButtons];
00273 
00274         ButtonContainer m_buttonsLeft;
00275         ButtonContainer m_buttonsRight;
00276 
00277         TQWidget *m_previewWidget;
00278 
00279         // button hiding for small windows
00280         void calcHiddenButtons();
00281         int btnHideMinWidth;
00282         int btnHideLastWidth;
00283 
00284         bool closing; // for menu doubleclick closing...
00285 
00286         KCommonDecorationPrivate *d;
00287 };
00288 
00292 class KWIN_EXPORT KCommonDecorationButton : public TQButton
00293 {
00294     friend class KCommonDecoration;
00295 
00296     Q_OBJECT
00297     TQ_OBJECT
00298 
00299     public:
00300         KCommonDecorationButton(ButtonType type, KCommonDecoration *parent, const char *name);
00301         virtual ~KCommonDecorationButton();
00302 
00306         enum
00307         {
00308             ManualReset     = 1 << 0, 
00309             SizeChange      = 1 << 1, 
00310             ToggleChange    = 1 << 2, 
00311             StateChange     = 1 << 3, 
00312             IconChange      = 1 << 4, 
00313             DecorationReset = 1 << 5  
00314         };
00318         virtual void reset(unsigned long changed) = 0;
00322         KCommonDecoration *decoration() const;
00327         ButtonType type() const;
00328 
00332         bool isLeft() const;
00333 
00337         void setRealizeButtons(int btns);
00341         void setSize(const TQSize &s);
00345         void setTipText(const TQString &tip);
00349         ButtonState lastMousePress() const { return m_lastMouse; }
00350 
00351         TQSize sizeHint() const;
00352 
00353     protected:
00354         void setToggleButton(bool toggle);
00355         void setOn(bool on);
00356         void setLeft(bool left);
00357         void mousePressEvent(TQMouseEvent *e);
00358         void mouseReleaseEvent(TQMouseEvent *e);
00359 
00360     private:
00361         KCommonDecoration *m_decoration;
00362         ButtonType m_type;
00363         int m_realizeButtons;
00364         TQSize m_size;
00365         ButtonState m_lastMouse;
00366 
00367         bool m_isLeft;
00368 
00369         KCommonDecorationButtonPrivate *d;
00370 };
00371 
00372 #endif // KCOMMONDECORATION_H

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.6.3
This website is maintained by Timothy Pearson.
KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. |