initial import
[vuplus_webkit] / Source / WebCore / rendering / RenderThemeWin.h
1 /*
2  * This file is part of the WebKit project.
3  *
4  * Copyright (C) 2006, 2008 Apple Computer, Inc.
5  * Copyright (C) 2009 Kenneth Rohde Christiansen
6  *
7  * This library is free software; you can redistribute it and/or
8  * modify it under the terms of the GNU Library General Public
9  * License as published by the Free Software Foundation; either
10  * version 2 of the License, or (at your option) any later version.
11  *
12  * This library is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
15  * Library General Public License for more details.
16  *
17  * You should have received a copy of the GNU Library General Public License
18  * along with this library; see the file COPYING.LIB.  If not, write to
19  * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
20  * Boston, MA 02110-1301, USA.
21  *
22  */
23
24 #ifndef RenderThemeWin_h
25 #define RenderThemeWin_h
26
27 #include "RenderTheme.h"
28
29 #if WIN32
30 typedef void* HANDLE;
31 typedef struct HINSTANCE__* HINSTANCE;
32 typedef HINSTANCE HMODULE;
33 #endif
34
35 namespace WebCore {
36
37 struct ThemeData {
38     ThemeData() :m_part(0), m_state(0), m_classicState(0) {}
39     ThemeData(int part, int state)
40         : m_part(part)
41         , m_state(state)
42         , m_classicState(0)
43     { }
44
45     unsigned m_part;
46     unsigned m_state;
47     unsigned m_classicState;
48 };
49
50 class RenderThemeWin : public RenderTheme {
51 public:
52     static PassRefPtr<RenderTheme> create();
53
54     virtual String extraDefaultStyleSheet();
55     virtual String extraQuirksStyleSheet();
56
57     // A method asking if the theme's controls actually care about redrawing when hovered.
58     virtual bool supportsHover(const RenderStyle*) const;
59
60     virtual Color platformActiveSelectionBackgroundColor() const;
61     virtual Color platformInactiveSelectionBackgroundColor() const;
62     virtual Color platformActiveSelectionForegroundColor() const;
63     virtual Color platformInactiveSelectionForegroundColor() const;
64
65     // System fonts.
66     virtual void systemFont(int propId, FontDescription&) const;
67     virtual Color systemColor(int cssValueId) const;
68
69     virtual bool paintCheckbox(RenderObject* o, const PaintInfo& i, const IntRect& r)
70     { return paintButton(o, i, r); }
71     virtual void setCheckboxSize(RenderStyle*) const;
72
73     virtual bool paintRadio(RenderObject* o, const PaintInfo& i, const IntRect& r)
74     { return paintButton(o, i, r); }
75     virtual void setRadioSize(RenderStyle* style) const
76     { return setCheckboxSize(style); }
77
78     virtual bool paintButton(RenderObject*, const PaintInfo&, const IntRect&);
79
80     virtual void adjustInnerSpinButtonStyle(CSSStyleSelector*, RenderStyle*, Element*) const;
81     virtual bool paintInnerSpinButton(RenderObject*, const PaintInfo&, const IntRect&);
82
83     virtual bool paintTextField(RenderObject*, const PaintInfo&, const IntRect&);
84
85     virtual bool paintTextArea(RenderObject* o, const PaintInfo& i, const IntRect& r)
86     { return paintTextField(o, i, r); }
87
88     virtual void adjustMenuListStyle(CSSStyleSelector* selector, RenderStyle* style, Element* e) const;
89     virtual bool paintMenuList(RenderObject*, const PaintInfo&, const IntRect&);
90     virtual void adjustMenuListButtonStyle(CSSStyleSelector* selector, RenderStyle* style, Element* e) const;
91
92     virtual bool paintMenuListButton(RenderObject*, const PaintInfo&, const IntRect&);
93
94     virtual bool paintSliderTrack(RenderObject* o, const PaintInfo& i, const IntRect& r);
95     virtual bool paintSliderThumb(RenderObject* o, const PaintInfo& i, const IntRect& r);
96     virtual void adjustSliderThumbSize(RenderStyle*) const;
97
98     virtual bool popupOptionSupportsTextIndent() const { return true; }
99
100     virtual void adjustSearchFieldStyle(CSSStyleSelector*, RenderStyle*, Element*) const;
101     virtual bool paintSearchField(RenderObject*, const PaintInfo&, const IntRect&);
102
103     virtual void adjustSearchFieldCancelButtonStyle(CSSStyleSelector*, RenderStyle*, Element*) const;
104     virtual bool paintSearchFieldCancelButton(RenderObject*, const PaintInfo&, const IntRect&);
105
106     virtual void adjustSearchFieldDecorationStyle(CSSStyleSelector*, RenderStyle*, Element*) const;
107     virtual bool paintSearchFieldDecoration(RenderObject*, const PaintInfo&, const IntRect&) { return false; }
108
109     virtual void adjustSearchFieldResultsDecorationStyle(CSSStyleSelector*, RenderStyle*, Element*) const;
110     virtual bool paintSearchFieldResultsDecoration(RenderObject*, const PaintInfo&, const IntRect&);
111
112     virtual void adjustSearchFieldResultsButtonStyle(CSSStyleSelector*, RenderStyle*, Element*) const;
113     virtual bool paintSearchFieldResultsButton(RenderObject*, const PaintInfo&, const IntRect&);
114
115     virtual void themeChanged();
116
117     virtual void adjustButtonStyle(CSSStyleSelector*, RenderStyle* style, Element*) const {}
118     virtual void adjustTextFieldStyle(CSSStyleSelector*, RenderStyle* style, Element*) const {}
119     virtual void adjustTextAreaStyle(CSSStyleSelector*, RenderStyle* style, Element*) const {}
120
121     static void setWebKitIsBeingUnloaded();
122
123     virtual bool supportsFocusRing(const RenderStyle*) const;
124
125 #if ENABLE(VIDEO)
126     virtual String extraMediaControlsStyleSheet();
127 #if ENABLE(FULLSCREEN_API)
128     virtual String extraFullScreenStyleSheet();
129 #endif
130     virtual bool supportsClosedCaptioning() const;
131     virtual bool paintMediaControlsBackground(RenderObject*, const PaintInfo&, const IntRect&);
132     virtual bool paintMediaFullscreenButton(RenderObject*, const PaintInfo&, const IntRect&);
133     virtual bool paintMediaMuteButton(RenderObject*, const PaintInfo&, const IntRect&);
134     virtual bool paintMediaPlayButton(RenderObject*, const PaintInfo&, const IntRect&);
135     virtual bool paintMediaRewindButton(RenderObject*, const PaintInfo&, const IntRect&);
136     virtual bool paintMediaSeekBackButton(RenderObject*, const PaintInfo&, const IntRect&);
137     virtual bool paintMediaSeekForwardButton(RenderObject*, const PaintInfo&, const IntRect&);
138     virtual bool paintMediaSliderTrack(RenderObject*, const PaintInfo&, const IntRect&);
139     virtual bool paintMediaSliderThumb(RenderObject*, const PaintInfo&, const IntRect&);
140     virtual bool paintMediaToggleClosedCaptionsButton(RenderObject*, const PaintInfo&, const IntRect&);
141     virtual bool paintMediaVolumeSliderContainer(RenderObject*, const PaintInfo&, const IntRect&);
142     virtual bool paintMediaVolumeSliderTrack(RenderObject*, const PaintInfo&, const IntRect&);
143     virtual bool paintMediaVolumeSliderThumb(RenderObject*, const PaintInfo&, const IntRect&);
144     virtual IntPoint volumeSliderOffsetFromMuteButton(RenderBox*, const IntSize&) const;
145 #endif
146
147     virtual bool shouldShowPlaceholderWhenFocused() const { return true; }
148
149 private:
150     enum ControlSubPart {
151         None,
152         SpinButtonDown,
153         SpinButtonUp,
154     };
155
156     RenderThemeWin();
157     ~RenderThemeWin();
158
159     void addIntrinsicMargins(RenderStyle*) const;
160     void close();
161
162     unsigned determineState(RenderObject*);
163     unsigned determineClassicState(RenderObject*, ControlSubPart = None);
164     unsigned determineSliderThumbState(RenderObject*);
165     unsigned determineButtonState(RenderObject*);
166     unsigned determineSpinButtonState(RenderObject*, ControlSubPart = None);
167
168     bool supportsFocus(ControlPart) const;
169
170     ThemeData getThemeData(RenderObject*, ControlSubPart = None);
171     ThemeData getClassicThemeData(RenderObject* o, ControlSubPart = None);
172
173     HANDLE buttonTheme() const;
174     HANDLE textFieldTheme() const;
175     HANDLE menuListTheme() const;
176     HANDLE sliderTheme() const;
177     HANDLE spinButtonTheme() const;
178
179     mutable HANDLE m_buttonTheme;
180     mutable HANDLE m_textFieldTheme;
181     mutable HANDLE m_menuListTheme;
182     mutable HANDLE m_sliderTheme;
183     mutable HANDLE m_spinButtonTheme;
184 };
185
186 };
187
188 #endif