#ifndef Widget_h
#define Widget_h
#ifndef NSView
#define NSView WAKView
#endif
#if PLATFORM(MAC)
#ifdef __OBJC__
@class NSView;
@class NSWindow;
#else
class NSView;
class NSWindow;
#endif
typedef NSView* PlatformWidget;
#endif
#if PLATFORM(WIN)
typedef struct HWND__* HWND;
typedef HWND PlatformWidget;
#endif
#if PLATFORM(GTK)
typedef struct _GdkDrawable GdkDrawable;
typedef struct _GtkWidget GtkWidget;
typedef struct _GtkContainer GtkContainer;
typedef GtkWidget* PlatformWidget;
#endif
#if PLATFORM(QT)
#include <qglobal.h>
QT_BEGIN_NAMESPACE
class QWidget;
QT_END_NAMESPACE
typedef QWidget* PlatformWidget;
#endif
#if PLATFORM(WX)
class wxWindow;
typedef wxWindow* PlatformWidget;
#endif
#if PLATFORM(HAIKU)
class BView;
typedef BView* PlatformWidget;
#endif
#if PLATFORM(CHROMIUM)
#include "PlatformWidget.h"
#endif
#if PLATFORM(EFL)
#include <Ecore_Evas.h>
#include <Evas.h>
typedef Evas_Object* PlatformWidget;
#endif
#if PLATFORM(QT)
class QWebPageClient;
typedef QWebPageClient* PlatformPageClient;
#else
typedef PlatformWidget PlatformPageClient;
#endif
#include "IntPoint.h"
#include "IntRect.h"
#include "IntSize.h"
#include <wtf/RefCounted.h>
namespace WebCore {
class Cursor;
class Event;
class Font;
class GraphicsContext;
class PlatformMouseEvent;
class ScrollView;
class WidgetPrivate;
#if PLATFORM(EFL)
class String;
#endif
class Widget : public RefCounted<Widget> {
public:
Widget(PlatformWidget = 0);
virtual ~Widget();
PlatformWidget platformWidget() const { return m_widget; }
void setPlatformWidget(PlatformWidget widget)
{
if (widget != m_widget) {
releasePlatformWidget();
m_widget = widget;
retainPlatformWidget();
}
}
#if PLATFORM(HAIKU)
PlatformWidget topLevelPlatformWidget() const { return m_topLevelPlatformWidget; }
void setTopLevelPlatformWidget(PlatformWidget widget)
{
m_topLevelPlatformWidget = widget;
}
#endif
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 pos() const { return frameRect().location(); }
virtual void setFrameRect(const IntRect&);
virtual 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(pos(), 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 isPluginWidget() const { return false; }
virtual bool isScrollbar() const { return false; }
void removeFromParent();
virtual void setParent(ScrollView* view);
ScrollView* parent() const { return m_parent; }
ScrollView* root() const;
virtual void handleEvent(Event*) { }
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() {}
NSView* getOuterView() const;
static void beforeMouseDown(NSView*, Widget*);
static void afterMouseDown(NSView*, Widget*);
void removeFromSuperview();
void addToSuperview(NSView* superview);
#if PLATFORM(EFL)
Evas* evas() const;
void setEvasObject(Evas_Object*);
Evas_Object* evasObject() const;
const String edjeTheme() const;
void setEdjeTheme(const String &);
const String edjeThemeRecursive() const;
#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;
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;
PlatformWidget m_widget;
bool m_selfVisible;
bool m_parentVisible;
IntRect m_frame;
#if PLATFORM(EFL)
Ecore_Evas* ecoreEvas() const;
void applyFallbackCursor();
void applyCursor();
#endif
#if PLATFORM(MAC) || PLATFORM(EFL)
WidgetPrivate* m_data;
#endif
#if PLATFORM(HAIKU)
PlatformWidget m_topLevelPlatformWidget;
#endif
};
}
#endif // Widget_h