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

Side by Side Diff: views/widget/widget_win.cc

Issue 254003: Refactored event handler method bodies from widget_win.h to... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 11 years, 2 months 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_win.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2006-2008 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 #include "views/widget/widget_win.h" 5 #include "views/widget/widget_win.h"
6 6
7 #include "app/gfx/canvas.h" 7 #include "app/gfx/canvas.h"
8 #include "app/gfx/path.h" 8 #include "app/gfx/path.h"
9 #include "app/l10n_util_win.h" 9 #include "app/l10n_util_win.h"
10 #include "app/win_util.h" 10 #include "app/win_util.h"
(...skipping 405 matching lines...) Expand 10 before | Expand all | Expand 10 after
416 // We are a proxy to the root view, so we should be bypassed when traversing 416 // We are a proxy to the root view, so we should be bypassed when traversing
417 // up and as a result this should not be called. 417 // up and as a result this should not be called.
418 NOTREACHED(); 418 NOTREACHED();
419 return NULL; 419 return NULL;
420 } 420 }
421 421
422 void WidgetWin::SetFocusTraversableParentView(View* parent_view) { 422 void WidgetWin::SetFocusTraversableParentView(View* parent_view) {
423 root_view_->SetFocusTraversableParentView(parent_view); 423 root_view_->SetFocusTraversableParentView(parent_view);
424 } 424 }
425 425
426 bool WidgetWin::AcceleratorPressed(const Accelerator& accelerator) {
427 return false;
428 }
429
430 bool WidgetWin::GetAccelerator(int cmd_id, Accelerator* accelerator) {
431 return false;
432 }
433
434
426 /////////////////////////////////////////////////////////////////////////////// 435 ///////////////////////////////////////////////////////////////////////////////
427 // Message handlers 436 // Message handlers
428 437
438 void WidgetWin::OnActivate(UINT action, BOOL minimized, HWND window) {
439 SetMsgHandled(FALSE);
440 }
441
442 void WidgetWin::OnActivateApp(BOOL active, DWORD thread_id) {
443 SetMsgHandled(FALSE);
444 }
445
446 LRESULT WidgetWin::OnAppCommand(HWND window, short app_command, WORD device,
447 int keystate) {
448 SetMsgHandled(FALSE);
449 return 0;
450 }
451
452 void WidgetWin::OnCancelMode() {
453 }
454
429 void WidgetWin::OnCaptureChanged(HWND hwnd) { 455 void WidgetWin::OnCaptureChanged(HWND hwnd) {
430 if (has_capture_) { 456 if (has_capture_) {
431 if (is_mouse_down_) 457 if (is_mouse_down_)
432 root_view_->ProcessMouseDragCanceled(); 458 root_view_->ProcessMouseDragCanceled();
433 is_mouse_down_ = false; 459 is_mouse_down_ = false;
434 has_capture_ = false; 460 has_capture_ = false;
435 } 461 }
436 } 462 }
437 463
438 void WidgetWin::OnClose() { 464 void WidgetWin::OnClose() {
439 Close(); 465 Close();
440 } 466 }
441 467
468 void WidgetWin::OnCommand(UINT notification_code, int command_id, HWND window) {
469 SetMsgHandled(FALSE);
470 }
471
472 LRESULT WidgetWin::OnCreate(CREATESTRUCT* create_struct) {
473 return 0;
474 }
475
442 void WidgetWin::OnDestroy() { 476 void WidgetWin::OnDestroy() {
443 if (drop_target_.get()) { 477 if (drop_target_.get()) {
444 RevokeDragDrop(hwnd()); 478 RevokeDragDrop(hwnd());
445 drop_target_ = NULL; 479 drop_target_ = NULL;
446 } 480 }
447 481
448 RemoveProp(hwnd(), kRootViewWindowProperty); 482 RemoveProp(hwnd(), kRootViewWindowProperty);
449 } 483 }
450 484
485 LRESULT WidgetWin::OnDwmCompositionChanged(UINT msg,
486 WPARAM w_param,
487 LPARAM l_param) {
488 SetMsgHandled(FALSE);
489 return 0;
490 }
491
492 void WidgetWin::OnEndSession(BOOL ending, UINT logoff) {
493 SetMsgHandled(FALSE);
494 }
495
496 void WidgetWin::OnEnterSizeMove() {
497 SetMsgHandled(FALSE);
498 }
499
451 LRESULT WidgetWin::OnEraseBkgnd(HDC dc) { 500 LRESULT WidgetWin::OnEraseBkgnd(HDC dc) {
452 // This is needed for magical win32 flicker ju-ju 501 // This is needed for magical win32 flicker ju-ju
453 return 1; 502 return 1;
454 } 503 }
455 504
505 void WidgetWin::OnExitMenuLoop(BOOL is_track_popup_menu) {
506 SetMsgHandled(FALSE);
507 }
508
509 void WidgetWin::OnExitSizeMove() {
510 SetMsgHandled(FALSE);
511 }
512
456 LRESULT WidgetWin::OnGetObject(UINT uMsg, WPARAM w_param, LPARAM l_param) { 513 LRESULT WidgetWin::OnGetObject(UINT uMsg, WPARAM w_param, LPARAM l_param) {
457 LRESULT reference_result = static_cast<LRESULT>(0L); 514 LRESULT reference_result = static_cast<LRESULT>(0L);
458 515
459 // Accessibility readers will send an OBJID_CLIENT message 516 // Accessibility readers will send an OBJID_CLIENT message
460 if (OBJID_CLIENT == l_param) { 517 if (OBJID_CLIENT == l_param) {
461 // If our MSAA root is already created, reuse that pointer. Otherwise, 518 // If our MSAA root is already created, reuse that pointer. Otherwise,
462 // create a new one. 519 // create a new one.
463 if (!accessibility_root_) { 520 if (!accessibility_root_) {
464 CComObject<ViewAccessibility>* instance = NULL; 521 CComObject<ViewAccessibility>* instance = NULL;
465 522
(...skipping 22 matching lines...) Expand all
488 } 545 }
489 546
490 // Create a reference to ViewAccessibility that MSAA will marshall 547 // Create a reference to ViewAccessibility that MSAA will marshall
491 // to the client. 548 // to the client.
492 reference_result = LresultFromObject(IID_IAccessible, w_param, 549 reference_result = LresultFromObject(IID_IAccessible, w_param,
493 static_cast<IAccessible*>(accessibility_root_)); 550 static_cast<IAccessible*>(accessibility_root_));
494 } 551 }
495 return reference_result; 552 return reference_result;
496 } 553 }
497 554
555 void WidgetWin::OnGetMinMaxInfo(MINMAXINFO* minmax_info) {
556 SetMsgHandled(FALSE);
557 }
558
559 void WidgetWin::OnHScroll(int scroll_type, short position, HWND scrollbar) {
560 SetMsgHandled(FALSE);
561 }
562
563 void WidgetWin::OnInitMenu(HMENU menu) {
564 SetMsgHandled(FALSE);
565 }
566
567 void WidgetWin::OnInitMenuPopup(HMENU menu,
568 UINT position,
569 BOOL is_system_menu) {
570 SetMsgHandled(FALSE);
571 }
572
498 void WidgetWin::OnKeyDown(TCHAR c, UINT rep_cnt, UINT flags) { 573 void WidgetWin::OnKeyDown(TCHAR c, UINT rep_cnt, UINT flags) {
499 KeyEvent event(Event::ET_KEY_PRESSED, c, rep_cnt, flags); 574 KeyEvent event(Event::ET_KEY_PRESSED, c, rep_cnt, flags);
500 SetMsgHandled(root_view_->ProcessKeyEvent(event)); 575 SetMsgHandled(root_view_->ProcessKeyEvent(event));
501 } 576 }
502 577
503 void WidgetWin::OnKeyUp(TCHAR c, UINT rep_cnt, UINT flags) { 578 void WidgetWin::OnKeyUp(TCHAR c, UINT rep_cnt, UINT flags) {
504 KeyEvent event(Event::ET_KEY_RELEASED, c, rep_cnt, flags); 579 KeyEvent event(Event::ET_KEY_RELEASED, c, rep_cnt, flags);
505 SetMsgHandled(root_view_->ProcessKeyEvent(event)); 580 SetMsgHandled(root_view_->ProcessKeyEvent(event));
506 } 581 }
507 582
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
560 } 635 }
561 636
562 int flags = GET_KEYSTATE_WPARAM(w_param); 637 int flags = GET_KEYSTATE_WPARAM(w_param);
563 short distance = GET_WHEEL_DELTA_WPARAM(w_param); 638 short distance = GET_WHEEL_DELTA_WPARAM(w_param);
564 int x = GET_X_LPARAM(l_param); 639 int x = GET_X_LPARAM(l_param);
565 int y = GET_Y_LPARAM(l_param); 640 int y = GET_Y_LPARAM(l_param);
566 MouseWheelEvent e(distance, x, y, Event::ConvertWindowsFlags(flags)); 641 MouseWheelEvent e(distance, x, y, Event::ConvertWindowsFlags(flags));
567 return root_view_->ProcessMouseWheelEvent(e) ? 0 : 1; 642 return root_view_->ProcessMouseWheelEvent(e) ? 0 : 1;
568 } 643 }
569 644
645 void WidgetWin::OnMove(const CPoint& point) {
646 SetMsgHandled(FALSE);
647 }
648
649 void WidgetWin::OnMoving(UINT param, const LPRECT new_bounds) {
650 }
651
570 LRESULT WidgetWin::OnMouseRange(UINT msg, WPARAM w_param, LPARAM l_param) { 652 LRESULT WidgetWin::OnMouseRange(UINT msg, WPARAM w_param, LPARAM l_param) {
571 tooltip_manager_->OnMouse(msg, w_param, l_param); 653 tooltip_manager_->OnMouse(msg, w_param, l_param);
572 SetMsgHandled(FALSE); 654 SetMsgHandled(FALSE);
573 return 0; 655 return 0;
574 } 656 }
575 657
658 LRESULT WidgetWin::OnNCActivate(BOOL active) {
659 SetMsgHandled(FALSE);
660 return 0;
661 }
662
663 LRESULT WidgetWin::OnNCCalcSize(BOOL w_param, LPARAM l_param) {
664 SetMsgHandled(FALSE);
665 return 0;
666 }
667
668 LRESULT WidgetWin::OnNCHitTest(const CPoint& pt) {
669 SetMsgHandled(FALSE);
670 return 0;
671 }
672
576 void WidgetWin::OnNCLButtonDblClk(UINT flags, const CPoint& point) { 673 void WidgetWin::OnNCLButtonDblClk(UINT flags, const CPoint& point) {
577 SetMsgHandled(ProcessMousePressed(point, flags | MK_LBUTTON, true, true)); 674 SetMsgHandled(ProcessMousePressed(point, flags | MK_LBUTTON, true, true));
578 } 675 }
579 676
580 void WidgetWin::OnNCLButtonDown(UINT flags, const CPoint& point) { 677 void WidgetWin::OnNCLButtonDown(UINT flags, const CPoint& point) {
581 SetMsgHandled(ProcessMousePressed(point, flags | MK_LBUTTON, false, true)); 678 SetMsgHandled(ProcessMousePressed(point, flags | MK_LBUTTON, false, true));
582 } 679 }
583 680
584 void WidgetWin::OnNCLButtonUp(UINT flags, const CPoint& point) { 681 void WidgetWin::OnNCLButtonUp(UINT flags, const CPoint& point) {
585 SetMsgHandled(FALSE); 682 SetMsgHandled(FALSE);
(...skipping 21 matching lines...) Expand all
607 CPoint temp = point; 704 CPoint temp = point;
608 MapWindowPoints(HWND_DESKTOP, hwnd(), &temp, 1); 705 MapWindowPoints(HWND_DESKTOP, hwnd(), &temp, 1);
609 ProcessMouseMoved(temp, 0, true); 706 ProcessMouseMoved(temp, 0, true);
610 707
611 // We need to process this message to stop Windows from drawing the window 708 // We need to process this message to stop Windows from drawing the window
612 // controls as the mouse moves over the title bar area when the window is 709 // controls as the mouse moves over the title bar area when the window is
613 // maximized. 710 // maximized.
614 return 0; 711 return 0;
615 } 712 }
616 713
714 void WidgetWin::OnNCPaint(HRGN rgn) {
715 SetMsgHandled(FALSE);
716 }
717
617 void WidgetWin::OnNCRButtonDblClk(UINT flags, const CPoint& point) { 718 void WidgetWin::OnNCRButtonDblClk(UINT flags, const CPoint& point) {
618 SetMsgHandled(ProcessMousePressed(point, flags | MK_RBUTTON, true, true)); 719 SetMsgHandled(ProcessMousePressed(point, flags | MK_RBUTTON, true, true));
619 } 720 }
620 721
621 void WidgetWin::OnNCRButtonDown(UINT flags, const CPoint& point) { 722 void WidgetWin::OnNCRButtonDown(UINT flags, const CPoint& point) {
622 SetMsgHandled(ProcessMousePressed(point, flags | MK_RBUTTON, false, true)); 723 SetMsgHandled(ProcessMousePressed(point, flags | MK_RBUTTON, false, true));
623 } 724 }
624 725
625 void WidgetWin::OnNCRButtonUp(UINT flags, const CPoint& point) { 726 void WidgetWin::OnNCRButtonUp(UINT flags, const CPoint& point) {
626 SetMsgHandled(FALSE); 727 SetMsgHandled(FALSE);
627 } 728 }
628 729
730 LRESULT WidgetWin::OnNCUAHDrawCaption(UINT msg,
731 WPARAM w_param,
732 LPARAM l_param) {
733 SetMsgHandled(FALSE);
734 return 0;
735 }
736
737 LRESULT WidgetWin::OnNCUAHDrawFrame(UINT msg, WPARAM w_param, LPARAM l_param) {
738 SetMsgHandled(FALSE);
739 return 0;
740 }
741
629 LRESULT WidgetWin::OnNotify(int w_param, NMHDR* l_param) { 742 LRESULT WidgetWin::OnNotify(int w_param, NMHDR* l_param) {
630 // We can be sent this message before the tooltip manager is created, if a 743 // We can be sent this message before the tooltip manager is created, if a
631 // subclass overrides OnCreate and creates some kind of Windows control there 744 // subclass overrides OnCreate and creates some kind of Windows control there
632 // that sends WM_NOTIFY messages. 745 // that sends WM_NOTIFY messages.
633 if (tooltip_manager_.get()) { 746 if (tooltip_manager_.get()) {
634 bool handled; 747 bool handled;
635 LRESULT result = tooltip_manager_->OnNotify(w_param, l_param, &handled); 748 LRESULT result = tooltip_manager_->OnNotify(w_param, l_param, &handled);
636 SetMsgHandled(handled); 749 SetMsgHandled(handled);
637 return result; 750 return result;
638 } 751 }
639 SetMsgHandled(FALSE); 752 SetMsgHandled(FALSE);
640 return 0; 753 return 0;
641 } 754 }
642 755
643 void WidgetWin::OnPaint(HDC dc) { 756 void WidgetWin::OnPaint(HDC dc) {
644 root_view_->OnPaint(hwnd()); 757 root_view_->OnPaint(hwnd());
645 } 758 }
646 759
760 LRESULT WidgetWin::OnPowerBroadcast(DWORD power_event, DWORD data) {
761 base::SystemMonitor* monitor = base::SystemMonitor::Get();
762 if (monitor)
763 monitor->ProcessWmPowerBroadcastMessage(power_event);
764 SetMsgHandled(FALSE);
765 return 0;
766 }
767
647 void WidgetWin::OnRButtonDown(UINT flags, const CPoint& point) { 768 void WidgetWin::OnRButtonDown(UINT flags, const CPoint& point) {
648 ProcessMousePressed(point, flags | MK_RBUTTON, false, false); 769 ProcessMousePressed(point, flags | MK_RBUTTON, false, false);
649 } 770 }
650 771
651 void WidgetWin::OnRButtonUp(UINT flags, const CPoint& point) { 772 void WidgetWin::OnRButtonUp(UINT flags, const CPoint& point) {
652 ProcessMouseReleased(point, flags | MK_RBUTTON); 773 ProcessMouseReleased(point, flags | MK_RBUTTON);
653 } 774 }
654 775
655 void WidgetWin::OnRButtonDblClk(UINT flags, const CPoint& point) { 776 void WidgetWin::OnRButtonDblClk(UINT flags, const CPoint& point) {
656 ProcessMousePressed(point, flags | MK_RBUTTON, true, false); 777 ProcessMousePressed(point, flags | MK_RBUTTON, true, false);
657 } 778 }
658 779
780 LRESULT WidgetWin::OnReflectedMessage(UINT msg,
781 WPARAM w_param,
782 LPARAM l_param) {
783 SetMsgHandled(FALSE);
784 return 0;
785 }
786
787 void WidgetWin::OnSetFocus(HWND focused_window) {
788 SetMsgHandled(FALSE);
789 }
790
791 LRESULT WidgetWin::OnSetIcon(UINT size_type, HICON new_icon) {
792 SetMsgHandled(FALSE);
793 return 0;
794 }
795
796 LRESULT WidgetWin::OnSetText(const wchar_t* text) {
797 SetMsgHandled(FALSE);
798 return 0;
799 }
800
801 void WidgetWin::OnSettingChange(UINT flags, const wchar_t* section) {
802 SetMsgHandled(FALSE);
803 }
804
659 void WidgetWin::OnSize(UINT param, const CSize& size) { 805 void WidgetWin::OnSize(UINT param, const CSize& size) {
660 ChangeSize(param, size); 806 ChangeSize(param, size);
661 } 807 }
662 808
809 void WidgetWin::OnSysCommand(UINT notification_code, CPoint click) {
810 }
811
663 void WidgetWin::OnThemeChanged() { 812 void WidgetWin::OnThemeChanged() {
664 // Notify NativeTheme. 813 // Notify NativeTheme.
665 gfx::NativeTheme::instance()->CloseHandles(); 814 gfx::NativeTheme::instance()->CloseHandles();
666 } 815 }
667 816
668 void WidgetWin::OnFinalMessage(HWND window) { 817 void WidgetWin::OnFinalMessage(HWND window) {
669 if (delete_on_destroy_) 818 if (delete_on_destroy_)
670 delete this; 819 delete this;
671 } 820 }
672 821
822 void WidgetWin::OnVScroll(int scroll_type, short position, HWND scrollbar) {
823 SetMsgHandled(FALSE);
824 }
825
826 void WidgetWin::OnWindowPosChanging(WINDOWPOS* window_pos) {
827 SetMsgHandled(FALSE);
828 }
829
830 void WidgetWin::OnWindowPosChanged(WINDOWPOS* window_pos) {
831 SetMsgHandled(FALSE);
832 }
833
673 /////////////////////////////////////////////////////////////////////////////// 834 ///////////////////////////////////////////////////////////////////////////////
674 // WidgetWin, protected: 835 // WidgetWin, protected:
675 836
676 void WidgetWin::TrackMouseEvents(DWORD mouse_tracking_flags) { 837 void WidgetWin::TrackMouseEvents(DWORD mouse_tracking_flags) {
677 // Begin tracking mouse events for this HWND so that we get WM_MOUSELEAVE 838 // Begin tracking mouse events for this HWND so that we get WM_MOUSELEAVE
678 // when the user moves the mouse outside this HWND's bounds. 839 // when the user moves the mouse outside this HWND's bounds.
679 if (active_mouse_tracking_flags_ == 0 || mouse_tracking_flags & TME_CANCEL) { 840 if (active_mouse_tracking_flags_ == 0 || mouse_tracking_flags & TME_CANCEL) {
680 if (mouse_tracking_flags & TME_CANCEL) { 841 if (mouse_tracking_flags & TME_CANCEL) {
681 // We're about to cancel active mouse tracking, so empty out the stored 842 // We're about to cancel active mouse tracking, so empty out the stored
682 // state. 843 // state.
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after
796 957
797 // Resizing changes the size of the view hierarchy and thus forces a 958 // Resizing changes the size of the view hierarchy and thus forces a
798 // complete relayout. 959 // complete relayout.
799 root_view_->SetBounds(0, 0, rect.Width(), rect.Height()); 960 root_view_->SetBounds(0, 0, rect.Width(), rect.Height());
800 root_view_->SchedulePaint(); 961 root_view_->SchedulePaint();
801 962
802 if (use_layered_buffer_) 963 if (use_layered_buffer_)
803 PaintNow(gfx::Rect(rect)); 964 PaintNow(gfx::Rect(rect));
804 } 965 }
805 966
967 bool WidgetWin::ReleaseCaptureOnMouseReleased() {
968 return true;
969 }
970
806 RootView* WidgetWin::CreateRootView() { 971 RootView* WidgetWin::CreateRootView() {
807 return new RootView(this); 972 return new RootView(this);
808 } 973 }
809 974
810 /////////////////////////////////////////////////////////////////////////////// 975 ///////////////////////////////////////////////////////////////////////////////
811 // WidgetWin, private: 976 // WidgetWin, private:
812 977
813 // static 978 // static
814 Window* WidgetWin::GetWindowImpl(HWND hwnd) { 979 Window* WidgetWin::GetWindowImpl(HWND hwnd) {
815 // NOTE: we can't use GetAncestor here as constrained windows are a Window, 980 // NOTE: we can't use GetAncestor here as constrained windows are a Window,
(...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after
969 WidgetWin* popup = new WidgetWin; 1134 WidgetWin* popup = new WidgetWin;
970 popup->set_window_style(WS_POPUP); 1135 popup->set_window_style(WS_POPUP);
971 popup->set_window_ex_style(WS_EX_LAYERED | WS_EX_TOOLWINDOW | 1136 popup->set_window_ex_style(WS_EX_LAYERED | WS_EX_TOOLWINDOW |
972 WS_EX_TRANSPARENT | 1137 WS_EX_TRANSPARENT |
973 l10n_util::GetExtendedTooltipStyles()); 1138 l10n_util::GetExtendedTooltipStyles());
974 popup->set_delete_on_destroy(delete_on_destroy); 1139 popup->set_delete_on_destroy(delete_on_destroy);
975 return popup; 1140 return popup;
976 } 1141 }
977 1142
978 } // namespace views 1143 } // namespace views
OLDNEW
« no previous file with comments | « views/widget/widget_win.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698