| 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_bubble.h" | 5 #include "chrome/browser/views/first_run_bubble.h" |
| 6 | 6 |
| 7 #include "chrome/app/locales/locale_settings.h" | 7 #include "chrome/app/locales/locale_settings.h" |
| 8 #include "chrome/browser/browser.h" | 8 #include "chrome/browser/browser.h" |
| 9 #include "chrome/browser/browser_list.h" | 9 #include "chrome/browser/browser_list.h" |
| 10 #include "chrome/browser/browser_window.h" | 10 #include "chrome/browser/browser_window.h" |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 56 keep_button_(NULL), | 56 keep_button_(NULL), |
| 57 change_button_(NULL) { | 57 change_button_(NULL) { |
| 58 ChromeFont& font = | 58 ChromeFont& font = |
| 59 ResourceBundle::GetSharedInstance().GetFont(ResourceBundle::MediumFont); | 59 ResourceBundle::GetSharedInstance().GetFont(ResourceBundle::MediumFont); |
| 60 | 60 |
| 61 label1_ = new ChromeViews::Label(l10n_util::GetString(IDS_FR_BUBBLE_TITLE)); | 61 label1_ = new ChromeViews::Label(l10n_util::GetString(IDS_FR_BUBBLE_TITLE)); |
| 62 label1_->SetFont(font.DeriveFont(3, ChromeFont::BOLD)); | 62 label1_->SetFont(font.DeriveFont(3, ChromeFont::BOLD)); |
| 63 label1_->SetHorizontalAlignment(ChromeViews::Label::ALIGN_LEFT); | 63 label1_->SetHorizontalAlignment(ChromeViews::Label::ALIGN_LEFT); |
| 64 AddChildView(label1_); | 64 AddChildView(label1_); |
| 65 | 65 |
| 66 CSize ps; | 66 gfx::Size ps = GetPreferredSize(); |
| 67 GetPreferredSize(&ps); | |
| 68 | 67 |
| 69 label2_ = | 68 label2_ = |
| 70 new ChromeViews::Label(l10n_util::GetString(IDS_FR_BUBBLE_SUBTEXT)); | 69 new ChromeViews::Label(l10n_util::GetString(IDS_FR_BUBBLE_SUBTEXT)); |
| 71 label2_->SetMultiLine(true); | 70 label2_->SetMultiLine(true); |
| 72 label2_->SetFont(font); | 71 label2_->SetFont(font); |
| 73 label2_->SetHorizontalAlignment(ChromeViews::Label::ALIGN_LEFT); | 72 label2_->SetHorizontalAlignment(ChromeViews::Label::ALIGN_LEFT); |
| 74 label2_->SizeToFit(ps.cx - kBubblePadding * 2); | 73 label2_->SizeToFit(ps.width() - kBubblePadding * 2); |
| 75 AddChildView(label2_); | 74 AddChildView(label2_); |
| 76 | 75 |
| 77 std::wstring question_str | 76 std::wstring question_str |
| 78 = l10n_util::GetStringF(IDS_FR_BUBBLE_QUESTION, | 77 = l10n_util::GetStringF(IDS_FR_BUBBLE_QUESTION, |
| 79 GetDefaultSearchEngineName()); | 78 GetDefaultSearchEngineName()); |
| 80 label3_ = new ChromeViews::Label(question_str); | 79 label3_ = new ChromeViews::Label(question_str); |
| 81 label3_->SetMultiLine(true); | 80 label3_->SetMultiLine(true); |
| 82 label3_->SetFont(font); | 81 label3_->SetFont(font); |
| 83 label3_->SetHorizontalAlignment(ChromeViews::Label::ALIGN_LEFT); | 82 label3_->SetHorizontalAlignment(ChromeViews::Label::ALIGN_LEFT); |
| 84 label3_->SizeToFit(ps.cx - kBubblePadding * 2); | 83 label3_->SizeToFit(ps.width() - kBubblePadding * 2); |
| 85 AddChildView(label3_); | 84 AddChildView(label3_); |
| 86 | 85 |
| 87 std::wstring keep_str = l10n_util::GetStringF(IDS_FR_BUBBLE_OK, | 86 std::wstring keep_str = l10n_util::GetStringF(IDS_FR_BUBBLE_OK, |
| 88 GetDefaultSearchEngineName()); | 87 GetDefaultSearchEngineName()); |
| 89 keep_button_ = new ChromeViews::NativeButton(keep_str, true); | 88 keep_button_ = new ChromeViews::NativeButton(keep_str, true); |
| 90 keep_button_->SetListener(this); | 89 keep_button_->SetListener(this); |
| 91 AddChildView(keep_button_); | 90 AddChildView(keep_button_); |
| 92 | 91 |
| 93 std::wstring change_str = l10n_util::GetString(IDS_FR_BUBBLE_CHANGE); | 92 std::wstring change_str = l10n_util::GetString(IDS_FR_BUBBLE_CHANGE); |
| 94 change_button_ = new ChromeViews::NativeButton(change_str); | 93 change_button_ = new ChromeViews::NativeButton(change_str); |
| (...skipping 13 matching lines...) Expand all Loading... |
| 108 Browser* browser = BrowserList::GetLastActive(); | 107 Browser* browser = BrowserList::GetLastActive(); |
| 109 if (browser) { | 108 if (browser) { |
| 110 ShowOptionsWindow(OPTIONS_PAGE_GENERAL, OPTIONS_GROUP_DEFAULT_SEARCH, | 109 ShowOptionsWindow(OPTIONS_PAGE_GENERAL, OPTIONS_GROUP_DEFAULT_SEARCH, |
| 111 browser->profile()); | 110 browser->profile()); |
| 112 } | 111 } |
| 113 } | 112 } |
| 114 } | 113 } |
| 115 | 114 |
| 116 // Overridden from ChromeViews::View. | 115 // Overridden from ChromeViews::View. |
| 117 virtual void Layout() { | 116 virtual void Layout() { |
| 118 CSize canvas; | 117 gfx::Size canvas = GetPreferredSize(); |
| 119 GetPreferredSize(&canvas); | |
| 120 | 118 |
| 121 CSize pref_size; | |
| 122 // The multiline business that follows is dirty hacks to get around | 119 // The multiline business that follows is dirty hacks to get around |
| 123 // bug 1325257. | 120 // bug 1325257. |
| 124 label1_->SetMultiLine(false); | 121 label1_->SetMultiLine(false); |
| 125 label1_->GetPreferredSize(&pref_size); | 122 gfx::Size pref_size = label1_->GetPreferredSize(); |
| 126 label1_->SetMultiLine(true); | 123 label1_->SetMultiLine(true); |
| 127 label1_->SizeToFit(canvas.cx - kBubblePadding * 2); | 124 label1_->SizeToFit(canvas.width() - kBubblePadding * 2); |
| 128 label1_->SetBounds(kBubblePadding, kBubblePadding, | 125 label1_->SetBounds(kBubblePadding, kBubblePadding, |
| 129 canvas.cx - kBubblePadding * 2, | 126 canvas.width() - kBubblePadding * 2, |
| 130 pref_size.cy); | 127 pref_size.height()); |
| 131 | 128 |
| 132 int next_v_space = label1_->y() + pref_size.cy + | 129 int next_v_space = label1_->y() + pref_size.height() + |
| 133 kRelatedControlSmallVerticalSpacing; | 130 kRelatedControlSmallVerticalSpacing; |
| 134 | 131 |
| 135 label2_->GetPreferredSize(&pref_size); | 132 pref_size = label2_->GetPreferredSize(); |
| 136 label2_->SetBounds(kBubblePadding, next_v_space, | 133 label2_->SetBounds(kBubblePadding, next_v_space, |
| 137 canvas.cx - kBubblePadding * 2, | 134 canvas.width() - kBubblePadding * 2, |
| 138 pref_size.cy); | 135 pref_size.height()); |
| 139 | 136 |
| 140 next_v_space = label2_->y() + label2_->height() + | 137 next_v_space = label2_->y() + label2_->height() + |
| 141 kPanelSubVerticalSpacing; | 138 kPanelSubVerticalSpacing; |
| 142 | 139 |
| 143 label3_->GetPreferredSize(&pref_size); | 140 pref_size = label3_->GetPreferredSize(); |
| 144 label3_->SetBounds(kBubblePadding, next_v_space, | 141 label3_->SetBounds(kBubblePadding, next_v_space, |
| 145 canvas.cx - kBubblePadding * 2, | 142 canvas.width() - kBubblePadding * 2, |
| 146 pref_size.cy); | 143 pref_size.height()); |
| 147 | 144 |
| 148 change_button_->GetPreferredSize(&pref_size); | 145 pref_size = change_button_->GetPreferredSize(); |
| 149 change_button_->SetBounds(canvas.cx - pref_size.cx - kBubblePadding, | 146 change_button_->SetBounds( |
| 150 canvas.cy - pref_size.cy - kButtonVEdgeMargin, | 147 canvas.width() - pref_size.width() - kBubblePadding, |
| 151 pref_size.cx, pref_size.cy); | 148 canvas.height() - pref_size.height() - kButtonVEdgeMargin, |
| 149 pref_size.width(), pref_size.height()); |
| 152 | 150 |
| 153 keep_button_->GetPreferredSize(&pref_size); | 151 pref_size = keep_button_->GetPreferredSize(); |
| 154 keep_button_->SetBounds(change_button_->x() - pref_size.cx - | 152 keep_button_->SetBounds(change_button_->x() - pref_size.width() - |
| 155 kRelatedButtonHSpacing, change_button_->y(), | 153 kRelatedButtonHSpacing, change_button_->y(), |
| 156 pref_size.cx, pref_size.cy); | 154 pref_size.width(), pref_size.height()); |
| 157 } | 155 } |
| 158 | 156 |
| 159 virtual void ViewHierarchyChanged(bool is_add, View* parent, View* child) { | 157 virtual void ViewHierarchyChanged(bool is_add, View* parent, View* child) { |
| 160 if (keep_button_) | 158 if (keep_button_) |
| 161 keep_button_->RequestFocus(); | 159 keep_button_->RequestFocus(); |
| 162 } | 160 } |
| 163 | 161 |
| 164 // Overridden from ChromeViews::View. | 162 // Overridden from ChromeViews::View. |
| 165 virtual void GetPreferredSize(CSize *out) { | 163 virtual gfx::Size GetPreferredSize() { |
| 166 DCHECK(out); | 164 return gfx::Size(ChromeViews::Window::GetLocalizedContentsSize( |
| 167 *out = ChromeViews::Window::GetLocalizedContentsSize( | |
| 168 IDS_FIRSTRUNBUBBLE_DIALOG_WIDTH_CHARS, | 165 IDS_FIRSTRUNBUBBLE_DIALOG_WIDTH_CHARS, |
| 169 IDS_FIRSTRUNBUBBLE_DIALOG_HEIGHT_LINES).ToSIZE(); | 166 IDS_FIRSTRUNBUBBLE_DIALOG_HEIGHT_LINES)); |
| 170 } | 167 } |
| 171 | 168 |
| 172 private: | 169 private: |
| 173 FirstRunBubble* bubble_window_; | 170 FirstRunBubble* bubble_window_; |
| 174 ChromeViews::Label* label1_; | 171 ChromeViews::Label* label1_; |
| 175 ChromeViews::Label* label2_; | 172 ChromeViews::Label* label2_; |
| 176 ChromeViews::Label* label3_; | 173 ChromeViews::Label* label3_; |
| 177 ChromeViews::NativeButton* change_button_; | 174 ChromeViews::NativeButton* change_button_; |
| 178 ChromeViews::NativeButton* keep_button_; | 175 ChromeViews::NativeButton* keep_button_; |
| 179 DISALLOW_EVIL_CONSTRUCTORS(FirstRunBubbleView); | 176 DISALLOW_EVIL_CONSTRUCTORS(FirstRunBubbleView); |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 219 DCHECK(frame); | 216 DCHECK(frame); |
| 220 frame->InfoBubbleShowing(); | 217 frame->InfoBubbleShowing(); |
| 221 window->ShowWindow(SW_SHOW); | 218 window->ShowWindow(SW_SHOW); |
| 222 return window; | 219 return window; |
| 223 } | 220 } |
| 224 | 221 |
| 225 void FirstRunBubble::EnableParent() { | 222 void FirstRunBubble::EnableParent() { |
| 226 ::EnableWindow(GetParent(), true); | 223 ::EnableWindow(GetParent(), true); |
| 227 } | 224 } |
| 228 | 225 |
| OLD | NEW |