RenderThemeGtk.h revision 2bde8e466a4451c7319e3a072d118917957d6554
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 "GRefPtr.h" 32#include "RenderTheme.h" 33 34typedef gulong GType; 35typedef struct _GdkColormap GdkColormap; 36 37namespace WebCore { 38 39class RenderThemeGtk : public RenderTheme { 40private: 41 RenderThemeGtk(); 42 virtual ~RenderThemeGtk(); 43 44public: 45 static PassRefPtr<RenderTheme> create(); 46 47 // A method asking if the theme's controls actually care about redrawing when hovered. 48 virtual bool supportsHover(const RenderStyle* style) const { return true; } 49 50 // A method asking if the theme is able to draw the focus ring. 51 virtual bool supportsFocusRing(const RenderStyle*) const; 52 53 // A method asking if the control changes its tint when the window has focus or not. 54 virtual bool controlSupportsTints(const RenderObject*) const; 55 56 // A general method asking if any control tinting is supported at all. 57 virtual bool supportsControlTints() const { return true; } 58 59 virtual void adjustRepaintRect(const RenderObject*, IntRect&); 60 61 // A method to obtain the baseline position for a "leaf" control. This will only be used if a baseline 62 // position cannot be determined by examining child content. Checkboxes and radio buttons are examples of 63 // controls that need to do this. 64 virtual int baselinePosition(const RenderObject*) const; 65 66 // The platform selection color. 67 virtual Color platformActiveSelectionBackgroundColor() const; 68 virtual Color platformInactiveSelectionBackgroundColor() const; 69 virtual Color platformActiveSelectionForegroundColor() const; 70 virtual Color platformInactiveSelectionForegroundColor() const; 71 72 // List Box selection color 73 virtual Color activeListBoxSelectionBackgroundColor() const; 74 virtual Color activeListBoxSelectionForegroundColor() const; 75 virtual Color inactiveListBoxSelectionBackgroundColor() const; 76 virtual Color inactiveListBoxSelectionForegroundColor() const; 77 78 virtual double caretBlinkInterval() const; 79 80 virtual void platformColorsDidChange(); 81 82 // System fonts and colors. 83 virtual void systemFont(int propId, FontDescription&) const; 84 virtual Color systemColor(int cssValueId) const; 85 86#if ENABLE(VIDEO) 87 virtual String extraMediaControlsStyleSheet(); 88 virtual String formatMediaControlsCurrentTime(float currentTime, float duration) const; 89#endif 90 91#ifdef GTK_API_VERSION_2 92 GtkWidget* gtkVScrollbar() const; 93 GtkWidget* gtkHScrollbar() const; 94 static void getIndicatorMetrics(ControlPart, int& indicatorSize, int& indicatorSpacing); 95#else 96 GtkStyleContext* gtkScrollbarStyle(); 97#endif 98 99protected: 100 virtual bool paintCheckbox(RenderObject* o, const PaintInfo& i, const IntRect& r); 101 virtual void setCheckboxSize(RenderStyle* style) const; 102 103 virtual bool paintRadio(RenderObject* o, const PaintInfo& i, const IntRect& r); 104 virtual void setRadioSize(RenderStyle* style) const; 105 106 virtual void adjustButtonStyle(CSSStyleSelector*, RenderStyle*, Element*) const; 107 virtual bool paintButton(RenderObject*, const PaintInfo&, const IntRect&); 108 109 virtual bool paintTextField(RenderObject*, const PaintInfo&, const IntRect&); 110 virtual bool paintTextArea(RenderObject*, const PaintInfo&, const IntRect&); 111 112 int popupInternalPaddingLeft(RenderStyle*) const; 113 int popupInternalPaddingRight(RenderStyle*) const; 114 int popupInternalPaddingTop(RenderStyle*) const; 115 int popupInternalPaddingBottom(RenderStyle*) const; 116 117 // The Mac port differentiates between the "menu list" and the "menu list button." 118 // The former is used when a menu list button has been styled. This is used to ensure 119 // Aqua themed controls whenever possible. We always want to use GTK+ theming, so 120 // we don't maintain this differentiation. 121 virtual void adjustMenuListStyle(CSSStyleSelector*, RenderStyle*, Element*) const; 122 virtual void adjustMenuListButtonStyle(CSSStyleSelector*, RenderStyle*, Element* e) const; 123 virtual bool paintMenuList(RenderObject*, const PaintInfo&, const IntRect&); 124 virtual bool paintMenuListButton(RenderObject*, const PaintInfo&, const IntRect&); 125 126 virtual void adjustSearchFieldResultsDecorationStyle(CSSStyleSelector*, RenderStyle*, Element*) const; 127 virtual bool paintSearchFieldResultsDecoration(RenderObject*, const PaintInfo&, const IntRect&); 128 129 virtual void adjustSearchFieldStyle(CSSStyleSelector*, RenderStyle*, Element*) const; 130 virtual bool paintSearchField(RenderObject*, const PaintInfo&, const IntRect&); 131 132 virtual void adjustSearchFieldResultsButtonStyle(CSSStyleSelector*, RenderStyle*, Element*) const; 133 virtual bool paintSearchFieldResultsButton(RenderObject*, const PaintInfo&, const IntRect&); 134 135 virtual void adjustSearchFieldCancelButtonStyle(CSSStyleSelector*, RenderStyle*, Element*) const; 136 virtual bool paintSearchFieldCancelButton(RenderObject*, const PaintInfo&, const IntRect&); 137 138 virtual bool paintSliderTrack(RenderObject*, const PaintInfo&, const IntRect&); 139 virtual void adjustSliderTrackStyle(CSSStyleSelector*, RenderStyle*, Element*) const; 140 141 virtual bool paintSliderThumb(RenderObject*, const PaintInfo&, const IntRect&); 142 virtual void adjustSliderThumbStyle(CSSStyleSelector*, RenderStyle*, Element*) const; 143 144 virtual void adjustSliderThumbSize(RenderObject* object) const; 145 146#if ENABLE(VIDEO) 147 void initMediaColors(); 148 void initMediaButtons(); 149 void adjustMediaSliderThumbSize(RenderObject*) const; 150 virtual bool paintMediaFullscreenButton(RenderObject*, const PaintInfo&, const IntRect&); 151 virtual bool paintMediaPlayButton(RenderObject*, const PaintInfo&, const IntRect&); 152 virtual bool paintMediaMuteButton(RenderObject*, const PaintInfo&, const IntRect&); 153 virtual bool paintMediaSeekBackButton(RenderObject*, const PaintInfo&, const IntRect&); 154 virtual bool paintMediaSeekForwardButton(RenderObject*, const PaintInfo&, const IntRect&); 155 virtual bool paintMediaSliderTrack(RenderObject*, const PaintInfo&, const IntRect&); 156 virtual bool paintMediaSliderThumb(RenderObject*, const PaintInfo&, const IntRect&); 157 virtual bool paintMediaVolumeSliderContainer(RenderObject*, const PaintInfo&, const IntRect&); 158 virtual bool paintMediaVolumeSliderTrack(RenderObject*, const PaintInfo&, const IntRect&); 159 virtual bool paintMediaVolumeSliderThumb(RenderObject*, const PaintInfo&, const IntRect&); 160 virtual bool paintMediaCurrentTime(RenderObject*, const PaintInfo&, const IntRect&); 161#endif 162 163#if ENABLE(PROGRESS_TAG) 164 virtual double animationRepeatIntervalForProgressBar(RenderProgress*) const; 165 virtual double animationDurationForProgressBar(RenderProgress*) const; 166 virtual void adjustProgressBarStyle(CSSStyleSelector*, RenderStyle*, Element*) const; 167 virtual bool paintProgressBar(RenderObject*, const PaintInfo&, const IntRect&); 168#endif 169 170 virtual bool paintCapsLockIndicator(RenderObject*, const PaintInfo&, const IntRect&); 171 172 virtual void adjustInnerSpinButtonStyle(CSSStyleSelector*, RenderStyle*, Element*) const; 173 virtual bool paintInnerSpinButton(RenderObject*, const PaintInfo&, const IntRect&); 174 175private: 176 void platformInit(); 177 static void setTextInputBorders(RenderStyle*); 178 GRefPtr<GdkPixbuf> getStockIcon(GType, const char* iconName, gint direction, gint state, gint iconSize); 179 static double getScreenDPI(); 180 181#if ENABLE(VIDEO) 182 bool paintMediaButton(RenderObject*, GraphicsContext*, const IntRect&, const char* iconName); 183#endif 184 185#if ENABLE(PROGRESS_TAG) 186 static IntRect calculateProgressRect(RenderObject*, const IntRect&); 187#endif 188 189 mutable Color m_panelColor; 190 mutable Color m_sliderColor; 191 mutable Color m_sliderThumbColor; 192 const int m_mediaIconSize; 193 const int m_mediaSliderHeight; 194 const int m_mediaSliderThumbWidth; 195 const int m_mediaSliderThumbHeight; 196 197#ifdef GTK_API_VERSION_2 198 void setupWidgetAndAddToContainer(GtkWidget*, GtkWidget*) const; 199 void refreshComboBoxChildren() const; 200 void getComboBoxPadding(RenderStyle*, int& left, int& top, int& right, int& bottom) const; 201 int getComboBoxSeparatorWidth() const; 202 int comboBoxArrowSize(RenderStyle*) const; 203 204 GtkWidget* gtkButton() const; 205 GtkWidget* gtkEntry() const; 206 GtkWidget* gtkTreeView() const; 207 GtkWidget* gtkVScale() const; 208 GtkWidget* gtkHScale() const; 209 GtkWidget* gtkContainer() const; 210 GtkWidget* gtkRadioButton() const; 211 GtkWidget* gtkCheckButton() const; 212 GtkWidget* gtkProgressBar() const; 213 GtkWidget* gtkComboBox() const; 214 GtkWidget* gtkComboBoxButton() const; 215 GtkWidget* gtkComboBoxArrow() const; 216 GtkWidget* gtkComboBoxSeparator() const; 217 GtkWidget* gtkSpinButton() const; 218 219 GdkColormap* m_colormap; 220 mutable GtkWidget* m_gtkWindow; 221 mutable GtkWidget* m_gtkContainer; 222 mutable GtkWidget* m_gtkButton; 223 mutable GtkWidget* m_gtkEntry; 224 mutable GtkWidget* m_gtkTreeView; 225 mutable GtkWidget* m_gtkVScale; 226 mutable GtkWidget* m_gtkHScale; 227 mutable GtkWidget* m_gtkRadioButton; 228 mutable GtkWidget* m_gtkCheckButton; 229 mutable GtkWidget* m_gtkProgressBar; 230 mutable GtkWidget* m_gtkComboBox; 231 mutable GtkWidget* m_gtkComboBoxButton; 232 mutable GtkWidget* m_gtkComboBoxArrow; 233 mutable GtkWidget* m_gtkComboBoxSeparator; 234 mutable GtkWidget* m_gtkVScrollbar; 235 mutable GtkWidget* m_gtkHScrollbar; 236 mutable GtkWidget* m_gtkSpinButton; 237 bool m_themePartsHaveRGBAColormap; 238 friend class WidgetRenderingContext; 239#endif 240}; 241 242} 243 244#endif // RenderThemeGtk_h 245