| 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_WIN_H_ | |
| 6 #define VIEWS_CONTROLS_TABLE_NATIVE_TABLE_WIN_H_ | |
| 7 #pragma once | |
| 8 | |
| 9 #include <windows.h> | |
| 10 | |
| 11 #include "ui/base/models/table_model.h" | |
| 12 #include "views/controls/native_control_win.h" | |
| 13 #include "views/controls/table/native_table_wrapper.h" | |
| 14 | |
| 15 typedef struct tagNMLVCUSTOMDRAW NMLVCUSTOMDRAW; | |
| 16 | |
| 17 namespace views { | |
| 18 | |
| 19 class TableView2; | |
| 20 | |
| 21 // A View that hosts a native Windows table. | |
| 22 class NativeTableWin : public NativeControlWin, public NativeTableWrapper { | |
| 23 public: | |
| 24 explicit NativeTableWin(TableView2* table); | |
| 25 virtual ~NativeTableWin(); | |
| 26 | |
| 27 // NativeTableWrapper implementation: | |
| 28 virtual int GetRowCount() const; | |
| 29 virtual View* GetView(); | |
| 30 virtual void SetFocus(); | |
| 31 virtual gfx::NativeView GetTestingHandle() const; | |
| 32 virtual void InsertColumn(const ui::TableColumn& column, int index); | |
| 33 virtual void RemoveColumn(int index); | |
| 34 virtual int GetColumnWidth(int column_index) const; | |
| 35 virtual void SetColumnWidth(int column_index, int width); | |
| 36 virtual int GetSelectedRowCount() const; | |
| 37 virtual int GetFirstSelectedRow() const; | |
| 38 virtual int GetFirstFocusedRow() const; | |
| 39 virtual void ClearSelection(); | |
| 40 virtual void ClearRowFocus(); | |
| 41 virtual void SetSelectedState(int model_row, bool state); | |
| 42 virtual void SetFocusState(int model_row, bool state); | |
| 43 virtual bool IsRowSelected(int model_row) const; | |
| 44 virtual bool IsRowFocused(int model_row) const; | |
| 45 virtual void OnRowsChanged(int start, int length); | |
| 46 virtual void OnRowsAdded(int start, int length); | |
| 47 virtual void OnRowsRemoved(int start, int length); | |
| 48 virtual gfx::Rect GetBounds() const; | |
| 49 | |
| 50 // Overridden from View: | |
| 51 virtual gfx::Size GetPreferredSize(); | |
| 52 | |
| 53 // Overridden from NativeControlWin: | |
| 54 virtual bool ProcessMessage(UINT message, | |
| 55 WPARAM w_param, | |
| 56 LPARAM l_param, | |
| 57 LRESULT* result); | |
| 58 | |
| 59 protected: | |
| 60 virtual void CreateNativeControl(); | |
| 61 | |
| 62 private: | |
| 63 // Makes |model_row| the only selected and focused row. | |
| 64 void Select(int model_row); | |
| 65 | |
| 66 // Notification from the ListView that the selected state of an item has | |
| 67 // changed. | |
| 68 virtual void OnSelectedStateChanged(); | |
| 69 | |
| 70 // Notification from the ListView that the used double clicked the table. | |
| 71 virtual void OnDoubleClick(); | |
| 72 | |
| 73 // Notification from the ListView that the user middle clicked the table. | |
| 74 virtual void OnMiddleClick(); | |
| 75 | |
| 76 // Overridden from NativeControl. Notifies the observer. | |
| 77 virtual bool OnKeyDown(ui::KeyboardCode virtual_keycode); | |
| 78 | |
| 79 // Custom drawing of our icons. | |
| 80 LRESULT OnCustomDraw(NMLVCUSTOMDRAW* draw_info); | |
| 81 | |
| 82 void UpdateListViewCache(int start, int length, bool add); | |
| 83 | |
| 84 void UpdateContentOffset(); | |
| 85 | |
| 86 // Window procedure of the list view class. We subclass the list view to | |
| 87 // ignore WM_ERASEBKGND, which gives smoother painting during resizing. | |
| 88 static LRESULT CALLBACK TableWndProc(HWND window, | |
| 89 UINT message, | |
| 90 WPARAM w_param, | |
| 91 LPARAM l_param); | |
| 92 | |
| 93 // Window procedure of the header class. We subclass the header of the table | |
| 94 // to disable resizing of columns. | |
| 95 static LRESULT CALLBACK TableHeaderWndProc(HWND window, | |
| 96 UINT message, | |
| 97 WPARAM w_param, | |
| 98 LPARAM l_param); | |
| 99 | |
| 100 // If true, any events that would normally be propagated to the observer | |
| 101 // are ignored. For example, if this is true and the selection changes in | |
| 102 // the listview, the observer is not notified. | |
| 103 bool ignore_listview_change_; | |
| 104 | |
| 105 // The Table we are bound to. | |
| 106 TableView2* table_; | |
| 107 | |
| 108 // The Y offset from the top of the table to the actual content (passed the | |
| 109 // header if any). | |
| 110 int content_offset_; | |
| 111 | |
| 112 // The list view's header original proc handler. It is required when | |
| 113 // subclassing. | |
| 114 WNDPROC header_original_handler_; | |
| 115 | |
| 116 // Window procedure of the listview before we subclassed it. | |
| 117 WNDPROC original_handler_; | |
| 118 | |
| 119 // Size (width and height) of images. | |
| 120 static const int kImageSize; | |
| 121 | |
| 122 DISALLOW_COPY_AND_ASSIGN(NativeTableWin); | |
| 123 }; | |
| 124 | |
| 125 } // namespace views | |
| 126 | |
| 127 #endif // VIEWS_CONTROLS_TABLE_NATIVE_TABLE_WIN_H_ | |
| OLD | NEW |