| 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/basewidget/fwl_listboximp.h" | 7 #include "xfa/fwl/basewidget/fwl_listboximp.h" |
| 8 | 8 |
| 9 #include "xfa/fde/tto/fde_textout.h" | 9 #include "xfa/fde/tto/fde_textout.h" |
| 10 #include "xfa/fwl/basewidget/fwl_comboboximp.h" | 10 #include "xfa/fwl/basewidget/fwl_comboboximp.h" |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 45 IFWL_ListBox::IFWL_ListBox() {} | 45 IFWL_ListBox::IFWL_ListBox() {} |
| 46 int32_t IFWL_ListBox::CountSelItems() { | 46 int32_t IFWL_ListBox::CountSelItems() { |
| 47 return static_cast<CFWL_ListBoxImp*>(GetImpl())->CountSelItems(); | 47 return static_cast<CFWL_ListBoxImp*>(GetImpl())->CountSelItems(); |
| 48 } | 48 } |
| 49 FWL_HLISTITEM IFWL_ListBox::GetSelItem(int32_t nIndexSel) { | 49 FWL_HLISTITEM IFWL_ListBox::GetSelItem(int32_t nIndexSel) { |
| 50 return static_cast<CFWL_ListBoxImp*>(GetImpl())->GetSelItem(nIndexSel); | 50 return static_cast<CFWL_ListBoxImp*>(GetImpl())->GetSelItem(nIndexSel); |
| 51 } | 51 } |
| 52 int32_t IFWL_ListBox::GetSelIndex(int32_t nIndex) { | 52 int32_t IFWL_ListBox::GetSelIndex(int32_t nIndex) { |
| 53 return static_cast<CFWL_ListBoxImp*>(GetImpl())->GetSelIndex(nIndex); | 53 return static_cast<CFWL_ListBoxImp*>(GetImpl())->GetSelIndex(nIndex); |
| 54 } | 54 } |
| 55 FWL_ERR IFWL_ListBox::SetSelItem(FWL_HLISTITEM hItem, FX_BOOL bSelect) { | 55 FWL_Error IFWL_ListBox::SetSelItem(FWL_HLISTITEM hItem, FX_BOOL bSelect) { |
| 56 return static_cast<CFWL_ListBoxImp*>(GetImpl())->SetSelItem(hItem, bSelect); | 56 return static_cast<CFWL_ListBoxImp*>(GetImpl())->SetSelItem(hItem, bSelect); |
| 57 } | 57 } |
| 58 FWL_ERR IFWL_ListBox::GetItemText(FWL_HLISTITEM hItem, CFX_WideString& wsText) { | 58 FWL_Error IFWL_ListBox::GetItemText(FWL_HLISTITEM hItem, |
| 59 CFX_WideString& wsText) { |
| 59 return static_cast<CFWL_ListBoxImp*>(GetImpl())->GetItemText(hItem, wsText); | 60 return static_cast<CFWL_ListBoxImp*>(GetImpl())->GetItemText(hItem, wsText); |
| 60 } | 61 } |
| 61 FWL_ERR IFWL_ListBox::GetScrollPos(FX_FLOAT& fPos, FX_BOOL bVert) { | 62 FWL_Error IFWL_ListBox::GetScrollPos(FX_FLOAT& fPos, FX_BOOL bVert) { |
| 62 return static_cast<CFWL_ListBoxImp*>(GetImpl())->GetScrollPos(fPos, bVert); | 63 return static_cast<CFWL_ListBoxImp*>(GetImpl())->GetScrollPos(fPos, bVert); |
| 63 } | 64 } |
| 64 FWL_ERR* IFWL_ListBox::Sort(IFWL_ListBoxCompare* pCom) { | |
| 65 return static_cast<CFWL_ListBoxImp*>(GetImpl())->Sort(pCom); | |
| 66 } | |
| 67 | 65 |
| 68 CFWL_ListBoxImp::CFWL_ListBoxImp(const CFWL_WidgetImpProperties& properties, | 66 CFWL_ListBoxImp::CFWL_ListBoxImp(const CFWL_WidgetImpProperties& properties, |
| 69 IFWL_Widget* pOuter) | 67 IFWL_Widget* pOuter) |
| 70 : CFWL_WidgetImp(properties, pOuter), | 68 : CFWL_WidgetImp(properties, pOuter), |
| 71 m_dwTTOStyles(0), | 69 m_dwTTOStyles(0), |
| 72 m_iTTOAligns(0), | 70 m_iTTOAligns(0), |
| 73 m_hAnchor(NULL), | 71 m_hAnchor(NULL), |
| 74 m_fScorllBarWidth(0), | 72 m_fScorllBarWidth(0), |
| 75 m_bLButtonDown(FALSE), | 73 m_bLButtonDown(FALSE), |
| 76 m_pScrollBarTP(NULL) { | 74 m_pScrollBarTP(NULL) { |
| 77 m_rtClient.Reset(); | 75 m_rtClient.Reset(); |
| 78 m_rtConent.Reset(); | 76 m_rtConent.Reset(); |
| 79 m_rtStatic.Reset(); | 77 m_rtStatic.Reset(); |
| 80 } | 78 } |
| 81 CFWL_ListBoxImp::~CFWL_ListBoxImp() {} | 79 CFWL_ListBoxImp::~CFWL_ListBoxImp() {} |
| 82 FWL_ERR CFWL_ListBoxImp::GetClassName(CFX_WideString& wsClass) const { | 80 FWL_Error CFWL_ListBoxImp::GetClassName(CFX_WideString& wsClass) const { |
| 83 wsClass = FWL_CLASS_ListBox; | 81 wsClass = FWL_CLASS_ListBox; |
| 84 return FWL_ERR_Succeeded; | 82 return FWL_Error::Succeeded; |
| 85 } | 83 } |
| 86 uint32_t CFWL_ListBoxImp::GetClassID() const { | 84 uint32_t CFWL_ListBoxImp::GetClassID() const { |
| 87 return FWL_CLASSHASH_ListBox; | 85 return FWL_CLASSHASH_ListBox; |
| 88 } | 86 } |
| 89 FWL_ERR CFWL_ListBoxImp::Initialize() { | 87 FWL_Error CFWL_ListBoxImp::Initialize() { |
| 90 if (CFWL_WidgetImp::Initialize() != FWL_ERR_Succeeded) | 88 if (CFWL_WidgetImp::Initialize() != FWL_Error::Succeeded) |
| 91 return FWL_ERR_Indefinite; | 89 return FWL_Error::Indefinite; |
| 92 m_pDelegate = new CFWL_ListBoxImpDelegate(this); | 90 m_pDelegate = new CFWL_ListBoxImpDelegate(this); |
| 93 return FWL_ERR_Succeeded; | 91 return FWL_Error::Succeeded; |
| 94 } | 92 } |
| 95 FWL_ERR CFWL_ListBoxImp::Finalize() { | 93 FWL_Error CFWL_ListBoxImp::Finalize() { |
| 96 if (m_pVertScrollBar) { | 94 if (m_pVertScrollBar) { |
| 97 m_pVertScrollBar->Finalize(); | 95 m_pVertScrollBar->Finalize(); |
| 98 } | 96 } |
| 99 if (m_pHorzScrollBar) { | 97 if (m_pHorzScrollBar) { |
| 100 m_pHorzScrollBar->Finalize(); | 98 m_pHorzScrollBar->Finalize(); |
| 101 } | 99 } |
| 102 delete m_pDelegate; | 100 delete m_pDelegate; |
| 103 m_pDelegate = nullptr; | 101 m_pDelegate = nullptr; |
| 104 return CFWL_WidgetImp::Finalize(); | 102 return CFWL_WidgetImp::Finalize(); |
| 105 } | 103 } |
| 106 FWL_ERR CFWL_ListBoxImp::GetWidgetRect(CFX_RectF& rect, FX_BOOL bAutoSize) { | 104 FWL_Error CFWL_ListBoxImp::GetWidgetRect(CFX_RectF& rect, FX_BOOL bAutoSize) { |
| 107 if (bAutoSize) { | 105 if (bAutoSize) { |
| 108 rect.Set(0, 0, 0, 0); | 106 rect.Set(0, 0, 0, 0); |
| 109 if (!m_pProperties->m_pThemeProvider) { | 107 if (!m_pProperties->m_pThemeProvider) { |
| 110 m_pProperties->m_pThemeProvider = GetAvailableTheme(); | 108 m_pProperties->m_pThemeProvider = GetAvailableTheme(); |
| 111 } | 109 } |
| 112 CFX_SizeF fs = CalcSize(TRUE); | 110 CFX_SizeF fs = CalcSize(TRUE); |
| 113 rect.Set(0, 0, fs.x, fs.y); | 111 rect.Set(0, 0, fs.x, fs.y); |
| 114 CFWL_WidgetImp::GetWidgetRect(rect, TRUE); | 112 CFWL_WidgetImp::GetWidgetRect(rect, TRUE); |
| 115 } else { | 113 } else { |
| 116 rect = m_pProperties->m_rtWidget; | 114 rect = m_pProperties->m_rtWidget; |
| 117 } | 115 } |
| 118 return FWL_ERR_Succeeded; | 116 return FWL_Error::Succeeded; |
| 119 } | 117 } |
| 120 FWL_ERR CFWL_ListBoxImp::Update() { | 118 FWL_Error CFWL_ListBoxImp::Update() { |
| 121 if (IsLocked()) { | 119 if (IsLocked()) { |
| 122 return FWL_ERR_Indefinite; | 120 return FWL_Error::Indefinite; |
| 123 } | 121 } |
| 124 if (!m_pProperties->m_pThemeProvider) { | 122 if (!m_pProperties->m_pThemeProvider) { |
| 125 m_pProperties->m_pThemeProvider = GetAvailableTheme(); | 123 m_pProperties->m_pThemeProvider = GetAvailableTheme(); |
| 126 } | 124 } |
| 127 m_iTTOAligns = FDE_TTOALIGNMENT_Center; | 125 m_iTTOAligns = FDE_TTOALIGNMENT_Center; |
| 128 switch (m_pProperties->m_dwStyleExes & FWL_STYLEEXT_LTB_AlignMask) { | 126 switch (m_pProperties->m_dwStyleExes & FWL_STYLEEXT_LTB_AlignMask) { |
| 129 case FWL_STYLEEXT_LTB_LeftAlign: { | 127 case FWL_STYLEEXT_LTB_LeftAlign: { |
| 130 m_iTTOAligns = FDE_TTOALIGNMENT_CenterLeft; | 128 m_iTTOAligns = FDE_TTOALIGNMENT_CenterLeft; |
| 131 break; | 129 break; |
| 132 } | 130 } |
| 133 case FWL_STYLEEXT_LTB_RightAlign: { | 131 case FWL_STYLEEXT_LTB_RightAlign: { |
| 134 m_iTTOAligns = FDE_TTOALIGNMENT_CenterRight; | 132 m_iTTOAligns = FDE_TTOALIGNMENT_CenterRight; |
| 135 break; | 133 break; |
| 136 } | 134 } |
| 137 case FWL_STYLEEXT_LTB_CenterAlign: | 135 case FWL_STYLEEXT_LTB_CenterAlign: |
| 138 default: { m_iTTOAligns = FDE_TTOALIGNMENT_Center; } | 136 default: { m_iTTOAligns = FDE_TTOALIGNMENT_Center; } |
| 139 } | 137 } |
| 140 if (m_pProperties->m_dwStyleExes & FWL_WGTSTYLE_RTLReading) { | 138 if (m_pProperties->m_dwStyleExes & FWL_WGTSTYLE_RTLReading) { |
| 141 m_dwTTOStyles |= FDE_TTOSTYLE_RTL; | 139 m_dwTTOStyles |= FDE_TTOSTYLE_RTL; |
| 142 } | 140 } |
| 143 m_dwTTOStyles |= FDE_TTOSTYLE_SingleLine; | 141 m_dwTTOStyles |= FDE_TTOSTYLE_SingleLine; |
| 144 m_fScorllBarWidth = GetScrollWidth(); | 142 m_fScorllBarWidth = GetScrollWidth(); |
| 145 SortItem(); | |
| 146 CalcSize(); | 143 CalcSize(); |
| 147 return FWL_ERR_Succeeded; | 144 return FWL_Error::Succeeded; |
| 148 } | 145 } |
| 149 FWL_WidgetHit CFWL_ListBoxImp::HitTest(FX_FLOAT fx, FX_FLOAT fy) { | 146 FWL_WidgetHit CFWL_ListBoxImp::HitTest(FX_FLOAT fx, FX_FLOAT fy) { |
| 150 if (IsShowScrollBar(FALSE)) { | 147 if (IsShowScrollBar(FALSE)) { |
| 151 CFX_RectF rect; | 148 CFX_RectF rect; |
| 152 m_pHorzScrollBar->GetWidgetRect(rect); | 149 m_pHorzScrollBar->GetWidgetRect(rect); |
| 153 if (rect.Contains(fx, fy)) | 150 if (rect.Contains(fx, fy)) |
| 154 return FWL_WidgetHit::HScrollBar; | 151 return FWL_WidgetHit::HScrollBar; |
| 155 } | 152 } |
| 156 if (IsShowScrollBar(TRUE)) { | 153 if (IsShowScrollBar(TRUE)) { |
| 157 CFX_RectF rect; | 154 CFX_RectF rect; |
| 158 m_pVertScrollBar->GetWidgetRect(rect); | 155 m_pVertScrollBar->GetWidgetRect(rect); |
| 159 if (rect.Contains(fx, fy)) | 156 if (rect.Contains(fx, fy)) |
| 160 return FWL_WidgetHit::VScrollBar; | 157 return FWL_WidgetHit::VScrollBar; |
| 161 } | 158 } |
| 162 if (m_rtClient.Contains(fx, fy)) | 159 if (m_rtClient.Contains(fx, fy)) |
| 163 return FWL_WidgetHit::Client; | 160 return FWL_WidgetHit::Client; |
| 164 return FWL_WidgetHit::Unknown; | 161 return FWL_WidgetHit::Unknown; |
| 165 } | 162 } |
| 166 FWL_ERR CFWL_ListBoxImp::DrawWidget(CFX_Graphics* pGraphics, | 163 FWL_Error CFWL_ListBoxImp::DrawWidget(CFX_Graphics* pGraphics, |
| 167 const CFX_Matrix* pMatrix) { | 164 const CFX_Matrix* pMatrix) { |
| 168 if (!pGraphics) | 165 if (!pGraphics) |
| 169 return FWL_ERR_Indefinite; | 166 return FWL_Error::Indefinite; |
| 170 if (!m_pProperties->m_pThemeProvider) | 167 if (!m_pProperties->m_pThemeProvider) |
| 171 return FWL_ERR_Indefinite; | 168 return FWL_Error::Indefinite; |
| 172 IFWL_ThemeProvider* pTheme = m_pProperties->m_pThemeProvider; | 169 IFWL_ThemeProvider* pTheme = m_pProperties->m_pThemeProvider; |
| 173 pGraphics->SaveGraphState(); | 170 pGraphics->SaveGraphState(); |
| 174 if (HasBorder()) { | 171 if (HasBorder()) { |
| 175 DrawBorder(pGraphics, CFWL_Part::Border, pTheme, pMatrix); | 172 DrawBorder(pGraphics, CFWL_Part::Border, pTheme, pMatrix); |
| 176 } | 173 } |
| 177 if (HasEdge()) { | 174 if (HasEdge()) { |
| 178 DrawEdge(pGraphics, CFWL_Part::Edge, pTheme, pMatrix); | 175 DrawEdge(pGraphics, CFWL_Part::Edge, pTheme, pMatrix); |
| 179 } | 176 } |
| 180 CFX_RectF rtClip(m_rtConent); | 177 CFX_RectF rtClip(m_rtConent); |
| 181 if (IsShowScrollBar(FALSE)) { | 178 if (IsShowScrollBar(FALSE)) { |
| 182 rtClip.height -= m_fScorllBarWidth; | 179 rtClip.height -= m_fScorllBarWidth; |
| 183 } | 180 } |
| 184 if (IsShowScrollBar(TRUE)) { | 181 if (IsShowScrollBar(TRUE)) { |
| 185 rtClip.width -= m_fScorllBarWidth; | 182 rtClip.width -= m_fScorllBarWidth; |
| 186 } | 183 } |
| 187 if (pMatrix) { | 184 if (pMatrix) { |
| 188 pMatrix->TransformRect(rtClip); | 185 pMatrix->TransformRect(rtClip); |
| 189 } | 186 } |
| 190 pGraphics->SetClipRect(rtClip); | 187 pGraphics->SetClipRect(rtClip); |
| 191 if ((m_pProperties->m_dwStyles & FWL_WGTSTYLE_NoBackground) == 0) { | 188 if ((m_pProperties->m_dwStyles & FWL_WGTSTYLE_NoBackground) == 0) { |
| 192 DrawBkground(pGraphics, pTheme, pMatrix); | 189 DrawBkground(pGraphics, pTheme, pMatrix); |
| 193 } | 190 } |
| 194 DrawItems(pGraphics, pTheme, pMatrix); | 191 DrawItems(pGraphics, pTheme, pMatrix); |
| 195 pGraphics->RestoreGraphState(); | 192 pGraphics->RestoreGraphState(); |
| 196 return FWL_ERR_Succeeded; | 193 return FWL_Error::Succeeded; |
| 197 } | 194 } |
| 198 FWL_ERR CFWL_ListBoxImp::SetThemeProvider(IFWL_ThemeProvider* pThemeProvider) { | 195 FWL_Error CFWL_ListBoxImp::SetThemeProvider( |
| 196 IFWL_ThemeProvider* pThemeProvider) { |
| 199 if (!pThemeProvider) | 197 if (!pThemeProvider) |
| 200 return FWL_ERR_Indefinite; | 198 return FWL_Error::Indefinite; |
| 201 if (!pThemeProvider->IsValidWidget(m_pInterface)) { | 199 if (!pThemeProvider->IsValidWidget(m_pInterface)) { |
| 202 m_pScrollBarTP = pThemeProvider; | 200 m_pScrollBarTP = pThemeProvider; |
| 203 return FWL_ERR_Succeeded; | 201 return FWL_Error::Succeeded; |
| 204 } | 202 } |
| 205 m_pProperties->m_pThemeProvider = pThemeProvider; | 203 m_pProperties->m_pThemeProvider = pThemeProvider; |
| 206 return FWL_ERR_Succeeded; | 204 return FWL_Error::Succeeded; |
| 207 } | 205 } |
| 208 int32_t CFWL_ListBoxImp::CountSelItems() { | 206 int32_t CFWL_ListBoxImp::CountSelItems() { |
| 209 if (!m_pProperties->m_pDataProvider) | 207 if (!m_pProperties->m_pDataProvider) |
| 210 return 0; | 208 return 0; |
| 211 int32_t iRet = 0; | 209 int32_t iRet = 0; |
| 212 IFWL_ListBoxDP* pData = | 210 IFWL_ListBoxDP* pData = |
| 213 static_cast<IFWL_ListBoxDP*>(m_pProperties->m_pDataProvider); | 211 static_cast<IFWL_ListBoxDP*>(m_pProperties->m_pDataProvider); |
| 214 int32_t iCount = pData->CountItems(m_pInterface); | 212 int32_t iCount = pData->CountItems(m_pInterface); |
| 215 for (int32_t i = 0; i < iCount; i++) { | 213 for (int32_t i = 0; i < iCount; i++) { |
| 216 FWL_HLISTITEM hItem = pData->GetItem(m_pInterface, i); | 214 FWL_HLISTITEM hItem = pData->GetItem(m_pInterface, i); |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 263 if (dwStyle & FWL_ITEMSTATE_LTB_Selected) { | 261 if (dwStyle & FWL_ITEMSTATE_LTB_Selected) { |
| 264 if (index == nIndex) { | 262 if (index == nIndex) { |
| 265 return i; | 263 return i; |
| 266 } else { | 264 } else { |
| 267 index++; | 265 index++; |
| 268 } | 266 } |
| 269 } | 267 } |
| 270 } | 268 } |
| 271 return -1; | 269 return -1; |
| 272 } | 270 } |
| 273 FWL_ERR CFWL_ListBoxImp::SetSelItem(FWL_HLISTITEM hItem, FX_BOOL bSelect) { | 271 FWL_Error CFWL_ListBoxImp::SetSelItem(FWL_HLISTITEM hItem, FX_BOOL bSelect) { |
| 274 if (!m_pProperties->m_pDataProvider) | 272 if (!m_pProperties->m_pDataProvider) |
| 275 return FWL_ERR_Indefinite; | 273 return FWL_Error::Indefinite; |
| 276 if (!hItem) { | 274 if (!hItem) { |
| 277 if (bSelect) { | 275 if (bSelect) { |
| 278 SelectAll(); | 276 SelectAll(); |
| 279 } else { | 277 } else { |
| 280 ClearSelection(); | 278 ClearSelection(); |
| 281 SetFocusItem(NULL); | 279 SetFocusItem(NULL); |
| 282 } | 280 } |
| 283 return FWL_ERR_Indefinite; | 281 return FWL_Error::Indefinite; |
| 284 } | 282 } |
| 285 if (m_pProperties->m_dwStyleExes & FWL_STYLEEXT_LTB_MultiSelection) { | 283 if (m_pProperties->m_dwStyleExes & FWL_STYLEEXT_LTB_MultiSelection) { |
| 286 SetSelectionDirect(hItem, bSelect); | 284 SetSelectionDirect(hItem, bSelect); |
| 287 } else { | 285 } else { |
| 288 SetSelection(hItem, hItem, bSelect); | 286 SetSelection(hItem, hItem, bSelect); |
| 289 } | 287 } |
| 290 return FWL_ERR_Succeeded; | 288 return FWL_Error::Succeeded; |
| 291 } | 289 } |
| 292 FWL_ERR CFWL_ListBoxImp::GetItemText(FWL_HLISTITEM hItem, | 290 FWL_Error CFWL_ListBoxImp::GetItemText(FWL_HLISTITEM hItem, |
| 293 CFX_WideString& wsText) { | 291 CFX_WideString& wsText) { |
| 294 if (!m_pProperties->m_pDataProvider) | 292 if (!m_pProperties->m_pDataProvider) |
| 295 return FWL_ERR_Indefinite; | 293 return FWL_Error::Indefinite; |
| 296 IFWL_ListBoxDP* pData = | 294 IFWL_ListBoxDP* pData = |
| 297 static_cast<IFWL_ListBoxDP*>(m_pProperties->m_pDataProvider); | 295 static_cast<IFWL_ListBoxDP*>(m_pProperties->m_pDataProvider); |
| 298 if (!hItem) | 296 if (!hItem) |
| 299 return FWL_ERR_Indefinite; | 297 return FWL_Error::Indefinite; |
| 300 pData->GetItemText(m_pInterface, hItem, wsText); | 298 pData->GetItemText(m_pInterface, hItem, wsText); |
| 301 return FWL_ERR_Succeeded; | 299 return FWL_Error::Succeeded; |
| 302 } | 300 } |
| 303 FWL_ERR CFWL_ListBoxImp::GetScrollPos(FX_FLOAT& fPos, FX_BOOL bVert) { | 301 |
| 302 FWL_Error CFWL_ListBoxImp::GetScrollPos(FX_FLOAT& fPos, FX_BOOL bVert) { |
| 304 if ((bVert && IsShowScrollBar(TRUE)) || (!bVert && IsShowScrollBar(FALSE))) { | 303 if ((bVert && IsShowScrollBar(TRUE)) || (!bVert && IsShowScrollBar(FALSE))) { |
| 305 IFWL_ScrollBar* pScrollBar = | 304 IFWL_ScrollBar* pScrollBar = |
| 306 bVert ? m_pVertScrollBar.get() : m_pHorzScrollBar.get(); | 305 bVert ? m_pVertScrollBar.get() : m_pHorzScrollBar.get(); |
| 307 fPos = pScrollBar->GetPos(); | 306 fPos = pScrollBar->GetPos(); |
| 308 return FWL_ERR_Succeeded; | 307 return FWL_Error::Succeeded; |
| 309 } | 308 } |
| 310 return FWL_ERR_Indefinite; | 309 return FWL_Error::Indefinite; |
| 311 } | 310 } |
| 312 FWL_ERR* CFWL_ListBoxImp::Sort(IFWL_ListBoxCompare* pCom) { | 311 |
| 313 FWL_HLISTITEM hTemp; | |
| 314 IFWL_ListBoxDP* pData = | |
| 315 static_cast<IFWL_ListBoxDP*>(m_pProperties->m_pDataProvider); | |
| 316 int32_t sz = pData->CountItems(m_pInterface); | |
| 317 for (int32_t i = 0; i < sz - 1; i++) { | |
| 318 for (int32_t j = i + 1; j < sz; j++) { | |
| 319 if (pCom->Compare(pData->GetItem(m_pInterface, i), | |
| 320 pData->GetItem(m_pInterface, j)) > 0) { | |
| 321 hTemp = pData->GetItem(m_pInterface, i); | |
| 322 pData->SetItemIndex(m_pInterface, pData->GetItem(m_pInterface, j), i); | |
| 323 pData->SetItemIndex(m_pInterface, hTemp, j); | |
| 324 } | |
| 325 } | |
| 326 } | |
| 327 return FWL_ERR_Succeeded; | |
| 328 } | |
| 329 FWL_HLISTITEM CFWL_ListBoxImp::GetItem(FWL_HLISTITEM hItem, | 312 FWL_HLISTITEM CFWL_ListBoxImp::GetItem(FWL_HLISTITEM hItem, |
| 330 uint32_t dwKeyCode) { | 313 uint32_t dwKeyCode) { |
| 331 FWL_HLISTITEM hRet = NULL; | 314 FWL_HLISTITEM hRet = NULL; |
| 332 switch (dwKeyCode) { | 315 switch (dwKeyCode) { |
| 333 case FWL_VKEY_Up: | 316 case FWL_VKEY_Up: |
| 334 case FWL_VKEY_Down: | 317 case FWL_VKEY_Down: |
| 335 case FWL_VKEY_Home: | 318 case FWL_VKEY_Home: |
| 336 case FWL_VKEY_End: { | 319 case FWL_VKEY_End: { |
| 337 const bool bUp = dwKeyCode == FWL_VKEY_Up; | 320 const bool bUp = dwKeyCode == FWL_VKEY_Up; |
| 338 const bool bDown = dwKeyCode == FWL_VKEY_Down; | 321 const bool bDown = dwKeyCode == FWL_VKEY_Down; |
| (...skipping 611 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 950 } | 933 } |
| 951 CFWL_WidgetImpProperties prop; | 934 CFWL_WidgetImpProperties prop; |
| 952 prop.m_dwStyleExes = bVert ? FWL_STYLEEXT_SCB_Vert : FWL_STYLEEXT_SCB_Horz; | 935 prop.m_dwStyleExes = bVert ? FWL_STYLEEXT_SCB_Vert : FWL_STYLEEXT_SCB_Horz; |
| 953 prop.m_dwStates = FWL_WGTSTATE_Invisible; | 936 prop.m_dwStates = FWL_WGTSTATE_Invisible; |
| 954 prop.m_pParent = m_pInterface; | 937 prop.m_pParent = m_pInterface; |
| 955 prop.m_pThemeProvider = m_pScrollBarTP; | 938 prop.m_pThemeProvider = m_pScrollBarTP; |
| 956 IFWL_ScrollBar* pScrollBar = IFWL_ScrollBar::Create(prop, m_pInterface); | 939 IFWL_ScrollBar* pScrollBar = IFWL_ScrollBar::Create(prop, m_pInterface); |
| 957 pScrollBar->Initialize(); | 940 pScrollBar->Initialize(); |
| 958 (bVert ? &m_pVertScrollBar : &m_pHorzScrollBar)->reset(pScrollBar); | 941 (bVert ? &m_pVertScrollBar : &m_pHorzScrollBar)->reset(pScrollBar); |
| 959 } | 942 } |
| 960 void CFWL_ListBoxImp::SortItem() {} | 943 |
| 961 FX_BOOL CFWL_ListBoxImp::IsShowScrollBar(FX_BOOL bVert) { | 944 FX_BOOL CFWL_ListBoxImp::IsShowScrollBar(FX_BOOL bVert) { |
| 962 IFWL_ScrollBar* pScrollbar = | 945 IFWL_ScrollBar* pScrollbar = |
| 963 bVert ? m_pVertScrollBar.get() : m_pHorzScrollBar.get(); | 946 bVert ? m_pVertScrollBar.get() : m_pHorzScrollBar.get(); |
| 964 if (!pScrollbar || (pScrollbar->GetStates() & FWL_WGTSTATE_Invisible)) { | 947 if (!pScrollbar || (pScrollbar->GetStates() & FWL_WGTSTATE_Invisible)) { |
| 965 return FALSE; | 948 return FALSE; |
| 966 } | 949 } |
| 967 return !(m_pProperties->m_dwStyleExes & | 950 return !(m_pProperties->m_dwStyleExes & |
| 968 FWL_STYLEEXT_LTB_ShowScrollBarFocus) || | 951 FWL_STYLEEXT_LTB_ShowScrollBarFocus) || |
| 969 (m_pProperties->m_dwStates & FWL_WGTSTATE_Focused); | 952 (m_pProperties->m_dwStates & FWL_WGTSTATE_Focused); |
| 970 } | 953 } |
| 971 void CFWL_ListBoxImp::ProcessSelChanged() { | 954 void CFWL_ListBoxImp::ProcessSelChanged() { |
| 972 CFWL_EvtLtbSelChanged selEvent; | 955 CFWL_EvtLtbSelChanged selEvent; |
| 973 selEvent.m_pSrcTarget = m_pInterface; | 956 selEvent.m_pSrcTarget = m_pInterface; |
| 974 CFX_Int32Array arrSels; | 957 CFX_Int32Array arrSels; |
| 975 int32_t iCount = CountSelItems(); | 958 int32_t iCount = CountSelItems(); |
| 976 for (int32_t i = 0; i < iCount; i++) { | 959 for (int32_t i = 0; i < iCount; i++) { |
| 977 FWL_HLISTITEM item = GetSelItem(i); | 960 FWL_HLISTITEM item = GetSelItem(i); |
| 978 if (item == NULL) { | 961 if (item == NULL) { |
| 979 continue; | 962 continue; |
| 980 } | 963 } |
| 981 selEvent.iarraySels.Add(i); | 964 selEvent.iarraySels.Add(i); |
| 982 } | 965 } |
| 983 DispatchEvent(&selEvent); | 966 DispatchEvent(&selEvent); |
| 984 } | 967 } |
| 985 | 968 |
| 986 CFWL_ListBoxImpDelegate::CFWL_ListBoxImpDelegate(CFWL_ListBoxImp* pOwner) | 969 CFWL_ListBoxImpDelegate::CFWL_ListBoxImpDelegate(CFWL_ListBoxImp* pOwner) |
| 987 : m_pOwner(pOwner) {} | 970 : m_pOwner(pOwner) {} |
| 988 | 971 |
| 989 int32_t CFWL_ListBoxImpDelegate::OnProcessMessage(CFWL_Message* pMessage) { | 972 void CFWL_ListBoxImpDelegate::OnProcessMessage(CFWL_Message* pMessage) { |
| 990 if (!pMessage) | 973 if (!pMessage) |
| 991 return 0; | 974 return; |
| 992 if (!m_pOwner->IsEnabled()) | 975 if (!m_pOwner->IsEnabled()) |
| 993 return 1; | 976 return; |
| 994 | 977 |
| 995 CFWL_MessageType dwMsgCode = pMessage->GetClassID(); | 978 CFWL_MessageType dwMsgCode = pMessage->GetClassID(); |
| 996 int32_t iRet = 1; | |
| 997 switch (dwMsgCode) { | 979 switch (dwMsgCode) { |
| 998 case CFWL_MessageType::SetFocus: { | 980 case CFWL_MessageType::SetFocus: { |
| 999 OnFocusChanged(pMessage, TRUE); | 981 OnFocusChanged(pMessage, TRUE); |
| 1000 break; | 982 break; |
| 1001 } | 983 } |
| 1002 case CFWL_MessageType::KillFocus: { | 984 case CFWL_MessageType::KillFocus: { |
| 1003 OnFocusChanged(pMessage, FALSE); | 985 OnFocusChanged(pMessage, FALSE); |
| 1004 break; | 986 break; |
| 1005 } | 987 } |
| 1006 case CFWL_MessageType::Mouse: { | 988 case CFWL_MessageType::Mouse: { |
| (...skipping 16 matching lines...) Expand all Loading... |
| 1023 OnMouseWheel(static_cast<CFWL_MsgMouseWheel*>(pMessage)); | 1005 OnMouseWheel(static_cast<CFWL_MsgMouseWheel*>(pMessage)); |
| 1024 break; | 1006 break; |
| 1025 } | 1007 } |
| 1026 case CFWL_MessageType::Key: { | 1008 case CFWL_MessageType::Key: { |
| 1027 CFWL_MsgKey* pMsg = static_cast<CFWL_MsgKey*>(pMessage); | 1009 CFWL_MsgKey* pMsg = static_cast<CFWL_MsgKey*>(pMessage); |
| 1028 if (pMsg->m_dwCmd == FWL_KeyCommand::KeyDown) | 1010 if (pMsg->m_dwCmd == FWL_KeyCommand::KeyDown) |
| 1029 OnKeyDown(pMsg); | 1011 OnKeyDown(pMsg); |
| 1030 break; | 1012 break; |
| 1031 } | 1013 } |
| 1032 default: { | 1014 default: { |
| 1033 iRet = 0; | |
| 1034 break; | 1015 break; |
| 1035 } | 1016 } |
| 1036 } | 1017 } |
| 1037 CFWL_WidgetImpDelegate::OnProcessMessage(pMessage); | 1018 CFWL_WidgetImpDelegate::OnProcessMessage(pMessage); |
| 1038 return iRet; | |
| 1039 } | 1019 } |
| 1040 | 1020 |
| 1041 FWL_ERR CFWL_ListBoxImpDelegate::OnProcessEvent(CFWL_Event* pEvent) { | 1021 void CFWL_ListBoxImpDelegate::OnProcessEvent(CFWL_Event* pEvent) { |
| 1042 if (!pEvent) | 1022 if (!pEvent) |
| 1043 return FWL_ERR_Indefinite; | 1023 return; |
| 1044 if (pEvent->GetClassID() != CFWL_EventType::Scroll) | 1024 if (pEvent->GetClassID() != CFWL_EventType::Scroll) |
| 1045 return FWL_ERR_Succeeded; | 1025 return; |
| 1046 | 1026 |
| 1047 IFWL_Widget* pSrcTarget = pEvent->m_pSrcTarget; | 1027 IFWL_Widget* pSrcTarget = pEvent->m_pSrcTarget; |
| 1048 if ((pSrcTarget == m_pOwner->m_pVertScrollBar.get() && | 1028 if ((pSrcTarget == m_pOwner->m_pVertScrollBar.get() && |
| 1049 m_pOwner->m_pVertScrollBar) || | 1029 m_pOwner->m_pVertScrollBar) || |
| 1050 (pSrcTarget == m_pOwner->m_pHorzScrollBar.get() && | 1030 (pSrcTarget == m_pOwner->m_pHorzScrollBar.get() && |
| 1051 m_pOwner->m_pHorzScrollBar)) { | 1031 m_pOwner->m_pHorzScrollBar)) { |
| 1052 CFWL_EvtScroll* pScrollEvent = static_cast<CFWL_EvtScroll*>(pEvent); | 1032 CFWL_EvtScroll* pScrollEvent = static_cast<CFWL_EvtScroll*>(pEvent); |
| 1053 OnScroll(static_cast<IFWL_ScrollBar*>(pSrcTarget), | 1033 OnScroll(static_cast<IFWL_ScrollBar*>(pSrcTarget), |
| 1054 pScrollEvent->m_iScrollCode, pScrollEvent->m_fPos); | 1034 pScrollEvent->m_iScrollCode, pScrollEvent->m_fPos); |
| 1055 } | 1035 } |
| 1056 return FWL_ERR_Succeeded; | |
| 1057 } | 1036 } |
| 1058 | 1037 |
| 1059 FWL_ERR CFWL_ListBoxImpDelegate::OnDrawWidget(CFX_Graphics* pGraphics, | 1038 void CFWL_ListBoxImpDelegate::OnDrawWidget(CFX_Graphics* pGraphics, |
| 1060 const CFX_Matrix* pMatrix) { | 1039 const CFX_Matrix* pMatrix) { |
| 1061 return m_pOwner->DrawWidget(pGraphics, pMatrix); | 1040 m_pOwner->DrawWidget(pGraphics, pMatrix); |
| 1062 } | 1041 } |
| 1042 |
| 1063 void CFWL_ListBoxImpDelegate::OnFocusChanged(CFWL_Message* pMsg, FX_BOOL bSet) { | 1043 void CFWL_ListBoxImpDelegate::OnFocusChanged(CFWL_Message* pMsg, FX_BOOL bSet) { |
| 1064 if (m_pOwner->GetStylesEx() & FWL_STYLEEXT_LTB_ShowScrollBarFocus) { | 1044 if (m_pOwner->GetStylesEx() & FWL_STYLEEXT_LTB_ShowScrollBarFocus) { |
| 1065 if (m_pOwner->m_pVertScrollBar) { | 1045 if (m_pOwner->m_pVertScrollBar) { |
| 1066 m_pOwner->m_pVertScrollBar->SetStates(FWL_WGTSTATE_Invisible, !bSet); | 1046 m_pOwner->m_pVertScrollBar->SetStates(FWL_WGTSTATE_Invisible, !bSet); |
| 1067 } | 1047 } |
| 1068 if (m_pOwner->m_pHorzScrollBar) { | 1048 if (m_pOwner->m_pHorzScrollBar) { |
| 1069 m_pOwner->m_pHorzScrollBar->SetStates(FWL_WGTSTATE_Invisible, !bSet); | 1049 m_pOwner->m_pHorzScrollBar->SetStates(FWL_WGTSTATE_Invisible, !bSet); |
| 1070 } | 1050 } |
| 1071 } | 1051 } |
| 1072 if (bSet) { | 1052 if (bSet) { |
| (...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1246 pScrollBar->SetTrackPos(fPos); | 1226 pScrollBar->SetTrackPos(fPos); |
| 1247 m_pOwner->Repaint(&m_pOwner->m_rtClient); | 1227 m_pOwner->Repaint(&m_pOwner->m_rtClient); |
| 1248 } | 1228 } |
| 1249 return TRUE; | 1229 return TRUE; |
| 1250 } | 1230 } |
| 1251 void CFWL_ListBoxImpDelegate::DispatchSelChangedEv() { | 1231 void CFWL_ListBoxImpDelegate::DispatchSelChangedEv() { |
| 1252 CFWL_EvtLtbSelChanged ev; | 1232 CFWL_EvtLtbSelChanged ev; |
| 1253 ev.m_pSrcTarget = m_pOwner->m_pInterface; | 1233 ev.m_pSrcTarget = m_pOwner->m_pInterface; |
| 1254 m_pOwner->DispatchEvent(&ev); | 1234 m_pOwner->DispatchEvent(&ev); |
| 1255 } | 1235 } |
| OLD | NEW |