#ifndef Widget_h
#define Widget_h
#if PLATFORM(IOS)
#ifndef NSView
#define NSView WAKView
#endif
#endif
#include "IntRect.h"
#include "PlatformScreen.h"
#include <wtf/Forward.h>
#include <wtf/RefCounted.h>
#if PLATFORM(MAC)
#include <wtf/RetainPtr.h>
#endif
#if PLATFORM(QT)
#include <QPointer>
#include <qglobal.h>
#endif
#if PLATFORM(MAC)
OBJC_CLASS NSView;
OBJC_CLASS NSWindow;
typedef NSView *PlatformWidget;
#endif
#if PLATFORM(WIN)
typedef struct HWND__* HWND;
typedef HWND PlatformWidget;
#endif
#if PLATFORM(GTK)
typedef struct _GtkWidget GtkWidget;
typedef struct _GtkContainer GtkContainer;
typedef GtkWidget* PlatformWidget;
#endif
#if PLATFORM(QT)
QT_BEGIN_NAMESPACE
class QObject;
QT_END_NAMESPACE
typedef QObject* PlatformWidget;
#endif
#if PLATFORM(BLACKBERRY)
typedef void* PlatformWidget;
#endif
#if PLATFORM(EFL)
#if USE(EO)
typedef struct _Eo Evas_Object;
#else
typedef struct _Evas_Object Evas_Object;
#endif
typedef Evas_Object* PlatformWidget;
#endif
#if PLATFORM(QT)
class QWebPageClient;
typedef QWebPageClient* PlatformPageClient;
#elif PLATFORM(BLACKBERRY)
#include "PageClientBlackBerry.h"
typedef PageClientBlackBerry* PlatformPageClient;
#elif PLATFORM(EFL)
class PageClientEfl;
typedef PageClientEfl* PlatformPageClient;
#else
typedef PlatformWidget PlatformPageClient;
#endif
namespace WebCore {
class Cursor;
class Event;
class Font;
class GraphicsContext;
class PlatformMouseEvent;
class ScrollView;
class WidgetPrivate;
enum WidgetNotification { WillPaintFlattened, DidPaintFlattened };
class Widget : public RefCounted<Widget> {
public:
explicit Widget(PlatformWidget = 0);
virtual ~Widget();
PlatformWidget platformWidget() const;
void setPlatformWidget(PlatformWidget);
int x() const { return frameRect().x(); }
int y() const { return frameRect().y(); }
int width() const { return frameRect().width(); }
int height() const { return frameRect().height(); }
IntSize size() const { return frameRect().size(); }
IntPoint location() const { return frameRect().location(); }
virtual void setFrameRect(const IntRect&);
IntRect frameRect() const;
IntRect boundsRect() const { return IntRect(0, 0, width(), height()); }
void resize(int w, int h) { setFrameRect(IntRect(x(), y(), w, h)); }
void resize(const IntSize& s) { setFrameRect(IntRect(location(), s)); }
void move(int x, int y) { setFrameRect(IntRect(x, y, width(), height())); }
void move(const IntPoint& p) { setFrameRect(IntRect(p, size())); }
virtual void paint(GraphicsContext*, const IntRect&);
void invalidate() { invalidateRect(boundsRect()); }
virtual void invalidateRect(const IntRect&) = 0;
virtual void setFocus(bool);
void setCursor(const Cursor&);
virtual void show();
virtual void hide();
bool isSelfVisible() const { return m_selfVisible; } bool isParentVisible() const { return m_parentVisible; } bool isVisible() const { return m_selfVisible && m_parentVisible; } virtual void setParentVisible(bool visible) { m_parentVisible = visible; }
void setSelfVisible(bool v) { m_selfVisible = v; }
void setIsSelected(bool);
virtual bool isFrameView() const { return false; }
virtual bool isPluginView() const { return false; }
virtual bool isPluginViewBase() const { return false; }
virtual bool isScrollbar() const { return false; }
virtual bool isScrollView() const { return false; }
void removeFromParent();
virtual void setParent(ScrollView* view);
ScrollView* parent() const { return m_parent; }
ScrollView* root() const;
virtual void handleEvent(Event*) { }
virtual void notifyWidget(WidgetNotification) { }
IntRect convertToRootView(const IntRect&) const;
IntRect convertFromRootView(const IntRect&) const;
IntPoint convertToRootView(const IntPoint&) const;
IntPoint convertFromRootView(const IntPoint&) const;
IntRect convertToContainingWindow(const IntRect&) const;
IntRect convertFromContainingWindow(const IntRect&) const;
IntPoint convertToContainingWindow(const IntPoint&) const;
IntPoint convertFromContainingWindow(const IntPoint&) const;
virtual void frameRectsChanged();
virtual void widgetPositionsUpdated() {}
virtual void clipRectChanged() { }
virtual bool transformsAffectFrameRect() { return true; }
#if PLATFORM(MAC) || PLATFORM(IOS)
NSView* getOuterView() const;
void removeFromSuperview();
#endif
#if PLATFORM(IOS)
void addToSuperview(NSView* superview);
#endif
#if PLATFORM(EFL)
void setEvasObject(Evas_Object*);
Evas_Object* evasObject() { return m_evasObject; }
#endif
#if PLATFORM(QT)
QObject* bindingObject() const;
void setBindingObject(QObject*);
#endif
virtual IntRect convertToContainingView(const IntRect&) const;
virtual IntRect convertFromContainingView(const IntRect&) const;
virtual IntPoint convertToContainingView(const IntPoint&) const;
virtual IntPoint convertFromContainingView(const IntPoint&) const;
virtual PlatformDisplayID windowDisplayID() const;
private:
void init(PlatformWidget);
void releasePlatformWidget();
void retainPlatformWidget();
static IntRect convertFromRootToContainingWindow(const Widget* rootWidget, const IntRect&);
static IntRect convertFromContainingWindowToRoot(const Widget* rootWidget, const IntRect&);
static IntPoint convertFromRootToContainingWindow(const Widget* rootWidget, const IntPoint&);
static IntPoint convertFromContainingWindowToRoot(const Widget* rootWidget, const IntPoint&);
private:
ScrollView* m_parent;
#if !PLATFORM(MAC)
PlatformWidget m_widget;
#else
RetainPtr<NSView> m_widget;
#endif
bool m_selfVisible;
bool m_parentVisible;
IntRect m_frame;
#if !PLATFORM(IOS)
#if PLATFORM(MAC)
WidgetPrivate* m_data;
#endif
#endif // !PLATFORM(IOS)
#if PLATFORM(EFL)
Evas_Object* m_evasObject;
#endif
#if PLATFORM(QT)
QPointer<QObject> m_bindingObject;
#endif
};
#if !PLATFORM(MAC)
inline PlatformWidget Widget::platformWidget() const
{
return m_widget;
}
inline void Widget::setPlatformWidget(PlatformWidget widget)
{
if (widget != m_widget) {
releasePlatformWidget();
m_widget = widget;
retainPlatformWidget();
}
}
#endif
#if !PLATFORM(GTK)
inline void Widget::releasePlatformWidget()
{
}
inline void Widget::retainPlatformWidget()
{
}
#endif
}
#endif // Widget_h