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/dialog_client_view.h" | 5 #include "views/window/dialog_client_view.h" |
6 | 6 |
7 #if defined(OS_WIN) | 7 #if defined(OS_WIN) |
8 #include <windows.h> | 8 #include <windows.h> |
9 #include <uxtheme.h> | 9 #include <uxtheme.h> |
10 #include <vsstyle.h> | 10 #include <vsstyle.h> |
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
132 if (buttons & MessageBoxFlags::DIALOGBUTTON_OK && !ok_button_) { | 132 if (buttons & MessageBoxFlags::DIALOGBUTTON_OK && !ok_button_) { |
133 std::wstring label = | 133 std::wstring label = |
134 dd->GetDialogButtonLabel(MessageBoxFlags::DIALOGBUTTON_OK); | 134 dd->GetDialogButtonLabel(MessageBoxFlags::DIALOGBUTTON_OK); |
135 if (label.empty()) | 135 if (label.empty()) |
136 label = UTF16ToWide(l10n_util::GetStringUTF16(IDS_APP_OK)); | 136 label = UTF16ToWide(l10n_util::GetStringUTF16(IDS_APP_OK)); |
137 bool is_default_button = | 137 bool is_default_button = |
138 (dd->GetDefaultDialogButton() & MessageBoxFlags::DIALOGBUTTON_OK) != 0; | 138 (dd->GetDefaultDialogButton() & MessageBoxFlags::DIALOGBUTTON_OK) != 0; |
139 ok_button_ = new DialogButton(this, window(), | 139 ok_button_ = new DialogButton(this, window(), |
140 MessageBoxFlags::DIALOGBUTTON_OK, label, | 140 MessageBoxFlags::DIALOGBUTTON_OK, label, |
141 is_default_button); | 141 is_default_button); |
142 ok_button_->SetGroup(kButtonGroup); | 142 ok_button_->set_group(kButtonGroup); |
143 if (is_default_button) | 143 if (is_default_button) |
144 default_button_ = ok_button_; | 144 default_button_ = ok_button_; |
145 if (!(buttons & MessageBoxFlags::DIALOGBUTTON_CANCEL)) | 145 if (!(buttons & MessageBoxFlags::DIALOGBUTTON_CANCEL)) |
146 ok_button_->AddAccelerator(Accelerator(ui::VKEY_ESCAPE, | 146 ok_button_->AddAccelerator(Accelerator(ui::VKEY_ESCAPE, |
147 false, false, false)); | 147 false, false, false)); |
148 AddChildView(ok_button_); | 148 AddChildView(ok_button_); |
149 } | 149 } |
150 if (buttons & MessageBoxFlags::DIALOGBUTTON_CANCEL && !cancel_button_) { | 150 if (buttons & MessageBoxFlags::DIALOGBUTTON_CANCEL && !cancel_button_) { |
151 std::wstring label = | 151 std::wstring label = |
152 dd->GetDialogButtonLabel(MessageBoxFlags::DIALOGBUTTON_CANCEL); | 152 dd->GetDialogButtonLabel(MessageBoxFlags::DIALOGBUTTON_CANCEL); |
153 if (label.empty()) { | 153 if (label.empty()) { |
154 if (buttons & MessageBoxFlags::DIALOGBUTTON_OK) { | 154 if (buttons & MessageBoxFlags::DIALOGBUTTON_OK) { |
155 label = UTF16ToWide(l10n_util::GetStringUTF16(IDS_APP_CANCEL)); | 155 label = UTF16ToWide(l10n_util::GetStringUTF16(IDS_APP_CANCEL)); |
156 } else { | 156 } else { |
157 label = UTF16ToWide(l10n_util::GetStringUTF16(IDS_APP_CLOSE)); | 157 label = UTF16ToWide(l10n_util::GetStringUTF16(IDS_APP_CLOSE)); |
158 } | 158 } |
159 } | 159 } |
160 bool is_default_button = | 160 bool is_default_button = |
161 (dd->GetDefaultDialogButton() & MessageBoxFlags::DIALOGBUTTON_CANCEL) | 161 (dd->GetDefaultDialogButton() & MessageBoxFlags::DIALOGBUTTON_CANCEL) |
162 != 0; | 162 != 0; |
163 cancel_button_ = new DialogButton(this, window(), | 163 cancel_button_ = new DialogButton(this, window(), |
164 MessageBoxFlags::DIALOGBUTTON_CANCEL, | 164 MessageBoxFlags::DIALOGBUTTON_CANCEL, |
165 label, is_default_button); | 165 label, is_default_button); |
166 cancel_button_->SetGroup(kButtonGroup); | 166 cancel_button_->set_group(kButtonGroup); |
167 cancel_button_->AddAccelerator(Accelerator(ui::VKEY_ESCAPE, | 167 cancel_button_->AddAccelerator(Accelerator(ui::VKEY_ESCAPE, |
168 false, false, false)); | 168 false, false, false)); |
169 if (is_default_button) | 169 if (is_default_button) |
170 default_button_ = ok_button_; | 170 default_button_ = ok_button_; |
171 AddChildView(cancel_button_); | 171 AddChildView(cancel_button_); |
172 } | 172 } |
173 if (!buttons) { | 173 if (!buttons) { |
174 // Register the escape key as an accelerator which will close the window | 174 // Register the escape key as an accelerator which will close the window |
175 // if there are no dialog buttons. | 175 // if there are no dialog buttons. |
176 AddAccelerator(Accelerator(ui::VKEY_ESCAPE, false, false, false)); | 176 AddAccelerator(Accelerator(ui::VKEY_ESCAPE, false, false, false)); |
(...skipping 347 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
524 gfx::Rect lb = GetContentsBounds(); | 524 gfx::Rect lb = GetContentsBounds(); |
525 lb.set_height(std::max(0, lb.height() - GetButtonsHeight())); | 525 lb.set_height(std::max(0, lb.height() - GetButtonsHeight())); |
526 contents_view()->SetBoundsRect(lb); | 526 contents_view()->SetBoundsRect(lb); |
527 contents_view()->Layout(); | 527 contents_view()->Layout(); |
528 } | 528 } |
529 | 529 |
530 void DialogClientView::CreateExtraView() { | 530 void DialogClientView::CreateExtraView() { |
531 View* extra_view = GetDialogDelegate()->GetExtraView(); | 531 View* extra_view = GetDialogDelegate()->GetExtraView(); |
532 if (extra_view && !extra_view_) { | 532 if (extra_view && !extra_view_) { |
533 extra_view_ = extra_view; | 533 extra_view_ = extra_view; |
534 extra_view_->SetGroup(kButtonGroup); | 534 extra_view_->set_group(kButtonGroup); |
535 AddChildView(extra_view_); | 535 AddChildView(extra_view_); |
536 size_extra_view_height_to_buttons_ = | 536 size_extra_view_height_to_buttons_ = |
537 GetDialogDelegate()->GetSizeExtraViewHeightToButtons(); | 537 GetDialogDelegate()->GetSizeExtraViewHeightToButtons(); |
538 } | 538 } |
539 } | 539 } |
540 | 540 |
541 DialogDelegate* DialogClientView::GetDialogDelegate() const { | 541 DialogDelegate* DialogClientView::GetDialogDelegate() const { |
542 return window()->window_delegate()->AsDialogDelegate(); | 542 return window()->window_delegate()->AsDialogDelegate(); |
543 } | 543 } |
544 | 544 |
(...skipping 28 matching lines...) Expand all Loading... |
573 void DialogClientView::InitClass() { | 573 void DialogClientView::InitClass() { |
574 static bool initialized = false; | 574 static bool initialized = false; |
575 if (!initialized) { | 575 if (!initialized) { |
576 ResourceBundle& rb = ResourceBundle::GetSharedInstance(); | 576 ResourceBundle& rb = ResourceBundle::GetSharedInstance(); |
577 dialog_button_font_ = new gfx::Font(rb.GetFont(ResourceBundle::BaseFont)); | 577 dialog_button_font_ = new gfx::Font(rb.GetFont(ResourceBundle::BaseFont)); |
578 initialized = true; | 578 initialized = true; |
579 } | 579 } |
580 } | 580 } |
581 | 581 |
582 } // namespace views | 582 } // namespace views |
OLD | NEW |