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 "views/window/custom_frame_view.h" | 5 #include "views/window/custom_frame_view.h" |
6 | 6 |
7 #include "base/utf_string_conversions.h" | 7 #include "base/utf_string_conversions.h" |
8 #include "grit/app_resources.h" | 8 #include "grit/app_resources.h" |
9 #include "grit/app_strings.h" | 9 #include "grit/app_strings.h" |
10 #include "ui/base/l10n/l10n_util.h" | 10 #include "ui/base/l10n/l10n_util.h" |
(...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
150 | 150 |
151 int frame_component = frame_->GetClientView()->NonClientHitTest(point); | 151 int frame_component = frame_->GetClientView()->NonClientHitTest(point); |
152 | 152 |
153 // See if we're in the sysmenu region. (We check the ClientView first to be | 153 // See if we're in the sysmenu region. (We check the ClientView first to be |
154 // consistent with OpaqueBrowserFrameView; it's not really necessary here.) | 154 // consistent with OpaqueBrowserFrameView; it's not really necessary here.) |
155 gfx::Rect sysmenu_rect(IconBounds()); | 155 gfx::Rect sysmenu_rect(IconBounds()); |
156 // In maximized mode we extend the rect to the screen corner to take advantage | 156 // In maximized mode we extend the rect to the screen corner to take advantage |
157 // of Fitts' Law. | 157 // of Fitts' Law. |
158 if (frame_->IsMaximized()) | 158 if (frame_->IsMaximized()) |
159 sysmenu_rect.SetRect(0, 0, sysmenu_rect.right(), sysmenu_rect.bottom()); | 159 sysmenu_rect.SetRect(0, 0, sysmenu_rect.right(), sysmenu_rect.bottom()); |
160 sysmenu_rect.set_x(MirroredLeftPointForRect(sysmenu_rect)); | 160 sysmenu_rect.set_x(GetMirroredXForRect(sysmenu_rect)); |
161 if (sysmenu_rect.Contains(point)) | 161 if (sysmenu_rect.Contains(point)) |
162 return (frame_component == HTCLIENT) ? HTCLIENT : HTSYSMENU; | 162 return (frame_component == HTCLIENT) ? HTCLIENT : HTSYSMENU; |
163 | 163 |
164 if (frame_component != HTNOWHERE) | 164 if (frame_component != HTNOWHERE) |
165 return frame_component; | 165 return frame_component; |
166 | 166 |
167 // Then see if the point is within any of the window controls. | 167 // Then see if the point is within any of the window controls. |
168 if (close_button_->GetBounds(APPLY_MIRRORING_TRANSFORMATION).Contains(point)) | 168 if (close_button_->GetMirroredBounds().Contains(point)) |
169 return HTCLOSE; | 169 return HTCLOSE; |
170 if (restore_button_->GetBounds(APPLY_MIRRORING_TRANSFORMATION).Contains( | 170 if (restore_button_->GetMirroredBounds().Contains(point)) |
171 point)) | |
172 return HTMAXBUTTON; | 171 return HTMAXBUTTON; |
173 if (maximize_button_->GetBounds(APPLY_MIRRORING_TRANSFORMATION).Contains( | 172 if (maximize_button_->GetMirroredBounds().Contains(point)) |
174 point)) | |
175 return HTMAXBUTTON; | 173 return HTMAXBUTTON; |
176 if (minimize_button_->GetBounds(APPLY_MIRRORING_TRANSFORMATION).Contains( | 174 if (minimize_button_->GetMirroredBounds().Contains(point)) |
177 point)) | |
178 return HTMINBUTTON; | 175 return HTMINBUTTON; |
179 if (window_icon_ && | 176 if (window_icon_ && window_icon_->GetMirroredBounds().Contains(point)) |
180 window_icon_->GetBounds(APPLY_MIRRORING_TRANSFORMATION).Contains(point)) | |
181 return HTSYSMENU; | 177 return HTSYSMENU; |
182 | 178 |
183 int window_component = GetHTComponentForFrame(point, FrameBorderThickness(), | 179 int window_component = GetHTComponentForFrame(point, FrameBorderThickness(), |
184 NonClientBorderThickness(), kResizeAreaCornerSize, kResizeAreaCornerSize, | 180 NonClientBorderThickness(), kResizeAreaCornerSize, kResizeAreaCornerSize, |
185 frame_->GetDelegate()->CanResize()); | 181 frame_->GetDelegate()->CanResize()); |
186 // Fall back to the caption if no other component matches. | 182 // Fall back to the caption if no other component matches. |
187 return (window_component == HTNOWHERE) ? HTCAPTION : window_component; | 183 return (window_component == HTNOWHERE) ? HTCAPTION : window_component; |
188 } | 184 } |
189 | 185 |
190 void CustomFrameView::GetWindowMask(const gfx::Size& size, | 186 void CustomFrameView::GetWindowMask(const gfx::Size& size, |
(...skipping 216 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
407 void CustomFrameView::PaintTitleBar(gfx::Canvas* canvas) { | 403 void CustomFrameView::PaintTitleBar(gfx::Canvas* canvas) { |
408 WindowDelegate* d = frame_->GetDelegate(); | 404 WindowDelegate* d = frame_->GetDelegate(); |
409 | 405 |
410 // It seems like in some conditions we can be asked to paint after the window | 406 // It seems like in some conditions we can be asked to paint after the window |
411 // that contains us is WM_DESTROYed. At this point, our delegate is NULL. The | 407 // that contains us is WM_DESTROYed. At this point, our delegate is NULL. The |
412 // correct long term fix may be to shut down the RootView in WM_DESTROY. | 408 // correct long term fix may be to shut down the RootView in WM_DESTROY. |
413 if (!d) | 409 if (!d) |
414 return; | 410 return; |
415 | 411 |
416 canvas->DrawStringInt(WideToUTF16Hack(d->GetWindowTitle()), *title_font_, | 412 canvas->DrawStringInt(WideToUTF16Hack(d->GetWindowTitle()), *title_font_, |
417 SK_ColorWHITE, MirroredLeftPointForRect(title_bounds_), | 413 SK_ColorWHITE, GetMirroredXForRect(title_bounds_), |
418 title_bounds_.y(), title_bounds_.width(), | 414 title_bounds_.y(), title_bounds_.width(), |
419 title_bounds_.height()); | 415 title_bounds_.height()); |
420 } | 416 } |
421 | 417 |
422 void CustomFrameView::PaintRestoredClientEdge(gfx::Canvas* canvas) { | 418 void CustomFrameView::PaintRestoredClientEdge(gfx::Canvas* canvas) { |
423 gfx::Rect client_area_bounds = frame_->GetClientView()->bounds(); | 419 gfx::Rect client_area_bounds = frame_->GetClientView()->bounds(); |
424 int client_area_top = client_area_bounds.y(); | 420 int client_area_top = client_area_bounds.y(); |
425 | 421 |
426 ResourceBundle& rb = ResourceBundle::GetSharedInstance(); | 422 ResourceBundle& rb = ResourceBundle::GetSharedInstance(); |
427 SkBitmap* top_left = rb.GetBitmapNamed(IDR_APP_TOP_LEFT); | 423 SkBitmap* top_left = rb.GetBitmapNamed(IDR_APP_TOP_LEFT); |
(...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
574 title_font_ = new gfx::Font(WindowWin::GetWindowTitleFont()); | 570 title_font_ = new gfx::Font(WindowWin::GetWindowTitleFont()); |
575 #elif defined(OS_LINUX) | 571 #elif defined(OS_LINUX) |
576 // TODO(ben): need to resolve what font this is. | 572 // TODO(ben): need to resolve what font this is. |
577 title_font_ = new gfx::Font(); | 573 title_font_ = new gfx::Font(); |
578 #endif | 574 #endif |
579 initialized = true; | 575 initialized = true; |
580 } | 576 } |
581 } | 577 } |
582 | 578 |
583 } // namespace views | 579 } // namespace views |
OLD | NEW |