| 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 <string> | 7 #include <string> |
| 8 | 8 |
| 9 #include "base/memory/scoped_vector.h" | 9 #include "base/memory/scoped_vector.h" |
| 10 #include "base/strings/utf_string_conversions.h" | 10 #include "base/strings/utf_string_conversions.h" |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 44 namespace examples { | 44 namespace examples { |
| 45 | 45 |
| 46 // Model for the examples that are being added via AddExample(). | 46 // Model for the examples that are being added via AddExample(). |
| 47 class ComboboxModelExampleList : public ui::ComboboxModel { | 47 class ComboboxModelExampleList : public ui::ComboboxModel { |
| 48 public: | 48 public: |
| 49 ComboboxModelExampleList() {} | 49 ComboboxModelExampleList() {} |
| 50 virtual ~ComboboxModelExampleList() {} | 50 virtual ~ComboboxModelExampleList() {} |
| 51 | 51 |
| 52 // Overridden from ui::ComboboxModel: | 52 // Overridden from ui::ComboboxModel: |
| 53 virtual int GetItemCount() const OVERRIDE { return example_list_.size(); } | 53 virtual int GetItemCount() const OVERRIDE { return example_list_.size(); } |
| 54 virtual string16 GetItemAt(int index) OVERRIDE { | 54 virtual base::string16 GetItemAt(int index) OVERRIDE { |
| 55 return UTF8ToUTF16(example_list_[index]->example_title()); | 55 return UTF8ToUTF16(example_list_[index]->example_title()); |
| 56 } | 56 } |
| 57 | 57 |
| 58 View* GetItemViewAt(int index) { | 58 View* GetItemViewAt(int index) { |
| 59 return example_list_[index]->example_view(); | 59 return example_list_[index]->example_view(); |
| 60 } | 60 } |
| 61 | 61 |
| 62 void AddExample(ExampleBase* example) { | 62 void AddExample(ExampleBase* example) { |
| 63 example_list_.push_back(example); | 63 example_list_.push_back(example); |
| 64 } | 64 } |
| (...skipping 25 matching lines...) Expand all Loading... |
| 90 void SetStatus(const std::string& status) { | 90 void SetStatus(const std::string& status) { |
| 91 status_label_->SetText(UTF8ToUTF16(status)); | 91 status_label_->SetText(UTF8ToUTF16(status)); |
| 92 } | 92 } |
| 93 | 93 |
| 94 static ExamplesWindowContents* instance() { return instance_; } | 94 static ExamplesWindowContents* instance() { return instance_; } |
| 95 | 95 |
| 96 private: | 96 private: |
| 97 // Overridden from WidgetDelegateView: | 97 // Overridden from WidgetDelegateView: |
| 98 virtual bool CanResize() const OVERRIDE { return true; } | 98 virtual bool CanResize() const OVERRIDE { return true; } |
| 99 virtual bool CanMaximize() const OVERRIDE { return true; } | 99 virtual bool CanMaximize() const OVERRIDE { return true; } |
| 100 virtual string16 GetWindowTitle() const OVERRIDE { | 100 virtual base::string16 GetWindowTitle() const OVERRIDE { |
| 101 return ASCIIToUTF16("Views Examples"); | 101 return ASCIIToUTF16("Views Examples"); |
| 102 } | 102 } |
| 103 virtual View* GetContentsView() OVERRIDE { return this; } | 103 virtual View* GetContentsView() OVERRIDE { return this; } |
| 104 virtual void WindowClosing() OVERRIDE { | 104 virtual void WindowClosing() OVERRIDE { |
| 105 instance_ = NULL; | 105 instance_ = NULL; |
| 106 if (operation_ == QUIT_ON_CLOSE) | 106 if (operation_ == QUIT_ON_CLOSE) |
| 107 base::MessageLoopForUI::current()->Quit(); | 107 base::MessageLoopForUI::current()->Quit(); |
| 108 } | 108 } |
| 109 | 109 |
| 110 // Overridden from View: | 110 // Overridden from View: |
| (...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 202 gfx::Rect(0, 0, 850, 300))->Show(); | 202 gfx::Rect(0, 0, 850, 300))->Show(); |
| 203 } | 203 } |
| 204 } | 204 } |
| 205 | 205 |
| 206 void LogStatus(const std::string& string) { | 206 void LogStatus(const std::string& string) { |
| 207 ExamplesWindowContents::instance()->SetStatus(string); | 207 ExamplesWindowContents::instance()->SetStatus(string); |
| 208 } | 208 } |
| 209 | 209 |
| 210 } // namespace examples | 210 } // namespace examples |
| 211 } // namespace views | 211 } // namespace views |
| OLD | NEW |