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 void PaintLayeredWindow(gfx::Canvas
* canvas
) = 0;
79 virtual InputMethod
* GetInputMethod() = 0;
81 virtual gfx::NativeViewAccessible
GetNativeViewAccessible() = 0;
83 // Returns true if the window should handle standard system commands, such as
84 // close, minimize, maximize.
85 // TODO(benwells): Remove this once bubbles don't have two widgets
86 // implementing them on non-aura windows. http://crbug.com/189112.
87 virtual bool ShouldHandleSystemCommands() const = 0;
89 // TODO(beng): Investigate migrating these methods to On* prefixes once
90 // HWNDMessageHandler is the WindowImpl.
92 // Called when another app was activated.
93 virtual void HandleAppDeactivated() = 0;
95 // Called when the window was activated or deactivated. |active| reflects the
97 virtual void HandleActivationChanged(bool active
) = 0;
99 // Called when a well known "app command" from the system was performed.
100 // Returns true if the command was handled.
101 virtual bool HandleAppCommand(short command
) = 0;
103 // Called from WM_CANCELMODE.
104 virtual void HandleCancelMode() = 0;
106 // Called when the window has lost mouse capture.
107 virtual void HandleCaptureLost() = 0;
109 // Called when the user tried to close the window.
110 virtual void HandleClose() = 0;
112 // Called when a command defined by the application was performed. Returns
113 // true if the command was handled.
114 virtual bool HandleCommand(int command
) = 0;
116 // Called when an accelerator is invoked.
117 virtual void HandleAccelerator(const ui::Accelerator
& accelerator
) = 0;
119 // Called when the HWND is created.
120 virtual void HandleCreate() = 0;
122 // Called when the HWND is being destroyed, before any child HWNDs are
124 virtual void HandleDestroying() = 0;
126 // Called after the HWND is destroyed, after all child HWNDs have been
128 virtual void HandleDestroyed() = 0;
130 // Called when the HWND is to be focused for the first time. This is called
131 // when the window is shown for the first time. Returns true if the delegate
132 // set focus and no default processing should be done by the message handler.
133 virtual bool HandleInitialFocus(ui::WindowShowState show_state
) = 0;
135 // Called when display settings are adjusted on the system.
136 virtual void HandleDisplayChange() = 0;
138 // Called when the user begins or ends a size/move operation using the window
140 virtual void HandleBeginWMSizeMove() = 0;
141 virtual void HandleEndWMSizeMove() = 0;
143 // Called when the window's position changed.
144 virtual void HandleMove() = 0;
146 // Called when the system's work area has changed.
147 virtual void HandleWorkAreaChanged() = 0;
149 // Called when the window's visibility is changing. |visible| holds the new
151 virtual void HandleVisibilityChanging(bool visible
) = 0;
153 // Called when the window's visibility changed. |visible| holds the new state.
154 virtual void HandleVisibilityChanged(bool visible
) = 0;
156 // Called when the window's client size changed. |new_size| holds the new
158 virtual void HandleClientSizeChanged(const gfx::Size
& new_size
) = 0;
160 // Called when the window's frame has changed.
161 virtual void HandleFrameChanged() = 0;
163 // Called when focus shifted to this HWND from |last_focused_window|.
164 virtual void HandleNativeFocus(HWND last_focused_window
) = 0;
166 // Called when focus shifted from the HWND to a different window.
167 virtual void HandleNativeBlur(HWND focused_window
) = 0;
169 // Called when a mouse event is received. Returns true if the event was
170 // handled by the delegate.
171 virtual bool HandleMouseEvent(const ui::MouseEvent
& event
) = 0;
173 // Called when a translated key event is received (i.e. post IME translation.)
174 // Returns true if the event was handled by the delegate.
175 virtual bool HandleKeyEvent(const ui::KeyEvent
& event
) = 0;
177 // Called when an untranslated key event is received (i.e. pre-IME
178 // translation). Returns true if the event was sent to the input method.
179 virtual bool HandleUntranslatedKeyEvent(const ui::KeyEvent
& event
) = 0;
181 // Called when a touch event is received.
182 virtual void HandleTouchEvent(const ui::TouchEvent
& event
) = 0;
184 // Called when an IME message needs to be processed by the delegate. Returns
185 // true if the event was handled and no default processing should be
187 virtual bool HandleIMEMessage(UINT message
,
190 LRESULT
* result
) = 0;
192 // Called when the system input language changes.
193 virtual void HandleInputLanguageChange(DWORD character_set
,
194 HKL input_language_id
) = 0;
196 // Called to compel the delegate to paint |invalid_rect| accelerated. Returns
197 // true if accelerated painting was performed.
198 virtual bool HandlePaintAccelerated(const gfx::Rect
& invalid_rect
) = 0;
200 // Called to compel the delegate to paint using the software path.
201 virtual void HandlePaint(gfx::Canvas
* canvas
) = 0;
203 // Called to forward a WM_NOTIFY message to the tooltip manager.
204 virtual bool HandleTooltipNotify(int w_param
,
206 LRESULT
* l_result
) = 0;
208 // Invoked on entering/exiting a menu loop.
209 virtual void HandleMenuLoop(bool in_menu_loop
) = 0;
211 // Catch-all message handling and filtering. Called before
212 // HWNDMessageHandler's built-in handling, which may pre-empt some
213 // expectations in Views/Aura if messages are consumed. Returns true if the
214 // message was consumed by the delegate and should not be processed further
215 // by the HWNDMessageHandler. In this case, |result| is returned. |result| is
216 // not modified otherwise.
217 virtual bool PreHandleMSG(UINT message
,
220 LRESULT
* result
) = 0;
222 // Like PreHandleMSG, but called after HWNDMessageHandler's built-in handling
223 // has run and after DefWindowProc.
224 virtual void PostHandleMSG(UINT message
,
228 // Called when a scroll event is received. Returns true if the event was
229 // handled by the delegate.
230 virtual bool HandleScrollEvent(const ui::ScrollEvent
& event
) = 0;
232 // Called when the window size is about to change.
233 virtual void HandleWindowSizeChanging() = 0;
236 virtual ~HWNDMessageHandlerDelegate() {}
241 #endif // UI_VIEWS_WIN_HWND_MESSAGE_HANDLER_DELEGATE_H_