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 VIEWS_WIDGET_WIDGET_WIN_H_ | 5 #ifndef VIEWS_WIDGET_WIDGET_WIN_H_ |
6 #define VIEWS_WIDGET_WIDGET_WIN_H_ | 6 #define VIEWS_WIDGET_WIDGET_WIN_H_ |
7 #pragma once | 7 #pragma once |
8 | 8 |
9 #include <atlbase.h> | 9 #include <atlbase.h> |
10 #include <atlapp.h> | 10 #include <atlapp.h> |
(...skipping 188 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
199 void ResetLastMouseMoveFlag() { | 199 void ResetLastMouseMoveFlag() { |
200 last_mouse_event_was_move_ = false; | 200 last_mouse_event_was_move_ = false; |
201 } | 201 } |
202 | 202 |
203 // Overridden from NativeWidget: | 203 // Overridden from NativeWidget: |
204 virtual Widget* GetWidget() OVERRIDE; | 204 virtual Widget* GetWidget() OVERRIDE; |
205 virtual void SetNativeWindowProperty(const char* name, void* value) OVERRIDE; | 205 virtual void SetNativeWindowProperty(const char* name, void* value) OVERRIDE; |
206 virtual void* GetNativeWindowProperty(const char* name) OVERRIDE; | 206 virtual void* GetNativeWindowProperty(const char* name) OVERRIDE; |
207 virtual TooltipManager* GetTooltipManager() const OVERRIDE; | 207 virtual TooltipManager* GetTooltipManager() const OVERRIDE; |
208 virtual bool IsScreenReaderActive() const OVERRIDE; | 208 virtual bool IsScreenReaderActive() const OVERRIDE; |
209 virtual void SetNativeCapture() OVERRIDE; | 209 virtual void SetMouseCapture() OVERRIDE; |
210 virtual void ReleaseNativeCapture() OVERRIDE; | 210 virtual void ReleaseMouseCapture() OVERRIDE; |
211 virtual bool HasNativeCapture() const OVERRIDE; | 211 virtual bool HasMouseCapture() const OVERRIDE; |
212 virtual gfx::Rect GetWindowScreenBounds() const OVERRIDE; | 212 virtual gfx::Rect GetWindowScreenBounds() const OVERRIDE; |
213 virtual gfx::Rect GetClientAreaScreenBounds() const OVERRIDE; | 213 virtual gfx::Rect GetClientAreaScreenBounds() const OVERRIDE; |
214 virtual void SetBounds(const gfx::Rect& bounds) OVERRIDE; | 214 virtual void SetBounds(const gfx::Rect& bounds) OVERRIDE; |
215 virtual void MoveAbove(gfx::NativeView native_view) OVERRIDE; | 215 virtual void MoveAbove(gfx::NativeView native_view) OVERRIDE; |
216 virtual void SetShape(gfx::NativeRegion shape) OVERRIDE; | 216 virtual void SetShape(gfx::NativeRegion shape) OVERRIDE; |
217 virtual void Close() OVERRIDE; | 217 virtual void Close() OVERRIDE; |
218 virtual void CloseNow() OVERRIDE; | 218 virtual void CloseNow() OVERRIDE; |
219 virtual void Show() OVERRIDE; | 219 virtual void Show() OVERRIDE; |
220 virtual void Hide() OVERRIDE; | 220 virtual void Hide() OVERRIDE; |
221 virtual void SetOpacity(unsigned char opacity) OVERRIDE; | 221 virtual void SetOpacity(unsigned char opacity) OVERRIDE; |
(...skipping 17 matching lines...) Expand all Loading... |
239 virtual HICON GetDefaultWindowIcon() const OVERRIDE; | 239 virtual HICON GetDefaultWindowIcon() const OVERRIDE; |
240 virtual LRESULT OnWndProc(UINT message, | 240 virtual LRESULT OnWndProc(UINT message, |
241 WPARAM w_param, | 241 WPARAM w_param, |
242 LPARAM l_param) OVERRIDE; | 242 LPARAM l_param) OVERRIDE; |
243 | 243 |
244 // Message Handlers ---------------------------------------------------------- | 244 // Message Handlers ---------------------------------------------------------- |
245 | 245 |
246 BEGIN_MSG_MAP_EX(WidgetWin) | 246 BEGIN_MSG_MAP_EX(WidgetWin) |
247 // Range handlers must go first! | 247 // Range handlers must go first! |
248 MESSAGE_RANGE_HANDLER_EX(WM_MOUSEFIRST, WM_MOUSELAST, OnMouseRange) | 248 MESSAGE_RANGE_HANDLER_EX(WM_MOUSEFIRST, WM_MOUSELAST, OnMouseRange) |
249 MESSAGE_RANGE_HANDLER_EX(WM_NCMOUSEMOVE, WM_NCXBUTTONDBLCLK, OnNCMouseRange) | 249 MESSAGE_RANGE_HANDLER_EX(WM_NCMOUSEMOVE, WM_NCXBUTTONDBLCLK, OnMouseRange) |
250 | 250 |
251 // Reflected message handler | 251 // Reflected message handler |
252 MESSAGE_HANDLER_EX(kReflectedMessage, OnReflectedMessage) | 252 MESSAGE_HANDLER_EX(kReflectedMessage, OnReflectedMessage) |
253 | 253 |
254 // CustomFrameWindow hacks | 254 // CustomFrameWindow hacks |
255 MESSAGE_HANDLER_EX(WM_NCUAHDRAWCAPTION, OnNCUAHDrawCaption) | 255 MESSAGE_HANDLER_EX(WM_NCUAHDRAWCAPTION, OnNCUAHDrawCaption) |
256 MESSAGE_HANDLER_EX(WM_NCUAHDRAWFRAME, OnNCUAHDrawFrame) | 256 MESSAGE_HANDLER_EX(WM_NCUAHDRAWFRAME, OnNCUAHDrawFrame) |
257 | 257 |
258 // Vista and newer | 258 // Vista and newer |
259 MESSAGE_HANDLER_EX(WM_DWMCOMPOSITIONCHANGED, OnDwmCompositionChanged) | 259 MESSAGE_HANDLER_EX(WM_DWMCOMPOSITIONCHANGED, OnDwmCompositionChanged) |
260 | 260 |
261 // Non-atlcrack.h handlers | 261 // Non-atlcrack.h handlers |
262 MESSAGE_HANDLER_EX(WM_GETOBJECT, OnGetObject) | 262 MESSAGE_HANDLER_EX(WM_GETOBJECT, OnGetObject) |
263 | 263 |
264 // Mouse events. | 264 // Mouse events. |
265 MESSAGE_HANDLER_EX(WM_MOUSEACTIVATE, OnMouseActivate) | 265 MESSAGE_HANDLER_EX(WM_MOUSEACTIVATE, OnMouseActivate) |
266 MESSAGE_HANDLER_EX(WM_MOUSELEAVE, OnMouseLeave) | 266 MESSAGE_HANDLER_EX(WM_MOUSELEAVE, OnMouseRange) |
267 MESSAGE_HANDLER_EX(WM_MOUSEMOVE, OnMouseMove) | |
268 MESSAGE_HANDLER_EX(WM_MOUSEWHEEL, OnMouseWheel) | 267 MESSAGE_HANDLER_EX(WM_MOUSEWHEEL, OnMouseWheel) |
269 MESSAGE_HANDLER_EX(WM_NCMOUSELEAVE, OnNCMouseLeave) | 268 MESSAGE_HANDLER_EX(WM_NCMOUSELEAVE, OnMouseRange) |
270 MESSAGE_HANDLER_EX(WM_NCMOUSEMOVE, OnNCMouseMove) | |
271 | 269 |
272 // Key events. | 270 // Key events. |
273 MESSAGE_HANDLER_EX(WM_KEYDOWN, OnKeyDown) | 271 MESSAGE_HANDLER_EX(WM_KEYDOWN, OnKeyDown) |
274 MESSAGE_HANDLER_EX(WM_KEYUP, OnKeyUp) | 272 MESSAGE_HANDLER_EX(WM_KEYUP, OnKeyUp) |
275 MESSAGE_HANDLER_EX(WM_SYSKEYDOWN, OnKeyDown); | 273 MESSAGE_HANDLER_EX(WM_SYSKEYDOWN, OnKeyDown); |
276 MESSAGE_HANDLER_EX(WM_SYSKEYUP, OnKeyUp); | 274 MESSAGE_HANDLER_EX(WM_SYSKEYUP, OnKeyUp); |
277 | 275 |
278 // This list is in _ALPHABETICAL_ order! OR I WILL HURT YOU. | 276 // This list is in _ALPHABETICAL_ order! OR I WILL HURT YOU. |
279 MSG_WM_ACTIVATE(OnActivate) | 277 MSG_WM_ACTIVATE(OnActivate) |
280 MSG_WM_ACTIVATEAPP(OnActivateApp) | 278 MSG_WM_ACTIVATEAPP(OnActivateApp) |
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
348 virtual void OnExitSizeMove(); | 346 virtual void OnExitSizeMove(); |
349 virtual LRESULT OnGetObject(UINT uMsg, WPARAM w_param, LPARAM l_param); | 347 virtual LRESULT OnGetObject(UINT uMsg, WPARAM w_param, LPARAM l_param); |
350 virtual void OnGetMinMaxInfo(MINMAXINFO* minmax_info); | 348 virtual void OnGetMinMaxInfo(MINMAXINFO* minmax_info); |
351 virtual void OnHScroll(int scroll_type, short position, HWND scrollbar); | 349 virtual void OnHScroll(int scroll_type, short position, HWND scrollbar); |
352 virtual void OnInitMenu(HMENU menu); | 350 virtual void OnInitMenu(HMENU menu); |
353 virtual void OnInitMenuPopup(HMENU menu, UINT position, BOOL is_system_menu); | 351 virtual void OnInitMenuPopup(HMENU menu, UINT position, BOOL is_system_menu); |
354 virtual LRESULT OnKeyDown(UINT message, WPARAM w_param, LPARAM l_param); | 352 virtual LRESULT OnKeyDown(UINT message, WPARAM w_param, LPARAM l_param); |
355 virtual LRESULT OnKeyUp(UINT message, WPARAM w_param, LPARAM l_param); | 353 virtual LRESULT OnKeyUp(UINT message, WPARAM w_param, LPARAM l_param); |
356 virtual void OnKillFocus(HWND focused_window); | 354 virtual void OnKillFocus(HWND focused_window); |
357 virtual LRESULT OnMouseActivate(UINT message, WPARAM w_param, LPARAM l_param); | 355 virtual LRESULT OnMouseActivate(UINT message, WPARAM w_param, LPARAM l_param); |
358 virtual LRESULT OnMouseLeave(UINT message, WPARAM w_param, LPARAM l_param); | |
359 virtual LRESULT OnMouseMove(UINT message, WPARAM w_param, LPARAM l_param); | |
360 virtual LRESULT OnMouseRange(UINT message, WPARAM w_param, LPARAM l_param); | 356 virtual LRESULT OnMouseRange(UINT message, WPARAM w_param, LPARAM l_param); |
361 virtual LRESULT OnMouseWheel(UINT message, WPARAM w_param, LPARAM l_param); | 357 virtual LRESULT OnMouseWheel(UINT message, WPARAM w_param, LPARAM l_param); |
362 virtual void OnMove(const CPoint& point); | 358 virtual void OnMove(const CPoint& point); |
363 virtual void OnMoving(UINT param, LPRECT new_bounds); | 359 virtual void OnMoving(UINT param, LPRECT new_bounds); |
364 virtual LRESULT OnNCActivate(BOOL active); | 360 virtual LRESULT OnNCActivate(BOOL active); |
365 virtual LRESULT OnNCCalcSize(BOOL w_param, LPARAM l_param); | 361 virtual LRESULT OnNCCalcSize(BOOL w_param, LPARAM l_param); |
366 virtual LRESULT OnNCHitTest(const CPoint& pt); | 362 virtual LRESULT OnNCHitTest(const CPoint& pt); |
367 virtual LRESULT OnNCMouseLeave(UINT message, WPARAM w_param, LPARAM l_param); | |
368 virtual LRESULT OnNCMouseMove(UINT message, WPARAM w_param, LPARAM l_param); | |
369 virtual LRESULT OnNCMouseRange(UINT message, WPARAM w_param, LPARAM l_param); | |
370 virtual void OnNCPaint(HRGN rgn); | 363 virtual void OnNCPaint(HRGN rgn); |
371 virtual LRESULT OnNCUAHDrawCaption(UINT msg, | 364 virtual LRESULT OnNCUAHDrawCaption(UINT msg, |
372 WPARAM w_param, | 365 WPARAM w_param, |
373 LPARAM l_param); | 366 LPARAM l_param); |
374 virtual LRESULT OnNCUAHDrawFrame(UINT msg, WPARAM w_param, LPARAM l_param); | 367 virtual LRESULT OnNCUAHDrawFrame(UINT msg, WPARAM w_param, LPARAM l_param); |
375 virtual LRESULT OnNotify(int w_param, NMHDR* l_param); | 368 virtual LRESULT OnNotify(int w_param, NMHDR* l_param); |
376 virtual void OnPaint(HDC dc); | 369 virtual void OnPaint(HDC dc); |
377 virtual LRESULT OnPowerBroadcast(DWORD power_event, DWORD data); | 370 virtual LRESULT OnPowerBroadcast(DWORD power_event, DWORD data); |
378 virtual LRESULT OnReflectedMessage(UINT msg, WPARAM w_param, LPARAM l_param); | 371 virtual LRESULT OnReflectedMessage(UINT msg, WPARAM w_param, LPARAM l_param); |
379 virtual void OnSetFocus(HWND focused_window); | 372 virtual void OnSetFocus(HWND focused_window); |
380 virtual LRESULT OnSetIcon(UINT size_type, HICON new_icon); | 373 virtual LRESULT OnSetIcon(UINT size_type, HICON new_icon); |
381 virtual LRESULT OnSetText(const wchar_t* text); | 374 virtual LRESULT OnSetText(const wchar_t* text); |
382 virtual void OnSettingChange(UINT flags, const wchar_t* section); | 375 virtual void OnSettingChange(UINT flags, const wchar_t* section); |
383 virtual void OnSize(UINT param, const CSize& size); | 376 virtual void OnSize(UINT param, const CSize& size); |
384 virtual void OnSysCommand(UINT notification_code, CPoint click); | 377 virtual void OnSysCommand(UINT notification_code, CPoint click); |
385 virtual void OnThemeChanged(); | 378 virtual void OnThemeChanged(); |
386 virtual void OnVScroll(int scroll_type, short position, HWND scrollbar); | 379 virtual void OnVScroll(int scroll_type, short position, HWND scrollbar); |
387 virtual void OnWindowPosChanging(WINDOWPOS* window_pos); | 380 virtual void OnWindowPosChanging(WINDOWPOS* window_pos); |
388 virtual void OnWindowPosChanged(WINDOWPOS* window_pos); | 381 virtual void OnWindowPosChanged(WINDOWPOS* window_pos); |
389 | 382 |
390 // Deletes this window as it is destroyed, override to provide different | 383 // Deletes this window as it is destroyed, override to provide different |
391 // behavior. | 384 // behavior. |
392 virtual void OnFinalMessage(HWND window); | 385 virtual void OnFinalMessage(HWND window); |
393 | 386 |
394 // Start tracking all mouse events so that this window gets sent mouse leave | 387 // Start tracking all mouse events so that this window gets sent mouse leave |
395 // messages too. | 388 // messages too. |
396 void TrackMouseEvents(DWORD mouse_tracking_flags); | 389 void TrackMouseEvents(DWORD mouse_tracking_flags); |
397 | 390 |
398 // Actually handle mouse events. These functions are called by subclasses who | |
399 // override the message handlers above to do the actual real work of handling | |
400 // the event in the View system. | |
401 bool ProcessMousePressed(UINT message, WPARAM w_param, LPARAM l_param); | |
402 bool ProcessMouseReleased(UINT message, WPARAM w_param, LPARAM l_param); | |
403 bool ProcessMouseMoved(UINT message, WPARAM w_param, LPARAM l_param); | |
404 void ProcessMouseExited(UINT message, WPARAM w_param, LPARAM l_param); | |
405 | |
406 // Called when a MSAA screen reader client is detected. | 391 // Called when a MSAA screen reader client is detected. |
407 virtual void OnScreenReaderDetected(); | 392 virtual void OnScreenReaderDetected(); |
408 | 393 |
409 // Returns whether capture should be released on mouse release. The default | |
410 // is true. | |
411 virtual bool ReleaseCaptureOnMouseReleased(); | |
412 | |
413 // The TooltipManager. | 394 // The TooltipManager. |
414 // WARNING: RootView's destructor calls into the TooltipManager. As such, this | 395 // WARNING: RootView's destructor calls into the TooltipManager. As such, this |
415 // must be destroyed AFTER root_view_. | 396 // must be destroyed AFTER root_view_. |
416 scoped_ptr<TooltipManagerWin> tooltip_manager_; | 397 scoped_ptr<TooltipManagerWin> tooltip_manager_; |
417 | 398 |
418 scoped_refptr<DropTargetWin> drop_target_; | 399 scoped_refptr<DropTargetWin> drop_target_; |
419 | 400 |
420 // If true, the mouse is currently down. | |
421 bool is_mouse_down_; | |
422 | |
423 // Are a subclass of WindowWin? | 401 // Are a subclass of WindowWin? |
424 bool is_window_; | 402 bool is_window_; |
425 | 403 |
426 private: | 404 private: |
427 typedef ScopedVector<ui::ViewProp> ViewProps; | 405 typedef ScopedVector<ui::ViewProp> ViewProps; |
428 | 406 |
429 // Implementation of GetWindow. Ascends the parents of |hwnd| returning the | 407 // Implementation of GetWindow. Ascends the parents of |hwnd| returning the |
430 // first ancestor that is a Window. | 408 // first ancestor that is a Window. |
431 static Window* GetWindowImpl(HWND hwnd); | 409 static Window* GetWindowImpl(HWND hwnd); |
432 | 410 |
433 // Returns the RootView that contains the focused view, or NULL if there is no | 411 // Returns the RootView that contains the focused view, or NULL if there is no |
434 // focused view. | 412 // focused view. |
435 RootView* GetFocusedViewRootView(); | 413 RootView* GetFocusedViewRootView(); |
436 | 414 |
437 // Called after the WM_ACTIVATE message has been processed by the default | 415 // Called after the WM_ACTIVATE message has been processed by the default |
438 // windows procedure. | 416 // windows procedure. |
439 static void PostProcessActivateMessage(WidgetWin* widget, | 417 static void PostProcessActivateMessage(WidgetWin* widget, |
440 int activation_state); | 418 int activation_state); |
441 | 419 |
442 // Fills out a MSG struct with the supplied values. | |
443 void MakeMSG(MSG* msg, UINT message, WPARAM w_param, LPARAM l_param, | |
444 DWORD time = 0, LONG x = 0, LONG y = 0) const; | |
445 | |
446 // Synchronously paints the invalid contents of the Widget. | 420 // Synchronously paints the invalid contents of the Widget. |
447 void RedrawInvalidRect(); | 421 void RedrawInvalidRect(); |
448 | 422 |
449 // Synchronously updates the invalid contents of the Widget. Valid for | 423 // Synchronously updates the invalid contents of the Widget. Valid for |
450 // layered windows only. | 424 // layered windows only. |
451 void RedrawLayeredWindowContents(); | 425 void RedrawLayeredWindowContents(); |
452 | 426 |
453 // Responds to the client area changing size, either at window creation time | 427 // Responds to the client area changing size, either at window creation time |
454 // or subsequently. | 428 // or subsequently. |
455 void ClientAreaSizeChanged(); | 429 void ClientAreaSizeChanged(); |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
497 ScopedRunnableMethodFactory<WidgetWin> paint_layered_window_factory_; | 471 ScopedRunnableMethodFactory<WidgetWin> paint_layered_window_factory_; |
498 | 472 |
499 // Whether or not the window should delete itself when it is destroyed. | 473 // Whether or not the window should delete itself when it is destroyed. |
500 // Set this to false via its setter for stack allocated instances. | 474 // Set this to false via its setter for stack allocated instances. |
501 bool delete_on_destroy_; | 475 bool delete_on_destroy_; |
502 | 476 |
503 // True if we are allowed to update the layered window from the DIB backing | 477 // True if we are allowed to update the layered window from the DIB backing |
504 // store if necessary. | 478 // store if necessary. |
505 bool can_update_layered_window_; | 479 bool can_update_layered_window_; |
506 | 480 |
507 // The following are used to detect duplicate mouse move events and not | |
508 // deliver them. Displaying a window may result in the system generating | |
509 // duplicate move events even though the mouse hasn't moved. | |
510 | |
511 // If true, the last event was a mouse move event. | |
512 bool last_mouse_event_was_move_; | |
513 | |
514 // Coordinates of the last mouse move event. | |
515 int last_mouse_move_x_; | |
516 int last_mouse_move_y_; | |
517 | |
518 // Whether the focus should be restored next time we get enabled. Needed to | 481 // Whether the focus should be restored next time we get enabled. Needed to |
519 // restore focus correctly when Windows modal dialogs are displayed. | 482 // restore focus correctly when Windows modal dialogs are displayed. |
520 bool restore_focus_when_enabled_; | 483 bool restore_focus_when_enabled_; |
521 | 484 |
522 // Instance of accessibility information and handling for MSAA root | 485 // Instance of accessibility information and handling for MSAA root |
523 base::win::ScopedComPtr<IAccessible> accessibility_root_; | 486 base::win::ScopedComPtr<IAccessible> accessibility_root_; |
524 | 487 |
525 // Value determines whether the Widget is customized for accessibility. | 488 // Value determines whether the Widget is customized for accessibility. |
526 static bool screen_reader_active_; | 489 static bool screen_reader_active_; |
527 | 490 |
(...skipping 13 matching lines...) Expand all Loading... |
541 gfx::NativeCursor previous_cursor_; | 504 gfx::NativeCursor previous_cursor_; |
542 | 505 |
543 ViewProps props_; | 506 ViewProps props_; |
544 | 507 |
545 DISALLOW_COPY_AND_ASSIGN(WidgetWin); | 508 DISALLOW_COPY_AND_ASSIGN(WidgetWin); |
546 }; | 509 }; |
547 | 510 |
548 } // namespace views | 511 } // namespace views |
549 | 512 |
550 #endif // VIEWS_WIDGET_WIDGET_WIN_H_ | 513 #endif // VIEWS_WIDGET_WIDGET_WIN_H_ |
OLD | NEW |