| 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 "views/window/dialog_client_view.h" | 5 #include "views/window/dialog_client_view.h" |
| 6 | 6 |
| 7 #include <windows.h> | 7 #include <windows.h> |
| 8 #include <uxtheme.h> | 8 #include <uxtheme.h> |
| 9 #include <vsstyle.h> | 9 #include <vsstyle.h> |
| 10 | 10 |
| 11 #include "app/gfx/chrome_canvas.h" | 11 #include "app/gfx/canvas.h" |
| 12 #include "app/gfx/chrome_font.h" | 12 #include "app/gfx/font.h" |
| 13 #include "app/l10n_util.h" | 13 #include "app/l10n_util.h" |
| 14 #include "app/resource_bundle.h" | 14 #include "app/resource_bundle.h" |
| 15 #include "base/gfx/native_theme.h" | 15 #include "base/gfx/native_theme.h" |
| 16 #include "grit/generated_resources.h" | 16 #include "grit/generated_resources.h" |
| 17 #include "views/controls/button/native_button.h" | 17 #include "views/controls/button/native_button.h" |
| 18 #include "views/standard_layout.h" | 18 #include "views/standard_layout.h" |
| 19 #include "views/window/dialog_delegate.h" | 19 #include "views/window/dialog_delegate.h" |
| 20 #include "views/window/window.h" | 20 #include "views/window/window.h" |
| 21 | 21 |
| 22 namespace views { | 22 namespace views { |
| 23 | 23 |
| 24 namespace { | 24 namespace { |
| 25 | 25 |
| 26 // Updates any of the standard buttons according to the delegate. | 26 // Updates any of the standard buttons according to the delegate. |
| 27 void UpdateButtonHelper(NativeButton* button_view, | 27 void UpdateButtonHelper(NativeButton* button_view, |
| 28 DialogDelegate* delegate, | 28 DialogDelegate* delegate, |
| 29 MessageBoxFlags::DialogButton button) { | 29 MessageBoxFlags::DialogButton button) { |
| 30 std::wstring label = delegate->GetDialogButtonLabel(button); | 30 std::wstring label = delegate->GetDialogButtonLabel(button); |
| 31 if (!label.empty()) | 31 if (!label.empty()) |
| 32 button_view->SetLabel(label); | 32 button_view->SetLabel(label); |
| 33 button_view->SetEnabled(delegate->IsDialogButtonEnabled(button)); | 33 button_view->SetEnabled(delegate->IsDialogButtonEnabled(button)); |
| 34 button_view->SetVisible(delegate->IsDialogButtonVisible(button)); | 34 button_view->SetVisible(delegate->IsDialogButtonVisible(button)); |
| 35 } | 35 } |
| 36 | 36 |
| 37 void FillViewWithSysColor(ChromeCanvas* canvas, View* view, COLORREF color) { | 37 void FillViewWithSysColor(gfx::Canvas* canvas, View* view, COLORREF color) { |
| 38 SkColor sk_color = | 38 SkColor sk_color = |
| 39 SkColorSetRGB(GetRValue(color), GetGValue(color), GetBValue(color)); | 39 SkColorSetRGB(GetRValue(color), GetGValue(color), GetBValue(color)); |
| 40 canvas->FillRectInt(sk_color, 0, 0, view->width(), view->height()); | 40 canvas->FillRectInt(sk_color, 0, 0, view->width(), view->height()); |
| 41 } | 41 } |
| 42 | 42 |
| 43 // DialogButton ---------------------------------------------------------------- | 43 // DialogButton ---------------------------------------------------------------- |
| 44 | 44 |
| 45 // DialogButtons is used for the ok/cancel buttons of the window. DialogButton | 45 // DialogButtons is used for the ok/cancel buttons of the window. DialogButton |
| 46 // forwards AcceleratorPressed to the delegate. | 46 // forwards AcceleratorPressed to the delegate. |
| 47 | 47 |
| (...skipping 195 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 243 | 243 |
| 244 int DialogClientView::NonClientHitTest(const gfx::Point& point) { | 244 int DialogClientView::NonClientHitTest(const gfx::Point& point) { |
| 245 if (size_box_bounds_.Contains(point.x() - x(), point.y() - y())) | 245 if (size_box_bounds_.Contains(point.x() - x(), point.y() - y())) |
| 246 return HTBOTTOMRIGHT; | 246 return HTBOTTOMRIGHT; |
| 247 return ClientView::NonClientHitTest(point); | 247 return ClientView::NonClientHitTest(point); |
| 248 } | 248 } |
| 249 | 249 |
| 250 //////////////////////////////////////////////////////////////////////////////// | 250 //////////////////////////////////////////////////////////////////////////////// |
| 251 // DialogClientView, View overrides: | 251 // DialogClientView, View overrides: |
| 252 | 252 |
| 253 void DialogClientView::Paint(ChromeCanvas* canvas) { | 253 void DialogClientView::Paint(gfx::Canvas* canvas) { |
| 254 FillViewWithSysColor(canvas, this, GetSysColor(COLOR_3DFACE)); | 254 FillViewWithSysColor(canvas, this, GetSysColor(COLOR_3DFACE)); |
| 255 } | 255 } |
| 256 | 256 |
| 257 void DialogClientView::PaintChildren(ChromeCanvas* canvas) { | 257 void DialogClientView::PaintChildren(gfx::Canvas* canvas) { |
| 258 View::PaintChildren(canvas); | 258 View::PaintChildren(canvas); |
| 259 if (!window()->IsMaximized() && !window()->IsMinimized()) | 259 if (!window()->IsMaximized() && !window()->IsMinimized()) |
| 260 PaintSizeBox(canvas); | 260 PaintSizeBox(canvas); |
| 261 } | 261 } |
| 262 | 262 |
| 263 void DialogClientView::Layout() { | 263 void DialogClientView::Layout() { |
| 264 if (has_dialog_buttons()) | 264 if (has_dialog_buttons()) |
| 265 LayoutDialogButtons(); | 265 LayoutDialogButtons(); |
| 266 LayoutContentsView(); | 266 LayoutContentsView(); |
| 267 } | 267 } |
| (...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 340 } else if (sender == cancel_button_) { | 340 } else if (sender == cancel_button_) { |
| 341 CancelWindow(); | 341 CancelWindow(); |
| 342 } else { | 342 } else { |
| 343 NOTREACHED(); | 343 NOTREACHED(); |
| 344 } | 344 } |
| 345 } | 345 } |
| 346 | 346 |
| 347 //////////////////////////////////////////////////////////////////////////////// | 347 //////////////////////////////////////////////////////////////////////////////// |
| 348 // DialogClientView, private: | 348 // DialogClientView, private: |
| 349 | 349 |
| 350 void DialogClientView::PaintSizeBox(ChromeCanvas* canvas) { | 350 void DialogClientView::PaintSizeBox(gfx::Canvas* canvas) { |
| 351 if (window()->GetDelegate()->CanResize() || | 351 if (window()->GetDelegate()->CanResize() || |
| 352 window()->GetDelegate()->CanMaximize()) { | 352 window()->GetDelegate()->CanMaximize()) { |
| 353 HDC dc = canvas->beginPlatformPaint(); | 353 HDC dc = canvas->beginPlatformPaint(); |
| 354 SIZE gripper_size = { 0, 0 }; | 354 SIZE gripper_size = { 0, 0 }; |
| 355 gfx::NativeTheme::instance()->GetThemePartSize( | 355 gfx::NativeTheme::instance()->GetThemePartSize( |
| 356 gfx::NativeTheme::STATUS, dc, SP_GRIPPER, 1, NULL, TS_TRUE, | 356 gfx::NativeTheme::STATUS, dc, SP_GRIPPER, 1, NULL, TS_TRUE, |
| 357 &gripper_size); | 357 &gripper_size); |
| 358 | 358 |
| 359 // TODO(beng): (http://b/1085509) In "classic" rendering mode, there isn't | 359 // TODO(beng): (http://b/1085509) In "classic" rendering mode, there isn't |
| 360 // a theme-supplied gripper. We should probably improvise | 360 // a theme-supplied gripper. We should probably improvise |
| (...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 453 void DialogClientView::InitClass() { | 453 void DialogClientView::InitClass() { |
| 454 static bool initialized = false; | 454 static bool initialized = false; |
| 455 if (!initialized) { | 455 if (!initialized) { |
| 456 ResourceBundle& rb = ResourceBundle::GetSharedInstance(); | 456 ResourceBundle& rb = ResourceBundle::GetSharedInstance(); |
| 457 dialog_button_font_ = new gfx::Font(rb.GetFont(ResourceBundle::BaseFont)); | 457 dialog_button_font_ = new gfx::Font(rb.GetFont(ResourceBundle::BaseFont)); |
| 458 initialized = true; | 458 initialized = true; |
| 459 } | 459 } |
| 460 } | 460 } |
| 461 | 461 |
| 462 } // namespace views | 462 } // namespace views |
| OLD | NEW |