Back to index

kdeartwork  4.3.2
kde1client.h
Go to the documentation of this file.
00001 /*****************************************************************
00002 kwin - the KDE window manager
00003                                                         
00004 Copyright (C) 1999, 2000 Matthias Ettrich <ettrich@kde.org>
00005 
00006 Permission is hereby granted, free of charge, to any person obtaining a copy
00007 of this software and associated documentation files (the "Software"), to deal
00008 in the Software without restriction, including without limitation the rights
00009 to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
00010 copies of the Software, and to permit persons to whom the Software is
00011 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 THE
00019 AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
00020 AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
00021 CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
00022 ******************************************************************/
00023 
00024 #ifndef STDCLIENT_H
00025 #define STDCLIENT_H
00026 #include <qlayout.h>
00027 #include <qvariant.h>
00028 #include <kdecoration.h>
00029 #include <kdecorationfactory.h>
00030 #include <qtoolbutton.h>
00031 class QLabel;
00032 class QSpacerItem;
00033 
00034 namespace KDE1 {
00035 
00036 enum ButtonType {
00037     ButtonMenu=0,
00038     ButtonSticky,
00039     ButtonMinimize,
00040     ButtonMaximize,
00041     ButtonClose,
00042     ButtonHelp,
00043     ButtonTypeCount
00044 };
00045 
00046 class StdClient : public KDecoration
00047 {
00048     Q_OBJECT
00049 public:
00050     StdClient( KDecorationBridge* b, KDecorationFactory* f );
00051     ~StdClient();
00052     void init();
00053     QSize minimumSize() const;
00054     void borders( int& left, int& right, int& top, int& bottom ) const;
00055     void reset( unsigned long mask );
00056     void resize( const QSize& s );
00057     void shadeChange() {};
00058     Position mousePosition( const QPoint& p ) const { return KDecoration::mousePosition( p ); }
00059 protected:
00060     bool eventFilter( QObject* o, QEvent* e );
00061     void resizeEvent( QResizeEvent* );
00062     void paintEvent( QPaintEvent* );
00063 
00064     void mouseDoubleClickEvent( QMouseEvent * );
00065     void captionChange();
00066     void iconChange();
00067     void maximizeChange();
00068     void desktopChange();
00069     void activeChange();
00070 
00071 private:
00072     void addButtons(QBoxLayout* hb, const QString& buttons);
00073 
00074 private slots:
00075     void menuButtonPressed();
00076     void maxButtonClicked( ButtonState );
00077 
00078 private:
00079     QToolButton* button[ButtonTypeCount];
00080     QSpacerItem* titlebar;
00081 };
00082 
00083 class StdToolClient : public KDecoration
00084 {
00085     Q_OBJECT
00086 public:
00087     StdToolClient( KDecorationBridge* b, KDecorationFactory* f );
00088     ~StdToolClient();
00089     void init();
00090     QSize minimumSize() const;
00091     void borders( int& left, int& right, int& top, int& bottom ) const;
00092     void reset( unsigned long mask );
00093     void resize( const QSize& s );
00094     void shadeChange() {};
00095     void activeChange() {};
00096     void iconChange() {};
00097     void maximizeChange() {};
00098     void desktopChange() {};
00099     Position mousePosition( const QPoint& p ) const { return KDecoration::mousePosition( p ); }
00100 protected:
00101     bool eventFilter( QObject* o, QEvent* e );
00102     void resizeEvent( QResizeEvent* );
00103     void paintEvent( QPaintEvent* );
00104 
00105     void mouseDoubleClickEvent( QMouseEvent * );
00106     void captionChange();
00107 
00108 private:
00109     QToolButton* closeBtn;
00110     QSpacerItem* titlebar;
00111 };
00112 
00113 
00114 
00115 /*
00116   Like QToolButton, but provides a clicked(ButtonState) signals that
00117   has the last pressed mouse button as argument
00118  */
00119 class ThreeButtonButton: public QToolButton
00120 {
00121     Q_OBJECT
00122 public:
00123   ThreeButtonButton ( QWidget *parent = 0, const char* name = 0 )
00124       : QToolButton( parent, name )
00125     {
00126        connect( this, SIGNAL( clicked() ), this, SLOT( handleClicked() ) );
00127         setCursor( arrowCursor );
00128     }
00129     ~ThreeButtonButton () {}
00130 
00131 signals:
00132     void clicked( ButtonState );
00133 
00134 protected:
00135     void mousePressEvent( QMouseEvent* e )
00136     {
00137        last_button = e->button();
00138        QMouseEvent me ( e->type(), e->pos(), e->globalPos(), Qt::LeftButton, e->state() );
00139        QToolButton::mousePressEvent( &me );
00140     }
00141 
00142     void mouseReleaseEvent( QMouseEvent* e )
00143     {
00144        QMouseEvent me ( e->type(), e->pos(), e->globalPos(), Qt::LeftButton, e->state() );
00145        QToolButton::mouseReleaseEvent( &me );
00146     }
00147 
00148 private slots:
00149     void handleClicked()
00150     {
00151        emit clicked( last_button );
00152     }
00153 
00154 private:
00155     ButtonState last_button;
00156 
00157 };
00158 
00159 class StdFactory : public KDecorationFactory
00160 {
00161 public:
00162     StdFactory();
00163     ~StdFactory();
00164     KDecoration* createDecoration( KDecorationBridge* b );
00165     bool reset( unsigned long mask );
00166     virtual bool supports( Ability ability );
00167 };
00168 
00169 }
00170 
00171 #endif