| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "base/utf_string_conversions.h" | 9 #include "base/utf_string_conversions.h" |
| 10 #include "chrome/app/chrome_command_ids.h" | 10 #include "chrome/app/chrome_command_ids.h" |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 56 #endif | 56 #endif |
| 57 | 57 |
| 58 using base::TimeDelta; | 58 using base::TimeDelta; |
| 59 | 59 |
| 60 namespace views { | 60 namespace views { |
| 61 class ClientView; | 61 class ClientView; |
| 62 } | 62 } |
| 63 | 63 |
| 64 // An enumeration of bitmap resources used by this window. | 64 // An enumeration of bitmap resources used by this window. |
| 65 enum { | 65 enum { |
| 66 FRAME_PART_BITMAP_FIRST = 0, // Must be first. | 66 FRAME_PART_IMAGE_FIRST = 0, // Must be first. |
| 67 | 67 |
| 68 // Window Frame Border. | 68 // Window Frame Border. |
| 69 FRAME_BOTTOM_EDGE, | 69 FRAME_BOTTOM_EDGE, |
| 70 FRAME_BOTTOM_LEFT_CORNER, | 70 FRAME_BOTTOM_LEFT_CORNER, |
| 71 FRAME_BOTTOM_RIGHT_CORNER, | 71 FRAME_BOTTOM_RIGHT_CORNER, |
| 72 FRAME_LEFT_EDGE, | 72 FRAME_LEFT_EDGE, |
| 73 FRAME_RIGHT_EDGE, | 73 FRAME_RIGHT_EDGE, |
| 74 FRAME_TOP_EDGE, | 74 FRAME_TOP_EDGE, |
| 75 FRAME_TOP_LEFT_CORNER, | 75 FRAME_TOP_LEFT_CORNER, |
| 76 FRAME_TOP_RIGHT_CORNER, | 76 FRAME_TOP_RIGHT_CORNER, |
| 77 | 77 |
| 78 FRAME_PART_BITMAP_COUNT // Must be last. | 78 FRAME_PART_IMAGE_COUNT // Must be last. |
| 79 }; | 79 }; |
| 80 | 80 |
| 81 static const int kXPFramePartIDs[] = { | 81 static const int kXPFramePartIDs[] = { |
| 82 0, | 82 0, |
| 83 IDR_WINDOW_BOTTOM_CENTER, IDR_WINDOW_BOTTOM_LEFT_CORNER, | 83 IDR_WINDOW_BOTTOM_CENTER, IDR_WINDOW_BOTTOM_LEFT_CORNER, |
| 84 IDR_WINDOW_BOTTOM_RIGHT_CORNER, IDR_WINDOW_LEFT_SIDE, | 84 IDR_WINDOW_BOTTOM_RIGHT_CORNER, IDR_WINDOW_LEFT_SIDE, |
| 85 IDR_WINDOW_RIGHT_SIDE, IDR_WINDOW_TOP_CENTER, | 85 IDR_WINDOW_RIGHT_SIDE, IDR_WINDOW_TOP_CENTER, |
| 86 IDR_WINDOW_TOP_LEFT_CORNER, IDR_WINDOW_TOP_RIGHT_CORNER, | 86 IDR_WINDOW_TOP_LEFT_CORNER, IDR_WINDOW_TOP_RIGHT_CORNER, |
| 87 0 }; | 87 0 }; |
| 88 static const int kVistaFramePartIDs[] = { | 88 static const int kVistaFramePartIDs[] = { |
| 89 0, | 89 0, |
| 90 IDR_CONSTRAINED_BOTTOM_CENTER_V, IDR_CONSTRAINED_BOTTOM_LEFT_CORNER_V, | 90 IDR_CONSTRAINED_BOTTOM_CENTER_V, IDR_CONSTRAINED_BOTTOM_LEFT_CORNER_V, |
| 91 IDR_CONSTRAINED_BOTTOM_RIGHT_CORNER_V, IDR_CONSTRAINED_LEFT_SIDE_V, | 91 IDR_CONSTRAINED_BOTTOM_RIGHT_CORNER_V, IDR_CONSTRAINED_LEFT_SIDE_V, |
| 92 IDR_CONSTRAINED_RIGHT_SIDE_V, IDR_CONSTRAINED_TOP_CENTER_V, | 92 IDR_CONSTRAINED_RIGHT_SIDE_V, IDR_CONSTRAINED_TOP_CENTER_V, |
| 93 IDR_CONSTRAINED_TOP_LEFT_CORNER_V, IDR_CONSTRAINED_TOP_RIGHT_CORNER_V, | 93 IDR_CONSTRAINED_TOP_LEFT_CORNER_V, IDR_CONSTRAINED_TOP_RIGHT_CORNER_V, |
| 94 0 }; | 94 0 }; |
| 95 | 95 |
| 96 class XPWindowResources : public views::WindowResources { | 96 class XPWindowResources : public views::WindowResources { |
| 97 public: | 97 public: |
| 98 XPWindowResources() { | 98 XPWindowResources() { |
| 99 InitClass(); | 99 InitClass(); |
| 100 } | 100 } |
| 101 virtual ~XPWindowResources() {} | 101 virtual ~XPWindowResources() {} |
| 102 | 102 |
| 103 virtual SkBitmap* GetPartBitmap(views::FramePartBitmap part_id) const { | 103 virtual gfx::ImageSkia* GetPartImage(views::FramePartImage part_id) const { |
| 104 return bitmaps_[part_id]; | 104 return images_[part_id]; |
| 105 } | 105 } |
| 106 | 106 |
| 107 private: | 107 private: |
| 108 static void InitClass() { | 108 static void InitClass() { |
| 109 static bool initialized = false; | 109 static bool initialized = false; |
| 110 if (!initialized) { | 110 if (!initialized) { |
| 111 ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance(); | 111 ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance(); |
| 112 for (int i = 0; i < FRAME_PART_BITMAP_COUNT; ++i) { | 112 for (int i = 0; i < FRAME_PART_IMAGE_COUNT; ++i) { |
| 113 int id = kXPFramePartIDs[i]; | 113 int id = kXPFramePartIDs[i]; |
| 114 if (id != 0) | 114 if (id != 0) |
| 115 bitmaps_[i] = rb.GetBitmapNamed(id); | 115 images_[i] = rb.GetImageSkiaNamed(id); |
| 116 } | 116 } |
| 117 initialized = true; | 117 initialized = true; |
| 118 } | 118 } |
| 119 } | 119 } |
| 120 | 120 |
| 121 static SkBitmap* bitmaps_[FRAME_PART_BITMAP_COUNT]; | 121 static gfx::ImageSkia* images_[FRAME_PART_IMAGE_COUNT]; |
| 122 | 122 |
| 123 DISALLOW_COPY_AND_ASSIGN(XPWindowResources); | 123 DISALLOW_COPY_AND_ASSIGN(XPWindowResources); |
| 124 }; | 124 }; |
| 125 | 125 |
| 126 class VistaWindowResources : public views::WindowResources { | 126 class VistaWindowResources : public views::WindowResources { |
| 127 public: | 127 public: |
| 128 VistaWindowResources() { | 128 VistaWindowResources() { |
| 129 InitClass(); | 129 InitClass(); |
| 130 } | 130 } |
| 131 virtual ~VistaWindowResources() {} | 131 virtual ~VistaWindowResources() {} |
| 132 | 132 |
| 133 virtual SkBitmap* GetPartBitmap(views::FramePartBitmap part_id) const { | 133 virtual gfx::ImageSkia* GetPartImage(views::FramePartImage part_id) const { |
| 134 return bitmaps_[part_id]; | 134 return images_[part_id]; |
| 135 } | 135 } |
| 136 | 136 |
| 137 private: | 137 private: |
| 138 static void InitClass() { | 138 static void InitClass() { |
| 139 static bool initialized = false; | 139 static bool initialized = false; |
| 140 if (!initialized) { | 140 if (!initialized) { |
| 141 ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance(); | 141 ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance(); |
| 142 for (int i = 0; i < FRAME_PART_BITMAP_COUNT; ++i) { | 142 for (int i = 0; i < FRAME_PART_IMAGE_COUNT; ++i) { |
| 143 int id = kVistaFramePartIDs[i]; | 143 int id = kVistaFramePartIDs[i]; |
| 144 if (id != 0) | 144 if (id != 0) |
| 145 bitmaps_[i] = rb.GetBitmapNamed(id); | 145 images_[i] = rb.GetImageSkiaNamed(id); |
| 146 } | 146 } |
| 147 initialized = true; | 147 initialized = true; |
| 148 } | 148 } |
| 149 } | 149 } |
| 150 | 150 |
| 151 static SkBitmap* bitmaps_[FRAME_PART_BITMAP_COUNT]; | 151 static gfx::ImageSkia* images_[FRAME_PART_IMAGE_COUNT]; |
| 152 | 152 |
| 153 DISALLOW_COPY_AND_ASSIGN(VistaWindowResources); | 153 DISALLOW_COPY_AND_ASSIGN(VistaWindowResources); |
| 154 }; | 154 }; |
| 155 | 155 |
| 156 SkBitmap* XPWindowResources::bitmaps_[]; | 156 gfx::ImageSkia* XPWindowResources::images_[]; |
| 157 SkBitmap* VistaWindowResources::bitmaps_[]; | 157 gfx::ImageSkia* VistaWindowResources::images_[]; |
| 158 | 158 |
| 159 //////////////////////////////////////////////////////////////////////////////// | 159 //////////////////////////////////////////////////////////////////////////////// |
| 160 // ConstrainedWindowFrameView | 160 // ConstrainedWindowFrameView |
| 161 | 161 |
| 162 class ConstrainedWindowFrameView : public views::NonClientFrameView, | 162 class ConstrainedWindowFrameView : public views::NonClientFrameView, |
| 163 public views::ButtonListener { | 163 public views::ButtonListener { |
| 164 public: | 164 public: |
| 165 explicit ConstrainedWindowFrameView(ConstrainedWindowViews* container); | 165 explicit ConstrainedWindowFrameView(ConstrainedWindowViews* container); |
| 166 virtual ~ConstrainedWindowFrameView(); | 166 virtual ~ConstrainedWindowFrameView(); |
| 167 | 167 |
| (...skipping 267 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 435 // eye) more like additional space than does the 3D edge above; hence the +1. | 435 // eye) more like additional space than does the 3D edge above; hence the +1. |
| 436 int y = unavailable_px_at_top + (NonClientTopBorderHeight() - | 436 int y = unavailable_px_at_top + (NonClientTopBorderHeight() - |
| 437 unavailable_px_at_top - size - TitlebarBottomThickness() + 1) / 2; | 437 unavailable_px_at_top - size - TitlebarBottomThickness() + 1) / 2; |
| 438 return gfx::Rect(kFrameBorderThickness + kTitleLeftSpacing, y, size, size); | 438 return gfx::Rect(kFrameBorderThickness + kTitleLeftSpacing, y, size, size); |
| 439 } | 439 } |
| 440 | 440 |
| 441 void ConstrainedWindowFrameView::PaintFrameBorder(gfx::Canvas* canvas) { | 441 void ConstrainedWindowFrameView::PaintFrameBorder(gfx::Canvas* canvas) { |
| 442 ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance(); | 442 ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance(); |
| 443 frame_background_->set_frame_color(ThemeService::GetDefaultColor( | 443 frame_background_->set_frame_color(ThemeService::GetDefaultColor( |
| 444 ThemeService::COLOR_FRAME)); | 444 ThemeService::COLOR_FRAME)); |
| 445 SkBitmap* theme_frame = rb.GetBitmapNamed(IDR_THEME_FRAME); | 445 gfx::ImageSkia* theme_frame = rb.GetImageSkiaNamed(IDR_THEME_FRAME); |
| 446 frame_background_->set_theme_bitmap(theme_frame); | 446 frame_background_->set_theme_image(theme_frame); |
| 447 frame_background_->set_theme_overlay_bitmap(NULL); | 447 frame_background_->set_theme_overlay_image(NULL); |
| 448 frame_background_->set_top_area_height(theme_frame->height()); | 448 frame_background_->set_top_area_height(theme_frame->height()); |
| 449 | 449 |
| 450 frame_background_->SetCornerImages( | 450 frame_background_->SetCornerImages( |
| 451 resources_->GetPartBitmap(FRAME_TOP_LEFT_CORNER), | 451 resources_->GetPartImage(FRAME_TOP_LEFT_CORNER), |
| 452 resources_->GetPartBitmap(FRAME_TOP_RIGHT_CORNER), | 452 resources_->GetPartImage(FRAME_TOP_RIGHT_CORNER), |
| 453 resources_->GetPartBitmap(FRAME_BOTTOM_LEFT_CORNER), | 453 resources_->GetPartImage(FRAME_BOTTOM_LEFT_CORNER), |
| 454 resources_->GetPartBitmap(FRAME_BOTTOM_RIGHT_CORNER)); | 454 resources_->GetPartImage(FRAME_BOTTOM_RIGHT_CORNER)); |
| 455 frame_background_->SetSideImages( | 455 frame_background_->SetSideImages( |
| 456 resources_->GetPartBitmap(FRAME_LEFT_EDGE), | 456 resources_->GetPartImage(FRAME_LEFT_EDGE), |
| 457 resources_->GetPartBitmap(FRAME_TOP_EDGE), | 457 resources_->GetPartImage(FRAME_TOP_EDGE), |
| 458 resources_->GetPartBitmap(FRAME_RIGHT_EDGE), | 458 resources_->GetPartImage(FRAME_RIGHT_EDGE), |
| 459 resources_->GetPartBitmap(FRAME_BOTTOM_EDGE)); | 459 resources_->GetPartImage(FRAME_BOTTOM_EDGE)); |
| 460 frame_background_->PaintRestored(canvas, this); | 460 frame_background_->PaintRestored(canvas, this); |
| 461 } | 461 } |
| 462 | 462 |
| 463 void ConstrainedWindowFrameView::PaintTitleBar(gfx::Canvas* canvas) { | 463 void ConstrainedWindowFrameView::PaintTitleBar(gfx::Canvas* canvas) { |
| 464 canvas->DrawStringInt( | 464 canvas->DrawStringInt( |
| 465 container_->widget_delegate()->GetWindowTitle(), | 465 container_->widget_delegate()->GetWindowTitle(), |
| 466 *title_font_, GetTitleColor(), GetMirroredXForRect(title_bounds_), | 466 *title_font_, GetTitleColor(), GetMirroredXForRect(title_bounds_), |
| 467 title_bounds_.y(), title_bounds_.width(), title_bounds_.height()); | 467 title_bounds_.y(), title_bounds_.width(), title_bounds_.height()); |
| 468 } | 468 } |
| 469 | 469 |
| (...skipping 182 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 652 } | 652 } |
| 653 | 653 |
| 654 void ConstrainedWindowViews::OnNativeConstrainedWindowMouseActivate() { | 654 void ConstrainedWindowViews::OnNativeConstrainedWindowMouseActivate() { |
| 655 Activate(); | 655 Activate(); |
| 656 } | 656 } |
| 657 | 657 |
| 658 views::internal::NativeWidgetDelegate* | 658 views::internal::NativeWidgetDelegate* |
| 659 ConstrainedWindowViews::AsNativeWidgetDelegate() { | 659 ConstrainedWindowViews::AsNativeWidgetDelegate() { |
| 660 return this; | 660 return this; |
| 661 } | 661 } |
| OLD | NEW |