Home | History | Annotate | Download | only in rendering
      1 /*
      2  * This file is part of the WebKit project.
      3  *
      4  * Copyright (C) 2006, 2008 Apple Computer, Inc.
      5  * Copyright (C) 2009 Kenneth Rohde Christiansen
      6  *
      7  * This library is free software; you can redistribute it and/or
      8  * modify it under the terms of the GNU Library General Public
      9  * License as published by the Free Software Foundation; either
     10  * version 2 of the License, or (at your option) any later version.
     11  *
     12  * This library is distributed in the hope that it will be useful,
     13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
     14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
     15  * Library General Public License for more details.
     16  *
     17  * You should have received a copy of the GNU Library General Public License
     18  * along with this library; see the file COPYING.LIB.  If not, write to
     19  * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
     20  * Boston, MA 02110-1301, USA.
     21  *
     22  */
     23 
     24 #ifndef RenderThemeWin_h
     25 #define RenderThemeWin_h
     26 
     27 #include "RenderTheme.h"
     28 
     29 #if WIN32
     30 typedef void* HANDLE;
     31 typedef struct HINSTANCE__* HINSTANCE;
     32 typedef HINSTANCE HMODULE;
     33 #endif
     34 
     35 namespace WebCore {
     36 
     37 struct ThemeData {
     38     ThemeData() :m_part(0), m_state(0), m_classicState(0) {}
     39     ThemeData(int part, int state)
     40         : m_part(part)
     41         , m_state(state)
     42         , m_classicState(0)
     43     { }
     44 
     45     unsigned m_part;
     46     unsigned m_state;
     47     unsigned m_classicState;
     48 };
     49 
     50 class RenderThemeWin : public RenderTheme {
     51 public:
     52     static PassRefPtr<RenderTheme> create();
     53 
     54     virtual String extraDefaultStyleSheet();
     55     virtual String extraQuirksStyleSheet();
     56 
     57     // A method asking if the theme's controls actually care about redrawing when hovered.
     58     virtual bool supportsHover(const RenderStyle*) const;
     59 
     60     virtual Color platformActiveSelectionBackgroundColor() const;
     61     virtual Color platformInactiveSelectionBackgroundColor() const;
     62     virtual Color platformActiveSelectionForegroundColor() const;
     63     virtual Color platformInactiveSelectionForegroundColor() const;
     64 
     65     // System fonts.
     66     virtual void systemFont(int propId, FontDescription&) const;
     67     virtual Color systemColor(int cssValueId) const;
     68 
     69     virtual bool paintCheckbox(RenderObject* o, const PaintInfo& i, const IntRect& r)
     70     { return paintButton(o, i, r); }
     71     virtual void setCheckboxSize(RenderStyle*) const;
     72 
     73     virtual bool paintRadio(RenderObject* o, const PaintInfo& i, const IntRect& r)
     74     { return paintButton(o, i, r); }
     75     virtual void setRadioSize(RenderStyle* style) const
     76     { return setCheckboxSize(style); }
     77 
     78     virtual bool paintButton(RenderObject*, const PaintInfo&, const IntRect&);
     79 
     80     virtual void adjustInnerSpinButtonStyle(CSSStyleSelector*, RenderStyle*, Element*) const;
     81     virtual bool paintInnerSpinButton(RenderObject*, const PaintInfo&, const IntRect&);
     82 
     83     virtual bool paintTextField(RenderObject*, const PaintInfo&, const IntRect&);
     84 
     85     virtual bool paintTextArea(RenderObject* o, const PaintInfo& i, const IntRect& r)
     86     { return paintTextField(o, i, r); }
     87 
     88     virtual void adjustMenuListStyle(CSSStyleSelector* selector, RenderStyle* style, Element* e) const;
     89     virtual bool paintMenuList(RenderObject*, const PaintInfo&, const IntRect&);
     90     virtual void adjustMenuListButtonStyle(CSSStyleSelector* selector, RenderStyle* style, Element* e) const;
     91 
     92     virtual bool paintMenuListButton(RenderObject*, const PaintInfo&, const IntRect&);
     93 
     94     virtual bool paintSliderTrack(RenderObject* o, const PaintInfo& i, const IntRect& r);
     95     virtual bool paintSliderThumb(RenderObject* o, const PaintInfo& i, const IntRect& r);
     96     virtual void adjustSliderThumbSize(RenderObject*) const;
     97 
     98     virtual bool popupOptionSupportsTextIndent() const { return true; }
     99 
    100     virtual void adjustSearchFieldStyle(CSSStyleSelector*, RenderStyle*, Element*) const;
    101     virtual bool paintSearchField(RenderObject*, const PaintInfo&, const IntRect&);
    102 
    103     virtual void adjustSearchFieldCancelButtonStyle(CSSStyleSelector*, RenderStyle*, Element*) const;
    104     virtual bool paintSearchFieldCancelButton(RenderObject*, const PaintInfo&, const IntRect&);
    105 
    106     virtual void adjustSearchFieldDecorationStyle(CSSStyleSelector*, RenderStyle*, Element*) const;
    107     virtual bool paintSearchFieldDecoration(RenderObject*, const PaintInfo&, const IntRect&) { return false; }
    108 
    109     virtual void adjustSearchFieldResultsDecorationStyle(CSSStyleSelector*, RenderStyle*, Element*) const;
    110     virtual bool paintSearchFieldResultsDecoration(RenderObject*, const PaintInfo&, const IntRect&);
    111 
    112     virtual void adjustSearchFieldResultsButtonStyle(CSSStyleSelector*, RenderStyle*, Element*) const;
    113     virtual bool paintSearchFieldResultsButton(RenderObject*, const PaintInfo&, const IntRect&);
    114 
    115     virtual void themeChanged();
    116 
    117     virtual void adjustButtonStyle(CSSStyleSelector*, RenderStyle* style, Element*) const {}
    118     virtual void adjustTextFieldStyle(CSSStyleSelector*, RenderStyle* style, Element*) const {}
    119     virtual void adjustTextAreaStyle(CSSStyleSelector*, RenderStyle* style, Element*) const {}
    120 
    121     static void setWebKitIsBeingUnloaded();
    122 
    123     virtual bool supportsFocusRing(const RenderStyle*) const;
    124 
    125 #if ENABLE(VIDEO)
    126     virtual String extraMediaControlsStyleSheet();
    127     virtual bool supportsClosedCaptioning() const;
    128     virtual bool paintMediaControlsBackground(RenderObject*, const PaintInfo&, const IntRect&);
    129     virtual bool paintMediaFullscreenButton(RenderObject*, const PaintInfo&, const IntRect&);
    130     virtual bool paintMediaMuteButton(RenderObject*, const PaintInfo&, const IntRect&);
    131     virtual bool paintMediaPlayButton(RenderObject*, const PaintInfo&, const IntRect&);
    132     virtual bool paintMediaRewindButton(RenderObject*, const PaintInfo&, const IntRect&);
    133     virtual bool paintMediaSeekBackButton(RenderObject*, const PaintInfo&, const IntRect&);
    134     virtual bool paintMediaSeekForwardButton(RenderObject*, const PaintInfo&, const IntRect&);
    135     virtual bool paintMediaSliderTrack(RenderObject*, const PaintInfo&, const IntRect&);
    136     virtual bool paintMediaSliderThumb(RenderObject*, const PaintInfo&, const IntRect&);
    137     virtual bool paintMediaToggleClosedCaptionsButton(RenderObject*, const PaintInfo&, const IntRect&);
    138     virtual bool paintMediaVolumeSliderContainer(RenderObject*, const PaintInfo&, const IntRect&);
    139     virtual bool paintMediaVolumeSliderTrack(RenderObject*, const PaintInfo&, const IntRect&);
    140     virtual bool paintMediaVolumeSliderThumb(RenderObject*, const PaintInfo&, const IntRect&);
    141     virtual IntPoint volumeSliderOffsetFromMuteButton(RenderBox*, const IntSize&) const;
    142 #endif
    143 
    144 private:
    145     enum ControlSubPart {
    146         None,
    147         SpinButtonDown,
    148         SpinButtonUp,
    149     };
    150 
    151     RenderThemeWin();
    152     ~RenderThemeWin();
    153 
    154     void addIntrinsicMargins(RenderStyle*) const;
    155     void close();
    156 
    157     unsigned determineState(RenderObject*);
    158     unsigned determineClassicState(RenderObject*, ControlSubPart = None);
    159     unsigned determineSliderThumbState(RenderObject*);
    160     unsigned determineButtonState(RenderObject*);
    161     unsigned determineSpinButtonState(RenderObject*, ControlSubPart = None);
    162 
    163     bool supportsFocus(ControlPart) const;
    164 
    165     ThemeData getThemeData(RenderObject*, ControlSubPart = None);
    166     ThemeData getClassicThemeData(RenderObject* o, ControlSubPart = None);
    167 
    168     HANDLE buttonTheme() const;
    169     HANDLE textFieldTheme() const;
    170     HANDLE menuListTheme() const;
    171     HANDLE sliderTheme() const;
    172     HANDLE spinButtonTheme() const;
    173 
    174     mutable HANDLE m_buttonTheme;
    175     mutable HANDLE m_textFieldTheme;
    176     mutable HANDLE m_menuListTheme;
    177     mutable HANDLE m_sliderTheme;
    178     mutable HANDLE m_spinButtonTheme;
    179 };
    180 
    181 };
    182 
    183 #endif
    184