~ubuntu-branches/ubuntu/utopic/kde-workspace/utopic-proposed

« back to all changes in this revision

Viewing changes to kwin/clients/oxygen/demo/oxygenshadowdemowidget.h

  • Committer: Bazaar Package Importer
  • Author(s): Michał Zając
  • Date: 2011-07-09 08:31:15 UTC
  • Revision ID: james.westby@ubuntu.com-20110709083115-ohyxn6z93mily9fc
Tags: upstream-4.6.90
Import upstream version 4.6.90

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#ifndef oxygenshadowdemowidget_h
 
2
#define oxygenshadowdemowidget_h
 
3
 
 
4
//////////////////////////////////////////////////////////////////////////////
 
5
// oxygenshadowdemowidget.h
 
6
// shadow demo widget
 
7
// -------------------
 
8
//
 
9
// Copyright (c) 2009 Hugo Pereira Da Costa <hugo.pereira@free.fr>
 
10
//
 
11
// Permission is hereby granted, free of charge, to any person obtaining a copy
 
12
// of this software and associated documentation files (the "Software"), to
 
13
// deal in the Software without restriction, including without limitation the
 
14
// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
 
15
// sell copies of the Software, and to permit persons to whom the Software is
 
16
// furnished to do so, subject to the following conditions:
 
17
//
 
18
// The above copyright notice and this permission notice shall be included in
 
19
// all copies or substantial portions of the Software.
 
20
//
 
21
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 
22
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 
23
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
 
24
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 
25
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
 
26
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
 
27
// IN THE SOFTWARE.
 
28
//////////////////////////////////////////////////////////////////////////////
 
29
 
 
30
#include "oxygentileset.h"
 
31
#include "oxygenhelper.h"
 
32
 
 
33
#include <QtGui/QWidget>
 
34
#include <QtGui/QPaintEvent>
 
35
#include <QtGui/QPixmap>
 
36
#include <cassert>
 
37
 
 
38
namespace Oxygen
 
39
{
 
40
 
 
41
    //! shadow demo widget
 
42
    class ShadowDemoWidget: public QWidget
 
43
    {
 
44
 
 
45
        Q_OBJECT
 
46
 
 
47
        public:
 
48
 
 
49
        //! constructor
 
50
        explicit ShadowDemoWidget( QWidget* parent = 0 ):
 
51
            QWidget( parent ),
 
52
            _drawBackground( true ),
 
53
            _square( false ),
 
54
            _helper( 0L )
 
55
            {}
 
56
 
 
57
        //! destructor
 
58
        virtual ~ShadowDemoWidget( void )
 
59
        {}
 
60
 
 
61
        //! helper
 
62
        void setHelper( Helper& helper )
 
63
        { _helper = &helper; }
 
64
 
 
65
        //! set tileSet
 
66
        void setTileSet( const TileSet& tileSet )
 
67
        {
 
68
            _tileSet = tileSet;
 
69
            if( isVisible() ) update();
 
70
        }
 
71
 
 
72
        //! tileset
 
73
        const TileSet& tileSet( void ) const
 
74
        { return _tileSet; }
 
75
 
 
76
        //! set shadow size
 
77
        void setShadowSize( int size )
 
78
        {
 
79
            _shadowSize = size;
 
80
            setMinimumSize( _shadowSize*2 + 100, _shadowSize*2 + 60 );
 
81
        }
 
82
 
 
83
        //! square
 
84
        void setSquare( bool value )
 
85
        {
 
86
            _square = value;
 
87
             if( isVisible() ) update();
 
88
        }
 
89
 
 
90
        protected slots:
 
91
 
 
92
        //! toggle background drawing
 
93
        void toggleBackground( bool value )
 
94
        {
 
95
            if( value == _drawBackground ) return;
 
96
            _drawBackground = value;
 
97
            update();
 
98
        }
 
99
 
 
100
        protected:
 
101
 
 
102
        //! paint event
 
103
        virtual void paintEvent( QPaintEvent* );
 
104
 
 
105
        //! render window to pixmap
 
106
        void updateBackgroundPixmap( void );
 
107
 
 
108
        Helper& helper( void ) const
 
109
        {
 
110
            assert( _helper );
 
111
            return *_helper;
 
112
        }
 
113
 
 
114
        private:
 
115
 
 
116
        //! shadow size
 
117
        int _shadowSize;
 
118
 
 
119
        //! draw window background
 
120
        bool _drawBackground;
 
121
 
 
122
        //! true if (bottom) corners are square
 
123
        bool _square;
 
124
 
 
125
        //! helper
 
126
        Helper* _helper;
 
127
 
 
128
        //! dummy widget
 
129
        QWidget _dummy;
 
130
 
 
131
        //! window pixmap
 
132
        QPixmap _backgroundPixmap;
 
133
 
 
134
        //! tileSet
 
135
        TileSet _tileSet;
 
136
 
 
137
    };
 
138
}
 
139
 
 
140
#endif