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

« back to all changes in this revision

Viewing changes to Source/WebCore/platform/gtk/RenderThemeGtk.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
 * This file is part of the WebKit project.
 
3
 *
 
4
 * Copyright (C) 2006 Apple Computer, Inc.
 
5
 * Copyright (C) 2006 Michael Emmel mike.emmel@gmail.com
 
6
 * Copyright (C) 2007 Holger Hans Peter Freyther
 
7
 * Copyright (C) 2007 Alp Toker <alp@atoker.com>
 
8
 * Copyright (C) 2010 Igalia S.L.
 
9
 * All rights reserved.
 
10
 *
 
11
 * This library is free software; you can redistribute it and/or
 
12
 * modify it under the terms of the GNU Library General Public
 
13
 * License as published by the Free Software Foundation; either
 
14
 * version 2 of the License, or (at your option) any later version.
 
15
 *
 
16
 * This library is distributed in the hope that it will be useful,
 
17
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 
18
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 
19
 * Library General Public License for more details.
 
20
 *
 
21
 * You should have received a copy of the GNU Library General Public License
 
22
 * along with this library; see the file COPYING.LIB.  If not, write to
 
23
 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
 
24
 * Boston, MA 02110-1301, USA.
 
25
 *
 
26
 */
 
27
 
 
28
#ifndef RenderThemeGtk_h
 
29
#define RenderThemeGtk_h
 
30
 
 
31
#include <wtf/gobject/GRefPtr.h>
 
32
#include "RenderTheme.h"
 
33
 
 
34
typedef struct _GdkColormap GdkColormap;
 
