Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(941)

Unified Diff: ui/native_theme/native_theme_win.cc

Issue 1482863002: Add support for drawing window caption buttons on windows. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebased Created 4 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « ui/native_theme/native_theme_win.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/native_theme/native_theme_win.cc
diff --git a/ui/native_theme/native_theme_win.cc b/ui/native_theme/native_theme_win.cc
index 8539fe663c5596101958d19bfaa0a28bd1c075ad..5f7798538e07e590c0d3177336bfe2182d701674 100644
--- a/ui/native_theme/native_theme_win.cc
+++ b/ui/native_theme/native_theme_win.cc
@@ -464,6 +464,12 @@ void NativeThemeWin::PaintDirect(SkCanvas* canvas,
case kWindowResizeGripper:
PaintWindowResizeGripper(hdc, rect);
return;
+ case kCaptionMin:
+ case kCaptionMax:
+ case kCaptionRestore:
+ case kCaptionClose:
+ PaintCaptionButton(hdc, part, state, rect, extra);
+ return;
case kComboboxArrow:
case kSliderTrack:
case kSliderThumb:
@@ -1563,6 +1569,60 @@ HRESULT NativeThemeWin::PaintTabPanelBackground(HDC hdc,
return S_OK;
}
+HRESULT NativeThemeWin::PaintCaptionButton(HDC hdc,
+ Part part,
+ State state,
+ const gfx::Rect&rect,
+ const ExtraParams& extra) const {
+ HANDLE handle = GetThemeHandle(WINDOW);
+ RECT rect_win = rect.ToRECT();
+ if (handle && draw_theme_) {
+ int part_id = GetWindowsPart(part, state, extra);
+ int state_id = GetWindowsState(part, state, extra);
+ return draw_theme_(handle, hdc, part_id, state_id, &rect_win, NULL);
+ }
+
+ // Adjust classic_state based on part, state, and extras.
+ int classic_state = 0;
+ switch (part) {
+ case kCaptionMin:
+ classic_state |= DFCS_CAPTIONMIN;
+ break;
+ case kCaptionMax:
+ classic_state |= DFCS_CAPTIONMAX;
+ break;
+ case kCaptionRestore:
+ classic_state |= DFCS_CAPTIONRESTORE;
+ break;
+ case kCaptionClose:
+ classic_state |= DFCS_CAPTIONCLOSE;
+ break;
+ default:
+ NOTREACHED();
+ break;
+ }
+
+ switch (state) {
+ case kDisabled:
+ classic_state |= DFCS_INACTIVE;
+ break;
+ case kHovered:
+ classic_state |= DFCS_HOT;
+ break;
+ case kNormal:
+ break;
+ case kPressed:
+ classic_state |= DFCS_PUSHED;
+ break;
+ case kNumStates:
+ NOTREACHED();
+ break;
+ }
+
+ DrawFrameControl(hdc, &rect_win, DFC_CAPTION, classic_state);
+ return S_OK;
+}
+
HRESULT NativeThemeWin::PaintTextField(
HDC hdc,
Part part,
@@ -1754,6 +1814,14 @@ int NativeThemeWin::GetWindowsPart(Part part,
return SBP_THUMBBTNVERT;
case kWindowResizeGripper:
return SP_GRIPPER;
+ case kCaptionMin:
+ return WP_MINBUTTON;
+ case kCaptionMax:
+ return WP_MAXBUTTON;
+ case kCaptionRestore:
+ return WP_RESTOREBUTTON;
+ case kCaptionClose:
+ return WP_CLOSEBUTTON;
case kComboboxArrow:
case kInnerSpinButton:
case kMenuList:
@@ -1948,6 +2016,62 @@ int NativeThemeWin::GetWindowsState(Part part,
NOTREACHED();
return 0;
}
+ case kCaptionMin:
+ switch (state) {
+ case kDisabled:
+ return MINBS_DISABLED;
+ case kHovered:
+ return MINBS_HOT;
+ case kNormal:
+ return MINBS_NORMAL;
+ case kPressed:
+ return MINBS_PUSHED;
+ case kNumStates:
+ NOTREACHED();
+ return 0;
+ }
+ case kCaptionMax:
+ switch (state) {
+ case kDisabled:
+ return MAXBS_DISABLED;
+ case kHovered:
+ return MAXBS_HOT;
+ case kNormal:
+ return MAXBS_NORMAL;
+ case kPressed:
+ return MAXBS_PUSHED;
+ case kNumStates:
+ NOTREACHED();
+ return 0;
+ }
+ case kCaptionRestore:
+ switch (state) {
+ case kDisabled:
+ return RBS_DISABLED;
+ case kHovered:
+ return RBS_HOT;
+ case kNormal:
+ return RBS_NORMAL;
+ case kPressed:
+ return RBS_PUSHED;
+ case kNumStates:
+ NOTREACHED();
+ return 0;
+ }
+ case kCaptionClose:
+ switch (state) {
+ case kDisabled:
+ return CBS_DISABLED;
+ case kHovered:
+ return CBS_HOT;
+ case kNormal:
+ return CBS_NORMAL;
+ case kPressed:
+ return CBS_PUSHED;
+ case kNumStates:
+ NOTREACHED();
+ return 0;
+ }
case kComboboxArrow:
case kInnerSpinButton:
case kMenuList:
« no previous file with comments | « ui/native_theme/native_theme_win.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698