source: trunk/src/qt3support/widgets/q3frame.cpp@ 1023

Last change on this file since 1023 was 846, checked in by Dmitry A. Kuminov, 14 years ago

trunk: Merged in qt 4.7.2 sources from branches/vendor/nokia/qt.

File size: 5.5 KB
Line 
1/****************************************************************************
2**
3** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
4** All rights reserved.
5** Contact: Nokia Corporation ([email protected])
6**
7** This file is part of the Qt3Support module of the Qt Toolkit.
8**
9** $QT_BEGIN_LICENSE:LGPL$
10** Commercial Usage
11** Licensees holding valid Qt Commercial licenses may use this file in
12** accordance with the Qt Commercial License Agreement provided with the
13** Software or, alternatively, in accordance with the terms contained in
14** a written agreement between you and Nokia.
15**
16** GNU Lesser General Public License Usage
17** Alternatively, this file may be used under the terms of the GNU Lesser
18** General Public License version 2.1 as published by the Free Software
19** Foundation and appearing in the file LICENSE.LGPL included in the
20** packaging of this file. Please review the following information to
21** ensure the GNU Lesser General Public License version 2.1 requirements
22** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
23**
24** In addition, as a special exception, Nokia gives you certain additional
25** rights. These rights are described in the Nokia Qt LGPL Exception
26** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
27**
28** GNU General Public License Usage
29** Alternatively, this file may be used under the terms of the GNU
30** General Public License version 3.0 as published by the Free Software
31** Foundation and appearing in the file LICENSE.GPL included in the
32** packaging of this file. Please review the following information to
33** ensure the GNU General Public License version 3.0 requirements will be
34** met: http://www.gnu.org/copyleft/gpl.html.
35**
36** If you have questions regarding the use of this file, please contact
37** Nokia at [email protected].
38** $QT_END_LICENSE$
39**
40****************************************************************************/
41
42#include "q3frame.h"
43#include "qevent.h"
44#include "qpainter.h"
45
46QT_BEGIN_NAMESPACE
47
48/*! \class Q3Frame
49
50 \compat
51*/
52
53/*!
54 Creates a new frame with the given \a parent, object \a name, and
55 with widget flags \a f.
56*/
57Q3Frame::Q3Frame(QWidget* parent, const char* name, Qt::WindowFlags f)
58 :QFrame(parent, f), marg(0)
59{
60 if (name)
61 setObjectName(QLatin1String(name));
62 setAttribute(Qt::WA_LayoutOnEntireRect);
63}
64
65/*!
66 Destructs the frame.
67*/
68Q3Frame::~Q3Frame()
69{
70}
71
72/*!
73 Paints the frame (or part of the frame) that's necessary,
74 depending on the \a event.
75*/
76void Q3Frame::paintEvent(QPaintEvent * event)
77{
78 QPainter paint(this);
79 if (!contentsRect().contains(event->rect())) {
80 paint.save();
81 paint.setClipRegion(event->region().intersected(frameRect()));
82 drawFrame(&paint);
83 paint.restore();
84 }
85 if (event->rect().intersects(contentsRect())) {
86 paint.setClipRegion(event->region().intersected(contentsRect()));
87 drawContents(&paint);
88 }
89}
90
91/*!
92 \fn void Q3Frame::drawContents(QPainter *painter)
93
94 Virtual function that draws the contents of the frame on the given
95 \a painter.
96
97 The QPainter is already open when you get it, and you must leave
98 it open. Painter \link QPainter::setWorldMatrix()
99 transformations\endlink are switched off on entry. If you
100 transform the painter, remember to take the frame into account and
101 \link QPainter::resetXForm() reset transformation\endlink before
102 returning.
103
104 This function is reimplemented by subclasses that draw something
105 inside the frame. It should only draw inside contentsRect(). The
106 default function does nothing.
107
108 \sa contentsRect(), QPainter::setClipRect()
109*/
110
111void Q3Frame::drawContents(QPainter *)
112{
113}
114
115/*!
116 Draws the frame using the painter \a p and the current frame
117 attributes and color group. The rectangle inside the frame is not
118 affected.
119
120 This function is virtual, but in general you do not need to
121 reimplement it. If you do, note that the QPainter is already open
122 and must remain open.
123
124 \sa frameRect(), contentsRect(), drawContents(), frameStyle(), setPalette()
125*/
126
127void Q3Frame::drawFrame(QPainter *p)
128{
129 QFrame::drawFrame(p);
130}
131