OLD | NEW |
1 // Copyright 2016 PDFium Authors. All rights reserved. | 1 // Copyright 2016 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/ifwl_combolist.h" | 7 #include "xfa/fwl/core/ifwl_combolist.h" |
8 | 8 |
9 #include "third_party/base/ptr_util.h" | 9 #include "third_party/base/ptr_util.h" |
10 #include "xfa/fwl/core/ifwl_combobox.h" | 10 #include "xfa/fwl/core/ifwl_combobox.h" |
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
96 if (!pMessage) | 96 if (!pMessage) |
97 return; | 97 return; |
98 | 98 |
99 CFWL_MessageType dwHashCode = pMessage->GetClassID(); | 99 CFWL_MessageType dwHashCode = pMessage->GetClassID(); |
100 bool backDefault = true; | 100 bool backDefault = true; |
101 if (dwHashCode == CFWL_MessageType::SetFocus || | 101 if (dwHashCode == CFWL_MessageType::SetFocus || |
102 dwHashCode == CFWL_MessageType::KillFocus) { | 102 dwHashCode == CFWL_MessageType::KillFocus) { |
103 OnDropListFocusChanged(pMessage, dwHashCode == CFWL_MessageType::SetFocus); | 103 OnDropListFocusChanged(pMessage, dwHashCode == CFWL_MessageType::SetFocus); |
104 } else if (dwHashCode == CFWL_MessageType::Mouse) { | 104 } else if (dwHashCode == CFWL_MessageType::Mouse) { |
105 CFWL_MsgMouse* pMsg = static_cast<CFWL_MsgMouse*>(pMessage); | 105 CFWL_MsgMouse* pMsg = static_cast<CFWL_MsgMouse*>(pMessage); |
106 if (IsShowScrollBar(true) && m_pVertScrollBar) { | 106 IFWL_ScrollBar* vertSB = GetVertScrollBar(); |
| 107 if (IsShowScrollBar(true) && vertSB) { |
107 CFX_RectF rect; | 108 CFX_RectF rect; |
108 m_pVertScrollBar->GetWidgetRect(rect); | 109 vertSB->GetWidgetRect(rect); |
109 if (rect.Contains(pMsg->m_fx, pMsg->m_fy)) { | 110 if (rect.Contains(pMsg->m_fx, pMsg->m_fy)) { |
110 pMsg->m_fx -= rect.left; | 111 pMsg->m_fx -= rect.left; |
111 pMsg->m_fy -= rect.top; | 112 pMsg->m_fy -= rect.top; |
112 m_pVertScrollBar->GetDelegate()->OnProcessMessage(pMsg); | 113 vertSB->GetDelegate()->OnProcessMessage(pMsg); |
113 return; | 114 return; |
114 } | 115 } |
115 } | 116 } |
116 switch (pMsg->m_dwCmd) { | 117 switch (pMsg->m_dwCmd) { |
117 case FWL_MouseCommand::Move: { | 118 case FWL_MouseCommand::Move: { |
118 backDefault = false; | 119 backDefault = false; |
119 OnDropListMouseMove(pMsg); | 120 OnDropListMouseMove(pMsg); |
120 break; | 121 break; |
121 } | 122 } |
122 case FWL_MouseCommand::LeftButtonDown: { | 123 case FWL_MouseCommand::LeftButtonDown: { |
(...skipping 22 matching lines...) Expand all Loading... |
145 | 146 |
146 CFWL_MsgKillFocus* pKill = static_cast<CFWL_MsgKillFocus*>(pMsg); | 147 CFWL_MsgKillFocus* pKill = static_cast<CFWL_MsgKillFocus*>(pMsg); |
147 IFWL_ComboBox* pOuter = static_cast<IFWL_ComboBox*>(m_pOuter); | 148 IFWL_ComboBox* pOuter = static_cast<IFWL_ComboBox*>(m_pOuter); |
148 if (pKill->m_pSetFocus == m_pOuter || | 149 if (pKill->m_pSetFocus == m_pOuter || |
149 pKill->m_pSetFocus == pOuter->GetComboEdit()) { | 150 pKill->m_pSetFocus == pOuter->GetComboEdit()) { |
150 pOuter->ShowDropList(false); | 151 pOuter->ShowDropList(false); |
151 } | 152 } |
152 } | 153 } |
153 | 154 |
154 int32_t IFWL_ComboList::OnDropListMouseMove(CFWL_MsgMouse* pMsg) { | 155 int32_t IFWL_ComboList::OnDropListMouseMove(CFWL_MsgMouse* pMsg) { |
155 if (m_rtClient.Contains(pMsg->m_fx, pMsg->m_fy)) { | 156 if (GetRTClient().Contains(pMsg->m_fx, pMsg->m_fy)) { |
156 if (m_bNotifyOwner) { | 157 if (m_bNotifyOwner) { |
157 m_bNotifyOwner = false; | 158 m_bNotifyOwner = false; |
158 } | 159 } |
159 if (IsShowScrollBar(true) && m_pVertScrollBar) { | 160 IFWL_ScrollBar* vertSB = GetVertScrollBar(); |
| 161 if (IsShowScrollBar(true) && vertSB) { |
160 CFX_RectF rect; | 162 CFX_RectF rect; |
161 m_pVertScrollBar->GetWidgetRect(rect); | 163 vertSB->GetWidgetRect(rect); |
162 if (rect.Contains(pMsg->m_fx, pMsg->m_fy)) { | 164 if (rect.Contains(pMsg->m_fx, pMsg->m_fy)) { |
163 return 1; | 165 return 1; |
164 } | 166 } |
165 } | 167 } |
166 CFWL_ListItem* hItem = GetItemAtPoint(pMsg->m_fx, pMsg->m_fy); | 168 CFWL_ListItem* hItem = GetItemAtPoint(pMsg->m_fx, pMsg->m_fy); |
167 if (hItem) { | 169 if (hItem) { |
168 if (!m_pProperties->m_pDataProvider) | 170 if (!m_pProperties->m_pDataProvider) |
169 return 0; | 171 return 0; |
170 IFWL_ListBoxDP* pData = | 172 IFWL_ListBoxDP* pData = |
171 static_cast<IFWL_ListBoxDP*>(m_pProperties->m_pDataProvider); | 173 static_cast<IFWL_ListBoxDP*>(m_pProperties->m_pDataProvider); |
172 int32_t iSel = pData->GetItemIndex(this, hItem); | 174 int32_t iSel = pData->GetItemIndex(this, hItem); |
173 CFWL_EvtCmbHoverChanged event; | 175 CFWL_EvtCmbHoverChanged event; |
174 event.m_pSrcTarget = m_pOuter; | 176 event.m_pSrcTarget = m_pOuter; |
175 event.m_iCurHover = iSel; | 177 event.m_iCurHover = iSel; |
176 DispatchEvent(&event); | 178 DispatchEvent(&event); |
177 ChangeSelected(iSel); | 179 ChangeSelected(iSel); |
178 } | 180 } |
179 } else if (m_bNotifyOwner) { | 181 } else if (m_bNotifyOwner) { |
180 ClientToOuter(pMsg->m_fx, pMsg->m_fy); | 182 ClientToOuter(pMsg->m_fx, pMsg->m_fy); |
181 IFWL_ComboBox* pOuter = static_cast<IFWL_ComboBox*>(m_pOuter); | 183 IFWL_ComboBox* pOuter = static_cast<IFWL_ComboBox*>(m_pOuter); |
182 pOuter->GetDelegate()->OnProcessMessage(pMsg); | 184 pOuter->GetDelegate()->OnProcessMessage(pMsg); |
183 } | 185 } |
184 return 1; | 186 return 1; |
185 } | 187 } |
186 | 188 |
187 int32_t IFWL_ComboList::OnDropListLButtonDown(CFWL_MsgMouse* pMsg) { | 189 int32_t IFWL_ComboList::OnDropListLButtonDown(CFWL_MsgMouse* pMsg) { |
188 if (m_rtClient.Contains(pMsg->m_fx, pMsg->m_fy)) | 190 if (GetRTClient().Contains(pMsg->m_fx, pMsg->m_fy)) |
189 return 0; | 191 return 0; |
190 | 192 |
191 IFWL_ComboBox* pOuter = static_cast<IFWL_ComboBox*>(m_pOuter); | 193 IFWL_ComboBox* pOuter = static_cast<IFWL_ComboBox*>(m_pOuter); |
192 pOuter->ShowDropList(false); | 194 pOuter->ShowDropList(false); |
193 return 1; | 195 return 1; |
194 } | 196 } |
195 | 197 |
196 int32_t IFWL_ComboList::OnDropListLButtonUp(CFWL_MsgMouse* pMsg) { | 198 int32_t IFWL_ComboList::OnDropListLButtonUp(CFWL_MsgMouse* pMsg) { |
197 IFWL_ComboBox* pOuter = static_cast<IFWL_ComboBox*>(m_pOuter); | 199 IFWL_ComboBox* pOuter = static_cast<IFWL_ComboBox*>(m_pOuter); |
198 if (m_bNotifyOwner) { | 200 if (m_bNotifyOwner) { |
199 ClientToOuter(pMsg->m_fx, pMsg->m_fy); | 201 ClientToOuter(pMsg->m_fx, pMsg->m_fy); |
200 pOuter->GetDelegate()->OnProcessMessage(pMsg); | 202 pOuter->GetDelegate()->OnProcessMessage(pMsg); |
201 } else { | 203 } else { |
202 if (IsShowScrollBar(true) && m_pVertScrollBar) { | 204 IFWL_ScrollBar* vertSB = GetVertScrollBar(); |
| 205 if (IsShowScrollBar(true) && vertSB) { |
203 CFX_RectF rect; | 206 CFX_RectF rect; |
204 m_pVertScrollBar->GetWidgetRect(rect); | 207 vertSB->GetWidgetRect(rect); |
205 if (rect.Contains(pMsg->m_fx, pMsg->m_fy)) { | 208 if (rect.Contains(pMsg->m_fx, pMsg->m_fy)) { |
206 return 1; | 209 return 1; |
207 } | 210 } |
208 } | 211 } |
209 pOuter->ShowDropList(false); | 212 pOuter->ShowDropList(false); |
210 CFWL_ListItem* hItem = GetItemAtPoint(pMsg->m_fx, pMsg->m_fy); | 213 CFWL_ListItem* hItem = GetItemAtPoint(pMsg->m_fx, pMsg->m_fy); |
211 if (hItem) | 214 if (hItem) |
212 pOuter->ProcessSelChanged(true); | 215 pOuter->ProcessSelChanged(true); |
213 } | 216 } |
214 return 1; | 217 return 1; |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
265 CFX_RectF rtInvalidate; | 268 CFX_RectF rtInvalidate; |
266 rtInvalidate.Set(0, 0, m_pProperties->m_rtWidget.width, | 269 rtInvalidate.Set(0, 0, m_pProperties->m_rtWidget.width, |
267 m_pProperties->m_rtWidget.height); | 270 m_pProperties->m_rtWidget.height); |
268 Repaint(&rtInvalidate); | 271 Repaint(&rtInvalidate); |
269 break; | 272 break; |
270 } | 273 } |
271 default: | 274 default: |
272 break; | 275 break; |
273 } | 276 } |
274 } | 277 } |
OLD | NEW |