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

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

Issue 2467993003: Merge delegates into IFWL_* classes. (Closed)
Patch Set: Add const version Created 4 years, 1 month 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
« no previous file with comments | « xfa/fwl/core/ifwl_comboboxproxy.h ('k') | xfa/fwl/core/ifwl_comboedit.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright 2016 PDFium 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.
4
5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
6
7 #include "xfa/fwl/core/ifwl_comboboxproxy.h"
8
9 #include "xfa/fwl/core/fwl_noteimp.h"
10 #include "xfa/fwl/core/ifwl_app.h"
11 #include "xfa/fwl/core/ifwl_combobox.h"
12
13 IFWL_ComboBoxProxy::IFWL_ComboBoxProxy(
14 IFWL_ComboBox* pComboBox,
15 const IFWL_App* app,
16 const CFWL_WidgetImpProperties& properties,
17 IFWL_Widget* pOuter)
18 : IFWL_FormProxy(app, properties, pOuter),
19 m_bLButtonDown(FALSE),
20 m_bLButtonUpSelf(FALSE),
21 m_pComboBox(pComboBox) {}
22
23 IFWL_ComboBoxProxy::~IFWL_ComboBoxProxy() {}
24
25 void IFWL_ComboBoxProxy::OnProcessMessage(CFWL_Message* pMessage) {
26 if (!pMessage)
27 return;
28
29 switch (pMessage->GetClassID()) {
30 case CFWL_MessageType::Mouse: {
31 CFWL_MsgMouse* pMsg = static_cast<CFWL_MsgMouse*>(pMessage);
32 switch (pMsg->m_dwCmd) {
33 case FWL_MouseCommand::LeftButtonDown:
34 OnLButtonDown(pMsg);
35 break;
36 case FWL_MouseCommand::LeftButtonUp:
37 OnLButtonUp(pMsg);
38 break;
39 case FWL_MouseCommand::Move:
40 break;
41 default:
42 break;
43 }
44 break;
45 }
46 case CFWL_MessageType::Deactivate:
47 OnDeactive(static_cast<CFWL_MsgDeactivate*>(pMessage));
48 break;
49 case CFWL_MessageType::KillFocus:
50 OnFocusChanged(static_cast<CFWL_MsgKillFocus*>(pMessage), FALSE);
51 break;
52 case CFWL_MessageType::SetFocus:
53 OnFocusChanged(static_cast<CFWL_MsgKillFocus*>(pMessage), TRUE);
54 break;
55 default:
56 break;
57 }
58 IFWL_Widget::OnProcessMessage(pMessage);
59 }
60
61 void IFWL_ComboBoxProxy::OnDrawWidget(CFX_Graphics* pGraphics,
62 const CFX_Matrix* pMatrix) {
63 m_pComboBox->DrawStretchHandler(pGraphics, pMatrix);
64 }
65
66 void IFWL_ComboBoxProxy::OnLButtonDown(CFWL_MsgMouse* pMsg) {
67 const IFWL_App* pApp = GetOwnerApp();
68 if (!pApp)
69 return;
70
71 CFWL_NoteDriver* pDriver =
72 static_cast<CFWL_NoteDriver*>(pApp->GetNoteDriver());
73 CFX_RectF rtWidget;
74 GetWidgetRect(rtWidget);
75 rtWidget.left = rtWidget.top = 0;
76 if (rtWidget.Contains(pMsg->m_fx, pMsg->m_fy)) {
77 m_bLButtonDown = TRUE;
78 pDriver->SetGrab(this, TRUE);
79 } else {
80 m_bLButtonDown = FALSE;
81 pDriver->SetGrab(this, FALSE);
82 m_pComboBox->ShowDropList(FALSE);
83 }
84 }
85
86 void IFWL_ComboBoxProxy::OnLButtonUp(CFWL_MsgMouse* pMsg) {
87 m_bLButtonDown = FALSE;
88 const IFWL_App* pApp = GetOwnerApp();
89 if (!pApp)
90 return;
91
92 CFWL_NoteDriver* pDriver =
93 static_cast<CFWL_NoteDriver*>(pApp->GetNoteDriver());
94 pDriver->SetGrab(this, FALSE);
95 if (m_bLButtonUpSelf) {
96 CFX_RectF rect;
97 GetWidgetRect(rect);
98 rect.left = rect.top = 0;
99 if (!rect.Contains(pMsg->m_fx, pMsg->m_fy) &&
100 m_pComboBox->IsDropListShowed()) {
101 m_pComboBox->ShowDropList(FALSE);
102 }
103 } else {
104 m_bLButtonUpSelf = TRUE;
105 }
106 }
107
108 void IFWL_ComboBoxProxy::OnDeactive(CFWL_MsgDeactivate* pMsg) {
109 m_pComboBox->ShowDropList(FALSE);
110 }
111
112 void IFWL_ComboBoxProxy::OnFocusChanged(CFWL_MsgKillFocus* pMsg, FX_BOOL bSet) {
113 if (bSet)
114 return;
115
116 if (!pMsg->m_pSetFocus)
117 m_pComboBox->ShowDropList(FALSE);
118 }
OLDNEW
« no previous file with comments | « xfa/fwl/core/ifwl_comboboxproxy.h ('k') | xfa/fwl/core/ifwl_comboedit.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698