| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 VIEWS_WINDOW_WINDOW_DELEGATE_H_ | 5 #ifndef VIEWS_WINDOW_WINDOW_DELEGATE_H_ |
| 6 #define VIEWS_WINDOW_WINDOW_DELEGATE_H_ | 6 #define VIEWS_WINDOW_WINDOW_DELEGATE_H_ |
| 7 #pragma once | 7 #pragma once |
| 8 | 8 |
| 9 #include <string> | 9 #include <string> |
| 10 | 10 |
| (...skipping 20 matching lines...) Expand all Loading... |
| 31 // WindowDelegate is an interface implemented by objects that wish to show a | 31 // WindowDelegate is an interface implemented by objects that wish to show a |
| 32 // Window. The window that is displayed uses this interface to determine how | 32 // Window. The window that is displayed uses this interface to determine how |
| 33 // it should be displayed and notify the delegate object of certain events. | 33 // it should be displayed and notify the delegate object of certain events. |
| 34 // | 34 // |
| 35 /////////////////////////////////////////////////////////////////////////////// | 35 /////////////////////////////////////////////////////////////////////////////// |
| 36 class WindowDelegate { | 36 class WindowDelegate { |
| 37 public: | 37 public: |
| 38 WindowDelegate(); | 38 WindowDelegate(); |
| 39 virtual ~WindowDelegate(); | 39 virtual ~WindowDelegate(); |
| 40 | 40 |
| 41 virtual DialogDelegate* AsDialogDelegate() { return NULL; } | 41 virtual DialogDelegate* AsDialogDelegate(); |
| 42 | 42 |
| 43 // Returns true if the window can ever be resized. | 43 // Returns true if the window can ever be resized. |
| 44 virtual bool CanResize() const { | 44 virtual bool CanResize() const; |
| 45 return false; | |
| 46 } | |
| 47 | 45 |
| 48 // Returns true if the window can ever be maximized. | 46 // Returns true if the window can ever be maximized. |
| 49 virtual bool CanMaximize() const { | 47 virtual bool CanMaximize() const; |
| 50 return false; | |
| 51 } | |
| 52 | 48 |
| 53 // Returns true if the dialog should be displayed modally to the window that | 49 // Returns true if the dialog should be displayed modally to the window that |
| 54 // opened it. Only windows with WindowType == DIALOG can be modal. | 50 // opened it. Only windows with WindowType == DIALOG can be modal. |
| 55 virtual bool IsModal() const { | 51 virtual bool IsModal() const; |
| 56 return false; | |
| 57 } | |
| 58 | 52 |
| 59 virtual AccessibilityTypes::Role accessible_role() const { | 53 virtual AccessibilityTypes::Role accessible_role() const; |
| 60 return AccessibilityTypes::ROLE_WINDOW; | |
| 61 } | |
| 62 | 54 |
| 63 virtual AccessibilityTypes::State accessible_state() const { | 55 virtual AccessibilityTypes::State accessible_state() const; |
| 64 return 0; | |
| 65 } | |
| 66 | 56 |
| 67 // Returns the title to be read with screen readers. | 57 // Returns the title to be read with screen readers. |
| 68 virtual std::wstring GetAccessibleWindowTitle() const { | 58 virtual std::wstring GetAccessibleWindowTitle() const; |
| 69 return GetWindowTitle(); | |
| 70 } | |
| 71 | 59 |
| 72 // Returns the text to be displayed in the window title. | 60 // Returns the text to be displayed in the window title. |
| 73 virtual std::wstring GetWindowTitle() const { | 61 virtual std::wstring GetWindowTitle() const; |
| 74 return L""; | |
| 75 } | |
| 76 | 62 |
| 77 // Returns the view that should have the focus when the dialog is opened. If | 63 // Returns the view that should have the focus when the dialog is opened. If |
| 78 // NULL no view is focused. | 64 // NULL no view is focused. |
| 79 virtual View* GetInitiallyFocusedView() { return NULL; } | 65 virtual View* GetInitiallyFocusedView(); |
| 80 | 66 |
| 81 // Returns true if the window should show a title in the title bar. | 67 // Returns true if the window should show a title in the title bar. |
| 82 virtual bool ShouldShowWindowTitle() const { | 68 virtual bool ShouldShowWindowTitle() const; |
| 83 return true; | |
| 84 } | |
| 85 | 69 |
| 86 // Returns true if the window's client view wants a client edge. | 70 // Returns true if the window's client view wants a client edge. |
| 87 virtual bool ShouldShowClientEdge() const { | 71 virtual bool ShouldShowClientEdge() const; |
| 88 return true; | |
| 89 } | |
| 90 | 72 |
| 91 // Returns the app icon for the window. On Windows, this is the ICON_BIG used | 73 // Returns the app icon for the window. On Windows, this is the ICON_BIG used |
| 92 // in Alt-Tab list and Win7's taskbar. | 74 // in Alt-Tab list and Win7's taskbar. |
| 93 virtual SkBitmap GetWindowAppIcon(); | 75 virtual SkBitmap GetWindowAppIcon(); |
| 94 | 76 |
| 95 // Returns the icon to be displayed in the window. | 77 // Returns the icon to be displayed in the window. |
| 96 virtual SkBitmap GetWindowIcon(); | 78 virtual SkBitmap GetWindowIcon(); |
| 97 | 79 |
| 98 // Returns true if a window icon should be shown. | 80 // Returns true if a window icon should be shown. |
| 99 virtual bool ShouldShowWindowIcon() const { | 81 virtual bool ShouldShowWindowIcon() const; |
| 100 return false; | |
| 101 } | |
| 102 | 82 |
| 103 // Execute a command in the window's controller. Returns true if the command | 83 // Execute a command in the window's controller. Returns true if the command |
| 104 // was handled, false if it was not. | 84 // was handled, false if it was not. |
| 105 virtual bool ExecuteWindowsCommand(int command_id) { return false; } | 85 virtual bool ExecuteWindowsCommand(int command_id); |
| 106 | 86 |
| 107 // Returns the window's name identifier. Used to identify this window for | 87 // Returns the window's name identifier. Used to identify this window for |
| 108 // state restoration. | 88 // state restoration. |
| 109 virtual std::wstring GetWindowName() const { | 89 virtual std::wstring GetWindowName() const; |
| 110 return std::wstring(); | |
| 111 } | |
| 112 | 90 |
| 113 // Saves the window's bounds and maximized states. By default this uses the | 91 // Saves the window's bounds and maximized states. By default this uses the |
| 114 // process' local state keyed by window name (See GetWindowName above). This | 92 // process' local state keyed by window name (See GetWindowName above). This |
| 115 // behavior can be overridden to provide additional functionality. | 93 // behavior can be overridden to provide additional functionality. |
| 116 virtual void SaveWindowPlacement(const gfx::Rect& bounds, bool maximized); | 94 virtual void SaveWindowPlacement(const gfx::Rect& bounds, bool maximized); |
| 117 | 95 |
| 118 // Retrieves the window's bounds and maximized states. | 96 // Retrieves the window's bounds and maximized states. |
| 119 // This behavior can be overridden to provide additional functionality. | 97 // This behavior can be overridden to provide additional functionality. |
| 120 virtual bool GetSavedWindowBounds(gfx::Rect* bounds) const; | 98 virtual bool GetSavedWindowBounds(gfx::Rect* bounds) const; |
| 121 virtual bool GetSavedMaximizedState(bool* maximized) const; | 99 virtual bool GetSavedMaximizedState(bool* maximized) const; |
| 122 | 100 |
| 123 // Returns true if the window's size should be restored. If this is false, | 101 // Returns true if the window's size should be restored. If this is false, |
| 124 // only the window's origin is restored and the window is given its | 102 // only the window's origin is restored and the window is given its |
| 125 // preferred size. | 103 // preferred size. |
| 126 // Default is true. | 104 // Default is true. |
| 127 virtual bool ShouldRestoreWindowSize() const; | 105 virtual bool ShouldRestoreWindowSize() const; |
| 128 | 106 |
| 129 // Called when the window closes. | 107 // Called when the window closes. |
| 130 virtual void WindowClosing() {} | 108 virtual void WindowClosing() {} |
| 131 | 109 |
| 132 // Called when the window is destroyed. No events must be sent or received | 110 // Called when the window is destroyed. No events must be sent or received |
| 133 // after this point. The delegate can use this opportunity to delete itself at | 111 // after this point. The delegate can use this opportunity to delete itself at |
| 134 // this time if necessary. | 112 // this time if necessary. |
| 135 virtual void DeleteDelegate() {} | 113 virtual void DeleteDelegate() {} |
| 136 | 114 |
| 137 // Returns the View that is contained within this Window. | 115 // Returns the View that is contained within this Window. |
| 138 virtual View* GetContentsView() { | 116 virtual View* GetContentsView(); |
| 139 return NULL; | |
| 140 } | |
| 141 | 117 |
| 142 // Called by the Window to create the Client View used to host the contents | 118 // Called by the Window to create the Client View used to host the contents |
| 143 // of the window. | 119 // of the window. |
| 144 virtual ClientView* CreateClientView(Window* window); | 120 virtual ClientView* CreateClientView(Window* window); |
| 145 | 121 |
| 146 Window* window() const { return window_; } | 122 Window* window() const { return window_; } |
| 147 | 123 |
| 148 private: | 124 private: |
| 149 friend class WindowGtk; | 125 friend class WindowGtk; |
| 150 friend class WindowWin; | 126 friend class WindowWin; |
| 151 // The Window this delegate is bound to. Weak reference. | 127 // The Window this delegate is bound to. Weak reference. |
| 152 Window* window_; | 128 Window* window_; |
| 153 }; | 129 }; |
| 154 | 130 |
| 155 } // namespace views | 131 } // namespace views |
| 156 | 132 |
| 157 #endif // VIEWS_WINDOW_WINDOW_DELEGATE_H_ | 133 #endif // VIEWS_WINDOW_WINDOW_DELEGATE_H_ |
| OLD | NEW |