Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(105)

Side by Side Diff: chrome/views/table_view.h

Issue 1822: Task Manager Double Click (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 12 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « chrome/views/group_table_view.cc ('k') | chrome/views/table_view.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2006-2008 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 CHROME_VIEWS_TABLE_VIEW_H__ 5 #ifndef CHROME_VIEWS_TABLE_VIEW_H__
6 #define CHROME_VIEWS_TABLE_VIEW_H__ 6 #define CHROME_VIEWS_TABLE_VIEW_H__
7 7
8 #include <windows.h> 8 #include <windows.h>
9 9
10 #include <map>
11 #include <vector>
12
10 #include "base/logging.h" 13 #include "base/logging.h"
11 #include "chrome/common/l10n_util.h" 14 #include "chrome/common/l10n_util.h"
12 #include "chrome/views/native_control.h" 15 #include "chrome/views/native_control.h"
13 #include "SkColor.h" 16 #include "SkColor.h"
14 17
15 class SkBitmap; 18 class SkBitmap;
16 19
17 // A TableView is a view that displays multiple rows with any number of columns. 20 // A TableView is a view that displays multiple rows with any number of columns.
18 // TableView is driven by a TableModel. The model returns the contents 21 // TableView is driven by a TableModel. The model returns the contents
19 // to display. TableModel also has an Observer which is used to notify 22 // to display. TableModel also has an Observer which is used to notify
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after
123 // of the observer. 126 // of the observer.
124 virtual void SetObserver(TableModelObserver* observer) = 0; 127 virtual void SetObserver(TableModelObserver* observer) = 0;
125 }; 128 };
126 129
127 // TableColumn specifies the title, alignment and size of a particular column. 130 // TableColumn specifies the title, alignment and size of a particular column.
128 struct TableColumn { 131 struct TableColumn {
129 typedef enum Alignment { 132 typedef enum Alignment {
130 LEFT, RIGHT, CENTER 133 LEFT, RIGHT, CENTER
131 }; 134 };
132 135
133 TableColumn() : id(0), title(), alignment(LEFT), width(-1), percent(), min_vis ible_width(0) {} 136 TableColumn()
134 137 : id(0),
138 title(),
139 alignment(LEFT),
140 width(-1),
141 percent(),
142 min_visible_width(0) {
143 }
135 TableColumn(int id, const std::wstring title, Alignment alignment, int width) 144 TableColumn(int id, const std::wstring title, Alignment alignment, int width)
136 : id(id), 145 : id(id),
137 title(title), 146 title(title),
138 alignment(alignment), 147 alignment(alignment),
139 width(width), 148 width(width),
140 percent(0), 149 percent(0),
141 min_visible_width(0) { 150 min_visible_width(0) {
142 } 151 }
143 TableColumn(int id, const std::wstring title, Alignment alignment, int width, 152 TableColumn(int id, const std::wstring title, Alignment alignment, int width,
144 float percent) 153 float percent)
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
187 // 3. If the width == -1 and percent == 0, the column is autosized based on 196 // 3. If the width == -1 and percent == 0, the column is autosized based on
188 // the width of the column header text. 197 // the width of the column header text.
189 // 198 //
190 // Sizing is done in four passes. Fixed width columns are given 199 // Sizing is done in four passes. Fixed width columns are given
191 // their width, percentages are applied, autosized columns are autosized, 200 // their width, percentages are applied, autosized columns are autosized,
192 // and finally percentages are applied again taking into account the widths 201 // and finally percentages are applied again taking into account the widths
193 // of autosized columns. 202 // of autosized columns.
194 int width; 203 int width;
195 float percent; 204 float percent;
196 205
197 // The minimum width required for all items in this column (including the head er) 206 // The minimum width required for all items in this column
207 // (including the header)
198 // to be visible. 208 // to be visible.
199 int min_visible_width; 209 int min_visible_width;
200 }; 210 };
201 211
202 // Returned from SelectionBegin/SelectionEnd 212 // Returned from SelectionBegin/SelectionEnd
203 class TableSelectionIterator { 213 class TableSelectionIterator {
204 public: 214 public:
205 TableSelectionIterator(TableView* view, int index); 215 TableSelectionIterator(TableView* view, int index);
206 TableSelectionIterator& operator=(const TableSelectionIterator& other); 216 TableSelectionIterator& operator=(const TableSelectionIterator& other);
207 bool operator==(const TableSelectionIterator& other); 217 bool operator==(const TableSelectionIterator& other);
208 bool operator!=(const TableSelectionIterator& other); 218 bool operator!=(const TableSelectionIterator& other);
209 TableSelectionIterator& operator++(); 219 TableSelectionIterator& operator++();
210 int operator*(); 220 int operator*();
211 221
212 private: 222 private:
213 TableView* table_view_; 223 TableView* table_view_;
214 int index_; 224 int index_;
215 }; 225 };
216 226
217 // TableViewObserver is notified about the TableView selection. 227 // TableViewObserver is notified about the TableView selection.
218 class TableViewObserver { 228 class TableViewObserver {
219 public: 229 public:
230 virtual ~TableViewObserver() {}
231
220 // Invoked when the selection changes. 232 // Invoked when the selection changes.
221 virtual void OnSelectionChanged() = 0; 233 virtual void OnSelectionChanged() = 0;
222 234
223 // Optional method invoked when the user double clicks on the table. 235 // Optional method invoked when the user double clicks on the table.
224 virtual void OnDoubleClick() {} 236 virtual void OnDoubleClick() {}
237
238 // Optional method invoked when the user hits a key with the table in focus.
239 virtual void OnKeyDown(unsigned short virtual_keycode) {}
225 }; 240 };
226 241
227 class TableView : public NativeControl, 242 class TableView : public NativeControl,
228 public TableModelObserver { 243 public TableModelObserver {
229 public: 244 public:
230 typedef TableSelectionIterator iterator; 245 typedef TableSelectionIterator iterator;
231 246
232 // A helper struct for GetCellColors. Set |color_is_set| to true if color is 247 // A helper struct for GetCellColors. Set |color_is_set| to true if color is
233 // set. See OnCustomDraw for more details on why we need this. 248 // set. See OnCustomDraw for more details on why we need this.
234 struct ItemColor { 249 struct ItemColor {
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after
333 // GetCellColors is never invoked. 348 // GetCellColors is never invoked.
334 void SetCustomColorsEnabled(bool custom_colors_enabled); 349 void SetCustomColorsEnabled(bool custom_colors_enabled);
335 350
336 // Notification from the ListView that the selected state of an item has 351 // Notification from the ListView that the selected state of an item has
337 // changed. 352 // changed.
338 virtual void OnSelectedStateChanged(int item, bool is_selected); 353 virtual void OnSelectedStateChanged(int item, bool is_selected);
339 354
340 // Notification from the ListView that the used double clicked the table. 355 // Notification from the ListView that the used double clicked the table.
341 virtual void OnDoubleClick(); 356 virtual void OnDoubleClick();
342 357
358 // Subclasses can implement this method if they need to be notified of a key
359 // press event. Other wise, it appeals to table_view_observer_
360 virtual void OnKeyDown(unsigned short virtual_keycode);
361
343 // Invoked to customize the colors or font at a particular cell. If you 362 // Invoked to customize the colors or font at a particular cell. If you
344 // change the colors or font, return true. This is only invoked if 363 // change the colors or font, return true. This is only invoked if
345 // SetCustomColorsEnabled(true) has been invoked. 364 // SetCustomColorsEnabled(true) has been invoked.
346 virtual bool GetCellColors(int row, 365 virtual bool GetCellColors(int row,
347 int column, 366 int column,
348 ItemColor* foreground, 367 ItemColor* foreground,
349 ItemColor* background, 368 ItemColor* background,
350 LOGFONT* logfont); 369 LOGFONT* logfont);
351 370
352 // Subclasses that want to perform some custom painting (on top of the regular 371 // Subclasses that want to perform some custom painting (on top of the regular
353 // list view painting) should return true here and implement the PostPaint 372 // list view painting) should return true here and implement the PostPaint
354 // method. 373 // method.
355 virtual bool ImplementPostPaint() { return false; } 374 virtual bool ImplementPostPaint() { return false; }
356 // Subclasses can implement in this method extra-painting for cells. 375 // Subclasses can implement in this method extra-painting for cells.
357 virtual void PostPaint(int row, int column, bool selected, 376 virtual void PostPaint(int row, int column, bool selected,
358 const CRect& bounds, HDC device_context) { } 377 const CRect& bounds, HDC device_context) { }
359 378
360 // Subclasses can implement this method if they need to be notified of a key
361 // press event.
362 virtual void OnKeyDown(unsigned short virtual_keycode) {}
363
364 virtual HWND CreateNativeControl(HWND parent_container); 379 virtual HWND CreateNativeControl(HWND parent_container);
365 380
366 virtual LRESULT OnNotify(int w_param, LPNMHDR l_param); 381 virtual LRESULT OnNotify(int w_param, LPNMHDR l_param);
367 382
368 // Overriden to destroy the image list. 383 // Overriden to destroy the image list.
369 virtual void OnDestroy(); 384 virtual void OnDestroy();
370 385
371 private: 386 private:
372 // We need this wrapper to pass the table view to the windows proc handler 387 // We need this wrapper to pass the table view to the windows proc handler
373 // when subclassing the list view and list view header, as the reinterpret 388 // when subclassing the list view and list view header, as the reinterpret
374 // cast from GetWindowLongPtr would break the pointer if it is pointing to a 389 // cast from GetWindowLongPtr would break the pointer if it is pointing to a
375 // subclass (in the OO sense of TableView). 390 // subclass (in the OO sense of TableView).
376 struct TableViewWrapper { 391 struct TableViewWrapper {
377 TableViewWrapper(TableView* view) : table_view(view) { } 392 explicit TableViewWrapper(TableView* view) : table_view(view) { }
378 TableView* table_view; 393 TableView* table_view;
379 }; 394 };
380 395
381 friend class ListViewParent; 396 friend class ListViewParent;
382 friend class TableSelectionIterator; 397 friend class TableSelectionIterator;
383 398
384 LRESULT OnCustomDraw(NMLVCUSTOMDRAW* draw_info); 399 LRESULT OnCustomDraw(NMLVCUSTOMDRAW* draw_info);
385 400
386 // Adds a new column. 401 // Adds a new column.
387 void InsertColumn(const TableColumn& tc, int index); 402 void InsertColumn(const TableColumn& tc, int index);
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after
489 HFONT custom_cell_font_; 504 HFONT custom_cell_font_;
490 505
491 // The preferred size of the table view. 506 // The preferred size of the table view.
492 CSize preferred_size_; 507 CSize preferred_size_;
493 508
494 // The offset from the top of the client area to the start of the content. 509 // The offset from the top of the client area to the start of the content.
495 int content_offset_; 510 int content_offset_;
496 511
497 DISALLOW_EVIL_CONSTRUCTORS(TableView); 512 DISALLOW_EVIL_CONSTRUCTORS(TableView);
498 }; 513 };
499
500 } 514 }
501 515
502 #endif // CHROME_VIEWS_TABLE_VIEW_H__ 516 #endif // CHROME_VIEWS_TABLE_VIEW_H__
503 517
OLDNEW
« no previous file with comments | « chrome/views/group_table_view.cc ('k') | chrome/views/table_view.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698