1/* 2 * This file is part of the theme implementation for form controls in WebCore. 3 * 4 * Copyright (C) 2005 Apple Computer, Inc. 5 * 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. 10 * 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. 15 * 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. 20 * 21 */ 22 23#ifndef RenderThemeMac_h 24#define RenderThemeMac_h 25 26#import "RenderTheme.h" 27#import <wtf/HashMap.h> 28#import <wtf/RetainPtr.h> 29 30#ifdef __OBJC__ 31@class WebCoreRenderThemeNotificationObserver; 32#else 33class WebCoreRenderThemeNotificationObserver; 34#endif 35 36namespace WebCore { 37 38class RenderStyle; 39 40class RenderThemeMac : public RenderTheme { 41public: 42 static PassRefPtr<RenderTheme> create(); 43 44 // A method asking if the control changes its tint when the window has focus or not. 45 virtual bool controlSupportsTints(const RenderObject*) const; 46 47 // A general method asking if any control tinting is supported at all. 48 virtual bool supportsControlTints() const { return true; } 49 50 virtual void adjustRepaintRect(const RenderObject*, IntRect&); 51 52 virtual bool isControlStyled(const RenderStyle*, const BorderData&, 53 const FillLayer&, const Color& backgroundColor) const; 54 55 virtual Color platformActiveSelectionBackgroundColor() const; 56 virtual Color platformInactiveSelectionBackgroundColor() const; 57 virtual Color platformActiveListBoxSelectionBackgroundColor() const; 58 virtual Color platformActiveListBoxSelectionForegroundColor() const; 59 virtual Color platformInactiveListBoxSelectionBackgroundColor() const; 60 virtual Color platformInactiveListBoxSelectionForegroundColor() const; 61 virtual Color platformFocusRingColor() const; 62 63 virtual ScrollbarControlSize scrollbarControlSizeForPart(ControlPart) { return SmallScrollbar; } 64 65 virtual void platformColorsDidChange(); 66 67 // System fonts. 68 virtual void systemFont(int cssValueId, FontDescription&) const; 69 70 virtual int minimumMenuListSize(RenderStyle*) const; 71 72 virtual void adjustSliderThumbSize(RenderObject*) const; 73 74 virtual int popupInternalPaddingLeft(RenderStyle*) const; 75 virtual int popupInternalPaddingRight(RenderStyle*) const; 76 virtual int popupInternalPaddingTop(RenderStyle*) const; 77 virtual int popupInternalPaddingBottom(RenderStyle*) const; 78 79 virtual bool paintCapsLockIndicator(RenderObject*, const RenderObject::PaintInfo&, const IntRect&); 80 81 virtual Color systemColor(int cssValueId) const; 82 83protected: 84 virtual bool supportsSelectionForegroundColors() const { return false; } 85 86 virtual bool paintTextField(RenderObject*, const RenderObject::PaintInfo&, const IntRect&); 87 virtual void adjustTextFieldStyle(CSSStyleSelector*, RenderStyle*, Element*) const; 88 89 virtual bool paintTextArea(RenderObject*, const RenderObject::PaintInfo&, const IntRect&); 90 virtual void adjustTextAreaStyle(CSSStyleSelector*, RenderStyle*, Element*) const; 91 92 virtual bool paintMenuList(RenderObject*, const RenderObject::PaintInfo&, const IntRect&); 93 virtual void adjustMenuListStyle(CSSStyleSelector*, RenderStyle*, Element*) const; 94 95 virtual bool paintMenuListButton(RenderObject*, const RenderObject::PaintInfo&, const IntRect&); 96 virtual void adjustMenuListButtonStyle(CSSStyleSelector*, RenderStyle*, Element*) const; 97 98 virtual bool paintSliderTrack(RenderObject*, const RenderObject::PaintInfo&, const IntRect&); 99 virtual void adjustSliderTrackStyle(CSSStyleSelector*, RenderStyle*, Element*) const; 100 101 virtual bool paintSliderThumb(RenderObject*, const RenderObject::PaintInfo&, const IntRect&); 102 virtual void adjustSliderThumbStyle(CSSStyleSelector*, RenderStyle*, Element*) const; 103 104 virtual bool paintSearchField(RenderObject*, const RenderObject::PaintInfo&, const IntRect&); 105 virtual void adjustSearchFieldStyle(CSSStyleSelector*, RenderStyle*, Element*) const; 106 107 virtual void adjustSearchFieldCancelButtonStyle(CSSStyleSelector*, RenderStyle*, Element*) const; 108 virtual bool paintSearchFieldCancelButton(RenderObject*, const RenderObject::PaintInfo&, const IntRect&); 109 110 virtual void adjustSearchFieldDecorationStyle(CSSStyleSelector*, RenderStyle*, Element*) const; 111 virtual bool paintSearchFieldDecoration(RenderObject*, const RenderObject::PaintInfo&, const IntRect&); 112 113 virtual void adjustSearchFieldResultsDecorationStyle(CSSStyleSelector*, RenderStyle*, Element*) const; 114 virtual bool paintSearchFieldResultsDecoration(RenderObject*, const RenderObject::PaintInfo&, const IntRect&); 115 116 virtual void adjustSearchFieldResultsButtonStyle(CSSStyleSelector*, RenderStyle*, Element*) const; 117 virtual bool paintSearchFieldResultsButton(RenderObject*, const RenderObject::PaintInfo&, const IntRect&); 118 119#if ENABLE(VIDEO) 120 virtual bool paintMediaFullscreenButton(RenderObject*, const RenderObject::PaintInfo&, const IntRect&); 121 virtual bool paintMediaPlayButton(RenderObject*, const RenderObject::PaintInfo&, const IntRect&); 122 virtual bool paintMediaMuteButton(RenderObject*, const RenderObject::PaintInfo&, const IntRect&); 123 virtual bool paintMediaSeekBackButton(RenderObject*, const RenderObject::PaintInfo&, const IntRect&); 124 virtual bool paintMediaSeekForwardButton(RenderObject*, const RenderObject::PaintInfo&, const IntRect&); 125 virtual bool paintMediaSliderTrack(RenderObject*, const RenderObject::PaintInfo&, const IntRect&); 126 virtual bool paintMediaSliderThumb(RenderObject*, const RenderObject::PaintInfo&, const IntRect&); 127 virtual bool paintMediaRewindButton(RenderObject*, const RenderObject::PaintInfo&, const IntRect&); 128 virtual bool paintMediaReturnToRealtimeButton(RenderObject*, const RenderObject::PaintInfo&, const IntRect&); 129 virtual bool paintMediaToggleClosedCaptionsButton(RenderObject*, const RenderObject::PaintInfo&, const IntRect&); 130 virtual bool paintMediaControlsBackground(RenderObject*, const RenderObject::PaintInfo&, const IntRect&); 131 virtual bool paintMediaCurrentTime(RenderObject*, const RenderObject::PaintInfo&, const IntRect&); 132 virtual bool paintMediaTimeRemaining(RenderObject*, const RenderObject::PaintInfo&, const IntRect&); 133 134 // Media controls 135 virtual String extraMediaControlsStyleSheet(); 136 137 virtual bool shouldRenderMediaControlPart(ControlPart, Element*); 138#endif 139 140private: 141 RenderThemeMac(); 142 virtual ~RenderThemeMac(); 143 144 IntRect inflateRect(const IntRect&, const IntSize&, const int* margins, float zoomLevel = 1.0f) const; 145 146 FloatRect convertToPaintingRect(const RenderObject* inputRenderer, const RenderObject* partRenderer, const FloatRect& inputRect, const IntRect& r) const; 147 148 // Get the control size based off the font. Used by some of the controls (like buttons). 149 NSControlSize controlSizeForFont(RenderStyle*) const; 150 NSControlSize controlSizeForSystemFont(RenderStyle*) const; 151 void setControlSize(NSCell*, const IntSize* sizes, const IntSize& minSize, float zoomLevel = 1.0f); 152 void setSizeFromFont(RenderStyle*, const IntSize* sizes) const; 153 IntSize sizeForFont(RenderStyle*, const IntSize* sizes) const; 154 IntSize sizeForSystemFont(RenderStyle*, const IntSize* sizes) const; 155 void setFontFromControlSize(CSSStyleSelector*, RenderStyle*, NSControlSize) const; 156 157 void updateCheckedState(NSCell*, const RenderObject*); 158 void updateEnabledState(NSCell*, const RenderObject*); 159 void updateFocusedState(NSCell*, const RenderObject*); 160 void updatePressedState(NSCell*, const RenderObject*); 161 162 // Helpers for adjusting appearance and for painting 163 164 void setPopupButtonCellState(const RenderObject*, const IntRect&); 165 const IntSize* popupButtonSizes() const; 166 const int* popupButtonMargins() const; 167 const int* popupButtonPadding(NSControlSize) const; 168 void paintMenuListButtonGradients(RenderObject*, const RenderObject::PaintInfo&, const IntRect&); 169 const IntSize* menuListSizes() const; 170 171 const IntSize* searchFieldSizes() const; 172 const IntSize* cancelButtonSizes() const; 173 const IntSize* resultsButtonSizes() const; 174 void setSearchCellState(RenderObject*, const IntRect&); 175 void setSearchFieldSize(RenderStyle*) const; 176 177 NSPopUpButtonCell* popupButton() const; 178 NSSearchFieldCell* search() const; 179 NSMenu* searchMenuTemplate() const; 180 NSSliderCell* sliderThumbHorizontal() const; 181 NSSliderCell* sliderThumbVertical() const; 182 183private: 184 mutable RetainPtr<NSPopUpButtonCell> m_popupButton; 185 mutable RetainPtr<NSSearchFieldCell> m_search; 186 mutable RetainPtr<NSMenu> m_searchMenuTemplate; 187 mutable RetainPtr<NSSliderCell> m_sliderThumbHorizontal; 188 mutable RetainPtr<NSSliderCell> m_sliderThumbVertical; 189 190 bool m_isSliderThumbHorizontalPressed; 191 bool m_isSliderThumbVerticalPressed; 192 193 mutable HashMap<int, RGBA32> m_systemColorCache; 194 195 RetainPtr<WebCoreRenderThemeNotificationObserver> m_notificationObserver; 196}; 197 198} // namespace WebCore 199 200#endif // RenderThemeMac_h 201