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

Side by Side Diff: views/widget/widget_delegate.h

Issue 8598031: views: Move widget/ directory to ui/views. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: reland for real Created 9 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/widget/widget.cc ('k') | views/widget/widget_delegate.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 #ifndef VIEWS_WIDGET_WIDGET_DELEGATE_H_
6 #define VIEWS_WIDGET_WIDGET_DELEGATE_H_
7 #pragma once
8
9 #include <string>
10
11 #include "base/memory/scoped_ptr.h"
12 #include "ui/base/accessibility/accessibility_types.h"
13 #include "ui/base/ui_base_types.h"
14 #include "views/view.h"
15
16 class SkBitmap;
17
18 namespace gfx {
19 class Rect;
20 }
21
22 namespace views {
23 class BubbleDelegateView;
24 class ClientView;
25 class DialogDelegate;
26 class NonClientFrameView;
27 class View;
28 class Widget;
29
30 // WidgetDelegate interface
31 // Handles events on Widgets in context-specific ways.
32 class VIEWS_EXPORT WidgetDelegate {
33 public:
34 WidgetDelegate();
35
36 // Called whenever the widget's position changes.
37 virtual void OnWidgetMove();
38
39 // Called with the display changes (color depth or resolution).
40 virtual void OnDisplayChanged();
41
42 // Called when the work area (the desktop area minus task bars,
43 // menu bars, etc.) changes in size.
44 virtual void OnWorkAreaChanged();
45
46 // Returns the view that should have the focus when the widget is shown. If
47 // NULL no view is focused.
48 virtual View* GetInitiallyFocusedView();
49
50 // Moved from WindowDelegate: ------------------------------------------------
51 // TODO(beng): sort
52
53 virtual BubbleDelegateView* AsBubbleDelegate();
54 virtual DialogDelegate* AsDialogDelegate();
55
56 // Returns true if the window can ever be resized.
57 virtual bool CanResize() const;
58
59 // Returns true if the window can ever be maximized.
60 virtual bool CanMaximize() const;
61
62 // Returns true if the window can be activated.
63 virtual bool CanActivate() const;
64
65 // Returns true if the dialog should be displayed modally to the window that
66 // opened it. Only windows with WindowType == DIALOG can be modal.
67 virtual bool IsModal() const;
68
69 virtual ui::AccessibilityTypes::Role GetAccessibleWindowRole() const;
70
71 virtual ui::AccessibilityTypes::State GetAccessibleWindowState() const;
72
73 // Returns the title to be read with screen readers.
74 virtual string16 GetAccessibleWindowTitle() const;
75
76 // Returns the text to be displayed in the window title.
77 virtual string16 GetWindowTitle() const;
78
79 // Returns true if the window should show a title in the title bar.
80 virtual bool ShouldShowWindowTitle() const;
81
82 // Returns true if the window's client view wants a client edge.
83 virtual bool ShouldShowClientEdge() const;
84
85 // Returns the app icon for the window. On Windows, this is the ICON_BIG used
86 // in Alt-Tab list and Win7's taskbar.
87 virtual SkBitmap GetWindowAppIcon();
88
89 // Returns the icon to be displayed in the window.
90 virtual SkBitmap GetWindowIcon();
91
92 // Returns true if a window icon should be shown.
93 virtual bool ShouldShowWindowIcon() const;
94
95 // Execute a command in the window's controller. Returns true if the command
96 // was handled, false if it was not.
97 virtual bool ExecuteWindowsCommand(int command_id);
98
99 // Returns the window's name identifier. Used to identify this window for
100 // state restoration.
101 virtual std::string GetWindowName() const;
102
103 // Saves the window's bounds and "show" state. By default this uses the
104 // process' local state keyed by window name (See GetWindowName above). This
105 // behavior can be overridden to provide additional functionality.
106 virtual void SaveWindowPlacement(const gfx::Rect& bounds,
107 ui::WindowShowState show_state);
108
109 // Retrieves the window's bounds and "show" states.
110 // This behavior can be overridden to provide additional functionality.
111 virtual bool GetSavedWindowPlacement(gfx::Rect* bounds,
112 ui::WindowShowState* show_state) const;
113
114 // Returns true if the window's size should be restored. If this is false,
115 // only the window's origin is restored and the window is given its
116 // preferred size.
117 // Default is true.
118 virtual bool ShouldRestoreWindowSize() const;
119
120 // Called when the window closes. The delegate MUST NOT delete itself during
121 // this call, since it can be called afterwards. See DeleteDelegate().
122 virtual void WindowClosing() {}
123
124 // Called when the window is destroyed. No events must be sent or received
125 // after this point. The delegate can use this opportunity to delete itself at
126 // this time if necessary.
127 virtual void DeleteDelegate() {}
128
129 // Called when the user begins/ends to change the bounds of the window.
130 virtual void OnWindowBeginUserBoundsChange() {}
131 virtual void OnWindowEndUserBoundsChange() {}
132
133 // Returns the Widget associated with this delegate.
134 virtual Widget* GetWidget() = 0;
135 virtual const Widget* GetWidget() const = 0;
136
137 // Returns the View that is contained within this Widget.
138 virtual View* GetContentsView();
139
140 // Called by the Widget to create the Client View used to host the contents
141 // of the widget.
142 virtual ClientView* CreateClientView(Widget* widget);
143
144 // Called by the Widget to create the NonClient Frame View for this widget.
145 // Return NULL to use the default one.
146 virtual NonClientFrameView* CreateNonClientFrameView();
147
148 // Returns true if the window can be notified with the work area change.
149 // Otherwise, the work area change for the top window will be processed by
150 // the default window manager. In some cases, like panel, we would like to
151 // manage the positions by ourselves.
152 virtual bool WillProcessWorkAreaChange() const;
153
154 protected:
155 virtual ~WidgetDelegate() {}
156
157 private:
158 View* default_contents_view_;
159
160 DISALLOW_COPY_AND_ASSIGN(WidgetDelegate);
161 };
162
163 // A WidgetDelegate implementation that is-a View. Used to override GetWidget()
164 // to call View's GetWidget() for the common case where a WidgetDelegate
165 // implementation is-a View.
166 class VIEWS_EXPORT WidgetDelegateView : public WidgetDelegate, public View {
167 public:
168 WidgetDelegateView();
169 virtual ~WidgetDelegateView();
170
171 // Overridden from WidgetDelegate:
172 virtual Widget* GetWidget() OVERRIDE;
173 virtual const Widget* GetWidget() const OVERRIDE;
174
175 private:
176 DISALLOW_COPY_AND_ASSIGN(WidgetDelegateView);
177 };
178
179 } // namespace views
180
181 #endif // VIEWS_WIDGET_WIDGET_DELEGATE_H_
OLDNEW
« no previous file with comments | « views/widget/widget.cc ('k') | views/widget/widget_delegate.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698