#ifndef Widget_h
#define Widget_h
#include <wtf/Platform.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(CHROMIUM)
#include "PlatformWidget.h"
#endif
#include "IntPoint.h"
#include "IntRect.h"
#include "IntSize.h"
namespace WebCore {
class Cursor;
class Event;
class Font;
class GraphicsContext;
class PlatformMouseEvent;
class ScrollView;
class WidgetClient;
class WidgetPrivate;
class 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();
}
}
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();
void setCursor(const Cursor&);
Cursor 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; }
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;
IntPoint convertToContainingWindow(const IntPoint&) const;
IntPoint convertFromContainingWindow(const IntPoint&) const; IntRect convertFromContainingWindow(const IntRect&) const;
virtual void frameRectsChanged() {}
#if PLATFORM(MAC)
NSView* getOuterView() const;
static void beforeMouseDown(NSView*, Widget*);
static void afterMouseDown(NSView*, Widget*);
void removeFromSuperview();
#endif
void addToSuperview(NSView* superview);
private:
void init(PlatformWidget);
void releasePlatformWidget();
void retainPlatformWidget();
private:
ScrollView* m_parent;
PlatformWidget m_widget;
bool m_selfVisible;
bool m_parentVisible;
IntRect m_frame;
#if PLATFORM(MAC) || PLATFORM(GTK)
WidgetPrivate* m_data;
#endif
};
}
#endif // Widget_h