~ubuntu-branches/ubuntu/raring/qtwebkit-source/raring-proposed

« back to all changes in this revision

Viewing changes to Source/WebCore/platform/win/PopupMenuWin.h

  • Committer: Package Import Robot
  • Author(s): Jonathan Riddell
  • Date: 2013-02-18 14:24:18 UTC
  • Revision ID: package-import@ubuntu.com-20130218142418-eon0jmjg3nj438uy
Tags: upstream-2.3
ImportĀ upstreamĀ versionĀ 2.3

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 * Copyright (C) 2011 Apple Inc. All rights reserved.
 
3
 * Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
 
4
 *
 
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.
 
9
 *
 
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.
 
14
 *
 
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.
 
19
 */
 
20
 
 
21
#ifndef PopupMenuWin_h
 
22
#define PopupMenuWin_h
 
23
 
 
24
#include "IntRect.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>
 
32
 
 
33
typedef struct HWND__* HWND;
 
34
typedef struct HDC__* HDC;
 
35
typedef struct HBITMAP__* HBITMAP;
 
36
 
 
37
namespace WebCore {
 
38
 
 
39
class FrameView;
 
40
class Scrollbar;
 
41
 
 
42
class PopupMenuWin : public PopupMenu, private ScrollableArea {
 
43
public:
 
44
    PopupMenuWin(PopupMenuClient*);
 
45
    ~PopupMenuWin();
 
46
 
 
47
    virtual void show(const IntRect&, FrameView*, int index);
 
48
    virtual void hide();
 
49
    virtual void updateFromElement();
 
50
    virtual void disconnectClient();
 
51
 
 
52
    static LPCWSTR popupClassName();
 
53
 
 
54
private:
 
55
    PopupMenuClient* client() const { return m_popupClient; }
 
56
 
 
57
    Scrollbar* scrollbar() const { return m_scrollbar.get(); }
 
58
 
 
59
    bool up(unsigned lines = 1);
 
60
    bool down(unsigned lines = 1);
 
61
 
 
62
    int itemHeight() const { return m_itemHeight; }
 
63
    const IntRect& windowRect() const { return m_windowRect; }
 
64
    IntRect clientRect() const;
 
65
 
 
66
    int visibleItems() const;
 
67
 
 
68
    int listIndexAtPoint(const IntPoint&) const;
 
69
 
 
70
    bool setFocusedIndex(int index, bool hotTracking = false);
 
71
    int focusedIndex() const;
 
72
    void focusFirst();
 
73
    void focusLast();
 
74
 
 
75
    void paint(const IntRect& damageRect, HDC = 0);
 
76
 
 
77
    HWND popupHandle() const { return m_popup; }
 
78
 
 
79
    void setWasClicked(bool b = true) { m_wasClicked = b; }
 
80
    bool wasClicked() const { return m_wasClicked; }
 
81
 
 
82
    int scrollOffset() const { return m_scrollOffset; }
 
83
 
 
84
    bool scrollToRevealSelection();
 
85
 
 
86
    void incrementWheelDelta(int delta);
 
87
    void reduceWheelDelta(int delta);
 
88
    int wheelDelta() const { return m_wheelDelta; }
 
89
 
 
90
    bool scrollbarCapturingMouse() const { return m_scrollbarCapturingMouse; }
 
91
    void setScrollbarCapturingMouse(bool b) { m_scrollbarCapturingMouse = b; }
 
92
 
 
93
    // ScrollableArea
 
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;
 
109
 
 
110
    // NOTE: This should only be called by the overriden setScrollOffset from ScrollableArea.
 
111
    void scrollTo(int offset);
 
112
 
 
113
    void calculatePositionAndSize(const IntRect&, FrameView*);
 
114
    void invalidateItem(int index);
 
115
 
 
116
    static LRESULT CALLBACK PopupMenuWndProc(HWND, UINT, WPARAM, LPARAM);
 
117
    LRESULT wndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam);
 
118
    static void registerClass();
 
119
 
 
120
    PopupMenuClient* m_popupClient;
 
121
    RefPtr<Scrollbar> m_scrollbar;
 
122
    HWND m_popup;
 
123
    HDC m_DC;
 
124
    HBITMAP m_bmp;
 
125
    bool m_wasClicked;
 
126
    IntRect m_windowRect;
 
127
    int m_itemHeight;
 
128
    int m_scrollOffset;
 
129
    int m_wheelDelta;
 
130
    int m_focusedIndex;
 
131
    bool m_scrollbarCapturingMouse;
 
132
    bool m_showPopup;
 
133
};
 
134
 
 
135
} // namespace WebCore
 
136
 
 
137
#endif // PopupMenuWin_h