2
* Copyright (C) 2011 Apple Inc. All rights reserved.
3
* Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
5
* This library is free software; you can redistribute it and/or
6
* modify it under the terms of the GNU Library General Public
7
* License as published by the Free Software Foundation; either
8
* version 2 of the License, or (at your option) any later version.
10
* This library is distributed in the hope that it will be useful,
11
* but WITHOUT ANY WARRANTY; without even the implied warranty of
12
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13
* Library General Public License for more details.
15
* You should have received a copy of the GNU Library General Public License
16
* along with this library; see the file COPYING.LIB. If not, write to
17
* the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
18
* Boston, MA 02110-1301, USA.
21
#ifndef PopupMenuWin_h
22
#define PopupMenuWin_h
25
#include "PopupMenu.h"
26
#include "PopupMenuClient.h"
27
#include "ScrollableArea.h"
28
#include "Scrollbar.h"
29
#include <wtf/PassRefPtr.h>
30
#include <wtf/RefCounted.h>
31
#include <wtf/RefPtr.h>
33
typedef struct HWND__* HWND;
34
typedef struct HDC__* HDC;
35
typedef struct HBITMAP__* HBITMAP;
42
class PopupMenuWin : public PopupMenu, private ScrollableArea {
44
PopupMenuWin(PopupMenuClient*);
47
virtual void show(const IntRect&, FrameView*, int index);
49
virtual void updateFromElement();
50
virtual void disconnectClient();
52
static LPCWSTR popupClassName();
55
PopupMenuClient* client() const { return m_popupClient; }
57
Scrollbar* scrollbar() const { return m_scrollbar.get(); }
59
bool up(unsigned lines = 1);
60
bool down(unsigned lines = 1);
62
int itemHeight() const { return m_itemHeight; }
63
const IntRect& windowRect() const { return m_windowRect; }
64
IntRect clientRect() const;
66
int visibleItems() const;
68
int listIndexAtPoint(const IntPoint&) const;
70
bool setFocusedIndex(int index, bool hotTracking = false);
71
int focusedIndex() const;
75
void paint(const IntRect& damageRect, HDC = 0);
77
HWND popupHandle() const { return m_popup; }
79
void setWasClicked(bool b = true) { m_wasClicked = b; }
80
bool wasClicked() const { return m_wasClicked; }
82
int scrollOffset() const { return m_scrollOffset; }
84
bool scrollToRevealSelection();
86
void incrementWheelDelta(int delta);
87
void reduceWheelDelta(int delta);
88
int wheelDelta() const { return m_wheelDelta; }
90
bool scrollbarCapturingMouse() const { return m_scrollbarCapturingMouse; }
91
void setScrollbarCapturingMouse(bool b) { m_scrollbarCapturingMouse = b; }
94
virtual int scrollSize(ScrollbarOrientation) const OVERRIDE;
95
virtual int scrollPosition(Scrollbar*) const OVERRIDE;
96
virtual void setScrollOffset(const IntPoint&) OVERRIDE;
97
virtual void invalidateScrollbarRect(Scrollbar*, const IntRect&) OVERRIDE;
98
virtual void invalidateScrollCornerRect(const IntRect&) OVERRIDE { }
99
virtual bool isActive() const OVERRIDE { return true; }
100
ScrollableArea* enclosingScrollableArea() const OVERRIDE { return 0; }
101
virtual bool isScrollCornerVisible() const OVERRIDE { return false; }
102
virtual IntRect scrollCornerRect() const OVERRIDE { return IntRect(); }
103
virtual Scrollbar* verticalScrollbar() const OVERRIDE { return m_scrollbar.get(); }
104
virtual int visibleHeight() const OVERRIDE;
105
virtual int visibleWidth() const OVERRIDE;
106
virtual IntSize contentsSize() const OVERRIDE;
107
virtual bool scrollbarsCanBeActive() const OVERRIDE;
108
virtual IntRect scrollableAreaBoundingBox() const OVERRIDE;
110
// NOTE: This should only be called by the overriden setScrollOffset from ScrollableArea.
111
void scrollTo(int offset);
113
void calculatePositionAndSize(const IntRect&, FrameView*);
114
void invalidateItem(int index);
116
static LRESULT CALLBACK PopupMenuWndProc(HWND, UINT, WPARAM, LPARAM);
117
LRESULT wndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam);
118
static void registerClass();
120
PopupMenuClient* m_popupClient;
121
RefPtr<Scrollbar> m_scrollbar;
126
IntRect m_windowRect;
131
bool m_scrollbarCapturingMouse;
135
} // namespace WebCore
137
#endif // PopupMenuWin_h