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

Side by Side Diff: views/controls/tree/tree_view.cc

Issue 399030: Add an option to tree_view for whether to show lines from the root node... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 11 years, 1 month 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 | « views/controls/tree/tree_view.h ('k') | no next file » | 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 #include "views/controls/tree/tree_view.h" 5 #include "views/controls/tree/tree_view.h"
6 6
7 #include <vector> 7 #include <vector>
8 8
9 #include "app/gfx/canvas.h" 9 #include "app/gfx/canvas.h"
10 #include "app/gfx/canvas_paint.h" 10 #include "app/gfx/canvas_paint.h"
11 #include "app/gfx/favicon_size.h" 11 #include "app/gfx/favicon_size.h"
12 #include "app/gfx/icon_util.h" 12 #include "app/gfx/icon_util.h"
13 #include "app/l10n_util.h" 13 #include "app/l10n_util.h"
14 #include "app/l10n_util_win.h" 14 #include "app/l10n_util_win.h"
15 #include "app/resource_bundle.h" 15 #include "app/resource_bundle.h"
16 #include "base/gfx/point.h" 16 #include "base/gfx/point.h"
17 #include "base/keyboard_codes.h" 17 #include "base/keyboard_codes.h"
18 #include "base/stl_util-inl.h" 18 #include "base/stl_util-inl.h"
19 #include "base/win_util.h" 19 #include "base/win_util.h"
20 #include "grit/app_resources.h" 20 #include "grit/app_resources.h"
21 #include "views/focus/focus_manager.h" 21 #include "views/focus/focus_manager.h"
22 #include "views/widget/widget.h" 22 #include "views/widget/widget.h"
23 23
24 namespace views { 24 namespace views {
25 25
26 TreeView::TreeView() 26 TreeView::TreeView()
27 : tree_view_(NULL), 27 : tree_view_(NULL),
28 model_(NULL), 28 model_(NULL),
29 auto_expand_children_(false),
29 editable_(true), 30 editable_(true),
30 next_id_(0), 31 next_id_(0),
31 controller_(NULL), 32 controller_(NULL),
32 editing_node_(NULL), 33 editing_node_(NULL),
33 root_shown_(true), 34 root_shown_(true),
35 lines_at_root_(false),
34 process_enter_(false), 36 process_enter_(false),
35 show_context_menu_only_when_node_selected_(true), 37 show_context_menu_only_when_node_selected_(true),
36 select_on_right_mouse_down_(true), 38 select_on_right_mouse_down_(true),
37 ALLOW_THIS_IN_INITIALIZER_LIST(wrapper_(this)), 39 ALLOW_THIS_IN_INITIALIZER_LIST(wrapper_(this)),
38 original_handler_(NULL), 40 original_handler_(NULL),
39 drag_enabled_(false), 41 drag_enabled_(false),
40 has_custom_icons_(false), 42 has_custom_icons_(false),
41 image_list_(NULL) { 43 image_list_(NULL) {
42 } 44 }
43 45
(...skipping 300 matching lines...) Expand 10 before | Expand all | Expand 10 after
344 ConvertPointToScreen(this, &screen_loc); 346 ConvertPointToScreen(this, &screen_loc);
345 return screen_loc; 347 return screen_loc;
346 } 348 }
347 349
348 HWND TreeView::CreateNativeControl(HWND parent_container) { 350 HWND TreeView::CreateNativeControl(HWND parent_container) {
349 int style = WS_CHILD | TVS_HASBUTTONS | TVS_HASLINES | TVS_SHOWSELALWAYS; 351 int style = WS_CHILD | TVS_HASBUTTONS | TVS_HASLINES | TVS_SHOWSELALWAYS;
350 if (!drag_enabled_) 352 if (!drag_enabled_)
351 style |= TVS_DISABLEDRAGDROP; 353 style |= TVS_DISABLEDRAGDROP;
352 if (editable_) 354 if (editable_)
353 style |= TVS_EDITLABELS; 355 style |= TVS_EDITLABELS;
356 if (lines_at_root_)
357 style |= TVS_LINESATROOT;
354 tree_view_ = ::CreateWindowEx(WS_EX_CLIENTEDGE | GetAdditionalExStyle(), 358 tree_view_ = ::CreateWindowEx(WS_EX_CLIENTEDGE | GetAdditionalExStyle(),
355 WC_TREEVIEW, 359 WC_TREEVIEW,
356 L"", 360 L"",
357 style, 361 style,
358 0, 0, width(), height(), 362 0, 0, width(), height(),
359 parent_container, NULL, NULL, NULL); 363 parent_container, NULL, NULL, NULL);
360 SetWindowLongPtr(tree_view_, GWLP_USERDATA, 364 SetWindowLongPtr(tree_view_, GWLP_USERDATA,
361 reinterpret_cast<LONG_PTR>(&wrapper_)); 365 reinterpret_cast<LONG_PTR>(&wrapper_));
362 original_handler_ = win_util::SetWindowProc(tree_view_, 366 original_handler_ = win_util::SetWindowProc(tree_view_,
363 &TreeWndProc); 367 &TreeWndProc);
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
408 412
409 case TVN_ITEMEXPANDING: { 413 case TVN_ITEMEXPANDING: {
410 // Notification that a node is expanding. If we haven't populated the 414 // Notification that a node is expanding. If we haven't populated the
411 // tree view with the contents of the model, we do it here. 415 // tree view with the contents of the model, we do it here.
412 DCHECK(model_); 416 DCHECK(model_);
413 NMTREEVIEW* info = reinterpret_cast<NMTREEVIEW*>(l_param); 417 NMTREEVIEW* info = reinterpret_cast<NMTREEVIEW*>(l_param);
414 NodeDetails* details = 418 NodeDetails* details =
415 GetNodeDetailsByID(static_cast<int>(info->itemNew.lParam)); 419 GetNodeDetailsByID(static_cast<int>(info->itemNew.lParam));
416 if (!details->loaded_children) { 420 if (!details->loaded_children) {
417 details->loaded_children = true; 421 details->loaded_children = true;
418 for (int i = 0; i < model_->GetChildCount(details->node); ++i) 422 for (int i = 0; i < model_->GetChildCount(details->node); ++i) {
419 CreateItem(details->tree_item, TVI_LAST, 423 CreateItem(details->tree_item, TVI_LAST,
420 model_->GetChild(details->node, i)); 424 model_->GetChild(details->node, i));
425 if (auto_expand_children_)
426 Expand(model_->GetChild(details->node, i));
427 }
421 } 428 }
422 // Return FALSE to allow the item to be expanded. 429 // Return FALSE to allow the item to be expanded.
423 return FALSE; 430 return FALSE;
424 } 431 }
425 432
426 case TVN_SELCHANGED: 433 case TVN_SELCHANGED:
427 if (controller_) 434 if (controller_)
428 controller_->OnTreeViewSelectionChanged(this); 435 controller_->OnTreeViewSelectionChanged(this);
429 break; 436 break;
430 437
(...skipping 334 matching lines...) Expand 10 before | Expand all | Expand 10 after
765 } 772 }
766 // Fall through and let the default handler process as well. 773 // Fall through and let the default handler process as well.
767 break; 774 break;
768 } 775 }
769 WNDPROC handler = tree->original_handler_; 776 WNDPROC handler = tree->original_handler_;
770 DCHECK(handler); 777 DCHECK(handler);
771 return CallWindowProc(handler, window, message, w_param, l_param); 778 return CallWindowProc(handler, window, message, w_param, l_param);
772 } 779 }
773 780
774 } // namespace views 781 } // namespace views
OLDNEW
« no previous file with comments | « views/controls/tree/tree_view.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698