Chromium Code Reviews| 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 |
| 66 FWL_Error IFWL_ListBox::Sort(IFWL_ListBoxCompare* pCom) { | |
| 65 return static_cast<CFWL_ListBoxImp*>(GetImpl())->Sort(pCom); | 67 return static_cast<CFWL_ListBoxImp*>(GetImpl())->Sort(pCom); |
| 66 } | 68 } |
| 67 | 69 |
| 68 CFWL_ListBoxImp::CFWL_ListBoxImp(const CFWL_WidgetImpProperties& properties, | 70 CFWL_ListBoxImp::CFWL_ListBoxImp(const CFWL_WidgetImpProperties& properties, |
| 69 IFWL_Widget* pOuter) | 71 IFWL_Widget* pOuter) |
| 70 : CFWL_WidgetImp(properties, pOuter), | 72 : CFWL_WidgetImp(properties, pOuter), |
| 71 m_dwTTOStyles(0), | 73 m_dwTTOStyles(0), |
| 72 m_iTTOAligns(0), | 74 m_iTTOAligns(0), |
| 73 m_hAnchor(NULL), | 75 m_hAnchor(NULL), |
| 74 m_fScorllBarWidth(0), | 76 m_fScorllBarWidth(0), |
| 75 m_bLButtonDown(FALSE), | 77 m_bLButtonDown(FALSE), |
| 76 m_pScrollBarTP(NULL) { | 78 m_pScrollBarTP(NULL) { |
| 77 m_rtClient.Reset(); | 79 m_rtClient.Reset(); |
| 78 m_rtConent.Reset(); | 80 m_rtConent.Reset(); |
| 79 m_rtStatic.Reset(); | 81 m_rtStatic.Reset(); |
| 80 } | 82 } |
| 81 CFWL_ListBoxImp::~CFWL_ListBoxImp() {} | 83 CFWL_ListBoxImp::~CFWL_ListBoxImp() {} |
| 82 FWL_ERR CFWL_ListBoxImp::GetClassName(CFX_WideString& wsClass) const { | 84 FWL_Error CFWL_ListBoxImp::GetClassName(CFX_WideString& wsClass) const { |
| 83 wsClass = FWL_CLASS_ListBox; | 85 wsClass = FWL_CLASS_ListBox; |
| 84 return FWL_ERR_Succeeded; | 86 return FWL_Error::Succeeded; |
| 85 } | 87 } |
| 86 uint32_t CFWL_ListBoxImp::GetClassID() const { | 88 uint32_t CFWL_ListBoxImp::GetClassID() const { |
| 87 return FWL_CLASSHASH_ListBox; | 89 return FWL_CLASSHASH_ListBox; |
| 88 } | 90 } |
| 89 FWL_ERR CFWL_ListBoxImp::Initialize() { | 91 FWL_Error CFWL_ListBoxImp::Initialize() { |
| 90 if (CFWL_WidgetImp::Initialize() != FWL_ERR_Succeeded) | 92 if (CFWL_WidgetImp::Initialize() != FWL_Error::Succeeded) |
| 91 return FWL_ERR_Indefinite; | 93 return FWL_Error::Indefinite; |
| 92 m_pDelegate = new CFWL_ListBoxImpDelegate(this); | 94 m_pDelegate = new CFWL_ListBoxImpDelegate(this); |
| 93 return FWL_ERR_Succeeded; | 95 return FWL_Error::Succeeded; |
| 94 } | 96 } |
| 95 FWL_ERR CFWL_ListBoxImp::Finalize() { | 97 FWL_Error CFWL_ListBoxImp::Finalize() { |
| 96 if (m_pVertScrollBar) { | 98 if (m_pVertScrollBar) { |
| 97 m_pVertScrollBar->Finalize(); | 99 m_pVertScrollBar->Finalize(); |
| 98 } | 100 } |
| 99 if (m_pHorzScrollBar) { | 101 if (m_pHorzScrollBar) { |
| 100 m_pHorzScrollBar->Finalize(); | 102 m_pHorzScrollBar->Finalize(); |
| 101 } | 103 } |
| 102 delete m_pDelegate; | 104 delete m_pDelegate; |
| 103 m_pDelegate = nullptr; | 105 m_pDelegate = nullptr; |
| 104 return CFWL_WidgetImp::Finalize(); | 106 return CFWL_WidgetImp::Finalize(); |
| 105 } | 107 } |
| 106 FWL_ERR CFWL_ListBoxImp::GetWidgetRect(CFX_RectF& rect, FX_BOOL bAutoSize) { | 108 FWL_Error CFWL_ListBoxImp::GetWidgetRect(CFX_RectF& rect, FX_BOOL bAutoSize) { |
| 107 if (bAutoSize) { | 109 if (bAutoSize) { |
| 108 rect.Set(0, 0, 0, 0); | 110 rect.Set(0, 0, 0, 0); |
| 109 if (!m_pProperties->m_pThemeProvider) { | 111 if (!m_pProperties->m_pThemeProvider) { |
| 110 m_pProperties->m_pThemeProvider = GetAvailableTheme(); | 112 m_pProperties->m_pThemeProvider = GetAvailableTheme(); |
| 111 } | 113 } |
| 112 CFX_SizeF fs = CalcSize(TRUE); | 114 CFX_SizeF fs = CalcSize(TRUE); |
| 113 rect.Set(0, 0, fs.x, fs.y); | 115 rect.Set(0, 0, fs.x, fs.y); |
| 114 CFWL_WidgetImp::GetWidgetRect(rect, TRUE); | 116 CFWL_WidgetImp::GetWidgetRect(rect, TRUE); |
| 115 } else { | 117 } else { |
| 116 rect = m_pProperties->m_rtWidget; | 118 rect = m_pProperties->m_rtWidget; |
| 117 } | 119 } |
| 118 return FWL_ERR_Succeeded; | 120 return FWL_Error::Succeeded; |
| 119 } | 121 } |
| 120 FWL_ERR CFWL_ListBoxImp::Update() { | 122 FWL_Error CFWL_ListBoxImp::Update() { |
| 121 if (IsLocked()) { | 123 if (IsLocked()) { |
| 122 return FWL_ERR_Indefinite; | 124 return FWL_Error::Indefinite; |
| 123 } | 125 } |
| 124 if (!m_pProperties->m_pThemeProvider) { | 126 if (!m_pProperties->m_pThemeProvider) { |
| 125 m_pProperties->m_pThemeProvider = GetAvailableTheme(); | 127 m_pProperties->m_pThemeProvider = GetAvailableTheme(); |
| 126 } | 128 } |
| 127 m_iTTOAligns = FDE_TTOALIGNMENT_Center; | 129 m_iTTOAligns = FDE_TTOALIGNMENT_Center; |
| 128 switch (m_pProperties->m_dwStyleExes & FWL_STYLEEXT_LTB_AlignMask) { | 130 switch (m_pProperties->m_dwStyleExes & FWL_STYLEEXT_LTB_AlignMask) { |
| 129 case FWL_STYLEEXT_LTB_LeftAlign: { | 131 case FWL_STYLEEXT_LTB_LeftAlign: { |
| 130 m_iTTOAligns = FDE_TTOALIGNMENT_CenterLeft; | 132 m_iTTOAligns = FDE_TTOALIGNMENT_CenterLeft; |
| 131 break; | 133 break; |
| 132 } | 134 } |
| 133 case FWL_STYLEEXT_LTB_RightAlign: { | 135 case FWL_STYLEEXT_LTB_RightAlign: { |
| 134 m_iTTOAligns = FDE_TTOALIGNMENT_CenterRight; | 136 m_iTTOAligns = FDE_TTOALIGNMENT_CenterRight; |
| 135 break; | 137 break; |
| 136 } | 138 } |
| 137 case FWL_STYLEEXT_LTB_CenterAlign: | 139 case FWL_STYLEEXT_LTB_CenterAlign: |
| 138 default: { m_iTTOAligns = FDE_TTOALIGNMENT_Center; } | 140 default: { m_iTTOAligns = FDE_TTOALIGNMENT_Center; } |
| 139 } | 141 } |
| 140 if (m_pProperties->m_dwStyleExes & FWL_WGTSTYLE_RTLReading) { | 142 if (m_pProperties->m_dwStyleExes & FWL_WGTSTYLE_RTLReading) { |
| 141 m_dwTTOStyles |= FDE_TTOSTYLE_RTL; | 143 m_dwTTOStyles |= FDE_TTOSTYLE_RTL; |
| 142 } | 144 } |
| 143 m_dwTTOStyles |= FDE_TTOSTYLE_SingleLine; | 145 m_dwTTOStyles |= FDE_TTOSTYLE_SingleLine; |
| 144 m_fScorllBarWidth = GetScrollWidth(); | 146 m_fScorllBarWidth = GetScrollWidth(); |
| 145 SortItem(); | 147 SortItem(); |
| 146 CalcSize(); | 148 CalcSize(); |
| 147 return FWL_ERR_Succeeded; | 149 return FWL_Error::Succeeded; |
| 148 } | 150 } |
| 149 uint32_t CFWL_ListBoxImp::HitTest(FX_FLOAT fx, FX_FLOAT fy) { | 151 uint32_t CFWL_ListBoxImp::HitTest(FX_FLOAT fx, FX_FLOAT fy) { |
| 150 if (IsShowScrollBar(FALSE)) { | 152 if (IsShowScrollBar(FALSE)) { |
| 151 CFX_RectF rect; | 153 CFX_RectF rect; |
| 152 m_pHorzScrollBar->GetWidgetRect(rect); | 154 m_pHorzScrollBar->GetWidgetRect(rect); |
| 153 if (rect.Contains(fx, fy)) { | 155 if (rect.Contains(fx, fy)) { |
| 154 return FWL_WGTHITTEST_HScrollBar; | 156 return FWL_WGTHITTEST_HScrollBar; |
| 155 } | 157 } |
| 156 } | 158 } |
| 157 if (IsShowScrollBar(TRUE)) { | 159 if (IsShowScrollBar(TRUE)) { |
| 158 CFX_RectF rect; | 160 CFX_RectF rect; |
| 159 m_pVertScrollBar->GetWidgetRect(rect); | 161 m_pVertScrollBar->GetWidgetRect(rect); |
| 160 if (rect.Contains(fx, fy)) { | 162 if (rect.Contains(fx, fy)) { |
| 161 return FWL_WGTHITTEST_VScrollBar; | 163 return FWL_WGTHITTEST_VScrollBar; |
| 162 } | 164 } |
| 163 } | 165 } |
| 164 if (m_rtClient.Contains(fx, fy)) { | 166 if (m_rtClient.Contains(fx, fy)) { |
| 165 return FWL_WGTHITTEST_Client; | 167 return FWL_WGTHITTEST_Client; |
| 166 } | 168 } |
| 167 return FWL_WGTHITTEST_Unknown; | 169 return FWL_WGTHITTEST_Unknown; |
| 168 } | 170 } |
| 169 FWL_ERR CFWL_ListBoxImp::DrawWidget(CFX_Graphics* pGraphics, | 171 FWL_Error CFWL_ListBoxImp::DrawWidget(CFX_Graphics* pGraphics, |
| 170 const CFX_Matrix* pMatrix) { | 172 const CFX_Matrix* pMatrix) { |
| 171 if (!pGraphics) | 173 if (!pGraphics) |
| 172 return FWL_ERR_Indefinite; | 174 return FWL_Error::Indefinite; |
| 173 if (!m_pProperties->m_pThemeProvider) | 175 if (!m_pProperties->m_pThemeProvider) |
| 174 return FWL_ERR_Indefinite; | 176 return FWL_Error::Indefinite; |
| 175 IFWL_ThemeProvider* pTheme = m_pProperties->m_pThemeProvider; | 177 IFWL_ThemeProvider* pTheme = m_pProperties->m_pThemeProvider; |
| 176 pGraphics->SaveGraphState(); | 178 pGraphics->SaveGraphState(); |
| 177 if (HasBorder()) { | 179 if (HasBorder()) { |
| 178 DrawBorder(pGraphics, CFWL_Part::Border, pTheme, pMatrix); | 180 DrawBorder(pGraphics, CFWL_Part::Border, pTheme, pMatrix); |
| 179 } | 181 } |
| 180 if (HasEdge()) { | 182 if (HasEdge()) { |
| 181 DrawEdge(pGraphics, CFWL_Part::Edge, pTheme, pMatrix); | 183 DrawEdge(pGraphics, CFWL_Part::Edge, pTheme, pMatrix); |
| 182 } | 184 } |
| 183 CFX_RectF rtClip(m_rtConent); | 185 CFX_RectF rtClip(m_rtConent); |
| 184 if (IsShowScrollBar(FALSE)) { | 186 if (IsShowScrollBar(FALSE)) { |
| 185 rtClip.height -= m_fScorllBarWidth; | 187 rtClip.height -= m_fScorllBarWidth; |
| 186 } | 188 } |
| 187 if (IsShowScrollBar(TRUE)) { | 189 if (IsShowScrollBar(TRUE)) { |
| 188 rtClip.width -= m_fScorllBarWidth; | 190 rtClip.width -= m_fScorllBarWidth; |
| 189 } | 191 } |
| 190 if (pMatrix) { | 192 if (pMatrix) { |
| 191 pMatrix->TransformRect(rtClip); | 193 pMatrix->TransformRect(rtClip); |
| 192 } | 194 } |
| 193 pGraphics->SetClipRect(rtClip); | 195 pGraphics->SetClipRect(rtClip); |
| 194 if ((m_pProperties->m_dwStyles & FWL_WGTSTYLE_NoBackground) == 0) { | 196 if ((m_pProperties->m_dwStyles & FWL_WGTSTYLE_NoBackground) == 0) { |
| 195 DrawBkground(pGraphics, pTheme, pMatrix); | 197 DrawBkground(pGraphics, pTheme, pMatrix); |
| 196 } | 198 } |
| 197 DrawItems(pGraphics, pTheme, pMatrix); | 199 DrawItems(pGraphics, pTheme, pMatrix); |
| 198 pGraphics->RestoreGraphState(); | 200 pGraphics->RestoreGraphState(); |
| 199 return FWL_ERR_Succeeded; | 201 return FWL_Error::Succeeded; |
| 200 } | 202 } |
| 201 FWL_ERR CFWL_ListBoxImp::SetThemeProvider(IFWL_ThemeProvider* pThemeProvider) { | 203 FWL_Error CFWL_ListBoxImp::SetThemeProvider( |
| 204 IFWL_ThemeProvider* pThemeProvider) { | |
| 202 if (!pThemeProvider) | 205 if (!pThemeProvider) |
| 203 return FWL_ERR_Indefinite; | 206 return FWL_Error::Indefinite; |
| 204 if (!pThemeProvider->IsValidWidget(m_pInterface)) { | 207 if (!pThemeProvider->IsValidWidget(m_pInterface)) { |
| 205 m_pScrollBarTP = pThemeProvider; | 208 m_pScrollBarTP = pThemeProvider; |
| 206 return FWL_ERR_Succeeded; | 209 return FWL_Error::Succeeded; |
| 207 } | 210 } |
| 208 m_pProperties->m_pThemeProvider = pThemeProvider; | 211 m_pProperties->m_pThemeProvider = pThemeProvider; |
| 209 return FWL_ERR_Succeeded; | 212 return FWL_Error::Succeeded; |
| 210 } | 213 } |
| 211 int32_t CFWL_ListBoxImp::CountSelItems() { | 214 int32_t CFWL_ListBoxImp::CountSelItems() { |
| 212 if (!m_pProperties->m_pDataProvider) | 215 if (!m_pProperties->m_pDataProvider) |
| 213 return 0; | 216 return 0; |
| 214 int32_t iRet = 0; | 217 int32_t iRet = 0; |
| 215 IFWL_ListBoxDP* pData = | 218 IFWL_ListBoxDP* pData = |
| 216 static_cast<IFWL_ListBoxDP*>(m_pProperties->m_pDataProvider); | 219 static_cast<IFWL_ListBoxDP*>(m_pProperties->m_pDataProvider); |
| 217 int32_t iCount = pData->CountItems(m_pInterface); | 220 int32_t iCount = pData->CountItems(m_pInterface); |
| 218 for (int32_t i = 0; i < iCount; i++) { | 221 for (int32_t i = 0; i < iCount; i++) { |
| 219 FWL_HLISTITEM hItem = pData->GetItem(m_pInterface, i); | 222 FWL_HLISTITEM hItem = pData->GetItem(m_pInterface, i); |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 266 if (dwStyle & FWL_ITEMSTATE_LTB_Selected) { | 269 if (dwStyle & FWL_ITEMSTATE_LTB_Selected) { |
| 267 if (index == nIndex) { | 270 if (index == nIndex) { |
| 268 return i; | 271 return i; |
| 269 } else { | 272 } else { |
| 270 index++; | 273 index++; |
| 271 } | 274 } |
| 272 } | 275 } |
| 273 } | 276 } |
| 274 return -1; | 277 return -1; |
| 275 } | 278 } |
| 276 FWL_ERR CFWL_ListBoxImp::SetSelItem(FWL_HLISTITEM hItem, FX_BOOL bSelect) { | 279 FWL_Error CFWL_ListBoxImp::SetSelItem(FWL_HLISTITEM hItem, FX_BOOL bSelect) { |
| 277 if (!m_pProperties->m_pDataProvider) | 280 if (!m_pProperties->m_pDataProvider) |
| 278 return FWL_ERR_Indefinite; | 281 return FWL_Error::Indefinite; |
| 279 if (!hItem) { | 282 if (!hItem) { |
| 280 if (bSelect) { | 283 if (bSelect) { |
| 281 SelectAll(); | 284 SelectAll(); |
| 282 } else { | 285 } else { |
| 283 ClearSelection(); | 286 ClearSelection(); |
| 284 SetFocusItem(NULL); | 287 SetFocusItem(NULL); |
| 285 } | 288 } |
| 286 return FWL_ERR_Indefinite; | 289 return FWL_Error::Indefinite; |
| 287 } | 290 } |
| 288 if (m_pProperties->m_dwStyleExes & FWL_STYLEEXT_LTB_MultiSelection) { | 291 if (m_pProperties->m_dwStyleExes & FWL_STYLEEXT_LTB_MultiSelection) { |
| 289 SetSelectionDirect(hItem, bSelect); | 292 SetSelectionDirect(hItem, bSelect); |
| 290 } else { | 293 } else { |
| 291 SetSelection(hItem, hItem, bSelect); | 294 SetSelection(hItem, hItem, bSelect); |
| 292 } | 295 } |
| 293 return FWL_ERR_Succeeded; | 296 return FWL_Error::Succeeded; |
| 294 } | 297 } |
| 295 FWL_ERR CFWL_ListBoxImp::GetItemText(FWL_HLISTITEM hItem, | 298 FWL_Error CFWL_ListBoxImp::GetItemText(FWL_HLISTITEM hItem, |
| 296 CFX_WideString& wsText) { | 299 CFX_WideString& wsText) { |
| 297 if (!m_pProperties->m_pDataProvider) | 300 if (!m_pProperties->m_pDataProvider) |
| 298 return FWL_ERR_Indefinite; | 301 return FWL_Error::Indefinite; |
| 299 IFWL_ListBoxDP* pData = | 302 IFWL_ListBoxDP* pData = |
| 300 static_cast<IFWL_ListBoxDP*>(m_pProperties->m_pDataProvider); | 303 static_cast<IFWL_ListBoxDP*>(m_pProperties->m_pDataProvider); |
| 301 if (!hItem) | 304 if (!hItem) |
| 302 return FWL_ERR_Indefinite; | 305 return FWL_Error::Indefinite; |
| 303 pData->GetItemText(m_pInterface, hItem, wsText); | 306 pData->GetItemText(m_pInterface, hItem, wsText); |
| 304 return FWL_ERR_Succeeded; | 307 return FWL_Error::Succeeded; |
| 305 } | 308 } |
| 306 FWL_ERR CFWL_ListBoxImp::GetScrollPos(FX_FLOAT& fPos, FX_BOOL bVert) { | 309 |
| 310 FWL_Error CFWL_ListBoxImp::GetScrollPos(FX_FLOAT& fPos, FX_BOOL bVert) { | |
| 307 if ((bVert && IsShowScrollBar(TRUE)) || (!bVert && IsShowScrollBar(FALSE))) { | 311 if ((bVert && IsShowScrollBar(TRUE)) || (!bVert && IsShowScrollBar(FALSE))) { |
| 308 IFWL_ScrollBar* pScrollBar = | 312 IFWL_ScrollBar* pScrollBar = |
| 309 bVert ? m_pVertScrollBar.get() : m_pHorzScrollBar.get(); | 313 bVert ? m_pVertScrollBar.get() : m_pHorzScrollBar.get(); |
| 310 fPos = pScrollBar->GetPos(); | 314 fPos = pScrollBar->GetPos(); |
| 311 return FWL_ERR_Succeeded; | 315 return FWL_Error::Succeeded; |
| 312 } | 316 } |
| 313 return FWL_ERR_Indefinite; | 317 return FWL_Error::Indefinite; |
| 314 } | 318 } |
| 315 FWL_ERR* CFWL_ListBoxImp::Sort(IFWL_ListBoxCompare* pCom) { | 319 |
|
Tom Sepez
2016/05/03 18:19:41
nice. presumably success == 0, and 0 is a valid va
dsinclair
2016/05/03 19:29:51
Looks like it can actually just be deleted.
| |
| 320 FWL_Error CFWL_ListBoxImp::Sort(IFWL_ListBoxCompare* pCom) { | |
| 316 FWL_HLISTITEM hTemp; | 321 FWL_HLISTITEM hTemp; |
| 317 IFWL_ListBoxDP* pData = | 322 IFWL_ListBoxDP* pData = |
| 318 static_cast<IFWL_ListBoxDP*>(m_pProperties->m_pDataProvider); | 323 static_cast<IFWL_ListBoxDP*>(m_pProperties->m_pDataProvider); |
| 319 int32_t sz = pData->CountItems(m_pInterface); | 324 int32_t sz = pData->CountItems(m_pInterface); |
| 320 for (int32_t i = 0; i < sz - 1; i++) { | 325 for (int32_t i = 0; i < sz - 1; i++) { |
| 321 for (int32_t j = i + 1; j < sz; j++) { | 326 for (int32_t j = i + 1; j < sz; j++) { |
| 322 if (pCom->Compare(pData->GetItem(m_pInterface, i), | 327 if (pCom->Compare(pData->GetItem(m_pInterface, i), |
| 323 pData->GetItem(m_pInterface, j)) > 0) { | 328 pData->GetItem(m_pInterface, j)) > 0) { |
| 324 hTemp = pData->GetItem(m_pInterface, i); | 329 hTemp = pData->GetItem(m_pInterface, i); |
| 325 pData->SetItemIndex(m_pInterface, pData->GetItem(m_pInterface, j), i); | 330 pData->SetItemIndex(m_pInterface, pData->GetItem(m_pInterface, j), i); |
| 326 pData->SetItemIndex(m_pInterface, hTemp, j); | 331 pData->SetItemIndex(m_pInterface, hTemp, j); |
| 327 } | 332 } |
| 328 } | 333 } |
| 329 } | 334 } |
| 330 return FWL_ERR_Succeeded; | 335 return FWL_Error::Succeeded; |
| 331 } | 336 } |
| 337 | |
| 332 FWL_HLISTITEM CFWL_ListBoxImp::GetItem(FWL_HLISTITEM hItem, | 338 FWL_HLISTITEM CFWL_ListBoxImp::GetItem(FWL_HLISTITEM hItem, |
| 333 uint32_t dwKeyCode) { | 339 uint32_t dwKeyCode) { |
| 334 FWL_HLISTITEM hRet = NULL; | 340 FWL_HLISTITEM hRet = NULL; |
| 335 switch (dwKeyCode) { | 341 switch (dwKeyCode) { |
| 336 case FWL_VKEY_Up: | 342 case FWL_VKEY_Up: |
| 337 case FWL_VKEY_Down: | 343 case FWL_VKEY_Down: |
| 338 case FWL_VKEY_Home: | 344 case FWL_VKEY_Home: |
| 339 case FWL_VKEY_End: { | 345 case FWL_VKEY_End: { |
| 340 const bool bUp = dwKeyCode == FWL_VKEY_Up; | 346 const bool bUp = dwKeyCode == FWL_VKEY_Up; |
| 341 const bool bDown = dwKeyCode == FWL_VKEY_Down; | 347 const bool bDown = dwKeyCode == FWL_VKEY_Down; |
| (...skipping 692 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1034 } | 1040 } |
| 1035 default: { | 1041 default: { |
| 1036 iRet = 0; | 1042 iRet = 0; |
| 1037 break; | 1043 break; |
| 1038 } | 1044 } |
| 1039 } | 1045 } |
| 1040 CFWL_WidgetImpDelegate::OnProcessMessage(pMessage); | 1046 CFWL_WidgetImpDelegate::OnProcessMessage(pMessage); |
| 1041 return iRet; | 1047 return iRet; |
| 1042 } | 1048 } |
| 1043 | 1049 |
| 1044 FWL_ERR CFWL_ListBoxImpDelegate::OnProcessEvent(CFWL_Event* pEvent) { | 1050 FWL_Error CFWL_ListBoxImpDelegate::OnProcessEvent(CFWL_Event* pEvent) { |
| 1045 if (!pEvent) | 1051 if (!pEvent) |
| 1046 return FWL_ERR_Indefinite; | 1052 return FWL_Error::Indefinite; |
| 1047 if (pEvent->GetClassID() != CFWL_EventType::Scroll) | 1053 if (pEvent->GetClassID() != CFWL_EventType::Scroll) |
| 1048 return FWL_ERR_Succeeded; | 1054 return FWL_Error::Succeeded; |
| 1049 | 1055 |
| 1050 IFWL_Widget* pSrcTarget = pEvent->m_pSrcTarget; | 1056 IFWL_Widget* pSrcTarget = pEvent->m_pSrcTarget; |
| 1051 if ((pSrcTarget == m_pOwner->m_pVertScrollBar.get() && | 1057 if ((pSrcTarget == m_pOwner->m_pVertScrollBar.get() && |
| 1052 m_pOwner->m_pVertScrollBar) || | 1058 m_pOwner->m_pVertScrollBar) || |
| 1053 (pSrcTarget == m_pOwner->m_pHorzScrollBar.get() && | 1059 (pSrcTarget == m_pOwner->m_pHorzScrollBar.get() && |
| 1054 m_pOwner->m_pHorzScrollBar)) { | 1060 m_pOwner->m_pHorzScrollBar)) { |
| 1055 CFWL_EvtScroll* pScrollEvent = static_cast<CFWL_EvtScroll*>(pEvent); | 1061 CFWL_EvtScroll* pScrollEvent = static_cast<CFWL_EvtScroll*>(pEvent); |
| 1056 OnScroll(static_cast<IFWL_ScrollBar*>(pSrcTarget), | 1062 OnScroll(static_cast<IFWL_ScrollBar*>(pSrcTarget), |
| 1057 pScrollEvent->m_iScrollCode, pScrollEvent->m_fPos); | 1063 pScrollEvent->m_iScrollCode, pScrollEvent->m_fPos); |
| 1058 } | 1064 } |
| 1059 return FWL_ERR_Succeeded; | 1065 return FWL_Error::Succeeded; |
| 1060 } | 1066 } |
| 1061 | 1067 |
| 1062 FWL_ERR CFWL_ListBoxImpDelegate::OnDrawWidget(CFX_Graphics* pGraphics, | 1068 FWL_Error CFWL_ListBoxImpDelegate::OnDrawWidget(CFX_Graphics* pGraphics, |
| 1063 const CFX_Matrix* pMatrix) { | 1069 const CFX_Matrix* pMatrix) { |
| 1064 return m_pOwner->DrawWidget(pGraphics, pMatrix); | 1070 return m_pOwner->DrawWidget(pGraphics, pMatrix); |
| 1065 } | 1071 } |
| 1066 void CFWL_ListBoxImpDelegate::OnFocusChanged(CFWL_Message* pMsg, FX_BOOL bSet) { | 1072 void CFWL_ListBoxImpDelegate::OnFocusChanged(CFWL_Message* pMsg, FX_BOOL bSet) { |
| 1067 if (m_pOwner->GetStylesEx() & FWL_STYLEEXT_LTB_ShowScrollBarFocus) { | 1073 if (m_pOwner->GetStylesEx() & FWL_STYLEEXT_LTB_ShowScrollBarFocus) { |
| 1068 if (m_pOwner->m_pVertScrollBar) { | 1074 if (m_pOwner->m_pVertScrollBar) { |
| 1069 m_pOwner->m_pVertScrollBar->SetStates(FWL_WGTSTATE_Invisible, !bSet); | 1075 m_pOwner->m_pVertScrollBar->SetStates(FWL_WGTSTATE_Invisible, !bSet); |
| 1070 } | 1076 } |
| 1071 if (m_pOwner->m_pHorzScrollBar) { | 1077 if (m_pOwner->m_pHorzScrollBar) { |
| 1072 m_pOwner->m_pHorzScrollBar->SetStates(FWL_WGTSTATE_Invisible, !bSet); | 1078 m_pOwner->m_pHorzScrollBar->SetStates(FWL_WGTSTATE_Invisible, !bSet); |
| 1073 } | 1079 } |
| (...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1249 pScrollBar->SetTrackPos(fPos); | 1255 pScrollBar->SetTrackPos(fPos); |
| 1250 m_pOwner->Repaint(&m_pOwner->m_rtClient); | 1256 m_pOwner->Repaint(&m_pOwner->m_rtClient); |
| 1251 } | 1257 } |
| 1252 return TRUE; | 1258 return TRUE; |
| 1253 } | 1259 } |
| 1254 void CFWL_ListBoxImpDelegate::DispatchSelChangedEv() { | 1260 void CFWL_ListBoxImpDelegate::DispatchSelChangedEv() { |
| 1255 CFWL_EvtLtbSelChanged ev; | 1261 CFWL_EvtLtbSelChanged ev; |
| 1256 ev.m_pSrcTarget = m_pOwner->m_pInterface; | 1262 ev.m_pSrcTarget = m_pOwner->m_pInterface; |
| 1257 m_pOwner->DispatchEvent(&ev); | 1263 m_pOwner->DispatchEvent(&ev); |
| 1258 } | 1264 } |
| OLD | NEW |