summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--chrome/browser/bookmarks/bookmark_table_model.cc4
-rw-r--r--chrome/browser/bookmarks/bookmark_table_model.h9
-rw-r--r--chrome/browser/task_manager_win.cc2
-rw-r--r--chrome/browser/views/bookmark_manager_view.cc1
-rw-r--r--chrome/browser/views/bookmark_manager_view.h2
-rw-r--r--chrome/browser/views/bookmark_table_view.cc2
-rw-r--r--chrome/browser/views/hung_renderer_view.cc1
-rw-r--r--chrome/browser/views/keyword_editor_view.cc1
-rw-r--r--chrome/browser/views/keyword_editor_view.h3
-rw-r--r--chrome/browser/views/options/advanced_contents_view.cc1
-rw-r--r--chrome/browser/views/options/cookies_view.cc1
-rw-r--r--chrome/browser/views/options/cookies_view.h8
-rw-r--r--chrome/browser/views/options/exceptions_page_view.h1
-rw-r--r--chrome/browser/views/options/general_page_view.h1
-rw-r--r--chrome/browser/views/options/languages_page_view.cc3
-rw-r--r--chrome/browser/views/options/languages_page_view.h2
-rw-r--r--chrome/browser/views/options/passwords_page_view.h2
-rw-r--r--chrome/browser/views/shelf_item_dialog.cc3
-rw-r--r--chrome/browser/views/shelf_item_dialog.h3
-rw-r--r--chrome/chrome.gyp5
-rw-r--r--views/controls/button/native_button.h2
-rw-r--r--views/controls/button/native_button_wrapper.h3
-rw-r--r--views/controls/button/text_button.h6
-rw-r--r--views/controls/table/group_table_view.h1
-rw-r--r--views/controls/table/table_model.cc68
-rw-r--r--views/controls/table/table_model.h154
-rw-r--r--views/controls/table/table_model_observer.h29
-rw-r--r--views/controls/table/table_view.cc2
-rw-r--r--views/controls/table/table_view.h214
-rw-r--r--views/controls/table/table_view_observer.h35
-rw-r--r--views/controls/table/table_view_unittest.cc1
-rw-r--r--views/views.gyp5
32 files changed, 347 insertions, 228 deletions
diff --git a/chrome/browser/bookmarks/bookmark_table_model.cc b/chrome/browser/bookmarks/bookmark_table_model.cc
index 85d4032..53e712e 100644
--- a/chrome/browser/bookmarks/bookmark_table_model.cc
+++ b/chrome/browser/bookmarks/bookmark_table_model.cc
@@ -20,6 +20,10 @@
#include "grit/theme_resources.h"
#include "net/base/net_util.h"
+#if defined(TOOLKIT_VIEWS)
+#include "views/controls/table/table_model_observer.h"
+#endif
+
namespace {
// Number of bookmarks shown in recently bookmarked.
diff --git a/chrome/browser/bookmarks/bookmark_table_model.h b/chrome/browser/bookmarks/bookmark_table_model.h
index 77ad787..7832f35 100644
--- a/chrome/browser/bookmarks/bookmark_table_model.h
+++ b/chrome/browser/bookmarks/bookmark_table_model.h
@@ -5,13 +5,12 @@
#ifndef CHROME_BROWSER_BOOKMARKS_BOOKMARK_TABLE_MODEL_H_
#define CHROME_BROWSER_BOOKMARKS_BOOKMARK_TABLE_MODEL_H_
-#include "chrome/browser/bookmarks/bookmark_model.h"
-
#include "build/build_config.h"
+#include "chrome/browser/bookmarks/bookmark_model.h"
-#if defined(OS_WIN)
-#include "views/controls/table/table_view.h"
-#elif defined(OS_POSIX)
+#if defined(TOOLKIT_VIEWS)
+#include "views/controls/table/table_model.h"
+#else
#include "chrome/common/temp_scaffolding_stubs.h"
#endif
diff --git a/chrome/browser/task_manager_win.cc b/chrome/browser/task_manager_win.cc
index 7fc7492..3f8c8dd 100644
--- a/chrome/browser/task_manager_win.cc
+++ b/chrome/browser/task_manager_win.cc
@@ -4,6 +4,7 @@
#include "chrome/browser/task_manager.h"
+#include "app/l10n_util.h"
#include "base/stats_table.h"
#include "chrome/app/chrome_dll_resource.h"
#include "chrome/browser/browser_list.h"
@@ -19,6 +20,7 @@
#include "views/controls/link.h"
#include "views/controls/menu/menu.h"
#include "views/controls/table/group_table_view.h"
+#include "views/controls/table/table_view_observer.h"
#include "views/standard_layout.h"
#include "views/widget/widget.h"
#include "views/window/dialog_delegate.h"
diff --git a/chrome/browser/views/bookmark_manager_view.cc b/chrome/browser/views/bookmark_manager_view.cc
index 1a8293fc..2852b33 100644
--- a/chrome/browser/views/bookmark_manager_view.cc
+++ b/chrome/browser/views/bookmark_manager_view.cc
@@ -8,6 +8,7 @@
#include "app/gfx/canvas.h"
#include "app/gfx/color_utils.h"
+#include "app/l10n_util.h"
#include "base/thread.h"
#include "chrome/browser/bookmarks/bookmark_folder_tree_model.h"
#include "chrome/browser/bookmarks/bookmark_html_writer.h"
diff --git a/chrome/browser/views/bookmark_manager_view.h b/chrome/browser/views/bookmark_manager_view.h
index a6ee77c96..12706fd 100644
--- a/chrome/browser/views/bookmark_manager_view.h
+++ b/chrome/browser/views/bookmark_manager_view.h
@@ -11,7 +11,7 @@
#include "chrome/browser/bookmarks/bookmark_model.h"
#include "chrome/browser/shell_dialogs.h"
#include "views/controls/menu/view_menu_delegate.h"
-#include "views/controls/table/table_view.h"
+#include "views/controls/table/table_view_observer.h"
#include "views/controls/textfield/textfield.h"
#include "views/controls/tree/tree_view.h"
#include "views/view.h"
diff --git a/chrome/browser/views/bookmark_table_view.cc b/chrome/browser/views/bookmark_table_view.cc
index a0236bf..8a74777 100644
--- a/chrome/browser/views/bookmark_table_view.cc
+++ b/chrome/browser/views/bookmark_table_view.cc
@@ -9,6 +9,7 @@
#include "app/drag_drop_types.h"
#include "app/gfx/canvas.h"
#include "app/gfx/font.h"
+#include "app/l10n_util.h"
#include "app/os_exchange_data.h"
#include "app/resource_bundle.h"
#include "base/base_drag_source.h"
@@ -19,6 +20,7 @@
#include "chrome/common/pref_names.h"
#include "chrome/common/pref_service.h"
#include "grit/generated_resources.h"
+#include "views/controls/table/table_view_observer.h"
#include "views/view_constants.h"
namespace {
diff --git a/chrome/browser/views/hung_renderer_view.cc b/chrome/browser/views/hung_renderer_view.cc
index adc08d5..de96a8e 100644
--- a/chrome/browser/views/hung_renderer_view.cc
+++ b/chrome/browser/views/hung_renderer_view.cc
@@ -5,6 +5,7 @@
#include "chrome/browser/hung_renderer_dialog.h"
#include "app/gfx/canvas.h"
+#include "app/l10n_util.h"
#include "app/resource_bundle.h"
#include "chrome/browser/browser_list.h"
#include "chrome/browser/renderer_host/render_process_host.h"
diff --git a/chrome/browser/views/keyword_editor_view.cc b/chrome/browser/views/keyword_editor_view.cc
index d17056d..d21b314 100644
--- a/chrome/browser/views/keyword_editor_view.cc
+++ b/chrome/browser/views/keyword_editor_view.cc
@@ -28,6 +28,7 @@
#include "views/background.h"
#include "views/grid_layout.h"
#include "views/controls/button/native_button.h"
+#include "views/controls/table/table_view.h"
#include "views/controls/textfield/textfield.h"
#include "views/standard_layout.h"
#include "views/widget/widget.h"
diff --git a/chrome/browser/views/keyword_editor_view.h b/chrome/browser/views/keyword_editor_view.h
index ef8b456..8b093c7 100644
--- a/chrome/browser/views/keyword_editor_view.h
+++ b/chrome/browser/views/keyword_editor_view.h
@@ -10,7 +10,8 @@
#include "chrome/browser/search_engines/template_url_model.h"
#include "views/controls/button/button.h"
-#include "views/controls/table/table_view.h"
+#include "views/controls/table/table_model.h"
+#include "views/controls/table/table_view_observer.h"
#include "views/view.h"
#include "views/window/dialog_delegate.h"
diff --git a/chrome/browser/views/options/advanced_contents_view.cc b/chrome/browser/views/options/advanced_contents_view.cc
index aa3974b..792370ba 100644
--- a/chrome/browser/views/options/advanced_contents_view.cc
+++ b/chrome/browser/views/options/advanced_contents_view.cc
@@ -13,6 +13,7 @@
#include <vssym32.h>
#include "app/gfx/canvas.h"
+#include "app/l10n_util.h"
#include "app/resource_bundle.h"
#include "base/file_util.h"
#include "base/path_service.h"
diff --git a/chrome/browser/views/options/cookies_view.cc b/chrome/browser/views/options/cookies_view.cc
index 797ae34..30b1e9d 100644
--- a/chrome/browser/views/options/cookies_view.cc
+++ b/chrome/browser/views/options/cookies_view.cc
@@ -23,6 +23,7 @@
#include "views/grid_layout.h"
#include "views/controls/label.h"
#include "views/controls/button/native_button.h"
+#include "views/controls/table/table_model.h"
#include "views/controls/table/table_view.h"
#include "views/controls/textfield/textfield.h"
#include "views/standard_layout.h"
diff --git a/chrome/browser/views/options/cookies_view.h b/chrome/browser/views/options/cookies_view.h
index 521dc7f..997841d 100644
--- a/chrome/browser/views/options/cookies_view.h
+++ b/chrome/browser/views/options/cookies_view.h
@@ -7,16 +7,20 @@
#include "base/task.h"
#include "views/controls/button/button.h"
-#include "views/controls/table/table_view.h"
+#include "views/controls/table/table_view_observer.h"
#include "views/controls/textfield/textfield.h"
#include "views/view.h"
#include "views/window/dialog_delegate.h"
#include "views/window/window.h"
namespace views {
+
class Label;
class NativeButton;
-}
+class TableView;
+
+} // namespace views
+
class CookieInfoView;
class CookiesTableModel;
class CookiesTableView;
diff --git a/chrome/browser/views/options/exceptions_page_view.h b/chrome/browser/views/options/exceptions_page_view.h
index e0abe67..7a2906b 100644
--- a/chrome/browser/views/options/exceptions_page_view.h
+++ b/chrome/browser/views/options/exceptions_page_view.h
@@ -7,6 +7,7 @@
#include "chrome/browser/views/options/options_page_view.h"
#include "chrome/browser/views/options/passwords_page_view.h"
+#include "views/controls/table/table_view_observer.h"
class Profile;
diff --git a/chrome/browser/views/options/general_page_view.h b/chrome/browser/views/options/general_page_view.h
index 077c2f3..a75fb99 100644
--- a/chrome/browser/views/options/general_page_view.h
+++ b/chrome/browser/views/options/general_page_view.h
@@ -10,6 +10,7 @@
#include "chrome/common/pref_member.h"
#include "views/controls/combo_box.h"
#include "views/controls/button/button.h"
+#include "views/controls/table/table_view_observer.h"
#include "views/view.h"
namespace views {
diff --git a/chrome/browser/views/options/languages_page_view.cc b/chrome/browser/views/options/languages_page_view.cc
index 817bdac..48932f9 100644
--- a/chrome/browser/views/options/languages_page_view.cc
+++ b/chrome/browser/views/options/languages_page_view.cc
@@ -31,6 +31,9 @@
#include "views/controls/button/radio_button.h"
#include "views/controls/combo_box.h"
#include "views/controls/tabbed_pane.h"
+#include "views/controls/table/table_model.h"
+#include "views/controls/table/table_model_observer.h"
+#include "views/controls/table/table_view.h"
#include "views/grid_layout.h"
#include "views/standard_layout.h"
#include "views/widget/widget.h"
diff --git a/chrome/browser/views/options/languages_page_view.h b/chrome/browser/views/options/languages_page_view.h
index 308df34..b0ad138 100644
--- a/chrome/browser/views/options/languages_page_view.h
+++ b/chrome/browser/views/options/languages_page_view.h
@@ -9,7 +9,7 @@
#include "chrome/common/pref_member.h"
#include "views/controls/combo_box.h"
#include "views/controls/button/button.h"
-#include "views/controls/table/table_view.h"
+#include "views/controls/table/table_view_observer.h"
#include "views/view.h"
namespace views {
diff --git a/chrome/browser/views/options/passwords_page_view.h b/chrome/browser/views/options/passwords_page_view.h
index 2fd9e46..35cb31e 100644
--- a/chrome/browser/views/options/passwords_page_view.h
+++ b/chrome/browser/views/options/passwords_page_view.h
@@ -15,6 +15,8 @@
#include "views/controls/button/native_button.h"
#include "views/controls/label.h"
#include "views/controls/table/table_view.h"
+#include "views/controls/table/table_model.h"
+#include "views/controls/table/table_view_observer.h"
#include "views/window/dialog_delegate.h"
#include "views/window/window.h"
#include "webkit/glue/password_form.h"
diff --git a/chrome/browser/views/shelf_item_dialog.cc b/chrome/browser/views/shelf_item_dialog.cc
index 0b68634..c80f991 100644
--- a/chrome/browser/views/shelf_item_dialog.cc
+++ b/chrome/browser/views/shelf_item_dialog.cc
@@ -21,6 +21,9 @@
#include "net/base/net_util.h"
#include "views/background.h"
#include "views/controls/label.h"
+#include "views/controls/table/table_model.h"
+#include "views/controls/table/table_model_observer.h"
+#include "views/controls/table/table_view.h"
#include "views/controls/textfield/textfield.h"
#include "views/focus/focus_manager.h"
#include "views/grid_layout.h"
diff --git a/chrome/browser/views/shelf_item_dialog.h b/chrome/browser/views/shelf_item_dialog.h
index 73a85ef..8f5953a 100644
--- a/chrome/browser/views/shelf_item_dialog.h
+++ b/chrome/browser/views/shelf_item_dialog.h
@@ -8,7 +8,7 @@
#include "chrome/browser/cancelable_request.h"
#include "chrome/browser/history/history.h"
#include "views/controls/button/native_button.h"
-#include "views/controls/table/table_view.h"
+#include "views/controls/table/table_view_observer.h"
#include "views/controls/textfield/textfield.h"
#include "views/view.h"
#include "views/window/dialog_delegate.h"
@@ -17,6 +17,7 @@
namespace views {
class Button;
class Label;
+class TableView;
}
class PossibleURLModel;
diff --git a/chrome/chrome.gyp b/chrome/chrome.gyp
index 1f6617b..f17b24e 100644
--- a/chrome/chrome.gyp
+++ b/chrome/chrome.gyp
@@ -1358,8 +1358,13 @@
'browser/views/bookmark_menu_button.h',
'browser/views/bookmark_menu_controller_views.cc',
'browser/views/bookmark_menu_controller_views.h',
+ 'browser/views/bookmark_table_model.cc',
+ 'browser/views/bookmark_table_model.h',
+ 'browser/views/bookmark_table_model_observer.h',
'browser/views/bookmark_table_view.cc',
'browser/views/bookmark_table_view.h',
+ 'browser/views/bookmark_table_view_observer.h',
+ 'browser/views/bookmark_table_observer.h',
'browser/views/browser_bubble.cc',
'browser/views/browser_bubble.h',
'browser/views/browser_bubble_gtk.cc',
diff --git a/views/controls/button/native_button.h b/views/controls/button/native_button.h
index 50aaff73..3b77d5f 100644
--- a/views/controls/button/native_button.h
+++ b/views/controls/button/native_button.h
@@ -99,4 +99,4 @@ class NativeButton : public Button {
} // namespace views
-#endif // #ifndef VIEWS_CONTROLS_BUTTON_NATIVE_BUTTON_H_
+#endif // VIEWS_CONTROLS_BUTTON_NATIVE_BUTTON_H_
diff --git a/views/controls/button/native_button_wrapper.h b/views/controls/button/native_button_wrapper.h
index 4ae939c..07739af 100644
--- a/views/controls/button/native_button_wrapper.h
+++ b/views/controls/button/native_button_wrapper.h
@@ -53,9 +53,8 @@ class NativeButtonWrapper {
static NativeButtonWrapper* CreateCheckboxWrapper(Checkbox* checkbox);
static NativeButtonWrapper* CreateRadioButtonWrapper(
RadioButton* radio_button);
-
};
} // namespace views
-#endif // #ifndef VIEWS_CONTROLS_BUTTON_NATIVE_BUTTON_WRAPPER_H_
+#endif // VIEWS_CONTROLS_BUTTON_NATIVE_BUTTON_WRAPPER_H_
diff --git a/views/controls/button/text_button.h b/views/controls/button/text_button.h
index 8b3d343..1a8134e 100644
--- a/views/controls/button/text_button.h
+++ b/views/controls/button/text_button.h
@@ -32,8 +32,6 @@ class TextButtonBorder : public Border {
virtual void GetInsets(gfx::Insets* insets) const;
private:
- DISALLOW_EVIL_CONSTRUCTORS(TextButtonBorder);
-
// Images
struct MBBImageSet {
SkBitmap* top_left;
@@ -48,6 +46,8 @@ class TextButtonBorder : public Border {
};
MBBImageSet hot_set_;
MBBImageSet pushed_set_;
+
+ DISALLOW_COPY_AND_ASSIGN(TextButtonBorder);
};
@@ -130,7 +130,7 @@ class TextButton : public CustomButton {
// indicates the width is not constrained.
int max_width_;
- DISALLOW_EVIL_CONSTRUCTORS(TextButton);
+ DISALLOW_COPY_AND_ASSIGN(TextButton);
};
} // namespace views
diff --git a/views/controls/table/group_table_view.h b/views/controls/table/group_table_view.h
index e581d5d..c92587f 100644
--- a/views/controls/table/group_table_view.h
+++ b/views/controls/table/group_table_view.h
@@ -6,6 +6,7 @@
#define VIEWS_CONTROLS_TABLE_GROUP_TABLE_VIEW_H_
#include "base/task.h"
+#include "views/controls/table/table_model.h"
#include "views/controls/table/table_view.h"
// The GroupTableView adds grouping to the TableView class.
diff --git a/views/controls/table/table_model.cc b/views/controls/table/table_model.cc
new file mode 100644
index 0000000..7e1dd0e
--- /dev/null
+++ b/views/controls/table/table_model.cc
@@ -0,0 +1,68 @@
+// 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.
+
+#include "views/controls/table/table_model.h"
+
+#include "app/l10n_util.h"
+
+namespace views {
+
+TableColumn::TableColumn()
+ : id(0),
+ title(),
+ alignment(LEFT),
+ width(-1),
+ percent(),
+ min_visible_width(0),
+ sortable(false) {
+}
+
+TableColumn::TableColumn(int id, const std::wstring& title,
+ Alignment alignment,
+ int width)
+ : id(id),
+ title(title),
+ alignment(alignment),
+ width(width),
+ percent(0),
+ min_visible_width(0),
+ sortable(false) {
+}
+
+TableColumn::TableColumn(int id, const std::wstring& title,
+ Alignment alignment, int width, float percent)
+ : id(id),
+ title(title),
+ alignment(alignment),
+ width(width),
+ percent(percent),
+ min_visible_width(0),
+ sortable(false) {
+}
+
+// It's common (but not required) to use the title's IDS_* tag as the column
+// id. In this case, the provided conveniences look up the title string on
+// bahalf of the caller.
+TableColumn::TableColumn(int id, Alignment alignment, int width)
+ : id(id),
+ alignment(alignment),
+ width(width),
+ percent(0),
+ min_visible_width(0),
+ sortable(false) {
+ title = l10n_util::GetString(id);
+}
+
+TableColumn::TableColumn(int id, Alignment alignment, int width, float percent)
+ : id(id),
+ alignment(alignment),
+ width(width),
+ percent(percent),
+ min_visible_width(0),
+ sortable(false) {
+ title = l10n_util::GetString(id);
+}
+
+} // namespace views
+
diff --git a/views/controls/table/table_model.h b/views/controls/table/table_model.h
new file mode 100644
index 0000000..5c377c7
--- /dev/null
+++ b/views/controls/table/table_model.h
@@ -0,0 +1,154 @@
+// 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_TABLE_MODEL_H_
+#define VIEWS_CONTROLS_TABLE_TABLE_MODEL_H_
+
+#include <string>
+#include <vector>
+
+#include "base/logging.h"
+#include "unicode/coll.h"
+
+class SkBitmap;
+
+namespace views {
+
+class TableModelObserver;
+
+// The model driving the TableView.
+class TableModel {
+ public:
+ // See HasGroups, get GetGroupID for details as to how this is used.
+ struct Group {
+ // The title text for the group.
+ std::wstring title;
+
+ // Unique id for the group.
+ int id;
+ };
+ typedef std::vector<Group> Groups;
+
+ // Number of rows in the model.
+ virtual int RowCount() = 0;
+
+ // Returns the value at a particular location in text.
+ virtual std::wstring GetText(int row, int column_id) = 0;
+
+ // Returns the small icon (16x16) that should be displayed in the first
+ // column before the text. This is only used when the TableView was created
+ // with the ICON_AND_TEXT table type. Returns an isNull() bitmap if there is
+ // no bitmap.
+ virtual SkBitmap GetIcon(int row);
+
+ // Sets whether a particular row is checked. This is only invoked
+ // if the TableView was created with show_check_in_first_column true.
+ virtual void SetChecked(int row, bool is_checked) {
+ NOTREACHED();
+ }
+
+ // Returns whether a particular row is checked. This is only invoked
+ // if the TableView was created with show_check_in_first_column true.
+ virtual bool IsChecked(int row) {
+ return false;
+ }
+
+ // Returns true if the TableView has groups. Groups provide a way to visually
+ // delineate the rows in a table view. When groups are enabled table view
+ // shows a visual separator for each group, followed by all the rows in
+ // the group.
+ //
+ // On win2k a visual separator is not rendered for the group headers.
+ virtual bool HasGroups() { return false; }
+
+ // Returns the groups.
+ // This is only used if HasGroups returns true.
+ virtual Groups GetGroups() {
+ // If you override HasGroups to return true, you must override this as
+ // well.
+ NOTREACHED();
+ return std::vector<Group>();
+ }
+
+ // Returns the group id of the specified row.
+ // This is only used if HasGroups returns true.
+ virtual int GetGroupID(int row) {
+ // If you override HasGroups to return true, you must override this as
+ // well.
+ NOTREACHED();
+ return 0;
+ }
+
+ // Sets the observer for the model. The TableView should NOT take ownership
+ // of the observer.
+ virtual void SetObserver(TableModelObserver* observer) = 0;
+
+ // Compares the values in the column with id |column_id| for the two rows.
+ // Returns a value < 0, == 0 or > 0 as to whether the first value is
+ // <, == or > the second value.
+ //
+ // This implementation does a case insensitive locale specific string
+ // comparison.
+ virtual int CompareValues(int row1, int row2, int column_id);
+
+ protected:
+ // Returns the collator used by CompareValues.
+ Collator* GetCollator();
+};
+
+// TableColumn specifies the title, alignment and size of a particular column.
+struct TableColumn {
+ enum Alignment {
+ LEFT, RIGHT, CENTER
+ };
+
+ TableColumn();
+ TableColumn(int id, const std::wstring& title,
+ Alignment alignment, int width);
+ TableColumn(int id, const std::wstring& title,
+ Alignment alignment, int width, float percent);
+
+ // It's common (but not required) to use the title's IDS_* tag as the column
+ // id. In this case, the provided conveniences look up the title string on
+ // bahalf of the caller.
+ TableColumn(int id, Alignment alignment, int width);
+ TableColumn(int id, Alignment alignment, int width, float percent);
+
+ // A unique identifier for the column.
+ int id;
+
+ // The title for the column.
+ std::wstring title;
+
+ // Alignment for the content.
+ Alignment alignment;
+
+ // The size of a column may be specified in two ways:
+ // 1. A fixed width. Set the width field to a positive number and the
+ // column will be given that width, in pixels.
+ // 2. As a percentage of the available width. If width is -1, and percent is
+ // > 0, the column is given a width of
+ // available_width * percent / total_percent.
+ // 3. If the width == -1 and percent == 0, the column is autosized based on
+ // the width of the column header text.
+ //
+ // Sizing is done in four passes. Fixed width columns are given
+ // their width, percentages are applied, autosized columns are autosized,
+ // and finally percentages are applied again taking into account the widths
+ // of autosized columns.
+ int width;
+ float percent;
+
+ // The minimum width required for all items in this column
+ // (including the header)
+ // to be visible.
+ int min_visible_width;
+
+ // Is this column sortable? Default is false
+ bool sortable;
+};
+
+} // namespace views
+
+#endif // VIEWS_CONTROLS_TABLE_TABLE_MODEL_H_
diff --git a/views/controls/table/table_model_observer.h b/views/controls/table/table_model_observer.h
new file mode 100644
index 0000000..b968a9f
--- /dev/null
+++ b/views/controls/table/table_model_observer.h
@@ -0,0 +1,29 @@
+// 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_CONTROL_TABLE_TABLE_MODEL_OBSERVER_H_
+#define VIEWS_CONTROL_TABLE_TABLE_MODEL_OBSERVER_H_
+
+namespace views {
+
+// Observer for a TableModel. Anytime the model changes, it must notify its
+// observer.
+class TableModelObserver {
+ public:
+ // Invoked when the model has been completely changed.
+ virtual void OnModelChanged() = 0;
+
+ // Invoked when a range of items has changed.
+ virtual void OnItemsChanged(int start, int length) = 0;
+
+ // Invoked when new items are added.
+ virtual void OnItemsAdded(int start, int length) = 0;
+
+ // Invoked when a range of items has been removed.
+ virtual void OnItemsRemoved(int start, int length) = 0;
+};
+
+} // namespace views
+
+#endif // VIEWS_CONTROL_TABLE_TABLE_MODEL_OBSERVER_H_
diff --git a/views/controls/table/table_view.cc b/views/controls/table/table_view.cc
index d114b2d6..4e095cf 100644
--- a/views/controls/table/table_view.cc
+++ b/views/controls/table/table_view.cc
@@ -22,6 +22,8 @@
#include "third_party/skia/include/core/SkBitmap.h"
#include "third_party/skia/include/core/SkColorFilter.h"
#include "views/controls/native/native_view_host.h"
+#include "views/controls/table/table_model.h"
+#include "views/controls/table/table_view_observer.h"
namespace views {
diff --git a/views/controls/table/table_view.h b/views/controls/table/table_view.h
index c1a9a23..94198f8 100644
--- a/views/controls/table/table_view.h
+++ b/views/controls/table/table_view.h
@@ -13,17 +13,14 @@ typedef struct tagNMLVCUSTOMDRAW NMLVCUSTOMDRAW;
#endif // defined(OS_WIN)
#include <map>
-#include <unicode/coll.h>
-#include <unicode/uchar.h>
#include <vector>
-#include "app/l10n_util.h"
-#include "base/logging.h"
#include "third_party/skia/include/core/SkColor.h"
#if defined(OS_WIN)
// TODO(port): remove the ifdef when native_control.h is ported.
#include "views/controls/native_control.h"
#endif // defined(OS_WIN)
+#include "views/controls/table/table_model_observer.h"
class SkBitmap;
@@ -55,6 +52,8 @@ class ListView;
class ListViewParent;
class TableView;
struct TableColumn;
+class TableModel;
+class TableViewObserver;
// The cells in the first column of a table can contain:
// - only text
@@ -66,192 +65,6 @@ enum TableTypes {
CHECK_BOX_AND_TEXT
};
-// Any time the TableModel changes, it must notify its observer.
-class TableModelObserver {
- public:
- // Invoked when the model has been completely changed.
- virtual void OnModelChanged() = 0;
-
- // Invoked when a range of items has changed.
- virtual void OnItemsChanged(int start, int length) = 0;
-
- // Invoked when new items are added.
- virtual void OnItemsAdded(int start, int length) = 0;
-
- // Invoked when a range of items has been removed.
- virtual void OnItemsRemoved(int start, int length) = 0;
-};
-
-// The model driving the TableView.
-class TableModel {
- public:
- // See HasGroups, get GetGroupID for details as to how this is used.
- struct Group {
- // The title text for the group.
- std::wstring title;
-
- // Unique id for the group.
- int id;
- };
- typedef std::vector<Group> Groups;
-
- // Number of rows in the model.
- virtual int RowCount() = 0;
-
- // Returns the value at a particular location in text.
- virtual std::wstring GetText(int row, int column_id) = 0;
-
- // Returns the small icon (16x16) that should be displayed in the first
- // column before the text. This is only used when the TableView was created
- // with the ICON_AND_TEXT table type. Returns an isNull() bitmap if there is
- // no bitmap.
- virtual SkBitmap GetIcon(int row);
-
- // Sets whether a particular row is checked. This is only invoked
- // if the TableView was created with show_check_in_first_column true.
- virtual void SetChecked(int row, bool is_checked) {
- NOTREACHED();
- }
-
- // Returns whether a particular row is checked. This is only invoked
- // if the TableView was created with show_check_in_first_column true.
- virtual bool IsChecked(int row) {
- return false;
- }
-
- // Returns true if the TableView has groups. Groups provide a way to visually
- // delineate the rows in a table view. When groups are enabled table view
- // shows a visual separator for each group, followed by all the rows in
- // the group.
- //
- // On win2k a visual separator is not rendered for the group headers.
- virtual bool HasGroups() { return false; }
-
- // Returns the groups.
- // This is only used if HasGroups returns true.
- virtual Groups GetGroups() {
- // If you override HasGroups to return true, you must override this as
- // well.
- NOTREACHED();
- return std::vector<Group>();
- }
-
- // Returns the group id of the specified row.
- // This is only used if HasGroups returns true.
- virtual int GetGroupID(int row) {
- // If you override HasGroups to return true, you must override this as
- // well.
- NOTREACHED();
- return 0;
- }
-
- // Sets the observer for the model. The TableView should NOT take ownership
- // of the observer.
- virtual void SetObserver(TableModelObserver* observer) = 0;
-
- // Compares the values in the column with id |column_id| for the two rows.
- // Returns a value < 0, == 0 or > 0 as to whether the first value is
- // <, == or > the second value.
- //
- // This implementation does a case insensitive locale specific string
- // comparison.
- virtual int CompareValues(int row1, int row2, int column_id);
-
- protected:
- // Returns the collator used by CompareValues.
- Collator* GetCollator();
-};
-
-// TableColumn specifies the title, alignment and size of a particular column.
-struct TableColumn {
- enum Alignment {
- LEFT, RIGHT, CENTER
- };
-
- TableColumn()
- : id(0),
- title(),
- alignment(LEFT),
- width(-1),
- percent(),
- min_visible_width(0),
- sortable(false) {
- }
- TableColumn(int id, const std::wstring title, Alignment alignment, int width)
- : id(id),
- title(title),
- alignment(alignment),
- width(width),
- percent(0),
- min_visible_width(0),
- sortable(false) {
- }
- TableColumn(int id, const std::wstring title, Alignment alignment, int width,
- float percent)
- : id(id),
- title(title),
- alignment(alignment),
- width(width),
- percent(percent),
- min_visible_width(0),
- sortable(false) {
- }
- // It's common (but not required) to use the title's IDS_* tag as the column
- // id. In this case, the provided conveniences look up the title string on
- // bahalf of the caller.
- TableColumn(int id, Alignment alignment, int width)
- : id(id),
- alignment(alignment),
- width(width),
- percent(0),
- min_visible_width(0),
- sortable(false) {
- title = l10n_util::GetString(id);
- }
- TableColumn(int id, Alignment alignment, int width, float percent)
- : id(id),
- alignment(alignment),
- width(width),
- percent(percent),
- min_visible_width(0),
- sortable(false) {
- title = l10n_util::GetString(id);
- }
-
- // A unique identifier for the column.
- int id;
-
- // The title for the column.
- std::wstring title;
-
- // Alignment for the content.
- Alignment alignment;
-
- // The size of a column may be specified in two ways:
- // 1. A fixed width. Set the width field to a positive number and the
- // column will be given that width, in pixels.
- // 2. As a percentage of the available width. If width is -1, and percent is
- // > 0, the column is given a width of
- // available_width * percent / total_percent.
- // 3. If the width == -1 and percent == 0, the column is autosized based on
- // the width of the column header text.
- //
- // Sizing is done in four passes. Fixed width columns are given
- // their width, percentages are applied, autosized columns are autosized,
- // and finally percentages are applied again taking into account the widths
- // of autosized columns.
- int width;
- float percent;
-
- // The minimum width required for all items in this column
- // (including the header)
- // to be visible.
- int min_visible_width;
-
- // Is this column sortable? Default is false
- bool sortable;
-};
-
// Returned from SelectionBegin/SelectionEnd
class TableSelectionIterator {
public:
@@ -273,27 +86,6 @@ class TableSelectionIterator {
int model_index_;
};
-// TableViewObserver is notified about the TableView selection.
-class TableViewObserver {
- public:
- virtual ~TableViewObserver() {}
-
- // Invoked when the selection changes.
- virtual void OnSelectionChanged() = 0;
-
- // Optional method invoked when the user double clicks on the table.
- virtual void OnDoubleClick() {}
-
- // Optional method invoked when the user middle clicks on the table.
- virtual void OnMiddleClick() {}
-
- // Optional method invoked when the user hits a key with the table in focus.
- virtual void OnKeyDown(unsigned short virtual_keycode) {}
-
- // Invoked when the user presses the delete key.
- virtual void OnTableViewDelete(TableView* table_view) {}
-};
-
#if defined(OS_WIN)
// TODO(port): Port TableView.
class TableView : public NativeControl,
diff --git a/views/controls/table/table_view_observer.h b/views/controls/table/table_view_observer.h
new file mode 100644
index 0000000..c88cb21
--- /dev/null
+++ b/views/controls/table/table_view_observer.h
@@ -0,0 +1,35 @@
+// Copyright (c) 2006-2008 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_TABLE_VIEW_OBSERVER_H_
+#define VIEWS_CONTROLS_TABLE_TABLE_VIEW_OBSERVER_H_
+
+namespace views {
+
+class TableView;
+
+// TableViewObserver is notified about the TableView selection.
+class TableViewObserver {
+ public:
+ virtual ~TableViewObserver() {}
+
+ // Invoked when the selection changes.
+ virtual void OnSelectionChanged() = 0;
+
+ // Optional method invoked when the user double clicks on the table.
+ virtual void OnDoubleClick() {}
+
+ // Optional method invoked when the user middle clicks on the table.
+ virtual void OnMiddleClick() {}
+
+ // Optional method invoked when the user hits a key with the table in focus.
+ virtual void OnKeyDown(unsigned short virtual_keycode) {}
+
+ // Invoked when the user presses the delete key.
+ virtual void OnTableViewDelete(TableView* table_view) {}
+};
+
+} // namespace views
+
+#endif // VIEWS_CONTROLS_TABLE_TABLE_VIEW_OBSERVER_H_
diff --git a/views/controls/table/table_view_unittest.cc b/views/controls/table/table_view_unittest.cc
index e0f08e2..c3d0a75 100644
--- a/views/controls/table/table_view_unittest.cc
+++ b/views/controls/table/table_view_unittest.cc
@@ -7,6 +7,7 @@
#include "base/message_loop.h"
#include "base/string_util.h"
#include "testing/gtest/include/gtest/gtest.h"
+#include "views/controls/table/table_model.h"
#include "views/controls/table/table_view.h"
#include "views/window/window_delegate.h"
#include "views/window/window_win.h"
diff --git a/views/views.gyp b/views/views.gyp
index a438e81d..42423be 100644
--- a/views/views.gyp
+++ b/views/views.gyp
@@ -134,8 +134,12 @@
'controls/tabbed_pane.h',
'controls/table/group_table_view.cc',
'controls/table/group_table_view.h',
+ 'controls/table/table_model.cc',
+ 'controls/table/table_model.h',
+ 'controls/table/table_model_observer.h',
'controls/table/table_view.cc',
'controls/table/table_view.h',
+ 'controls/table/table_view_observer.h',
'controls/textfield/textfield.cc',
'controls/textfield/textfield.h',
'controls/textfield/native_textfield_gtk.cc',
@@ -250,6 +254,7 @@
'controls/separator.cc',
'controls/single_split_view.cc',
'controls/tabbed_pane.cc',
+ 'controls/table/table_model.cc',
'controls/table/table_view.cc',
'controls/table/group_table_view.cc',
'controls/tree/tree_view.cc',