1/* 2 * This file is part of the WebKit project. 3 * 4 * Copyright (C) 2006, 2008, 2013 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 30typedef void* HANDLE; 31typedef struct HINSTANCE__* HINSTANCE; 32typedef HINSTANCE HMODULE; 33#endif 34 35namespace WebCore { 36 37struct 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 50class RenderThemeWin : public RenderTheme { 51public: 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(StyleResolver*, 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(StyleResolver*, RenderStyle*, Element*) const; 89 virtual bool paintMenuList(RenderObject*, const PaintInfo&, const IntRect&); 90 virtual void adjustMenuListButtonStyle(StyleResolver*, RenderStyle*, Element*) 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*, Element*) const; 97 98 virtual bool popupOptionSupportsTextIndent() const { return true; } 99 100 virtual void adjustSearchFieldStyle(StyleResolver*, RenderStyle*, Element*) const; 101 virtual bool paintSearchField(RenderObject*, const PaintInfo&, const IntRect&); 102 103 virtual void adjustSearchFieldCancelButtonStyle(StyleResolver*, RenderStyle*, Element*) const; 104 virtual bool paintSearchFieldCancelButton(RenderObject*, const PaintInfo&, const IntRect&); 105 106 virtual void adjustSearchFieldDecorationStyle(StyleResolver*, RenderStyle*, Element*) const; 107 virtual bool paintSearchFieldDecoration(RenderObject*, const PaintInfo&, const IntRect&) { return false; } 108 109 virtual void adjustSearchFieldResultsDecorationStyle(StyleResolver*, RenderStyle*, Element*) const; 110 virtual bool paintSearchFieldResultsDecoration(RenderObject*, const PaintInfo&, const IntRect&); 111 112 virtual void adjustSearchFieldResultsButtonStyle(StyleResolver*, RenderStyle*, Element*) const; 113 virtual bool paintSearchFieldResultsButton(RenderObject*, const PaintInfo&, const IntRect&); 114 115 virtual void themeChanged(); 116 117 virtual void adjustButtonStyle(StyleResolver*, RenderStyle* style, Element*) const { } 118 virtual void adjustTextFieldStyle(StyleResolver*, RenderStyle* style, Element*) const { } 119 virtual void adjustTextAreaStyle(StyleResolver*, 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 paintMediaVolumeSliderContainer(RenderObject*, const PaintInfo&, const IntRect&); 141 virtual bool paintMediaVolumeSliderTrack(RenderObject*, const PaintInfo&, const IntRect&); 142 virtual bool paintMediaVolumeSliderThumb(RenderObject*, const PaintInfo&, const IntRect&); 143 virtual IntPoint volumeSliderOffsetFromMuteButton(RenderBox*, const IntSize&) const OVERRIDE; 144#endif 145 146#if ENABLE(METER_ELEMENT) 147 virtual IntSize meterSizeForBounds(const RenderMeter*, const IntRect&) const OVERRIDE; 148 virtual bool supportsMeter(ControlPart) const OVERRIDE; 149 virtual void adjustMeterStyle(StyleResolver*, RenderStyle*, Element*) const OVERRIDE; 150 virtual bool paintMeter(RenderObject*, const PaintInfo&, const IntRect&) OVERRIDE; 151#endif 152 153 virtual bool shouldShowPlaceholderWhenFocused() const { return true; } 154 155private: 156 enum ControlSubPart { 157 None, 158 SpinButtonDown, 159 SpinButtonUp, 160 }; 161 162 RenderThemeWin(); 163 virtual ~RenderThemeWin(); 164 165 void addIntrinsicMargins(RenderStyle*) const; 166 void close(); 167 168 unsigned determineState(RenderObject*); 169 unsigned determineClassicState(RenderObject*, ControlSubPart = None); 170 unsigned determineSliderThumbState(RenderObject*); 171 unsigned determineButtonState(RenderObject*); 172 unsigned determineSpinButtonState(RenderObject*, ControlSubPart = None); 173 174 bool supportsFocus(ControlPart) const; 175 176 ThemeData getThemeData(RenderObject*, ControlSubPart = None); 177 ThemeData getClassicThemeData(RenderObject* o, ControlSubPart = None); 178 179 HANDLE buttonTheme() const; 180 HANDLE textFieldTheme() const; 181 HANDLE menuListTheme() const; 182 HANDLE sliderTheme() const; 183 HANDLE spinButtonTheme() const; 184 HANDLE progressBarTheme() const; 185 186 mutable HANDLE m_buttonTheme; 187 mutable HANDLE m_textFieldTheme; 188 mutable HANDLE m_menuListTheme; 189 mutable HANDLE m_sliderTheme; 190 mutable HANDLE m_spinButtonTheme; 191 mutable HANDLE m_progressBarTheme; 192}; 193 194}; 195 196#endif 197