2008-11-04 Anders Carlsson <andersca@apple.com>
[webkit/qt.git] / WebCore / rendering / RenderThemeSafari.h
blob8ac5acfe71d83ad236b73367a62bd907d1422d36
1 /*
2 * Copyright (C) 2007, 2008 Apple Inc.
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Library General Public
6 * License as published by the Free Software Foundation; either
7 * version 2 of the License, or (at your option) any later version.
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Library General Public License for more details.
14 * You should have received a copy of the GNU Library General Public License
15 * along with this library; see the file COPYING.LIB. If not, write to
16 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
17 * Boston, MA 02110-1301, USA.
21 #ifndef RenderThemeSafari_h
22 #define RenderThemeSafari_h
24 #if USE(SAFARI_THEME)
26 #include "RenderTheme.h"
28 // If you have an empty placeholder SafariThemeConstants.h, then include SafariTheme.h
29 // This is a workaround until a version of WebKitSupportLibrary is released with an updated SafariThemeConstants.h
30 #include <SafariTheme/SafariThemeConstants.h>
31 #ifndef SafariThemeConstants_h
32 #include <SafariTheme/SafariTheme.h>
33 #endif
35 #if PLATFORM(WIN)
36 typedef void* HANDLE;
37 typedef struct HINSTANCE__* HINSTANCE;
38 typedef HINSTANCE HMODULE;
39 #endif
41 namespace WebCore {
43 using namespace SafariTheme;
45 class RenderStyle;
47 class RenderThemeSafari : public RenderTheme {
48 public:
49 RenderThemeSafari();
50 virtual ~RenderThemeSafari();
52 // A method to obtain the baseline position for a "leaf" control. This will only be used if a baseline
53 // position cannot be determined by examining child content. Checkboxes and radio buttons are examples of
54 // controls that need to do this.
55 virtual int baselinePosition(const RenderObject*) const;
57 // A method asking if the control changes its tint when the window has focus or not.
58 virtual bool controlSupportsTints(const RenderObject*) const;
60 // A general method asking if any control tinting is supported at all.
61 virtual bool supportsControlTints() const { return true; }
63 virtual void adjustRepaintRect(const RenderObject*, IntRect&);
65 virtual bool isControlStyled(const RenderStyle*, const BorderData&,
66 const FillLayer&, const Color& backgroundColor) const;
68 virtual Color platformActiveSelectionBackgroundColor() const;
69 virtual Color platformInactiveSelectionBackgroundColor() const;
70 virtual Color activeListBoxSelectionBackgroundColor() const;
72 // System fonts.
73 virtual void systemFont(int propId, FontDescription&) const;
75 virtual int minimumMenuListSize(RenderStyle*) const;
77 virtual void adjustSliderThumbSize(RenderObject*) const;
78 virtual void adjustSliderThumbStyle(CSSStyleSelector*, RenderStyle*, Element*) const;
80 virtual int popupInternalPaddingLeft(RenderStyle*) const;
81 virtual int popupInternalPaddingRight(RenderStyle*) const;
82 virtual int popupInternalPaddingTop(RenderStyle*) const;
83 virtual int popupInternalPaddingBottom(RenderStyle*) const;
85 protected:
86 // Methods for each appearance value.
87 virtual bool paintCheckbox(RenderObject*, const RenderObject::PaintInfo&, const IntRect&);
88 virtual void setCheckboxSize(RenderStyle*) const;
90 virtual bool paintRadio(RenderObject*, const RenderObject::PaintInfo&, const IntRect&);
91 virtual void setRadioSize(RenderStyle*) const;
93 virtual void adjustButtonStyle(CSSStyleSelector*, RenderStyle*, WebCore::Element*) const;
94 virtual bool paintButton(RenderObject*, const RenderObject::PaintInfo&, const IntRect&);
95 virtual void setButtonSize(RenderStyle*) const;
97 virtual bool paintTextField(RenderObject*, const RenderObject::PaintInfo&, const IntRect&);
98 virtual void adjustTextFieldStyle(CSSStyleSelector*, RenderStyle*, Element*) const;
100 virtual bool paintTextArea(RenderObject*, const RenderObject::PaintInfo&, const IntRect&);
101 virtual void adjustTextAreaStyle(CSSStyleSelector*, RenderStyle*, Element*) const;
103 virtual bool paintMenuList(RenderObject*, const RenderObject::PaintInfo&, const IntRect&);
104 virtual void adjustMenuListStyle(CSSStyleSelector*, RenderStyle*, Element*) const;
106 virtual bool paintMenuListButton(RenderObject*, const RenderObject::PaintInfo&, const IntRect&);
107 virtual void adjustMenuListButtonStyle(CSSStyleSelector*, RenderStyle*, Element*) const;
109 virtual bool paintSliderTrack(RenderObject*, const RenderObject::PaintInfo&, const IntRect&);
110 virtual bool paintSliderThumb(RenderObject*, const RenderObject::PaintInfo&, const IntRect&);
112 virtual bool paintSearchField(RenderObject*, const RenderObject::PaintInfo&, const IntRect&);
113 virtual void adjustSearchFieldStyle(CSSStyleSelector*, RenderStyle*, Element*) const;
115 virtual void adjustSearchFieldCancelButtonStyle(CSSStyleSelector*, RenderStyle*, Element*) const;
116 virtual bool paintSearchFieldCancelButton(RenderObject*, const RenderObject::PaintInfo&, const IntRect&);
118 virtual void adjustSearchFieldDecorationStyle(CSSStyleSelector*, RenderStyle*, Element*) const;
119 virtual bool paintSearchFieldDecoration(RenderObject*, const RenderObject::PaintInfo&, const IntRect&);
121 virtual void adjustSearchFieldResultsDecorationStyle(CSSStyleSelector*, RenderStyle*, Element*) const;
122 virtual bool paintSearchFieldResultsDecoration(RenderObject*, const RenderObject::PaintInfo&, const IntRect&);
124 virtual void adjustSearchFieldResultsButtonStyle(CSSStyleSelector*, RenderStyle*, Element*) const;
125 virtual bool paintSearchFieldResultsButton(RenderObject*, const RenderObject::PaintInfo&, const IntRect&);
127 virtual bool paintCapsLockIndicator(RenderObject*, const RenderObject::PaintInfo&, const IntRect&);
129 #if ENABLE(VIDEO)
130 virtual bool paintMediaFullscreenButton(RenderObject*, const RenderObject::PaintInfo&, const IntRect&);
131 virtual bool paintMediaPlayButton(RenderObject*, const RenderObject::PaintInfo&, const IntRect&);
132 virtual bool paintMediaMuteButton(RenderObject*, const RenderObject::PaintInfo&, const IntRect&);
133 virtual bool paintMediaSeekBackButton(RenderObject*, const RenderObject::PaintInfo&, const IntRect&);
134 virtual bool paintMediaSeekForwardButton(RenderObject*, const RenderObject::PaintInfo&, const IntRect&);
135 virtual bool paintMediaSliderTrack(RenderObject*, const RenderObject::PaintInfo&, const IntRect&);
136 virtual bool paintMediaSliderThumb(RenderObject*, const RenderObject::PaintInfo&, const IntRect&);
137 #endif
139 private:
140 IntRect inflateRect(const IntRect&, const IntSize&, const int* margins) const;
142 // Get the control size based off the font. Used by some of the controls (like buttons).
144 NSControlSize controlSizeForFont(RenderStyle*) const;
145 NSControlSize controlSizeForSystemFont(RenderStyle*) const;
146 //void setControlSize(NSCell*, const IntSize* sizes, const IntSize& minSize);
147 void setSizeFromFont(RenderStyle*, const IntSize* sizes) const;
148 IntSize sizeForFont(RenderStyle*, const IntSize* sizes) const;
149 IntSize sizeForSystemFont(RenderStyle*, const IntSize* sizes) const;
150 void setFontFromControlSize(CSSStyleSelector*, RenderStyle*, NSControlSize) const;
152 // Helpers for adjusting appearance and for painting
153 const IntSize* checkboxSizes() const;
154 const int* checkboxMargins(NSControlSize) const;
156 const IntSize* radioSizes() const;
157 const int* radioMargins(NSControlSize) const;
159 void setButtonPaddingFromControlSize(RenderStyle*, NSControlSize) const;
160 const IntSize* buttonSizes() const;
161 const int* buttonMargins(NSControlSize) const;
163 const IntSize* popupButtonSizes() const;
164 const int* popupButtonMargins(NSControlSize) const;
165 const int* popupButtonPadding(NSControlSize) const;
166 void paintMenuListButtonGradients(RenderObject*, const RenderObject::PaintInfo&, const IntRect&);
167 const IntSize* menuListSizes() const;
169 const IntSize* searchFieldSizes() const;
170 const IntSize* cancelButtonSizes() const;
171 const IntSize* resultsButtonSizes() const;
172 void setSearchFieldSize(RenderStyle*) const;
174 ThemeControlState determineState(RenderObject*) const;
177 } // namespace WebCore
179 #endif // #if USE(SAFARI_THEME)
181 #endif // RenderThemeSafari_h