| 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/views/custom_frame_window.h" | 5 #include "chrome/views/custom_frame_window.h" |
| 6 | 6 |
| 7 #include "base/gfx/point.h" | 7 #include "base/gfx/point.h" |
| 8 #include "base/gfx/size.h" | 8 #include "base/gfx/size.h" |
| 9 #include "base/win_util.h" | 9 #include "base/win_util.h" |
| 10 #include "chrome/app/theme/theme_resources.h" | 10 #include "chrome/app/theme/theme_resources.h" |
| (...skipping 225 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 236 int height) const; | 236 int height) const; |
| 237 virtual CPoint GetSystemMenuPoint() const; | 237 virtual CPoint GetSystemMenuPoint() const; |
| 238 virtual int NonClientHitTest(const gfx::Point& point); | 238 virtual int NonClientHitTest(const gfx::Point& point); |
| 239 virtual void GetWindowMask(const gfx::Size& size, gfx::Path* window_mask); | 239 virtual void GetWindowMask(const gfx::Size& size, gfx::Path* window_mask); |
| 240 virtual void EnableClose(bool enable); | 240 virtual void EnableClose(bool enable); |
| 241 virtual void ResetWindowControls(); | 241 virtual void ResetWindowControls(); |
| 242 | 242 |
| 243 // View overrides: | 243 // View overrides: |
| 244 virtual void Paint(ChromeCanvas* canvas); | 244 virtual void Paint(ChromeCanvas* canvas); |
| 245 virtual void Layout(); | 245 virtual void Layout(); |
| 246 virtual gfx::Size GetPreferredSize(); | |
| 247 virtual void ViewHierarchyChanged(bool is_add, View* parent, View* child); | 246 virtual void ViewHierarchyChanged(bool is_add, View* parent, View* child); |
| 248 | 247 |
| 249 // BaseButton::ButtonListener implementation: | 248 // BaseButton::ButtonListener implementation: |
| 250 virtual void ButtonPressed(BaseButton* sender); | 249 virtual void ButtonPressed(BaseButton* sender); |
| 251 | 250 |
| 252 private: | 251 private: |
| 253 // Returns the thickness of the border that makes up the window frame edges. | 252 // Returns the thickness of the border that makes up the window frame edges. |
| 254 // This does not include any client edge. | 253 // This does not include any client edge. |
| 255 int FrameBorderThickness() const; | 254 int FrameBorderThickness() const; |
| 256 | 255 |
| (...skipping 187 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 444 CPoint DefaultNonClientView::GetSystemMenuPoint() const { | 443 CPoint DefaultNonClientView::GetSystemMenuPoint() const { |
| 445 // TODO(pkasting): This is wrong; Windows native runs the menu at the bottom | 444 // TODO(pkasting): This is wrong; Windows native runs the menu at the bottom |
| 446 // of the titlebar, not the bottom of the window icon. | 445 // of the titlebar, not the bottom of the window icon. |
| 447 CPoint system_menu_point(system_menu_button_->x(), | 446 CPoint system_menu_point(system_menu_button_->x(), |
| 448 system_menu_button_->y() + system_menu_button_->height()); | 447 system_menu_button_->y() + system_menu_button_->height()); |
| 449 MapWindowPoints(container_->GetHWND(), HWND_DESKTOP, &system_menu_point, 1); | 448 MapWindowPoints(container_->GetHWND(), HWND_DESKTOP, &system_menu_point, 1); |
| 450 return system_menu_point; | 449 return system_menu_point; |
| 451 } | 450 } |
| 452 | 451 |
| 453 int DefaultNonClientView::NonClientHitTest(const gfx::Point& point) { | 452 int DefaultNonClientView::NonClientHitTest(const gfx::Point& point) { |
| 454 // First see if it's within the grow box area, since that overlaps the client | 453 if (!bounds().Contains(point)) |
| 455 // bounds. | 454 return HTNOWHERE; |
| 455 |
| 456 int frame_component = container_->client_view()->NonClientHitTest(point); | 456 int frame_component = container_->client_view()->NonClientHitTest(point); |
| 457 if (frame_component != HTNOWHERE) | 457 if (frame_component != HTNOWHERE) |
| 458 return frame_component; | 458 return frame_component; |
| 459 | 459 |
| 460 // Then see if the point is within any of the window controls. | 460 // Then see if the point is within any of the window controls. |
| 461 if (close_button_->GetBounds(APPLY_MIRRORING_TRANSFORMATION).Contains(point)) | 461 if (close_button_->GetBounds(APPLY_MIRRORING_TRANSFORMATION).Contains(point)) |
| 462 return HTCLOSE; | 462 return HTCLOSE; |
| 463 if (restore_button_->GetBounds(APPLY_MIRRORING_TRANSFORMATION).Contains( | 463 if (restore_button_->GetBounds(APPLY_MIRRORING_TRANSFORMATION).Contains( |
| 464 point)) | 464 point)) |
| 465 return HTMAXBUTTON; | 465 return HTMAXBUTTON; |
| 466 if (maximize_button_->GetBounds(APPLY_MIRRORING_TRANSFORMATION).Contains( | 466 if (maximize_button_->GetBounds(APPLY_MIRRORING_TRANSFORMATION).Contains( |
| 467 point)) | 467 point)) |
| 468 return HTMAXBUTTON; | 468 return HTMAXBUTTON; |
| 469 if (minimize_button_->GetBounds(APPLY_MIRRORING_TRANSFORMATION).Contains( | 469 if (minimize_button_->GetBounds(APPLY_MIRRORING_TRANSFORMATION).Contains( |
| 470 point)) | 470 point)) |
| 471 return HTMINBUTTON; | 471 return HTMINBUTTON; |
| 472 if (system_menu_button_->GetBounds(APPLY_MIRRORING_TRANSFORMATION).Contains( | 472 if (system_menu_button_->GetBounds(APPLY_MIRRORING_TRANSFORMATION).Contains( |
| 473 point)) | 473 point)) |
| 474 return HTSYSMENU; | 474 return HTSYSMENU; |
| 475 | 475 |
| 476 int window_component = GetHTComponentForFrame(point, FrameBorderThickness(), | 476 int window_component = GetHTComponentForFrame(point, FrameBorderThickness(), |
| 477 NonClientBorderThickness(), kResizeAreaCornerSize, | 477 NonClientBorderThickness(), kResizeAreaCornerSize, kResizeAreaCornerSize, |
| 478 container_->window_delegate()->CanResize()); | 478 container_->window_delegate()->CanResize()); |
| 479 // Fall back to the caption if no other component matches. | 479 // Fall back to the caption if no other component matches. |
| 480 return ((window_component == HTNOWHERE) && bounds().Contains(point)) ? | 480 return (window_component == HTNOWHERE) ? HTCAPTION : window_component; |
| 481 HTCAPTION : window_component; | |
| 482 } | 481 } |
| 483 | 482 |
| 484 void DefaultNonClientView::GetWindowMask(const gfx::Size& size, | 483 void DefaultNonClientView::GetWindowMask(const gfx::Size& size, |
| 485 gfx::Path* window_mask) { | 484 gfx::Path* window_mask) { |
| 486 DCHECK(window_mask); | 485 DCHECK(window_mask); |
| 487 | 486 |
| 488 // Redefine the window visible region for the new size. | 487 // Redefine the window visible region for the new size. |
| 489 window_mask->moveTo(0, 3); | 488 window_mask->moveTo(0, 3); |
| 490 window_mask->lineTo(1, 2); | 489 window_mask->lineTo(1, 2); |
| 491 window_mask->lineTo(1, 1); | 490 window_mask->lineTo(1, 1); |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 527 if (!container_->IsMaximized()) | 526 if (!container_->IsMaximized()) |
| 528 PaintRestoredClientEdge(canvas); | 527 PaintRestoredClientEdge(canvas); |
| 529 } | 528 } |
| 530 | 529 |
| 531 void DefaultNonClientView::Layout() { | 530 void DefaultNonClientView::Layout() { |
| 532 LayoutWindowControls(); | 531 LayoutWindowControls(); |
| 533 LayoutTitleBar(); | 532 LayoutTitleBar(); |
| 534 LayoutClientView(); | 533 LayoutClientView(); |
| 535 } | 534 } |
| 536 | 535 |
| 537 gfx::Size DefaultNonClientView::GetPreferredSize() { | |
| 538 gfx::Size prefsize(container_->client_view()->GetPreferredSize()); | |
| 539 int border_thickness = NonClientBorderThickness(); | |
| 540 prefsize.Enlarge(2 * border_thickness, | |
| 541 NonClientTopBorderHeight() + border_thickness); | |
| 542 return prefsize; | |
| 543 } | |
| 544 | |
| 545 void DefaultNonClientView::ViewHierarchyChanged(bool is_add, | 536 void DefaultNonClientView::ViewHierarchyChanged(bool is_add, |
| 546 View* parent, | 537 View* parent, |
| 547 View* child) { | 538 View* child) { |
| 548 // Add our Client View as we are added to the Widget so that if we are | 539 // Add our Client View as we are added to the Widget so that if we are |
| 549 // subsequently resized all the parent-child relationships are established. | 540 // subsequently resized all the parent-child relationships are established. |
| 550 if (is_add && GetWidget() && child == this) | 541 if (is_add && GetWidget() && child == this) |
| 551 AddChildView(container_->client_view()); | 542 AddChildView(container_->client_view()); |
| 552 } | 543 } |
| 553 | 544 |
| 554 /////////////////////////////////////////////////////////////////////////////// | 545 /////////////////////////////////////////////////////////////////////////////// |
| (...skipping 773 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1328 if ((GetKeyState(VK_CONTROL) & 0x80) == 0x80) | 1319 if ((GetKeyState(VK_CONTROL) & 0x80) == 0x80) |
| 1329 message_flags |= MK_CONTROL; | 1320 message_flags |= MK_CONTROL; |
| 1330 if ((GetKeyState(VK_SHIFT) & 0x80) == 0x80) | 1321 if ((GetKeyState(VK_SHIFT) & 0x80) == 0x80) |
| 1331 message_flags |= MK_SHIFT; | 1322 message_flags |= MK_SHIFT; |
| 1332 message_flags |= flags; | 1323 message_flags |= flags; |
| 1333 ProcessMousePressed(temp, message_flags, false); | 1324 ProcessMousePressed(temp, message_flags, false); |
| 1334 } | 1325 } |
| 1335 | 1326 |
| 1336 } // namespace views | 1327 } // namespace views |
| 1337 | 1328 |
| OLD | NEW |