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 RenderObject::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 RenderObject::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 RenderObject::PaintInfo&, const IntRect&);
     79 
     80     virtual bool paintTextField(RenderObject*, const RenderObject::PaintInfo&, const IntRect&);
     81 
     82     virtual bool paintTextArea(RenderObject* o, const RenderObject::PaintInfo& i, const IntRect& r)
     83     { return paintTextField(o, i, r); }
     84 
     85     virtual void adjustMenuListStyle(CSSStyleSelector* selector, RenderStyle* style, Element* e) const;
     86     virtual bool paintMenuList(RenderObject*, const RenderObject::PaintInfo&, const IntRect&);
     87     virtual void adjustMenuListButtonStyle(CSSStyleSelector* selector, RenderStyle* style, Element* e) const;
     88 
     89     virtual bool paintMenuListButton(RenderObject*, const RenderObject::PaintInfo&, const IntRect&);
     90 
     91     virtual bool paintSliderTrack(RenderObject* o, const RenderObject::PaintInfo& i, const IntRect& r);
     92     virtual bool paintSliderThumb(RenderObject* o, const RenderObject::PaintInfo& i, const IntRect& r);
     93     virtual void adjustSliderThumbSize(RenderObject*) const;
     94 
     95     virtual bool popupOptionSupportsTextIndent() const { return true; }
     96 
     97     virtual int buttonInternalPaddingLeft() const;
     98     virtual int buttonInternalPaddingRight() const;
     99     virtual int buttonInternalPaddingTop() const;
    100     virtual int buttonInternalPaddingBottom() const;
    101 
    102     virtual void adjustSearchFieldStyle(CSSStyleSelector*, RenderStyle*, Element*) const;
    103     virtual bool paintSearchField(RenderObject*, const RenderObject::PaintInfo&, const IntRect&);
    104 
    105     virtual void adjustSearchFieldCancelButtonStyle(CSSStyleSelector*, RenderStyle*, Element*) const;
    106     virtual bool paintSearchFieldCancelButton(RenderObject*, const RenderObject::PaintInfo&, const IntRect&);
    107 
    108     virtual void adjustSearchFieldDecorationStyle(CSSStyleSelector*, RenderStyle*, Element*) const;
    109     virtual bool paintSearchFieldDecoration(RenderObject*, const RenderObject::PaintInfo&, const IntRect&) { return false; }
    110 
    111     virtual void adjustSearchFieldResultsDecorationStyle(CSSStyleSelector*, RenderStyle*, Element*) const;
    112     virtual bool paintSearchFieldResultsDecoration(RenderObject*, const RenderObject::PaintInfo&, const IntRect&);
    113 
    114     virtual void adjustSearchFieldResultsButtonStyle(CSSStyleSelector*, RenderStyle*, Element*) const;
    115     virtual bool paintSearchFieldResultsButton(RenderObject*, const RenderObject::PaintInfo&, const IntRect&);
    116 
    117     virtual void themeChanged();
    118 
    119     virtual void adjustButtonStyle(CSSStyleSelector*, RenderStyle* style, Element*) const {}
    120     virtual void adjustTextFieldStyle(CSSStyleSelector*, RenderStyle* style, Element*) const {}
    121     virtual void adjustTextAreaStyle(CSSStyleSelector*, RenderStyle* style, Element*) const {}
    122 
    123     static void setWebKitIsBeingUnloaded();
    124 
    125     virtual bool supportsFocusRing(const RenderStyle*) const;
    126 
    127 #if ENABLE(VIDEO)
    128     virtual bool shouldRenderMediaControlPart(ControlPart, Element*);
    129     virtual bool paintMediaFullscreenButton(RenderObject*, const RenderObject::PaintInfo&, const IntRect&);
    130     virtual bool paintMediaPlayButton(RenderObject*, const RenderObject::PaintInfo&, const IntRect&);
    131     virtual bool paintMediaMuteButton(RenderObject*, const RenderObject::PaintInfo&, const IntRect&);
    132     virtual bool paintMediaSeekBackButton(RenderObject*, const RenderObject::PaintInfo&, const IntRect&);
    133     virtual bool paintMediaSeekForwardButton(RenderObject*, const RenderObject::PaintInfo&, const IntRect&);
    134     virtual bool paintMediaSliderTrack(RenderObject*, const RenderObject::PaintInfo&, const IntRect&);
    135     virtual bool paintMediaSliderThumb(RenderObject*, const RenderObject::PaintInfo&, const IntRect&);
    136     virtual bool paintMediaToggleClosedCaptionsButton(RenderObject*, const RenderObject::PaintInfo&, const IntRect&);
    137 #endif
    138 
    139 private:
    140     RenderThemeWin();
    141     ~RenderThemeWin();
    142 
    143     void addIntrinsicMargins(RenderStyle*) const;
    144     void close();
    145 
    146     unsigned determineState(RenderObject*);
    147     unsigned determineClassicState(RenderObject*);
    148     unsigned determineSliderThumbState(RenderObject*);
    149     unsigned determineButtonState(RenderObject*);
    150 
    151     bool supportsFocus(ControlPart) const;
    152 
    153     ThemeData getThemeData(RenderObject*);
    154     ThemeData getClassicThemeData(RenderObject* o);
    155 
    156     HANDLE buttonTheme() const;
    157     HANDLE textFieldTheme() const;
    158     HANDLE menuListTheme() const;
    159     HANDLE sliderTheme() const;
    160 
    161     mutable HANDLE m_buttonTheme;
    162     mutable HANDLE m_textFieldTheme;
    163     mutable HANDLE m_menuListTheme;
    164     mutable HANDLE m_sliderTheme;
    165 };
    166 
    167 };
    168 
    169 #endif
    170