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 <QBrush> 28#include <QPalette> 29#include <QSharedPointer> 30#include <QString> 31 32QT_BEGIN_NAMESPACE 33class QPainter; 34QT_END_NAMESPACE 35 36namespace WebCore { 37 38#if ENABLE(PROGRESS_ELEMENT) 39class RenderProgress; 40#endif 41class RenderStyle; 42class HTMLMediaElement; 43class StylePainter; 44class ScrollbarTheme; 45 46typedef PassRefPtr<RenderTheme> (*QtThemeFactoryFunction)(Page* page); 47 48class RenderThemeQt : public RenderTheme { 49 50public: 51 RenderThemeQt(Page*); 52 53 static void setCustomTheme(QtThemeFactoryFunction, ScrollbarTheme* customScrollbarTheme); 54 static ScrollbarTheme* customScrollbarTheme(); 55 56 String extraDefaultStyleSheet(); 57 58 virtual bool supportsHover(const RenderStyle*) const; 59 virtual bool supportsFocusRing(const RenderStyle*) const; 60 61 virtual int baselinePosition(const RenderObject*) const; 62 63 // A method asking if the control changes its tint when the window has focus or not. 64 virtual bool controlSupportsTints(const RenderObject*) const; 65 66 // A general method asking if any control tinting is supported at all. 67 virtual bool supportsControlTints() const; 68 69 virtual void adjustRepaintRect(const RenderObject*, IntRect&); 70 71 // The platform selection color. 72 virtual Color platformActiveSelectionBackgroundColor() const; 73 virtual Color platformInactiveSelectionBackgroundColor() const; 74 virtual Color platformActiveSelectionForegroundColor() const; 75 virtual Color platformInactiveSelectionForegroundColor() const; 76 77 virtual Color platformFocusRingColor() const; 78 79 virtual void systemFont(int propId, FontDescription&) const; 80 virtual Color systemColor(int cssValueId) const; 81 82 virtual int minimumMenuListSize(RenderStyle*) const; 83 84 virtual void adjustSliderThumbSize(RenderStyle*, Element*) const; 85 86#if ENABLE(DATALIST_ELEMENT) 87 virtual IntSize sliderTickSize() const OVERRIDE; 88 virtual int sliderTickOffsetFromTrackCenter() const OVERRIDE; 89#endif 90 91 virtual double caretBlinkInterval() const; 92 93 virtual bool isControlStyled(const RenderStyle*, const BorderData&, const FillLayer&, const Color&) const; 94 95#if ENABLE(VIDEO) 96 virtual String extraMediaControlsStyleSheet(); 97#endif 98 99protected: 100 virtual bool paintCheckbox(RenderObject*, const PaintInfo&, const IntRect&); 101 virtual void setCheckboxSize(RenderStyle*) const; 102 103 virtual bool paintRadio(RenderObject*, const PaintInfo&, const IntRect&); 104 virtual void setRadioSize(RenderStyle*) const; 105 106 virtual void setButtonSize(RenderStyle*) const; 107 108 virtual void adjustTextFieldStyle(StyleResolver*, RenderStyle*, Element*) const; 109 110 virtual bool paintTextArea(RenderObject*, const PaintInfo&, const IntRect&); 111 virtual void adjustTextAreaStyle(StyleResolver*, RenderStyle*, Element*) const; 112 113 virtual void adjustMenuListStyle(StyleResolver*, RenderStyle*, Element*) const; 114 115 virtual void adjustMenuListButtonStyle(StyleResolver*, RenderStyle*, Element*) const; 116 117#if ENABLE(PROGRESS_ELEMENT) 118 virtual void adjustProgressBarStyle(StyleResolver*, RenderStyle*, Element*) const; 119 // Returns the repeat interval of the animation for the progress bar. 120 virtual double animationRepeatIntervalForProgressBar(RenderProgress*) const; 121#endif 122 123 virtual void adjustSliderTrackStyle(StyleResolver*, RenderStyle*, Element*) const; 124 125 virtual void adjustSliderThumbStyle(StyleResolver*, RenderStyle*, Element*) const; 126 127 virtual bool paintSearchField(RenderObject*, const PaintInfo&, const IntRect&); 128 virtual void adjustSearchFieldStyle(StyleResolver*, RenderStyle*, Element*) const; 129 130 virtual void adjustSearchFieldCancelButtonStyle(StyleResolver*, RenderStyle*, Element*) const; 131 virtual bool paintSearchFieldCancelButton(RenderObject*, const PaintInfo&, const IntRect&); 132 133 virtual void adjustSearchFieldDecorationStyle(StyleResolver*, RenderStyle*, Element*) const; 134 virtual bool paintSearchFieldDecoration(RenderObject*, const PaintInfo&, const IntRect&); 135 136 virtual void adjustSearchFieldResultsDecorationStyle(StyleResolver*, RenderStyle*, Element*) const; 137 virtual bool paintSearchFieldResultsDecoration(RenderObject*, const PaintInfo&, const IntRect&); 138 139#ifndef QT_NO_SPINBOX 140 virtual void adjustInnerSpinButtonStyle(StyleResolver*, RenderStyle*, Element*) const; 141#endif 142 143#if ENABLE(VIDEO) 144 virtual bool paintMediaFullscreenButton(RenderObject*, const PaintInfo&, const IntRect&); 145 virtual bool paintMediaPlayButton(RenderObject*, const PaintInfo&, const IntRect&); 146 virtual bool paintMediaMuteButton(RenderObject*, const PaintInfo&, const IntRect&); 147 virtual bool paintMediaSeekBackButton(RenderObject*, const PaintInfo&, const IntRect&); 148 virtual bool paintMediaSeekForwardButton(RenderObject*, const PaintInfo&, const IntRect&); 149 virtual bool paintMediaSliderTrack(RenderObject*, const PaintInfo&, const IntRect&); 150 virtual bool paintMediaSliderThumb(RenderObject*, const PaintInfo&, const IntRect&); 151 virtual bool paintMediaCurrentTime(RenderObject*, const PaintInfo&, const IntRect&); 152 virtual bool paintMediaVolumeSliderTrack(RenderObject*, const PaintInfo&, const IntRect&); 153 virtual bool paintMediaVolumeSliderThumb(RenderObject*, const PaintInfo&, const IntRect&); 154 virtual String formatMediaControlsCurrentTime(float currentTime, float duration) const; 155 virtual String formatMediaControlsRemainingTime(float currentTime, float duration) const; 156 virtual bool hasOwnDisabledStateHandlingFor(ControlPart) const { return true; } 157 158 void paintMediaBackground(QPainter*, const IntRect&) const; 159 double mediaControlsBaselineOpacity() const; 160 QColor getMediaControlForegroundColor(RenderObject* = 0) const; 161#endif 162 virtual void computeSizeBasedOnStyle(RenderStyle*) const = 0; 163 164 virtual String fileListNameForWidth(const FileList*, const Font&, int width, bool multipleFilesAllowed) const OVERRIDE; 165 166 virtual QRect inflateButtonRect(const QRect& originalRect) const; 167 168 virtual void setPopupPadding(RenderStyle*) const = 0; 169 170 virtual QSharedPointer<StylePainter> getStylePainter(const PaintInfo&) = 0; 171 172 bool supportsFocus(ControlPart) const; 173 174 IntRect convertToPaintingRect(RenderObject* inputRenderer, const RenderObject* partRenderer, IntRect partRect, const IntRect& localOffset) const; 175 176 virtual QPalette colorPalette() const; 177 178 Page* m_page; 179 180 QString m_buttonFontFamily; 181 182}; 183 184class StylePainter { 185public: 186 virtual ~StylePainter(); 187 188 bool isValid() const { return painter; } 189 190 QPainter* painter; 191 192protected: 193 StylePainter(RenderThemeQt*, const PaintInfo&); 194 StylePainter(); 195 void init(GraphicsContext*); 196 197private: 198 QBrush m_previousBrush; 199 bool m_previousAntialiasing; 200 201}; 202 203} 204 205#endif // RenderThemeQt_h 206