diff options
author | sky@chromium.org <sky@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-07-07 16:19:16 +0000 |
---|---|---|
committer | sky@chromium.org <sky@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-07-07 16:19:16 +0000 |
commit | 0e76c9c9a560fd966c8f06719331179502a350ce (patch) | |
tree | 3e0a5ffea043d7c3af88468180cef1ebad7af336 | |
parent | 18e093c1e4b8c875ff3f7332479b21f2eb466b95 (diff) | |
download | chromium_src-0e76c9c9a560fd966c8f06719331179502a350ce.zip chromium_src-0e76c9c9a560fd966c8f06719331179502a350ce.tar.gz chromium_src-0e76c9c9a560fd966c8f06719331179502a350ce.tar.bz2 |
Makes menu draw disabled arrow the correct color for classic windows.
BUG=48099
TEST=see bug
Review URL: http://codereview.chromium.org/2835033
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@51721 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r-- | gfx/native_theme_win.cc | 40 | ||||
-rw-r--r-- | gfx/native_theme_win.h | 12 | ||||
-rw-r--r-- | views/controls/menu/menu_item_view.h | 6 | ||||
-rw-r--r-- | views/controls/menu/menu_item_view_win.cc | 19 |
4 files changed, 56 insertions, 21 deletions
diff --git a/gfx/native_theme_win.cc b/gfx/native_theme_win.cc index 57a5c2f..5123739 100644 --- a/gfx/native_theme_win.cc +++ b/gfx/native_theme_win.cc @@ -177,7 +177,7 @@ HRESULT NativeTheme::PaintMenuArrow(ThemeName theme, int state_id, RECT* rect, MenuArrowDirection arrow_direction, - bool is_highlighted) const { + ControlState control_state) const { HANDLE handle = GetThemeHandle(MENU); if (handle && draw_theme_) { if (arrow_direction == RIGHT_POINTING_ARROW) { @@ -216,7 +216,7 @@ HRESULT NativeTheme::PaintMenuArrow(ThemeName theme, state = DFCS_MENUARROW; else state = DFCS_MENUARROWRIGHT; - return PaintFrameControl(hdc, rect, DFC_MENU, state, is_highlighted); + return PaintFrameControl(hdc, rect, DFC_MENU, state, control_state); } HRESULT NativeTheme::PaintMenuBackground(ThemeName theme, @@ -253,12 +253,12 @@ HRESULT NativeTheme::PaintMenuCheck(ThemeName theme, int part_id, int state_id, RECT* rect, - bool is_highlighted) const { + ControlState control_state) const { HANDLE handle = GetThemeHandle(MENU); if (handle && draw_theme_) { return draw_theme_(handle, hdc, part_id, state_id, rect, NULL); } - return PaintFrameControl(hdc, rect, DFC_MENU, DFCS_MENUCHECK, is_highlighted); + return PaintFrameControl(hdc, rect, DFC_MENU, DFCS_MENUCHECK, control_state); } HRESULT NativeTheme::PaintMenuGutter(HDC hdc, @@ -687,7 +687,7 @@ HRESULT NativeTheme::PaintFrameControl(HDC hdc, RECT* rect, UINT type, UINT state, - bool is_highlighted) const { + ControlState control_state) const { const int width = rect->right - rect->left; const int height = rect->bottom - rect->top; @@ -706,13 +706,29 @@ HRESULT NativeTheme::PaintFrameControl(HDC hdc, // dc's text color for the black bits in the mask, and the dest dc's // background color for the white bits in the mask. DrawFrameControl draws the // check in black, and the background in white. - COLORREF old_bg_color = - SetBkColor(hdc, - GetSysColor(is_highlighted ? COLOR_HIGHLIGHT : COLOR_MENU)); - COLORREF old_text_color = - SetTextColor(hdc, - GetSysColor(is_highlighted ? COLOR_HIGHLIGHTTEXT : - COLOR_MENUTEXT)); + int bg_color_key; + int text_color_key; + switch (control_state) { + case CONTROL_HIGHLIGHTED: + bg_color_key = COLOR_HIGHLIGHT; + text_color_key = COLOR_HIGHLIGHTTEXT; + break; + case CONTROL_NORMAL: + bg_color_key = COLOR_MENU; + text_color_key = COLOR_MENUTEXT; + break; + case CONTROL_DISABLED: + bg_color_key = COLOR_MENU; + text_color_key = COLOR_GRAYTEXT; + break; + default: + NOTREACHED(); + bg_color_key = COLOR_MENU; + text_color_key = COLOR_MENUTEXT; + break; + } + COLORREF old_bg_color = SetBkColor(hdc, GetSysColor(bg_color_key)); + COLORREF old_text_color = SetTextColor(hdc, GetSysColor(text_color_key)); BitBlt(hdc, rect->left, rect->top, width, height, bitmap_dc, 0, 0, SRCCOPY); SetBkColor(hdc, old_bg_color); SetTextColor(hdc, old_text_color); diff --git a/gfx/native_theme_win.h b/gfx/native_theme_win.h index 6df247d..687bb65 100644 --- a/gfx/native_theme_win.h +++ b/gfx/native_theme_win.h @@ -54,6 +54,12 @@ class NativeTheme { RIGHT_POINTING_ARROW }; + enum ControlState { + CONTROL_NORMAL, + CONTROL_HIGHLIGHTED, + CONTROL_DISABLED + }; + typedef HRESULT (WINAPI* DrawThemeBackgroundPtr)(HANDLE theme, HDC hdc, int part_id, @@ -115,7 +121,7 @@ class NativeTheme { int state_id, RECT* rect, MenuArrowDirection arrow_direction, - bool is_highlighted) const; + ControlState state) const; HRESULT PaintMenuBackground(ThemeName theme, HDC hdc, @@ -128,7 +134,7 @@ class NativeTheme { int part_id, int state_id, RECT* rect, - bool is_highlighted) const; + ControlState state) const; HRESULT PaintMenuCheckBackground(ThemeName theme, HDC hdc, @@ -276,7 +282,7 @@ class NativeTheme { RECT* rect, UINT type, UINT state, - bool is_highlighted) const; + ControlState control_state) const; // Returns a handle to the theme data. HANDLE GetThemeHandle(ThemeName theme_name) const; diff --git a/views/controls/menu/menu_item_view.h b/views/controls/menu/menu_item_view.h index baa3461..e6ed28b 100644 --- a/views/controls/menu/menu_item_view.h +++ b/views/controls/menu/menu_item_view.h @@ -12,6 +12,10 @@ #include "third_party/skia/include/core/SkBitmap.h" #include "views/view.h" +#if defined(OS_WIN) +#include "gfx/native_theme_win.h" +#endif + namespace views { class MenuButton; @@ -304,7 +308,7 @@ class MenuItemView : public View { // native theme drawing routines. void PaintCheck(HDC dc, int part_id, - bool render_selection, + gfx::NativeTheme::ControlState control_state, int icon_width, int icon_height); #endif diff --git a/views/controls/menu/menu_item_view_win.cc b/views/controls/menu/menu_item_view_win.cc index 30a8982e..049a443 100644 --- a/views/controls/menu/menu_item_view_win.cc +++ b/views/controls/menu/menu_item_view_win.cc @@ -35,6 +35,14 @@ void MenuItemView::Paint(gfx::Canvas* canvas, bool for_drag) { int state = render_selection ? MPI_HOT : (IsEnabled() ? MPI_NORMAL : MPI_DISABLED); HDC dc = canvas->BeginPlatformPaint(); + NativeTheme::ControlState control_state; + + if (!IsEnabled()) { + control_state = NativeTheme::CONTROL_DISABLED; + } else { + control_state = render_selection ? NativeTheme::CONTROL_HIGHLIGHTED : + NativeTheme::CONTROL_NORMAL; + } // The gutter is rendered before the background. if (config.render_gutter && !for_drag) { @@ -63,10 +71,10 @@ void MenuItemView::Paint(gfx::Canvas* canvas, bool for_drag) { if (type_ == CHECKBOX && GetDelegate()->IsItemChecked(GetCommand())) { PaintCheck(dc, IsEnabled() ? MC_CHECKMARKNORMAL : MC_CHECKMARKDISABLED, - render_selection, config.check_height, config.check_width); + control_state, config.check_height, config.check_width); } else if (type_ == RADIO && GetDelegate()->IsItemChecked(GetCommand())) { PaintCheck(dc, IsEnabled() ? MC_BULLETNORMAL : MC_BULLETDISABLED, - render_selection, config.radio_height, config.radio_width); + control_state, config.radio_height, config.radio_width); } // Render the foreground. @@ -129,13 +137,14 @@ void MenuItemView::Paint(gfx::Canvas* canvas, bool for_drag) { RECT arrow_rect = arrow_bounds.ToRECT(); NativeTheme::instance()->PaintMenuArrow( NativeTheme::MENU, dc, MENU_POPUPSUBMENU, state_id, &arrow_rect, - arrow_direction, render_selection); + arrow_direction, control_state); } canvas->EndPlatformPaint(); } + void MenuItemView::PaintCheck(HDC dc, int state_id, - bool render_selection, + NativeTheme::ControlState control_state, int icon_width, int icon_height) { int top_margin = GetTopMargin(); @@ -157,7 +166,7 @@ void MenuItemView::PaintCheck(HDC dc, RECT icon_rect = icon_bounds.ToRECT(); NativeTheme::instance()->PaintMenuCheck( NativeTheme::MENU, dc, MENU_POPUPCHECK, state_id, &icon_rect, - render_selection); + control_state); } } // namespace views |