#include "config.h"
#include "Widget.h"
#include "Cursor.h"
#include "IntRect.h"
#include "NotImplemented.h"
#include <View.h>
namespace WebCore {
class AutoPlatformWidgetLocker {
public:
AutoPlatformWidgetLocker(PlatformWidget widget)
: m_widget(widget)
{
if (!m_widget || m_widget->LockLooperWithTimeout(5000) != B_OK)
m_widget = 0;
}
~AutoPlatformWidgetLocker()
{
if (m_widget)
m_widget->UnlockLooper();
}
bool isLocked() const
{
return m_widget;
}
private:
PlatformWidget m_widget;
};
Widget::Widget(PlatformWidget widget)
: m_topLevelPlatformWidget(0)
{
init(widget);
}
Widget::~Widget()
{
}
IntRect Widget::frameRect() const
{
return m_frame;
}
void Widget::setFrameRect(const IntRect& rect)
{
m_frame = rect;
}
void Widget::setFocus(bool focused)
{
if (focused) {
AutoPlatformWidgetLocker locker(topLevelPlatformWidget());
if (locker.isLocked())
topLevelPlatformWidget()->MakeFocus();
}
}
void Widget::setCursor(const Cursor& cursor)
{
AutoPlatformWidgetLocker locker(topLevelPlatformWidget());
if (locker.isLocked())
topLevelPlatformWidget()->SetViewCursor(cursor.impl());
}
void Widget::show()
{
setSelfVisible(true);
if (!isParentVisible())
return;
AutoPlatformWidgetLocker locker(platformWidget());
if (locker.isLocked() && platformWidget()->IsHidden())
platformWidget()->Show();
}
void Widget::hide()
{
setSelfVisible(false);
if (!isParentVisible())
return;
AutoPlatformWidgetLocker locker(platformWidget());
if (locker.isLocked() && !platformWidget()->IsHidden())
platformWidget()->Hide();
}
void Widget::paint(GraphicsContext*, IntRect const&)
{
notImplemented();
}
void Widget::setIsSelected(bool)
{
notImplemented();
}
}