| 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" |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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, bool bAutoSize) { | 69 void IFWL_ComboBox::GetWidgetRect(CFX_RectF& rect, bool bAutoSize) { |
| 70 if (bAutoSize) { | 70 if (bAutoSize) { |
| 71 rect.Reset(); | 71 rect.Reset(); |
| 72 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; |
| 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; | |
| 92 } | 91 } |
| 93 | 92 |
| 94 FWL_Error IFWL_ComboBox::ModifyStylesEx(uint32_t dwStylesExAdded, | 93 void IFWL_ComboBox::ModifyStylesEx(uint32_t dwStylesExAdded, |
| 95 uint32_t dwStylesExRemoved) { | 94 uint32_t dwStylesExRemoved) { |
| 96 if (m_pWidgetMgr->IsFormDisabled()) { | 95 if (m_pWidgetMgr->IsFormDisabled()) { |
| 97 return DisForm_ModifyStylesEx(dwStylesExAdded, dwStylesExRemoved); | 96 DisForm_ModifyStylesEx(dwStylesExAdded, dwStylesExRemoved); |
| 97 return; |
| 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 m_pEdit.reset(new IFWL_ComboEdit( | 102 m_pEdit.reset(new IFWL_ComboEdit( |
| 103 m_pOwnerApp, pdfium::MakeUnique<CFWL_WidgetProperties>(), nullptr)); | 103 m_pOwnerApp, pdfium::MakeUnique<CFWL_WidgetProperties>(), 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 IFWL_Widget::ModifyStylesEx(dwStylesExAdded, dwStylesExRemoved); |
| 110 } | 110 } |
| 111 | 111 |
| 112 FWL_Error IFWL_ComboBox::Update() { | 112 void IFWL_ComboBox::Update() { |
| 113 if (m_pWidgetMgr->IsFormDisabled()) { | 113 if (m_pWidgetMgr->IsFormDisabled()) { |
| 114 return DisForm_Update(); | 114 DisForm_Update(); |
| 115 return; |
| 115 } | 116 } |
| 116 if (IsLocked()) { | 117 if (IsLocked()) { |
| 117 return FWL_Error::Indefinite; | 118 return; |
| 118 } | 119 } |
| 119 ReSetTheme(); | 120 ReSetTheme(); |
| 120 bool bDropDown = IsDropDownStyle(); | 121 bool bDropDown = IsDropDownStyle(); |
| 121 if (bDropDown && m_pEdit) { | 122 if (bDropDown && m_pEdit) { |
| 122 ReSetEditAlignment(); | 123 ReSetEditAlignment(); |
| 123 } | 124 } |
| 124 if (!m_pProperties->m_pThemeProvider) { | 125 if (!m_pProperties->m_pThemeProvider) { |
| 125 m_pProperties->m_pThemeProvider = GetAvailableTheme(); | 126 m_pProperties->m_pThemeProvider = GetAvailableTheme(); |
| 126 } | 127 } |
| 127 Layout(); | 128 Layout(); |
| 128 CFWL_ThemePart part; | 129 CFWL_ThemePart part; |
| 129 part.m_pWidget = this; | 130 part.m_pWidget = this; |
| 130 m_fComboFormHandler = | 131 m_fComboFormHandler = |
| 131 *static_cast<FX_FLOAT*>(m_pProperties->m_pThemeProvider->GetCapacity( | 132 *static_cast<FX_FLOAT*>(m_pProperties->m_pThemeProvider->GetCapacity( |
| 132 &part, CFWL_WidgetCapacity::ComboFormHandler)); | 133 &part, CFWL_WidgetCapacity::ComboFormHandler)); |
| 133 return FWL_Error::Succeeded; | |
| 134 } | 134 } |
| 135 | 135 |
| 136 FWL_WidgetHit IFWL_ComboBox::HitTest(FX_FLOAT fx, FX_FLOAT fy) { | 136 FWL_WidgetHit IFWL_ComboBox::HitTest(FX_FLOAT fx, FX_FLOAT fy) { |
| 137 if (m_pWidgetMgr->IsFormDisabled()) { | 137 if (m_pWidgetMgr->IsFormDisabled()) { |
| 138 return DisForm_HitTest(fx, fy); | 138 return DisForm_HitTest(fx, fy); |
| 139 } | 139 } |
| 140 return IFWL_Widget::HitTest(fx, fy); | 140 return IFWL_Widget::HitTest(fx, fy); |
| 141 } | 141 } |
| 142 | 142 |
| 143 FWL_Error IFWL_ComboBox::DrawWidget(CFX_Graphics* pGraphics, | 143 void 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 DisForm_DrawWidget(pGraphics, pMatrix); |
| 147 return; |
| 147 } | 148 } |
| 148 if (!pGraphics) | 149 if (!pGraphics) |
| 149 return FWL_Error::Indefinite; | 150 return; |
| 150 if (!m_pProperties->m_pThemeProvider) | 151 if (!m_pProperties->m_pThemeProvider) |
| 151 return FWL_Error::Indefinite; | 152 return; |
| 152 IFWL_ThemeProvider* pTheme = m_pProperties->m_pThemeProvider; | 153 IFWL_ThemeProvider* pTheme = m_pProperties->m_pThemeProvider; |
| 153 bool bIsDropDown = IsDropDownStyle(); | 154 bool bIsDropDown = IsDropDownStyle(); |
| 154 if (HasBorder()) { | 155 if (HasBorder()) { |
| 155 DrawBorder(pGraphics, CFWL_Part::Border, pTheme, pMatrix); | 156 DrawBorder(pGraphics, CFWL_Part::Border, pTheme, pMatrix); |
| 156 } | 157 } |
| 157 if (HasEdge()) { | 158 if (HasEdge()) { |
| 158 DrawEdge(pGraphics, CFWL_Part::Edge, pTheme, pMatrix); | 159 DrawEdge(pGraphics, CFWL_Part::Edge, pTheme, pMatrix); |
| 159 } | 160 } |
| 160 if (!bIsDropDown) { | 161 if (!bIsDropDown) { |
| 161 CFX_RectF rtTextBk(m_rtClient); | 162 CFX_RectF rtTextBk(m_rtClient); |
| (...skipping 19 matching lines...) Expand all Loading... |
| 181 param.m_dwStates = CFWL_PartState_Disabled; | 182 param.m_dwStates = CFWL_PartState_Disabled; |
| 182 } else if ((m_pProperties->m_dwStates & FWL_WGTSTATE_Focused) && | 183 } else if ((m_pProperties->m_dwStates & FWL_WGTSTATE_Focused) && |
| 183 (m_iCurSel >= 0)) { | 184 (m_iCurSel >= 0)) { |
| 184 param.m_dwStates = CFWL_PartState_Selected; | 185 param.m_dwStates = CFWL_PartState_Selected; |
| 185 } else { | 186 } else { |
| 186 param.m_dwStates = CFWL_PartState_Normal; | 187 param.m_dwStates = CFWL_PartState_Normal; |
| 187 } | 188 } |
| 188 pTheme->DrawBackground(¶m); | 189 pTheme->DrawBackground(¶m); |
| 189 if (m_iCurSel >= 0) { | 190 if (m_iCurSel >= 0) { |
| 190 if (!m_pListBox) | 191 if (!m_pListBox) |
| 191 return FWL_Error::Indefinite; | 192 return; |
| 192 CFX_WideString wsText; | 193 CFX_WideString wsText; |
| 193 IFWL_ComboBoxDP* pData = | 194 IFWL_ComboBoxDP* pData = |
| 194 static_cast<IFWL_ComboBoxDP*>(m_pProperties->m_pDataProvider); | 195 static_cast<IFWL_ComboBoxDP*>(m_pProperties->m_pDataProvider); |
| 195 CFWL_ListItem* hItem = pData->GetItem(this, m_iCurSel); | 196 CFWL_ListItem* hItem = pData->GetItem(this, m_iCurSel); |
| 196 m_pListBox->GetItemText(hItem, wsText); | 197 m_pListBox->GetItemText(hItem, wsText); |
| 197 CFWL_ThemeText theme_text; | 198 CFWL_ThemeText theme_text; |
| 198 theme_text.m_pWidget = this; | 199 theme_text.m_pWidget = this; |
| 199 theme_text.m_iPart = CFWL_Part::Caption; | 200 theme_text.m_iPart = CFWL_Part::Caption; |
| 200 theme_text.m_dwStates = m_iBtnState; | 201 theme_text.m_dwStates = m_iBtnState; |
| 201 theme_text.m_pGraphics = pGraphics; | 202 theme_text.m_pGraphics = pGraphics; |
| (...skipping 13 matching lines...) Expand all Loading... |
| 215 param.m_pWidget = this; | 216 param.m_pWidget = this; |
| 216 param.m_iPart = CFWL_Part::DropDownButton; | 217 param.m_iPart = CFWL_Part::DropDownButton; |
| 217 param.m_dwStates = (m_pProperties->m_dwStates & FWL_WGTSTATE_Disabled) | 218 param.m_dwStates = (m_pProperties->m_dwStates & FWL_WGTSTATE_Disabled) |
| 218 ? CFWL_PartState_Disabled | 219 ? CFWL_PartState_Disabled |
| 219 : m_iBtnState; | 220 : m_iBtnState; |
| 220 param.m_pGraphics = pGraphics; | 221 param.m_pGraphics = pGraphics; |
| 221 param.m_matrix.Concat(*pMatrix); | 222 param.m_matrix.Concat(*pMatrix); |
| 222 param.m_rtPart = m_rtBtn; | 223 param.m_rtPart = m_rtBtn; |
| 223 pTheme->DrawBackground(¶m); | 224 pTheme->DrawBackground(¶m); |
| 224 } | 225 } |
| 225 return FWL_Error::Succeeded; | |
| 226 } | 226 } |
| 227 | 227 |
| 228 FWL_Error IFWL_ComboBox::SetThemeProvider(IFWL_ThemeProvider* pThemeProvider) { | 228 void IFWL_ComboBox::SetThemeProvider(IFWL_ThemeProvider* pThemeProvider) { |
| 229 if (!pThemeProvider) | 229 if (!pThemeProvider) |
| 230 return FWL_Error::Indefinite; | 230 return; |
| 231 m_pProperties->m_pThemeProvider = pThemeProvider; | 231 m_pProperties->m_pThemeProvider = pThemeProvider; |
| 232 if (m_pListBox) | 232 if (m_pListBox) |
| 233 m_pListBox->SetThemeProvider(pThemeProvider); | 233 m_pListBox->SetThemeProvider(pThemeProvider); |
| 234 if (m_pEdit) | 234 if (m_pEdit) |
| 235 m_pEdit->SetThemeProvider(pThemeProvider); | 235 m_pEdit->SetThemeProvider(pThemeProvider); |
| 236 return FWL_Error::Succeeded; | |
| 237 } | 236 } |
| 238 | 237 |
| 239 int32_t IFWL_ComboBox::GetCurSel() { | 238 int32_t IFWL_ComboBox::GetCurSel() { |
| 240 return m_iCurSel; | 239 return m_iCurSel; |
| 241 } | 240 } |
| 242 | 241 |
| 243 FWL_Error IFWL_ComboBox::SetCurSel(int32_t iSel) { | 242 FWL_Error IFWL_ComboBox::SetCurSel(int32_t iSel) { |
| 244 int32_t iCount = m_pListBox->CountItems(); | 243 int32_t iCount = m_pListBox->CountItems(); |
| 245 bool bClearSel = iSel < 0 || iSel >= iCount; | 244 bool bClearSel = iSel < 0 || iSel >= iCount; |
| 246 bool bDropDown = IsDropDownStyle(); | 245 bool bDropDown = IsDropDownStyle(); |
| (...skipping 16 matching lines...) Expand all Loading... |
| 263 | 262 |
| 264 void IFWL_ComboBox::SetStates(uint32_t dwStates, bool bSet) { | 263 void IFWL_ComboBox::SetStates(uint32_t dwStates, bool bSet) { |
| 265 bool bIsDropDown = IsDropDownStyle(); | 264 bool bIsDropDown = IsDropDownStyle(); |
| 266 if (bIsDropDown && m_pEdit) | 265 if (bIsDropDown && m_pEdit) |
| 267 m_pEdit->SetStates(dwStates, bSet); | 266 m_pEdit->SetStates(dwStates, bSet); |
| 268 if (m_pListBox) | 267 if (m_pListBox) |
| 269 m_pListBox->SetStates(dwStates, bSet); | 268 m_pListBox->SetStates(dwStates, bSet); |
| 270 IFWL_Widget::SetStates(dwStates, bSet); | 269 IFWL_Widget::SetStates(dwStates, bSet); |
| 271 } | 270 } |
| 272 | 271 |
| 273 FWL_Error IFWL_ComboBox::SetEditText(const CFX_WideString& wsText) { | 272 void IFWL_ComboBox::SetEditText(const CFX_WideString& wsText) { |
| 274 if (!m_pEdit) | 273 if (!m_pEdit) |
| 275 return FWL_Error::Indefinite; | 274 return; |
| 276 m_pEdit->SetText(wsText); | 275 m_pEdit->SetText(wsText); |
| 277 return m_pEdit->Update(); | 276 m_pEdit->Update(); |
| 278 } | 277 } |
| 279 | 278 |
| 280 int32_t IFWL_ComboBox::GetEditTextLength() const { | 279 int32_t IFWL_ComboBox::GetEditTextLength() const { |
| 281 if (!m_pEdit) | 280 if (!m_pEdit) |
| 282 return -1; | 281 return -1; |
| 283 return m_pEdit->GetTextLength(); | 282 return m_pEdit->GetTextLength(); |
| 284 } | 283 } |
| 285 | 284 |
| 286 FWL_Error IFWL_ComboBox::GetEditText(CFX_WideString& wsText, | 285 FWL_Error IFWL_ComboBox::GetEditText(CFX_WideString& wsText, |
| 287 int32_t nStart, | 286 int32_t nStart, |
| (...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 420 rect = m_pProperties->m_rtWidget; | 419 rect = m_pProperties->m_rtWidget; |
| 421 if (m_pListBox && IsDropListShowed()) { | 420 if (m_pListBox && IsDropListShowed()) { |
| 422 CFX_RectF rtList; | 421 CFX_RectF rtList; |
| 423 m_pListBox->GetWidgetRect(rtList); | 422 m_pListBox->GetWidgetRect(rtList); |
| 424 rtList.Offset(rect.left, rect.top); | 423 rtList.Offset(rect.left, rect.top); |
| 425 rect.Union(rtList); | 424 rect.Union(rtList); |
| 426 } | 425 } |
| 427 return FWL_Error::Succeeded; | 426 return FWL_Error::Succeeded; |
| 428 } | 427 } |
| 429 | 428 |
| 430 FWL_Error IFWL_ComboBox::EditModifyStylesEx(uint32_t dwStylesExAdded, | 429 void IFWL_ComboBox::EditModifyStylesEx(uint32_t dwStylesExAdded, |
| 431 uint32_t dwStylesExRemoved) { | 430 uint32_t dwStylesExRemoved) { |
| 432 if (!m_pEdit) | 431 if (m_pEdit) |
| 433 return FWL_Error::ParameterInvalid; | 432 m_pEdit->ModifyStylesEx(dwStylesExAdded, dwStylesExRemoved); |
| 434 return m_pEdit->ModifyStylesEx(dwStylesExAdded, dwStylesExRemoved); | |
| 435 } | 433 } |
| 436 | 434 |
| 437 FX_FLOAT IFWL_ComboBox::GetListHeight() { | 435 FX_FLOAT IFWL_ComboBox::GetListHeight() { |
| 438 return static_cast<IFWL_ComboBoxDP*>(m_pProperties->m_pDataProvider) | 436 return static_cast<IFWL_ComboBoxDP*>(m_pProperties->m_pDataProvider) |
| 439 ->GetListHeight(this); | 437 ->GetListHeight(this); |
| 440 } | 438 } |
| 441 | 439 |
| 442 void IFWL_ComboBox::DrawStretchHandler(CFX_Graphics* pGraphics, | 440 void IFWL_ComboBox::DrawStretchHandler(CFX_Graphics* pGraphics, |
| 443 const CFX_Matrix* pMatrix) { | 441 const CFX_Matrix* pMatrix) { |
| 444 CFWL_ThemeBackground param; | 442 CFWL_ThemeBackground param; |
| (...skipping 325 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 770 CFX_RectF rect; | 768 CFX_RectF rect; |
| 771 m_pListBox->GetWidgetRect(rect); | 769 m_pListBox->GetWidgetRect(rect); |
| 772 rect.Inflate(2, 2); | 770 rect.Inflate(2, 2); |
| 773 Repaint(&rect); | 771 Repaint(&rect); |
| 774 } | 772 } |
| 775 | 773 |
| 776 bool IFWL_ComboBox::DisForm_IsDropListShowed() { | 774 bool IFWL_ComboBox::DisForm_IsDropListShowed() { |
| 777 return !(m_pListBox->GetStates() & FWL_WGTSTATE_Invisible); | 775 return !(m_pListBox->GetStates() & FWL_WGTSTATE_Invisible); |
| 778 } | 776 } |
| 779 | 777 |
| 780 FWL_Error IFWL_ComboBox::DisForm_ModifyStylesEx(uint32_t dwStylesExAdded, | 778 void IFWL_ComboBox::DisForm_ModifyStylesEx(uint32_t dwStylesExAdded, |
| 781 uint32_t dwStylesExRemoved) { | 779 uint32_t dwStylesExRemoved) { |
| 782 if (!m_pEdit) | 780 if (!m_pEdit) |
| 783 DisForm_InitComboEdit(); | 781 DisForm_InitComboEdit(); |
| 784 | 782 |
| 785 bool bAddDropDown = !!(dwStylesExAdded & FWL_STYLEEXT_CMB_DropDown); | 783 bool bAddDropDown = !!(dwStylesExAdded & FWL_STYLEEXT_CMB_DropDown); |
| 786 bool bDelDropDown = !!(dwStylesExRemoved & FWL_STYLEEXT_CMB_DropDown); | 784 bool bDelDropDown = !!(dwStylesExRemoved & FWL_STYLEEXT_CMB_DropDown); |
| 787 dwStylesExRemoved &= ~FWL_STYLEEXT_CMB_DropDown; | 785 dwStylesExRemoved &= ~FWL_STYLEEXT_CMB_DropDown; |
| 788 m_pProperties->m_dwStyleExes |= FWL_STYLEEXT_CMB_DropDown; | 786 m_pProperties->m_dwStyleExes |= FWL_STYLEEXT_CMB_DropDown; |
| 789 if (bAddDropDown) { | 787 if (bAddDropDown) { |
| 790 m_pEdit->ModifyStylesEx(0, FWL_STYLEEXT_EDT_ReadOnly); | 788 m_pEdit->ModifyStylesEx(0, FWL_STYLEEXT_EDT_ReadOnly); |
| 791 } else if (bDelDropDown) { | 789 } else if (bDelDropDown) { |
| 792 m_pEdit->ModifyStylesEx(FWL_STYLEEXT_EDT_ReadOnly, 0); | 790 m_pEdit->ModifyStylesEx(FWL_STYLEEXT_EDT_ReadOnly, 0); |
| 793 } | 791 } |
| 794 return IFWL_Widget::ModifyStylesEx(dwStylesExAdded, dwStylesExRemoved); | 792 IFWL_Widget::ModifyStylesEx(dwStylesExAdded, dwStylesExRemoved); |
| 795 } | 793 } |
| 796 | 794 |
| 797 FWL_Error IFWL_ComboBox::DisForm_Update() { | 795 void IFWL_ComboBox::DisForm_Update() { |
| 798 if (m_iLock) { | 796 if (m_iLock) { |
| 799 return FWL_Error::Indefinite; | 797 return; |
| 800 } | 798 } |
| 801 if (m_pEdit) { | 799 if (m_pEdit) { |
| 802 ReSetEditAlignment(); | 800 ReSetEditAlignment(); |
| 803 } | 801 } |
| 804 ReSetTheme(); | 802 ReSetTheme(); |
| 805 Layout(); | 803 Layout(); |
| 806 return FWL_Error::Succeeded; | |
| 807 } | 804 } |
| 808 | 805 |
| 809 FWL_WidgetHit IFWL_ComboBox::DisForm_HitTest(FX_FLOAT fx, FX_FLOAT fy) { | 806 FWL_WidgetHit IFWL_ComboBox::DisForm_HitTest(FX_FLOAT fx, FX_FLOAT fy) { |
| 810 CFX_RectF rect; | 807 CFX_RectF rect; |
| 811 rect.Set(0, 0, m_pProperties->m_rtWidget.width - m_rtBtn.width, | 808 rect.Set(0, 0, m_pProperties->m_rtWidget.width - m_rtBtn.width, |
| 812 m_pProperties->m_rtWidget.height); | 809 m_pProperties->m_rtWidget.height); |
| 813 if (rect.Contains(fx, fy)) | 810 if (rect.Contains(fx, fy)) |
| 814 return FWL_WidgetHit::Edit; | 811 return FWL_WidgetHit::Edit; |
| 815 if (m_rtBtn.Contains(fx, fy)) | 812 if (m_rtBtn.Contains(fx, fy)) |
| 816 return FWL_WidgetHit::Client; | 813 return FWL_WidgetHit::Client; |
| 817 if (DisForm_IsDropListShowed()) { | 814 if (DisForm_IsDropListShowed()) { |
| 818 m_pListBox->GetWidgetRect(rect); | 815 m_pListBox->GetWidgetRect(rect); |
| 819 if (rect.Contains(fx, fy)) | 816 if (rect.Contains(fx, fy)) |
| 820 return FWL_WidgetHit::Client; | 817 return FWL_WidgetHit::Client; |
| 821 } | 818 } |
| 822 return FWL_WidgetHit::Unknown; | 819 return FWL_WidgetHit::Unknown; |
| 823 } | 820 } |
| 824 | 821 |
| 825 FWL_Error IFWL_ComboBox::DisForm_DrawWidget(CFX_Graphics* pGraphics, | 822 void IFWL_ComboBox::DisForm_DrawWidget(CFX_Graphics* pGraphics, |
| 826 const CFX_Matrix* pMatrix) { | 823 const CFX_Matrix* pMatrix) { |
| 827 IFWL_ThemeProvider* pTheme = m_pProperties->m_pThemeProvider; | 824 IFWL_ThemeProvider* pTheme = m_pProperties->m_pThemeProvider; |
| 828 CFX_Matrix mtOrg; | 825 CFX_Matrix mtOrg; |
| 829 mtOrg.Set(1, 0, 0, 1, 0, 0); | 826 mtOrg.Set(1, 0, 0, 1, 0, 0); |
| 830 if (pMatrix) { | 827 if (pMatrix) { |
| 831 mtOrg = *pMatrix; | 828 mtOrg = *pMatrix; |
| 832 } | 829 } |
| 833 bool bListShowed = m_pListBox && DisForm_IsDropListShowed(); | 830 bool bListShowed = m_pListBox && DisForm_IsDropListShowed(); |
| 834 pGraphics->SaveGraphState(); | 831 pGraphics->SaveGraphState(); |
| 835 pGraphics->ConcatMatrix(&mtOrg); | 832 pGraphics->ConcatMatrix(&mtOrg); |
| 836 if (!m_rtBtn.IsEmpty(0.1f)) { | 833 if (!m_rtBtn.IsEmpty(0.1f)) { |
| (...skipping 15 matching lines...) Expand all Loading... |
| 852 m_pEdit->DrawWidget(pGraphics, &mt); | 849 m_pEdit->DrawWidget(pGraphics, &mt); |
| 853 } | 850 } |
| 854 if (bListShowed) { | 851 if (bListShowed) { |
| 855 CFX_RectF rtList; | 852 CFX_RectF rtList; |
| 856 m_pListBox->GetWidgetRect(rtList); | 853 m_pListBox->GetWidgetRect(rtList); |
| 857 CFX_Matrix mt; | 854 CFX_Matrix mt; |
| 858 mt.Set(1, 0, 0, 1, rtList.left, rtList.top); | 855 mt.Set(1, 0, 0, 1, rtList.left, rtList.top); |
| 859 mt.Concat(mtOrg); | 856 mt.Concat(mtOrg); |
| 860 m_pListBox->DrawWidget(pGraphics, &mt); | 857 m_pListBox->DrawWidget(pGraphics, &mt); |
| 861 } | 858 } |
| 862 return FWL_Error::Succeeded; | |
| 863 } | 859 } |
| 864 | 860 |
| 865 FWL_Error IFWL_ComboBox::DisForm_GetBBox(CFX_RectF& rect) { | 861 FWL_Error IFWL_ComboBox::DisForm_GetBBox(CFX_RectF& rect) { |
| 866 rect = m_pProperties->m_rtWidget; | 862 rect = m_pProperties->m_rtWidget; |
| 867 if (m_pListBox && DisForm_IsDropListShowed()) { | 863 if (m_pListBox && DisForm_IsDropListShowed()) { |
| 868 CFX_RectF rtList; | 864 CFX_RectF rtList; |
| 869 m_pListBox->GetWidgetRect(rtList); | 865 m_pListBox->GetWidgetRect(rtList); |
| 870 rtList.Offset(rect.left, rect.top); | 866 rtList.Offset(rect.left, rect.top); |
| 871 rect.Union(rtList); | 867 rect.Union(rtList); |
| 872 } | 868 } |
| (...skipping 382 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1255 else | 1251 else |
| 1256 iCurSel++; | 1252 iCurSel++; |
| 1257 } | 1253 } |
| 1258 m_iCurSel = iCurSel; | 1254 m_iCurSel = iCurSel; |
| 1259 SynchrEditText(m_iCurSel); | 1255 SynchrEditText(m_iCurSel); |
| 1260 return; | 1256 return; |
| 1261 } | 1257 } |
| 1262 if (m_pEdit) | 1258 if (m_pEdit) |
| 1263 m_pEdit->GetDelegate()->OnProcessMessage(pMsg); | 1259 m_pEdit->GetDelegate()->OnProcessMessage(pMsg); |
| 1264 } | 1260 } |
| OLD | NEW |