| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/ui/views/constrained_window_views.h" | 5 #include "chrome/browser/ui/views/constrained_window_views.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 | 8 |
| 9 #include "chrome/app/chrome_command_ids.h" | 9 #include "chrome/app/chrome_command_ids.h" |
| 10 #include "chrome/browser/profiles/profile.h" | 10 #include "chrome/browser/profiles/profile.h" |
| (...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 148 : public views::NonClientFrameView, | 148 : public views::NonClientFrameView, |
| 149 public views::ButtonListener { | 149 public views::ButtonListener { |
| 150 public: | 150 public: |
| 151 explicit ConstrainedWindowFrameView(ConstrainedWindowViews* container); | 151 explicit ConstrainedWindowFrameView(ConstrainedWindowViews* container); |
| 152 virtual ~ConstrainedWindowFrameView(); | 152 virtual ~ConstrainedWindowFrameView(); |
| 153 | 153 |
| 154 void UpdateWindowTitle(); | 154 void UpdateWindowTitle(); |
| 155 | 155 |
| 156 // Overridden from views::NonClientFrameView: | 156 // Overridden from views::NonClientFrameView: |
| 157 virtual gfx::Rect GetBoundsForClientView() const OVERRIDE; | 157 virtual gfx::Rect GetBoundsForClientView() const OVERRIDE; |
| 158 virtual bool AlwaysUseCustomFrame() const OVERRIDE; | |
| 159 virtual gfx::Rect GetWindowBoundsForClientBounds( | 158 virtual gfx::Rect GetWindowBoundsForClientBounds( |
| 160 const gfx::Rect& client_bounds) const OVERRIDE; | 159 const gfx::Rect& client_bounds) const OVERRIDE; |
| 161 virtual int NonClientHitTest(const gfx::Point& point) OVERRIDE; | 160 virtual int NonClientHitTest(const gfx::Point& point) OVERRIDE; |
| 162 virtual void GetWindowMask(const gfx::Size& size, gfx::Path* window_mask) | 161 virtual void GetWindowMask(const gfx::Size& size, gfx::Path* window_mask) |
| 163 OVERRIDE; | 162 OVERRIDE; |
| 164 virtual void EnableClose(bool enable) OVERRIDE; | 163 virtual void EnableClose(bool enable) OVERRIDE; |
| 165 virtual void ResetWindowControls() OVERRIDE {} | 164 virtual void ResetWindowControls() OVERRIDE {} |
| 166 virtual void UpdateWindowIcon() OVERRIDE {} | 165 virtual void UpdateWindowIcon() OVERRIDE {} |
| 167 | 166 |
| 168 // Overridden from views::View: | 167 // Overridden from views::View: |
| (...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 266 // ConstrainedWindowFrameView, public: | 265 // ConstrainedWindowFrameView, public: |
| 267 | 266 |
| 268 ConstrainedWindowFrameView::ConstrainedWindowFrameView( | 267 ConstrainedWindowFrameView::ConstrainedWindowFrameView( |
| 269 ConstrainedWindowViews* container) | 268 ConstrainedWindowViews* container) |
| 270 : NonClientFrameView(), | 269 : NonClientFrameView(), |
| 271 container_(container), | 270 container_(container), |
| 272 close_button_(new views::ImageButton(this)) { | 271 close_button_(new views::ImageButton(this)) { |
| 273 InitClass(); | 272 InitClass(); |
| 274 InitWindowResources(); | 273 InitWindowResources(); |
| 275 | 274 |
| 275 // Constrained windows always use the custom frame - they just have a |
| 276 // different set of bitmaps. |
| 277 container->set_frame_type(views::Window::FRAME_TYPE_FORCE_CUSTOM); |
| 278 |
| 276 ResourceBundle& rb = ResourceBundle::GetSharedInstance(); | 279 ResourceBundle& rb = ResourceBundle::GetSharedInstance(); |
| 277 close_button_->SetImage(views::CustomButton::BS_NORMAL, | 280 close_button_->SetImage(views::CustomButton::BS_NORMAL, |
| 278 rb.GetBitmapNamed(IDR_CLOSE_SA)); | 281 rb.GetBitmapNamed(IDR_CLOSE_SA)); |
| 279 close_button_->SetImage(views::CustomButton::BS_HOT, | 282 close_button_->SetImage(views::CustomButton::BS_HOT, |
| 280 rb.GetBitmapNamed(IDR_CLOSE_SA_H)); | 283 rb.GetBitmapNamed(IDR_CLOSE_SA_H)); |
| 281 close_button_->SetImage(views::CustomButton::BS_PUSHED, | 284 close_button_->SetImage(views::CustomButton::BS_PUSHED, |
| 282 rb.GetBitmapNamed(IDR_CLOSE_SA_P)); | 285 rb.GetBitmapNamed(IDR_CLOSE_SA_P)); |
| 283 close_button_->SetImageAlignment(views::ImageButton::ALIGN_CENTER, | 286 close_button_->SetImageAlignment(views::ImageButton::ALIGN_CENTER, |
| 284 views::ImageButton::ALIGN_MIDDLE); | 287 views::ImageButton::ALIGN_MIDDLE); |
| 285 AddChildView(close_button_); | 288 AddChildView(close_button_); |
| 286 } | 289 } |
| 287 | 290 |
| 288 ConstrainedWindowFrameView::~ConstrainedWindowFrameView() { | 291 ConstrainedWindowFrameView::~ConstrainedWindowFrameView() { |
| 289 } | 292 } |
| 290 | 293 |
| 291 void ConstrainedWindowFrameView::UpdateWindowTitle() { | 294 void ConstrainedWindowFrameView::UpdateWindowTitle() { |
| 292 SchedulePaintInRect(title_bounds_); | 295 SchedulePaintInRect(title_bounds_); |
| 293 } | 296 } |
| 294 | 297 |
| 295 //////////////////////////////////////////////////////////////////////////////// | 298 //////////////////////////////////////////////////////////////////////////////// |
| 296 // ConstrainedWindowFrameView, views::NonClientFrameView implementation: | 299 // ConstrainedWindowFrameView, views::NonClientFrameView implementation: |
| 297 | 300 |
| 298 gfx::Rect ConstrainedWindowFrameView::GetBoundsForClientView() const { | 301 gfx::Rect ConstrainedWindowFrameView::GetBoundsForClientView() const { |
| 299 return client_view_bounds_; | 302 return client_view_bounds_; |
| 300 } | 303 } |
| 301 | 304 |
| 302 bool ConstrainedWindowFrameView::AlwaysUseCustomFrame() const { | |
| 303 // Constrained windows always use the custom frame - they just have a | |
| 304 // different set of bitmaps. | |
| 305 return true; | |
| 306 } | |
| 307 | |
| 308 gfx::Rect ConstrainedWindowFrameView::GetWindowBoundsForClientBounds( | 305 gfx::Rect ConstrainedWindowFrameView::GetWindowBoundsForClientBounds( |
| 309 const gfx::Rect& client_bounds) const { | 306 const gfx::Rect& client_bounds) const { |
| 310 int top_height = NonClientTopBorderHeight(); | 307 int top_height = NonClientTopBorderHeight(); |
| 311 int border_thickness = NonClientBorderThickness(); | 308 int border_thickness = NonClientBorderThickness(); |
| 312 return gfx::Rect(std::max(0, client_bounds.x() - border_thickness), | 309 return gfx::Rect(std::max(0, client_bounds.x() - border_thickness), |
| 313 std::max(0, client_bounds.y() - top_height), | 310 std::max(0, client_bounds.y() - top_height), |
| 314 client_bounds.width() + (2 * border_thickness), | 311 client_bounds.width() + (2 * border_thickness), |
| 315 client_bounds.height() + top_height + border_thickness); | 312 client_bounds.height() + top_height + border_thickness); |
| 316 } | 313 } |
| 317 | 314 |
| (...skipping 333 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 651 | 648 |
| 652 //////////////////////////////////////////////////////////////////////////////// | 649 //////////////////////////////////////////////////////////////////////////////// |
| 653 // ConstrainedWindow, public: | 650 // ConstrainedWindow, public: |
| 654 | 651 |
| 655 // static | 652 // static |
| 656 ConstrainedWindow* ConstrainedWindow::CreateConstrainedDialog( | 653 ConstrainedWindow* ConstrainedWindow::CreateConstrainedDialog( |
| 657 TabContents* parent, | 654 TabContents* parent, |
| 658 views::WindowDelegate* window_delegate) { | 655 views::WindowDelegate* window_delegate) { |
| 659 return new ConstrainedWindowViews(parent, window_delegate); | 656 return new ConstrainedWindowViews(parent, window_delegate); |
| 660 } | 657 } |
| OLD | NEW |