OLD | NEW |
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 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
98 class ComboboxModelExampleList : public ui::ComboboxModel { | 98 class ComboboxModelExampleList : public ui::ComboboxModel { |
99 public: | 99 public: |
100 ComboboxModelExampleList() {} | 100 ComboboxModelExampleList() {} |
101 virtual ~ComboboxModelExampleList() {} | 101 virtual ~ComboboxModelExampleList() {} |
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 virtual int GetItemCount() const override { return example_list_.size(); } |
109 virtual base::string16 GetItemAt(int index) OVERRIDE { | 109 virtual 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 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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 virtual bool CanResize() const override { return true; } |
176 virtual bool CanMaximize() const OVERRIDE { return true; } | 176 virtual bool CanMaximize() const override { return true; } |
177 virtual bool CanMinimize() const OVERRIDE { return true; } | 177 virtual bool CanMinimize() const override { return true; } |
178 virtual base::string16 GetWindowTitle() const OVERRIDE { | 178 virtual 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 virtual View* GetContentsView() override { return this; } |
182 virtual void WindowClosing() OVERRIDE { | 182 virtual 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 virtual 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 Loading... |
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 |
OLD | NEW |