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&);
131 IntRect inflateRect(const IntRect&, const IntSize&, const int* margins) const;
133 // Get the control size based off the font. Used by some of the controls (like buttons).
134 NSControlSize controlSizeForFont(RenderStyle*) const;
135 NSControlSize controlSizeForSystemFont(RenderStyle*) const;
136 void setControlSize(NSCell*, const IntSize* sizes, const IntSize& minSize);
137 void setSizeFromFont(RenderStyle*, const IntSize* sizes) const;
138 IntSize sizeForFont(RenderStyle*, const IntSize* sizes) const;
139 IntSize sizeForSystemFont(RenderStyle*, const IntSize* sizes) const;
140 void setFontFromControlSize(CSSStyleSelector*, RenderStyle*, NSControlSize) const;
142 void updateCheckedState(NSCell*, const RenderObject*);
143 void updateEnabledState(NSCell*, const RenderObject*);
144 void updateFocusedState(NSCell*, const RenderObject*);
145 void updatePressedState(NSCell*, const RenderObject*);
147 // Helpers for adjusting appearance and for painting
148 const IntSize* checkboxSizes() const;
149 const int* checkboxMargins() const;
150 void setCheckboxCellState(const RenderObject*, const IntRect&);
152 const IntSize* radioSizes() const;
153 const int* radioMargins() const;
154 void setRadioCellState(const RenderObject*, const IntRect&);
156 void setButtonPaddingFromControlSize(RenderStyle*, NSControlSize) const;
157 const IntSize* buttonSizes() const;
158 const int* buttonMargins() const;
159 void setButtonCellState(const RenderObject*, const IntRect&);
161 void setPopupButtonCellState(const RenderObject*, const IntRect&);
162 const IntSize* popupButtonSizes() const;
163 const int* popupButtonMargins() const;
164 const int* popupButtonPadding(NSControlSize) const;
165 void paintMenuListButtonGradients(RenderObject*, const RenderObject::PaintInfo&, const IntRect&);
166 const IntSize* menuListSizes() const;
168 const IntSize* searchFieldSizes() const;
169 const IntSize* cancelButtonSizes() const;
170 const IntSize* resultsButtonSizes() const;
171 void setSearchCellState(RenderObject*, const IntRect&);
172 void setSearchFieldSize(RenderStyle*) const;
174 NSButtonCell* checkbox() const;
175 NSButtonCell* radio() const;
176 NSButtonCell* button() const;
177 NSPopUpButtonCell* popupButton() const;
178 NSSearchFieldCell* search() const;
179 NSMenu* searchMenuTemplate() const;
180 NSSliderCell* sliderThumbHorizontal() const;
181 NSSliderCell* sliderThumbVertical() const;
182 Image* resizeCornerImage() const;
185 mutable RetainPtr<NSButtonCell> m_checkbox;
186 mutable RetainPtr<NSButtonCell> m_radio;
187 mutable RetainPtr<NSButtonCell> m_button;
188 mutable RetainPtr<NSPopUpButtonCell> m_popupButton;
189 mutable RetainPtr<NSSearchFieldCell> m_search;
190 mutable RetainPtr<NSMenu> m_searchMenuTemplate;
191 mutable RetainPtr<NSSliderCell> m_sliderThumbHorizontal;
192 mutable RetainPtr<NSSliderCell> m_sliderThumbVertical;
193 mutable Image* m_resizeCornerImage;
195 bool m_isSliderThumbHorizontalPressed;
196 bool m_isSliderThumbVerticalPressed;
198 mutable HashMap<int, RGBA32> m_systemColorCache;
200 RetainPtr<WebCoreRenderThemeNotificationObserver> m_notificationObserver;
203 } // namespace WebCore
205 #endif // RenderThemeMac_h