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 3 // found in the LICENSE file. 4 5 #ifndef UI_VIEWS_EXAMPLES_TABLE_EXAMPLE_H_ 6 #define UI_VIEWS_EXAMPLES_TABLE_EXAMPLE_H_ 7 8 #include <string> 9 10 #include "base/basictypes.h" 11 #include "base/compiler_specific.h" 12 #include "third_party/skia/include/core/SkBitmap.h" 13 #include "ui/base/models/table_model.h" 14 #include "ui/views/controls/button/button.h" 15 #include "ui/views/controls/table/table_grouper.h" 16 #include "ui/views/controls/table/table_view.h" 17 #include "ui/views/controls/table/table_view_observer.h" 18 #include "ui/views/examples/example_base.h" 19 20 namespace gfx { 21 class ImageSkia; 22 } 23 24 namespace views { 25 class Checkbox; 26 class TableView; 27 28 namespace examples { 29 30 class TableExample : public ExampleBase, 31 public ui::TableModel, 32 public TableGrouper, 33 public TableViewObserver, 34 public ButtonListener { 35 public: 36 TableExample(); 37 virtual ~TableExample(); 38 39 // ExampleBase: 40 virtual void CreateExampleView(View* container) OVERRIDE; 41 42 // ui::TableModel: 43 virtual int RowCount() OVERRIDE; 44 virtual string16 GetText(int row, int column_id) OVERRIDE; 45 virtual gfx::ImageSkia GetIcon(int row) OVERRIDE; 46 virtual void SetObserver(ui::TableModelObserver* observer) OVERRIDE; 47 48 // TableGrouper: 49 virtual void GetGroupRange(int model_index, GroupRange* range) OVERRIDE; 50 51 // TableViewObserver: 52 virtual void OnSelectionChanged() OVERRIDE; 53 virtual void OnDoubleClick() OVERRIDE; 54 virtual void OnMiddleClick() OVERRIDE; 55 virtual void OnKeyDown(ui::KeyboardCode virtual_keycode) OVERRIDE; 56 57 // ButtonListener: 58 virtual void ButtonPressed(Button* sender, const ui::Event& event) OVERRIDE; 59 60 private: 61 // The table to be tested. 62 TableView* table_; 63 64 Checkbox* column1_visible_checkbox_; 65 Checkbox* column2_visible_checkbox_; 66 Checkbox* column3_visible_checkbox_; 67 Checkbox* column4_visible_checkbox_; 68 69 SkBitmap icon1_; 70 SkBitmap icon2_; 71 72 DISALLOW_COPY_AND_ASSIGN(TableExample); 73 }; 74 75 } // namespace examples 76 } // namespace views 77 78 #endif // UI_VIEWS_EXAMPLES_TABLE_EXAMPLE_H_ 79