2 * This file is part of the theme implementation for form controls in WebCore.
4 * Copyright (C) 2005 Apple Computer, Inc.
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.
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.
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.
23 #ifndef RenderThemeMac_h
24 #define RenderThemeMac_h
26 #import "RenderTheme.h"
27 #import <wtf/HashMap.h>
28 #import <wtf/RetainPtr.h>
31 @class WebCoreRenderThemeNotificationObserver;
33 class WebCoreRenderThemeNotificationObserver;
40 class RenderThemeMac : public RenderTheme {
43 virtual ~RenderThemeMac();
45 // A method to obtain the baseline position for a "leaf" control. This will only be used if a baseline
46 // position cannot be determined by examining child content. Checkboxes and radio buttons are examples of
47 // controls that need to do this.
48 virtual short baselinePosition(const RenderObject*) const;
50 // A method asking if the control changes its tint when the window has focus or not.
51 virtual bool controlSupportsTints(const RenderObject*) const;
53 // A general method asking if any control tinting is supported at all.
54 virtual bool supportsControlTints() const { return true; }
56 virtual void adjustRepaintRect(const RenderObject*, IntRect&);
58 virtual bool isControlStyled(const RenderStyle*, const BorderData&,
59 const BackgroundLayer&, const Color& backgroundColor) const;
61 virtual void paintResizeControl(GraphicsContext*, const IntRect&);
63 virtual Color platformActiveSelectionBackgroundColor() const;
64 virtual Color platformInactiveSelectionBackgroundColor() const;
65 virtual Color activeListBoxSelectionBackgroundColor() const;
67 virtual void platformColorsDidChange();
70 virtual void systemFont(int cssValueId, FontDescription&) const;
72 virtual int minimumMenuListSize(RenderStyle*) const;
74 virtual void adjustSliderThumbSize(RenderObject*) const;
76 virtual int popupInternalPaddingLeft(RenderStyle*) const;
77 virtual int popupInternalPaddingRight(RenderStyle*) const;
78 virtual int popupInternalPaddingTop(RenderStyle*) const;
79 virtual int popupInternalPaddingBottom(RenderStyle*) const;
81 virtual bool paintCapsLockIndicator(RenderObject*, const RenderObject::PaintInfo&, const IntRect&);
83 virtual Color systemColor(int cssValueId) const;
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 void adjustSliderTrackStyle(CSSStyleSelector*, RenderStyle*, Element*) const;
112 virtual bool paintSliderThumb(RenderObject*, const RenderObject::PaintInfo&, const IntRect&);
113 virtual void adjustSliderThumbStyle(CSSStyleSelector*, RenderStyle*, Element*) const;
115 virtual bool paintSearchField(RenderObject*, const RenderObject::PaintInfo&, const IntRect&);
116 virtual void adjustSearchFieldStyle(CSSStyleSelector*, RenderStyle*, Element*) const;
118 virtual void adjustSearchFieldCancelButtonStyle(CSSStyleSelector*, RenderStyle*, Element*) const;
119 virtual bool paintSearchFieldCancelButton(RenderObject*, const RenderObject::PaintInfo&, const IntRect&);
121 virtual void adjustSearchFieldDecorationStyle(CSSStyleSelector*, RenderStyle*, Element*) const;
122 virtual bool paintSearchFieldDecoration(RenderObject*, const RenderObject::PaintInfo&, const IntRect&);
124 virtual void adjustSearchFieldResultsDecorationStyle(CSSStyleSelector*, RenderStyle*, Element*) const;
125 virtual bool paintSearchFieldResultsDecoration(RenderObject*, const RenderObject::PaintInfo&, const IntRect&);
127 virtual void adjustSearchFieldResultsButtonStyle(CSSStyleSelector*, RenderStyle*, Element*) const;
128 virtual bool paintSearchFieldResultsButton(RenderObject*, const RenderObject::PaintInfo&, const IntRect&);
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&);
139 IntRect inflateRect(const IntRect&, const IntSize&, const int* margins) const;
141 // Get the control size based off the font. Used by some of the controls (like buttons).
142 NSControlSize controlSizeForFont(RenderStyle*) const;
143 NSControlSize controlSizeForSystemFont(RenderStyle*) const;
144 void setControlSize(NSCell*, const IntSize* sizes, const IntSize& minSize);
145 void setSizeFromFont(RenderStyle*, const IntSize* sizes) const;
146 IntSize sizeForFont(RenderStyle*, const IntSize* sizes) const;
147 IntSize sizeForSystemFont(RenderStyle*, const IntSize* sizes) const;
148 void setFontFromControlSize(CSSStyleSelector*, RenderStyle*, NSControlSize) const;
150 void updateCheckedState(NSCell*, const RenderObject*);
151 void updateEnabledState(NSCell*, const RenderObject*);
152 void updateFocusedState(NSCell*, const RenderObject*);
153 void updatePressedState(NSCell*, const RenderObject*);
155 // Helpers for adjusting appearance and for painting
156 const IntSize* checkboxSizes() const;
157 const int* checkboxMargins() const;
158 void setCheckboxCellState(const RenderObject*, const IntRect&);
160 const IntSize* radioSizes() const;
161 const int* radioMargins() const;
162 void setRadioCellState(const RenderObject*, const IntRect&);
164 void setButtonPaddingFromControlSize(RenderStyle*, NSControlSize) const;
165 const IntSize* buttonSizes() const;
166 const int* buttonMargins() const;
167 void setButtonCellState(const RenderObject*, const IntRect&);
169 void setPopupButtonCellState(const RenderObject*, const IntRect&);
170 const IntSize* popupButtonSizes() const;
171 const int* popupButtonMargins() const;
172 const int* popupButtonPadding(NSControlSize) const;
173 void paintMenuListButtonGradients(RenderObject*, const RenderObject::PaintInfo&, const IntRect&);
174 const IntSize* menuListSizes() const;
176 const IntSize* searchFieldSizes() const;
177 const IntSize* cancelButtonSizes() const;
178 const IntSize* resultsButtonSizes() const;
179 void setSearchCellState(RenderObject*, const IntRect&);
180 void setSearchFieldSize(RenderStyle*) const;
182 NSButtonCell* checkbox() const;
183 NSButtonCell* radio() const;
184 NSButtonCell* button() const;
185 NSPopUpButtonCell* popupButton() const;
186 NSSearchFieldCell* search() const;
187 NSMenu* searchMenuTemplate() const;
188 NSSliderCell* sliderThumbHorizontal() const;
189 NSSliderCell* sliderThumbVertical() const;
190 Image* resizeCornerImage() const;
193 mutable RetainPtr<NSButtonCell> m_checkbox;
194 mutable RetainPtr<NSButtonCell> m_radio;
195 mutable RetainPtr<NSButtonCell> m_button;
196 mutable RetainPtr<NSPopUpButtonCell> m_popupButton;
197 mutable RetainPtr<NSSearchFieldCell> m_search;
198 mutable RetainPtr<NSMenu> m_searchMenuTemplate;
199 mutable RetainPtr<NSSliderCell> m_sliderThumbHorizontal;
200 mutable RetainPtr<NSSliderCell> m_sliderThumbVertical;
201 mutable Image* m_resizeCornerImage;
203 bool m_isSliderThumbHorizontalPressed;
204 bool m_isSliderThumbVerticalPressed;
206 mutable HashMap<int, RGBA32> m_systemColorCache;
208 RetainPtr<WebCoreRenderThemeNotificationObserver> m_notificationObserver;
211 } // namespace WebCore
213 #endif // RenderThemeMac_h