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

Side by Side Diff: xfa/fwl/core/cfwl_widget.cpp

Issue 2530993002: Cleanup FWL Event and Message code. (Closed)
Patch Set: Cleanup Created 4 years 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
« xfa/fwl/core/cfwl_message.h ('K') | « xfa/fwl/core/cfwl_widget.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 2014 PDFium Authors. All rights reserved. 1 // Copyright 2014 PDFium 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 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com 5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
6 6
7 #include "xfa/fwl/core/cfwl_widget.h" 7 #include "xfa/fwl/core/cfwl_widget.h"
8 8
9 #include <algorithm> 9 #include <algorithm>
10 #include <utility> 10 #include <utility>
11 11
12 #include "xfa/fde/tto/fde_textout.h" 12 #include "xfa/fde/tto/fde_textout.h"
13 #include "xfa/fwl/core/cfwl_app.h" 13 #include "xfa/fwl/core/cfwl_app.h"
14 #include "xfa/fwl/core/cfwl_combobox.h" 14 #include "xfa/fwl/core/cfwl_combobox.h"
15 #include "xfa/fwl/core/cfwl_evtkey.h" 15 #include "xfa/fwl/core/cfwl_event.h"
16 #include "xfa/fwl/core/cfwl_evtkillfocus.h"
17 #include "xfa/fwl/core/cfwl_evtmouse.h" 16 #include "xfa/fwl/core/cfwl_evtmouse.h"
18 #include "xfa/fwl/core/cfwl_evtmousewheel.h"
19 #include "xfa/fwl/core/cfwl_evtsetfocus.h"
20 #include "xfa/fwl/core/cfwl_evtsizechanged.h"
21 #include "xfa/fwl/core/cfwl_form.h" 17 #include "xfa/fwl/core/cfwl_form.h"
22 #include "xfa/fwl/core/cfwl_msgkey.h" 18 #include "xfa/fwl/core/cfwl_msgkey.h"
23 #include "xfa/fwl/core/cfwl_msgkillfocus.h" 19 #include "xfa/fwl/core/cfwl_msgkillfocus.h"
24 #include "xfa/fwl/core/cfwl_msgmouse.h" 20 #include "xfa/fwl/core/cfwl_msgmouse.h"
25 #include "xfa/fwl/core/cfwl_msgmousewheel.h" 21 #include "xfa/fwl/core/cfwl_msgmousewheel.h"
26 #include "xfa/fwl/core/cfwl_msgsetfocus.h" 22 #include "xfa/fwl/core/cfwl_msgsetfocus.h"
27 #include "xfa/fwl/core/cfwl_notedriver.h" 23 #include "xfa/fwl/core/cfwl_notedriver.h"
28 #include "xfa/fwl/core/cfwl_themebackground.h" 24 #include "xfa/fwl/core/cfwl_themebackground.h"
29 #include "xfa/fwl/core/cfwl_themepart.h" 25 #include "xfa/fwl/core/cfwl_themepart.h"
30 #include "xfa/fwl/core/cfwl_themetext.h" 26 #include "xfa/fwl/core/cfwl_themetext.h"
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
79 FX_FLOAT fEdge = GetEdgeWidth(); 75 FX_FLOAT fEdge = GetEdgeWidth();
80 rect.Inflate(fEdge, fEdge); 76 rect.Inflate(fEdge, fEdge);
81 } 77 }
82 if (HasBorder()) { 78 if (HasBorder()) {
83 FX_FLOAT fBorder = GetBorderSize(); 79 FX_FLOAT fBorder = GetBorderSize();
84 rect.Inflate(fBorder, fBorder); 80 rect.Inflate(fBorder, fBorder);
85 } 81 }
86 } 82 }
87 83
88 void CFWL_Widget::SetWidgetRect(const CFX_RectF& rect) { 84 void CFWL_Widget::SetWidgetRect(const CFX_RectF& rect) {
89 CFX_RectF rtOld = m_pProperties->m_rtWidget;
90 m_pProperties->m_rtWidget = rect; 85 m_pProperties->m_rtWidget = rect;
91 if (IsChild()) { 86 if (IsChild())
92 if (FXSYS_fabs(rtOld.width - rect.width) > 0.5f || 87 return;
93 FXSYS_fabs(rtOld.height - rect.height) > 0.5f) {
94 CFWL_EvtSizeChanged ev;
95 ev.m_pSrcTarget = this;
96 ev.m_rtOld = rtOld;
97 ev.m_rtNew = rect;
98 88
99 if (IFWL_WidgetDelegate* pDelegate = GetDelegate())
100 pDelegate->OnProcessEvent(&ev);
101 }
102 return;
103 }
104 m_pWidgetMgr->SetWidgetRect_Native(this, rect); 89 m_pWidgetMgr->SetWidgetRect_Native(this, rect);
105 } 90 }
106 91
107 void CFWL_Widget::GetClientRect(CFX_RectF& rect) { 92 void CFWL_Widget::GetClientRect(CFX_RectF& rect) {
108 GetEdgeRect(rect); 93 GetEdgeRect(rect);
109 if (HasEdge()) { 94 if (HasEdge()) {
110 FX_FLOAT fEdge = GetEdgeWidth(); 95 FX_FLOAT fEdge = GetEdgeWidth();
111 rect.Deflate(fEdge, fEdge); 96 rect.Deflate(fEdge, fEdge);
112 } 97 }
113 } 98 }
(...skipping 477 matching lines...) Expand 10 before | Expand all | Expand 10 after
591 if (!pApp) 576 if (!pApp)
592 return; 577 return;
593 578
594 CFWL_NoteDriver* pNoteDriver = pApp->GetNoteDriver(); 579 CFWL_NoteDriver* pNoteDriver = pApp->GetNoteDriver();
595 if (!pNoteDriver) 580 if (!pNoteDriver)
596 return; 581 return;
597 582
598 pNoteDriver->UnregisterEventTarget(this); 583 pNoteDriver->UnregisterEventTarget(this);
599 } 584 }
600 585
601 void CFWL_Widget::DispatchKeyEvent(CFWL_MsgKey* pNote) {
602 if (!pNote)
603 return;
604
605 auto pEvent = pdfium::MakeUnique<CFWL_EvtKey>();
606 pEvent->m_pSrcTarget = this;
607 pEvent->m_dwCmd = pNote->m_dwCmd;
608 pEvent->m_dwKeyCode = pNote->m_dwKeyCode;
609 pEvent->m_dwFlags = pNote->m_dwFlags;
610 DispatchEvent(pEvent.get());
611 }
612
613 void CFWL_Widget::DispatchEvent(CFWL_Event* pEvent) { 586 void CFWL_Widget::DispatchEvent(CFWL_Event* pEvent) {
614 if (m_pOuter) { 587 if (m_pOuter) {
615 m_pOuter->GetDelegate()->OnProcessEvent(pEvent); 588 m_pOuter->GetDelegate()->OnProcessEvent(pEvent);
616 return; 589 return;
617 } 590 }
618 const CFWL_App* pApp = GetOwnerApp(); 591 const CFWL_App* pApp = GetOwnerApp();
619 if (!pApp) 592 if (!pApp)
620 return; 593 return;
621 594
622 CFWL_NoteDriver* pNoteDriver = pApp->GetNoteDriver(); 595 CFWL_NoteDriver* pNoteDriver = pApp->GetNoteDriver();
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after
734 707
735 CFWL_Widget* pWidget = pMessage->m_pDstTarget; 708 CFWL_Widget* pWidget = pMessage->m_pDstTarget;
736 CFWL_MessageType dwMsgCode = pMessage->GetClassID(); 709 CFWL_MessageType dwMsgCode = pMessage->GetClassID();
737 switch (dwMsgCode) { 710 switch (dwMsgCode) {
738 case CFWL_MessageType::Mouse: { 711 case CFWL_MessageType::Mouse: {
739 CFWL_MsgMouse* pMsgMouse = static_cast<CFWL_MsgMouse*>(pMessage); 712 CFWL_MsgMouse* pMsgMouse = static_cast<CFWL_MsgMouse*>(pMessage);
740 CFWL_EvtMouse evt; 713 CFWL_EvtMouse evt;
741 evt.m_pSrcTarget = pWidget; 714 evt.m_pSrcTarget = pWidget;
742 evt.m_pDstTarget = pWidget; 715 evt.m_pDstTarget = pWidget;
743 evt.m_dwCmd = pMsgMouse->m_dwCmd; 716 evt.m_dwCmd = pMsgMouse->m_dwCmd;
744 evt.m_dwFlags = pMsgMouse->m_dwFlags;
745 evt.m_fx = pMsgMouse->m_fx;
746 evt.m_fy = pMsgMouse->m_fy;
747 pWidget->DispatchEvent(&evt); 717 pWidget->DispatchEvent(&evt);
748 break; 718 break;
749 } 719 }
750 case CFWL_MessageType::MouseWheel: {
751 CFWL_MsgMouseWheel* pMsgMouseWheel =
752 static_cast<CFWL_MsgMouseWheel*>(pMessage);
753 CFWL_EvtMouseWheel evt;
754 evt.m_pSrcTarget = pWidget;
755 evt.m_pDstTarget = pWidget;
756 evt.m_dwFlags = pMsgMouseWheel->m_dwFlags;
757 evt.m_fDeltaX = pMsgMouseWheel->m_fDeltaX;
758 evt.m_fDeltaY = pMsgMouseWheel->m_fDeltaY;
759 evt.m_fx = pMsgMouseWheel->m_fx;
760 evt.m_fy = pMsgMouseWheel->m_fy;
761 pWidget->DispatchEvent(&evt);
762 break;
763 }
764 case CFWL_MessageType::Key: {
765 CFWL_MsgKey* pMsgKey = static_cast<CFWL_MsgKey*>(pMessage);
766 CFWL_EvtKey evt;
767 evt.m_pSrcTarget = pWidget;
768 evt.m_pDstTarget = pWidget;
769 evt.m_dwKeyCode = pMsgKey->m_dwKeyCode;
770 evt.m_dwFlags = pMsgKey->m_dwFlags;
771 evt.m_dwCmd = pMsgKey->m_dwCmd;
772 pWidget->DispatchEvent(&evt);
773 break;
774 }
775 case CFWL_MessageType::SetFocus: {
776 CFWL_MsgSetFocus* pMsgSetFocus = static_cast<CFWL_MsgSetFocus*>(pMessage);
777 CFWL_EvtSetFocus evt;
778 evt.m_pSrcTarget = pMsgSetFocus->m_pDstTarget;
779 evt.m_pDstTarget = pMsgSetFocus->m_pDstTarget;
780 evt.m_pSetFocus = pWidget;
781 pWidget->DispatchEvent(&evt);
782 break;
783 }
784 case CFWL_MessageType::KillFocus: {
785 CFWL_MsgKillFocus* pMsgKillFocus =
786 static_cast<CFWL_MsgKillFocus*>(pMessage);
787 CFWL_EvtKillFocus evt;
788 evt.m_pSrcTarget = pMsgKillFocus->m_pDstTarget;
789 evt.m_pDstTarget = pMsgKillFocus->m_pDstTarget;
790 evt.m_pKillFocus = pWidget;
791 pWidget->DispatchEvent(&evt);
792 break;
793 }
794 default: 720 default:
795 break; 721 break;
796 } 722 }
797 } 723 }
798 724
799 void CFWL_Widget::OnProcessEvent(CFWL_Event* pEvent) {} 725 void CFWL_Widget::OnProcessEvent(CFWL_Event* pEvent) {}
800 726
801 void CFWL_Widget::OnDrawWidget(CFX_Graphics* pGraphics, 727 void CFWL_Widget::OnDrawWidget(CFX_Graphics* pGraphics,
802 const CFX_Matrix* pMatrix) {} 728 const CFX_Matrix* pMatrix) {}
OLDNEW
« xfa/fwl/core/cfwl_message.h ('K') | « xfa/fwl/core/cfwl_widget.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698