18e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project/* 28e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project * Copyright (C) 2008 Apple Inc. All Rights Reserved. 38e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project * 48e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project * Redistribution and use in source and binary forms, with or without 58e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project * modification, are permitted provided that the following conditions 68e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project * are met: 78e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project * 1. Redistributions of source code must retain the above copyright 88e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project * notice, this list of conditions and the following disclaimer. 98e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project * 2. Redistributions in binary form must reproduce the above copyright 108e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project * notice, this list of conditions and the following disclaimer in the 118e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project * documentation and/or other materials provided with the distribution. 128e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project * 138e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY 148e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 158e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 168e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR 178e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 188e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 198e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 208e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY 218e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 228e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 238e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 248e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project */ 258e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project 268e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project#ifndef Theme_h 278e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project#define Theme_h 288e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project 298e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project#include "Color.h" 308e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project#include "Font.h" 318e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project#include "IntRect.h" 328e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project#include "LengthBox.h" 338e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project#include "LengthSize.h" 348e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project#include "PlatformString.h" 358e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project#include "ThemeTypes.h" 368e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project 378e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Projectnamespace WebCore { 388e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project 398e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Projectclass GraphicsContext; 408e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Projectclass ScrollView; 418e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project 428e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project// Unlike other platform classes, Theme does extensively use virtual functions. This design allows a platform to switch between multiple themes at runtime. 438e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Projectclass Theme { 448e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Projectpublic: 458e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project Theme() { } 468e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project virtual ~Theme() { } 478e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project 488e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project // A method to obtain the baseline position adjustment for a "leaf" control. This will only be used if a baseline 498e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project // position cannot be determined by examining child content. Checkboxes and radio buttons are examples of 508e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project // controls that need to do this. The adjustment is an offset that adds to the baseline, e.g., marginTop() + height() + |offset|. 518e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project // The offset is not zoomed. 528e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project virtual int baselinePositionAdjustment(ControlPart) const { return 0; } 538e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project 548e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project // A method asking if the control changes its appearance when the window is inactive. 558e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project virtual bool controlHasInactiveAppearance(ControlPart) const { return false; } 568e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project 578e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project // General methods for whether or not any of the controls in the theme change appearance when the window is inactive or 588e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project // when hovered over. 598e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project virtual bool controlsCanHaveInactiveAppearance() const { return false; } 608e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project virtual bool controlsCanHaveHoveredAppearance() const { return false; } 618e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project 628e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project // Used by RenderTheme::isControlStyled to figure out if the native look and feel should be turned off. 638e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project virtual bool controlDrawsBorder(ControlPart) const { return true; } 648e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project virtual bool controlDrawsBackground(ControlPart) const { return true; } 658e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project virtual bool controlDrawsFocusOutline(ControlPart) const { return true; } 668e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project 678e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project // Methods for obtaining platform-specific colors. 688e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project virtual Color selectionColor(ControlPart, ControlState, SelectionPart) const { return Color(); } 698e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project virtual Color textSearchHighlightColor() const { return Color(); } 708e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project 718e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project // CSS system colors and fonts 728e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project virtual Color systemColor(ThemeColor) const { return Color(); } 738e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project virtual Font systemFont(ThemeFont, FontDescription&) const { return Font(); } 748e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project 758e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project // How fast the caret blinks in text fields. 76635860845790a19bf50bbc51ba8fb66a96dde068The Android Open Source Project virtual double caretBlinkInterval() const { return 0.5; } 778e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project 788e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project // Notification when the theme has changed 798e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project virtual void themeChanged() { } 808e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project 818e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project // Methods used to adjust the RenderStyles of controls. 828e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project 838e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project // The font description result should have a zoomed font size. 84635860845790a19bf50bbc51ba8fb66a96dde068The Android Open Source Project virtual FontDescription controlFont(ControlPart, const Font& font, float /*zoomFactor*/) const { return font.fontDescription(); } 858e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project 868e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project // The size here is in zoomed coordinates already. If a new size is returned, it also needs to be in zoomed coordinates. 87635860845790a19bf50bbc51ba8fb66a96dde068The Android Open Source Project virtual LengthSize controlSize(ControlPart, const Font&, const LengthSize& zoomedSize, float /*zoomFactor*/) const { return zoomedSize; } 888e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project 898e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project // Returns the minimum size for a control in zoomed coordinates. 90635860845790a19bf50bbc51ba8fb66a96dde068The Android Open Source Project virtual LengthSize minimumControlSize(ControlPart, const Font&, float /*zoomFactor*/) const { return LengthSize(Length(0, Fixed), Length(0, Fixed)); } 918e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project 928e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project // Allows the theme to modify the existing padding/border. 938e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project virtual LengthBox controlPadding(ControlPart, const Font&, const LengthBox& zoomedBox, float zoomFactor) const; 948e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project virtual LengthBox controlBorder(ControlPart, const Font&, const LengthBox& zoomedBox, float zoomFactor) const; 958e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project 968e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project // Whether or not whitespace: pre should be forced on always. 978e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project virtual bool controlRequiresPreWhiteSpace(ControlPart) const { return false; } 988e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project 99635860845790a19bf50bbc51ba8fb66a96dde068The Android Open Source Project // Method for painting a control. The rect is in zoomed coordinates. 100635860845790a19bf50bbc51ba8fb66a96dde068The Android Open Source Project virtual void paint(ControlPart, ControlStates, GraphicsContext*, const IntRect& /*zoomedRect*/, float /*zoomFactor*/, ScrollView*) const { } 1018e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project 1028e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project // Some controls may spill out of their containers (e.g., the check on an OS X checkbox). When these controls repaint, 1038e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project // the theme needs to communicate this inflated rect to the engine so that it can invalidate the whole control. 1048e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project // The rect passed in is in zoomed coordinates, so the inflation should take that into account and make sure the inflation 1058e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project // amount is also scaled by the zoomFactor. 106635860845790a19bf50bbc51ba8fb66a96dde068The Android Open Source Project virtual void inflateControlPaintRect(ControlPart, ControlStates, IntRect& /*zoomedRect*/, float /*zoomFactor*/) const { } 1078e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project 1088e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project // This method is called once, from RenderTheme::adjustDefaultStyleSheet(), to let each platform adjust 1090bf48ef3be53ddaa52bbead65dfd75bf90e7a2b5Ben Murdoch // the default CSS rules in html.css. 1108e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project static String defaultStyleSheet(); 1118e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project 1128e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Projectprivate: 1138e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project mutable Color m_activeSelectionColor; 1148e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project mutable Color m_inactiveSelectionColor; 1158e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project}; 1168e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project 1178e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project// Function to obtain the theme. This is implemented in the platform-specific subclasses. 1188e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source ProjectTheme* platformTheme(); 1198e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project 1208e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project} // namespace WebCore 1218e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project 1228e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project#endif // Theme_h 123