#ifndef Widget_h
#define Widget_h
#include "platform/PlatformExport.h"
#include "platform/geometry/IntRect.h"
#include "wtf/Forward.h"
#include "wtf/RefCounted.h"
namespace WebCore {
class Event;
class GraphicsContext;
class HostWindow;
class PLATFORM_EXPORT Widget : public RefCounted<Widget> {
public:
Widget();
virtual ~Widget();
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& frame) { m_frame = frame; }
const IntRect& frameRect() const { return m_frame; }
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) { }
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; }
virtual bool isFrameView() const { return false; }
virtual bool isRemoteFrameView() const { return false; }
virtual bool isPluginView() const { return false; }
virtual bool isPluginContainer() const { return false; }
virtual bool pluginShouldPersist() const { return false; }
virtual bool isScrollbar() const { return false; }
virtual bool isScrollView() const { return false; }
virtual HostWindow* hostWindow() const { ASSERT_NOT_REACHED(); return 0; }
virtual void setParent(Widget*);
Widget* parent() const { return m_parent; }
Widget* root() const;
virtual void handleEvent(Event*) { }
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 IntRect convertToContainingView(const IntRect&) const;
virtual IntRect convertFromContainingView(const IntRect&) const;
virtual IntPoint convertToContainingView(const IntPoint&) const;
virtual IntPoint convertFromContainingView(const IntPoint&) const;
virtual IntPoint convertChildToSelf(const Widget*, const IntPoint&) const;
virtual IntPoint convertSelfToChild(const Widget*, const IntPoint&) const;
virtual void eventListenersRemoved() { }
private:
Widget* m_parent;
IntRect m_frame;
bool m_selfVisible;
bool m_parentVisible;
};
}
#endif