| OLD | NEW |
| 1 // Copyright (c) 2006-2008 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/constrained_window_win.h" | 5 #include "chrome/browser/views/constrained_window_win.h" |
| 6 | 6 |
| 7 #include "app/gfx/canvas.h" | 7 #include "app/gfx/canvas.h" |
| 8 #include "app/gfx/font.h" | 8 #include "app/gfx/font.h" |
| 9 #include "app/gfx/path.h" | 9 #include "app/gfx/path.h" |
| 10 #include "app/gfx/text_elider.h" | 10 #include "app/gfx/text_elider.h" |
| 11 #include "app/l10n_util.h" | 11 #include "app/l10n_util.h" |
| (...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 162 explicit ConstrainedWindowFrameView(ConstrainedWindowWin* container); | 162 explicit ConstrainedWindowFrameView(ConstrainedWindowWin* container); |
| 163 virtual ~ConstrainedWindowFrameView(); | 163 virtual ~ConstrainedWindowFrameView(); |
| 164 | 164 |
| 165 void UpdateWindowTitle(); | 165 void UpdateWindowTitle(); |
| 166 | 166 |
| 167 // Overridden from views::NonClientFrameView: | 167 // Overridden from views::NonClientFrameView: |
| 168 virtual gfx::Rect GetBoundsForClientView() const; | 168 virtual gfx::Rect GetBoundsForClientView() const; |
| 169 virtual bool AlwaysUseCustomFrame() const; | 169 virtual bool AlwaysUseCustomFrame() const; |
| 170 virtual gfx::Rect GetWindowBoundsForClientBounds( | 170 virtual gfx::Rect GetWindowBoundsForClientBounds( |
| 171 const gfx::Rect& client_bounds) const; | 171 const gfx::Rect& client_bounds) const; |
| 172 virtual gfx::Point GetSystemMenuPoint() const; | |
| 173 virtual int NonClientHitTest(const gfx::Point& point); | 172 virtual int NonClientHitTest(const gfx::Point& point); |
| 174 virtual void GetWindowMask(const gfx::Size& size, gfx::Path* window_mask); | 173 virtual void GetWindowMask(const gfx::Size& size, gfx::Path* window_mask); |
| 175 virtual void EnableClose(bool enable); | 174 virtual void EnableClose(bool enable); |
| 176 virtual void ResetWindowControls() { } | 175 virtual void ResetWindowControls() { } |
| 177 | 176 |
| 178 // Overridden from views::View: | 177 // Overridden from views::View: |
| 179 virtual void Paint(gfx::Canvas* canvas); | 178 virtual void Paint(gfx::Canvas* canvas); |
| 180 virtual void Layout(); | 179 virtual void Layout(); |
| 181 virtual void ThemeChanged(); | 180 virtual void ThemeChanged(); |
| 182 | 181 |
| (...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 315 gfx::Rect ConstrainedWindowFrameView::GetWindowBoundsForClientBounds( | 314 gfx::Rect ConstrainedWindowFrameView::GetWindowBoundsForClientBounds( |
| 316 const gfx::Rect& client_bounds) const { | 315 const gfx::Rect& client_bounds) const { |
| 317 int top_height = NonClientTopBorderHeight(); | 316 int top_height = NonClientTopBorderHeight(); |
| 318 int border_thickness = NonClientBorderThickness(); | 317 int border_thickness = NonClientBorderThickness(); |
| 319 return gfx::Rect(std::max(0, client_bounds.x() - border_thickness), | 318 return gfx::Rect(std::max(0, client_bounds.x() - border_thickness), |
| 320 std::max(0, client_bounds.y() - top_height), | 319 std::max(0, client_bounds.y() - top_height), |
| 321 client_bounds.width() + (2 * border_thickness), | 320 client_bounds.width() + (2 * border_thickness), |
| 322 client_bounds.height() + top_height + border_thickness); | 321 client_bounds.height() + top_height + border_thickness); |
| 323 } | 322 } |
| 324 | 323 |
| 325 gfx::Point ConstrainedWindowFrameView::GetSystemMenuPoint() const { | |
| 326 // Doesn't really matter, since we never show system menus on constrained | |
| 327 // windows... | |
| 328 gfx::Point system_menu_point(FrameBorderThickness(), | |
| 329 NonClientTopBorderHeight()); | |
| 330 ConvertPointToScreen(this, &system_menu_point); | |
| 331 return system_menu_point; | |
| 332 } | |
| 333 | |
| 334 int ConstrainedWindowFrameView::NonClientHitTest(const gfx::Point& point) { | 324 int ConstrainedWindowFrameView::NonClientHitTest(const gfx::Point& point) { |
| 335 if (!bounds().Contains(point)) | 325 if (!bounds().Contains(point)) |
| 336 return HTNOWHERE; | 326 return HTNOWHERE; |
| 337 | 327 |
| 338 int frame_component = container_->GetClientView()->NonClientHitTest(point); | 328 int frame_component = container_->GetClientView()->NonClientHitTest(point); |
| 339 if (frame_component != HTNOWHERE) | 329 if (frame_component != HTNOWHERE) |
| 340 return frame_component; | 330 return frame_component; |
| 341 | 331 |
| 342 // Then see if the point is within any of the window controls. | 332 // Then see if the point is within any of the window controls. |
| 343 if (close_button_->GetBounds(APPLY_MIRRORING_TRANSFORMATION).Contains(point)) | 333 if (close_button_->GetBounds(APPLY_MIRRORING_TRANSFORMATION).Contains(point)) |
| (...skipping 349 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 693 | 683 |
| 694 | 684 |
| 695 // static | 685 // static |
| 696 ConstrainedWindow* ConstrainedWindow::CreateConstrainedDialog( | 686 ConstrainedWindow* ConstrainedWindow::CreateConstrainedDialog( |
| 697 TabContents* parent, | 687 TabContents* parent, |
| 698 views::WindowDelegate* window_delegate) { | 688 views::WindowDelegate* window_delegate) { |
| 699 ConstrainedWindowWin* window = new ConstrainedWindowWin(parent, | 689 ConstrainedWindowWin* window = new ConstrainedWindowWin(parent, |
| 700 window_delegate); | 690 window_delegate); |
| 701 return window; | 691 return window; |
| 702 } | 692 } |
| OLD | NEW |