| OLD | NEW |
| 1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 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/opaque_non_client_view.h" | 5 #include "chrome/browser/views/frame/opaque_non_client_view.h" |
| 6 | 6 |
| 7 #include "chrome/app/theme/theme_resources.h" | 7 #include "chrome/app/theme/theme_resources.h" |
| 8 #include "chrome/browser/tab_contents/tab_contents.h" | |
| 9 #include "chrome/browser/views/frame/browser_view.h" | 8 #include "chrome/browser/views/frame/browser_view.h" |
| 10 #include "chrome/browser/views/tabs/tab_strip.h" | 9 #include "chrome/browser/views/tabs/tab_strip.h" |
| 11 #include "chrome/common/gfx/chrome_font.h" | 10 #include "chrome/common/gfx/chrome_font.h" |
| 12 #include "chrome/common/gfx/path.h" | 11 #include "chrome/common/gfx/path.h" |
| 13 #include "chrome/common/l10n_util.h" | 12 #include "chrome/common/l10n_util.h" |
| 14 #include "chrome/common/resource_bundle.h" | 13 #include "chrome/common/resource_bundle.h" |
| 15 #include "chrome/common/win_util.h" | 14 #include "chrome/common/win_util.h" |
| 16 #include "chrome/views/root_view.h" | 15 #include "chrome/views/root_view.h" |
| 17 #include "chrome/views/window_resources.h" | 16 #include "chrome/views/window_resources.h" |
| 18 #include "chromium_strings.h" | 17 #include "chromium_strings.h" |
| (...skipping 483 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 502 | 501 |
| 503 CPoint OpaqueNonClientView::GetSystemMenuPoint() const { | 502 CPoint OpaqueNonClientView::GetSystemMenuPoint() const { |
| 504 // TODO(pkasting): This is wrong; Windows native runs the menu at the bottom | 503 // TODO(pkasting): This is wrong; Windows native runs the menu at the bottom |
| 505 // of the titlebar, not the bottom of the window icon. | 504 // of the titlebar, not the bottom of the window icon. |
| 506 CPoint system_menu_point(icon_bounds_.x(), icon_bounds_.bottom()); | 505 CPoint system_menu_point(icon_bounds_.x(), icon_bounds_.bottom()); |
| 507 MapWindowPoints(frame_->GetHWND(), HWND_DESKTOP, &system_menu_point, 1); | 506 MapWindowPoints(frame_->GetHWND(), HWND_DESKTOP, &system_menu_point, 1); |
| 508 return system_menu_point; | 507 return system_menu_point; |
| 509 } | 508 } |
| 510 | 509 |
| 511 int OpaqueNonClientView::NonClientHitTest(const gfx::Point& point) { | 510 int OpaqueNonClientView::NonClientHitTest(const gfx::Point& point) { |
| 512 // First see if it's within the grow box area, since that overlaps the client | 511 if (!bounds().Contains(point)) |
| 513 // bounds. | 512 return HTNOWHERE; |
| 513 |
| 514 int frame_component = frame_->client_view()->NonClientHitTest(point); | 514 int frame_component = frame_->client_view()->NonClientHitTest(point); |
| 515 if (frame_component != HTNOWHERE) | 515 if (frame_component != HTNOWHERE) |
| 516 return frame_component; | 516 return frame_component; |
| 517 | 517 |
| 518 // Then see if the point is within any of the window controls. | 518 // Then see if the point is within any of the window controls. |
| 519 if (close_button_->GetBounds(APPLY_MIRRORING_TRANSFORMATION).Contains(point)) | 519 if (close_button_->GetBounds(APPLY_MIRRORING_TRANSFORMATION).Contains(point)) |
| 520 return HTCLOSE; | 520 return HTCLOSE; |
| 521 if (restore_button_->GetBounds(APPLY_MIRRORING_TRANSFORMATION).Contains( | 521 if (restore_button_->GetBounds(APPLY_MIRRORING_TRANSFORMATION).Contains( |
| 522 point)) | 522 point)) |
| 523 return HTMAXBUTTON; | 523 return HTMAXBUTTON; |
| 524 if (maximize_button_->GetBounds(APPLY_MIRRORING_TRANSFORMATION).Contains( | 524 if (maximize_button_->GetBounds(APPLY_MIRRORING_TRANSFORMATION).Contains( |
| 525 point)) | 525 point)) |
| 526 return HTMAXBUTTON; | 526 return HTMAXBUTTON; |
| 527 if (minimize_button_->GetBounds(APPLY_MIRRORING_TRANSFORMATION).Contains( | 527 if (minimize_button_->GetBounds(APPLY_MIRRORING_TRANSFORMATION).Contains( |
| 528 point)) | 528 point)) |
| 529 return HTMINBUTTON; | 529 return HTMINBUTTON; |
| 530 if (window_icon_ && | 530 if (window_icon_ && |
| 531 window_icon_->GetBounds(APPLY_MIRRORING_TRANSFORMATION).Contains(point)) | 531 window_icon_->GetBounds(APPLY_MIRRORING_TRANSFORMATION).Contains(point)) |
| 532 return HTSYSMENU; | 532 return HTSYSMENU; |
| 533 | 533 |
| 534 int window_component = GetHTComponentForFrame(point, TopResizeHeight(), | 534 int window_component = GetHTComponentForFrame(point, TopResizeHeight(), |
| 535 NonClientBorderThickness(), kResizeAreaCornerSize, | 535 NonClientBorderThickness(), kResizeAreaCornerSize, kResizeAreaCornerSize, |
| 536 frame_->window_delegate()->CanResize()); | 536 frame_->window_delegate()->CanResize()); |
| 537 // Fall back to the caption if no other component matches. | 537 // Fall back to the caption if no other component matches. |
| 538 return ((window_component == HTNOWHERE) && bounds().Contains(point)) ? | 538 return (window_component == HTNOWHERE) ? HTCAPTION : window_component; |
| 539 HTCAPTION : window_component; | |
| 540 } | 539 } |
| 541 | 540 |
| 542 void OpaqueNonClientView::GetWindowMask(const gfx::Size& size, | 541 void OpaqueNonClientView::GetWindowMask(const gfx::Size& size, |
| 543 gfx::Path* window_mask) { | 542 gfx::Path* window_mask) { |
| 544 DCHECK(window_mask); | 543 DCHECK(window_mask); |
| 545 | 544 |
| 546 // Redefine the window visible region for the new size. | 545 // Redefine the window visible region for the new size. |
| 547 window_mask->moveTo(0, 3); | 546 window_mask->moveTo(0, 3); |
| 548 window_mask->lineTo(1, 2); | 547 window_mask->lineTo(1, 2); |
| 549 window_mask->lineTo(1, 1); | 548 window_mask->lineTo(1, 1); |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 590 } | 589 } |
| 591 | 590 |
| 592 void OpaqueNonClientView::Layout() { | 591 void OpaqueNonClientView::Layout() { |
| 593 LayoutWindowControls(); | 592 LayoutWindowControls(); |
| 594 LayoutDistributorLogo(); | 593 LayoutDistributorLogo(); |
| 595 LayoutTitleBar(); | 594 LayoutTitleBar(); |
| 596 LayoutOTRAvatar(); | 595 LayoutOTRAvatar(); |
| 597 LayoutClientView(); | 596 LayoutClientView(); |
| 598 } | 597 } |
| 599 | 598 |
| 600 gfx::Size OpaqueNonClientView::GetPreferredSize() { | |
| 601 gfx::Size prefsize(frame_->client_view()->GetPreferredSize()); | |
| 602 int border_thickness = NonClientBorderThickness(); | |
| 603 prefsize.Enlarge(2 * border_thickness, | |
| 604 NonClientTopBorderHeight() + border_thickness); | |
| 605 return prefsize; | |
| 606 } | |
| 607 | |
| 608 views::View* OpaqueNonClientView::GetViewForPoint(const gfx::Point& point, | 599 views::View* OpaqueNonClientView::GetViewForPoint(const gfx::Point& point, |
| 609 bool can_create_floating) { | 600 bool can_create_floating) { |
| 610 // We override this function because the ClientView can overlap the non - | 601 // We override this function because the ClientView can overlap the non - |
| 611 // client view, making it impossible to click on the window controls. We need | 602 // client view, making it impossible to click on the window controls. We need |
| 612 // to ensure the window controls are checked _first_. | 603 // to ensure the window controls are checked _first_. |
| 613 views::View* views[] = | 604 views::View* views[] = |
| 614 { close_button_, restore_button_, maximize_button_, minimize_button_ }; | 605 { close_button_, restore_button_, maximize_button_, minimize_button_ }; |
| 615 for (int i = 0; i < arraysize(views); ++i) { | 606 for (int i = 0; i < arraysize(views); ++i) { |
| 616 if (!views[i]->IsVisible()) | 607 if (!views[i]->IsVisible()) |
| 617 continue; | 608 continue; |
| (...skipping 465 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1083 } | 1074 } |
| 1084 | 1075 |
| 1085 // static | 1076 // static |
| 1086 void OpaqueNonClientView::InitAppWindowResources() { | 1077 void OpaqueNonClientView::InitAppWindowResources() { |
| 1087 static bool initialized = false; | 1078 static bool initialized = false; |
| 1088 if (!initialized) { | 1079 if (!initialized) { |
| 1089 title_font_ = win_util::GetWindowTitleFont(); | 1080 title_font_ = win_util::GetWindowTitleFont(); |
| 1090 initialized = true; | 1081 initialized = true; |
| 1091 } | 1082 } |
| 1092 } | 1083 } |
| OLD | NEW |