RenderThemeWin.h 8.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197
  1. /*
  2. * This file is part of the WebKit project.
  3. *
  4. * Copyright (C) 2006, 2008, 2013 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. #ifndef RenderThemeWin_h
  24. #define RenderThemeWin_h
  25. #include "RenderTheme.h"
  26. #if WIN32
  27. typedef void* HANDLE;
  28. typedef struct HINSTANCE__* HINSTANCE;
  29. typedef HINSTANCE HMODULE;
  30. #endif
  31. namespace WebCore {
  32. struct ThemeData {
  33. ThemeData() :m_part(0), m_state(0), m_classicState(0) {}
  34. ThemeData(int part, int state)
  35. : m_part(part)
  36. , m_state(state)
  37. , m_classicState(0)
  38. { }
  39. unsigned m_part;
  40. unsigned m_state;
  41. unsigned m_classicState;
  42. };
  43. class RenderThemeWin : public RenderTheme {
  44. public:
  45. static PassRefPtr<RenderTheme> create();
  46. virtual String extraDefaultStyleSheet();
  47. virtual String extraQuirksStyleSheet();
  48. // A method asking if the theme's controls actually care about redrawing when hovered.
  49. virtual bool supportsHover(const RenderStyle*) const;
  50. virtual Color platformActiveSelectionBackgroundColor() const;
  51. virtual Color platformInactiveSelectionBackgroundColor() const;
  52. virtual Color platformActiveSelectionForegroundColor() const;
  53. virtual Color platformInactiveSelectionForegroundColor() const;
  54. // System fonts.
  55. virtual void systemFont(int propId, FontDescription&) const;
  56. virtual Color systemColor(int cssValueId) const;
  57. virtual bool paintCheckbox(RenderObject* o, const PaintInfo& i, const IntRect& r)
  58. { return paintButton(o, i, r); }
  59. virtual void setCheckboxSize(RenderStyle*) const;
  60. virtual bool paintRadio(RenderObject* o, const PaintInfo& i, const IntRect& r)
  61. { return paintButton(o, i, r); }
  62. virtual void setRadioSize(RenderStyle* style) const
  63. { return setCheckboxSize(style); }
  64. virtual bool paintButton(RenderObject*, const PaintInfo&, const IntRect&);
  65. virtual void adjustInnerSpinButtonStyle(StyleResolver*, RenderStyle*, Element*) const;
  66. virtual bool paintInnerSpinButton(RenderObject*, const PaintInfo&, const IntRect&);
  67. virtual bool paintTextField(RenderObject*, const PaintInfo&, const IntRect&);
  68. virtual bool paintTextArea(RenderObject* o, const PaintInfo& i, const IntRect& r)
  69. { return paintTextField(o, i, r); }
  70. virtual void adjustMenuListStyle(StyleResolver*, RenderStyle*, Element*) const;
  71. virtual bool paintMenuList(RenderObject*, const PaintInfo&, const IntRect&);
  72. virtual void adjustMenuListButtonStyle(StyleResolver*, RenderStyle*, Element*) const;
  73. virtual bool paintMenuListButton(RenderObject*, const PaintInfo&, const IntRect&);
  74. virtual bool paintSliderTrack(RenderObject* o, const PaintInfo& i, const IntRect& r);
  75. virtual bool paintSliderThumb(RenderObject* o, const PaintInfo& i, const IntRect& r);
  76. virtual void adjustSliderThumbSize(RenderStyle*, Element*) const;
  77. virtual bool popupOptionSupportsTextIndent() const { return true; }
  78. virtual void adjustSearchFieldStyle(StyleResolver*, RenderStyle*, Element*) const;
  79. virtual bool paintSearchField(RenderObject*, const PaintInfo&, const IntRect&);
  80. virtual void adjustSearchFieldCancelButtonStyle(StyleResolver*, RenderStyle*, Element*) const;
  81. virtual bool paintSearchFieldCancelButton(RenderObject*, const PaintInfo&, const IntRect&);
  82. virtual void adjustSearchFieldDecorationStyle(StyleResolver*, RenderStyle*, Element*) const;
  83. virtual bool paintSearchFieldDecoration(RenderObject*, const PaintInfo&, const IntRect&) { return false; }
  84. virtual void adjustSearchFieldResultsDecorationStyle(StyleResolver*, RenderStyle*, Element*) const;
  85. virtual bool paintSearchFieldResultsDecoration(RenderObject*, const PaintInfo&, const IntRect&);
  86. virtual void adjustSearchFieldResultsButtonStyle(StyleResolver*, RenderStyle*, Element*) const;
  87. virtual bool paintSearchFieldResultsButton(RenderObject*, const PaintInfo&, const IntRect&);
  88. virtual void themeChanged();
  89. virtual void adjustButtonStyle(StyleResolver*, RenderStyle* style, Element*) const { }
  90. virtual void adjustTextFieldStyle(StyleResolver*, RenderStyle* style, Element*) const { }
  91. virtual void adjustTextAreaStyle(StyleResolver*, RenderStyle* style, Element*) const { }
  92. static void setWebKitIsBeingUnloaded();
  93. virtual bool supportsFocusRing(const RenderStyle*) const;
  94. #if ENABLE(VIDEO)
  95. virtual String extraMediaControlsStyleSheet();
  96. #if ENABLE(FULLSCREEN_API)
  97. virtual String extraFullScreenStyleSheet();
  98. #endif
  99. virtual bool supportsClosedCaptioning() const;
  100. virtual bool paintMediaControlsBackground(RenderObject*, const PaintInfo&, const IntRect&);
  101. virtual bool paintMediaFullscreenButton(RenderObject*, const PaintInfo&, const IntRect&);
  102. virtual bool paintMediaMuteButton(RenderObject*, const PaintInfo&, const IntRect&);
  103. virtual bool paintMediaPlayButton(RenderObject*, const PaintInfo&, const IntRect&);
  104. virtual bool paintMediaRewindButton(RenderObject*, const PaintInfo&, const IntRect&);
  105. virtual bool paintMediaSeekBackButton(RenderObject*, const PaintInfo&, const IntRect&);
  106. virtual bool paintMediaSeekForwardButton(RenderObject*, const PaintInfo&, const IntRect&);
  107. virtual bool paintMediaSliderTrack(RenderObject*, const PaintInfo&, const IntRect&);
  108. virtual bool paintMediaSliderThumb(RenderObject*, const PaintInfo&, const IntRect&);
  109. virtual bool paintMediaVolumeSliderContainer(RenderObject*, const PaintInfo&, const IntRect&);
  110. virtual bool paintMediaVolumeSliderTrack(RenderObject*, const PaintInfo&, const IntRect&);
  111. virtual bool paintMediaVolumeSliderThumb(RenderObject*, const PaintInfo&, const IntRect&);
  112. virtual IntPoint volumeSliderOffsetFromMuteButton(RenderBox*, const IntSize&) const OVERRIDE;
  113. #endif
  114. #if ENABLE(METER_ELEMENT)
  115. virtual IntSize meterSizeForBounds(const RenderMeter*, const IntRect&) const OVERRIDE;
  116. virtual bool supportsMeter(ControlPart) const OVERRIDE;
  117. virtual void adjustMeterStyle(StyleResolver*, RenderStyle*, Element*) const OVERRIDE;
  118. virtual bool paintMeter(RenderObject*, const PaintInfo&, const IntRect&) OVERRIDE;
  119. #endif
  120. virtual bool shouldShowPlaceholderWhenFocused() const { return true; }
  121. private:
  122. enum ControlSubPart {
  123. None,
  124. SpinButtonDown,
  125. SpinButtonUp,
  126. };
  127. RenderThemeWin();
  128. virtual ~RenderThemeWin();
  129. void addIntrinsicMargins(RenderStyle*) const;
  130. void close();
  131. unsigned determineState(RenderObject*);
  132. unsigned determineClassicState(RenderObject*, ControlSubPart = None);
  133. unsigned determineSliderThumbState(RenderObject*);
  134. unsigned determineButtonState(RenderObject*);
  135. unsigned determineSpinButtonState(RenderObject*, ControlSubPart = None);
  136. bool supportsFocus(ControlPart) const;
  137. ThemeData getThemeData(RenderObject*, ControlSubPart = None);
  138. ThemeData getClassicThemeData(RenderObject* o, ControlSubPart = None);
  139. HANDLE buttonTheme() const;
  140. HANDLE textFieldTheme() const;
  141. HANDLE menuListTheme() const;
  142. HANDLE sliderTheme() const;
  143. HANDLE spinButtonTheme() const;
  144. HANDLE progressBarTheme() const;
  145. mutable HANDLE m_buttonTheme;
  146. mutable HANDLE m_textFieldTheme;
  147. mutable HANDLE m_menuListTheme;
  148. mutable HANDLE m_sliderTheme;
  149. mutable HANDLE m_spinButtonTheme;
  150. mutable HANDLE m_progressBarTheme;
  151. };
  152. };
  153. #endif