OLD | NEW |
| (Empty) |
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 | |
3 // found in the LICENSE file. | |
4 | |
5 #ifndef VIEWS_CONTROLS_TABLE_NATIVE_TABLE_GTK_H_ | |
6 #define VIEWS_CONTROLS_TABLE_NATIVE_TABLE_GTK_H_ | |
7 #pragma once | |
8 | |
9 #include "ui/base/gtk/gtk_signal.h" | |
10 #include "ui/base/models/table_model.h" | |
11 #include "views/controls/native_control_gtk.h" | |
12 #include "views/controls/table/native_table_wrapper.h" | |
13 | |
14 namespace views { | |
15 | |
16 class TableView2; | |
17 | |
18 // A View that hosts a native GTK table. | |
19 // TODO: Note that the implementation is still incomplete. What remains to be | |
20 // done: | |
21 // - support resizable columns | |
22 // - support autosize columns | |
23 // - implement focus row methods. | |
24 class NativeTableGtk : public NativeControlGtk, public NativeTableWrapper { | |
25 public: | |
26 explicit NativeTableGtk(TableView2* table); | |
27 virtual ~NativeTableGtk(); | |
28 | |
29 // NativeTableWrapper implementation: | |
30 virtual int GetRowCount() const; | |
31 virtual View* GetView(); | |
32 virtual void SetFocus(); | |
33 virtual gfx::NativeView GetTestingHandle() const; | |
34 virtual void InsertColumn(const ui::TableColumn& column, int index); | |
35 virtual void RemoveColumn(int index); | |
36 virtual int GetColumnWidth(int column_index) const; | |
37 virtual void SetColumnWidth(int column_index, int width); | |
38 virtual int GetSelectedRowCount() const; | |
39 virtual int GetFirstSelectedRow() const; | |
40 virtual int GetFirstFocusedRow() const; | |
41 virtual void ClearSelection(); | |
42 virtual void ClearRowFocus(); | |
43 virtual void SetSelectedState(int model_row, bool state); | |
44 virtual void SetFocusState(int model_row, bool state); | |
45 virtual bool IsRowSelected(int model_row) const; | |
46 virtual bool IsRowFocused(int model_row) const; | |
47 virtual void OnRowsChanged(int start, int length); | |
48 virtual void OnRowsAdded(int start, int length); | |
49 virtual void OnRowsRemoved(int start, int length); | |
50 virtual gfx::Rect GetBounds() const; | |
51 | |
52 protected: | |
53 // NativeControlGtk implementation: | |
54 virtual void CreateNativeControl(); | |
55 | |
56 private: | |
57 void InsertTextColumn(const ui::TableColumn& column, int index); | |
58 void InsertIconAndTextColumn(const ui::TableColumn& column, int index); | |
59 | |
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|. | |
62 void SetRowData(int index, GtkTreeIter* iter); | |
63 | |
64 // Handles the "cursor-changed" event. | |
65 CHROMEGTK_CALLBACK_0(NativeTableGtk, void, OnCursorChanged); | |
66 | |
67 // Returns the icon that should be displayed for the row at |row|. | |
68 GdkPixbuf* GetModelIcon(int row); | |
69 | |
70 // The Table we are bound to. | |
71 TableView2* table_; | |
72 | |
73 // The GtkTree model. | |
74 GtkListStore* gtk_model_; | |
75 | |
76 // The actual tree view. | |
77 GtkTreeView* tree_view_; | |
78 | |
79 // The selection for tree_view_. | |
80 GtkTreeSelection* tree_selection_; | |
81 | |
82 // Size (width and height) of images. | |
83 static const int kImageSize; | |
84 | |
85 DISALLOW_COPY_AND_ASSIGN(NativeTableGtk); | |
86 }; | |
87 | |
88 } // namespace views | |
89 | |
90 #endif // VIEWS_CONTROLS_TABLE_NATIVE_TABLE_GTK_H_ | |
OLD | NEW |