2 * Copyright (C) 2006, 2008 Apple Inc. All rights reserved.
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Library General Public
6 * License as published by the Free Software Foundation; either
7 * version 2 of the License, or (at your option) any later version.
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Library General Public License for more details.
14 * You should have received a copy of the GNU Library General Public License
15 * along with this library; see the file COPYING.LIB. If not, write to
16 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
17 * Boston, MA 02110-1301, USA.
25 #include "PopupMenuClient.h"
26 #include <wtf/PassRefPtr.h>
27 #include <wtf/RefCounted.h>
30 #include <wtf/RetainPtr.h>
32 @
class NSPopUpButtonCell
;
34 class NSPopUpButtonCell
;
37 #include "Scrollbar.h"
38 #include "ScrollbarClient.h"
39 #include <wtf/RefPtr.h>
40 typedef struct HWND__
* HWND
;
41 typedef struct HDC__
* HDC
;
42 typedef struct HBITMAP__
* HBITMAP
;
48 typedef struct _GtkMenu GtkMenu
;
49 typedef struct _GtkMenuItem GtkMenuItem
;
50 typedef struct _GtkWidget GtkWidget
;
51 #include <wtf/HashMap.h>
55 #include <wx/msw/winundef.h>
60 #elif PLATFORM(CHROMIUM)
61 #include "PopupMenuPrivate.h"
69 class PopupMenu
: public RefCounted
<PopupMenu
>
71 , private ScrollbarClient
78 static PassRefPtr
<PopupMenu
> create(PopupMenuClient
* client
) { return adoptRef(new PopupMenu(client
)); }
81 void disconnectClient() { m_popupClient
= 0; }
83 void show(const IntRect
&, FrameView
*, int index
);
86 void updateFromElement();
88 PopupMenuClient
* client() const { return m_popupClient
; }
90 static bool itemWritingDirectionIsNatural();
93 Scrollbar
* scrollbar() const { return m_scrollbar
.get(); }
95 bool up(unsigned lines
= 1);
96 bool down(unsigned lines
= 1);
98 int itemHeight() const { return m_itemHeight
; }
99 const IntRect
& windowRect() const { return m_windowRect
; }
100 IntRect
clientRect() const;
102 int visibleItems() const;
104 int listIndexAtPoint(const IntPoint
&) const;
106 bool setFocusedIndex(int index
, bool hotTracking
= false);
107 int focusedIndex() const;
111 void paint(const IntRect
& damageRect
, HDC
= 0);
113 HWND
popupHandle() const { return m_popup
; }
115 void setWasClicked(bool b
= true) { m_wasClicked
= b
; }
116 bool wasClicked() const { return m_wasClicked
; }
118 void setScrollOffset(int offset
) { m_scrollOffset
= offset
; }
119 int scrollOffset() const { return m_scrollOffset
; }
121 bool scrollToRevealSelection();
123 void incrementWheelDelta(int delta
);
124 void reduceWheelDelta(int delta
);
125 int wheelDelta() const { return m_wheelDelta
; }
127 bool scrollbarCapturingMouse() const { return m_scrollbarCapturingMouse
; }
128 void setScrollbarCapturingMouse(bool b
) { m_scrollbarCapturingMouse
= b
; }
132 PopupMenu(PopupMenuClient
*);
135 PopupMenuClient
* m_popupClient
;
143 void populate(const IntRect
&);
147 virtual void valueChanged(Scrollbar
*);
148 virtual void invalidateScrollbarRect(Scrollbar
*, const IntRect
&);
149 virtual bool isActive() const { return true; }
150 virtual bool scrollbarCornerPresent() const { return false; }
152 void calculatePositionAndSize(const IntRect
&, FrameView
*);
153 void invalidateItem(int index
);
155 RefPtr
<Scrollbar
> m_scrollbar
;
160 IntRect m_windowRect
;
165 bool m_scrollbarCapturingMouse
;
167 IntPoint m_menuPosition
;
169 HashMap
<GtkWidget
*, int> m_indexMap
;
170 static void menuItemActivated(GtkMenuItem
* item
, PopupMenu
*);
171 static void menuUnmapped(GtkWidget
*, PopupMenu
*);
172 static void menuPositionFunction(GtkMenu
*, gint
*, gint
*, gboolean
*, PopupMenu
*);
173 static void menuRemoveItem(GtkWidget
*, PopupMenu
*);
176 void OnMenuItemSelected(wxCommandEvent
&);
177 #elif PLATFORM(CHROMIUM)