OLD | NEW |
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/ifwl_combobox.h" | 7 #include "xfa/fwl/core/ifwl_combobox.h" |
8 | 8 |
9 #include "third_party/base/ptr_util.h" | 9 #include "third_party/base/ptr_util.h" |
10 #include "xfa/fde/cfde_txtedtengine.h" | 10 #include "xfa/fde/cfde_txtedtengine.h" |
11 #include "xfa/fde/tto/fde_textout.h" | 11 #include "xfa/fde/tto/fde_textout.h" |
12 #include "xfa/fwl/core/cfwl_message.h" | 12 #include "xfa/fwl/core/cfwl_message.h" |
13 #include "xfa/fwl/core/cfwl_themebackground.h" | 13 #include "xfa/fwl/core/cfwl_themebackground.h" |
14 #include "xfa/fwl/core/cfwl_themepart.h" | 14 #include "xfa/fwl/core/cfwl_themepart.h" |
15 #include "xfa/fwl/core/cfwl_themetext.h" | 15 #include "xfa/fwl/core/cfwl_themetext.h" |
16 #include "xfa/fwl/core/cfwl_widgetmgr.h" | 16 #include "xfa/fwl/core/cfwl_widgetmgr.h" |
17 #include "xfa/fwl/core/fwl_noteimp.h" | 17 #include "xfa/fwl/core/fwl_noteimp.h" |
18 #include "xfa/fwl/core/ifwl_app.h" | 18 #include "xfa/fwl/core/ifwl_app.h" |
19 #include "xfa/fwl/core/ifwl_comboboxproxy.h" | 19 #include "xfa/fwl/core/ifwl_comboboxproxy.h" |
20 #include "xfa/fwl/core/ifwl_comboedit.h" | 20 #include "xfa/fwl/core/ifwl_comboedit.h" |
21 #include "xfa/fwl/core/ifwl_combolist.h" | |
22 #include "xfa/fwl/core/ifwl_formproxy.h" | 21 #include "xfa/fwl/core/ifwl_formproxy.h" |
23 #include "xfa/fwl/core/ifwl_themeprovider.h" | 22 #include "xfa/fwl/core/ifwl_themeprovider.h" |
24 | 23 |
25 IFWL_ComboBox::IFWL_ComboBox(const IFWL_App* app, | 24 IFWL_ComboBox::IFWL_ComboBox(const IFWL_App* app, |
26 std::unique_ptr<CFWL_WidgetProperties> properties) | 25 std::unique_ptr<CFWL_WidgetProperties> properties) |
27 : IFWL_Widget(app, std::move(properties), nullptr), | 26 : IFWL_Widget(app, std::move(properties), nullptr), |
28 m_pComboBoxProxy(nullptr), | 27 m_pComboBoxProxy(nullptr), |
29 m_bLButtonDown(false), | 28 m_bLButtonDown(false), |
30 m_iCurSel(-1), | 29 m_iCurSel(-1), |
31 m_iBtnState(CFWL_PartState_Normal), | 30 m_iBtnState(CFWL_PartState_Normal), |
32 m_fComboFormHandler(0), | 31 m_fComboFormHandler(0) { |
33 m_bNeedShowList(false) { | |
34 m_rtClient.Reset(); | 32 m_rtClient.Reset(); |
35 m_rtBtn.Reset(); | 33 m_rtBtn.Reset(); |
36 m_rtHandler.Reset(); | 34 m_rtHandler.Reset(); |
37 | 35 |
38 if (m_pWidgetMgr->IsFormDisabled()) { | 36 if (m_pWidgetMgr->IsFormDisabled()) { |
39 DisForm_InitComboList(); | 37 DisForm_InitComboList(); |
40 DisForm_InitComboEdit(); | 38 DisForm_InitComboEdit(); |
41 return; | 39 return; |
42 } | 40 } |
43 | 41 |
(...skipping 26 matching lines...) Expand all Loading... |
70 if (bAutoSize) { | 68 if (bAutoSize) { |
71 rect.Reset(); | 69 rect.Reset(); |
72 bool bIsDropDown = IsDropDownStyle(); | 70 bool bIsDropDown = IsDropDownStyle(); |
73 if (bIsDropDown && m_pEdit) { | 71 if (bIsDropDown && m_pEdit) { |
74 m_pEdit->GetWidgetRect(rect, true); | 72 m_pEdit->GetWidgetRect(rect, true); |
75 } else { | 73 } else { |
76 rect.width = 100; | 74 rect.width = 100; |
77 rect.height = 16; | 75 rect.height = 16; |
78 } | 76 } |
79 if (!m_pProperties->m_pThemeProvider) { | 77 if (!m_pProperties->m_pThemeProvider) { |
80 ReSetTheme(); | 78 ResetTheme(); |
81 } | 79 } |
82 FX_FLOAT* pFWidth = static_cast<FX_FLOAT*>( | 80 FX_FLOAT* pFWidth = static_cast<FX_FLOAT*>( |
83 GetThemeCapacity(CFWL_WidgetCapacity::ScrollBarWidth)); | 81 GetThemeCapacity(CFWL_WidgetCapacity::ScrollBarWidth)); |
84 if (!pFWidth) | 82 if (!pFWidth) |
85 return; | 83 return; |
86 rect.Inflate(0, 0, *pFWidth, 0); | 84 rect.Inflate(0, 0, *pFWidth, 0); |
87 IFWL_Widget::GetWidgetRect(rect, true); | 85 IFWL_Widget::GetWidgetRect(rect, true); |
88 } else { | 86 } else { |
89 rect = m_pProperties->m_rtWidget; | 87 rect = m_pProperties->m_rtWidget; |
90 } | 88 } |
(...skipping 19 matching lines...) Expand all Loading... |
110 } | 108 } |
111 | 109 |
112 void IFWL_ComboBox::Update() { | 110 void IFWL_ComboBox::Update() { |
113 if (m_pWidgetMgr->IsFormDisabled()) { | 111 if (m_pWidgetMgr->IsFormDisabled()) { |
114 DisForm_Update(); | 112 DisForm_Update(); |
115 return; | 113 return; |
116 } | 114 } |
117 if (IsLocked()) { | 115 if (IsLocked()) { |
118 return; | 116 return; |
119 } | 117 } |
120 ReSetTheme(); | 118 ResetTheme(); |
121 bool bDropDown = IsDropDownStyle(); | 119 bool bDropDown = IsDropDownStyle(); |
122 if (bDropDown && m_pEdit) { | 120 if (bDropDown && m_pEdit) { |
123 ReSetEditAlignment(); | 121 ResetEditAlignment(); |
124 } | 122 } |
125 if (!m_pProperties->m_pThemeProvider) { | 123 if (!m_pProperties->m_pThemeProvider) { |
126 m_pProperties->m_pThemeProvider = GetAvailableTheme(); | 124 m_pProperties->m_pThemeProvider = GetAvailableTheme(); |
127 } | 125 } |
128 Layout(); | 126 Layout(); |
129 CFWL_ThemePart part; | 127 CFWL_ThemePart part; |
130 part.m_pWidget = this; | 128 part.m_pWidget = this; |
131 m_fComboFormHandler = | 129 m_fComboFormHandler = |
132 *static_cast<FX_FLOAT*>(m_pProperties->m_pThemeProvider->GetCapacity( | 130 *static_cast<FX_FLOAT*>(m_pProperties->m_pThemeProvider->GetCapacity( |
133 &part, CFWL_WidgetCapacity::ComboFormHandler)); | 131 &part, CFWL_WidgetCapacity::ComboFormHandler)); |
(...skipping 29 matching lines...) Expand all Loading... |
163 rtTextBk.width -= m_rtBtn.width; | 161 rtTextBk.width -= m_rtBtn.width; |
164 CFWL_ThemeBackground param; | 162 CFWL_ThemeBackground param; |
165 param.m_pWidget = this; | 163 param.m_pWidget = this; |
166 param.m_iPart = CFWL_Part::Background; | 164 param.m_iPart = CFWL_Part::Background; |
167 param.m_pGraphics = pGraphics; | 165 param.m_pGraphics = pGraphics; |
168 if (pMatrix) { | 166 if (pMatrix) { |
169 param.m_matrix.Concat(*pMatrix); | 167 param.m_matrix.Concat(*pMatrix); |
170 } | 168 } |
171 param.m_rtPart = rtTextBk; | 169 param.m_rtPart = rtTextBk; |
172 if (m_iCurSel >= 0) { | 170 if (m_iCurSel >= 0) { |
173 IFWL_ListBoxDP* pData = static_cast<IFWL_ListBoxDP*>( | 171 IFWL_ListBoxDP* pData = |
174 m_pListBox->m_pProperties->m_pDataProvider); | 172 static_cast<IFWL_ListBoxDP*>(m_pListBox->GetDataProvider()); |
175 void* p = pData->GetItemData(m_pListBox.get(), | 173 void* p = pData->GetItemData(m_pListBox.get(), |
176 pData->GetItem(m_pListBox.get(), m_iCurSel)); | 174 pData->GetItem(m_pListBox.get(), m_iCurSel)); |
177 if (p) { | 175 if (p) { |
178 param.m_pData = p; | 176 param.m_pData = p; |
179 } | 177 } |
180 } | 178 } |
181 if (m_pProperties->m_dwStates & FWL_WGTSTATE_Disabled) { | 179 if (m_pProperties->m_dwStates & FWL_WGTSTATE_Disabled) { |
182 param.m_dwStates = CFWL_PartState_Disabled; | 180 param.m_dwStates = CFWL_PartState_Disabled; |
183 } else if ((m_pProperties->m_dwStates & FWL_WGTSTATE_Focused) && | 181 } else if ((m_pProperties->m_dwStates & FWL_WGTSTATE_Focused) && |
184 (m_iCurSel >= 0)) { | 182 (m_iCurSel >= 0)) { |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
228 void IFWL_ComboBox::SetThemeProvider(IFWL_ThemeProvider* pThemeProvider) { | 226 void IFWL_ComboBox::SetThemeProvider(IFWL_ThemeProvider* pThemeProvider) { |
229 if (!pThemeProvider) | 227 if (!pThemeProvider) |
230 return; | 228 return; |
231 m_pProperties->m_pThemeProvider = pThemeProvider; | 229 m_pProperties->m_pThemeProvider = pThemeProvider; |
232 if (m_pListBox) | 230 if (m_pListBox) |
233 m_pListBox->SetThemeProvider(pThemeProvider); | 231 m_pListBox->SetThemeProvider(pThemeProvider); |
234 if (m_pEdit) | 232 if (m_pEdit) |
235 m_pEdit->SetThemeProvider(pThemeProvider); | 233 m_pEdit->SetThemeProvider(pThemeProvider); |
236 } | 234 } |
237 | 235 |
238 int32_t IFWL_ComboBox::GetCurSel() { | 236 int32_t IFWL_ComboBox::GetCurSel() const { |
239 return m_iCurSel; | 237 return m_iCurSel; |
240 } | 238 } |
241 | 239 |
242 FWL_Error IFWL_ComboBox::SetCurSel(int32_t iSel) { | 240 void IFWL_ComboBox::SetCurSel(int32_t iSel) { |
243 int32_t iCount = m_pListBox->CountItems(); | 241 int32_t iCount = m_pListBox->CountItems(); |
244 bool bClearSel = iSel < 0 || iSel >= iCount; | 242 bool bClearSel = iSel < 0 || iSel >= iCount; |
245 bool bDropDown = IsDropDownStyle(); | 243 bool bDropDown = IsDropDownStyle(); |
246 if (bDropDown && m_pEdit) { | 244 if (bDropDown && m_pEdit) { |
247 if (bClearSel) { | 245 if (bClearSel) { |
248 m_pEdit->SetText(CFX_WideString()); | 246 m_pEdit->SetText(CFX_WideString()); |
249 } else { | 247 } else { |
250 CFX_WideString wsText; | 248 CFX_WideString wsText; |
251 IFWL_ComboBoxDP* pData = | 249 IFWL_ComboBoxDP* pData = |
252 static_cast<IFWL_ComboBoxDP*>(m_pProperties->m_pDataProvider); | 250 static_cast<IFWL_ComboBoxDP*>(m_pProperties->m_pDataProvider); |
253 CFWL_ListItem* hItem = pData->GetItem(this, iSel); | 251 CFWL_ListItem* hItem = pData->GetItem(this, iSel); |
254 m_pListBox->GetItemText(hItem, wsText); | 252 m_pListBox->GetItemText(hItem, wsText); |
255 m_pEdit->SetText(wsText); | 253 m_pEdit->SetText(wsText); |
256 } | 254 } |
257 m_pEdit->Update(); | 255 m_pEdit->Update(); |
258 } | 256 } |
259 m_iCurSel = bClearSel ? -1 : iSel; | 257 m_iCurSel = bClearSel ? -1 : iSel; |
260 return FWL_Error::Succeeded; | |
261 } | 258 } |
262 | 259 |
263 void IFWL_ComboBox::SetStates(uint32_t dwStates, bool bSet) { | 260 void IFWL_ComboBox::SetStates(uint32_t dwStates, bool bSet) { |
264 bool bIsDropDown = IsDropDownStyle(); | 261 bool bIsDropDown = IsDropDownStyle(); |
265 if (bIsDropDown && m_pEdit) | 262 if (bIsDropDown && m_pEdit) |
266 m_pEdit->SetStates(dwStates, bSet); | 263 m_pEdit->SetStates(dwStates, bSet); |
267 if (m_pListBox) | 264 if (m_pListBox) |
268 m_pListBox->SetStates(dwStates, bSet); | 265 m_pListBox->SetStates(dwStates, bSet); |
269 IFWL_Widget::SetStates(dwStates, bSet); | 266 IFWL_Widget::SetStates(dwStates, bSet); |
270 } | 267 } |
271 | 268 |
272 void IFWL_ComboBox::SetEditText(const CFX_WideString& wsText) { | 269 void IFWL_ComboBox::SetEditText(const CFX_WideString& wsText) { |
273 if (!m_pEdit) | 270 if (!m_pEdit) |
274 return; | 271 return; |
275 m_pEdit->SetText(wsText); | 272 m_pEdit->SetText(wsText); |
276 m_pEdit->Update(); | 273 m_pEdit->Update(); |
277 } | 274 } |
278 | 275 |
279 int32_t IFWL_ComboBox::GetEditTextLength() const { | 276 void IFWL_ComboBox::GetEditText(CFX_WideString& wsText, |
280 if (!m_pEdit) | 277 int32_t nStart, |
281 return -1; | 278 int32_t nCount) const { |
282 return m_pEdit->GetTextLength(); | 279 if (m_pEdit) { |
| 280 m_pEdit->GetText(wsText, nStart, nCount); |
| 281 return; |
| 282 } |
| 283 if (!m_pListBox) |
| 284 return; |
| 285 |
| 286 IFWL_ComboBoxDP* pData = |
| 287 static_cast<IFWL_ComboBoxDP*>(m_pProperties->m_pDataProvider); |
| 288 CFWL_ListItem* hItem = pData->GetItem(this, m_iCurSel); |
| 289 m_pListBox->GetItemText(hItem, wsText); |
283 } | 290 } |
284 | 291 |
285 FWL_Error IFWL_ComboBox::GetEditText(CFX_WideString& wsText, | 292 void IFWL_ComboBox::OpenDropDownList(bool bActivate) { |
286 int32_t nStart, | |
287 int32_t nCount) const { | |
288 if (m_pEdit) { | |
289 m_pEdit->GetText(wsText, nStart, nCount); | |
290 return FWL_Error::Succeeded; | |
291 } | |
292 if (m_pListBox) { | |
293 IFWL_ComboBoxDP* pData = | |
294 static_cast<IFWL_ComboBoxDP*>(m_pProperties->m_pDataProvider); | |
295 CFWL_ListItem* hItem = pData->GetItem(this, m_iCurSel); | |
296 m_pListBox->GetItemText(hItem, wsText); | |
297 return FWL_Error::Succeeded; | |
298 } | |
299 return FWL_Error::Indefinite; | |
300 } | |
301 | |
302 FWL_Error IFWL_ComboBox::SetEditSelRange(int32_t nStart, int32_t nCount) { | |
303 if (!m_pEdit) | |
304 return FWL_Error::Indefinite; | |
305 m_pEdit->ClearSelected(); | |
306 m_pEdit->AddSelRange(nStart, nCount); | |
307 return FWL_Error::Succeeded; | |
308 } | |
309 | |
310 int32_t IFWL_ComboBox::GetEditSelRange(int32_t nIndex, int32_t& nStart) { | |
311 if (!m_pEdit) | |
312 return -1; | |
313 return m_pEdit->GetSelRange(nIndex, nStart); | |
314 } | |
315 | |
316 int32_t IFWL_ComboBox::GetEditLimit() { | |
317 if (!m_pEdit) | |
318 return -1; | |
319 return m_pEdit->GetLimit(); | |
320 } | |
321 | |
322 FWL_Error IFWL_ComboBox::SetEditLimit(int32_t nLimit) { | |
323 if (!m_pEdit) | |
324 return FWL_Error::Indefinite; | |
325 m_pEdit->SetLimit(nLimit); | |
326 return FWL_Error::Succeeded; | |
327 } | |
328 | |
329 bool IFWL_ComboBox::EditRedo(const IFDE_TxtEdtDoRecord* pRecord) { | |
330 return m_pEdit && m_pEdit->Redo(pRecord); | |
331 } | |
332 | |
333 bool IFWL_ComboBox::EditUndo(const IFDE_TxtEdtDoRecord* pRecord) { | |
334 return m_pEdit && m_pEdit->Undo(pRecord); | |
335 } | |
336 | |
337 IFWL_ListBox* IFWL_ComboBox::GetListBoxt() { | |
338 return m_pListBox.get(); | |
339 } | |
340 | |
341 bool IFWL_ComboBox::AfterFocusShowDropList() { | |
342 if (!m_bNeedShowList) { | |
343 return false; | |
344 } | |
345 if (m_pEdit) { | |
346 MatchEditText(); | |
347 } | |
348 ShowDropList(true); | |
349 m_bNeedShowList = false; | |
350 return true; | |
351 } | |
352 | |
353 FWL_Error IFWL_ComboBox::OpenDropDownList(bool bActivate) { | |
354 ShowDropList(bActivate); | 293 ShowDropList(bActivate); |
355 return FWL_Error::Succeeded; | |
356 } | 294 } |
357 | 295 |
358 bool IFWL_ComboBox::EditCanUndo() { | 296 bool IFWL_ComboBox::EditCanUndo() { |
359 return m_pEdit->CanUndo(); | 297 return m_pEdit->CanUndo(); |
360 } | 298 } |
361 | 299 |
362 bool IFWL_ComboBox::EditCanRedo() { | 300 bool IFWL_ComboBox::EditCanRedo() { |
363 return m_pEdit->CanRedo(); | 301 return m_pEdit->CanRedo(); |
364 } | 302 } |
365 | 303 |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
406 bool IFWL_ComboBox::EditDelete() { | 344 bool IFWL_ComboBox::EditDelete() { |
407 m_pEdit->ClearText(); | 345 m_pEdit->ClearText(); |
408 return true; | 346 return true; |
409 } | 347 } |
410 | 348 |
411 bool IFWL_ComboBox::EditDeSelect() { | 349 bool IFWL_ComboBox::EditDeSelect() { |
412 m_pEdit->ClearSelections(); | 350 m_pEdit->ClearSelections(); |
413 return true; | 351 return true; |
414 } | 352 } |
415 | 353 |
416 FWL_Error IFWL_ComboBox::GetBBox(CFX_RectF& rect) { | 354 void IFWL_ComboBox::GetBBox(CFX_RectF& rect) { |
417 if (m_pWidgetMgr->IsFormDisabled()) { | 355 if (m_pWidgetMgr->IsFormDisabled()) { |
418 return DisForm_GetBBox(rect); | 356 DisForm_GetBBox(rect); |
| 357 return; |
419 } | 358 } |
420 rect = m_pProperties->m_rtWidget; | 359 rect = m_pProperties->m_rtWidget; |
421 if (m_pListBox && IsDropListShowed()) { | 360 if (m_pListBox && IsDropListVisible()) { |
422 CFX_RectF rtList; | 361 CFX_RectF rtList; |
423 m_pListBox->GetWidgetRect(rtList); | 362 m_pListBox->GetWidgetRect(rtList); |
424 rtList.Offset(rect.left, rect.top); | 363 rtList.Offset(rect.left, rect.top); |
425 rect.Union(rtList); | 364 rect.Union(rtList); |
426 } | 365 } |
427 return FWL_Error::Succeeded; | |
428 } | 366 } |
429 | 367 |
430 void IFWL_ComboBox::EditModifyStylesEx(uint32_t dwStylesExAdded, | 368 void IFWL_ComboBox::EditModifyStylesEx(uint32_t dwStylesExAdded, |
431 uint32_t dwStylesExRemoved) { | 369 uint32_t dwStylesExRemoved) { |
432 if (m_pEdit) | 370 if (m_pEdit) |
433 m_pEdit->ModifyStylesEx(dwStylesExAdded, dwStylesExRemoved); | 371 m_pEdit->ModifyStylesEx(dwStylesExAdded, dwStylesExRemoved); |
434 } | 372 } |
435 | 373 |
436 FX_FLOAT IFWL_ComboBox::GetListHeight() { | 374 FX_FLOAT IFWL_ComboBox::GetListHeight() { |
437 return static_cast<IFWL_ComboBoxDP*>(m_pProperties->m_pDataProvider) | 375 return static_cast<IFWL_ComboBoxDP*>(m_pProperties->m_pDataProvider) |
(...skipping 11 matching lines...) Expand all Loading... |
449 param.m_matrix.Concat(*pMatrix); | 387 param.m_matrix.Concat(*pMatrix); |
450 } | 388 } |
451 param.m_rtPart = m_rtHandler; | 389 param.m_rtPart = m_rtHandler; |
452 m_pProperties->m_pThemeProvider->DrawBackground(¶m); | 390 m_pProperties->m_pThemeProvider->DrawBackground(¶m); |
453 } | 391 } |
454 | 392 |
455 void IFWL_ComboBox::ShowDropList(bool bActivate) { | 393 void IFWL_ComboBox::ShowDropList(bool bActivate) { |
456 if (m_pWidgetMgr->IsFormDisabled()) | 394 if (m_pWidgetMgr->IsFormDisabled()) |
457 return DisForm_ShowDropList(bActivate); | 395 return DisForm_ShowDropList(bActivate); |
458 | 396 |
459 bool bDropList = IsDropListShowed(); | 397 bool bDropList = IsDropListVisible(); |
460 if (bDropList == bActivate) | 398 if (bDropList == bActivate) |
461 return; | 399 return; |
462 if (!m_pComboBoxProxy) | 400 if (!m_pComboBoxProxy) |
463 InitProxyForm(); | 401 InitProxyForm(); |
464 | 402 |
465 m_pComboBoxProxy->Reset(); | 403 m_pComboBoxProxy->Reset(); |
466 if (bActivate) { | 404 if (bActivate) { |
467 m_pListBox->ChangeSelected(m_iCurSel); | 405 m_pListBox->ChangeSelected(m_iCurSel); |
468 ReSetListItemAlignment(); | 406 ResetListItemAlignment(); |
469 uint32_t dwStyleAdd = m_pProperties->m_dwStyleExes & | 407 uint32_t dwStyleAdd = m_pProperties->m_dwStyleExes & |
470 (FWL_STYLEEXT_CMB_Sort | FWL_STYLEEXT_CMB_OwnerDraw); | 408 (FWL_STYLEEXT_CMB_Sort | FWL_STYLEEXT_CMB_OwnerDraw); |
471 m_pListBox->ModifyStylesEx(dwStyleAdd, 0); | 409 m_pListBox->ModifyStylesEx(dwStyleAdd, 0); |
472 m_pListBox->GetWidgetRect(m_rtList, true); | 410 m_pListBox->GetWidgetRect(m_rtList, true); |
473 FX_FLOAT fHeight = GetListHeight(); | 411 FX_FLOAT fHeight = GetListHeight(); |
474 if (fHeight > 0) { | 412 if (fHeight > 0) { |
475 if (m_rtList.height > GetListHeight()) { | 413 if (m_rtList.height > GetListHeight()) { |
476 m_rtList.height = GetListHeight(); | 414 m_rtList.height = GetListHeight(); |
477 m_pListBox->ModifyStyles(FWL_WGTSTYLE_VScroll, 0); | 415 m_pListBox->ModifyStyles(FWL_WGTSTYLE_VScroll, 0); |
478 } | 416 } |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
512 m_fItemHeight = m_pListBox->GetItemHeight(); | 450 m_fItemHeight = m_pListBox->GetItemHeight(); |
513 m_pListBox->SetFocus(true); | 451 m_pListBox->SetFocus(true); |
514 m_pComboBoxProxy->DoModal(); | 452 m_pComboBoxProxy->DoModal(); |
515 m_pListBox->SetFocus(false); | 453 m_pListBox->SetFocus(false); |
516 } else { | 454 } else { |
517 m_pComboBoxProxy->EndDoModal(); | 455 m_pComboBoxProxy->EndDoModal(); |
518 CFWL_EvtCmbCloseUp ev; | 456 CFWL_EvtCmbCloseUp ev; |
519 ev.m_pSrcTarget = this; | 457 ev.m_pSrcTarget = this; |
520 DispatchEvent(&ev); | 458 DispatchEvent(&ev); |
521 m_bLButtonDown = false; | 459 m_bLButtonDown = false; |
522 m_pListBox->m_bNotifyOwner = true; | 460 m_pListBox->SetNotifyOwner(true); |
523 SetFocus(true); | 461 SetFocus(true); |
524 } | 462 } |
525 } | 463 } |
526 | 464 |
527 bool IFWL_ComboBox::IsDropListShowed() { | 465 bool IFWL_ComboBox::IsDropListVisible() { |
528 return m_pComboBoxProxy && | 466 return m_pComboBoxProxy && |
529 !(m_pComboBoxProxy->GetStates() & FWL_WGTSTATE_Invisible); | 467 !(m_pComboBoxProxy->GetStates() & FWL_WGTSTATE_Invisible); |
530 } | 468 } |
531 | 469 |
532 bool IFWL_ComboBox::IsDropDownStyle() const { | |
533 return m_pProperties->m_dwStyleExes & FWL_STYLEEXT_CMB_DropDown; | |
534 } | |
535 | |
536 void IFWL_ComboBox::MatchEditText() { | 470 void IFWL_ComboBox::MatchEditText() { |
537 CFX_WideString wsText; | 471 CFX_WideString wsText; |
538 m_pEdit->GetText(wsText); | 472 m_pEdit->GetText(wsText); |
539 int32_t iMatch = m_pListBox->MatchItem(wsText); | 473 int32_t iMatch = m_pListBox->MatchItem(wsText); |
540 if (iMatch != m_iCurSel) { | 474 if (iMatch != m_iCurSel) { |
541 m_pListBox->ChangeSelected(iMatch); | 475 m_pListBox->ChangeSelected(iMatch); |
542 if (iMatch >= 0) { | 476 if (iMatch >= 0) { |
543 SynchrEditText(iMatch); | 477 SyncEditText(iMatch); |
544 } | 478 } |
545 } else if (iMatch >= 0) { | 479 } else if (iMatch >= 0) { |
546 m_pEdit->SetSelected(); | 480 m_pEdit->SetSelected(); |
547 } | 481 } |
548 m_iCurSel = iMatch; | 482 m_iCurSel = iMatch; |
549 } | 483 } |
550 | 484 |
551 void IFWL_ComboBox::SynchrEditText(int32_t iListItem) { | 485 void IFWL_ComboBox::SyncEditText(int32_t iListItem) { |
552 CFX_WideString wsText; | 486 CFX_WideString wsText; |
553 IFWL_ComboBoxDP* pData = | 487 IFWL_ComboBoxDP* pData = |
554 static_cast<IFWL_ComboBoxDP*>(m_pProperties->m_pDataProvider); | 488 static_cast<IFWL_ComboBoxDP*>(m_pProperties->m_pDataProvider); |
555 CFWL_ListItem* hItem = pData->GetItem(this, iListItem); | 489 CFWL_ListItem* hItem = pData->GetItem(this, iListItem); |
556 m_pListBox->GetItemText(hItem, wsText); | 490 m_pListBox->GetItemText(hItem, wsText); |
557 m_pEdit->SetText(wsText); | 491 m_pEdit->SetText(wsText); |
558 m_pEdit->Update(); | 492 m_pEdit->Update(); |
559 m_pEdit->SetSelected(); | 493 m_pEdit->SetSelected(); |
560 } | 494 } |
561 | 495 |
(...skipping 22 matching lines...) Expand all Loading... |
584 CFWL_ListItem* hItem = pData->GetItem(this, m_iCurSel); | 518 CFWL_ListItem* hItem = pData->GetItem(this, m_iCurSel); |
585 m_pListBox->GetItemText(hItem, wsText); | 519 m_pListBox->GetItemText(hItem, wsText); |
586 m_pEdit->LockUpdate(); | 520 m_pEdit->LockUpdate(); |
587 m_pEdit->SetText(wsText); | 521 m_pEdit->SetText(wsText); |
588 m_pEdit->UnlockUpdate(); | 522 m_pEdit->UnlockUpdate(); |
589 } | 523 } |
590 m_pEdit->Update(); | 524 m_pEdit->Update(); |
591 } | 525 } |
592 } | 526 } |
593 | 527 |
594 void IFWL_ComboBox::ReSetTheme() { | 528 void IFWL_ComboBox::ResetTheme() { |
595 IFWL_ThemeProvider* pTheme = m_pProperties->m_pThemeProvider; | 529 IFWL_ThemeProvider* pTheme = m_pProperties->m_pThemeProvider; |
596 if (!pTheme) { | 530 if (!pTheme) { |
597 pTheme = GetAvailableTheme(); | 531 pTheme = GetAvailableTheme(); |
598 m_pProperties->m_pThemeProvider = pTheme; | 532 m_pProperties->m_pThemeProvider = pTheme; |
599 } | 533 } |
600 if (m_pListBox && !m_pListBox->GetThemeProvider()) | 534 if (m_pListBox && !m_pListBox->GetThemeProvider()) |
601 m_pListBox->SetThemeProvider(pTheme); | 535 m_pListBox->SetThemeProvider(pTheme); |
602 if (m_pEdit && !m_pEdit->GetThemeProvider()) | 536 if (m_pEdit && !m_pEdit->GetThemeProvider()) |
603 m_pEdit->SetThemeProvider(pTheme); | 537 m_pEdit->SetThemeProvider(pTheme); |
604 } | 538 } |
605 | 539 |
606 void IFWL_ComboBox::ReSetEditAlignment() { | 540 void IFWL_ComboBox::ResetEditAlignment() { |
607 if (!m_pEdit) | 541 if (!m_pEdit) |
608 return; | 542 return; |
609 uint32_t dwStylExes = m_pProperties->m_dwStyleExes; | 543 uint32_t dwStylExes = m_pProperties->m_dwStyleExes; |
610 uint32_t dwAdd = 0; | 544 uint32_t dwAdd = 0; |
611 switch (dwStylExes & FWL_STYLEEXT_CMB_EditHAlignMask) { | 545 switch (dwStylExes & FWL_STYLEEXT_CMB_EditHAlignMask) { |
612 case FWL_STYLEEXT_CMB_EditHCenter: { | 546 case FWL_STYLEEXT_CMB_EditHCenter: { |
613 dwAdd |= FWL_STYLEEXT_EDT_HCenter; | 547 dwAdd |= FWL_STYLEEXT_EDT_HCenter; |
614 break; | 548 break; |
615 } | 549 } |
616 case FWL_STYLEEXT_CMB_EditHFar: { | 550 case FWL_STYLEEXT_CMB_EditHFar: { |
(...skipping 17 matching lines...) Expand all Loading... |
634 dwAdd |= FWL_STYLEEXT_EDT_Justified; | 568 dwAdd |= FWL_STYLEEXT_EDT_Justified; |
635 } | 569 } |
636 if (dwStylExes & FWL_STYLEEXT_CMB_EditDistributed) { | 570 if (dwStylExes & FWL_STYLEEXT_CMB_EditDistributed) { |
637 dwAdd |= FWL_STYLEEXT_EDT_Distributed; | 571 dwAdd |= FWL_STYLEEXT_EDT_Distributed; |
638 } | 572 } |
639 m_pEdit->ModifyStylesEx(dwAdd, FWL_STYLEEXT_EDT_HAlignMask | | 573 m_pEdit->ModifyStylesEx(dwAdd, FWL_STYLEEXT_EDT_HAlignMask | |
640 FWL_STYLEEXT_EDT_HAlignModeMask | | 574 FWL_STYLEEXT_EDT_HAlignModeMask | |
641 FWL_STYLEEXT_EDT_VAlignMask); | 575 FWL_STYLEEXT_EDT_VAlignMask); |
642 } | 576 } |
643 | 577 |
644 void IFWL_ComboBox::ReSetListItemAlignment() { | 578 void IFWL_ComboBox::ResetListItemAlignment() { |
645 if (!m_pListBox) | 579 if (!m_pListBox) |
646 return; | 580 return; |
647 uint32_t dwStylExes = m_pProperties->m_dwStyleExes; | 581 uint32_t dwStylExes = m_pProperties->m_dwStyleExes; |
648 uint32_t dwAdd = 0; | 582 uint32_t dwAdd = 0; |
649 switch (dwStylExes & FWL_STYLEEXT_CMB_ListItemAlignMask) { | 583 switch (dwStylExes & FWL_STYLEEXT_CMB_ListItemAlignMask) { |
650 case FWL_STYLEEXT_CMB_ListItemCenterAlign: { | 584 case FWL_STYLEEXT_CMB_ListItemCenterAlign: { |
651 dwAdd |= FWL_STYLEEXT_LTB_CenterAlign; | 585 dwAdd |= FWL_STYLEEXT_LTB_CenterAlign; |
652 } | 586 } |
653 case FWL_STYLEEXT_CMB_ListItemRightAlign: { | 587 case FWL_STYLEEXT_CMB_ListItemRightAlign: { |
654 dwAdd |= FWL_STYLEEXT_LTB_RightAlign; | 588 dwAdd |= FWL_STYLEEXT_LTB_RightAlign; |
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
720 return; | 654 return; |
721 | 655 |
722 auto prop = pdfium::MakeUnique<CFWL_WidgetProperties>(); | 656 auto prop = pdfium::MakeUnique<CFWL_WidgetProperties>(); |
723 prop->m_pParent = this; | 657 prop->m_pParent = this; |
724 prop->m_pThemeProvider = m_pProperties->m_pThemeProvider; | 658 prop->m_pThemeProvider = m_pProperties->m_pThemeProvider; |
725 m_pEdit.reset(new IFWL_ComboEdit(m_pOwnerApp, std::move(prop), this)); | 659 m_pEdit.reset(new IFWL_ComboEdit(m_pOwnerApp, std::move(prop), this)); |
726 m_pEdit->SetOuter(this); | 660 m_pEdit->SetOuter(this); |
727 } | 661 } |
728 | 662 |
729 void IFWL_ComboBox::DisForm_ShowDropList(bool bActivate) { | 663 void IFWL_ComboBox::DisForm_ShowDropList(bool bActivate) { |
730 bool bDropList = DisForm_IsDropListShowed(); | 664 bool bDropList = DisForm_IsDropListVisible(); |
731 if (bDropList == bActivate) { | 665 if (bDropList == bActivate) { |
732 return; | 666 return; |
733 } | 667 } |
734 if (bActivate) { | 668 if (bActivate) { |
735 CFWL_EvtCmbPreDropDown preEvent; | 669 CFWL_EvtCmbPreDropDown preEvent; |
736 preEvent.m_pSrcTarget = this; | 670 preEvent.m_pSrcTarget = this; |
737 DispatchEvent(&preEvent); | 671 DispatchEvent(&preEvent); |
738 IFWL_ComboList* pComboList = m_pListBox.get(); | 672 IFWL_ComboList* pComboList = m_pListBox.get(); |
739 int32_t iItems = pComboList->CountItems(); | 673 int32_t iItems = pComboList->CountItems(); |
740 if (iItems < 1) { | 674 if (iItems < 1) { |
741 return; | 675 return; |
742 } | 676 } |
743 ReSetListItemAlignment(); | 677 ResetListItemAlignment(); |
744 pComboList->ChangeSelected(m_iCurSel); | 678 pComboList->ChangeSelected(m_iCurSel); |
745 FX_FLOAT fItemHeight = pComboList->CalcItemHeight(); | 679 FX_FLOAT fItemHeight = pComboList->CalcItemHeight(); |
746 FX_FLOAT fBorder = GetBorderSize(); | 680 FX_FLOAT fBorder = GetBorderSize(); |
747 FX_FLOAT fPopupMin = 0.0f; | 681 FX_FLOAT fPopupMin = 0.0f; |
748 if (iItems > 3) { | 682 if (iItems > 3) { |
749 fPopupMin = fItemHeight * 3 + fBorder * 2; | 683 fPopupMin = fItemHeight * 3 + fBorder * 2; |
750 } | 684 } |
751 FX_FLOAT fPopupMax = fItemHeight * iItems + fBorder * 2; | 685 FX_FLOAT fPopupMax = fItemHeight * iItems + fBorder * 2; |
752 CFX_RectF rtList; | 686 CFX_RectF rtList; |
753 rtList.left = m_rtClient.left; | 687 rtList.left = m_rtClient.left; |
(...skipping 11 matching lines...) Expand all Loading... |
765 CFWL_EvtCmbPostDropDown postEvent; | 699 CFWL_EvtCmbPostDropDown postEvent; |
766 postEvent.m_pSrcTarget = this; | 700 postEvent.m_pSrcTarget = this; |
767 DispatchEvent(&postEvent); | 701 DispatchEvent(&postEvent); |
768 } | 702 } |
769 CFX_RectF rect; | 703 CFX_RectF rect; |
770 m_pListBox->GetWidgetRect(rect); | 704 m_pListBox->GetWidgetRect(rect); |
771 rect.Inflate(2, 2); | 705 rect.Inflate(2, 2); |
772 Repaint(&rect); | 706 Repaint(&rect); |
773 } | 707 } |
774 | 708 |
775 bool IFWL_ComboBox::DisForm_IsDropListShowed() { | |
776 return !(m_pListBox->GetStates() & FWL_WGTSTATE_Invisible); | |
777 } | |
778 | |
779 void IFWL_ComboBox::DisForm_ModifyStylesEx(uint32_t dwStylesExAdded, | 709 void IFWL_ComboBox::DisForm_ModifyStylesEx(uint32_t dwStylesExAdded, |
780 uint32_t dwStylesExRemoved) { | 710 uint32_t dwStylesExRemoved) { |
781 if (!m_pEdit) | 711 if (!m_pEdit) |
782 DisForm_InitComboEdit(); | 712 DisForm_InitComboEdit(); |
783 | 713 |
784 bool bAddDropDown = !!(dwStylesExAdded & FWL_STYLEEXT_CMB_DropDown); | 714 bool bAddDropDown = !!(dwStylesExAdded & FWL_STYLEEXT_CMB_DropDown); |
785 bool bDelDropDown = !!(dwStylesExRemoved & FWL_STYLEEXT_CMB_DropDown); | 715 bool bDelDropDown = !!(dwStylesExRemoved & FWL_STYLEEXT_CMB_DropDown); |
786 dwStylesExRemoved &= ~FWL_STYLEEXT_CMB_DropDown; | 716 dwStylesExRemoved &= ~FWL_STYLEEXT_CMB_DropDown; |
787 m_pProperties->m_dwStyleExes |= FWL_STYLEEXT_CMB_DropDown; | 717 m_pProperties->m_dwStyleExes |= FWL_STYLEEXT_CMB_DropDown; |
788 if (bAddDropDown) { | 718 if (bAddDropDown) { |
789 m_pEdit->ModifyStylesEx(0, FWL_STYLEEXT_EDT_ReadOnly); | 719 m_pEdit->ModifyStylesEx(0, FWL_STYLEEXT_EDT_ReadOnly); |
790 } else if (bDelDropDown) { | 720 } else if (bDelDropDown) { |
791 m_pEdit->ModifyStylesEx(FWL_STYLEEXT_EDT_ReadOnly, 0); | 721 m_pEdit->ModifyStylesEx(FWL_STYLEEXT_EDT_ReadOnly, 0); |
792 } | 722 } |
793 IFWL_Widget::ModifyStylesEx(dwStylesExAdded, dwStylesExRemoved); | 723 IFWL_Widget::ModifyStylesEx(dwStylesExAdded, dwStylesExRemoved); |
794 } | 724 } |
795 | 725 |
796 void IFWL_ComboBox::DisForm_Update() { | 726 void IFWL_ComboBox::DisForm_Update() { |
797 if (m_iLock) { | 727 if (m_iLock) { |
798 return; | 728 return; |
799 } | 729 } |
800 if (m_pEdit) { | 730 if (m_pEdit) { |
801 ReSetEditAlignment(); | 731 ResetEditAlignment(); |
802 } | 732 } |
803 ReSetTheme(); | 733 ResetTheme(); |
804 Layout(); | 734 Layout(); |
805 } | 735 } |
806 | 736 |
807 FWL_WidgetHit IFWL_ComboBox::DisForm_HitTest(FX_FLOAT fx, FX_FLOAT fy) { | 737 FWL_WidgetHit IFWL_ComboBox::DisForm_HitTest(FX_FLOAT fx, FX_FLOAT fy) { |
808 CFX_RectF rect; | 738 CFX_RectF rect; |
809 rect.Set(0, 0, m_pProperties->m_rtWidget.width - m_rtBtn.width, | 739 rect.Set(0, 0, m_pProperties->m_rtWidget.width - m_rtBtn.width, |
810 m_pProperties->m_rtWidget.height); | 740 m_pProperties->m_rtWidget.height); |
811 if (rect.Contains(fx, fy)) | 741 if (rect.Contains(fx, fy)) |
812 return FWL_WidgetHit::Edit; | 742 return FWL_WidgetHit::Edit; |
813 if (m_rtBtn.Contains(fx, fy)) | 743 if (m_rtBtn.Contains(fx, fy)) |
814 return FWL_WidgetHit::Client; | 744 return FWL_WidgetHit::Client; |
815 if (DisForm_IsDropListShowed()) { | 745 if (DisForm_IsDropListVisible()) { |
816 m_pListBox->GetWidgetRect(rect); | 746 m_pListBox->GetWidgetRect(rect); |
817 if (rect.Contains(fx, fy)) | 747 if (rect.Contains(fx, fy)) |
818 return FWL_WidgetHit::Client; | 748 return FWL_WidgetHit::Client; |
819 } | 749 } |
820 return FWL_WidgetHit::Unknown; | 750 return FWL_WidgetHit::Unknown; |
821 } | 751 } |
822 | 752 |
823 void IFWL_ComboBox::DisForm_DrawWidget(CFX_Graphics* pGraphics, | 753 void IFWL_ComboBox::DisForm_DrawWidget(CFX_Graphics* pGraphics, |
824 const CFX_Matrix* pMatrix) { | 754 const CFX_Matrix* pMatrix) { |
825 IFWL_ThemeProvider* pTheme = m_pProperties->m_pThemeProvider; | 755 IFWL_ThemeProvider* pTheme = m_pProperties->m_pThemeProvider; |
826 CFX_Matrix mtOrg; | 756 CFX_Matrix mtOrg; |
827 mtOrg.Set(1, 0, 0, 1, 0, 0); | 757 mtOrg.Set(1, 0, 0, 1, 0, 0); |
828 if (pMatrix) { | 758 if (pMatrix) { |
829 mtOrg = *pMatrix; | 759 mtOrg = *pMatrix; |
830 } | 760 } |
831 bool bListShowed = m_pListBox && DisForm_IsDropListShowed(); | 761 bool bListShowed = m_pListBox && DisForm_IsDropListVisible(); |
832 pGraphics->SaveGraphState(); | 762 pGraphics->SaveGraphState(); |
833 pGraphics->ConcatMatrix(&mtOrg); | 763 pGraphics->ConcatMatrix(&mtOrg); |
834 if (!m_rtBtn.IsEmpty(0.1f)) { | 764 if (!m_rtBtn.IsEmpty(0.1f)) { |
835 CFWL_ThemeBackground param; | 765 CFWL_ThemeBackground param; |
836 param.m_pWidget = this; | 766 param.m_pWidget = this; |
837 param.m_iPart = CFWL_Part::DropDownButton; | 767 param.m_iPart = CFWL_Part::DropDownButton; |
838 param.m_dwStates = m_iBtnState; | 768 param.m_dwStates = m_iBtnState; |
839 param.m_pGraphics = pGraphics; | 769 param.m_pGraphics = pGraphics; |
840 param.m_rtPart = m_rtBtn; | 770 param.m_rtPart = m_rtBtn; |
841 pTheme->DrawBackground(¶m); | 771 pTheme->DrawBackground(¶m); |
(...skipping 10 matching lines...) Expand all Loading... |
852 if (bListShowed) { | 782 if (bListShowed) { |
853 CFX_RectF rtList; | 783 CFX_RectF rtList; |
854 m_pListBox->GetWidgetRect(rtList); | 784 m_pListBox->GetWidgetRect(rtList); |
855 CFX_Matrix mt; | 785 CFX_Matrix mt; |
856 mt.Set(1, 0, 0, 1, rtList.left, rtList.top); | 786 mt.Set(1, 0, 0, 1, rtList.left, rtList.top); |
857 mt.Concat(mtOrg); | 787 mt.Concat(mtOrg); |
858 m_pListBox->DrawWidget(pGraphics, &mt); | 788 m_pListBox->DrawWidget(pGraphics, &mt); |
859 } | 789 } |
860 } | 790 } |
861 | 791 |
862 FWL_Error IFWL_ComboBox::DisForm_GetBBox(CFX_RectF& rect) { | 792 void IFWL_ComboBox::DisForm_GetBBox(CFX_RectF& rect) { |
863 rect = m_pProperties->m_rtWidget; | 793 rect = m_pProperties->m_rtWidget; |
864 if (m_pListBox && DisForm_IsDropListShowed()) { | 794 if (m_pListBox && DisForm_IsDropListVisible()) { |
865 CFX_RectF rtList; | 795 CFX_RectF rtList; |
866 m_pListBox->GetWidgetRect(rtList); | 796 m_pListBox->GetWidgetRect(rtList); |
867 rtList.Offset(rect.left, rect.top); | 797 rtList.Offset(rect.left, rect.top); |
868 rect.Union(rtList); | 798 rect.Union(rtList); |
869 } | 799 } |
870 return FWL_Error::Succeeded; | |
871 } | 800 } |
872 | 801 |
873 void IFWL_ComboBox::DisForm_Layout() { | 802 void IFWL_ComboBox::DisForm_Layout() { |
874 GetClientRect(m_rtClient); | 803 GetClientRect(m_rtClient); |
875 m_rtContent = m_rtClient; | 804 m_rtContent = m_rtClient; |
876 FX_FLOAT* pFWidth = static_cast<FX_FLOAT*>( | 805 FX_FLOAT* pFWidth = static_cast<FX_FLOAT*>( |
877 GetThemeCapacity(CFWL_WidgetCapacity::ScrollBarWidth)); | 806 GetThemeCapacity(CFWL_WidgetCapacity::ScrollBarWidth)); |
878 if (!pFWidth) | 807 if (!pFWidth) |
879 return; | 808 return; |
880 FX_FLOAT borderWidth = 1; | 809 FX_FLOAT borderWidth = 1; |
(...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1055 m_iBtnState = CFWL_PartState_Normal; | 984 m_iBtnState = CFWL_PartState_Normal; |
1056 } | 985 } |
1057 if ((iOldState != m_iBtnState) && | 986 if ((iOldState != m_iBtnState) && |
1058 !((m_pProperties->m_dwStates & FWL_WGTSTATE_Disabled) == | 987 !((m_pProperties->m_dwStates & FWL_WGTSTATE_Disabled) == |
1059 FWL_WGTSTATE_Disabled)) { | 988 FWL_WGTSTATE_Disabled)) { |
1060 Repaint(&m_rtBtn); | 989 Repaint(&m_rtBtn); |
1061 } | 990 } |
1062 } | 991 } |
1063 | 992 |
1064 void IFWL_ComboBox::OnMouseLeave(CFWL_MsgMouse* pMsg) { | 993 void IFWL_ComboBox::OnMouseLeave(CFWL_MsgMouse* pMsg) { |
1065 if (!IsDropListShowed() && | 994 if (!IsDropListVisible() && |
1066 !((m_pProperties->m_dwStates & FWL_WGTSTATE_Disabled) == | 995 !((m_pProperties->m_dwStates & FWL_WGTSTATE_Disabled) == |
1067 FWL_WGTSTATE_Disabled)) { | 996 FWL_WGTSTATE_Disabled)) { |
1068 m_iBtnState = CFWL_PartState_Normal; | 997 m_iBtnState = CFWL_PartState_Normal; |
1069 Repaint(&m_rtBtn); | 998 Repaint(&m_rtBtn); |
1070 } | 999 } |
1071 } | 1000 } |
1072 | 1001 |
1073 void IFWL_ComboBox::OnKey(CFWL_MsgKey* pMsg) { | 1002 void IFWL_ComboBox::OnKey(CFWL_MsgKey* pMsg) { |
1074 uint32_t dwKeyCode = pMsg->m_dwKeyCode; | 1003 uint32_t dwKeyCode = pMsg->m_dwKeyCode; |
1075 if (dwKeyCode == FWL_VKEY_Tab) { | 1004 if (dwKeyCode == FWL_VKEY_Tab) { |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1110 } else if (!bDropDown || bMatchEqual) { | 1039 } else if (!bDropDown || bMatchEqual) { |
1111 if ((bUp && iCurSel == 0) || (bDown && iCurSel == iCount - 1)) | 1040 if ((bUp && iCurSel == 0) || (bDown && iCurSel == iCount - 1)) |
1112 return; | 1041 return; |
1113 if (bUp) | 1042 if (bUp) |
1114 iCurSel--; | 1043 iCurSel--; |
1115 else | 1044 else |
1116 iCurSel++; | 1045 iCurSel++; |
1117 } | 1046 } |
1118 m_iCurSel = iCurSel; | 1047 m_iCurSel = iCurSel; |
1119 if (bDropDown && m_pEdit) | 1048 if (bDropDown && m_pEdit) |
1120 SynchrEditText(m_iCurSel); | 1049 SyncEditText(m_iCurSel); |
1121 else | 1050 else |
1122 Repaint(&m_rtClient); | 1051 Repaint(&m_rtClient); |
1123 return; | 1052 return; |
1124 } | 1053 } |
1125 | 1054 |
1126 bool bDropDown = IsDropDownStyle(); | 1055 bool bDropDown = IsDropDownStyle(); |
1127 if (bDropDown) | 1056 if (bDropDown) |
1128 m_pEdit->GetDelegate()->OnProcessMessage(pMsg); | 1057 m_pEdit->GetDelegate()->OnProcessMessage(pMsg); |
1129 } | 1058 } |
1130 | 1059 |
(...skipping 26 matching lines...) Expand all Loading... |
1157 default: | 1086 default: |
1158 break; | 1087 break; |
1159 } | 1088 } |
1160 break; | 1089 break; |
1161 } | 1090 } |
1162 case CFWL_MessageType::Key: { | 1091 case CFWL_MessageType::Key: { |
1163 backDefault = false; | 1092 backDefault = false; |
1164 CFWL_MsgKey* pKey = static_cast<CFWL_MsgKey*>(pMessage); | 1093 CFWL_MsgKey* pKey = static_cast<CFWL_MsgKey*>(pMessage); |
1165 if (pKey->m_dwCmd == FWL_KeyCommand::KeyUp) | 1094 if (pKey->m_dwCmd == FWL_KeyCommand::KeyUp) |
1166 break; | 1095 break; |
1167 if (DisForm_IsDropListShowed() && | 1096 if (DisForm_IsDropListVisible() && |
1168 pKey->m_dwCmd == FWL_KeyCommand::KeyDown) { | 1097 pKey->m_dwCmd == FWL_KeyCommand::KeyDown) { |
1169 bool bListKey = pKey->m_dwKeyCode == FWL_VKEY_Up || | 1098 bool bListKey = pKey->m_dwKeyCode == FWL_VKEY_Up || |
1170 pKey->m_dwKeyCode == FWL_VKEY_Down || | 1099 pKey->m_dwKeyCode == FWL_VKEY_Down || |
1171 pKey->m_dwKeyCode == FWL_VKEY_Return || | 1100 pKey->m_dwKeyCode == FWL_VKEY_Return || |
1172 pKey->m_dwKeyCode == FWL_VKEY_Escape; | 1101 pKey->m_dwKeyCode == FWL_VKEY_Escape; |
1173 if (bListKey) { | 1102 if (bListKey) { |
1174 m_pListBox->GetDelegate()->OnProcessMessage(pMessage); | 1103 m_pListBox->GetDelegate()->OnProcessMessage(pMessage); |
1175 break; | 1104 break; |
1176 } | 1105 } |
1177 } | 1106 } |
1178 DisForm_OnKey(pKey); | 1107 DisForm_OnKey(pKey); |
1179 break; | 1108 break; |
1180 } | 1109 } |
1181 default: | 1110 default: |
1182 break; | 1111 break; |
1183 } | 1112 } |
1184 if (backDefault) | 1113 if (backDefault) |
1185 IFWL_Widget::OnProcessMessage(pMessage); | 1114 IFWL_Widget::OnProcessMessage(pMessage); |
1186 } | 1115 } |
1187 | 1116 |
1188 void IFWL_ComboBox::DisForm_OnLButtonDown(CFWL_MsgMouse* pMsg) { | 1117 void IFWL_ComboBox::DisForm_OnLButtonDown(CFWL_MsgMouse* pMsg) { |
1189 bool bDropDown = DisForm_IsDropListShowed(); | 1118 bool bDropDown = DisForm_IsDropListVisible(); |
1190 CFX_RectF& rtBtn = bDropDown ? m_rtBtn : m_rtClient; | 1119 CFX_RectF& rtBtn = bDropDown ? m_rtBtn : m_rtClient; |
1191 if (!rtBtn.Contains(pMsg->m_fx, pMsg->m_fy)) | 1120 if (!rtBtn.Contains(pMsg->m_fx, pMsg->m_fy)) |
1192 return; | 1121 return; |
1193 | 1122 |
1194 if (DisForm_IsDropListShowed()) { | 1123 if (DisForm_IsDropListVisible()) { |
1195 DisForm_ShowDropList(false); | 1124 DisForm_ShowDropList(false); |
1196 return; | 1125 return; |
1197 } | 1126 } |
1198 if (m_pEdit) | 1127 if (m_pEdit) |
1199 MatchEditText(); | 1128 MatchEditText(); |
1200 DisForm_ShowDropList(true); | 1129 DisForm_ShowDropList(true); |
1201 } | 1130 } |
1202 | 1131 |
1203 void IFWL_ComboBox::DisForm_OnFocusChanged(CFWL_Message* pMsg, bool bSet) { | 1132 void IFWL_ComboBox::DisForm_OnFocusChanged(CFWL_Message* pMsg, bool bSet) { |
1204 if (bSet) { | 1133 if (bSet) { |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1246 iCurSel = 0; | 1175 iCurSel = 0; |
1247 } else if (bMatchEqual) { | 1176 } else if (bMatchEqual) { |
1248 if ((bUp && iCurSel == 0) || (bDown && iCurSel == iCount - 1)) | 1177 if ((bUp && iCurSel == 0) || (bDown && iCurSel == iCount - 1)) |
1249 return; | 1178 return; |
1250 if (bUp) | 1179 if (bUp) |
1251 iCurSel--; | 1180 iCurSel--; |
1252 else | 1181 else |
1253 iCurSel++; | 1182 iCurSel++; |
1254 } | 1183 } |
1255 m_iCurSel = iCurSel; | 1184 m_iCurSel = iCurSel; |
1256 SynchrEditText(m_iCurSel); | 1185 SyncEditText(m_iCurSel); |
1257 return; | 1186 return; |
1258 } | 1187 } |
1259 if (m_pEdit) | 1188 if (m_pEdit) |
1260 m_pEdit->GetDelegate()->OnProcessMessage(pMsg); | 1189 m_pEdit->GetDelegate()->OnProcessMessage(pMsg); |
1261 } | 1190 } |
OLD | NEW |