1 /*
2 * Copyright (C) 2006 Dirk Mueller <mueller@kde.org>
3 * Copyright (C) 2006 George Staikos <staikos@kde.org>
4 * Copyright (C) 2006 Zack Rusin <zack@kde.org>
5 * Copyright (C) 2006 Nikolas Zimmermann <zimmermann@kde.org>
6 * Copyright (C) 2008 Holger Hans Peter Freyther
7 *
8 * All rights reserved.
9 *
10 * Redistribution and use in source and binary forms, with or without
11 * modification, are permitted provided that the following conditions
12 * are met:
13 * 1. Redistributions of source code must retain the above copyright
14 * notice, this list of conditions and the following disclaimer.
15 * 2. Redistributions in binary form must reproduce the above copyright
16 * notice, this list of conditions and the following disclaimer in the
17 * documentation and/or other materials provided with the distribution.
18 *
19 * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
20 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
21 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
23 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
24 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
25 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
26 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
27 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
28 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
29 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 */
31
32 #include "config.h"
33 #include "Widget.h"
34
35 #include "Cursor.h"
36 #include "Font.h"
37 #include "GraphicsContext.h"
38 #include "HostWindow.h"
39 #include "IntRect.h"
40 #include "NotImplemented.h"
41 #include "QWebPageClient.h"
42 #include "ScrollView.h"
43
44 #include <QApplication>
45 #include <QCoreApplication>
46 #include <QDebug>
47 #include <QPaintEngine>
48 #include <QPainter>
49 #include <QWidget>
50
51 namespace WebCore {
52
Widget(QWidget * widget)53 Widget::Widget(QWidget* widget)
54 {
55 init(widget);
56 }
57
~Widget()58 Widget::~Widget()
59 {
60 Q_ASSERT(!parent());
61 }
62
frameRect() const63 IntRect Widget::frameRect() const
64 {
65 return m_frame;
66 }
67
setFrameRect(const IntRect & rect)68 void Widget::setFrameRect(const IntRect& rect)
69 {
70 m_frame = rect;
71
72 frameRectsChanged();
73 }
74
setFocus(bool focused)75 void Widget::setFocus(bool focused)
76 {
77 }
78
setCursor(const Cursor & cursor)79 void Widget::setCursor(const Cursor& cursor)
80 {
81 #ifndef QT_NO_CURSOR
82 if (QApplication::type() == QApplication::Tty)
83 return;
84
85 ScrollView* view = root();
86 if (!view)
87 return;
88 view->hostWindow()->setCursor(cursor);
89 #endif
90 }
91
show()92 void Widget::show()
93 {
94 setSelfVisible(true);
95
96 if (isParentVisible() && platformWidget())
97 platformWidget()->show();
98 }
99
hide()100 void Widget::hide()
101 {
102 setSelfVisible(false);
103
104 if (isParentVisible() && platformWidget())
105 platformWidget()->hide();
106 }
107
paint(GraphicsContext *,const IntRect &)108 void Widget::paint(GraphicsContext*, const IntRect&)
109 {
110 }
111
setIsSelected(bool)112 void Widget::setIsSelected(bool)
113 {
114 notImplemented();
115 }
116
setBindingObject(QObject * object)117 void Widget::setBindingObject(QObject* object)
118 {
119 m_bindingObject = object;
120 }
121
bindingObject() const122 QObject* Widget::bindingObject() const
123 {
124 return m_bindingObject.data();
125 }
126
127 }
128
129 // vim: ts=4 sw=4 et
130