| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 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 | 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_BROWSER_UI_VIEWS_BOOKMARKS_BOOKMARK_EDITOR_VIEW_H_ | 5 #ifndef CHROME_BROWSER_UI_VIEWS_BOOKMARKS_BOOKMARK_EDITOR_VIEW_H_ |
| 6 #define CHROME_BROWSER_UI_VIEWS_BOOKMARKS_BOOKMARK_EDITOR_VIEW_H_ | 6 #define CHROME_BROWSER_UI_VIEWS_BOOKMARKS_BOOKMARK_EDITOR_VIEW_H_ |
| 7 #pragma once | 7 #pragma once |
| 8 | 8 |
| 9 #include "base/string16.h" | 9 #include "base/string16.h" |
| 10 #include "chrome/browser/bookmarks/bookmark_editor.h" | 10 #include "chrome/browser/bookmarks/bookmark_editor.h" |
| 11 #include "chrome/browser/bookmarks/bookmark_model_observer.h" | 11 #include "chrome/browser/bookmarks/bookmark_model_observer.h" |
| 12 #include "testing/gtest/include/gtest/gtest_prod.h" | 12 #include "testing/gtest/include/gtest/gtest_prod.h" |
| 13 #include "ui/base/models/simple_menu_model.h" | 13 #include "ui/base/models/simple_menu_model.h" |
| 14 #include "ui/base/models/tree_node_model.h" | 14 #include "ui/base/models/tree_node_model.h" |
| 15 #include "views/controls/button/button.h" | 15 #include "views/controls/button/button.h" |
| 16 #include "views/controls/textfield/textfield.h" | 16 #include "views/controls/textfield/textfield.h" |
| 17 #include "views/controls/textfield/textfield_controller.h" |
| 17 #include "views/controls/tree/tree_view.h" | 18 #include "views/controls/tree/tree_view.h" |
| 18 #include "views/window/dialog_delegate.h" | 19 #include "views/window/dialog_delegate.h" |
| 19 | 20 |
| 20 namespace views { | 21 namespace views { |
| 21 class Label; | 22 class Label; |
| 22 class Menu2; | 23 class Menu2; |
| 23 class NativeButton; | 24 class NativeButton; |
| 24 class Window; | 25 class Window; |
| 25 } | 26 } |
| 26 | 27 |
| (...skipping 10 matching lines...) Expand all Loading... |
| 37 // | 38 // |
| 38 // Edits are applied to the BookmarkModel when the user presses 'OK'. | 39 // Edits are applied to the BookmarkModel when the user presses 'OK'. |
| 39 // | 40 // |
| 40 // To use BookmarkEditorView invoke the static show method. | 41 // To use BookmarkEditorView invoke the static show method. |
| 41 | 42 |
| 42 class BookmarkEditorView : public BookmarkEditor, | 43 class BookmarkEditorView : public BookmarkEditor, |
| 43 public views::View, | 44 public views::View, |
| 44 public views::ButtonListener, | 45 public views::ButtonListener, |
| 45 public views::TreeViewController, | 46 public views::TreeViewController, |
| 46 public views::DialogDelegate, | 47 public views::DialogDelegate, |
| 47 public views::Textfield::Controller, | 48 public views::TextfieldController, |
| 48 public views::ContextMenuController, | 49 public views::ContextMenuController, |
| 49 public ui::SimpleMenuModel::Delegate, | 50 public ui::SimpleMenuModel::Delegate, |
| 50 public BookmarkModelObserver { | 51 public BookmarkModelObserver { |
| 51 public: | 52 public: |
| 52 // Type of node in the tree. Public purely for testing. | 53 // Type of node in the tree. Public purely for testing. |
| 53 typedef ui::TreeNodeWithValue<int64> EditorNode; | 54 typedef ui::TreeNodeWithValue<int64> EditorNode; |
| 54 | 55 |
| 55 // Model for the TreeView. Trivial subclass that doesn't allow titles with | 56 // Model for the TreeView. Trivial subclass that doesn't allow titles with |
| 56 // empty strings. Public purely for testing. | 57 // empty strings. Public purely for testing. |
| 57 class EditorTreeModel : public ui::TreeNodeModel<EditorNode> { | 58 class EditorTreeModel : public ui::TreeNodeModel<EditorNode> { |
| (...skipping 21 matching lines...) Expand all Loading... |
| 79 // DialogDelegate methods: | 80 // DialogDelegate methods: |
| 80 virtual bool IsDialogButtonEnabled( | 81 virtual bool IsDialogButtonEnabled( |
| 81 MessageBoxFlags::DialogButton button) const; | 82 MessageBoxFlags::DialogButton button) const; |
| 82 virtual bool IsModal() const; | 83 virtual bool IsModal() const; |
| 83 virtual bool CanResize() const; | 84 virtual bool CanResize() const; |
| 84 virtual std::wstring GetWindowTitle() const; | 85 virtual std::wstring GetWindowTitle() const; |
| 85 virtual bool Accept(); | 86 virtual bool Accept(); |
| 86 virtual bool AreAcceleratorsEnabled(MessageBoxFlags::DialogButton button); | 87 virtual bool AreAcceleratorsEnabled(MessageBoxFlags::DialogButton button); |
| 87 virtual views::View* GetContentsView(); | 88 virtual views::View* GetContentsView(); |
| 88 | 89 |
| 89 // View methods. | 90 // views::View. |
| 90 virtual void Layout(); | 91 virtual void Layout(); |
| 91 virtual gfx::Size GetPreferredSize(); | 92 virtual gfx::Size GetPreferredSize(); |
| 92 virtual void ViewHierarchyChanged(bool is_add, views::View* parent, | 93 virtual void ViewHierarchyChanged(bool is_add, |
| 94 views::View* parent, |
| 93 views::View* child); | 95 views::View* child); |
| 94 | 96 |
| 95 // TreeViewObserver methods. | 97 // views::TreeViewObserver. |
| 96 virtual void OnTreeViewSelectionChanged(views::TreeView* tree_view); | 98 virtual void OnTreeViewSelectionChanged(views::TreeView* tree_view); |
| 97 virtual bool CanEdit(views::TreeView* tree_view, ui::TreeModelNode* node); | 99 virtual bool CanEdit(views::TreeView* tree_view, ui::TreeModelNode* node); |
| 98 | 100 |
| 99 // Textfield::Controller methods. | 101 // views::TextfieldController: |
| 100 virtual void ContentsChanged(views::Textfield* sender, | 102 virtual void ContentsChanged(views::Textfield* sender, |
| 101 const std::wstring& new_contents); | 103 const std::wstring& new_contents); |
| 102 virtual bool HandleKeyEvent(views::Textfield* sender, | 104 virtual bool HandleKeyEvent(views::Textfield* sender, |
| 103 const views::KeyEvent& key_event) { | 105 const views::KeyEvent& key_event) { |
| 104 return false; | 106 return false; |
| 105 } | 107 } |
| 106 | 108 |
| 107 // NativeButton. | 109 // views::ButtonListener: |
| 108 virtual void ButtonPressed(views::Button* sender, const views::Event& event); | 110 virtual void ButtonPressed(views::Button* sender, const views::Event& event); |
| 109 | 111 |
| 110 // ui::SimpleMenuModel::Delegate. | 112 // ui::SimpleMenuModel::Delegate: |
| 111 virtual bool IsCommandIdChecked(int command_id) const; | 113 virtual bool IsCommandIdChecked(int command_id) const; |
| 112 virtual bool IsCommandIdEnabled(int command_id) const; | 114 virtual bool IsCommandIdEnabled(int command_id) const; |
| 113 virtual bool GetAcceleratorForCommandId(int command_id, | 115 virtual bool GetAcceleratorForCommandId(int command_id, |
| 114 ui::Accelerator* accelerator); | 116 ui::Accelerator* accelerator); |
| 115 virtual void ExecuteCommand(int command_id); | 117 virtual void ExecuteCommand(int command_id); |
| 116 | 118 |
| 117 // Creates a Window and adds the BookmarkEditorView to it. When the window is | 119 // Creates a Window and adds the BookmarkEditorView to it. When the window is |
| 118 // closed the BookmarkEditorView is deleted. | 120 // closed the BookmarkEditorView is deleted. |
| 119 void Show(HWND parent_hwnd); | 121 void Show(HWND parent_hwnd); |
| 120 | 122 |
| (...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 257 // nodes. | 259 // nodes. |
| 258 bool running_menu_for_root_; | 260 bool running_menu_for_root_; |
| 259 | 261 |
| 260 // Is the tree shown? | 262 // Is the tree shown? |
| 261 bool show_tree_; | 263 bool show_tree_; |
| 262 | 264 |
| 263 DISALLOW_COPY_AND_ASSIGN(BookmarkEditorView); | 265 DISALLOW_COPY_AND_ASSIGN(BookmarkEditorView); |
| 264 }; | 266 }; |
| 265 | 267 |
| 266 #endif // CHROME_BROWSER_UI_VIEWS_BOOKMARKS_BOOKMARK_EDITOR_VIEW_H_ | 268 #endif // CHROME_BROWSER_UI_VIEWS_BOOKMARKS_BOOKMARK_EDITOR_VIEW_H_ |
| OLD | NEW |