diff options
-rw-r--r-- | ui/gfx/native_theme.cc | 26 | ||||
-rw-r--r-- | ui/gfx/native_theme.h | 164 | ||||
-rw-r--r-- | ui/gfx/native_theme_win.cc | 310 | ||||
-rw-r--r-- | ui/gfx/native_theme_win.h | 192 | ||||
-rw-r--r-- | ui/ui_gfx.gypi | 2 |
5 files changed, 70 insertions, 624 deletions
diff --git a/ui/gfx/native_theme.cc b/ui/gfx/native_theme.cc deleted file mode 100644 index 331d429..0000000 --- a/ui/gfx/native_theme.cc +++ /dev/null @@ -1,26 +0,0 @@ -// Copyright (c) 2011 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#include "ui/gfx/native_theme.h" - -#include "ui/gfx/size.h" - -namespace gfx { - -unsigned int NativeTheme::thumb_inactive_color_ = 0xeaeaea; -unsigned int NativeTheme::thumb_active_color_ = 0xf4f4f4; -unsigned int NativeTheme::track_color_ = 0xd3d3d3; - -void NativeTheme::SetScrollbarColors(unsigned inactive_color, - unsigned active_color, - unsigned track_color) const { - thumb_inactive_color_ = inactive_color; - thumb_active_color_ = active_color; - track_color_ = track_color; -} - -// NativeTheme::instance() is implemented in the platform specific source files, -// such as native_theme_win.cc or native_theme_linux.cc - -} // namespace gfx diff --git a/ui/gfx/native_theme.h b/ui/gfx/native_theme.h deleted file mode 100644 index 807427d..0000000 --- a/ui/gfx/native_theme.h +++ /dev/null @@ -1,164 +0,0 @@ -// Copyright (c) 2011 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#ifndef UI_GFX_NATIVE_THEME_H_ -#define UI_GFX_NATIVE_THEME_H_ -#pragma once - -#include "skia/ext/platform_canvas.h" -#include "ui/gfx/native_widget_types.h" - -namespace skia { -class PlatformCanvas; -} - -namespace gfx { - -class Rect; -class Size; - -// This class supports drawing UI controls (like buttons, text fields, lists, -// comboboxes, etc) that look like the native UI controls of the underlying -// platform, such as Windows or Linux. -// -// The supported control types are listed in the Part enum. These parts can be -// in any state given by the State enum, where the actual definititon of the -// state is part-specific. -// -// Some parts require more information than simply the state in order to be -// drawn correctly, and this information is given to the Paint() method via the -// ExtraParams union. Each part that requires more information has its own -// field in the union. -// -// NativeTheme also supports getting the default size of a given part with -// the GetPartSize() method. -class NativeTheme { - public: - // The part to be painted / sized. - enum Part { - kScrollbarDownArrow, - kScrollbarLeftArrow, - kScrollbarRightArrow, - kScrollbarUpArrow, - kScrollbarHorizontalThumb, - kScrollbarVerticalThumb, - kScrollbarHorizontalTrack, - kScrollbarVerticalTrack, - kCheckbox, - kRadio, - kPushButton, - kTextField, - kMenuList, - kSliderTrack, - kSliderThumb, - kInnerSpinButton, - kProgressBar, - kMaxPart, - }; - - // The state of the part. - enum State { - kDisabled, - kHovered, - kNormal, - kPressed, - kMaxState, - }; - - // Each structure below hold extra information needed when painting a given - // part. - - struct ScrollbarTrackExtraParams { - int track_x; - int track_y; - int track_width; - int track_height; - }; - - struct ButtonExtraParams { - bool checked; - bool indeterminate; // Whether the button state is indeterminate. - bool is_default; // Whether the button is default button. - bool has_border; - int classic_state; // Used on Windows when uxtheme is not available. - SkColor background_color; - }; - - struct TextFieldExtraParams { - bool is_text_area; - bool is_listbox; - SkColor background_color; - }; - - struct MenuListExtraParams { - bool has_border; - bool has_border_radius; - int arrow_x; - int arrow_y; - SkColor background_color; - }; - - struct SliderExtraParams { - bool vertical; - bool in_drag; - }; - - struct InnerSpinButtonExtraParams { - bool spin_up; - bool read_only; - }; - - struct ProgressBarExtraParams { - bool determinate; - int value_rect_x; - int value_rect_y; - int value_rect_width; - int value_rect_height; - }; - - union ExtraParams { - ScrollbarTrackExtraParams scrollbar_track; - ButtonExtraParams button; - MenuListExtraParams menu_list; - SliderExtraParams slider; - TextFieldExtraParams text_field; - InnerSpinButtonExtraParams inner_spin; - ProgressBarExtraParams progress_bar; - }; - - // Return the size of the part. - virtual Size GetPartSize(Part part) const = 0; - - // Paint the part to the canvas. - virtual void Paint(skia::PlatformCanvas* canvas, - Part part, - State state, - const gfx::Rect& rect, - const ExtraParams& extra) const = 0; - - // Supports theme specific colors. - void SetScrollbarColors(unsigned inactive_color, - unsigned active_color, - unsigned track_color) const; - - // Returns a shared instance of the native theme. - // The retuned object should not be deleted by the caller. This function - // is not thread safe and should only be called from the UI thread. - static const NativeTheme* instance(); - - protected: - NativeTheme() {} - virtual ~NativeTheme() {} - - private: - static unsigned int thumb_inactive_color_; - static unsigned int thumb_active_color_; - static unsigned int track_color_; - - DISALLOW_COPY_AND_ASSIGN(NativeTheme); -}; - -} // namespace gfx - -#endif // UI_GFX_NATIVE_THEME_H_ diff --git a/ui/gfx/native_theme_win.cc b/ui/gfx/native_theme_win.cc index 83f339f..b22973c 100644 --- a/ui/gfx/native_theme_win.cc +++ b/ui/gfx/native_theme_win.cc @@ -54,12 +54,7 @@ void SetCheckerboardShader(SkPaint* paint, const RECT& align_rect) { namespace gfx { -// static -const NativeTheme* NativeTheme::instance() { - return NativeThemeWin::instance(); -} - -// static +/* static */ const NativeThemeWin* NativeThemeWin::instance() { // The global NativeThemeWin instance. static const NativeThemeWin s_native_theme; @@ -105,222 +100,10 @@ NativeThemeWin::NativeThemeWin() NativeThemeWin::~NativeThemeWin() { if (theme_dll_) { - CloseHandles(); - - draw_theme_ = NULL; - draw_theme_ex_ = NULL; - get_theme_color_ = NULL; - get_theme_content_rect_ = NULL; - get_theme_part_size_ = NULL; - open_theme_ = NULL; - close_theme_ = NULL; - set_theme_properties_ = NULL; - is_theme_active_ = NULL; - get_theme_int_ = NULL; + // todo (cpu): fix this soon. + // CloseHandles(); FreeLibrary(theme_dll_); - theme_dll_ = NULL; - } -} - -gfx::Size NativeThemeWin::GetPartSize(Part part) const { - HDC hdc = GetDC(NULL); - SIZE size; - HANDLE handle = GetThemeHandle(GetThemeName(part)); - int part_win = GetWindowsPart(part); - HRESULT hr = get_theme_part_size_(handle, hdc, part_win, 0, NULL, TS_TRUE, - &size); - ReleaseDC(NULL, hdc); - return SUCCEEDED(hr) ? Size(size.cx, size.cy) : Size(); -} - -void NativeThemeWin::Paint(skia::PlatformCanvas* canvas, - Part part, - State state, - const gfx::Rect& rect, - const ExtraParams& extra) const { - HDC hdc = canvas->beginPlatformPaint(); - - switch (part) { - case kCheckbox: - PaintCheckbox(hdc, part, state, rect, extra.button); - break; - case kRadio: - PaintRadioButton(hdc, part, state, rect, extra.button); - break; - case kPushButton: - PaintPushButton(hdc, part, state, rect, extra.button); - break; - case kScrollbarDownArrow: - case kScrollbarUpArrow: - case kScrollbarLeftArrow: - case kScrollbarRightArrow: - case kScrollbarHorizontalThumb: - case kScrollbarVerticalThumb: - case kScrollbarHorizontalTrack: - case kScrollbarVerticalTrack: - case kTextField: - case kMenuList: - case kSliderTrack: - case kSliderThumb: - case kInnerSpinButton: - case kProgressBar: - default: - // While transitioning NativeThemeWin to the single Paint() entry point, - // unsupported parts will DCHECK here. - DCHECK(false); - } - - canvas->endPlatformPaint(); -} - -HRESULT NativeThemeWin::PaintScrollbarArrow(HDC hdc, - Part direction, - State state, - const gfx::Rect& rect) const { - static int state_id[4][kMaxState] = { - ABS_DOWNDISABLED, ABS_DOWNHOT, ABS_DOWNNORMAL, ABS_DOWNPRESSED, - ABS_LEFTDISABLED, ABS_LEFTHOT, ABS_LEFTNORMAL, ABS_LEFTPRESSED, - ABS_RIGHTDISABLED, ABS_RIGHTHOT, ABS_RIGHTNORMAL, ABS_RIGHTPRESSED, - ABS_UPDISABLED, ABS_UPHOT, ABS_UPNORMAL, ABS_UPPRESSED - }; - - HANDLE handle = GetThemeHandle(SCROLLBAR); - if (handle && draw_theme_) { - int index = direction - kScrollbarDownArrow; - DCHECK(index >=0 && index < 4); - return draw_theme_(handle, hdc, SBP_ARROWBTN, state_id[index][state], - &rect.ToRECT(), NULL); - } - - // TODO: Draw it manually. - RECT rect_win = rect.ToRECT(); - DrawFrameControl(hdc, &rect_win, DFC_SCROLL, 0); - return S_OK; -} - -HRESULT NativeThemeWin::PaintScrollbarThumb(HDC hdc, - Part part, - State state, - const gfx::Rect& rect) const { - int part_id; - if (part == kScrollbarHorizontalThumb) { - part_id = SBP_THUMBBTNHORZ; - } else if (part == kScrollbarHorizontalThumb) { - part_id = SBP_THUMBBTNVERT; - } else { - DCHECK(false); - } - - static int state_id[kMaxState] = { - SCRBS_DISABLED, SCRBS_HOT, SCRBS_NORMAL, SCRBS_PRESSED - }; - - HANDLE handle = GetThemeHandle(SCROLLBAR); - if (handle && draw_theme_) { - return draw_theme_(handle, hdc, part_id, state_id[state], - &rect.ToRECT(), NULL); - } - - - // TODO: Draw it manually. - if ((part_id == SBP_THUMBBTNHORZ) || (part_id == SBP_THUMBBTNVERT)) { - RECT rect_win = rect.ToRECT(); - DrawEdge(hdc, &rect_win, EDGE_RAISED, BF_RECT | BF_MIDDLE); - // Classic mode doesn't have a gripper. - } - return S_OK; -} - -HRESULT NativeThemeWin::PaintPushButton(HDC hdc, - Part part, - State state, - const gfx::Rect& rect, - const ButtonExtraParams& extra) const { - int state_id; - switch(state) { - case kDisabled: - state_id = PBS_DISABLED; - break; - case kHovered: - state_id = PBS_HOT; - break; - case kNormal: - state_id = extra.is_default ? PBS_DEFAULTED : PBS_NORMAL; - break; - case kPressed: - state_id = PBS_PRESSED; - break; - default: - DCHECK(false); - } - - RECT rect_win = rect.ToRECT(); - return PaintButton(hdc, BP_PUSHBUTTON, state_id, extra.classic_state, - &rect_win); -} - -HRESULT NativeThemeWin::PaintRadioButton(HDC hdc, - Part part, - State state, - const gfx::Rect& rect, - const ButtonExtraParams& extra) const { - int state_id; - switch(state) { - case kDisabled: - state_id = extra.checked ? RBS_CHECKEDDISABLED : RBS_UNCHECKEDDISABLED; - break; - case kHovered: - state_id = extra.checked ? RBS_CHECKEDHOT : RBS_UNCHECKEDHOT; - break; - case kNormal: - state_id = extra.checked ? RBS_CHECKEDNORMAL : RBS_UNCHECKEDNORMAL; - break; - case kPressed: - state_id = extra.checked ? RBS_CHECKEDPRESSED : RBS_UNCHECKEDPRESSED; - break; - default: - DCHECK(false); } - - RECT rect_win = rect.ToRECT(); - return PaintButton(hdc, BP_RADIOBUTTON, state_id, extra.classic_state, - &rect_win); -} - -HRESULT NativeThemeWin::PaintCheckbox(HDC hdc, - Part part, - State state, - const gfx::Rect& rect, - const ButtonExtraParams& extra) const { - int state_id; - switch(state) { - case kDisabled: - state_id = extra.checked ? CBS_CHECKEDDISABLED : - extra.indeterminate ? CBS_MIXEDDISABLED : - CBS_UNCHECKEDDISABLED; - break; - case kHovered: - state_id = extra.checked ? CBS_CHECKEDHOT : - extra.indeterminate ? CBS_MIXEDHOT : - CBS_UNCHECKEDHOT; - break; - case kNormal: - state_id = extra.checked ? CBS_CHECKEDNORMAL : - extra.indeterminate ? CBS_MIXEDNORMAL : - CBS_UNCHECKEDNORMAL; - break; - case kPressed: - state_id = extra.checked ? CBS_CHECKEDPRESSED : - extra.indeterminate ? CBS_MIXEDPRESSED : - CBS_UNCHECKEDPRESSED; - break; - default: - DCHECK(false); - } - - RECT rect_win = rect.ToRECT(); - return PaintButton(hdc, BP_CHECKBOX, state_id, extra.classic_state, - &rect_win); } HRESULT NativeThemeWin::PaintButton(HDC hdc, @@ -1015,15 +798,15 @@ HRESULT NativeThemeWin::PaintFrameControl(HDC hdc, return S_OK; } -void NativeThemeWin::CloseHandles() const { +void NativeThemeWin::CloseHandles() const +{ if (!close_theme_) return; for (int i = 0; i < LAST; ++i) { - if (theme_handles_[i]) { + if (theme_handles_[i]) close_theme_(theme_handles_[i]); theme_handles_[i] = NULL; - } } } @@ -1034,7 +817,8 @@ bool NativeThemeWin::IsClassicTheme(ThemeName name) const { return !GetThemeHandle(name); } -HANDLE NativeThemeWin::GetThemeHandle(ThemeName theme_name) const { +HANDLE NativeThemeWin::GetThemeHandle(ThemeName theme_name) const +{ if (!open_theme_ || theme_name < 0 || theme_name >= LAST) return 0; @@ -1087,82 +871,4 @@ HANDLE NativeThemeWin::GetThemeHandle(ThemeName theme_name) const { return handle; } -// static -NativeThemeWin::ThemeName NativeThemeWin::GetThemeName(Part part) { - ThemeName name; - switch(part) { - case kScrollbarDownArrow: - case kScrollbarLeftArrow: - case kScrollbarRightArrow: - case kScrollbarUpArrow: - case kScrollbarHorizontalThumb: - case kScrollbarVerticalThumb: - case kScrollbarHorizontalTrack: - case kScrollbarVerticalTrack: - name = SCROLLBAR; - break; - case kCheckbox: - case kRadio: - case kPushButton: - name = BUTTON; - break; - case kTextField: - name = TEXTFIELD; - break; - case kMenuList: - name = MENU; - break; - case kSliderTrack: - case kSliderThumb: - name = TRACKBAR; - break; - case kInnerSpinButton: - name = SPIN; - break; - case kProgressBar: - name = PROGRESS; - break; - default: - DCHECK(false); - break; - } - return name; -} - -// static -int NativeThemeWin::GetWindowsPart(Part part) { - int part_id; - switch(part) { - case kCheckbox: - part_id = BP_CHECKBOX; - break; - case kRadio: - part_id = BP_RADIOBUTTON; - break; - case kPushButton: - part_id = BP_PUSHBUTTON; - break; - case kTextField: - case kMenuList: - case kSliderTrack: - case kSliderThumb: - case kInnerSpinButton: - case kProgressBar: - case kScrollbarDownArrow: - case kScrollbarLeftArrow: - case kScrollbarRightArrow: - case kScrollbarUpArrow: - case kScrollbarHorizontalThumb: - case kScrollbarVerticalThumb: - case kScrollbarHorizontalTrack: - case kScrollbarVerticalTrack: - default: - // While transitioning NativeThemeWin to the single Paint() entry point, - // unsupported parts will DCHECK here. - DCHECK(false); - break; - } - return part_id; -} - } // namespace gfx diff --git a/ui/gfx/native_theme_win.h b/ui/gfx/native_theme_win.h index 364e29c..e1749c0 100644 --- a/ui/gfx/native_theme_win.h +++ b/ui/gfx/native_theme_win.h @@ -1,4 +1,4 @@ -// Copyright (c) 2011 The Chromium Authors. All rights reserved. +// Copyright (c) 2010 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. // @@ -12,7 +12,6 @@ #define UI_GFX_NATIVE_THEME_WIN_H_ #pragma once -#include "ui/gfx/native_theme.h" #include "ui/gfx/size.h" #include <windows.h> #include <uxtheme.h> @@ -25,13 +24,14 @@ class PlatformCanvas; namespace gfx { -// Windows implementation of native theme class. -// -// At the moment, this class in in transition from an older API that consists -// of several PaintXXX methods to an API, inherited from the NativeTheme base -// class, that consists of a single Paint() method with a argument to indicate -// what kind of part to paint. -class NativeThemeWin : public NativeTheme { +// TODO: Define class member enums to replace part_id and state_id parameters +// that are currently defined in <vssym32.h>. Afterward, classic_state should +// be removed and class users wouldn't need to include <vssym32.h> anymore. +// This would enable HOT state on non-themed UI (like when RDP'ing) and would +// simplify usage. +// TODO: This class should probably be changed to be platform independent at +// the same time. +class NativeThemeWin { public: enum ThemeName { BUTTON, @@ -49,63 +49,6 @@ class NativeThemeWin : public NativeTheme { LAST }; - bool IsThemingActive() const; - - HRESULT GetThemePartSize(ThemeName themeName, - HDC hdc, - int part_id, - int state_id, - RECT* rect, - int ts, - SIZE* size) const; - - HRESULT GetThemeColor(ThemeName theme, - int part_id, - int state_id, - int prop_id, - SkColor* color) const; - - // Get the theme color if theming is enabled. If theming is unsupported - // for this part, use Win32's GetSysColor to find the color specified - // by default_sys_color. - SkColor GetThemeColorWithDefault(ThemeName theme, - int part_id, - int state_id, - int prop_id, - int default_sys_color) const; - - HRESULT GetThemeInt(ThemeName theme, - int part_id, - int state_id, - int prop_id, - int *result) const; - - // Get the thickness of the border associated with the specified theme, - // defaulting to GetSystemMetrics edge size if themes are disabled. - // In Classic Windows, borders are typically 2px; on XP+, they are 1px. - Size GetThemeBorderSize(ThemeName theme) const; - - // Disables all theming for top-level windows in the entire process, from - // when this method is called until the process exits. All the other - // methods in this class will continue to work, but their output will ignore - // the user's theme. This is meant for use when running tests that require - // consistent visual results. - void DisableTheming() const; - - // Closes cached theme handles so we can unload the DLL or update our UI - // for a theme change. - void CloseHandles() const; - - // Returns true if classic theme is in use. - bool IsClassicTheme(ThemeName name) const; - - // Gets our singleton instance. - static const NativeThemeWin* instance(); - - // The PaintXXX methods below this point should be private or be deleted, - // but remain public while NativeThemeWin is transitioned over to use the - // single Paint() entry point. Do not make new calls to these methods. - // This enumeration is used within PaintMenuArrow in order to indicate the // direction the menu arrow should point to. enum MenuArrowDirection { @@ -161,20 +104,16 @@ class NativeThemeWin : public NativeTheme { int prop_id, int *value); - // This method is deprecated and will be removed in the near future. HRESULT PaintButton(HDC hdc, int part_id, int state_id, int classic_state, RECT* rect) const; - // This method is deprecated and will be removed in the near future. HRESULT PaintDialogBackground(HDC dc, bool active, RECT* rect) const; - // This method is deprecated and will be removed in the near future. HRESULT PaintListBackground(HDC dc, bool enabled, RECT* rect) const; - // This method is deprecated and will be removed in the near future. // |arrow_direction| determines whether the arrow is pointing to the left or // to the right. In RTL locales, sub-menus open from right to left and // therefore the menu arrow should point to the left and not to the right. @@ -186,14 +125,12 @@ class NativeThemeWin : public NativeTheme { MenuArrowDirection arrow_direction, ControlState state) const; - // This method is deprecated and will be removed in the near future. HRESULT PaintMenuBackground(ThemeName theme, HDC hdc, int part_id, int state_id, RECT* rect) const; - // This method is deprecated and will be removed in the near future. HRESULT PaintMenuCheck(ThemeName theme, HDC hdc, int part_id, @@ -201,20 +138,17 @@ class NativeThemeWin : public NativeTheme { RECT* rect, ControlState state) const; - // This method is deprecated and will be removed in the near future. HRESULT PaintMenuCheckBackground(ThemeName theme, HDC hdc, int part_id, int state_id, RECT* rect) const; - // This method is deprecated and will be removed in the near future. HRESULT PaintMenuGutter(HDC hdc, int part_id, int state_id, RECT* rect) const; - // This method is deprecated and will be removed in the near future. HRESULT PaintMenuItemBackground(ThemeName theme, HDC hdc, int part_id, @@ -222,20 +156,17 @@ class NativeThemeWin : public NativeTheme { bool selected, RECT* rect) const; - // This method is deprecated and will be removed in the near future. HRESULT PaintMenuList(HDC hdc, int part_id, int state_id, int classic_state, RECT* rect) const; - // This method is deprecated and will be removed in the near future. HRESULT PaintMenuSeparator(HDC hdc, int part_id, int state_id, RECT* rect) const; - // This method is deprecated and will be removed in the near future. // Paints a scrollbar arrow. |classic_state| should have the appropriate // classic part number ORed in already. HRESULT PaintScrollbarArrow(HDC hdc, @@ -243,7 +174,6 @@ class NativeThemeWin : public NativeTheme { int classic_state, RECT* rect) const; - // This method is deprecated and will be removed in the near future. // Paints a scrollbar track section. |align_rect| is only used in classic // mode, and makes sure the checkerboard pattern in |target_rect| is aligned // with one presumed to be in |align_rect|. @@ -255,7 +185,6 @@ class NativeThemeWin : public NativeTheme { RECT* align_rect, skia::PlatformCanvas* canvas) const; - // This method is deprecated and will be removed in the near future. // Paints a scrollbar thumb or gripper. HRESULT PaintScrollbarThumb(HDC hdc, int part_id, @@ -263,24 +192,20 @@ class NativeThemeWin : public NativeTheme { int classic_state, RECT* rect) const; - // This method is deprecated and will be removed in the near future. HRESULT PaintSpinButton(HDC hdc, int part_id, int state_id, int classic_state, RECT* rect) const; - // This method is deprecated and will be removed in the near future. HRESULT PaintStatusGripper(HDC hdc, int part_id, int state_id, int classic_state, RECT* rect) const; - // This method is deprecated and will be removed in the near future. HRESULT PaintTabPanelBackground(HDC dc, RECT* rect) const; - // This method is deprecated and will be removed in the near future. HRESULT PaintTextField(HDC hdc, int part_id, int state_id, @@ -290,7 +215,6 @@ class NativeThemeWin : public NativeTheme { bool fill_content_area, bool draw_edges) const; - // This method is deprecated and will be removed in the near future. HRESULT PaintTrackbar(HDC hdc, int part_id, int state_id, @@ -298,7 +222,6 @@ class NativeThemeWin : public NativeTheme { RECT* rect, skia::PlatformCanvas* canvas) const; - // This method is deprecated and will be removed in the near future. HRESULT PaintProgressBar(HDC hdc, RECT* bar_rect, RECT* value_rect, @@ -306,53 +229,62 @@ class NativeThemeWin : public NativeTheme { double animated_seconds, skia::PlatformCanvas* canvas) const; - private: - NativeThemeWin(); - ~NativeThemeWin(); + bool IsThemingActive() const; - // NativeTheme Implementation: - virtual gfx::Size GetPartSize(Part part) const; - virtual void Paint(skia::PlatformCanvas* canvas, - Part part, - State state, - const gfx::Rect& rect, - const ExtraParams& extra) const; + HRESULT GetThemePartSize(ThemeName themeName, + HDC hdc, + int part_id, + int state_id, + RECT* rect, + int ts, + SIZE* size) const; - // Paints a scrollbar arrow. |classic_state| should have the appropriate - // classic part number ORed in already. - HRESULT PaintScrollbarArrow(HDC hdc, - Part direction, - State state, - const gfx::Rect& rect) const; + HRESULT GetThemeColor(ThemeName theme, + int part_id, + int state_id, + int prop_id, + SkColor* color) const; - HRESULT PaintScrollbarThumb(HDC hdc, - Part direction, - State state, - const gfx::Rect& rect) const; - - HRESULT PaintPushButton(HDC hdc, - Part part, - State state, - const gfx::Rect& rect, - const ButtonExtraParams& extra) const; - - HRESULT PaintRadioButton(HDC hdc, - Part part, - State state, - const gfx::Rect& rect, - const ButtonExtraParams& extra) const; - - HRESULT PaintCheckbox(HDC hdc, - Part part, - State state, - const gfx::Rect& rect, - const ButtonExtraParams& extra) const; - - // Get the windows theme name that goes with the part. - static ThemeName GetThemeName(Part part); - - // Get the windows theme part id that goes with the part. - static int GetWindowsPart(Part part); + // Get the theme color if theming is enabled. If theming is unsupported + // for this part, use Win32's GetSysColor to find the color specified + // by default_sys_color. + SkColor GetThemeColorWithDefault(ThemeName theme, + int part_id, + int state_id, + int prop_id, + int default_sys_color) const; + + HRESULT GetThemeInt(ThemeName theme, + int part_id, + int state_id, + int prop_id, + int *result) const; + + // Get the thickness of the border associated with the specified theme, + // defaulting to GetSystemMetrics edge size if themes are disabled. + // In Classic Windows, borders are typically 2px; on XP+, they are 1px. + Size GetThemeBorderSize(ThemeName theme) const; + + // Disables all theming for top-level windows in the entire process, from + // when this method is called until the process exits. All the other + // methods in this class will continue to work, but their output will ignore + // the user's theme. This is meant for use when running tests that require + // consistent visual results. + void DisableTheming() const; + + // Closes cached theme handles so we can unload the DLL or update our UI + // for a theme change. + void CloseHandles() const; + + // Returns true if classic theme is in use. + bool IsClassicTheme(ThemeName name) const; + + // Gets our singleton instance. + static const NativeThemeWin* instance(); + + private: + NativeThemeWin(); + ~NativeThemeWin(); HRESULT PaintFrameControl(HDC hdc, RECT* rect, diff --git a/ui/ui_gfx.gypi b/ui/ui_gfx.gypi index 78303a6..9fbc83d 100644 --- a/ui/ui_gfx.gypi +++ b/ui/ui_gfx.gypi @@ -79,8 +79,6 @@ 'gfx/image_mac.mm', 'gfx/insets.cc', 'gfx/insets.h', - 'gfx/native_theme.cc', - 'gfx/native_theme.h', 'gfx/native_widget_types.h', 'gfx/path.cc', 'gfx/path.h', |