1/*
2 * Copyright 2007, The Android Open Source Project
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions
6 * are met:
7 *  * Redistributions of source code must retain the above copyright
8 *    notice, this list of conditions and the following disclaimer.
9 *  * Redistributions in binary form must reproduce the above copyright
10 *    notice, this list of conditions and the following disclaimer in the
11 *    documentation and/or other materials provided with the distribution.
12 *
13 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ``AS IS'' AND ANY
14 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
15 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
16 * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL APPLE COMPUTER, INC. OR
17 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
18 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
19 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
20 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
21 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
22 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
23 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
24 */
25
26#include "config.h"
27#include "Widget.h"
28
29#include "Font.h"
30#include "FrameView.h"
31#include "GraphicsContext.h"
32#include "NotImplemented.h"
33#include "WebCoreFrameBridge.h"
34#include "WebCoreViewBridge.h"
35#include "WebViewCore.h"
36
37namespace WebCore {
38
39Widget::Widget(PlatformWidget widget)
40{
41    init(widget);
42}
43
44Widget::~Widget()
45{
46    ASSERT(!parent());
47    releasePlatformWidget();
48}
49
50IntRect Widget::frameRect() const
51{
52    if (!platformWidget())
53        return m_frame;
54    return platformWidget()->getBounds();
55}
56
57void Widget::setFocus(bool focused)
58{
59    notImplemented();
60}
61
62void Widget::paint(GraphicsContext* ctx, const IntRect& r)
63{
64}
65
66void Widget::releasePlatformWidget()
67{
68    Release(platformWidget());
69}
70
71void Widget::retainPlatformWidget()
72{
73    Retain(platformWidget());
74}
75
76void Widget::setCursor(const Cursor& cursor)
77{
78    notImplemented();
79}
80
81void Widget::show()
82{
83    notImplemented();
84}
85
86void Widget::hide()
87{
88    notImplemented();
89}
90
91void Widget::setFrameRect(const IntRect& rect)
92{
93    m_frame = rect;
94    // platformWidget() is 0 when called from Scrollbar
95    if (!platformWidget())
96        return;
97    platformWidget()->setLocation(rect.x(), rect.y());
98    platformWidget()->setSize(rect.width(), rect.height());
99}
100
101void Widget::setIsSelected(bool isSelected)
102{
103    notImplemented();
104}
105
106int Widget::textWrapWidth() const
107{
108    const Widget* widget = this;
109    while (!widget->isFrameView()) {
110        widget = widget->parent();
111        if (!widget)
112            break;
113    }
114    if (!widget)
115        return 0;
116    android::WebViewCore* core = android::WebViewCore::getWebViewCore(
117        static_cast<const ScrollView*>(widget));
118    if (!core)
119        return 0;
120    return core->textWrapWidth();
121}
122
123} // WebCore namepsace
124