diff options
author | jcampan@chromium.org <jcampan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-11-12 00:26:44 +0000 |
---|---|---|
committer | jcampan@chromium.org <jcampan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-11-12 00:26:44 +0000 |
commit | d0545b7f65cfee49e1bdfc10d256886c1fd89818 (patch) | |
tree | 65b8d32b4937e379fff7f522937095bbdf9f3654 /views/controls/table/native_table_win.h | |
parent | cdcb3bd006d0823d45187f2c7fe3c3adc0ebb031 (diff) | |
download | chromium_src-d0545b7f65cfee49e1bdfc10d256886c1fd89818.zip chromium_src-d0545b7f65cfee49e1bdfc10d256886c1fd89818.tar.gz chromium_src-d0545b7f65cfee49e1bdfc10d256886c1fd89818.tar.bz2 |
Refactoring of the TableView so it uses NativeViewControl.
At this point it does not support grouping or sorting.
Mostly refactoring things from TableView to TableView2 and NativeTableWin.
BUG=None
TEST=Unit-tests and view examples for now.
R=sky
Review URL: http://codereview.chromium.org/387021
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@31741 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'views/controls/table/native_table_win.h')
-rw-r--r-- | views/controls/table/native_table_win.h | 130 |
1 files changed, 130 insertions, 0 deletions
diff --git a/views/controls/table/native_table_win.h b/views/controls/table/native_table_win.h new file mode 100644 index 0000000..6b6c8ef --- /dev/null +++ b/views/controls/table/native_table_win.h @@ -0,0 +1,130 @@ +// Copyright (c) 2009 The Chromium Authors. All rights reserved. Use of this +// source code is governed by a BSD-style license that can be found in the +// LICENSE file. + +#ifndef VIEWS_CONTROLS_TABLE_NATIVE_TABLE_WIN_H_ +#define VIEWS_CONTROLS_TABLE_NATIVE_TABLE_WIN_H_ + +#include <windows.h> + +#include "app/table_model.h" +#include "views/controls/native_control_win.h" +#include "views/controls/table/native_table_wrapper.h" + +typedef struct tagNMLVCUSTOMDRAW NMLVCUSTOMDRAW; + +namespace views { + +class TableView2; + +// A View that hosts a native Windows table. +class NativeTableWin : public NativeControlWin, public NativeTableWrapper { + public: + explicit NativeTableWin(TableView2* table); + virtual ~NativeTableWin(); + + // NativeTableWrapper implementation: + virtual int GetRowCount(); + virtual View* GetView(); + virtual void SetFocus(); + virtual gfx::NativeView GetTestingHandle() const; + virtual void InsertColumn(const TableColumn& column, int index); + virtual void RemoveColumn(int index); + virtual int GetColumnWidth(int column_index); + virtual void SetColumnWidth(int column_index, int width); + virtual int GetSelectedRowCount(); + virtual int GetFirstSelectedRow(); + virtual int GetFirstFocusedRow(); + virtual void ClearSelection(); + virtual void ClearRowFocus(); + virtual void SetSelectedState(int model_row, bool state); + virtual void SetFocusState(int model_row, bool state); + virtual bool IsRowSelected(int model_row); + virtual bool IsRowFocused(int model_row); + virtual void OnRowsChanged(int start, int length); + virtual void OnRowsAdded(int start, int length); + virtual void OnRowsRemoved(int start, int length); + virtual gfx::Rect GetBounds(); + + // Overridden from View: + virtual gfx::Size GetPreferredSize(); + + // Overridden from NativeControlWin: + virtual bool ProcessMessage(UINT message, + WPARAM w_param, + LPARAM l_param, + LRESULT* result); + + protected: + virtual void CreateNativeControl(); + + private: + // Makes |model_row| the only selected and focused row. + void Select(int model_row); + + // Notification from the ListView that the selected state of an item has + // changed. + virtual void OnSelectedStateChanged(); + + // Notification from the ListView that the used double clicked the table. + virtual void OnDoubleClick(); + + // Notification from the ListView that the user middle clicked the table. + virtual void OnMiddleClick(); + + // Overridden from NativeControl. Notifies the observer. + virtual bool OnKeyDown(base::KeyboardCode virtual_keycode); + + // Notification from the ListView that the checked state of the item has + // changed. + void OnCheckedStateChanged(int model_row, bool is_checked); + + // Custom drawing of our icons. + LRESULT OnCustomDraw(NMLVCUSTOMDRAW* draw_info); + + void UpdateListViewCache(int start, int length, bool add); + + void UpdateContentOffset(); + + // Window procedure of the list view class. We subclass the list view to + // ignore WM_ERASEBKGND, which gives smoother painting during resizing. + static LRESULT CALLBACK TableWndProc(HWND window, + UINT message, + WPARAM w_param, + LPARAM l_param); + + // Window procedure of the header class. We subclass the header of the table + // to disable resizing of columns. + static LRESULT CALLBACK TableHeaderWndProc(HWND window, + UINT message, + WPARAM w_param, + LPARAM l_param); + + // If true, any events that would normally be propagated to the observer + // are ignored. For example, if this is true and the selection changes in + // the listview, the observer is not notified. + bool ignore_listview_change_; + + // The Table we are bound to. + TableView2* table_; + + // The Y offset from the top of the table to the actual content (passed the + // header if any). + int content_offset_; + + // The list view's header original proc handler. It is required when + // subclassing. + WNDPROC header_original_handler_; + + // Window procedure of the listview before we subclassed it. + WNDPROC original_handler_; + + // Size (width and height) of images. + static const int kImageSize; + + DISALLOW_COPY_AND_ASSIGN(NativeTableWin); +}; + +} // namespace views + +#endif // VIEWS_CONTROLS_TABLE_NATIVE_TABLE_WIN_H_ |