| 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 <windows.h> | 5 #include <windows.h> |
| 6 #include <uxtheme.h> | 6 #include <uxtheme.h> |
| 7 #include <vsstyle.h> | 7 #include <vsstyle.h> |
| 8 | 8 |
| 9 #include "chrome/views/dialog_client_view.h" | 9 #include "chrome/views/dialog_client_view.h" |
| 10 | 10 |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 60 AreAcceleratorsEnabled(type_)) { | 60 AreAcceleratorsEnabled(type_)) { |
| 61 return false; | 61 return false; |
| 62 } | 62 } |
| 63 return NativeButton::AcceleratorPressed(accelerator); | 63 return NativeButton::AcceleratorPressed(accelerator); |
| 64 } | 64 } |
| 65 | 65 |
| 66 private: | 66 private: |
| 67 Window* owner_; | 67 Window* owner_; |
| 68 const DialogDelegate::DialogButton type_; | 68 const DialogDelegate::DialogButton type_; |
| 69 | 69 |
| 70 DISALLOW_EVIL_CONSTRUCTORS(DialogButton); | 70 DISALLOW_COPY_AND_ASSIGN(DialogButton); |
| 71 }; | 71 }; |
| 72 | 72 |
| 73 } // namespace | 73 } // namespace |
| 74 | 74 |
| 75 // static | 75 // static |
| 76 ChromeFont DialogClientView::dialog_button_font_; | 76 ChromeFont DialogClientView::dialog_button_font_; |
| 77 static const int kDialogMinButtonWidth = 75; | 77 static const int kDialogMinButtonWidth = 75; |
| 78 static const int kDialogButtonLabelSpacing = 16; | 78 static const int kDialogButtonLabelSpacing = 16; |
| 79 static const int kDialogButtonContentSpacing = 5; | 79 static const int kDialogButtonContentSpacing = 5; |
| 80 | 80 |
| (...skipping 26 matching lines...) Expand all Loading... |
| 107 if (label.empty()) | 107 if (label.empty()) |
| 108 label = l10n_util::GetString(IDS_OK); | 108 label = l10n_util::GetString(IDS_OK); |
| 109 bool is_default_button = | 109 bool is_default_button = |
| 110 (dd->GetDefaultDialogButton() & DialogDelegate::DIALOGBUTTON_OK) != 0; | 110 (dd->GetDefaultDialogButton() & DialogDelegate::DIALOGBUTTON_OK) != 0; |
| 111 ok_button_ = new DialogButton(window(), DialogDelegate::DIALOGBUTTON_OK, | 111 ok_button_ = new DialogButton(window(), DialogDelegate::DIALOGBUTTON_OK, |
| 112 label, is_default_button); | 112 label, is_default_button); |
| 113 ok_button_->SetListener(this); | 113 ok_button_->SetListener(this); |
| 114 ok_button_->SetGroup(kButtonGroup); | 114 ok_button_->SetGroup(kButtonGroup); |
| 115 if (is_default_button) | 115 if (is_default_button) |
| 116 default_button_ = ok_button_; | 116 default_button_ = ok_button_; |
| 117 if (!cancel_button_) | 117 if (!(buttons & DialogDelegate::DIALOGBUTTON_CANCEL)) |
| 118 ok_button_->AddAccelerator(Accelerator(VK_ESCAPE, false, false, false)); | 118 ok_button_->AddAccelerator(Accelerator(VK_ESCAPE, false, false, false)); |
| 119 AddChildView(ok_button_); | 119 AddChildView(ok_button_); |
| 120 } | 120 } |
| 121 if (buttons & DialogDelegate::DIALOGBUTTON_CANCEL && !cancel_button_) { | 121 if (buttons & DialogDelegate::DIALOGBUTTON_CANCEL && !cancel_button_) { |
| 122 std::wstring label = | 122 std::wstring label = |
| 123 dd->GetDialogButtonLabel(DialogDelegate::DIALOGBUTTON_CANCEL); | 123 dd->GetDialogButtonLabel(DialogDelegate::DIALOGBUTTON_CANCEL); |
| 124 if (label.empty()) { | 124 if (label.empty()) { |
| 125 if (buttons & DialogDelegate::DIALOGBUTTON_OK) { | 125 if (buttons & DialogDelegate::DIALOGBUTTON_OK) { |
| 126 label = l10n_util::GetString(IDS_CANCEL); | 126 label = l10n_util::GetString(IDS_CANCEL); |
| 127 } else { | 127 } else { |
| (...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 266 // Can only add and update the dialog buttons _after_ they are added to the | 266 // Can only add and update the dialog buttons _after_ they are added to the |
| 267 // view hierarchy since they are native controls and require the | 267 // view hierarchy since they are native controls and require the |
| 268 // Container's HWND. | 268 // Container's HWND. |
| 269 ShowDialogButtons(); | 269 ShowDialogButtons(); |
| 270 ClientView::ViewHierarchyChanged(is_add, parent, child); | 270 ClientView::ViewHierarchyChanged(is_add, parent, child); |
| 271 | 271 |
| 272 FocusManager* focus_manager = GetFocusManager(); | 272 FocusManager* focus_manager = GetFocusManager(); |
| 273 // Listen for focus change events so we can update the default button. | 273 // Listen for focus change events so we can update the default button. |
| 274 DCHECK(focus_manager); // bug #1291225: crash reports seem to indicate it | 274 DCHECK(focus_manager); // bug #1291225: crash reports seem to indicate it |
| 275 // can be NULL. | 275 // can be NULL. |
| 276 if (focus_manager) | 276 if (focus_manager) |
| 277 focus_manager->AddFocusChangeListener(this); | 277 focus_manager->AddFocusChangeListener(this); |
| 278 | 278 |
| 279 // The "extra view" must be created and installed after the contents view | 279 // The "extra view" must be created and installed after the contents view |
| 280 // has been inserted into the view hierarchy. | 280 // has been inserted into the view hierarchy. |
| 281 CreateExtraView(); | 281 CreateExtraView(); |
| 282 UpdateDialogButtons(); | 282 UpdateDialogButtons(); |
| 283 Layout(); | 283 Layout(); |
| 284 } | 284 } |
| 285 } | 285 } |
| 286 | 286 |
| (...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 426 static bool initialized = false; | 426 static bool initialized = false; |
| 427 if (!initialized) { | 427 if (!initialized) { |
| 428 ResourceBundle& rb = ResourceBundle::GetSharedInstance(); | 428 ResourceBundle& rb = ResourceBundle::GetSharedInstance(); |
| 429 dialog_button_font_ = rb.GetFont(ResourceBundle::BaseFont); | 429 dialog_button_font_ = rb.GetFont(ResourceBundle::BaseFont); |
| 430 initialized = true; | 430 initialized = true; |
| 431 } | 431 } |
| 432 } | 432 } |
| 433 | 433 |
| 434 } // namespace views | 434 } // namespace views |
| 435 | 435 |
| OLD | NEW |