1 // Copyright (c) 2012 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.
5 #ifndef UI_VIEWS_WIN_HWND_MESSAGE_HANDLER_DELEGATE_H_
6 #define UI_VIEWS_WIN_HWND_MESSAGE_HANDLER_DELEGATE_H_
8 #include "ui/views/views_export.h"
29 // Implemented by the object that uses the HWNDMessageHandler to handle
30 // notifications from the underlying HWND and service requests for data.
31 class VIEWS_EXPORT HWNDMessageHandlerDelegate
{
33 virtual bool IsWidgetWindow() const = 0;
35 // TODO(beng): resolve this more satisfactorily vis-a-vis ShouldUseNativeFrame
36 // to avoid confusion.
37 virtual bool IsUsingCustomFrame() const = 0;
39 virtual void SchedulePaint() = 0;
40 virtual void EnableInactiveRendering() = 0;
41 virtual bool IsInactiveRenderingDisabled() = 0;
43 virtual bool CanResize() const = 0;
44 virtual bool CanMaximize() const = 0;
45 virtual bool CanMinimize() const = 0;
46 virtual bool CanActivate() const = 0;
48 virtual bool WidgetSizeIsClientSize() const = 0;
50 // Returns true if the delegate represents a modal window.
51 virtual bool IsModal() const = 0;
53 // Returns the show state that should be used for the application's first
55 virtual int GetInitialShowState() const = 0;
57 virtual bool WillProcessWorkAreaChange() const = 0;
59 virtual int GetNonClientComponent(const gfx::Point
& point
) const = 0;
60 virtual void GetWindowMask(const gfx::Size
& size
, gfx::Path
* mask
) = 0;
62 // Returns true if the delegate modifies |insets| to define a custom client
63 // area for the window, false if the default client area should be used. If
64 // false is returned, |insets| is not modified.
65 virtual bool GetClientAreaInsets(gfx::Insets
* insets
) const = 0;
67 // Returns the minimum and maximum size the window can be resized to by the
69 virtual void GetMinMaxSize(gfx::Size
* min_size
,
70 gfx::Size
* max_size
) const = 0;
72 // Returns the current size of the RootView.
73 virtual gfx::Size
GetRootViewSize() const = 0;
75 virtual void ResetWindowControls() = 0;
77 virtual gfx::NativeViewAccessible
GetNativeViewAccessible() = 0;
79 // Returns true if the window should handle standard system commands, such as
80 // close, minimize, maximize.
81 // TODO(benwells): Remove this once bubbles don't have two widgets
82 // implementing them on non-aura windows. http://crbug.com/189112.
83 virtual bool ShouldHandleSystemCommands() const = 0;
85 // TODO(beng): Investigate migrating these methods to On* prefixes once
86 // HWNDMessageHandler is the WindowImpl.
88 // Called when another app was activated.
89 virtual void HandleAppDeactivated() = 0;
91 // Called when the window was activated or deactivated. |active| reflects the
93 virtual void HandleActivationChanged(bool active
) = 0;
95 // Called when a well known "app command" from the system was performed.
96 // Returns true if the command was handled.
97 virtual bool HandleAppCommand(short command
) = 0;
99 // Called from WM_CANCELMODE.
100 virtual void HandleCancelMode() = 0;
102 // Called when the window has lost mouse capture.
103 virtual void HandleCaptureLost() = 0;
105 // Called when the user tried to close the window.
106 virtual void HandleClose() = 0;
108 // Called when a command defined by the application was performed. Returns
109 // true if the command was handled.
110 virtual bool HandleCommand(int command
) = 0;
112 // Called when an accelerator is invoked.
113 virtual void HandleAccelerator(const ui::Accelerator
& accelerator
) = 0;
115 // Called when the HWND is created.
116 virtual void HandleCreate() = 0;
118 // Called when the HWND is being destroyed, before any child HWNDs are
120 virtual void HandleDestroying() = 0;
122 // Called after the HWND is destroyed, after all child HWNDs have been
124 virtual void HandleDestroyed() = 0;
126 // Called when the HWND is to be focused for the first time. This is called
127 // when the window is shown for the first time. Returns true if the delegate
128 // set focus and no default processing should be done by the message handler.
129 virtual bool HandleInitialFocus(ui::WindowShowState show_state
) = 0;
131 // Called when display settings are adjusted on the system.
132 virtual void HandleDisplayChange() = 0;
134 // Called when the user begins or ends a size/move operation using the window
136 virtual void HandleBeginWMSizeMove() = 0;
137 virtual void HandleEndWMSizeMove() = 0;
139 // Called when the window's position changed.
140 virtual void HandleMove() = 0;
142 // Called when the system's work area has changed.
143 virtual void HandleWorkAreaChanged() = 0;
145 // Called when the window's visibility is changing. |visible| holds the new
147 virtual void HandleVisibilityChanging(bool visible
) = 0;
149 // Called when the window's visibility changed. |visible| holds the new state.
150 virtual void HandleVisibilityChanged(bool visible
) = 0;
152 // Called when the window's client size changed. |new_size| holds the new
154 virtual void HandleClientSizeChanged(const gfx::Size
& new_size
) = 0;
156 // Called when the window's frame has changed.
157 virtual void HandleFrameChanged() = 0;
159 // Called when focus shifted to this HWND from |last_focused_window|.
160 virtual void HandleNativeFocus(HWND last_focused_window
) = 0;
162 // Called when focus shifted from the HWND to a different window.
163 virtual void HandleNativeBlur(HWND focused_window
) = 0;
165 // Called when a mouse event is received. Returns true if the event was
166 // handled by the delegate.
167 virtual bool HandleMouseEvent(const ui::MouseEvent
& event
) = 0;
169 // Called when an untranslated key event is received (i.e. pre-IME
171 virtual void HandleKeyEvent(ui::KeyEvent
* event
) = 0;
173 // Called when a touch event is received.
174 virtual void HandleTouchEvent(const ui::TouchEvent
& event
) = 0;
176 // Called when an IME message needs to be processed by the delegate. Returns
177 // true if the event was handled and no default processing should be
179 virtual bool HandleIMEMessage(UINT message
,
182 LRESULT
* result
) = 0;
184 // Called when the system input language changes.
185 virtual void HandleInputLanguageChange(DWORD character_set
,
186 HKL input_language_id
) = 0;
188 // Called to compel the delegate to paint |invalid_rect| accelerated.
189 virtual void HandlePaintAccelerated(const gfx::Rect
& invalid_rect
) = 0;
191 // Called to forward a WM_NOTIFY message to the tooltip manager.
192 virtual bool HandleTooltipNotify(int w_param
,
194 LRESULT
* l_result
) = 0;
196 // Invoked on entering/exiting a menu loop.
197 virtual void HandleMenuLoop(bool in_menu_loop
) = 0;
199 // Catch-all message handling and filtering. Called before
200 // HWNDMessageHandler's built-in handling, which may pre-empt some
201 // expectations in Views/Aura if messages are consumed. Returns true if the
202 // message was consumed by the delegate and should not be processed further
203 // by the HWNDMessageHandler. In this case, |result| is returned. |result| is
204 // not modified otherwise.
205 virtual bool PreHandleMSG(UINT message
,
208 LRESULT
* result
) = 0;
210 // Like PreHandleMSG, but called after HWNDMessageHandler's built-in handling
211 // has run and after DefWindowProc.
212 virtual void PostHandleMSG(UINT message
,
216 // Called when a scroll event is received. Returns true if the event was
217 // handled by the delegate.
218 virtual bool HandleScrollEvent(const ui::ScrollEvent
& event
) = 0;
220 // Called when the window size is about to change.
221 virtual void HandleWindowSizeChanging() = 0;
223 // Called when the window size has finished changing.
224 virtual void HandleWindowSizeChanged() = 0;
227 virtual ~HWNDMessageHandlerDelegate() {}
232 #endif // UI_VIEWS_WIN_HWND_MESSAGE_HANDLER_DELEGATE_H_