]> git.saurik.com Git - iphone-api.git/blob - WebCore/RenderThemeChromiumMac.h
Add support for new WinterBoard Settings features.
[iphone-api.git] / WebCore / RenderThemeChromiumMac.h
1 /*
2 * This file is part of the theme implementation for form controls in WebCore.
3 *
4 * Copyright (C) 2005 Apple Computer, Inc.
5 * Copyright (C) 2008, 2009 Google, Inc.
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 RenderThemeChromiumMac_h
25 #define RenderThemeChromiumMac_h
26
27 #import "RenderTheme.h"
28 #import <wtf/HashMap.h>
29 #import <wtf/RetainPtr.h>
30
31 #ifdef __OBJC__
32 @class WebCoreRenderThemeNotificationObserver;
33 #else
34 class WebCoreRenderThemeNotificationObserver;
35 #endif
36
37 namespace WebCore {
38
39 class RenderStyle;
40
41 class RenderThemeChromiumMac : public RenderTheme {
42 public:
43 RenderThemeChromiumMac();
44 virtual ~RenderThemeChromiumMac();
45
46 // A method to obtain the baseline position for a "leaf" control. This will only be used if a baseline
47 // position cannot be determined by examining child content. Checkboxes and radio buttons are examples of
48 // controls that need to do this.
49 virtual int baselinePosition(const RenderObject*) const;
50
51 // A method asking if the control changes its tint when the window has focus or not.
52 virtual bool controlSupportsTints(const RenderObject*) const;
53
54 // A general method asking if any control tinting is supported at all.
55 virtual bool supportsControlTints() const { return true; }
56
57 virtual void adjustRepaintRect(const RenderObject*, IntRect&);
58
59 virtual bool isControlStyled(const RenderStyle*, const BorderData&,
60 const FillLayer&, const Color& backgroundColor) const;
61
62 virtual Color platformActiveSelectionBackgroundColor() const;
63 virtual Color platformInactiveSelectionBackgroundColor() const;
64 virtual Color activeListBoxSelectionBackgroundColor() const;
65
66 virtual void platformColorsDidChange();
67
68 // System fonts.
69 virtual void systemFont(int cssValueId, Document*, FontDescription&) const;
70
71 virtual int minimumMenuListSize(RenderStyle*) const;
72
73 virtual void adjustSliderThumbSize(RenderObject*) const;
74
75 virtual int popupInternalPaddingLeft(RenderStyle*) const;
76 virtual int popupInternalPaddingRight(RenderStyle*) const;
77 virtual int popupInternalPaddingTop(RenderStyle*) const;
78 virtual int popupInternalPaddingBottom(RenderStyle*) const;
79
80 virtual bool paintCapsLockIndicator(RenderObject*, const RenderObject::PaintInfo&, const IntRect&);
81
82 virtual Color systemColor(int cssValueId) const;
83
84 protected:
85 // Methods for each appearance value.
86 virtual bool paintCheckbox(RenderObject*, const RenderObject::PaintInfo&, const IntRect&);
87 virtual void setCheckboxSize(RenderStyle*) const;
88
89 virtual bool paintRadio(RenderObject*, const RenderObject::PaintInfo&, const IntRect&);
90 virtual void setRadioSize(RenderStyle*) const;
91
92 virtual void adjustButtonStyle(CSSStyleSelector*, RenderStyle*, WebCore::Element*) const;
93 virtual bool paintButton(RenderObject*, const RenderObject::PaintInfo&, const IntRect&);
94 virtual void setButtonSize(RenderStyle*) const;
95
96 virtual bool paintTextField(RenderObject*, const RenderObject::PaintInfo&, const IntRect&);
97 virtual void adjustTextFieldStyle(CSSStyleSelector*, RenderStyle*, Element*) const;
98
99 virtual bool paintTextArea(RenderObject*, const RenderObject::PaintInfo&, const IntRect&);
100 virtual void adjustTextAreaStyle(CSSStyleSelector*, RenderStyle*, Element*) const;
101
102 virtual bool paintMenuList(RenderObject*, const RenderObject::PaintInfo&, const IntRect&);
103 virtual void adjustMenuListStyle(CSSStyleSelector*, RenderStyle*, Element*) const;
104
105 virtual bool paintMenuListButton(RenderObject*, const RenderObject::PaintInfo&, const IntRect&);
106 virtual void adjustMenuListButtonStyle(CSSStyleSelector*, RenderStyle*, Element*) const;
107
108 virtual bool paintSliderTrack(RenderObject*, const RenderObject::PaintInfo&, const IntRect&);
109 virtual void adjustSliderTrackStyle(CSSStyleSelector*, RenderStyle*, Element*) const;
110
111 virtual bool paintSliderThumb(RenderObject*, const RenderObject::PaintInfo&, const IntRect&);
112 virtual void adjustSliderThumbStyle(CSSStyleSelector*, RenderStyle*, Element*) const;
113
114 virtual bool paintSearchField(RenderObject*, const RenderObject::PaintInfo&, const IntRect&);
115 virtual void adjustSearchFieldStyle(CSSStyleSelector*, RenderStyle*, Element*) const;
116
117 virtual void adjustSearchFieldCancelButtonStyle(CSSStyleSelector*, RenderStyle*, Element*) const;
118 virtual bool paintSearchFieldCancelButton(RenderObject*, const RenderObject::PaintInfo&, const IntRect&);
119
120 virtual void adjustSearchFieldDecorationStyle(CSSStyleSelector*, RenderStyle*, Element*) const;
121 virtual bool paintSearchFieldDecoration(RenderObject*, const RenderObject::PaintInfo&, const IntRect&);
122
123 virtual void adjustSearchFieldResultsDecorationStyle(CSSStyleSelector*, RenderStyle*, Element*) const;
124 virtual bool paintSearchFieldResultsDecoration(RenderObject*, const RenderObject::PaintInfo&, const IntRect&);
125
126 virtual void adjustSearchFieldResultsButtonStyle(CSSStyleSelector*, RenderStyle*, Element*) const;
127 virtual bool paintSearchFieldResultsButton(RenderObject*, const RenderObject::PaintInfo&, const IntRect&);
128
129 virtual bool paintMediaFullscreenButton(RenderObject*, const RenderObject::PaintInfo&, const IntRect&);
130 virtual bool paintMediaPlayButton(RenderObject*, const RenderObject::PaintInfo&, const IntRect&);
131 virtual bool paintMediaMuteButton(RenderObject*, const RenderObject::PaintInfo&, const IntRect&);
132 virtual bool paintMediaSeekBackButton(RenderObject*, const RenderObject::PaintInfo&, const IntRect&);
133 virtual bool paintMediaSeekForwardButton(RenderObject*, const RenderObject::PaintInfo&, const IntRect&);
134 virtual bool paintMediaSliderTrack(RenderObject*, const RenderObject::PaintInfo&, const IntRect&);
135 virtual bool paintMediaSliderThumb(RenderObject*, const RenderObject::PaintInfo&, const IntRect&);
136
137 private:
138 IntRect inflateRect(const IntRect&, const IntSize&, const int* margins, float zoomLevel = 1.0f) const;
139
140 // Get the control size based off the font. Used by some of the controls (like buttons).
141 NSControlSize controlSizeForFont(RenderStyle*) const;
142 NSControlSize controlSizeForSystemFont(RenderStyle*) const;
143 void setControlSize(NSCell*, const IntSize* sizes, const IntSize& minSize, float zoomLevel = 1.0f);
144 void setSizeFromFont(RenderStyle*, const IntSize* sizes) const;
145 IntSize sizeForFont(RenderStyle*, const IntSize* sizes) const;
146 IntSize sizeForSystemFont(RenderStyle*, const IntSize* sizes) const;
147 void setFontFromControlSize(CSSStyleSelector*, RenderStyle*, NSControlSize) const;
148
149 void updateCheckedState(NSCell*, const RenderObject*);
150 void updateEnabledState(NSCell*, const RenderObject*);
151 void updateFocusedState(NSCell*, const RenderObject*);
152 void updatePressedState(NSCell*, const RenderObject*);
153
154 // Helpers for adjusting appearance and for painting
155 const IntSize* checkboxSizes() const;
156 const int* checkboxMargins() const;
157 void setCheckboxCellState(const RenderObject*, const IntRect&);
158
159 const IntSize* radioSizes() const;
160 const int* radioMargins() const;
161 void setRadioCellState(const RenderObject*, const IntRect&);
162
163 void setButtonPaddingFromControlSize(RenderStyle*, NSControlSize) const;
164 const IntSize* buttonSizes() const;
165 const int* buttonMargins() const;
166 void setButtonCellState(const RenderObject*, const IntRect&);
167
168 void setPopupButtonCellState(const RenderObject*, const IntRect&);
169 const IntSize* popupButtonSizes() const;
170 const int* popupButtonMargins() const;
171 const int* popupButtonPadding(NSControlSize) const;
172 void paintMenuListButtonGradients(RenderObject*, const RenderObject::PaintInfo&, const IntRect&);
173 const IntSize* menuListSizes() const;
174
175 const IntSize* searchFieldSizes() const;
176 const IntSize* cancelButtonSizes() const;
177 const IntSize* resultsButtonSizes() const;
178 void setSearchCellState(RenderObject*, const IntRect&);
179 void setSearchFieldSize(RenderStyle*) const;
180
181 NSButtonCell* checkbox() const;
182 NSButtonCell* radio() const;
183 NSButtonCell* button() const;
184 NSPopUpButtonCell* popupButton() const;
185 NSSearchFieldCell* search() const;
186 NSMenu* searchMenuTemplate() const;
187 NSSliderCell* sliderThumbHorizontal() const;
188 NSSliderCell* sliderThumbVertical() const;
189
190 private:
191 mutable RetainPtr<NSButtonCell> m_checkbox;
192 mutable RetainPtr<NSButtonCell> m_radio;
193 mutable RetainPtr<NSButtonCell> m_button;
194 mutable RetainPtr<NSPopUpButtonCell> m_popupButton;
195 mutable RetainPtr<NSSearchFieldCell> m_search;
196 mutable RetainPtr<NSMenu> m_searchMenuTemplate;
197 mutable RetainPtr<NSSliderCell> m_sliderThumbHorizontal;
198 mutable RetainPtr<NSSliderCell> m_sliderThumbVertical;
199
200 bool m_isSliderThumbHorizontalPressed;
201 bool m_isSliderThumbVerticalPressed;
202
203 mutable HashMap<int, RGBA32> m_systemColorCache;
204
205 RetainPtr<WebCoreRenderThemeNotificationObserver> m_notificationObserver;
206 };
207
208 } // namespace WebCore
209
210 #endif