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 "chrome/browser/views/first_run_customize_view.h" | 5 #include "chrome/browser/views/first_run_customize_view.h" |
6 | 6 |
7 #include "chrome/app/locales/locale_settings.h" | 7 #include "chrome/app/locales/locale_settings.h" |
8 #include "chrome/app/theme/theme_resources.h" | 8 #include "chrome/app/theme/theme_resources.h" |
9 #include "chrome/browser/importer/importer.h" | 9 #include "chrome/browser/importer/importer.h" |
10 #include "chrome/browser/first_run.h" | 10 #include "chrome/browser/first_run.h" |
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
76 AddChildView(shortcuts_label_); | 76 AddChildView(shortcuts_label_); |
77 | 77 |
78 // The two check boxes for the different shortcut creation. | 78 // The two check boxes for the different shortcut creation. |
79 desktop_shortcut_cbox_ = MakeCheckBox(IDS_FR_CUSTOM_SHORTCUT_DESKTOP); | 79 desktop_shortcut_cbox_ = MakeCheckBox(IDS_FR_CUSTOM_SHORTCUT_DESKTOP); |
80 desktop_shortcut_cbox_->SetIsSelected(true); | 80 desktop_shortcut_cbox_->SetIsSelected(true); |
81 | 81 |
82 quick_shortcut_cbox_ = MakeCheckBox(IDS_FR_CUSTOM_SHORTCUT_QUICKL); | 82 quick_shortcut_cbox_ = MakeCheckBox(IDS_FR_CUSTOM_SHORTCUT_QUICKL); |
83 quick_shortcut_cbox_->SetIsSelected(true); | 83 quick_shortcut_cbox_->SetIsSelected(true); |
84 } | 84 } |
85 | 85 |
86 void FirstRunCustomizeView::GetPreferredSize(CSize *out) { | 86 gfx::Size FirstRunCustomizeView::GetPreferredSize() { |
87 DCHECK(out); | 87 return gfx::Size(ChromeViews::Window::GetLocalizedContentsSize( |
88 *out = ChromeViews::Window::GetLocalizedContentsSize( | |
89 IDS_FIRSTRUNCUSTOMIZE_DIALOG_WIDTH_CHARS, | 88 IDS_FIRSTRUNCUSTOMIZE_DIALOG_WIDTH_CHARS, |
90 IDS_FIRSTRUNCUSTOMIZE_DIALOG_HEIGHT_LINES).ToSIZE(); | 89 IDS_FIRSTRUNCUSTOMIZE_DIALOG_HEIGHT_LINES)); |
91 } | 90 } |
92 | 91 |
93 void FirstRunCustomizeView::Layout() { | 92 void FirstRunCustomizeView::Layout() { |
94 FirstRunViewBase::Layout(); | 93 FirstRunViewBase::Layout(); |
95 | 94 |
96 const int kVertSpacing = 8; | 95 const int kVertSpacing = 8; |
97 const int kComboExtraPad = 8; | 96 const int kComboExtraPad = 8; |
98 | 97 |
99 CSize canvas; | 98 gfx::Size canvas = GetPreferredSize(); |
100 GetPreferredSize(&canvas); | |
101 | 99 |
102 // Welcome label goes in to to the left. It does not go across the | 100 // Welcome label goes in to to the left. It does not go across the |
103 // entire window because the background gets busy on the right. | 101 // entire window because the background gets busy on the right. |
104 CSize pref_size; | 102 gfx::Size pref_size = main_label_->GetPreferredSize(); |
105 main_label_->GetPreferredSize(&pref_size); | |
106 main_label_->SetBounds(kPanelHorizMargin, kPanelVertMargin, | 103 main_label_->SetBounds(kPanelHorizMargin, kPanelVertMargin, |
107 canvas.cx - pref_size.cx, pref_size.cy); | 104 canvas.width() - pref_size.width(), |
| 105 pref_size.height()); |
108 AdjustDialogWidth(main_label_); | 106 AdjustDialogWidth(main_label_); |
109 | 107 |
110 int next_v_space = background_image()->y() + | 108 int next_v_space = background_image()->y() + |
111 background_image()->height() + kPanelVertMargin; | 109 background_image()->height() + kPanelVertMargin; |
112 | 110 |
113 import_cbox_->GetPreferredSize(&pref_size); | 111 pref_size = import_cbox_->GetPreferredSize(); |
114 import_cbox_->SetBounds(kPanelHorizMargin, next_v_space, | 112 import_cbox_->SetBounds(kPanelHorizMargin, next_v_space, |
115 pref_size.cx, pref_size.cy); | 113 pref_size.width(), pref_size.height()); |
116 | 114 |
117 import_cbox_->SetIsSelected(true); | 115 import_cbox_->SetIsSelected(true); |
118 | 116 |
119 int x_offset = import_cbox_->x() + | 117 int x_offset = import_cbox_->x() + |
120 import_cbox_->width(); | 118 import_cbox_->width(); |
121 | 119 |
122 import_from_combo_->GetPreferredSize(&pref_size); | 120 pref_size = import_from_combo_->GetPreferredSize(); |
123 import_from_combo_->SetBounds(x_offset, | 121 import_from_combo_->SetBounds(x_offset, |
124 next_v_space + | 122 next_v_space + |
125 (import_cbox_->height() - | 123 (import_cbox_->height() - |
126 pref_size.cy) / 2, | 124 pref_size.height()) / 2, |
127 pref_size.cx + kComboExtraPad, | 125 pref_size.width() + kComboExtraPad, |
128 pref_size.cy); | 126 pref_size.height()); |
129 | 127 |
130 AdjustDialogWidth(import_from_combo_); | 128 AdjustDialogWidth(import_from_combo_); |
131 | 129 |
132 next_v_space = import_cbox_->y() + import_cbox_->height() + | 130 next_v_space = import_cbox_->y() + import_cbox_->height() + |
133 kUnrelatedControlVerticalSpacing; | 131 kUnrelatedControlVerticalSpacing; |
134 | 132 |
135 shortcuts_label_->GetPreferredSize(&pref_size); | 133 pref_size = shortcuts_label_->GetPreferredSize(); |
136 shortcuts_label_->SetBounds(kPanelHorizMargin, next_v_space, | 134 shortcuts_label_->SetBounds(kPanelHorizMargin, next_v_space, |
137 pref_size.cx, pref_size.cy); | 135 pref_size.width(), pref_size.height()); |
138 | 136 |
139 AdjustDialogWidth(shortcuts_label_); | 137 AdjustDialogWidth(shortcuts_label_); |
140 | 138 |
141 next_v_space += shortcuts_label_->height() + | 139 next_v_space += shortcuts_label_->height() + |
142 kRelatedControlVerticalSpacing; | 140 kRelatedControlVerticalSpacing; |
143 | 141 |
144 desktop_shortcut_cbox_->GetPreferredSize(&pref_size); | 142 pref_size = desktop_shortcut_cbox_->GetPreferredSize(); |
145 desktop_shortcut_cbox_->SetBounds(kPanelHorizMargin, next_v_space, | 143 desktop_shortcut_cbox_->SetBounds(kPanelHorizMargin, next_v_space, |
146 pref_size.cx, pref_size.cy); | 144 pref_size.width(), pref_size.height()); |
147 | 145 |
148 AdjustDialogWidth(desktop_shortcut_cbox_); | 146 AdjustDialogWidth(desktop_shortcut_cbox_); |
149 | 147 |
150 next_v_space += desktop_shortcut_cbox_->height() + | 148 next_v_space += desktop_shortcut_cbox_->height() + |
151 kRelatedControlVerticalSpacing; | 149 kRelatedControlVerticalSpacing; |
152 | 150 |
153 quick_shortcut_cbox_->GetPreferredSize(&pref_size); | 151 pref_size = quick_shortcut_cbox_->GetPreferredSize(); |
154 quick_shortcut_cbox_->SetBounds(kPanelHorizMargin, next_v_space, | 152 quick_shortcut_cbox_->SetBounds(kPanelHorizMargin, next_v_space, |
155 pref_size.cx, pref_size.cy); | 153 pref_size.width(), pref_size.height()); |
156 | 154 |
157 AdjustDialogWidth(quick_shortcut_cbox_); | 155 AdjustDialogWidth(quick_shortcut_cbox_); |
158 } | 156 } |
159 | 157 |
160 void FirstRunCustomizeView::ButtonPressed(ChromeViews::NativeButton* sender) { | 158 void FirstRunCustomizeView::ButtonPressed(ChromeViews::NativeButton* sender) { |
161 if (import_cbox_ == sender) { | 159 if (import_cbox_ == sender) { |
162 // Disable the import combobox if the user unchecks the checkbox. | 160 // Disable the import combobox if the user unchecks the checkbox. |
163 import_from_combo_->SetEnabled(import_cbox_->IsSelected()); | 161 import_from_combo_->SetEnabled(import_cbox_->IsSelected()); |
164 } | 162 } |
165 } | 163 } |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
221 bool FirstRunCustomizeView::Cancel() { | 219 bool FirstRunCustomizeView::Cancel() { |
222 if (customize_observer_) | 220 if (customize_observer_) |
223 customize_observer_->CustomizeCanceled(); | 221 customize_observer_->CustomizeCanceled(); |
224 | 222 |
225 // Don't quit the message loop in this case - we're still showing the main | 223 // Don't quit the message loop in this case - we're still showing the main |
226 // First run dialog box underneath ourselves. | 224 // First run dialog box underneath ourselves. |
227 | 225 |
228 return true; | 226 return true; |
229 } | 227 } |
230 | 228 |
OLD | NEW |