| 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_with_content.h" | 5 #include "ui/views/examples/examples_window_with_content.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 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 46 namespace examples { | 46 namespace examples { |
| 47 | 47 |
| 48 // Model for the examples that are being added via AddExample(). | 48 // Model for the examples that are being added via AddExample(). |
| 49 class ComboboxModelExampleList : public ui::ComboboxModel { | 49 class ComboboxModelExampleList : public ui::ComboboxModel { |
| 50 public: | 50 public: |
| 51 ComboboxModelExampleList() {} | 51 ComboboxModelExampleList() {} |
| 52 virtual ~ComboboxModelExampleList() {} | 52 virtual ~ComboboxModelExampleList() {} |
| 53 | 53 |
| 54 // Overridden from ui::ComboboxModel: | 54 // Overridden from ui::ComboboxModel: |
| 55 virtual int GetItemCount() const OVERRIDE { return example_list_.size(); } | 55 virtual int GetItemCount() const OVERRIDE { return example_list_.size(); } |
| 56 virtual string16 GetItemAt(int index) OVERRIDE { | 56 virtual base::string16 GetItemAt(int index) OVERRIDE { |
| 57 return UTF8ToUTF16(example_list_[index]->example_title()); | 57 return UTF8ToUTF16(example_list_[index]->example_title()); |
| 58 } | 58 } |
| 59 | 59 |
| 60 View* GetItemViewAt(int index) { | 60 View* GetItemViewAt(int index) { |
| 61 return example_list_[index]->example_view(); | 61 return example_list_[index]->example_view(); |
| 62 } | 62 } |
| 63 | 63 |
| 64 void AddExample(ExampleBase* example) { | 64 void AddExample(ExampleBase* example) { |
| 65 example_list_.push_back(example); | 65 example_list_.push_back(example); |
| 66 } | 66 } |
| (...skipping 27 matching lines...) Expand all Loading... |
| 94 void SetStatus(const std::string& status) { | 94 void SetStatus(const std::string& status) { |
| 95 status_label_->SetText(UTF8ToUTF16(status)); | 95 status_label_->SetText(UTF8ToUTF16(status)); |
| 96 } | 96 } |
| 97 | 97 |
| 98 static ExamplesWindowContents* instance() { return instance_; } | 98 static ExamplesWindowContents* instance() { return instance_; } |
| 99 | 99 |
| 100 private: | 100 private: |
| 101 // Overridden from WidgetDelegateView: | 101 // Overridden from WidgetDelegateView: |
| 102 virtual bool CanResize() const OVERRIDE { return true; } | 102 virtual bool CanResize() const OVERRIDE { return true; } |
| 103 virtual bool CanMaximize() const OVERRIDE { return true; } | 103 virtual bool CanMaximize() const OVERRIDE { return true; } |
| 104 virtual string16 GetWindowTitle() const OVERRIDE { | 104 virtual base::string16 GetWindowTitle() const OVERRIDE { |
| 105 return ASCIIToUTF16("Views Examples"); | 105 return ASCIIToUTF16("Views Examples"); |
| 106 } | 106 } |
| 107 virtual View* GetContentsView() OVERRIDE { return this; } | 107 virtual View* GetContentsView() OVERRIDE { return this; } |
| 108 virtual void WindowClosing() OVERRIDE { | 108 virtual void WindowClosing() OVERRIDE { |
| 109 instance_ = NULL; | 109 instance_ = NULL; |
| 110 if (operation_ == QUIT_ON_CLOSE) | 110 if (operation_ == QUIT_ON_CLOSE) |
| 111 base::MessageLoopForUI::current()->Quit(); | 111 base::MessageLoopForUI::current()->Quit(); |
| 112 } | 112 } |
| 113 | 113 |
| 114 // Overridden from View: | 114 // Overridden from View: |
| (...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 216 widget->Show(); | 216 widget->Show(); |
| 217 } | 217 } |
| 218 } | 218 } |
| 219 | 219 |
| 220 void LogStatus(const std::string& string) { | 220 void LogStatus(const std::string& string) { |
| 221 ExamplesWindowContents::instance()->SetStatus(string); | 221 ExamplesWindowContents::instance()->SetStatus(string); |
| 222 } | 222 } |
| 223 | 223 |
| 224 } // namespace examples | 224 } // namespace examples |
| 225 } // namespace views | 225 } // namespace views |
| OLD | NEW |