1
/****************************************************************************
3
** Copyright (C) 1992-2005 Trolltech AS. All rights reserved.
5
** This file is part of the Qt 3 compatibility classes of the Qt Toolkit.
7
** This file may be distributed under the terms of the Q Public License
8
** as defined by Trolltech AS of Norway and appearing in the file
9
** LICENSE.QPL included in the packaging of this file.
11
** This file may be distributed and/or modified under the terms of the
12
** GNU General Public License version 2 as published by the Free Software
13
** Foundation and appearing in the file LICENSE.GPL included in the
14
** packaging of this file.
16
** See http://www.trolltech.com/pricing.html or email sales@trolltech.com for
17
** information about Qt Commercial License Agreements.
18
** See http://www.trolltech.com/qpl/ for QPL licensing information.
19
** See http://www.trolltech.com/gpl/ for GPL licensing information.
21
** Contact info@trolltech.com if any conditions of this licensing are
24
** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
25
** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
27
****************************************************************************/
40
Creates a new frame with the given \a parent, object \a name, and
41
with widget flags \a f.
43
Q3Frame::Q3Frame(QWidget* parent, const char* name, Qt::WFlags f)
44
:QFrame(parent, f), marg(0)
48
setAttribute(Qt::WA_LayoutOnEntireRect);
49
setAttribute(Qt::WA_PaintOnScreen);
60
Paints the frame (or part of the frame) that's necessary,
61
depending on the \a event.
63
void Q3Frame::paintEvent(QPaintEvent * event)
66
if (!contentsRect().contains(event->rect())) {
68
paint.setClipRegion(event->region().intersect(frameRect()));
72
if (event->rect().intersects(contentsRect())) {
73
paint.setClipRegion(event->region().intersect(contentsRect()));
79
\fn void Q3Frame::drawContents(QPainter *painter)
81
Virtual function that draws the contents of the frame on the given
84
The QPainter is already open when you get it, and you must leave
85
it open. Painter \link QPainter::setWorldMatrix()
86
transformations\endlink are switched off on entry. If you
87
transform the painter, remember to take the frame into account and
88
\link QPainter::resetXForm() reset transformation\endlink before
91
This function is reimplemented by subclasses that draw something
92
inside the frame. It should only draw inside contentsRect(). The
93
default function does nothing.
95
\sa contentsRect(), QPainter::setClipRect()
98
void Q3Frame::drawContents(QPainter *)
103
Draws the frame using the painter \a p and the current frame
104
attributes and color group. The rectangle inside the frame is not
107
This function is virtual, but in general you do not need to
108
reimplement it. If you do, note that the QPainter is already open
109
and must remain open.
111
\sa frameRect(), contentsRect(), drawContents(), frameStyle(), setPalette()
114
void Q3Frame::drawFrame(QPainter *p)
116
QFrame::drawFrame(p);
120
\fn void Q3Frame::resizeEvent(QResizeEvent *event)
122
This just calls frameChanged(); it does not make use of the \a
125
void Q3Frame::resizeEvent(QResizeEvent *)
131
Virtual function that is called when the frame style, line width
132
or mid-line width changes.
134
This function can be reimplemented by subclasses that need to know
135
when the frame attributes change.
138
void Q3Frame::frameChanged()
144
\property Q3Frame::margin
145
\brief the width of the margin
147
The margin is the distance between the innermost pixel of the
148
frame and the outermost pixel of contentsRect(). It is included in
151
The margin is filled according to backgroundMode().
153
The default value is 0.
155
\sa lineWidth(), frameWidth()
158
void Q3Frame::setMargin(int w)
168
\property Q3Frame::contentsRect
169
\brief the frame's contents rectangle (including the margins)
171
QRect Q3Frame::contentsRect() const
173
QRect cr(QFrame::contentsRect());
174
cr.adjust(marg, marg, -marg, -marg);
179
Returns the width of the frame (including the margin).
181
int Q3Frame::frameWidth() const
183
return QFrame::frameWidth() + marg;