~ubuntu-branches/ubuntu/gutsy/kdebase-workspace/gutsy

« back to all changes in this revision

Viewing changes to libs/plasma/widgets/layoutitem.h

  • Committer: Bazaar Package Importer
  • Author(s): Jonathan Riddell
  • Date: 2007-09-05 20:45:14 UTC
  • Revision ID: james.westby@ubuntu.com-20070905204514-632hhspl0nvrc84i
Tags: upstream-3.93.0
ImportĀ upstreamĀ versionĀ 3.93.0

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 *   Copyright 2007 by Matias Valdenegro T. <mvaldenegro@informatica.utem.cl>
 
3
 *
 
4
 *   This program is free software; you can redistribute it and/or modify
 
5
 *   it under the terms of the GNU Library General Public License version 2 as
 
6
 *   published by the Free Software Foundation
 
7
 *
 
8
 *   This program is distributed in the hope that it will be useful,
 
9
 *   but WITHOUT ANY WARRANTY; without even the implied warranty of
 
10
 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
11
 *   GNU General Public License for more details
 
12
 *
 
13
 *   You should have received a copy of the GNU Library General Public
 
14
 *   License along with this program; if not, write to the
 
15
 *   Free Software Foundation, Inc.,
 
16
 *   51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
 
17
 */
 
18
 
 
19
#ifndef __LAYOUT_ITEM__
 
20
#define __LAYOUT_ITEM__
 
21
 
 
22
#include <QtCore/QRectF>
 
23
#include <QtCore/QSizeF>
 
24
 
 
25
#include <plasma/plasma_export.h>
 
26
 
 
27
class QGraphicsItem;
 
28
 
 
29
namespace Plasma
 
30
{
 
31
 
 
32
class Layout;
 
33
 
 
34
/**
 
35
 * Base class for Plasma layout-managed items
 
36
 *
 
37
 * @author Matias Valdenegro T. <mvaldenegro@informatica.utem.cl>
 
38
 *
 
39
 * All layout-managed items should implement this class, but regular users just need to use
 
40
 * Plasma::Widget and Plasma::Layout.
 
41
 */
 
42
class PLASMA_EXPORT LayoutItem
 
43
{
 
44
    public:
 
45
 
 
46
        /**
 
47
         * Constructor.
 
48
         */
 
49
        explicit LayoutItem();
 
50
 
 
51
        /**
 
52
         * Virtual Destructor.
 
53
         */
 
54
        virtual ~LayoutItem();
 
55
 
 
56
        /**
 
57
         * Returns a bitmask with the directions that this Item can be expanded.
 
58
         */
 
59
        virtual Qt::Orientations expandingDirections() const = 0;
 
60
 
 
61
        /**
 
62
         * Returns the minimum size of this Item and it's contents.
 
63
         */
 
64
        virtual QSizeF minimumSize() const = 0;
 
65
 
 
66
        /**
 
67
         * Returns the maximum size of this Item.
 
68
         */
 
69
        virtual QSizeF maximumSize() const = 0;
 
70
 
 
71
        /**
 
72
         * Returns true whatever this Item can use height-for-width layout management,
 
73
         * false otherwise.
 
74
         */
 
75
        virtual bool hasHeightForWidth() const;
 
76
 
 
77
        /**
 
78
         * Returns the corresponding height for a given width.
 
79
         * @param w Width
 
80
         */
 
81
        virtual qreal heightForWidth(qreal w) const;
 
82
 
 
83
        /**
 
84
         * Returns true whatever this Item can use width-for-height layout management,
 
85
         * false otherwise.
 
86
         */
 
87
        virtual bool hasWidthForHeight() const;
 
88
 
 
89
        /**
 
90
         * Returns the corresponding width for a given height.
 
91
         * @param h Height
 
92
         */
 
93
        virtual qreal widthForHeight(qreal h) const;
 
94
 
 
95
        /**
 
96
         * Returns the geometry of this Item.
 
97
         */
 
98
        virtual QRectF geometry() const = 0;
 
99
 
 
100
        /**
 
101
         * Sets the geometry of this Item.
 
102
         */
 
103
        virtual void setGeometry(const QRectF& geometry) = 0;
 
104
 
 
105
        /**
 
106
         * Returns the most appropriate size of this Item to hold whatever contents it has.
 
107
         */
 
108
        virtual QSizeF sizeHint() const = 0;
 
109
 
 
110
        /**
 
111
         * Sets the layout that will manage children items
 
112
         *
 
113
         * @param layout The Layout that this LayoutItem will be managed by.
 
114
         */
 
115
        void setLayout(Layout* layout);
 
116
 
 
117
        /**
 
118
         * @return the layout this item is currently associated with.
 
119
         */
 
120
        Layout* layout() const;
 
121
 
 
122
        /**
 
123
         * Sets the layout that manages this item's geometry
 
124
         *
 
125
         * @param layout the layout that manage this item's geometry
 
126
         **/
 
127
        void setManagingLayout(Layout* layout);
 
128
 
 
129
        /**
 
130
         * Resets the layout that manges this item's geometry if it is the
 
131
         * currently associated layout
 
132
         *
 
133
         * @param layout to unset
 
134
         **/
 
135
        void unsetManagingLayout(Layout* layout);
 
136
 
 
137
        /**
 
138
         * @return the layout that manages this item's geometry, or 0 if none
 
139
         **/
 
140
        Layout* managingLayout() const;
 
141
 
 
142
        /**
 
143
         * Returns the graphics item associated with this layout item or 0
 
144
         * if there is no associated graphics item.
 
145
         *
 
146
         * The default implementation returns 0.
 
147
         */
 
148
        virtual QGraphicsItem* graphicsItem();
 
149
 
 
150
    private:
 
151
        class Private;
 
152
        Private *const d;
 
153
};
 
154
 
 
155
}
 
156
 
 
157
#endif /* __LAYOUT_ITEM__ */