#ifndef PopupMenuWin_h
#define PopupMenuWin_h
#include "IntRect.h"
#include "PopupMenu.h"
#include "PopupMenuClient.h"
#include "ScrollableArea.h"
#include "Scrollbar.h"
#include <wtf/PassRefPtr.h>
#include <wtf/RefCounted.h>
#include <wtf/RefPtr.h>
typedef struct HWND__* HWND;
typedef struct HDC__* HDC;
typedef struct HBITMAP__* HBITMAP;
namespace WebCore {
class FrameView;
class Scrollbar;
class PopupMenuWin : public PopupMenu, private ScrollableArea {
public:
PopupMenuWin(PopupMenuClient*);
~PopupMenuWin();
virtual void show(const IntRect&, FrameView*, int index);
virtual void hide();
virtual void updateFromElement();
virtual void disconnectClient();
static LPCWSTR popupClassName();
private:
PopupMenuClient* client() const { return m_popupClient; }
Scrollbar* scrollbar() const { return m_scrollbar.get(); }
bool up(unsigned lines = 1);
bool down(unsigned lines = 1);
int itemHeight() const { return m_itemHeight; }
const IntRect& windowRect() const { return m_windowRect; }
IntRect clientRect() const;
int visibleItems() const;
int listIndexAtPoint(const IntPoint&) const;
bool setFocusedIndex(int index, bool hotTracking = false);
int focusedIndex() const;
void focusFirst();
void focusLast();
void paint(const IntRect& damageRect, HDC = 0);
HWND popupHandle() const { return m_popup; }
void setWasClicked(bool b = true) { m_wasClicked = b; }
bool wasClicked() const { return m_wasClicked; }
int scrollOffset() const { return m_scrollOffset; }
bool scrollToRevealSelection();
void incrementWheelDelta(int delta);
void reduceWheelDelta(int delta);
int wheelDelta() const { return m_wheelDelta; }
bool scrollbarCapturingMouse() const { return m_scrollbarCapturingMouse; }
void setScrollbarCapturingMouse(bool b) { m_scrollbarCapturingMouse = b; }
virtual int scrollSize(ScrollbarOrientation) const OVERRIDE;
virtual int scrollPosition(Scrollbar*) const OVERRIDE;
virtual void setScrollOffset(const IntPoint&) OVERRIDE;
virtual void invalidateScrollbarRect(Scrollbar*, const IntRect&) OVERRIDE;
virtual void invalidateScrollCornerRect(const IntRect&) OVERRIDE { }
virtual bool isActive() const OVERRIDE { return true; }
ScrollableArea* enclosingScrollableArea() const OVERRIDE { return 0; }
virtual bool isScrollCornerVisible() const OVERRIDE { return false; }
virtual IntRect scrollCornerRect() const OVERRIDE { return IntRect(); }
virtual Scrollbar* verticalScrollbar() const OVERRIDE { return m_scrollbar.get(); }
virtual int visibleHeight() const OVERRIDE;
virtual int visibleWidth() const OVERRIDE;
virtual IntSize contentsSize() const OVERRIDE;
virtual bool scrollbarsCanBeActive() const OVERRIDE;
virtual IntRect scrollableAreaBoundingBox() const OVERRIDE;
void scrollTo(int offset);
void calculatePositionAndSize(const IntRect&, FrameView*);
void invalidateItem(int index);
static LRESULT CALLBACK PopupMenuWndProc(HWND, UINT, WPARAM, LPARAM);
LRESULT wndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam);
static void registerClass();
PopupMenuClient* m_popupClient;
RefPtr<Scrollbar> m_scrollbar;
HWND m_popup;
HDC m_DC;
HBITMAP m_bmp;
bool m_wasClicked;
IntRect m_windowRect;
int m_itemHeight;
int m_scrollOffset;
int m_wheelDelta;
int m_focusedIndex;
bool m_scrollbarCapturingMouse;
bool m_showPopup;
};
}
#endif // PopupMenuWin_h