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

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

Issue 2467203003: Remove FX_BOOL from xfa. (Closed)
Patch Set: 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_combobox.h ('k') | xfa/fwl/core/ifwl_comboboxproxy.h » ('j') | 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/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" 21 #include "xfa/fwl/core/ifwl_combolist.h"
22 #include "xfa/fwl/core/ifwl_formproxy.h" 22 #include "xfa/fwl/core/ifwl_formproxy.h"
23 #include "xfa/fwl/core/ifwl_themeprovider.h" 23 #include "xfa/fwl/core/ifwl_themeprovider.h"
24 24
25 IFWL_ComboBox::IFWL_ComboBox(const IFWL_App* app, 25 IFWL_ComboBox::IFWL_ComboBox(const IFWL_App* app,
26 const CFWL_WidgetImpProperties& properties) 26 const CFWL_WidgetImpProperties& properties)
27 : IFWL_Widget(app, properties, nullptr), 27 : IFWL_Widget(app, properties, nullptr),
28 m_pComboBoxProxy(nullptr), 28 m_pComboBoxProxy(nullptr),
29 m_bLButtonDown(FALSE), 29 m_bLButtonDown(false),
30 m_iCurSel(-1), 30 m_iCurSel(-1),
31 m_iBtnState(CFWL_PartState_Normal), 31 m_iBtnState(CFWL_PartState_Normal),
32 m_fComboFormHandler(0), 32 m_fComboFormHandler(0),
33 m_bNeedShowList(FALSE) { 33 m_bNeedShowList(false) {
34 m_rtClient.Reset(); 34 m_rtClient.Reset();
35 m_rtBtn.Reset(); 35 m_rtBtn.Reset();
36 m_rtHandler.Reset(); 36 m_rtHandler.Reset();
37 37
38 if (m_pWidgetMgr->IsFormDisabled()) { 38 if (m_pWidgetMgr->IsFormDisabled()) {
39 DisForm_InitComboList(); 39 DisForm_InitComboList();
40 DisForm_InitComboEdit(); 40 DisForm_InitComboEdit();
41 return; 41 return;
42 } 42 }
43 43
(...skipping 15 matching lines...) Expand all
59 59
60 SetStates(m_pProperties->m_dwStates); 60 SetStates(m_pProperties->m_dwStates);
61 } 61 }
62 62
63 IFWL_ComboBox::~IFWL_ComboBox() {} 63 IFWL_ComboBox::~IFWL_ComboBox() {}
64 64
65 FWL_Type IFWL_ComboBox::GetClassID() const { 65 FWL_Type IFWL_ComboBox::GetClassID() const {
66 return FWL_Type::ComboBox; 66 return FWL_Type::ComboBox;
67 } 67 }
68 68
69 FWL_Error IFWL_ComboBox::GetWidgetRect(CFX_RectF& rect, FX_BOOL bAutoSize) { 69 FWL_Error IFWL_ComboBox::GetWidgetRect(CFX_RectF& rect, bool bAutoSize) {
70 if (bAutoSize) { 70 if (bAutoSize) {
71 rect.Reset(); 71 rect.Reset();
72 FX_BOOL bIsDropDown = IsDropDownStyle(); 72 bool bIsDropDown = IsDropDownStyle();
73 if (bIsDropDown && m_pEdit) { 73 if (bIsDropDown && m_pEdit) {
74 m_pEdit->GetWidgetRect(rect, TRUE); 74 m_pEdit->GetWidgetRect(rect, true);
75 } else { 75 } else {
76 rect.width = 100; 76 rect.width = 100;
77 rect.height = 16; 77 rect.height = 16;
78 } 78 }
79 if (!m_pProperties->m_pThemeProvider) { 79 if (!m_pProperties->m_pThemeProvider) {
80 ReSetTheme(); 80 ReSetTheme();
81 } 81 }
82 FX_FLOAT* pFWidth = static_cast<FX_FLOAT*>( 82 FX_FLOAT* pFWidth = static_cast<FX_FLOAT*>(
83 GetThemeCapacity(CFWL_WidgetCapacity::ScrollBarWidth)); 83 GetThemeCapacity(CFWL_WidgetCapacity::ScrollBarWidth));
84 if (!pFWidth) 84 if (!pFWidth)
85 return FWL_Error::Indefinite; 85 return FWL_Error::Indefinite;
86 rect.Inflate(0, 0, *pFWidth, 0); 86 rect.Inflate(0, 0, *pFWidth, 0);
87 IFWL_Widget::GetWidgetRect(rect, TRUE); 87 IFWL_Widget::GetWidgetRect(rect, true);
88 } else { 88 } else {
89 rect = m_pProperties->m_rtWidget; 89 rect = m_pProperties->m_rtWidget;
90 } 90 }
91 return FWL_Error::Succeeded; 91 return FWL_Error::Succeeded;
92 } 92 }
93 93
94 FWL_Error IFWL_ComboBox::ModifyStylesEx(uint32_t dwStylesExAdded, 94 FWL_Error IFWL_ComboBox::ModifyStylesEx(uint32_t dwStylesExAdded,
95 uint32_t dwStylesExRemoved) { 95 uint32_t dwStylesExRemoved) {
96 if (m_pWidgetMgr->IsFormDisabled()) { 96 if (m_pWidgetMgr->IsFormDisabled()) {
97 return DisForm_ModifyStylesEx(dwStylesExAdded, dwStylesExRemoved); 97 return DisForm_ModifyStylesEx(dwStylesExAdded, dwStylesExRemoved);
98 } 98 }
99 bool bAddDropDown = !!(dwStylesExAdded & FWL_STYLEEXT_CMB_DropDown); 99 bool bAddDropDown = !!(dwStylesExAdded & FWL_STYLEEXT_CMB_DropDown);
100 bool bRemoveDropDown = !!(dwStylesExRemoved & FWL_STYLEEXT_CMB_DropDown); 100 bool bRemoveDropDown = !!(dwStylesExRemoved & FWL_STYLEEXT_CMB_DropDown);
101 if (bAddDropDown && !m_pEdit) { 101 if (bAddDropDown && !m_pEdit) {
102 CFWL_WidgetImpProperties prop; 102 CFWL_WidgetImpProperties prop;
103 m_pEdit.reset(new IFWL_ComboEdit(m_pOwnerApp, prop, nullptr)); 103 m_pEdit.reset(new IFWL_ComboEdit(m_pOwnerApp, prop, nullptr));
104 m_pEdit->SetOuter(this); 104 m_pEdit->SetOuter(this);
105 m_pEdit->SetParent(this); 105 m_pEdit->SetParent(this);
106 } else if (bRemoveDropDown && m_pEdit) { 106 } else if (bRemoveDropDown && m_pEdit) {
107 m_pEdit->SetStates(FWL_WGTSTATE_Invisible, TRUE); 107 m_pEdit->SetStates(FWL_WGTSTATE_Invisible, true);
108 } 108 }
109 return IFWL_Widget::ModifyStylesEx(dwStylesExAdded, dwStylesExRemoved); 109 return IFWL_Widget::ModifyStylesEx(dwStylesExAdded, dwStylesExRemoved);
110 } 110 }
111 111
112 FWL_Error IFWL_ComboBox::Update() { 112 FWL_Error IFWL_ComboBox::Update() {
113 if (m_pWidgetMgr->IsFormDisabled()) { 113 if (m_pWidgetMgr->IsFormDisabled()) {
114 return DisForm_Update(); 114 return DisForm_Update();
115 } 115 }
116 if (IsLocked()) { 116 if (IsLocked()) {
117 return FWL_Error::Indefinite; 117 return FWL_Error::Indefinite;
118 } 118 }
119 ReSetTheme(); 119 ReSetTheme();
120 FX_BOOL bDropDown = IsDropDownStyle(); 120 bool bDropDown = IsDropDownStyle();
121 if (bDropDown && m_pEdit) { 121 if (bDropDown && m_pEdit) {
122 ReSetEditAlignment(); 122 ReSetEditAlignment();
123 } 123 }
124 if (!m_pProperties->m_pThemeProvider) { 124 if (!m_pProperties->m_pThemeProvider) {
125 m_pProperties->m_pThemeProvider = GetAvailableTheme(); 125 m_pProperties->m_pThemeProvider = GetAvailableTheme();
126 } 126 }
127 Layout(); 127 Layout();
128 CFWL_ThemePart part; 128 CFWL_ThemePart part;
129 part.m_pWidget = this; 129 part.m_pWidget = this;
130 m_fComboFormHandler = 130 m_fComboFormHandler =
(...skipping 12 matching lines...) Expand all
143 FWL_Error IFWL_ComboBox::DrawWidget(CFX_Graphics* pGraphics, 143 FWL_Error IFWL_ComboBox::DrawWidget(CFX_Graphics* pGraphics,
144 const CFX_Matrix* pMatrix) { 144 const CFX_Matrix* pMatrix) {
145 if (m_pWidgetMgr->IsFormDisabled()) { 145 if (m_pWidgetMgr->IsFormDisabled()) {
146 return DisForm_DrawWidget(pGraphics, pMatrix); 146 return DisForm_DrawWidget(pGraphics, pMatrix);
147 } 147 }
148 if (!pGraphics) 148 if (!pGraphics)
149 return FWL_Error::Indefinite; 149 return FWL_Error::Indefinite;
150 if (!m_pProperties->m_pThemeProvider) 150 if (!m_pProperties->m_pThemeProvider)
151 return FWL_Error::Indefinite; 151 return FWL_Error::Indefinite;
152 IFWL_ThemeProvider* pTheme = m_pProperties->m_pThemeProvider; 152 IFWL_ThemeProvider* pTheme = m_pProperties->m_pThemeProvider;
153 FX_BOOL bIsDropDown = IsDropDownStyle(); 153 bool bIsDropDown = IsDropDownStyle();
154 if (HasBorder()) { 154 if (HasBorder()) {
155 DrawBorder(pGraphics, CFWL_Part::Border, pTheme, pMatrix); 155 DrawBorder(pGraphics, CFWL_Part::Border, pTheme, pMatrix);
156 } 156 }
157 if (HasEdge()) { 157 if (HasEdge()) {
158 DrawEdge(pGraphics, CFWL_Part::Edge, pTheme, pMatrix); 158 DrawEdge(pGraphics, CFWL_Part::Edge, pTheme, pMatrix);
159 } 159 }
160 if (!bIsDropDown) { 160 if (!bIsDropDown) {
161 CFX_RectF rtTextBk(m_rtClient); 161 CFX_RectF rtTextBk(m_rtClient);
162 rtTextBk.width -= m_rtBtn.width; 162 rtTextBk.width -= m_rtBtn.width;
163 CFWL_ThemeBackground param; 163 CFWL_ThemeBackground param;
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
235 m_pEdit->SetThemeProvider(pThemeProvider); 235 m_pEdit->SetThemeProvider(pThemeProvider);
236 return FWL_Error::Succeeded; 236 return FWL_Error::Succeeded;
237 } 237 }
238 238
239 int32_t IFWL_ComboBox::GetCurSel() { 239 int32_t IFWL_ComboBox::GetCurSel() {
240 return m_iCurSel; 240 return m_iCurSel;
241 } 241 }
242 242
243 FWL_Error IFWL_ComboBox::SetCurSel(int32_t iSel) { 243 FWL_Error IFWL_ComboBox::SetCurSel(int32_t iSel) {
244 int32_t iCount = m_pListBox->CountItems(); 244 int32_t iCount = m_pListBox->CountItems();
245 FX_BOOL bClearSel = iSel < 0 || iSel >= iCount; 245 bool bClearSel = iSel < 0 || iSel >= iCount;
246 FX_BOOL bDropDown = IsDropDownStyle(); 246 bool bDropDown = IsDropDownStyle();
247 if (bDropDown && m_pEdit) { 247 if (bDropDown && m_pEdit) {
248 if (bClearSel) { 248 if (bClearSel) {
249 m_pEdit->SetText(CFX_WideString()); 249 m_pEdit->SetText(CFX_WideString());
250 } else { 250 } else {
251 CFX_WideString wsText; 251 CFX_WideString wsText;
252 IFWL_ComboBoxDP* pData = 252 IFWL_ComboBoxDP* pData =
253 static_cast<IFWL_ComboBoxDP*>(m_pProperties->m_pDataProvider); 253 static_cast<IFWL_ComboBoxDP*>(m_pProperties->m_pDataProvider);
254 IFWL_ListItem* hItem = pData->GetItem(this, iSel); 254 IFWL_ListItem* hItem = pData->GetItem(this, iSel);
255 m_pListBox->GetItemText(hItem, wsText); 255 m_pListBox->GetItemText(hItem, wsText);
256 m_pEdit->SetText(wsText); 256 m_pEdit->SetText(wsText);
257 } 257 }
258 m_pEdit->Update(); 258 m_pEdit->Update();
259 } 259 }
260 m_iCurSel = bClearSel ? -1 : iSel; 260 m_iCurSel = bClearSel ? -1 : iSel;
261 return FWL_Error::Succeeded; 261 return FWL_Error::Succeeded;
262 } 262 }
263 263
264 void IFWL_ComboBox::SetStates(uint32_t dwStates, FX_BOOL bSet) { 264 void IFWL_ComboBox::SetStates(uint32_t dwStates, bool bSet) {
265 FX_BOOL bIsDropDown = IsDropDownStyle(); 265 bool bIsDropDown = IsDropDownStyle();
266 if (bIsDropDown && m_pEdit) 266 if (bIsDropDown && m_pEdit)
267 m_pEdit->SetStates(dwStates, bSet); 267 m_pEdit->SetStates(dwStates, bSet);
268 if (m_pListBox) 268 if (m_pListBox)
269 m_pListBox->SetStates(dwStates, bSet); 269 m_pListBox->SetStates(dwStates, bSet);
270 IFWL_Widget::SetStates(dwStates, bSet); 270 IFWL_Widget::SetStates(dwStates, bSet);
271 } 271 }
272 272
273 FWL_Error IFWL_ComboBox::SetEditText(const CFX_WideString& wsText) { 273 FWL_Error IFWL_ComboBox::SetEditText(const CFX_WideString& wsText) {
274 if (!m_pEdit) 274 if (!m_pEdit)
275 return FWL_Error::Indefinite; 275 return FWL_Error::Indefinite;
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
322 return FWL_Error::Indefinite; 322 return FWL_Error::Indefinite;
323 return m_pEdit->SetLimit(nLimit); 323 return m_pEdit->SetLimit(nLimit);
324 } 324 }
325 325
326 FWL_Error IFWL_ComboBox::EditDoClipboard(int32_t iCmd) { 326 FWL_Error IFWL_ComboBox::EditDoClipboard(int32_t iCmd) {
327 if (!m_pEdit) 327 if (!m_pEdit)
328 return FWL_Error::Indefinite; 328 return FWL_Error::Indefinite;
329 return m_pEdit->DoClipboard(iCmd); 329 return m_pEdit->DoClipboard(iCmd);
330 } 330 }
331 331
332 FX_BOOL IFWL_ComboBox::EditRedo(const IFDE_TxtEdtDoRecord* pRecord) { 332 bool IFWL_ComboBox::EditRedo(const IFDE_TxtEdtDoRecord* pRecord) {
333 return m_pEdit && m_pEdit->Redo(pRecord); 333 return m_pEdit && m_pEdit->Redo(pRecord);
334 } 334 }
335 335
336 FX_BOOL IFWL_ComboBox::EditUndo(const IFDE_TxtEdtDoRecord* pRecord) { 336 bool IFWL_ComboBox::EditUndo(const IFDE_TxtEdtDoRecord* pRecord) {
337 return m_pEdit && m_pEdit->Undo(pRecord); 337 return m_pEdit && m_pEdit->Undo(pRecord);
338 } 338 }
339 339
340 IFWL_ListBox* IFWL_ComboBox::GetListBoxt() { 340 IFWL_ListBox* IFWL_ComboBox::GetListBoxt() {
341 return m_pListBox.get(); 341 return m_pListBox.get();
342 } 342 }
343 343
344 FX_BOOL IFWL_ComboBox::AfterFocusShowDropList() { 344 bool IFWL_ComboBox::AfterFocusShowDropList() {
345 if (!m_bNeedShowList) { 345 if (!m_bNeedShowList) {
346 return FALSE; 346 return false;
347 } 347 }
348 if (m_pEdit) { 348 if (m_pEdit) {
349 MatchEditText(); 349 MatchEditText();
350 } 350 }
351 ShowDropList(TRUE); 351 ShowDropList(true);
352 m_bNeedShowList = FALSE; 352 m_bNeedShowList = false;
353 return TRUE; 353 return true;
354 } 354 }
355 355
356 FWL_Error IFWL_ComboBox::OpenDropDownList(FX_BOOL bActivate) { 356 FWL_Error IFWL_ComboBox::OpenDropDownList(bool bActivate) {
357 ShowDropList(bActivate); 357 ShowDropList(bActivate);
358 return FWL_Error::Succeeded; 358 return FWL_Error::Succeeded;
359 } 359 }
360 360
361 FX_BOOL IFWL_ComboBox::EditCanUndo() { 361 bool IFWL_ComboBox::EditCanUndo() {
362 return m_pEdit->CanUndo(); 362 return m_pEdit->CanUndo();
363 } 363 }
364 364
365 FX_BOOL IFWL_ComboBox::EditCanRedo() { 365 bool IFWL_ComboBox::EditCanRedo() {
366 return m_pEdit->CanRedo(); 366 return m_pEdit->CanRedo();
367 } 367 }
368 368
369 FX_BOOL IFWL_ComboBox::EditUndo() { 369 bool IFWL_ComboBox::EditUndo() {
370 return m_pEdit->Undo(); 370 return m_pEdit->Undo();
371 } 371 }
372 372
373 FX_BOOL IFWL_ComboBox::EditRedo() { 373 bool IFWL_ComboBox::EditRedo() {
374 return m_pEdit->Redo(); 374 return m_pEdit->Redo();
375 } 375 }
376 376
377 FX_BOOL IFWL_ComboBox::EditCanCopy() { 377 bool IFWL_ComboBox::EditCanCopy() {
378 return m_pEdit->CountSelRanges() > 0; 378 return m_pEdit->CountSelRanges() > 0;
379 } 379 }
380 380
381 FX_BOOL IFWL_ComboBox::EditCanCut() { 381 bool IFWL_ComboBox::EditCanCut() {
382 if (m_pEdit->GetStylesEx() & FWL_STYLEEXT_EDT_ReadOnly) { 382 if (m_pEdit->GetStylesEx() & FWL_STYLEEXT_EDT_ReadOnly) {
383 return FALSE; 383 return false;
384 } 384 }
385 return m_pEdit->CountSelRanges() > 0; 385 return m_pEdit->CountSelRanges() > 0;
386 } 386 }
387 387
388 FX_BOOL IFWL_ComboBox::EditCanSelectAll() { 388 bool IFWL_ComboBox::EditCanSelectAll() {
389 return m_pEdit->GetTextLength() > 0; 389 return m_pEdit->GetTextLength() > 0;
390 } 390 }
391 391
392 FX_BOOL IFWL_ComboBox::EditCopy(CFX_WideString& wsCopy) { 392 bool IFWL_ComboBox::EditCopy(CFX_WideString& wsCopy) {
393 return m_pEdit->Copy(wsCopy); 393 return m_pEdit->Copy(wsCopy);
394 } 394 }
395 395
396 FX_BOOL IFWL_ComboBox::EditCut(CFX_WideString& wsCut) { 396 bool IFWL_ComboBox::EditCut(CFX_WideString& wsCut) {
397 return m_pEdit->Cut(wsCut); 397 return m_pEdit->Cut(wsCut);
398 } 398 }
399 399
400 FX_BOOL IFWL_ComboBox::EditPaste(const CFX_WideString& wsPaste) { 400 bool IFWL_ComboBox::EditPaste(const CFX_WideString& wsPaste) {
401 return m_pEdit->Paste(wsPaste); 401 return m_pEdit->Paste(wsPaste);
402 } 402 }
403 403
404 FX_BOOL IFWL_ComboBox::EditSelectAll() { 404 bool IFWL_ComboBox::EditSelectAll() {
405 return m_pEdit->AddSelRange(0) == FWL_Error::Succeeded; 405 return m_pEdit->AddSelRange(0) == FWL_Error::Succeeded;
406 } 406 }
407 407
408 FX_BOOL IFWL_ComboBox::EditDelete() { 408 bool IFWL_ComboBox::EditDelete() {
409 return m_pEdit->ClearText() == FWL_Error::Succeeded; 409 return m_pEdit->ClearText() == FWL_Error::Succeeded;
410 } 410 }
411 411
412 FX_BOOL IFWL_ComboBox::EditDeSelect() { 412 bool IFWL_ComboBox::EditDeSelect() {
413 return m_pEdit->ClearSelections() == FWL_Error::Succeeded; 413 return m_pEdit->ClearSelections() == FWL_Error::Succeeded;
414 } 414 }
415 415
416 FWL_Error IFWL_ComboBox::GetBBox(CFX_RectF& rect) { 416 FWL_Error IFWL_ComboBox::GetBBox(CFX_RectF& rect) {
417 if (m_pWidgetMgr->IsFormDisabled()) { 417 if (m_pWidgetMgr->IsFormDisabled()) {
418 return DisForm_GetBBox(rect); 418 return DisForm_GetBBox(rect);
419 } 419 }
420 rect = m_pProperties->m_rtWidget; 420 rect = m_pProperties->m_rtWidget;
421 if (m_pListBox && IsDropListShowed()) { 421 if (m_pListBox && IsDropListShowed()) {
422 CFX_RectF rtList; 422 CFX_RectF rtList;
(...skipping 23 matching lines...) Expand all
446 param.m_iPart = CFWL_Part::StretchHandler; 446 param.m_iPart = CFWL_Part::StretchHandler;
447 param.m_dwStates = CFWL_PartState_Normal; 447 param.m_dwStates = CFWL_PartState_Normal;
448 param.m_pWidget = this; 448 param.m_pWidget = this;
449 if (pMatrix) { 449 if (pMatrix) {
450 param.m_matrix.Concat(*pMatrix); 450 param.m_matrix.Concat(*pMatrix);
451 } 451 }
452 param.m_rtPart = m_rtHandler; 452 param.m_rtPart = m_rtHandler;
453 m_pProperties->m_pThemeProvider->DrawBackground(&param); 453 m_pProperties->m_pThemeProvider->DrawBackground(&param);
454 } 454 }
455 455
456 void IFWL_ComboBox::ShowDropList(FX_BOOL bActivate) { 456 void IFWL_ComboBox::ShowDropList(bool bActivate) {
457 if (m_pWidgetMgr->IsFormDisabled()) 457 if (m_pWidgetMgr->IsFormDisabled())
458 return DisForm_ShowDropList(bActivate); 458 return DisForm_ShowDropList(bActivate);
459 459
460 FX_BOOL bDropList = IsDropListShowed(); 460 bool bDropList = IsDropListShowed();
461 if (bDropList == bActivate) 461 if (bDropList == bActivate)
462 return; 462 return;
463 if (!m_pComboBoxProxy) 463 if (!m_pComboBoxProxy)
464 InitProxyForm(); 464 InitProxyForm();
465 465
466 m_pComboBoxProxy->Reset(); 466 m_pComboBoxProxy->Reset();
467 if (bActivate) { 467 if (bActivate) {
468 m_pListBox->ChangeSelected(m_iCurSel); 468 m_pListBox->ChangeSelected(m_iCurSel);
469 ReSetListItemAlignment(); 469 ReSetListItemAlignment();
470 uint32_t dwStyleAdd = m_pProperties->m_dwStyleExes & 470 uint32_t dwStyleAdd = m_pProperties->m_dwStyleExes &
471 (FWL_STYLEEXT_CMB_Sort | FWL_STYLEEXT_CMB_OwnerDraw); 471 (FWL_STYLEEXT_CMB_Sort | FWL_STYLEEXT_CMB_OwnerDraw);
472 m_pListBox->ModifyStylesEx(dwStyleAdd, 0); 472 m_pListBox->ModifyStylesEx(dwStyleAdd, 0);
473 m_pListBox->GetWidgetRect(m_rtList, TRUE); 473 m_pListBox->GetWidgetRect(m_rtList, true);
474 FX_FLOAT fHeight = GetListHeight(); 474 FX_FLOAT fHeight = GetListHeight();
475 if (fHeight > 0) { 475 if (fHeight > 0) {
476 if (m_rtList.height > GetListHeight()) { 476 if (m_rtList.height > GetListHeight()) {
477 m_rtList.height = GetListHeight(); 477 m_rtList.height = GetListHeight();
478 m_pListBox->ModifyStyles(FWL_WGTSTYLE_VScroll, 0); 478 m_pListBox->ModifyStyles(FWL_WGTSTYLE_VScroll, 0);
479 } 479 }
480 } 480 }
481 CFX_RectF rtAnchor; 481 CFX_RectF rtAnchor;
482 rtAnchor.Set(0, 0, m_pProperties->m_rtWidget.width, 482 rtAnchor.Set(0, 0, m_pProperties->m_rtWidget.width,
483 m_pProperties->m_rtWidget.height); 483 m_pProperties->m_rtWidget.height);
(...skipping 20 matching lines...) Expand all
504 } 504 }
505 } 505 }
506 m_pComboBoxProxy->SetWidgetRect(m_rtProxy); 506 m_pComboBoxProxy->SetWidgetRect(m_rtProxy);
507 m_pComboBoxProxy->Update(); 507 m_pComboBoxProxy->Update();
508 m_pListBox->SetWidgetRect(m_rtList); 508 m_pListBox->SetWidgetRect(m_rtList);
509 m_pListBox->Update(); 509 m_pListBox->Update();
510 CFWL_EvtCmbPreDropDown ev; 510 CFWL_EvtCmbPreDropDown ev;
511 ev.m_pSrcTarget = this; 511 ev.m_pSrcTarget = this;
512 DispatchEvent(&ev); 512 DispatchEvent(&ev);
513 m_fItemHeight = m_pListBox->m_fItemHeight; 513 m_fItemHeight = m_pListBox->m_fItemHeight;
514 m_pListBox->SetFocus(TRUE); 514 m_pListBox->SetFocus(true);
515 m_pComboBoxProxy->DoModal(); 515 m_pComboBoxProxy->DoModal();
516 m_pListBox->SetFocus(FALSE); 516 m_pListBox->SetFocus(false);
517 } else { 517 } else {
518 m_pComboBoxProxy->EndDoModal(); 518 m_pComboBoxProxy->EndDoModal();
519 CFWL_EvtCmbCloseUp ev; 519 CFWL_EvtCmbCloseUp ev;
520 ev.m_pSrcTarget = this; 520 ev.m_pSrcTarget = this;
521 DispatchEvent(&ev); 521 DispatchEvent(&ev);
522 m_bLButtonDown = FALSE; 522 m_bLButtonDown = false;
523 m_pListBox->m_bNotifyOwner = TRUE; 523 m_pListBox->m_bNotifyOwner = true;
524 SetFocus(TRUE); 524 SetFocus(true);
525 } 525 }
526 } 526 }
527 527
528 FX_BOOL IFWL_ComboBox::IsDropListShowed() { 528 bool IFWL_ComboBox::IsDropListShowed() {
529 return m_pComboBoxProxy && 529 return m_pComboBoxProxy &&
530 !(m_pComboBoxProxy->GetStates() & FWL_WGTSTATE_Invisible); 530 !(m_pComboBoxProxy->GetStates() & FWL_WGTSTATE_Invisible);
531 } 531 }
532 532
533 FX_BOOL IFWL_ComboBox::IsDropDownStyle() const { 533 bool IFWL_ComboBox::IsDropDownStyle() const {
534 return m_pProperties->m_dwStyleExes & FWL_STYLEEXT_CMB_DropDown; 534 return m_pProperties->m_dwStyleExes & FWL_STYLEEXT_CMB_DropDown;
535 } 535 }
536 536
537 void IFWL_ComboBox::MatchEditText() { 537 void IFWL_ComboBox::MatchEditText() {
538 CFX_WideString wsText; 538 CFX_WideString wsText;
539 m_pEdit->GetText(wsText); 539 m_pEdit->GetText(wsText);
540 int32_t iMatch = m_pListBox->MatchItem(wsText); 540 int32_t iMatch = m_pListBox->MatchItem(wsText);
541 if (iMatch != m_iCurSel) { 541 if (iMatch != m_iCurSel) {
542 m_pListBox->ChangeSelected(iMatch); 542 m_pListBox->ChangeSelected(iMatch);
543 if (iMatch >= 0) { 543 if (iMatch >= 0) {
(...skipping 21 matching lines...) Expand all
565 return DisForm_Layout(); 565 return DisForm_Layout();
566 } 566 }
567 GetClientRect(m_rtClient); 567 GetClientRect(m_rtClient);
568 FX_FLOAT* pFWidth = static_cast<FX_FLOAT*>( 568 FX_FLOAT* pFWidth = static_cast<FX_FLOAT*>(
569 GetThemeCapacity(CFWL_WidgetCapacity::ScrollBarWidth)); 569 GetThemeCapacity(CFWL_WidgetCapacity::ScrollBarWidth));
570 if (!pFWidth) 570 if (!pFWidth)
571 return; 571 return;
572 FX_FLOAT fBtn = *pFWidth; 572 FX_FLOAT fBtn = *pFWidth;
573 m_rtBtn.Set(m_rtClient.right() - fBtn, m_rtClient.top, fBtn, 573 m_rtBtn.Set(m_rtClient.right() - fBtn, m_rtClient.top, fBtn,
574 m_rtClient.height); 574 m_rtClient.height);
575 FX_BOOL bIsDropDown = IsDropDownStyle(); 575 bool bIsDropDown = IsDropDownStyle();
576 if (bIsDropDown && m_pEdit) { 576 if (bIsDropDown && m_pEdit) {
577 CFX_RectF rtEdit; 577 CFX_RectF rtEdit;
578 rtEdit.Set(m_rtClient.left, m_rtClient.top, m_rtClient.width - fBtn, 578 rtEdit.Set(m_rtClient.left, m_rtClient.top, m_rtClient.width - fBtn,
579 m_rtClient.height); 579 m_rtClient.height);
580 m_pEdit->SetWidgetRect(rtEdit); 580 m_pEdit->SetWidgetRect(rtEdit);
581 if (m_iCurSel >= 0) { 581 if (m_iCurSel >= 0) {
582 CFX_WideString wsText; 582 CFX_WideString wsText;
583 IFWL_ComboBoxDP* pData = 583 IFWL_ComboBoxDP* pData =
584 static_cast<IFWL_ComboBoxDP*>(m_pProperties->m_pDataProvider); 584 static_cast<IFWL_ComboBoxDP*>(m_pProperties->m_pDataProvider);
585 IFWL_ListItem* hItem = pData->GetItem(this, m_iCurSel); 585 IFWL_ListItem* hItem = pData->GetItem(this, m_iCurSel);
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
652 dwAdd |= FWL_STYLEEXT_LTB_CenterAlign; 652 dwAdd |= FWL_STYLEEXT_LTB_CenterAlign;
653 } 653 }
654 case FWL_STYLEEXT_CMB_ListItemRightAlign: { 654 case FWL_STYLEEXT_CMB_ListItemRightAlign: {
655 dwAdd |= FWL_STYLEEXT_LTB_RightAlign; 655 dwAdd |= FWL_STYLEEXT_LTB_RightAlign;
656 } 656 }
657 default: { dwAdd |= FWL_STYLEEXT_LTB_LeftAlign; } 657 default: { dwAdd |= FWL_STYLEEXT_LTB_LeftAlign; }
658 } 658 }
659 m_pListBox->ModifyStylesEx(dwAdd, FWL_STYLEEXT_CMB_ListItemAlignMask); 659 m_pListBox->ModifyStylesEx(dwAdd, FWL_STYLEEXT_CMB_ListItemAlignMask);
660 } 660 }
661 661
662 void IFWL_ComboBox::ProcessSelChanged(FX_BOOL bLButtonUp) { 662 void IFWL_ComboBox::ProcessSelChanged(bool bLButtonUp) {
663 IFWL_ComboBoxDP* pDatas = 663 IFWL_ComboBoxDP* pDatas =
664 static_cast<IFWL_ComboBoxDP*>(m_pProperties->m_pDataProvider); 664 static_cast<IFWL_ComboBoxDP*>(m_pProperties->m_pDataProvider);
665 m_iCurSel = pDatas->GetItemIndex(this, m_pListBox->GetSelItem(0)); 665 m_iCurSel = pDatas->GetItemIndex(this, m_pListBox->GetSelItem(0));
666 FX_BOOL bDropDown = IsDropDownStyle(); 666 bool bDropDown = IsDropDownStyle();
667 if (bDropDown) { 667 if (bDropDown) {
668 IFWL_ComboBoxDP* pData = 668 IFWL_ComboBoxDP* pData =
669 static_cast<IFWL_ComboBoxDP*>(m_pProperties->m_pDataProvider); 669 static_cast<IFWL_ComboBoxDP*>(m_pProperties->m_pDataProvider);
670 IFWL_ListItem* hItem = pData->GetItem(this, m_iCurSel); 670 IFWL_ListItem* hItem = pData->GetItem(this, m_iCurSel);
671 if (hItem) { 671 if (hItem) {
672 CFX_WideString wsText; 672 CFX_WideString wsText;
673 pData->GetItemText(this, hItem, wsText); 673 pData->GetItemText(this, hItem, wsText);
674 if (m_pEdit) { 674 if (m_pEdit) {
675 m_pEdit->SetText(wsText); 675 m_pEdit->SetText(wsText);
676 m_pEdit->Update(); 676 m_pEdit->Update();
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
720 if (m_pEdit) 720 if (m_pEdit)
721 return; 721 return;
722 722
723 CFWL_WidgetImpProperties prop; 723 CFWL_WidgetImpProperties prop;
724 prop.m_pParent = this; 724 prop.m_pParent = this;
725 prop.m_pThemeProvider = m_pProperties->m_pThemeProvider; 725 prop.m_pThemeProvider = m_pProperties->m_pThemeProvider;
726 m_pEdit.reset(new IFWL_ComboEdit(m_pOwnerApp, prop, this)); 726 m_pEdit.reset(new IFWL_ComboEdit(m_pOwnerApp, prop, this));
727 m_pEdit->SetOuter(this); 727 m_pEdit->SetOuter(this);
728 } 728 }
729 729
730 void IFWL_ComboBox::DisForm_ShowDropList(FX_BOOL bActivate) { 730 void IFWL_ComboBox::DisForm_ShowDropList(bool bActivate) {
731 FX_BOOL bDropList = DisForm_IsDropListShowed(); 731 bool bDropList = DisForm_IsDropListShowed();
732 if (bDropList == bActivate) { 732 if (bDropList == bActivate) {
733 return; 733 return;
734 } 734 }
735 if (bActivate) { 735 if (bActivate) {
736 CFWL_EvtCmbPreDropDown preEvent; 736 CFWL_EvtCmbPreDropDown preEvent;
737 preEvent.m_pSrcTarget = this; 737 preEvent.m_pSrcTarget = this;
738 DispatchEvent(&preEvent); 738 DispatchEvent(&preEvent);
739 IFWL_ComboList* pComboList = m_pListBox.get(); 739 IFWL_ComboList* pComboList = m_pListBox.get();
740 int32_t iItems = pComboList->CountItems(); 740 int32_t iItems = pComboList->CountItems();
741 if (iItems < 1) { 741 if (iItems < 1) {
(...skipping 10 matching lines...) Expand all
752 FX_FLOAT fPopupMax = fItemHeight * iItems + fBorder * 2; 752 FX_FLOAT fPopupMax = fItemHeight * iItems + fBorder * 2;
753 CFX_RectF rtList; 753 CFX_RectF rtList;
754 rtList.left = m_rtClient.left; 754 rtList.left = m_rtClient.left;
755 rtList.width = m_pProperties->m_rtWidget.width; 755 rtList.width = m_pProperties->m_rtWidget.width;
756 rtList.top = 0; 756 rtList.top = 0;
757 rtList.height = 0; 757 rtList.height = 0;
758 GetPopupPos(fPopupMin, fPopupMax, m_pProperties->m_rtWidget, rtList); 758 GetPopupPos(fPopupMin, fPopupMax, m_pProperties->m_rtWidget, rtList);
759 m_pListBox->SetWidgetRect(rtList); 759 m_pListBox->SetWidgetRect(rtList);
760 m_pListBox->Update(); 760 m_pListBox->Update();
761 } else { 761 } else {
762 SetFocus(TRUE); 762 SetFocus(true);
763 } 763 }
764 m_pListBox->SetStates(FWL_WGTSTATE_Invisible, !bActivate); 764 m_pListBox->SetStates(FWL_WGTSTATE_Invisible, !bActivate);
765 if (bActivate) { 765 if (bActivate) {
766 CFWL_EvtCmbPostDropDown postEvent; 766 CFWL_EvtCmbPostDropDown postEvent;
767 postEvent.m_pSrcTarget = this; 767 postEvent.m_pSrcTarget = this;
768 DispatchEvent(&postEvent); 768 DispatchEvent(&postEvent);
769 } 769 }
770 CFX_RectF rect; 770 CFX_RectF rect;
771 m_pListBox->GetWidgetRect(rect); 771 m_pListBox->GetWidgetRect(rect);
772 rect.Inflate(2, 2); 772 rect.Inflate(2, 2);
773 Repaint(&rect); 773 Repaint(&rect);
774 } 774 }
775 775
776 FX_BOOL IFWL_ComboBox::DisForm_IsDropListShowed() { 776 bool IFWL_ComboBox::DisForm_IsDropListShowed() {
777 return !(m_pListBox->GetStates() & FWL_WGTSTATE_Invisible); 777 return !(m_pListBox->GetStates() & FWL_WGTSTATE_Invisible);
778 } 778 }
779 779
780 FWL_Error IFWL_ComboBox::DisForm_ModifyStylesEx(uint32_t dwStylesExAdded, 780 FWL_Error IFWL_ComboBox::DisForm_ModifyStylesEx(uint32_t dwStylesExAdded,
781 uint32_t dwStylesExRemoved) { 781 uint32_t dwStylesExRemoved) {
782 if (!m_pEdit) 782 if (!m_pEdit)
783 DisForm_InitComboEdit(); 783 DisForm_InitComboEdit();
784 784
785 bool bAddDropDown = !!(dwStylesExAdded & FWL_STYLEEXT_CMB_DropDown); 785 bool bAddDropDown = !!(dwStylesExAdded & FWL_STYLEEXT_CMB_DropDown);
786 bool bDelDropDown = !!(dwStylesExRemoved & FWL_STYLEEXT_CMB_DropDown); 786 bool bDelDropDown = !!(dwStylesExRemoved & FWL_STYLEEXT_CMB_DropDown);
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
823 } 823 }
824 824
825 FWL_Error IFWL_ComboBox::DisForm_DrawWidget(CFX_Graphics* pGraphics, 825 FWL_Error IFWL_ComboBox::DisForm_DrawWidget(CFX_Graphics* pGraphics,
826 const CFX_Matrix* pMatrix) { 826 const CFX_Matrix* pMatrix) {
827 IFWL_ThemeProvider* pTheme = m_pProperties->m_pThemeProvider; 827 IFWL_ThemeProvider* pTheme = m_pProperties->m_pThemeProvider;
828 CFX_Matrix mtOrg; 828 CFX_Matrix mtOrg;
829 mtOrg.Set(1, 0, 0, 1, 0, 0); 829 mtOrg.Set(1, 0, 0, 1, 0, 0);
830 if (pMatrix) { 830 if (pMatrix) {
831 mtOrg = *pMatrix; 831 mtOrg = *pMatrix;
832 } 832 }
833 FX_BOOL bListShowed = m_pListBox && DisForm_IsDropListShowed(); 833 bool bListShowed = m_pListBox && DisForm_IsDropListShowed();
834 pGraphics->SaveGraphState(); 834 pGraphics->SaveGraphState();
835 pGraphics->ConcatMatrix(&mtOrg); 835 pGraphics->ConcatMatrix(&mtOrg);
836 if (!m_rtBtn.IsEmpty(0.1f)) { 836 if (!m_rtBtn.IsEmpty(0.1f)) {
837 CFWL_ThemeBackground param; 837 CFWL_ThemeBackground param;
838 param.m_pWidget = this; 838 param.m_pWidget = this;
839 param.m_iPart = CFWL_Part::DropDownButton; 839 param.m_iPart = CFWL_Part::DropDownButton;
840 param.m_dwStates = m_iBtnState; 840 param.m_dwStates = m_iBtnState;
841 param.m_pGraphics = pGraphics; 841 param.m_pGraphics = pGraphics;
842 param.m_rtPart = m_rtBtn; 842 param.m_rtPart = m_rtBtn;
843 pTheme->DrawBackground(&param); 843 pTheme->DrawBackground(&param);
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
885 if (!(GetStylesEx() & FWL_STYLEEXT_CMB_ReadOnly)) { 885 if (!(GetStylesEx() & FWL_STYLEEXT_CMB_ReadOnly)) {
886 m_rtBtn.Set(m_rtClient.right() - fBtn, m_rtClient.top + borderWidth, 886 m_rtBtn.Set(m_rtClient.right() - fBtn, m_rtClient.top + borderWidth,
887 fBtn - borderWidth, m_rtClient.height - 2 * borderWidth); 887 fBtn - borderWidth, m_rtClient.height - 2 * borderWidth);
888 } 888 }
889 CFX_RectF* pUIMargin = 889 CFX_RectF* pUIMargin =
890 static_cast<CFX_RectF*>(GetThemeCapacity(CFWL_WidgetCapacity::UIMargin)); 890 static_cast<CFX_RectF*>(GetThemeCapacity(CFWL_WidgetCapacity::UIMargin));
891 if (pUIMargin) { 891 if (pUIMargin) {
892 m_rtContent.Deflate(pUIMargin->left, pUIMargin->top, pUIMargin->width, 892 m_rtContent.Deflate(pUIMargin->left, pUIMargin->top, pUIMargin->width,
893 pUIMargin->height); 893 pUIMargin->height);
894 } 894 }
895 FX_BOOL bIsDropDown = IsDropDownStyle(); 895 bool bIsDropDown = IsDropDownStyle();
896 if (bIsDropDown && m_pEdit) { 896 if (bIsDropDown && m_pEdit) {
897 CFX_RectF rtEdit; 897 CFX_RectF rtEdit;
898 rtEdit.Set(m_rtContent.left, m_rtContent.top, m_rtContent.width - fBtn, 898 rtEdit.Set(m_rtContent.left, m_rtContent.top, m_rtContent.width - fBtn,
899 m_rtContent.height); 899 m_rtContent.height);
900 m_pEdit->SetWidgetRect(rtEdit); 900 m_pEdit->SetWidgetRect(rtEdit);
901 if (m_iCurSel >= 0) { 901 if (m_iCurSel >= 0) {
902 CFX_WideString wsText; 902 CFX_WideString wsText;
903 IFWL_ComboBoxDP* pData = 903 IFWL_ComboBoxDP* pData =
904 static_cast<IFWL_ComboBoxDP*>(m_pProperties->m_pDataProvider); 904 static_cast<IFWL_ComboBoxDP*>(m_pProperties->m_pDataProvider);
905 IFWL_ListItem* hItem = pData->GetItem(this, m_iCurSel); 905 IFWL_ListItem* hItem = pData->GetItem(this, m_iCurSel);
906 m_pListBox->GetItemText(hItem, wsText); 906 m_pListBox->GetItemText(hItem, wsText);
907 m_pEdit->LockUpdate(); 907 m_pEdit->LockUpdate();
908 m_pEdit->SetText(wsText); 908 m_pEdit->SetText(wsText);
909 m_pEdit->UnlockUpdate(); 909 m_pEdit->UnlockUpdate();
910 } 910 }
911 m_pEdit->Update(); 911 m_pEdit->Update();
912 } 912 }
913 } 913 }
914 914
915 void IFWL_ComboBox::OnProcessMessage(CFWL_Message* pMessage) { 915 void IFWL_ComboBox::OnProcessMessage(CFWL_Message* pMessage) {
916 if (m_pWidgetMgr->IsFormDisabled()) { 916 if (m_pWidgetMgr->IsFormDisabled()) {
917 DisForm_OnProcessMessage(pMessage); 917 DisForm_OnProcessMessage(pMessage);
918 return; 918 return;
919 } 919 }
920 if (!pMessage) 920 if (!pMessage)
921 return; 921 return;
922 922
923 switch (pMessage->GetClassID()) { 923 switch (pMessage->GetClassID()) {
924 case CFWL_MessageType::SetFocus: 924 case CFWL_MessageType::SetFocus:
925 OnFocusChanged(pMessage, TRUE); 925 OnFocusChanged(pMessage, true);
926 break; 926 break;
927 case CFWL_MessageType::KillFocus: 927 case CFWL_MessageType::KillFocus:
928 OnFocusChanged(pMessage, FALSE); 928 OnFocusChanged(pMessage, false);
929 break; 929 break;
930 case CFWL_MessageType::Mouse: { 930 case CFWL_MessageType::Mouse: {
931 CFWL_MsgMouse* pMsg = static_cast<CFWL_MsgMouse*>(pMessage); 931 CFWL_MsgMouse* pMsg = static_cast<CFWL_MsgMouse*>(pMessage);
932 switch (pMsg->m_dwCmd) { 932 switch (pMsg->m_dwCmd) {
933 case FWL_MouseCommand::LeftButtonDown: 933 case FWL_MouseCommand::LeftButtonDown:
934 OnLButtonDown(pMsg); 934 OnLButtonDown(pMsg);
935 break; 935 break;
936 case FWL_MouseCommand::LeftButtonUp: 936 case FWL_MouseCommand::LeftButtonUp:
937 OnLButtonUp(pMsg); 937 OnLButtonUp(pMsg);
938 break; 938 break;
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
985 pTemp.nChangeType = pTextChangedEvent->nChangeType; 985 pTemp.nChangeType = pTextChangedEvent->nChangeType;
986 DispatchEvent(&pTemp); 986 DispatchEvent(&pTemp);
987 } 987 }
988 } 988 }
989 989
990 void IFWL_ComboBox::OnDrawWidget(CFX_Graphics* pGraphics, 990 void IFWL_ComboBox::OnDrawWidget(CFX_Graphics* pGraphics,
991 const CFX_Matrix* pMatrix) { 991 const CFX_Matrix* pMatrix) {
992 DrawWidget(pGraphics, pMatrix); 992 DrawWidget(pGraphics, pMatrix);
993 } 993 }
994 994
995 void IFWL_ComboBox::OnFocusChanged(CFWL_Message* pMsg, FX_BOOL bSet) { 995 void IFWL_ComboBox::OnFocusChanged(CFWL_Message* pMsg, bool bSet) {
996 IFWL_Widget* pDstTarget = pMsg->m_pDstTarget; 996 IFWL_Widget* pDstTarget = pMsg->m_pDstTarget;
997 IFWL_Widget* pSrcTarget = pMsg->m_pSrcTarget; 997 IFWL_Widget* pSrcTarget = pMsg->m_pSrcTarget;
998 FX_BOOL bDropDown = IsDropDownStyle(); 998 bool bDropDown = IsDropDownStyle();
999 if (bSet) { 999 if (bSet) {
1000 m_pProperties->m_dwStates |= FWL_WGTSTATE_Focused; 1000 m_pProperties->m_dwStates |= FWL_WGTSTATE_Focused;
1001 if (bDropDown && pSrcTarget != m_pListBox.get()) { 1001 if (bDropDown && pSrcTarget != m_pListBox.get()) {
1002 if (!m_pEdit) 1002 if (!m_pEdit)
1003 return; 1003 return;
1004 m_pEdit->SetSelected(); 1004 m_pEdit->SetSelected();
1005 } else { 1005 } else {
1006 Repaint(&m_rtClient); 1006 Repaint(&m_rtClient);
1007 } 1007 }
1008 } else { 1008 } else {
1009 m_pProperties->m_dwStates &= ~FWL_WGTSTATE_Focused; 1009 m_pProperties->m_dwStates &= ~FWL_WGTSTATE_Focused;
1010 if (bDropDown && pDstTarget != m_pListBox.get()) { 1010 if (bDropDown && pDstTarget != m_pListBox.get()) {
1011 if (!m_pEdit) 1011 if (!m_pEdit)
1012 return; 1012 return;
1013 m_pEdit->FlagFocus(FALSE); 1013 m_pEdit->FlagFocus(false);
1014 m_pEdit->ClearSelected(); 1014 m_pEdit->ClearSelected();
1015 } else { 1015 } else {
1016 Repaint(&m_rtClient); 1016 Repaint(&m_rtClient);
1017 } 1017 }
1018 } 1018 }
1019 } 1019 }
1020 1020
1021 void IFWL_ComboBox::OnLButtonDown(CFWL_MsgMouse* pMsg) { 1021 void IFWL_ComboBox::OnLButtonDown(CFWL_MsgMouse* pMsg) {
1022 if (m_pProperties->m_dwStates & FWL_WGTSTATE_Disabled) 1022 if (m_pProperties->m_dwStates & FWL_WGTSTATE_Disabled)
1023 return; 1023 return;
1024 1024
1025 FX_BOOL bDropDown = IsDropDownStyle(); 1025 bool bDropDown = IsDropDownStyle();
1026 CFX_RectF& rtBtn = bDropDown ? m_rtBtn : m_rtClient; 1026 CFX_RectF& rtBtn = bDropDown ? m_rtBtn : m_rtClient;
1027 FX_BOOL bClickBtn = rtBtn.Contains(pMsg->m_fx, pMsg->m_fy); 1027 bool bClickBtn = rtBtn.Contains(pMsg->m_fx, pMsg->m_fy);
1028 if (!bClickBtn) 1028 if (!bClickBtn)
1029 return; 1029 return;
1030 1030
1031 if (bDropDown && m_pEdit) 1031 if (bDropDown && m_pEdit)
1032 MatchEditText(); 1032 MatchEditText();
1033 1033
1034 m_bLButtonDown = TRUE; 1034 m_bLButtonDown = true;
1035 m_iBtnState = CFWL_PartState_Pressed; 1035 m_iBtnState = CFWL_PartState_Pressed;
1036 Repaint(&m_rtClient); 1036 Repaint(&m_rtClient);
1037 ShowDropList(TRUE); 1037 ShowDropList(true);
1038 m_iBtnState = CFWL_PartState_Normal; 1038 m_iBtnState = CFWL_PartState_Normal;
1039 Repaint(&m_rtClient); 1039 Repaint(&m_rtClient);
1040 } 1040 }
1041 1041
1042 void IFWL_ComboBox::OnLButtonUp(CFWL_MsgMouse* pMsg) { 1042 void IFWL_ComboBox::OnLButtonUp(CFWL_MsgMouse* pMsg) {
1043 m_bLButtonDown = FALSE; 1043 m_bLButtonDown = false;
1044 if (m_rtBtn.Contains(pMsg->m_fx, pMsg->m_fy)) 1044 if (m_rtBtn.Contains(pMsg->m_fx, pMsg->m_fy))
1045 m_iBtnState = CFWL_PartState_Hovered; 1045 m_iBtnState = CFWL_PartState_Hovered;
1046 else 1046 else
1047 m_iBtnState = CFWL_PartState_Normal; 1047 m_iBtnState = CFWL_PartState_Normal;
1048 1048
1049 Repaint(&m_rtBtn); 1049 Repaint(&m_rtBtn);
1050 } 1050 }
1051 1051
1052 void IFWL_ComboBox::OnMouseMove(CFWL_MsgMouse* pMsg) { 1052 void IFWL_ComboBox::OnMouseMove(CFWL_MsgMouse* pMsg) {
1053 int32_t iOldState = m_iBtnState; 1053 int32_t iOldState = m_iBtnState;
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
1085 1085
1086 void IFWL_ComboBox::DoSubCtrlKey(CFWL_MsgKey* pMsg) { 1086 void IFWL_ComboBox::DoSubCtrlKey(CFWL_MsgKey* pMsg) {
1087 uint32_t dwKeyCode = pMsg->m_dwKeyCode; 1087 uint32_t dwKeyCode = pMsg->m_dwKeyCode;
1088 const bool bUp = dwKeyCode == FWL_VKEY_Up; 1088 const bool bUp = dwKeyCode == FWL_VKEY_Up;
1089 const bool bDown = dwKeyCode == FWL_VKEY_Down; 1089 const bool bDown = dwKeyCode == FWL_VKEY_Down;
1090 if (bUp || bDown) { 1090 if (bUp || bDown) {
1091 int32_t iCount = m_pListBox->CountItems(); 1091 int32_t iCount = m_pListBox->CountItems();
1092 if (iCount < 1) 1092 if (iCount < 1)
1093 return; 1093 return;
1094 1094
1095 FX_BOOL bMatchEqual = FALSE; 1095 bool bMatchEqual = false;
1096 int32_t iCurSel = m_iCurSel; 1096 int32_t iCurSel = m_iCurSel;
1097 FX_BOOL bDropDown = IsDropDownStyle(); 1097 bool bDropDown = IsDropDownStyle();
1098 if (bDropDown && m_pEdit) { 1098 if (bDropDown && m_pEdit) {
1099 CFX_WideString wsText; 1099 CFX_WideString wsText;
1100 m_pEdit->GetText(wsText); 1100 m_pEdit->GetText(wsText);
1101 iCurSel = m_pListBox->MatchItem(wsText); 1101 iCurSel = m_pListBox->MatchItem(wsText);
1102 if (iCurSel >= 0) { 1102 if (iCurSel >= 0) {
1103 CFX_WideString wsTemp; 1103 CFX_WideString wsTemp;
1104 IFWL_ComboBoxDP* pData = 1104 IFWL_ComboBoxDP* pData =
1105 static_cast<IFWL_ComboBoxDP*>(m_pProperties->m_pDataProvider); 1105 static_cast<IFWL_ComboBoxDP*>(m_pProperties->m_pDataProvider);
1106 IFWL_ListItem* hItem = pData->GetItem(this, iCurSel); 1106 IFWL_ListItem* hItem = pData->GetItem(this, iCurSel);
1107 m_pListBox->GetItemText(hItem, wsTemp); 1107 m_pListBox->GetItemText(hItem, wsTemp);
(...skipping 11 matching lines...) Expand all
1119 iCurSel++; 1119 iCurSel++;
1120 } 1120 }
1121 m_iCurSel = iCurSel; 1121 m_iCurSel = iCurSel;
1122 if (bDropDown && m_pEdit) 1122 if (bDropDown && m_pEdit)
1123 SynchrEditText(m_iCurSel); 1123 SynchrEditText(m_iCurSel);
1124 else 1124 else
1125 Repaint(&m_rtClient); 1125 Repaint(&m_rtClient);
1126 return; 1126 return;
1127 } 1127 }
1128 1128
1129 FX_BOOL bDropDown = IsDropDownStyle(); 1129 bool bDropDown = IsDropDownStyle();
1130 if (bDropDown) 1130 if (bDropDown)
1131 m_pEdit->GetDelegate()->OnProcessMessage(pMsg); 1131 m_pEdit->GetDelegate()->OnProcessMessage(pMsg);
1132 } 1132 }
1133 1133
1134 void IFWL_ComboBox::DisForm_OnProcessMessage(CFWL_Message* pMessage) { 1134 void IFWL_ComboBox::DisForm_OnProcessMessage(CFWL_Message* pMessage) {
1135 if (!pMessage) 1135 if (!pMessage)
1136 return; 1136 return;
1137 1137
1138 FX_BOOL backDefault = TRUE; 1138 bool backDefault = true;
1139 switch (pMessage->GetClassID()) { 1139 switch (pMessage->GetClassID()) {
1140 case CFWL_MessageType::SetFocus: { 1140 case CFWL_MessageType::SetFocus: {
1141 backDefault = FALSE; 1141 backDefault = false;
1142 DisForm_OnFocusChanged(pMessage, TRUE); 1142 DisForm_OnFocusChanged(pMessage, true);
1143 break; 1143 break;
1144 } 1144 }
1145 case CFWL_MessageType::KillFocus: { 1145 case CFWL_MessageType::KillFocus: {
1146 backDefault = FALSE; 1146 backDefault = false;
1147 DisForm_OnFocusChanged(pMessage, FALSE); 1147 DisForm_OnFocusChanged(pMessage, false);
1148 break; 1148 break;
1149 } 1149 }
1150 case CFWL_MessageType::Mouse: { 1150 case CFWL_MessageType::Mouse: {
1151 backDefault = FALSE; 1151 backDefault = false;
1152 CFWL_MsgMouse* pMsg = static_cast<CFWL_MsgMouse*>(pMessage); 1152 CFWL_MsgMouse* pMsg = static_cast<CFWL_MsgMouse*>(pMessage);
1153 switch (pMsg->m_dwCmd) { 1153 switch (pMsg->m_dwCmd) {
1154 case FWL_MouseCommand::LeftButtonDown: 1154 case FWL_MouseCommand::LeftButtonDown:
1155 DisForm_OnLButtonDown(pMsg); 1155 DisForm_OnLButtonDown(pMsg);
1156 break; 1156 break;
1157 case FWL_MouseCommand::LeftButtonUp: 1157 case FWL_MouseCommand::LeftButtonUp:
1158 OnLButtonUp(pMsg); 1158 OnLButtonUp(pMsg);
1159 break; 1159 break;
1160 default: 1160 default:
1161 break; 1161 break;
1162 } 1162 }
1163 break; 1163 break;
1164 } 1164 }
1165 case CFWL_MessageType::Key: { 1165 case CFWL_MessageType::Key: {
1166 backDefault = FALSE; 1166 backDefault = false;
1167 CFWL_MsgKey* pKey = static_cast<CFWL_MsgKey*>(pMessage); 1167 CFWL_MsgKey* pKey = static_cast<CFWL_MsgKey*>(pMessage);
1168 if (pKey->m_dwCmd == FWL_KeyCommand::KeyUp) 1168 if (pKey->m_dwCmd == FWL_KeyCommand::KeyUp)
1169 break; 1169 break;
1170 if (DisForm_IsDropListShowed() && 1170 if (DisForm_IsDropListShowed() &&
1171 pKey->m_dwCmd == FWL_KeyCommand::KeyDown) { 1171 pKey->m_dwCmd == FWL_KeyCommand::KeyDown) {
1172 FX_BOOL bListKey = pKey->m_dwKeyCode == FWL_VKEY_Up || 1172 bool bListKey = pKey->m_dwKeyCode == FWL_VKEY_Up ||
1173 pKey->m_dwKeyCode == FWL_VKEY_Down || 1173 pKey->m_dwKeyCode == FWL_VKEY_Down ||
1174 pKey->m_dwKeyCode == FWL_VKEY_Return || 1174 pKey->m_dwKeyCode == FWL_VKEY_Return ||
1175 pKey->m_dwKeyCode == FWL_VKEY_Escape; 1175 pKey->m_dwKeyCode == FWL_VKEY_Escape;
1176 if (bListKey) { 1176 if (bListKey) {
1177 m_pListBox->GetDelegate()->OnProcessMessage(pMessage); 1177 m_pListBox->GetDelegate()->OnProcessMessage(pMessage);
1178 break; 1178 break;
1179 } 1179 }
1180 } 1180 }
1181 DisForm_OnKey(pKey); 1181 DisForm_OnKey(pKey);
1182 break; 1182 break;
1183 } 1183 }
1184 default: 1184 default:
1185 break; 1185 break;
1186 } 1186 }
1187 if (backDefault) 1187 if (backDefault)
1188 IFWL_Widget::OnProcessMessage(pMessage); 1188 IFWL_Widget::OnProcessMessage(pMessage);
1189 } 1189 }
1190 1190
1191 void IFWL_ComboBox::DisForm_OnLButtonDown(CFWL_MsgMouse* pMsg) { 1191 void IFWL_ComboBox::DisForm_OnLButtonDown(CFWL_MsgMouse* pMsg) {
1192 FX_BOOL bDropDown = DisForm_IsDropListShowed(); 1192 bool bDropDown = DisForm_IsDropListShowed();
1193 CFX_RectF& rtBtn = bDropDown ? m_rtBtn : m_rtClient; 1193 CFX_RectF& rtBtn = bDropDown ? m_rtBtn : m_rtClient;
1194 if (!rtBtn.Contains(pMsg->m_fx, pMsg->m_fy)) 1194 if (!rtBtn.Contains(pMsg->m_fx, pMsg->m_fy))
1195 return; 1195 return;
1196 1196
1197 if (DisForm_IsDropListShowed()) { 1197 if (DisForm_IsDropListShowed()) {
1198 DisForm_ShowDropList(FALSE); 1198 DisForm_ShowDropList(false);
1199 return; 1199 return;
1200 } 1200 }
1201 if (m_pEdit) 1201 if (m_pEdit)
1202 MatchEditText(); 1202 MatchEditText();
1203 DisForm_ShowDropList(TRUE); 1203 DisForm_ShowDropList(true);
1204 } 1204 }
1205 1205
1206 void IFWL_ComboBox::DisForm_OnFocusChanged(CFWL_Message* pMsg, FX_BOOL bSet) { 1206 void IFWL_ComboBox::DisForm_OnFocusChanged(CFWL_Message* pMsg, bool bSet) {
1207 if (bSet) { 1207 if (bSet) {
1208 m_pProperties->m_dwStates |= FWL_WGTSTATE_Focused; 1208 m_pProperties->m_dwStates |= FWL_WGTSTATE_Focused;
1209 if ((m_pEdit->GetStates() & FWL_WGTSTATE_Focused) == 0) { 1209 if ((m_pEdit->GetStates() & FWL_WGTSTATE_Focused) == 0) {
1210 CFWL_MsgSetFocus msg; 1210 CFWL_MsgSetFocus msg;
1211 msg.m_pDstTarget = m_pEdit.get(); 1211 msg.m_pDstTarget = m_pEdit.get();
1212 msg.m_pSrcTarget = nullptr; 1212 msg.m_pSrcTarget = nullptr;
1213 m_pEdit->GetDelegate()->OnProcessMessage(&msg); 1213 m_pEdit->GetDelegate()->OnProcessMessage(&msg);
1214 } 1214 }
1215 } else { 1215 } else {
1216 m_pProperties->m_dwStates &= ~FWL_WGTSTATE_Focused; 1216 m_pProperties->m_dwStates &= ~FWL_WGTSTATE_Focused;
1217 DisForm_ShowDropList(FALSE); 1217 DisForm_ShowDropList(false);
1218 CFWL_MsgKillFocus msg; 1218 CFWL_MsgKillFocus msg;
1219 msg.m_pDstTarget = nullptr; 1219 msg.m_pDstTarget = nullptr;
1220 msg.m_pSrcTarget = m_pEdit.get(); 1220 msg.m_pSrcTarget = m_pEdit.get();
1221 m_pEdit->GetDelegate()->OnProcessMessage(&msg); 1221 m_pEdit->GetDelegate()->OnProcessMessage(&msg);
1222 } 1222 }
1223 } 1223 }
1224 1224
1225 void IFWL_ComboBox::DisForm_OnKey(CFWL_MsgKey* pMsg) { 1225 void IFWL_ComboBox::DisForm_OnKey(CFWL_MsgKey* pMsg) {
1226 uint32_t dwKeyCode = pMsg->m_dwKeyCode; 1226 uint32_t dwKeyCode = pMsg->m_dwKeyCode;
1227 const bool bUp = dwKeyCode == FWL_VKEY_Up; 1227 const bool bUp = dwKeyCode == FWL_VKEY_Up;
1228 const bool bDown = dwKeyCode == FWL_VKEY_Down; 1228 const bool bDown = dwKeyCode == FWL_VKEY_Down;
1229 if (bUp || bDown) { 1229 if (bUp || bDown) {
1230 IFWL_ComboList* pComboList = m_pListBox.get(); 1230 IFWL_ComboList* pComboList = m_pListBox.get();
1231 int32_t iCount = pComboList->CountItems(); 1231 int32_t iCount = pComboList->CountItems();
1232 if (iCount < 1) 1232 if (iCount < 1)
1233 return; 1233 return;
1234 1234
1235 FX_BOOL bMatchEqual = FALSE; 1235 bool bMatchEqual = false;
1236 int32_t iCurSel = m_iCurSel; 1236 int32_t iCurSel = m_iCurSel;
1237 if (m_pEdit) { 1237 if (m_pEdit) {
1238 CFX_WideString wsText; 1238 CFX_WideString wsText;
1239 m_pEdit->GetText(wsText); 1239 m_pEdit->GetText(wsText);
1240 iCurSel = pComboList->MatchItem(wsText); 1240 iCurSel = pComboList->MatchItem(wsText);
1241 if (iCurSel >= 0) { 1241 if (iCurSel >= 0) {
1242 CFX_WideString wsTemp; 1242 CFX_WideString wsTemp;
1243 IFWL_ListItem* item = m_pListBox->GetSelItem(iCurSel); 1243 IFWL_ListItem* item = m_pListBox->GetSelItem(iCurSel);
1244 m_pListBox->GetItemText(item, wsTemp); 1244 m_pListBox->GetItemText(item, wsTemp);
1245 bMatchEqual = wsText == wsTemp; 1245 bMatchEqual = wsText == wsTemp;
1246 } 1246 }
1247 } 1247 }
1248 if (iCurSel < 0) { 1248 if (iCurSel < 0) {
1249 iCurSel = 0; 1249 iCurSel = 0;
1250 } else if (bMatchEqual) { 1250 } else if (bMatchEqual) {
1251 if ((bUp && iCurSel == 0) || (bDown && iCurSel == iCount - 1)) 1251 if ((bUp && iCurSel == 0) || (bDown && iCurSel == iCount - 1))
1252 return; 1252 return;
1253 if (bUp) 1253 if (bUp)
1254 iCurSel--; 1254 iCurSel--;
1255 else 1255 else
1256 iCurSel++; 1256 iCurSel++;
1257 } 1257 }
1258 m_iCurSel = iCurSel; 1258 m_iCurSel = iCurSel;
1259 SynchrEditText(m_iCurSel); 1259 SynchrEditText(m_iCurSel);
1260 return; 1260 return;
1261 } 1261 }
1262 if (m_pEdit) 1262 if (m_pEdit)
1263 m_pEdit->GetDelegate()->OnProcessMessage(pMsg); 1263 m_pEdit->GetDelegate()->OnProcessMessage(pMsg);
1264 } 1264 }
OLDNEW
« no previous file with comments | « xfa/fwl/core/ifwl_combobox.h ('k') | xfa/fwl/core/ifwl_comboboxproxy.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698