author | Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com> |
Mon, 03 May 2010 13:17:34 +0300 | |
changeset 19 | fcece45ef507 |
parent 18 | 2f34d5167611 |
child 30 | 5dc02b23752f |
permissions | -rw-r--r-- |
0 | 1 |
/* |
2 |
* This file is part of the theme implementation for form controls in WebCore. |
|
3 |
* |
|
4 |
* Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). |
|
5 |
* |
|
6 |
* This library is free software; you can redistribute it and/or |
|
7 |
* modify it under the terms of the GNU Library General Public |
|
8 |
* License as published by the Free Software Foundation; either |
|
9 |
* version 2 of the License, or (at your option) any later version. |
|
10 |
* |
|
11 |
* This library is distributed in the hope that it will be useful, |
|
12 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
13 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
|
14 |
* Library General Public License for more details. |
|
15 |
* |
|
16 |
* You should have received a copy of the GNU Library General Public License |
|
17 |
* along with this library; see the file COPYING.LIB. If not, write to |
|
18 |
* the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, |
|
19 |
* Boston, MA 02110-1301, USA. |
|
20 |
* |
|
21 |
*/ |
|
22 |
#ifndef RenderThemeQt_H |
|
23 |
#define RenderThemeQt_H |
|
24 |
||
25 |
#include "RenderTheme.h" |
|
26 |
||
27 |
#include <QStyle> |
|
28 |
||
29 |
QT_BEGIN_NAMESPACE |
|
19
fcece45ef507
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
30 |
class QLineEdit; |
0 | 31 |
class QPainter; |
32 |
class QWidget; |
|
33 |
QT_END_NAMESPACE |
|
34 |
||
35 |
namespace WebCore { |
|
36 |
||
37 |
class RenderStyle; |
|
38 |
class HTMLMediaElement; |
|
18
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
39 |
class ScrollbarThemeQt; |
0 | 40 |
|
41 |
class RenderThemeQt : public RenderTheme { |
|
42 |
private: |
|
43 |
RenderThemeQt(Page* page); |
|
44 |
virtual ~RenderThemeQt(); |
|
45 |
||
46 |
public: |
|
47 |
static PassRefPtr<RenderTheme> create(Page*); |
|
48 |
||
49 |
virtual bool supportsHover(const RenderStyle*) const; |
|
50 |
virtual bool supportsFocusRing(const RenderStyle* style) const; |
|
51 |
||
52 |
virtual int baselinePosition(const RenderObject* o) const; |
|
53 |
||
54 |
// A method asking if the control changes its tint when the window has focus or not. |
|
55 |
virtual bool controlSupportsTints(const RenderObject*) const; |
|
56 |
||
57 |
// A general method asking if any control tinting is supported at all. |
|
58 |
virtual bool supportsControlTints() const; |
|
59 |
||
60 |
virtual void adjustRepaintRect(const RenderObject* o, IntRect& r); |
|
61 |
||
62 |
// The platform selection color. |
|
63 |
virtual Color platformActiveSelectionBackgroundColor() const; |
|
64 |
virtual Color platformInactiveSelectionBackgroundColor() const; |
|
65 |
virtual Color platformActiveSelectionForegroundColor() const; |
|
66 |
virtual Color platformInactiveSelectionForegroundColor() const; |
|
67 |
||
68 |
virtual void systemFont(int propId, FontDescription&) const; |
|
69 |
||
70 |
virtual int minimumMenuListSize(RenderStyle*) const; |
|
71 |
||
72 |
virtual void adjustSliderThumbSize(RenderObject*) const; |
|
73 |
||
74 |
virtual double caretBlinkInterval() const; |
|
75 |
||
76 |
#if ENABLE(VIDEO) |
|
77 |
virtual String extraMediaControlsStyleSheet(); |
|
78 |
#endif |
|
79 |
||
18
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
80 |
QStyle* qStyle() const; |
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
81 |
|
0 | 82 |
protected: |
83 |
virtual bool paintCheckbox(RenderObject* o, const RenderObject::PaintInfo& i, const IntRect& r); |
|
84 |
virtual void setCheckboxSize(RenderStyle*) const; |
|
85 |
||
86 |
virtual bool paintRadio(RenderObject* o, const RenderObject::PaintInfo& i, const IntRect& r); |
|
87 |
virtual void setRadioSize(RenderStyle*) const; |
|
88 |
||
89 |
virtual void adjustButtonStyle(CSSStyleSelector*, RenderStyle*, Element*) const; |
|
90 |
virtual bool paintButton(RenderObject*, const RenderObject::PaintInfo&, const IntRect&); |
|
91 |
virtual void setButtonSize(RenderStyle*) const; |
|
92 |
||
93 |
virtual bool paintTextField(RenderObject*, const RenderObject::PaintInfo&, const IntRect&); |
|
94 |
virtual void adjustTextFieldStyle(CSSStyleSelector*, RenderStyle*, Element*) const; |
|
95 |
||
96 |
virtual bool paintTextArea(RenderObject*, const RenderObject::PaintInfo&, const IntRect&); |
|
97 |
virtual void adjustTextAreaStyle(CSSStyleSelector*, RenderStyle*, Element*) const; |
|
98 |
||
99 |
virtual bool paintMenuList(RenderObject* o, const RenderObject::PaintInfo& i, const IntRect& r); |
|
100 |
virtual void adjustMenuListStyle(CSSStyleSelector*, RenderStyle*, Element*) const; |
|
101 |
||
102 |
virtual bool paintMenuListButton(RenderObject*, const RenderObject::PaintInfo&, const IntRect&); |
|
103 |
virtual void adjustMenuListButtonStyle(CSSStyleSelector*, RenderStyle*, Element*) const; |
|
104 |
||
105 |
virtual bool paintSliderTrack(RenderObject*, const RenderObject::PaintInfo&, const IntRect&); |
|
106 |
virtual bool paintSliderThumb(RenderObject*, const RenderObject::PaintInfo&, const IntRect&); |
|
107 |
||
108 |
virtual bool paintSearchField(RenderObject*, const RenderObject::PaintInfo&, const IntRect&); |
|
109 |
virtual void adjustSearchFieldStyle(CSSStyleSelector*, RenderStyle*, Element*) const; |
|
110 |
||
111 |
virtual void adjustSearchFieldCancelButtonStyle(CSSStyleSelector*, RenderStyle*, Element*) const; |
|
112 |
virtual bool paintSearchFieldCancelButton(RenderObject*, const RenderObject::PaintInfo&, const IntRect&); |
|
113 |
||
114 |
virtual void adjustSearchFieldDecorationStyle(CSSStyleSelector*, RenderStyle*, Element*) const; |
|
115 |
virtual bool paintSearchFieldDecoration(RenderObject*, const RenderObject::PaintInfo&, const IntRect&); |
|
116 |
||
117 |
virtual void adjustSearchFieldResultsDecorationStyle(CSSStyleSelector*, RenderStyle*, Element*) const; |
|
118 |
virtual bool paintSearchFieldResultsDecoration(RenderObject*, const RenderObject::PaintInfo&, const IntRect&); |
|
119 |
||
120 |
#if ENABLE(VIDEO) |
|
121 |
virtual bool paintMediaFullscreenButton(RenderObject*, const RenderObject::PaintInfo&, const IntRect&); |
|
122 |
virtual bool paintMediaPlayButton(RenderObject*, const RenderObject::PaintInfo&, const IntRect&); |
|
123 |
virtual bool paintMediaMuteButton(RenderObject*, const RenderObject::PaintInfo&, const IntRect&); |
|
124 |
virtual bool paintMediaSeekBackButton(RenderObject*, const RenderObject::PaintInfo&, const IntRect&); |
|
125 |
virtual bool paintMediaSeekForwardButton(RenderObject*, const RenderObject::PaintInfo&, const IntRect&); |
|
126 |
virtual bool paintMediaSliderTrack(RenderObject*, const RenderObject::PaintInfo&, const IntRect&); |
|
127 |
virtual bool paintMediaSliderThumb(RenderObject*, const RenderObject::PaintInfo&, const IntRect&); |
|
128 |
||
129 |
private: |
|
130 |
HTMLMediaElement* getMediaElementFromRenderObject(RenderObject* o) const; |
|
131 |
void paintMediaBackground(QPainter* painter, const IntRect& r) const; |
|
132 |
QColor getMediaControlForegroundColor(RenderObject* o = 0) const; |
|
133 |
#endif |
|
134 |
void computeSizeBasedOnStyle(RenderStyle* renderStyle) const; |
|
135 |
||
136 |
private: |
|
137 |
bool supportsFocus(ControlPart) const; |
|
138 |
||
139 |
ControlPart applyTheme(QStyleOption&, RenderObject*) const; |
|
140 |
||
141 |
void setButtonPadding(RenderStyle*) const; |
|
142 |
void setPopupPadding(RenderStyle*) const; |
|
143 |
||
19
fcece45ef507
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
144 |
int findFrameLineWidth(QStyle* style) const; |
fcece45ef507
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
145 |
|
18
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
146 |
QStyle* fallbackStyle() const; |
0 | 147 |
|
148 |
Page* m_page; |
|
149 |
||
150 |
#ifdef Q_WS_MAC |
|
151 |
int m_buttonFontPixelSize; |
|
152 |
#endif |
|
153 |
QString m_buttonFontFamily; |
|
154 |
||
155 |
QStyle* m_fallbackStyle; |
|
19
fcece45ef507
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
156 |
mutable QLineEdit* m_lineEdit; |
0 | 157 |
}; |
158 |
||
159 |
class StylePainter { |
|
160 |
public: |
|
18
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
161 |
explicit StylePainter(RenderThemeQt*, const RenderObject::PaintInfo&); |
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
162 |
explicit StylePainter(ScrollbarThemeQt*, GraphicsContext*); |
0 | 163 |
~StylePainter(); |
164 |
||
165 |
bool isValid() const { return painter && style; } |
|
166 |
||
167 |
QPainter* painter; |
|
168 |
QWidget* widget; |
|
169 |
QStyle* style; |
|
170 |
||
171 |
void drawPrimitive(QStyle::PrimitiveElement pe, const QStyleOption& opt) |
|
172 |
{ style->drawPrimitive(pe, &opt, painter, widget); } |
|
173 |
void drawControl(QStyle::ControlElement ce, const QStyleOption& opt) |
|
174 |
{ style->drawControl(ce, &opt, painter, widget); } |
|
175 |
void drawComplexControl(QStyle::ComplexControl cc, const QStyleOptionComplex& opt) |
|
176 |
{ style->drawComplexControl(cc, &opt, painter, widget); } |
|
177 |
||
178 |
private: |
|
18
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
179 |
void init(GraphicsContext* context, QStyle*); |
0 | 180 |
|
181 |
QBrush oldBrush; |
|
182 |
bool oldAntialiasing; |
|
183 |
||
184 |
Q_DISABLE_COPY(StylePainter) |
|
185 |
}; |
|
186 |
||
187 |
} |
|
188 |
||
189 |
#endif |