1 /*
2  * Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies)
3  *
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.
8  *
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.
13  *
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.
18  *
19  */
20 #ifndef QtFallbackWebPopup_h
21 #define QtFallbackWebPopup_h
22 
23 #include "Platform.h"
24 #include "qwebkitplatformplugin.h"
25 
26 #include <QComboBox>
27 
28 #ifndef QT_NO_COMBOBOX
29 
30 QT_BEGIN_NAMESPACE
31 class QGraphicsProxyWidget;
32 QT_END_NAMESPACE
33 
34 class QWebPageClient;
35 
36 namespace WebCore {
37 
38 class ChromeClientQt;
39 class QtFallbackWebPopupCombo;
40 
41 class QtFallbackWebPopup : public QWebSelectMethod {
42     Q_OBJECT
43 public:
44     QtFallbackWebPopup(const ChromeClientQt*);
45     ~QtFallbackWebPopup();
46 
47     virtual void show(const QWebSelectData&);
48     virtual void hide();
49 
50     void destroyPopup();
51 
setGeometry(const QRect & rect)52     void setGeometry(const QRect& rect) { m_geometry = rect; }
geometry()53     QRect geometry() const { return m_geometry; }
54 
setFont(const QFont & font)55     void setFont(const QFont& font) { m_font = font; }
font()56     QFont font() const { return m_font; }
57 
58 private slots:
59     void activeChanged(int);
60 
61 private:
62     friend class QtFallbackWebPopupCombo;
63     bool m_popupVisible;
64     QtFallbackWebPopupCombo* m_combo;
65     const ChromeClientQt* m_chromeClient;
66     QRect m_geometry;
67     QFont m_font;
68 
69     QWebPageClient* pageClient() const;
70 
71     void populate(const QWebSelectData&);
72 };
73 
74 class QtFallbackWebPopupCombo : public QComboBox {
75 public:
76     QtFallbackWebPopupCombo(QtFallbackWebPopup& ownerPopup);
77     virtual void showPopup();
78     virtual void hidePopup();
79     virtual bool eventFilter(QObject* watched, QEvent* event);
80 
81 private:
82     QtFallbackWebPopup& m_ownerPopup;
83 };
84 
85 }
86 
87 #endif // QT_NO_COMBOBOX
88 
89 #endif // QtFallbackWebPopup_h
90