OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "chrome/browser/views/frame/browser_frame_win.h" | 5 #include "chrome/browser/views/frame/browser_frame_win.h" |
6 | 6 |
7 #include <dwmapi.h> | 7 #include <dwmapi.h> |
8 #include <shellapi.h> | 8 #include <shellapi.h> |
9 | 9 |
10 #include <set> | 10 #include <set> |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
60 set_focus_on_creation(false); | 60 set_focus_on_creation(false); |
61 } | 61 } |
62 | 62 |
63 void BrowserFrameWin::Init() { | 63 void BrowserFrameWin::Init() { |
64 WindowWin::Init(NULL, gfx::Rect()); | 64 WindowWin::Init(NULL, gfx::Rect()); |
65 } | 65 } |
66 | 66 |
67 BrowserFrameWin::~BrowserFrameWin() { | 67 BrowserFrameWin::~BrowserFrameWin() { |
68 } | 68 } |
69 | 69 |
70 int BrowserFrameWin::GetTitleBarHeight() { | |
71 RECT caption = { 0 }; | |
72 if (DwmGetWindowAttribute(GetNativeView(), DWMWA_CAPTION_BUTTON_BOUNDS, | |
73 &caption, sizeof(RECT)) == S_OK) { | |
74 return caption.bottom; | |
75 } | |
76 return GetSystemMetrics(SM_CYCAPTION); | |
77 } | |
78 | |
79 views::Window* BrowserFrameWin::GetWindow() { | 70 views::Window* BrowserFrameWin::GetWindow() { |
80 return this; | 71 return this; |
81 } | 72 } |
82 | 73 |
83 int BrowserFrameWin::GetMinimizeButtonOffset() const { | 74 int BrowserFrameWin::GetMinimizeButtonOffset() const { |
84 TITLEBARINFOEX titlebar_info; | 75 TITLEBARINFOEX titlebar_info; |
85 titlebar_info.cbSize = sizeof(TITLEBARINFOEX); | 76 titlebar_info.cbSize = sizeof(TITLEBARINFOEX); |
86 SendMessage(GetNativeView(), WM_GETTITLEBARINFOEX, 0, (WPARAM)&titlebar_info); | 77 SendMessage(GetNativeView(), WM_GETTITLEBARINFOEX, 0, (WPARAM)&titlebar_info); |
87 | 78 |
88 CPoint minimize_button_corner(titlebar_info.rgrect[2].left, | 79 CPoint minimize_button_corner(titlebar_info.rgrect[2].left, |
89 titlebar_info.rgrect[2].top); | 80 titlebar_info.rgrect[2].top); |
90 MapWindowPoints(HWND_DESKTOP, GetNativeView(), &minimize_button_corner, 1); | 81 MapWindowPoints(HWND_DESKTOP, GetNativeView(), &minimize_button_corner, 1); |
91 | 82 |
92 return minimize_button_corner.x; | 83 return minimize_button_corner.x; |
93 } | 84 } |
94 | 85 |
95 gfx::Rect BrowserFrameWin::GetBoundsForTabStrip(BaseTabStrip* tabstrip) const { | 86 gfx::Rect BrowserFrameWin::GetBoundsForTabStrip(BaseTabStrip* tabstrip) const { |
96 return browser_frame_view_->GetBoundsForTabStrip(tabstrip); | 87 return browser_frame_view_->GetBoundsForTabStrip(tabstrip); |
97 } | 88 } |
98 | 89 |
| 90 int BrowserFrameWin::GetHorizontalTabStripVerticalOffset(bool restored) const { |
| 91 return browser_frame_view_->GetHorizontalTabStripVerticalOffset(restored); |
| 92 } |
| 93 |
99 void BrowserFrameWin::UpdateThrobber(bool running) { | 94 void BrowserFrameWin::UpdateThrobber(bool running) { |
100 browser_frame_view_->UpdateThrobber(running); | 95 browser_frame_view_->UpdateThrobber(running); |
101 } | 96 } |
102 | 97 |
103 void BrowserFrameWin::ContinueDraggingDetachedTab() { | 98 void BrowserFrameWin::ContinueDraggingDetachedTab() { |
104 // Send the message directly, so that the window is positioned appropriately. | 99 // Send the message directly, so that the window is positioned appropriately. |
105 SendMessage(GetNativeWindow(), WM_NCLBUTTONDOWN, HTCAPTION, MAKELPARAM(0, 0)); | 100 SendMessage(GetNativeWindow(), WM_NCLBUTTONDOWN, HTCAPTION, MAKELPARAM(0, 0)); |
106 } | 101 } |
107 | 102 |
108 ThemeProvider* BrowserFrameWin::GetThemeProviderForFrame() const { | 103 ThemeProvider* BrowserFrameWin::GetThemeProviderForFrame() const { |
(...skipping 195 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
304 // become semi-transparent over any glass area. | 299 // become semi-transparent over any glass area. |
305 if (!IsMaximized() && !IsFullscreen()) { | 300 if (!IsMaximized() && !IsFullscreen()) { |
306 margins.cxLeftWidth = kClientEdgeThickness + 1; | 301 margins.cxLeftWidth = kClientEdgeThickness + 1; |
307 margins.cxRightWidth = kClientEdgeThickness + 1; | 302 margins.cxRightWidth = kClientEdgeThickness + 1; |
308 margins.cyBottomHeight = kClientEdgeThickness + 1; | 303 margins.cyBottomHeight = kClientEdgeThickness + 1; |
309 margins.cyTopHeight = kClientEdgeThickness + 1; | 304 margins.cyTopHeight = kClientEdgeThickness + 1; |
310 } | 305 } |
311 // In maximized mode, we only have a titlebar strip of glass, no side/bottom | 306 // In maximized mode, we only have a titlebar strip of glass, no side/bottom |
312 // borders. | 307 // borders. |
313 if (!browser_view_->IsFullscreen()) { | 308 if (!browser_view_->IsFullscreen()) { |
314 if (browser_view_->UseVerticalTabs()) { | 309 gfx::Rect tabstrip_bounds( |
315 margins.cyTopHeight = GetTitleBarHeight(); | 310 GetBoundsForTabStrip(browser_view_->tabstrip())); |
316 } else { | 311 margins.cyTopHeight = (browser_view_->UseVerticalTabs() ? |
317 margins.cyTopHeight = | 312 tabstrip_bounds.y() : tabstrip_bounds.bottom()) + kDWMFrameTopOffset; |
318 GetBoundsForTabStrip(browser_view_->tabstrip()).bottom() + | |
319 kDWMFrameTopOffset; | |
320 } | |
321 } | 313 } |
322 } else { | 314 } else { |
323 // For popup and app windows we want to use the default margins. | 315 // For popup and app windows we want to use the default margins. |
324 } | 316 } |
325 DwmExtendFrameIntoClientArea(GetNativeView(), &margins); | 317 DwmExtendFrameIntoClientArea(GetNativeView(), &margins); |
326 } | 318 } |
OLD | NEW |