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

Side by Side Diff: ui/views/examples/examples_window.cc

Issue 684463003: Standardize usage of virtual/override/final specifiers. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 1 month 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
« no previous file with comments | « ui/views/examples/example_combobox_model.h ('k') | ui/views/examples/label_example.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/examples/examples_window.h" 5 #include "ui/views/examples/examples_window.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <string> 8 #include <string>
9 9
10 #include "base/memory/scoped_vector.h" 10 #include "base/memory/scoped_vector.h"
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
91 std::sort(examples->begin(), examples->end(), ExampleTitleCompare()); 91 std::sort(examples->begin(), examples->end(), ExampleTitleCompare());
92 return examples.Pass(); 92 return examples.Pass();
93 } 93 }
94 94
95 } // namespace 95 } // namespace
96 96
97 // Model for the examples that are being added via AddExample(). 97 // Model for the examples that are being added via AddExample().
98 class ComboboxModelExampleList : public ui::ComboboxModel { 98 class ComboboxModelExampleList : public ui::ComboboxModel {
99 public: 99 public:
100 ComboboxModelExampleList() {} 100 ComboboxModelExampleList() {}
101 virtual ~ComboboxModelExampleList() {} 101 ~ComboboxModelExampleList() override {}
102 102
103 void SetExamples(ScopedExamples examples) { 103 void SetExamples(ScopedExamples examples) {
104 example_list_.swap(*examples); 104 example_list_.swap(*examples);
105 } 105 }
106 106
107 // ui::ComboboxModel: 107 // ui::ComboboxModel:
108 virtual int GetItemCount() const override { return example_list_.size(); } 108 int GetItemCount() const override { return example_list_.size(); }
109 virtual base::string16 GetItemAt(int index) override { 109 base::string16 GetItemAt(int index) override {
110 return base::UTF8ToUTF16(example_list_[index]->example_title()); 110 return base::UTF8ToUTF16(example_list_[index]->example_title());
111 } 111 }
112 112
113 View* GetItemViewAt(int index) { 113 View* GetItemViewAt(int index) {
114 return example_list_[index]->example_view(); 114 return example_list_[index]->example_view();
115 } 115 }
116 116
117 private: 117 private:
118 ScopedVector<ExampleBase> example_list_; 118 ScopedVector<ExampleBase> example_list_;
119 119
(...skipping 30 matching lines...) Expand all
150 example_shown_->SetLayoutManager(new FillLayout()); 150 example_shown_->SetLayoutManager(new FillLayout());
151 example_shown_->AddChildView(combobox_model_.GetItemViewAt(0)); 151 example_shown_->AddChildView(combobox_model_.GetItemViewAt(0));
152 layout->AddView(example_shown_); 152 layout->AddView(example_shown_);
153 } 153 }
154 154
155 layout->StartRow(0 /* no expand */, 0); 155 layout->StartRow(0 /* no expand */, 0);
156 layout->AddView(status_label_); 156 layout->AddView(status_label_);
157 layout->AddPaddingRow(0, 5); 157 layout->AddPaddingRow(0, 5);
158 } 158 }
159 159
160 virtual ~ExamplesWindowContents() { 160 ~ExamplesWindowContents() override {
161 // Delete |combobox_| first as it references |combobox_model_|. 161 // Delete |combobox_| first as it references |combobox_model_|.
162 delete combobox_; 162 delete combobox_;
163 combobox_ = NULL; 163 combobox_ = NULL;
164 } 164 }
165 165
166 // Prints a message in the status area, at the bottom of the window. 166 // Prints a message in the status area, at the bottom of the window.
167 void SetStatus(const std::string& status) { 167 void SetStatus(const std::string& status) {
168 status_label_->SetText(base::UTF8ToUTF16(status)); 168 status_label_->SetText(base::UTF8ToUTF16(status));
169 } 169 }
170 170
171 static ExamplesWindowContents* instance() { return instance_; } 171 static ExamplesWindowContents* instance() { return instance_; }
172 172
173 private: 173 private:
174 // WidgetDelegateView: 174 // WidgetDelegateView:
175 virtual bool CanResize() const override { return true; } 175 bool CanResize() const override { return true; }
176 virtual bool CanMaximize() const override { return true; } 176 bool CanMaximize() const override { return true; }
177 virtual bool CanMinimize() const override { return true; } 177 bool CanMinimize() const override { return true; }
178 virtual base::string16 GetWindowTitle() const override { 178 base::string16 GetWindowTitle() const override {
179 return base::ASCIIToUTF16("Views Examples"); 179 return base::ASCIIToUTF16("Views Examples");
180 } 180 }
181 virtual View* GetContentsView() override { return this; } 181 View* GetContentsView() override { return this; }
182 virtual void WindowClosing() override { 182 void WindowClosing() override {
183 instance_ = NULL; 183 instance_ = NULL;
184 if (operation_ == QUIT_ON_CLOSE) 184 if (operation_ == QUIT_ON_CLOSE)
185 base::MessageLoopForUI::current()->Quit(); 185 base::MessageLoopForUI::current()->Quit();
186 } 186 }
187 187
188 // ComboboxListener: 188 // ComboboxListener:
189 virtual void OnPerformAction(Combobox* combobox) override { 189 void OnPerformAction(Combobox* combobox) override {
190 DCHECK_EQ(combobox, combobox_); 190 DCHECK_EQ(combobox, combobox_);
191 DCHECK(combobox->selected_index() < combobox_model_.GetItemCount()); 191 DCHECK(combobox->selected_index() < combobox_model_.GetItemCount());
192 example_shown_->RemoveAllChildViews(false); 192 example_shown_->RemoveAllChildViews(false);
193 example_shown_->AddChildView(combobox_model_.GetItemViewAt( 193 example_shown_->AddChildView(combobox_model_.GetItemViewAt(
194 combobox->selected_index())); 194 combobox->selected_index()));
195 example_shown_->RequestFocus(); 195 example_shown_->RequestFocus();
196 SetStatus(std::string()); 196 SetStatus(std::string());
197 Layout(); 197 Layout();
198 } 198 }
199 199
(...skipping 26 matching lines...) Expand all
226 widget->Show(); 226 widget->Show();
227 } 227 }
228 } 228 }
229 229
230 void LogStatus(const std::string& string) { 230 void LogStatus(const std::string& string) {
231 ExamplesWindowContents::instance()->SetStatus(string); 231 ExamplesWindowContents::instance()->SetStatus(string);
232 } 232 }
233 233
234 } // namespace examples 234 } // namespace examples
235 } // namespace views 235 } // namespace views
OLDNEW
« no previous file with comments | « ui/views/examples/example_combobox_model.h ('k') | ui/views/examples/label_example.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698