OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 #ifndef VIEWS_CONTROLS_TABLE_NATIVE_TABLE_GTK_H_ | 5 #ifndef VIEWS_CONTROLS_TABLE_NATIVE_TABLE_GTK_H_ |
6 #define VIEWS_CONTROLS_TABLE_NATIVE_TABLE_GTK_H_ | 6 #define VIEWS_CONTROLS_TABLE_NATIVE_TABLE_GTK_H_ |
7 #pragma once | 7 #pragma once |
8 | 8 |
| 9 #include "ui/base/gtk/gtk_signal.h" |
9 #include "ui/base/models/table_model.h" | 10 #include "ui/base/models/table_model.h" |
10 #include "ui/base/gtk/gtk_signal.h" | |
11 #include "views/controls/native_control_gtk.h" | 11 #include "views/controls/native_control_gtk.h" |
12 #include "views/controls/table/native_table_wrapper.h" | 12 #include "views/controls/table/native_table_wrapper.h" |
13 | 13 |
14 namespace views { | 14 namespace views { |
15 | 15 |
16 class TableView2; | 16 class TableView2; |
17 | 17 |
18 // A View that hosts a native GTK table. | 18 // A View that hosts a native GTK table. |
19 // TODO: Note that the implementation is still incomplete. What remains to be | 19 // TODO: Note that the implementation is still incomplete. What remains to be |
20 // done: | 20 // done: |
21 // - support resizable columns | 21 // - support resizable columns |
22 // - support autosize columns | 22 // - support autosize columns |
23 // - implement focus row methods. | 23 // - implement focus row methods. |
24 class NativeTableGtk : public NativeControlGtk, public NativeTableWrapper { | 24 class NativeTableGtk : public NativeControlGtk, public NativeTableWrapper { |
25 public: | 25 public: |
26 explicit NativeTableGtk(TableView2* table); | 26 explicit NativeTableGtk(TableView2* table); |
27 virtual ~NativeTableGtk(); | 27 virtual ~NativeTableGtk(); |
28 | 28 |
29 // NativeTableWrapper implementation: | 29 // NativeTableWrapper implementation: |
30 virtual int GetRowCount() const; | 30 virtual int GetRowCount() const; |
31 virtual View* GetView(); | 31 virtual View* GetView(); |
32 virtual void SetFocus(); | 32 virtual void SetFocus(); |
33 virtual gfx::NativeView GetTestingHandle() const; | 33 virtual gfx::NativeView GetTestingHandle() const; |
34 virtual void InsertColumn(const TableColumn& column, int index); | 34 virtual void InsertColumn(const ui::TableColumn& column, int index); |
35 virtual void RemoveColumn(int index); | 35 virtual void RemoveColumn(int index); |
36 virtual int GetColumnWidth(int column_index) const; | 36 virtual int GetColumnWidth(int column_index) const; |
37 virtual void SetColumnWidth(int column_index, int width); | 37 virtual void SetColumnWidth(int column_index, int width); |
38 virtual int GetSelectedRowCount() const; | 38 virtual int GetSelectedRowCount() const; |
39 virtual int GetFirstSelectedRow() const; | 39 virtual int GetFirstSelectedRow() const; |
40 virtual int GetFirstFocusedRow() const; | 40 virtual int GetFirstFocusedRow() const; |
41 virtual void ClearSelection(); | 41 virtual void ClearSelection(); |
42 virtual void ClearRowFocus(); | 42 virtual void ClearRowFocus(); |
43 virtual void SetSelectedState(int model_row, bool state); | 43 virtual void SetSelectedState(int model_row, bool state); |
44 virtual void SetFocusState(int model_row, bool state); | 44 virtual void SetFocusState(int model_row, bool state); |
45 virtual bool IsRowSelected(int model_row) const; | 45 virtual bool IsRowSelected(int model_row) const; |
46 virtual bool IsRowFocused(int model_row) const; | 46 virtual bool IsRowFocused(int model_row) const; |
47 virtual void OnRowsChanged(int start, int length); | 47 virtual void OnRowsChanged(int start, int length); |
48 virtual void OnRowsAdded(int start, int length); | 48 virtual void OnRowsAdded(int start, int length); |
49 virtual void OnRowsRemoved(int start, int length); | 49 virtual void OnRowsRemoved(int start, int length); |
50 virtual gfx::Rect GetBounds() const; | 50 virtual gfx::Rect GetBounds() const; |
51 | 51 |
52 protected: | 52 protected: |
53 // NativeControlGtk implementation: | 53 // NativeControlGtk implementation: |
54 virtual void CreateNativeControl(); | 54 virtual void CreateNativeControl(); |
55 | 55 |
56 private: | 56 private: |
57 void InsertTextColumn(const TableColumn& column, int index); | 57 void InsertTextColumn(const ui::TableColumn& column, int index); |
58 void InsertIconAndTextColumn(const TableColumn& column, int index); | 58 void InsertIconAndTextColumn(const ui::TableColumn& column, int index); |
59 | 59 |
60 // Sets the content of the row pointed to by |iter| in the tree_view_, using | 60 // Sets the content of the row pointed to by |iter| in the tree_view_, using |
61 // the data in the model at row |index|. | 61 // the data in the model at row |index|. |
62 void SetRowData(int index, GtkTreeIter* iter); | 62 void SetRowData(int index, GtkTreeIter* iter); |
63 | 63 |
64 // Handles the "cursor-changed" event. | 64 // Handles the "cursor-changed" event. |
65 CHROMEGTK_CALLBACK_0(NativeTableGtk, void, OnCursorChanged); | 65 CHROMEGTK_CALLBACK_0(NativeTableGtk, void, OnCursorChanged); |
66 | 66 |
67 // Returns the icon that should be displayed for the row at |row|. | 67 // Returns the icon that should be displayed for the row at |row|. |
68 GdkPixbuf* GetModelIcon(int row); | 68 GdkPixbuf* GetModelIcon(int row); |
(...skipping 12 matching lines...) Expand all Loading... |
81 | 81 |
82 // Size (width and height) of images. | 82 // Size (width and height) of images. |
83 static const int kImageSize; | 83 static const int kImageSize; |
84 | 84 |
85 DISALLOW_COPY_AND_ASSIGN(NativeTableGtk); | 85 DISALLOW_COPY_AND_ASSIGN(NativeTableGtk); |
86 }; | 86 }; |
87 | 87 |
88 } // namespace views | 88 } // namespace views |
89 | 89 |
90 #endif // VIEWS_CONTROLS_TABLE_NATIVE_TABLE_GTK_H_ | 90 #endif // VIEWS_CONTROLS_TABLE_NATIVE_TABLE_GTK_H_ |
OLD | NEW |