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"
71 class PopupMenu
: public RefCounted
<PopupMenu
>
73 , private ScrollbarClient
80 static PassRefPtr
<PopupMenu
> create(PopupMenuClient
* client
) { return adoptRef(new PopupMenu(client
)); }
83 void disconnectClient() { m_popupClient
= 0; }
85 void show(const IntRect
&, FrameView
*, int index
);
88 void updateFromElement();
90 PopupMenuClient
* client() const { return m_popupClient
; }
92 static bool itemWritingDirectionIsNatural();
95 Scrollbar
* scrollbar() const { return m_scrollbar
.get(); }
97 static LPCTSTR
popupClassName();
99 bool up(unsigned lines
= 1);
100 bool down(unsigned lines
= 1);
102 int itemHeight() const { return m_itemHeight
; }
103 const IntRect
& windowRect() const { return m_windowRect
; }
104 IntRect
clientRect() const;
106 int visibleItems() const;
108 int listIndexAtPoint(const IntPoint
&) const;
110 bool setFocusedIndex(int index
, bool hotTracking
= false);
111 int focusedIndex() const;
115 void paint(const IntRect
& damageRect
, HDC
= 0);
117 HWND
popupHandle() const { return m_popup
; }
119 void setWasClicked(bool b
= true) { m_wasClicked
= b
; }
120 bool wasClicked() const { return m_wasClicked
; }
122 void setScrollOffset(int offset
) { m_scrollOffset
= offset
; }
123 int scrollOffset() const { return m_scrollOffset
; }
125 bool scrollToRevealSelection();
127 void incrementWheelDelta(int delta
);
128 void reduceWheelDelta(int delta
);
129 int wheelDelta() const { return m_wheelDelta
; }
131 bool scrollbarCapturingMouse() const { return m_scrollbarCapturingMouse
; }
132 void setScrollbarCapturingMouse(bool b
) { m_scrollbarCapturingMouse
= b
; }
136 PopupMenu(PopupMenuClient
*);
139 PopupMenuClient
* m_popupClient
;
145 RetainPtr
<NSPopUpButtonCell
> m_popup
;
148 void populate(const IntRect
&);
152 virtual void valueChanged(Scrollbar
*);
153 virtual void invalidateScrollbarRect(Scrollbar
*, const IntRect
&);
154 virtual bool isActive() const { return true; }
155 virtual bool scrollbarCornerPresent() const { return false; }
157 void calculatePositionAndSize(const IntRect
&, FrameView
*);
158 void invalidateItem(int index
);
160 static LRESULT CALLBACK
PopupMenuWndProc(HWND
, UINT
, WPARAM
, LPARAM
);
161 LRESULT
wndProc(HWND hWnd
, UINT message
, WPARAM wParam
, LPARAM lParam
);
162 static void registerClass();
164 RefPtr
<Scrollbar
> m_scrollbar
;
169 IntRect m_windowRect
;
174 bool m_scrollbarCapturingMouse
;
177 IntPoint m_menuPosition
;
179 HashMap
<GtkWidget
*, int> m_indexMap
;
180 static void menuItemActivated(GtkMenuItem
* item
, PopupMenu
*);
181 static void menuUnmapped(GtkWidget
*, PopupMenu
*);
182 static void menuPositionFunction(GtkMenu
*, gint
*, gint
*, gboolean
*, PopupMenu
*);
183 static void menuRemoveItem(GtkWidget
*, PopupMenu
*);
186 void OnMenuItemSelected(wxCommandEvent
&);
187 #elif PLATFORM(CHROMIUM)
189 #elif PLATFORM(HAIKU)