35
 
 
36
namespace WebCore {
 
37
 
 
38
class RenderThemeGtk : public RenderTheme {
 
39
private:
 
40
    RenderThemeGtk();
 
41
    virtual ~RenderThemeGtk();
 
42
 
 
43
public:
 
44
    static PassRefPtr<RenderTheme> create();
 
45
 
 
46
    // A method asking if the theme's controls actually care about redrawing when hovered.
 
47
    virtual bool supportsHover(const RenderStyle* style) const { return true; }
 
48
 
 
49
    // A method asking if the theme is able to draw the focus ring.
 
50
    virtual bool supportsFocusRing(const RenderStyle*) const;
 
51
 
 
52
    // A method asking if the control changes its tint when the window has focus or not.
 
53
    virtual bool controlSupportsTints(const RenderObject*) const;
 
54
 
 
55
    // A general method asking if any control tinting is supported at all.
 
56
    virtual bool supportsControlTints() const { return true; }
 
57
 
 
58
    virtual void adjustRepaintRect(const RenderObject*, IntRect&);
 
59
 
 
60
    // A method to obtain the baseline position for a "leaf" control.  This will only be used if a baseline
 
61
    // position cannot be determined by examining child content. Checkboxes and radio buttons are examples of
 
62
    // controls that need to do this.
 
63
    virtual int baselinePosition(const RenderObject*) const;
 
64
 
 
65
    // The platform selection color.
 
66
    virtual Color platformActiveSelectionBackgroundColor() const;
 
67
    virtual Color platformInactiveSelectionBackgroundColor() const;
 
68
    virtual Color platformActiveSelectionForegroundColor() const;
 
69
    virtual Color platformInactiveSelectionForegroundColor() const;
 
70
 
 
71
    // List Box selection color
 
72
    virtual Color activeListBoxSelectionBackgroundColor() const;
 
73
    virtual Color activeListBoxSelectionForegroundColor() const;
 
74
    virtual Color inactiveListBoxSelectionBackgroundColor() const;
 
75
    virtual Color inactiveListBoxSelectionForegroundColor() const;
 
76
 
 
77
    virtual double caretBlinkInterval() const;
 
78
 
 
79
    virtual void platformColorsDidChange();
 
80
 
 
81
    // System fonts and colors.
 
82
    virtual void systemFont(int propId, FontDescription&) const;
 
83
    virtual Color systemColor(int cssValueId) const;
 
84
 
 
85
    virtual bool popsMenuBySpaceOrReturn() const OVERRIDE { return true; }
 
86
 
 
87
#if ENABLE(VIDEO)
 
88
    virtual String extraMediaControlsStyleSheet();
 
89
    virtual String formatMediaControlsCurrentTime(float currentTime, float duration) const;
 
90
 
 
91
#if ENABLE(FULLSCREEN_API)
 
92
    virtual String extraFullScreenStyleSheet();
 
93
#endif
 
94
#endif
 
95
 
 
96
#if ENABLE(DATALIST_ELEMENT)
 
97
    // Returns size of one slider tick mark for a horizontal track.
 
98
    // For vertical tracks we rotate it and use it. i.e. Width is always length along the track.
 
99
    virtual IntSize sliderTickSize() const;
 
100
    // Returns the distance of slider tick origin from the slider track center.
 
101
    virtual int sliderTickOffsetFromTrackCenter() const;
 
102
#endif
 
103
 
 
104
#ifdef GTK_API_VERSION_2
 
105
    GtkWidget* gtkContainer() const;
 
106
    GtkWidget* gtkEntry() const;
 
107
    GtkWidget* gtkVScrollbar() const;
 
108
    GtkWidget* gtkHScrollbar() const;
 
109
    static void getIndicatorMetrics(ControlPart, int& indicatorSize, int& indicatorSpacing);
 
110
#else
 
111
    GtkStyleContext* gtkScrollbarStyle();
 
112
#endif
 
113
 
 
114
protected:
 
115
    virtual bool paintCheckbox(RenderObject* o, const PaintInfo& i, const IntRect& r);
 
116
    virtual void setCheckboxSize(RenderStyle* style) const;
 
117
 
 
118
    virtual bool paintRadio(RenderObject* o, const PaintInfo& i, const IntRect& r);
 
119
    virtual void setRadioSize(RenderStyle* style) const;
 
120
 
 
121
    virtual void adjustButtonStyle(StyleResolver*, RenderStyle*, Element*) const;
 
122
    virtual bool paintButton(RenderObject*, const PaintInfo&, const IntRect&);
 
123
 
 
124
    virtual bool paintTextField(RenderObject*, const PaintInfo&, const IntRect&);
 
125
    virtual bool paintTextArea(RenderObject*, const PaintInfo&, const IntRect&);
 
126
 
 
127
    int popupInternalPaddingLeft(RenderStyle*) const;
 
128
    int popupInternalPaddingRight(RenderStyle*) const;
 
129
    int popupInternalPaddingTop(RenderStyle*) const;
 
130
    int popupInternalPaddingBottom(RenderStyle*) const;
 
131
 
 
132
    // The Mac port differentiates between the "menu list" and the "menu list button."
 
133
    // The former is used when a menu list button has been styled. This is used to ensure
 
134
    // Aqua themed controls whenever possible. We always want to use GTK+ theming, so
 
135
    // we don't maintain this differentiation.
 
136
    virtual void adjustMenuListStyle(StyleResolver*, RenderStyle*, Element*) const;
 
137
    virtual void adjustMenuListButtonStyle(StyleResolver*, RenderStyle*, Element*) const;
 
138
    virtual bool paintMenuList(RenderObject*, const PaintInfo&, const IntRect&);
 
139
    virtual bool paintMenuListButton(RenderObject*, const PaintInfo&, const IntRect&);
 
140
 
 
141
    virtual void adjustSearchFieldResultsDecorationStyle(StyleResolver*, RenderStyle*, Element*) const;
 
142
    virtual bool paintSearchFieldResultsDecoration(RenderObject*, const PaintInfo&, const IntRect&);
 
143
 
 
144
    virtual void adjustSearchFieldStyle(StyleResolver*, RenderStyle*, Element*) const;
 
145
    virtual bool paintSearchField(RenderObject*, const PaintInfo&, const IntRect&);
 
146
 
 
147
    virtual void adjustSearchFieldResultsButtonStyle(StyleResolver*, RenderStyle*, Element*) const;
 
148
    virtual bool paintSearchFieldResultsButton(RenderObject*, const PaintInfo&, const IntRect&);
 
149
 
 
150
    virtual void adjustSearchFieldCancelButtonStyle(StyleResolver*, RenderStyle*, Element*) const;
 
151
    virtual bool paintSearchFieldCancelButton(RenderObject*, const PaintInfo&, const IntRect&);
 
152
 
 
153
    virtual bool paintSliderTrack(RenderObject*, const PaintInfo&, const IntRect&);
 
154
    virtual void adjustSliderTrackStyle(StyleResolver*, RenderStyle*, Element*) const;
 
155
 
 
156
    virtual bool paintSliderThumb(RenderObject*, const PaintInfo&, const IntRect&);
 
157
    virtual void adjustSliderThumbStyle(StyleResolver*, RenderStyle*, Element*) const;
 
158
 
 
159
    virtual void adjustSliderThumbSize(RenderStyle*, Element*) const;
 
160
 
 
161
#if ENABLE(VIDEO)
 
162
    void initMediaColors();
 
163
    void initMediaButtons();
 
164
    void adjustMediaSliderThumbSize(RenderStyle*) const;
 
165
    virtual bool hasOwnDisabledStateHandlingFor(ControlPart) const { return true; }
 
166
    virtual bool paintMediaFullscreenButton(RenderObject*, const PaintInfo&, const IntRect&);
 
167
    virtual bool paintMediaPlayButton(RenderObject*, const PaintInfo&, const IntRect&);
 
168
    virtual bool paintMediaMuteButton(RenderObject*, const PaintInfo&, const IntRect&);
 
169
    virtual bool paintMediaSeekBackButton(RenderObject*, const PaintInfo&, const IntRect&);
 
170
    virtual bool paintMediaSeekForwardButton(RenderObject*, const PaintInfo&, const IntRect&);
 
171
    virtual bool paintMediaSliderTrack(RenderObject*, const PaintInfo&, const IntRect&);
 
172
    virtual bool paintMediaSliderThumb(RenderObject*, const PaintInfo&, const IntRect&);
 
173
    virtual bool paintMediaVolumeSliderContainer(RenderObject*, const PaintInfo&, const IntRect&);
 
174
    virtual bool paintMediaVolumeSliderTrack(RenderObject*, const PaintInfo&, const IntRect&);
 
175
    virtual bool paintMediaVolumeSliderThumb(RenderObject*, const PaintInfo&, const IntRect&);
 
176
    virtual bool paintMediaCurrentTime(RenderObject*, const PaintInfo&, const IntRect&);
 
177
#endif
 
178
 
 
179
#if ENABLE(PROGRESS_ELEMENT)
 
180
    virtual double animationRepeatIntervalForProgressBar(RenderProgress*) const;
 
181
    virtual double animationDurationForProgressBar(RenderProgress*) const;
 
182
    virtual void adjustProgressBarStyle(StyleResolver*, RenderStyle*, Element*) const;
 
183
    virtual bool paintProgressBar(RenderObject*, const PaintInfo&, const IntRect&);
 
184
#endif
 
185
 
 
186
    virtual bool paintCapsLockIndicator(RenderObject*, const PaintInfo&, const IntRect&);
 
187
 
 
188
    virtual void adjustInnerSpinButtonStyle(StyleResolver*, RenderStyle*, Element*) const;
 
189
    virtual bool paintInnerSpinButton(RenderObject*, const PaintInfo&, const IntRect&);
 
190
 
 
191
private:
 
192
    virtual String fileListNameForWidth(const FileList*, const Font&, int width, bool multipleFilesAllowed) const OVERRIDE;
 
193
 
 
194
    void platformInit();
 
195
    static void setTextInputBorders(RenderStyle*);
 
196
    static double getScreenDPI();
 
197
 
 
198
#if ENABLE(VIDEO)
 
199
    bool paintMediaButton(RenderObject*, GraphicsContext*, const IntRect&, const char* iconName);
 
200
#endif
 
201
 
 
202
#if ENABLE(PROGRESS_ELEMENT)
 
203
    static IntRect calculateProgressRect(RenderObject*, const IntRect&);
 
204
#endif
 
205
 
 
206
    mutable Color m_panelColor;
 
207
    mutable Color m_sliderColor;
 
208
    mutable Color m_sliderThumbColor;
 
209
    const int m_mediaIconSize;
 
210
    const int m_mediaSliderHeight;
 
211
    const int m_mediaSliderThumbWidth;
 
212
    const int m_mediaSliderThumbHeight;
 
213
 
 
214
#ifdef GTK_API_VERSION_2
 
215
    void setupWidgetAndAddToContainer(GtkWidget*, GtkWidget*) const;
 
216
    void refreshComboBoxChildren() const;
 
217
    void getComboBoxPadding(RenderStyle*, int& left, int& top, int& right, int& bottom) const;
 
218
    int getComboBoxSeparatorWidth() const;
 
219
    int comboBoxArrowSize(RenderStyle*) const;
 
220
 
 
221
    GtkWidget* gtkButton() const;
 
222
    GtkWidget* gtkTreeView() const;
 
223
    GtkWidget* gtkVScale() const;
 
224
    GtkWidget* gtkHScale() const;
 
225
    GtkWidget* gtkRadioButton() const;
 
226
    GtkWidget* gtkCheckButton() const;
 
227
    GtkWidget* gtkProgressBar() const;
 
228
    GtkWidget* gtkComboBox() const;
 
229
    GtkWidget* gtkComboBoxButton() const;
 
230
    GtkWidget* gtkComboBoxArrow() const;
 
231
    GtkWidget* gtkComboBoxSeparator() const;
 
232
    GtkWidget* gtkSpinButton() const;
 
233
 
 
234
    GdkColormap* m_colormap;
 
235
    mutable GtkWidget* m_gtkWindow;
 
236
    mutable GtkWidget* m_gtkContainer;
 
237
    mutable GtkWidget* m_gtkButton;
 
238
    mutable GtkWidget* m_gtkEntry;
 
239
    mutable GtkWidget* m_gtkTreeView;
 
240
    mutable GtkWidget* m_gtkVScale;
 
241
    mutable GtkWidget* m_gtkHScale;
 
242
    mutable GtkWidget* m_gtkRadioButton;
 
243
    mutable GtkWidget* m_gtkCheckButton;
 
244
    mutable GtkWidget* m_gtkProgressBar;
 
245
    mutable GtkWidget* m_gtkComboBox;
 
246
    mutable GtkWidget* m_gtkComboBoxButton;
 
247
    mutable GtkWidget* m_gtkComboBoxArrow;
 
248
    mutable GtkWidget* m_gtkComboBoxSeparator;
 
249
    mutable GtkWidget* m_gtkVScrollbar;
 
250
    mutable GtkWidget* m_gtkHScrollbar;
 
251
    mutable GtkWidget* m_gtkSpinButton;
 
252
    bool m_themePartsHaveRGBAColormap;
 
253
    friend class WidgetRenderingContext;
 
254
#endif
 
255
};
 
256
 
 
257
}
 
258
 
 
259
#endif // RenderThemeGtk_h