Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(4)

Side by Side Diff: ui/views/window/dialog_client_view.cc

Issue 11571023: Move ash/wm's DialogFrameView to ui/views/window; etc. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Reorder DialogDelegate functions; inline Get*Params into WidgetExample::ButtonPressed; etc. Created 8 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « ui/views/window/dialog_client_view.h ('k') | ui/views/window/dialog_delegate.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 "ui/views/window/dialog_client_view.h" 5 #include "ui/views/window/dialog_client_view.h"
6 6
7 #include "build/build_config.h" 7 #include "build/build_config.h"
8 8
9 #if defined(OS_WIN) 9 #if defined(OS_WIN)
10 #include <windows.h> 10 #include <windows.h>
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after
106 template <> const char DialogButton<NativeTextButton>::kViewClassName[] = 106 template <> const char DialogButton<NativeTextButton>::kViewClassName[] =
107 "NativeDialogButton"; 107 "NativeDialogButton";
108 108
109 template <> const char DialogButton<TextButton>::kViewClassName[] = 109 template <> const char DialogButton<TextButton>::kViewClassName[] =
110 "TextDialogButton"; 110 "TextDialogButton";
111 } // namespace 111 } // namespace
112 112
113 /////////////////////////////////////////////////////////////////////////////// 113 ///////////////////////////////////////////////////////////////////////////////
114 // DialogClientView, public: 114 // DialogClientView, public:
115 115
116 DialogClientView::StyleParams::StyleParams() 116 DialogClientView::DialogClientView(Widget* owner, View* contents_view)
117 : button_vedge_margin(kButtonVEdgeMargin),
118 button_hedge_margin(kButtonHEdgeMargin),
119 button_shadow_margin(0),
120 button_content_spacing(kDialogButtonContentSpacing),
121 related_button_hspacing(kRelatedButtonHSpacing) {
122 }
123
124 DialogClientView::DialogClientView(Widget* owner,
125 View* contents_view,
126 const StyleParams &params)
127 : ClientView(owner, contents_view), 117 : ClientView(owner, contents_view),
128 style_params_(params),
129 ok_button_(NULL), 118 ok_button_(NULL),
130 cancel_button_(NULL), 119 cancel_button_(NULL),
131 default_button_(NULL), 120 default_button_(NULL),
132 extra_view_(NULL), 121 extra_view_(NULL),
133 size_extra_view_height_to_buttons_(false), 122 size_extra_view_height_to_buttons_(false),
134 notified_delegate_(false), 123 notified_delegate_(false),
135 listening_to_focus_(false), 124 listening_to_focus_(false),
136 saved_focus_manager_(NULL) { 125 saved_focus_manager_(NULL) {
137 SkColor bg_color = owner->GetNativeTheme()->GetSystemColor( 126 SkColor bg_color = owner->GetNativeTheme()->GetSystemColor(
138 ui::NativeTheme::kColorId_DialogBackground); 127 ui::NativeTheme::kColorId_DialogBackground);
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
187 } 176 }
188 } 177 }
189 178
190 void DialogClientView::OnWillChangeFocus(View* focused_before, 179 void DialogClientView::OnWillChangeFocus(View* focused_before,
191 View* focused_now) { 180 View* focused_now) {
192 // Chrome style dialogs do not move the default button with the focus. 181 // Chrome style dialogs do not move the default button with the focus.
193 // TODO(wittman): Remove all support for updating the default button on focus 182 // TODO(wittman): Remove all support for updating the default button on focus
194 // change once we move completely to Chrome style. See 183 // change once we move completely to Chrome style. See
195 // http://codereview.chromium.org/10230 for a rough idea of changes to be 184 // http://codereview.chromium.org/10230 for a rough idea of changes to be
196 // undone. 185 // undone.
197 if (GetDialogDelegate()->UseChromeStyle()) 186 if (DialogDelegate::UseNewStyle())
198 return; 187 return;
199 188
200 TextButton* new_default_button = NULL; 189 TextButton* new_default_button = NULL;
201 // TODO(wittman): Identify TextButtons in a better way than 190 // TODO(wittman): Identify TextButtons in a better way than
202 // enumerating every possible subclass. 191 // enumerating every possible subclass.
203 if (focused_now && 192 if (focused_now &&
204 ((focused_now->GetClassName() == NativeTextButton::kViewClassName) || 193 ((focused_now->GetClassName() == NativeTextButton::kViewClassName) ||
205 (focused_now->GetClassName() == TextButton::kViewClassName) || 194 (focused_now->GetClassName() == TextButton::kViewClassName) ||
206 (focused_now->GetClassName() == 195 (focused_now->GetClassName() ==
207 DialogButton<NativeTextButton>::kViewClassName) || 196 DialogButton<NativeTextButton>::kViewClassName) ||
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
253 } 242 }
254 } 243 }
255 244
256 void DialogClientView::CancelWindow() { 245 void DialogClientView::CancelWindow() {
257 // Call the standard Close handler, which checks with the delegate before 246 // Call the standard Close handler, which checks with the delegate before
258 // proceeding. This checking _isn't_ done here, but in the WM_CLOSE handler, 247 // proceeding. This checking _isn't_ done here, but in the WM_CLOSE handler,
259 // so that the close box on the window also shares this code path. 248 // so that the close box on the window also shares this code path.
260 Close(); 249 Close();
261 } 250 }
262 251
263 // static
264 DialogClientView::StyleParams DialogClientView::GetChromeStyleParams() {
265 StyleParams params;
266 params.button_vedge_margin = 0;
267 params.button_hedge_margin = 0;
268 params.button_shadow_margin = views::GetChromeStyleButtonShadowMargin();
269 params.button_content_spacing = 0;
270 params.related_button_hspacing = 10;
271 return params;
272 }
273
274 int DialogClientView::GetBottomMargin() { 252 int DialogClientView::GetBottomMargin() {
275 return style_params_.button_shadow_margin; 253 return style_params_.button_shadow_margin;
276 } 254 }
277 255
278 /////////////////////////////////////////////////////////////////////////////// 256 ///////////////////////////////////////////////////////////////////////////////
279 // DialogClientView, View overrides: 257 // DialogClientView, View overrides:
280 258
281 void DialogClientView::NativeViewHierarchyChanged( 259 void DialogClientView::NativeViewHierarchyChanged(
282 bool attached, 260 bool attached,
283 gfx::NativeView native_view, 261 gfx::NativeView native_view,
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after
411 } else if (sender == cancel_button_) { 389 } else if (sender == cancel_button_) {
412 CancelWindow(); 390 CancelWindow();
413 } else { 391 } else {
414 NOTREACHED(); 392 NOTREACHED();
415 } 393 }
416 } 394 }
417 395
418 //////////////////////////////////////////////////////////////////////////////// 396 ////////////////////////////////////////////////////////////////////////////////
419 // DialogClientView, private: 397 // DialogClientView, private:
420 398
399 DialogClientView::StyleParams::StyleParams()
400 : button_vedge_margin(kButtonVEdgeMargin),
401 button_hedge_margin(kButtonHEdgeMargin),
402 button_shadow_margin(0),
403 button_content_spacing(kDialogButtonContentSpacing),
404 related_button_hspacing(kRelatedButtonHSpacing) {
405 if (DialogDelegate::UseNewStyle()) {
406 button_vedge_margin = 0;
407 button_hedge_margin = 0;
408 button_shadow_margin = GetChromeStyleButtonShadowMargin();
409 button_content_spacing = 0;
410 related_button_hspacing = 10;
411 }
412 }
413
421 TextButton* DialogClientView::CreateDialogButton(ui::DialogButton type, 414 TextButton* DialogClientView::CreateDialogButton(ui::DialogButton type,
422 const string16& title) { 415 const string16& title) {
423 TextButton* button = NULL; 416 TextButton* button = NULL;
424 if (GetDialogDelegate()->UseChromeStyle()) 417 if (DialogDelegate::UseNewStyle())
425 button = new DialogButton<TextButton>(this, GetWidget(), type, title); 418 button = new DialogButton<TextButton>(this, GetWidget(), type, title);
426 else 419 else
427 button = new DialogButton<NativeTextButton>(this, GetWidget(), type, title); 420 button = new DialogButton<NativeTextButton>(this, GetWidget(), type, title);
428 421
429 if (!GetDialogDelegate()->UseChromeStyle()) 422 if (!DialogDelegate::UseNewStyle())
430 button->set_min_width(kDialogMinButtonWidth); 423 button->set_min_width(kDialogMinButtonWidth);
431 424
432 button->SetGroup(kButtonGroup); 425 button->SetGroup(kButtonGroup);
433 426
434 if (GetDialogDelegate()->GetDefaultDialogButton() & type) { 427 if (GetDialogDelegate()->GetDefaultDialogButton() & type) {
435 default_button_ = button; 428 default_button_ = button;
436 button->SetIsDefault(true); 429 button->SetIsDefault(true);
437 } 430 }
438 431
439 if (GetDialogDelegate()->UseChromeStyle()) 432 if (DialogDelegate::UseNewStyle())
440 ApplyChromeStyle(button); 433 ApplyChromeStyle(button);
441 434
442 return button; 435 return button;
443 } 436 }
444 437
445 void DialogClientView::PaintSizeBox(gfx::Canvas* canvas) { 438 void DialogClientView::PaintSizeBox(gfx::Canvas* canvas) {
446 if (GetWidget()->widget_delegate()->CanResize() || 439 if (GetWidget()->widget_delegate()->CanResize() ||
447 GetWidget()->widget_delegate()->CanMaximize()) { 440 GetWidget()->widget_delegate()->CanMaximize()) {
448 #if defined(OS_WIN) 441 #if defined(OS_WIN)
449 ui::NativeTheme* theme = GetNativeTheme(); 442 ui::NativeTheme* theme = GetNativeTheme();
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after
569 } 562 }
570 saved_focus_manager_ = focus_manager; 563 saved_focus_manager_ = focus_manager;
571 // Listen for focus change events so we can update the default button. 564 // Listen for focus change events so we can update the default button.
572 if (focus_manager) { 565 if (focus_manager) {
573 focus_manager->AddFocusChangeListener(this); 566 focus_manager->AddFocusChangeListener(this);
574 listening_to_focus_ = true; 567 listening_to_focus_ = true;
575 } 568 }
576 } 569 }
577 570
578 } // namespace views 571 } // namespace views
OLDNEW
« no previous file with comments | « ui/views/window/dialog_client_view.h ('k') | ui/views/window/dialog_delegate.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698