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/RetainPtr.h>
30 @class WebCoreRenderThemeNotificationObserver;
32 class WebCoreRenderThemeNotificationObserver;
39 class RenderThemeMac : public RenderTheme {
42 virtual ~RenderThemeMac();
44 // A method to obtain the baseline position for a "leaf" control. This will only be used if a baseline
45 // position cannot be determined by examining child content. Checkboxes and radio buttons are examples of
46 // controls that need to do this.
47 virtual short baselinePosition(const RenderObject*) const;
49 // A method asking if the control changes its tint when the window has focus or not.
50 virtual bool controlSupportsTints(const RenderObject*) const;
52 // A general method asking if any control tinting is supported at all.
53 virtual bool supportsControlTints() const { return true; }
55 virtual void adjustRepaintRect(const RenderObject*, IntRect&);
57 virtual bool isControlStyled(const RenderStyle*, const BorderData&,
58 const BackgroundLayer&, const Color& backgroundColor) const;
60 virtual void paintResizeControl(GraphicsContext*, const IntRect&);
62 virtual Color platformActiveSelectionBackgroundColor() const;
63 virtual Color platformInactiveSelectionBackgroundColor() const;
64 virtual Color activeListBoxSelectionBackgroundColor() const;
67 virtual void systemFont(int propId, FontDescription&) const;
69 virtual int minimumMenuListSize(RenderStyle*) const;
71 virtual void adjustSliderThumbSize(RenderObject*) const;
73 virtual int popupInternalPaddingLeft(RenderStyle*) const;
74 virtual int popupInternalPaddingRight(RenderStyle*) const;
75 virtual int popupInternalPaddingTop(RenderStyle*) const;
76 virtual int popupInternalPaddingBottom(RenderStyle*) const;
78 virtual bool paintCapsLockIndicator(RenderObject*, const RenderObject::PaintInfo&, const IntRect&);
81 // Methods for each appearance value.
82 virtual bool paintCheckbox(RenderObject*, const RenderObject::PaintInfo&, const IntRect&);
83 virtual void setCheckboxSize(RenderStyle*) const;
85 virtual bool paintRadio(RenderObject*, const RenderObject::PaintInfo&, const IntRect&);
86 virtual void setRadioSize(RenderStyle*) const;
88 virtual void adjustButtonStyle(CSSStyleSelector*, RenderStyle*, WebCore::Element*) const;
89 virtual bool paintButton(RenderObject*, const RenderObject::PaintInfo&, const IntRect&);
90 virtual void setButtonSize(RenderStyle*) const;
92 virtual bool paintTextField(RenderObject*, const RenderObject::PaintInfo&, const IntRect&);
93 virtual void adjustTextFieldStyle(CSSStyleSelector*, RenderStyle*, Element*) const;
95 virtual bool paintTextArea(RenderObject*, const RenderObject::PaintInfo&, const IntRect&);
96 virtual void adjustTextAreaStyle(CSSStyleSelector*, RenderStyle*, Element*) const;
98 virtual bool paintMenuList(RenderObject*, const RenderObject::PaintInfo&, const IntRect&);
99 virtual void adjustMenuListStyle(CSSStyleSelector*, RenderStyle*, Element*) const;
101 virtual bool paintMenuListButton(RenderObject*, const RenderObject::PaintInfo&, const IntRect&);
102 virtual void adjustMenuListButtonStyle(CSSStyleSelector*, RenderStyle*, Element*) const;
104 virtual bool paintSliderTrack(RenderObject*, const RenderObject::PaintInfo&, const IntRect&);
105 virtual void adjustSliderTrackStyle(CSSStyleSelector*, RenderStyle*, Element*) const;
107 virtual bool paintSliderThumb(RenderObject*, const RenderObject::PaintInfo&, const IntRect&);
108 virtual void adjustSliderThumbStyle(CSSStyleSelector*, RenderStyle*, Element*) const;
110 virtual bool paintSearchField(RenderObject*, const RenderObject::PaintInfo&, const IntRect&);
111 virtual void adjustSearchFieldStyle(CSSStyleSelector*, RenderStyle*, Element*) const;
113 virtual void adjustSearchFieldCancelButtonStyle(CSSStyleSelector*, RenderStyle*, Element*) const;
114 virtual bool paintSearchFieldCancelButton(RenderObject*, const RenderObject::PaintInfo&, const IntRect&);
116 virtual void adjustSearchFieldDecorationStyle(CSSStyleSelector*, RenderStyle*, Element*) const;
117 virtual bool paintSearchFieldDecoration(RenderObject*, const RenderObject::PaintInfo&, const IntRect&);
119 virtual void adjustSearchFieldResultsDecorationStyle(CSSStyleSelector*, RenderStyle*, Element*) const;
120 virtual bool paintSearchFieldResultsDecoration(RenderObject*, const RenderObject::PaintInfo&, const IntRect&);
122 virtual void adjustSearchFieldResultsButtonStyle(CSSStyleSelector*, RenderStyle*, Element*) const;
123 virtual bool paintSearchFieldResultsButton(RenderObject*, const RenderObject::PaintInfo&, const IntRect&);
126 IntRect inflateRect(const IntRect&, const IntSize&, const int* margins) const;
128 // Get the control size based off the font. Used by some of the controls (like buttons).
129 NSControlSize controlSizeForFont(RenderStyle*) const;
130 NSControlSize controlSizeForSystemFont(RenderStyle*) const;
131 void setControlSize(NSCell*, const IntSize* sizes, const IntSize& minSize);
132 void setSizeFromFont(RenderStyle*, const IntSize* sizes) const;
133 IntSize sizeForFont(RenderStyle*, const IntSize* sizes) const;
134 IntSize sizeForSystemFont(RenderStyle*, const IntSize* sizes) const;
135 void setFontFromControlSize(CSSStyleSelector*, RenderStyle*, NSControlSize) const;
137 void updateCheckedState(NSCell*, const RenderObject*);
138 void updateEnabledState(NSCell*, const RenderObject*);
139 void updateFocusedState(NSCell*, const RenderObject*);
140 void updatePressedState(NSCell*, const RenderObject*);
142 // Helpers for adjusting appearance and for painting
143 const IntSize* checkboxSizes() const;
144 const int* checkboxMargins() const;
145 void setCheckboxCellState(const RenderObject*, const IntRect&);
147 const IntSize* radioSizes() const;
148 const int* radioMargins() const;
149 void setRadioCellState(const RenderObject*, const IntRect&);
151 void setButtonPaddingFromControlSize(RenderStyle*, NSControlSize) const;
152 const IntSize* buttonSizes() const;
153 const int* buttonMargins() const;
154 void setButtonCellState(const RenderObject*, const IntRect&);
156 void setPopupButtonCellState(const RenderObject*, const IntRect&);
157 const IntSize* popupButtonSizes() const;
158 const int* popupButtonMargins() const;
159 const int* popupButtonPadding(NSControlSize) const;
160 void paintMenuListButtonGradients(RenderObject*, const RenderObject::PaintInfo&, const IntRect&);
161 const IntSize* menuListSizes() const;
163 const IntSize* searchFieldSizes() const;
164 const IntSize* cancelButtonSizes() const;
165 const IntSize* resultsButtonSizes() const;
166 void setSearchCellState(RenderObject*, const IntRect&);
167 void setSearchFieldSize(RenderStyle*) const;
169 NSButtonCell* checkbox() const;
170 NSButtonCell* radio() const;
171 NSButtonCell* button() const;
172 NSPopUpButtonCell* popupButton() const;
173 NSSearchFieldCell* search() const;
174 NSMenu* searchMenuTemplate() const;
175 NSSliderCell* sliderThumbHorizontal() const;
176 NSSliderCell* sliderThumbVertical() const;
177 Image* resizeCornerImage() const;
180 mutable RetainPtr<NSButtonCell> m_checkbox;
181 mutable RetainPtr<NSButtonCell> m_radio;
182 mutable RetainPtr<NSButtonCell> m_button;
183 mutable RetainPtr<NSPopUpButtonCell> m_popupButton;
184 mutable RetainPtr<NSSearchFieldCell> m_search;
185 mutable RetainPtr<NSMenu> m_searchMenuTemplate;
186 mutable RetainPtr<NSSliderCell> m_sliderThumbHorizontal;
187 mutable RetainPtr<NSSliderCell> m_sliderThumbVertical;
188 mutable Image* m_resizeCornerImage;
190 bool m_isSliderThumbHorizontalPressed;
191 bool m_isSliderThumbVerticalPressed;
193 RetainPtr<WebCoreRenderThemeNotificationObserver> m_notificationObserver;
196 } // namespace WebCore
198 #endif // RenderThemeMac_h