| 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_listbox.h" | 7 #include "xfa/fwl/core/ifwl_listbox.h" |
| 8 | 8 |
| 9 #include "third_party/base/ptr_util.h" | 9 #include "third_party/base/ptr_util.h" |
| 10 #include "xfa/fde/tto/fde_textout.h" | 10 #include "xfa/fde/tto/fde_textout.h" |
| (...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 144 return FWL_Error::Succeeded; | 144 return FWL_Error::Succeeded; |
| 145 } | 145 } |
| 146 int32_t IFWL_ListBox::CountSelItems() { | 146 int32_t IFWL_ListBox::CountSelItems() { |
| 147 if (!m_pProperties->m_pDataProvider) | 147 if (!m_pProperties->m_pDataProvider) |
| 148 return 0; | 148 return 0; |
| 149 int32_t iRet = 0; | 149 int32_t iRet = 0; |
| 150 IFWL_ListBoxDP* pData = | 150 IFWL_ListBoxDP* pData = |
| 151 static_cast<IFWL_ListBoxDP*>(m_pProperties->m_pDataProvider); | 151 static_cast<IFWL_ListBoxDP*>(m_pProperties->m_pDataProvider); |
| 152 int32_t iCount = pData->CountItems(this); | 152 int32_t iCount = pData->CountItems(this); |
| 153 for (int32_t i = 0; i < iCount; i++) { | 153 for (int32_t i = 0; i < iCount; i++) { |
| 154 IFWL_ListItem* pItem = pData->GetItem(this, i); | 154 CFWL_ListItem* pItem = pData->GetItem(this, i); |
| 155 if (!pItem) { | 155 if (!pItem) { |
| 156 continue; | 156 continue; |
| 157 } | 157 } |
| 158 uint32_t dwStyle = pData->GetItemStyles(this, pItem); | 158 uint32_t dwStyle = pData->GetItemStyles(this, pItem); |
| 159 if (dwStyle & FWL_ITEMSTATE_LTB_Selected) { | 159 if (dwStyle & FWL_ITEMSTATE_LTB_Selected) { |
| 160 iRet++; | 160 iRet++; |
| 161 } | 161 } |
| 162 } | 162 } |
| 163 return iRet; | 163 return iRet; |
| 164 } | 164 } |
| 165 | 165 |
| 166 IFWL_ListItem* IFWL_ListBox::GetSelItem(int32_t nIndexSel) { | 166 CFWL_ListItem* IFWL_ListBox::GetSelItem(int32_t nIndexSel) { |
| 167 if (!m_pProperties->m_pDataProvider) | 167 if (!m_pProperties->m_pDataProvider) |
| 168 return nullptr; | 168 return nullptr; |
| 169 int32_t index = 0; | 169 int32_t index = 0; |
| 170 IFWL_ListBoxDP* pData = | 170 IFWL_ListBoxDP* pData = |
| 171 static_cast<IFWL_ListBoxDP*>(m_pProperties->m_pDataProvider); | 171 static_cast<IFWL_ListBoxDP*>(m_pProperties->m_pDataProvider); |
| 172 int32_t iCount = pData->CountItems(this); | 172 int32_t iCount = pData->CountItems(this); |
| 173 for (int32_t i = 0; i < iCount; i++) { | 173 for (int32_t i = 0; i < iCount; i++) { |
| 174 IFWL_ListItem* pItem = pData->GetItem(this, i); | 174 CFWL_ListItem* pItem = pData->GetItem(this, i); |
| 175 if (!pItem) { | 175 if (!pItem) { |
| 176 return nullptr; | 176 return nullptr; |
| 177 } | 177 } |
| 178 uint32_t dwStyle = pData->GetItemStyles(this, pItem); | 178 uint32_t dwStyle = pData->GetItemStyles(this, pItem); |
| 179 if (dwStyle & FWL_ITEMSTATE_LTB_Selected) { | 179 if (dwStyle & FWL_ITEMSTATE_LTB_Selected) { |
| 180 if (index == nIndexSel) { | 180 if (index == nIndexSel) { |
| 181 return pItem; | 181 return pItem; |
| 182 } else { | 182 } else { |
| 183 index++; | 183 index++; |
| 184 } | 184 } |
| 185 } | 185 } |
| 186 } | 186 } |
| 187 return nullptr; | 187 return nullptr; |
| 188 } | 188 } |
| 189 | 189 |
| 190 int32_t IFWL_ListBox::GetSelIndex(int32_t nIndex) { | 190 int32_t IFWL_ListBox::GetSelIndex(int32_t nIndex) { |
| 191 if (!m_pProperties->m_pDataProvider) | 191 if (!m_pProperties->m_pDataProvider) |
| 192 return -1; | 192 return -1; |
| 193 int32_t index = 0; | 193 int32_t index = 0; |
| 194 IFWL_ListBoxDP* pData = | 194 IFWL_ListBoxDP* pData = |
| 195 static_cast<IFWL_ListBoxDP*>(m_pProperties->m_pDataProvider); | 195 static_cast<IFWL_ListBoxDP*>(m_pProperties->m_pDataProvider); |
| 196 int32_t iCount = pData->CountItems(this); | 196 int32_t iCount = pData->CountItems(this); |
| 197 for (int32_t i = 0; i < iCount; i++) { | 197 for (int32_t i = 0; i < iCount; i++) { |
| 198 IFWL_ListItem* pItem = pData->GetItem(this, i); | 198 CFWL_ListItem* pItem = pData->GetItem(this, i); |
| 199 if (!pItem) { | 199 if (!pItem) { |
| 200 return -1; | 200 return -1; |
| 201 } | 201 } |
| 202 uint32_t dwStyle = pData->GetItemStyles(this, pItem); | 202 uint32_t dwStyle = pData->GetItemStyles(this, pItem); |
| 203 if (dwStyle & FWL_ITEMSTATE_LTB_Selected) { | 203 if (dwStyle & FWL_ITEMSTATE_LTB_Selected) { |
| 204 if (index == nIndex) { | 204 if (index == nIndex) { |
| 205 return i; | 205 return i; |
| 206 } else { | 206 } else { |
| 207 index++; | 207 index++; |
| 208 } | 208 } |
| 209 } | 209 } |
| 210 } | 210 } |
| 211 return -1; | 211 return -1; |
| 212 } | 212 } |
| 213 | 213 |
| 214 FWL_Error IFWL_ListBox::SetSelItem(IFWL_ListItem* pItem, bool bSelect) { | 214 FWL_Error IFWL_ListBox::SetSelItem(CFWL_ListItem* pItem, bool bSelect) { |
| 215 if (!m_pProperties->m_pDataProvider) | 215 if (!m_pProperties->m_pDataProvider) |
| 216 return FWL_Error::Indefinite; | 216 return FWL_Error::Indefinite; |
| 217 if (!pItem) { | 217 if (!pItem) { |
| 218 if (bSelect) { | 218 if (bSelect) { |
| 219 SelectAll(); | 219 SelectAll(); |
| 220 } else { | 220 } else { |
| 221 ClearSelection(); | 221 ClearSelection(); |
| 222 SetFocusItem(nullptr); | 222 SetFocusItem(nullptr); |
| 223 } | 223 } |
| 224 return FWL_Error::Indefinite; | 224 return FWL_Error::Indefinite; |
| 225 } | 225 } |
| 226 if (m_pProperties->m_dwStyleExes & FWL_STYLEEXT_LTB_MultiSelection) { | 226 if (m_pProperties->m_dwStyleExes & FWL_STYLEEXT_LTB_MultiSelection) { |
| 227 SetSelectionDirect(pItem, bSelect); | 227 SetSelectionDirect(pItem, bSelect); |
| 228 } else { | 228 } else { |
| 229 SetSelection(pItem, pItem, bSelect); | 229 SetSelection(pItem, pItem, bSelect); |
| 230 } | 230 } |
| 231 return FWL_Error::Succeeded; | 231 return FWL_Error::Succeeded; |
| 232 } | 232 } |
| 233 | 233 |
| 234 FWL_Error IFWL_ListBox::GetItemText(IFWL_ListItem* pItem, | 234 FWL_Error IFWL_ListBox::GetItemText(CFWL_ListItem* pItem, |
| 235 CFX_WideString& wsText) { | 235 CFX_WideString& wsText) { |
| 236 if (!m_pProperties->m_pDataProvider) | 236 if (!m_pProperties->m_pDataProvider) |
| 237 return FWL_Error::Indefinite; | 237 return FWL_Error::Indefinite; |
| 238 IFWL_ListBoxDP* pData = | 238 IFWL_ListBoxDP* pData = |
| 239 static_cast<IFWL_ListBoxDP*>(m_pProperties->m_pDataProvider); | 239 static_cast<IFWL_ListBoxDP*>(m_pProperties->m_pDataProvider); |
| 240 if (!pItem) | 240 if (!pItem) |
| 241 return FWL_Error::Indefinite; | 241 return FWL_Error::Indefinite; |
| 242 pData->GetItemText(this, pItem, wsText); | 242 pData->GetItemText(this, pItem, wsText); |
| 243 return FWL_Error::Succeeded; | 243 return FWL_Error::Succeeded; |
| 244 } | 244 } |
| 245 | 245 |
| 246 FWL_Error IFWL_ListBox::GetScrollPos(FX_FLOAT& fPos, bool bVert) { | 246 FWL_Error IFWL_ListBox::GetScrollPos(FX_FLOAT& fPos, bool bVert) { |
| 247 if ((bVert && IsShowScrollBar(true)) || (!bVert && IsShowScrollBar(false))) { | 247 if ((bVert && IsShowScrollBar(true)) || (!bVert && IsShowScrollBar(false))) { |
| 248 IFWL_ScrollBar* pScrollBar = | 248 IFWL_ScrollBar* pScrollBar = |
| 249 bVert ? m_pVertScrollBar.get() : m_pHorzScrollBar.get(); | 249 bVert ? m_pVertScrollBar.get() : m_pHorzScrollBar.get(); |
| 250 fPos = pScrollBar->GetPos(); | 250 fPos = pScrollBar->GetPos(); |
| 251 return FWL_Error::Succeeded; | 251 return FWL_Error::Succeeded; |
| 252 } | 252 } |
| 253 return FWL_Error::Indefinite; | 253 return FWL_Error::Indefinite; |
| 254 } | 254 } |
| 255 | 255 |
| 256 IFWL_ListItem* IFWL_ListBox::GetItem(IFWL_ListItem* pItem, uint32_t dwKeyCode) { | 256 CFWL_ListItem* IFWL_ListBox::GetItem(CFWL_ListItem* pItem, uint32_t dwKeyCode) { |
| 257 IFWL_ListItem* hRet = nullptr; | 257 CFWL_ListItem* hRet = nullptr; |
| 258 switch (dwKeyCode) { | 258 switch (dwKeyCode) { |
| 259 case FWL_VKEY_Up: | 259 case FWL_VKEY_Up: |
| 260 case FWL_VKEY_Down: | 260 case FWL_VKEY_Down: |
| 261 case FWL_VKEY_Home: | 261 case FWL_VKEY_Home: |
| 262 case FWL_VKEY_End: { | 262 case FWL_VKEY_End: { |
| 263 const bool bUp = dwKeyCode == FWL_VKEY_Up; | 263 const bool bUp = dwKeyCode == FWL_VKEY_Up; |
| 264 const bool bDown = dwKeyCode == FWL_VKEY_Down; | 264 const bool bDown = dwKeyCode == FWL_VKEY_Down; |
| 265 const bool bHome = dwKeyCode == FWL_VKEY_Home; | 265 const bool bHome = dwKeyCode == FWL_VKEY_Home; |
| 266 IFWL_ListBoxDP* pData = | 266 IFWL_ListBoxDP* pData = |
| 267 static_cast<IFWL_ListBoxDP*>(m_pProperties->m_pDataProvider); | 267 static_cast<IFWL_ListBoxDP*>(m_pProperties->m_pDataProvider); |
| 268 int32_t iDstItem = -1; | 268 int32_t iDstItem = -1; |
| 269 if (bUp || bDown) { | 269 if (bUp || bDown) { |
| 270 int32_t index = pData->GetItemIndex(this, pItem); | 270 int32_t index = pData->GetItemIndex(this, pItem); |
| 271 iDstItem = dwKeyCode == FWL_VKEY_Up ? index - 1 : index + 1; | 271 iDstItem = dwKeyCode == FWL_VKEY_Up ? index - 1 : index + 1; |
| 272 } else if (bHome) { | 272 } else if (bHome) { |
| 273 iDstItem = 0; | 273 iDstItem = 0; |
| 274 } else { | 274 } else { |
| 275 int32_t iCount = pData->CountItems(this); | 275 int32_t iCount = pData->CountItems(this); |
| 276 iDstItem = iCount - 1; | 276 iDstItem = iCount - 1; |
| 277 } | 277 } |
| 278 hRet = pData->GetItem(this, iDstItem); | 278 hRet = pData->GetItem(this, iDstItem); |
| 279 break; | 279 break; |
| 280 } | 280 } |
| 281 default: {} | 281 default: {} |
| 282 } | 282 } |
| 283 return hRet; | 283 return hRet; |
| 284 } | 284 } |
| 285 | 285 |
| 286 void IFWL_ListBox::SetSelection(IFWL_ListItem* hStart, | 286 void IFWL_ListBox::SetSelection(CFWL_ListItem* hStart, |
| 287 IFWL_ListItem* hEnd, | 287 CFWL_ListItem* hEnd, |
| 288 bool bSelected) { | 288 bool bSelected) { |
| 289 IFWL_ListBoxDP* pData = | 289 IFWL_ListBoxDP* pData = |
| 290 static_cast<IFWL_ListBoxDP*>(m_pProperties->m_pDataProvider); | 290 static_cast<IFWL_ListBoxDP*>(m_pProperties->m_pDataProvider); |
| 291 int32_t iStart = pData->GetItemIndex(this, hStart); | 291 int32_t iStart = pData->GetItemIndex(this, hStart); |
| 292 int32_t iEnd = pData->GetItemIndex(this, hEnd); | 292 int32_t iEnd = pData->GetItemIndex(this, hEnd); |
| 293 if (iStart > iEnd) { | 293 if (iStart > iEnd) { |
| 294 int32_t iTemp = iStart; | 294 int32_t iTemp = iStart; |
| 295 iStart = iEnd; | 295 iStart = iEnd; |
| 296 iEnd = iTemp; | 296 iEnd = iTemp; |
| 297 } | 297 } |
| 298 if (bSelected) { | 298 if (bSelected) { |
| 299 int32_t iCount = pData->CountItems(this); | 299 int32_t iCount = pData->CountItems(this); |
| 300 for (int32_t i = 0; i < iCount; i++) { | 300 for (int32_t i = 0; i < iCount; i++) { |
| 301 IFWL_ListItem* pItem = pData->GetItem(this, i); | 301 CFWL_ListItem* pItem = pData->GetItem(this, i); |
| 302 SetSelectionDirect(pItem, false); | 302 SetSelectionDirect(pItem, false); |
| 303 } | 303 } |
| 304 } | 304 } |
| 305 for (; iStart <= iEnd; iStart++) { | 305 for (; iStart <= iEnd; iStart++) { |
| 306 IFWL_ListItem* pItem = pData->GetItem(this, iStart); | 306 CFWL_ListItem* pItem = pData->GetItem(this, iStart); |
| 307 SetSelectionDirect(pItem, bSelected); | 307 SetSelectionDirect(pItem, bSelected); |
| 308 } | 308 } |
| 309 } | 309 } |
| 310 | 310 |
| 311 void IFWL_ListBox::SetSelectionDirect(IFWL_ListItem* pItem, bool bSelect) { | 311 void IFWL_ListBox::SetSelectionDirect(CFWL_ListItem* pItem, bool bSelect) { |
| 312 IFWL_ListBoxDP* pData = | 312 IFWL_ListBoxDP* pData = |
| 313 static_cast<IFWL_ListBoxDP*>(m_pProperties->m_pDataProvider); | 313 static_cast<IFWL_ListBoxDP*>(m_pProperties->m_pDataProvider); |
| 314 uint32_t dwOldStyle = pData->GetItemStyles(this, pItem); | 314 uint32_t dwOldStyle = pData->GetItemStyles(this, pItem); |
| 315 bSelect ? dwOldStyle |= FWL_ITEMSTATE_LTB_Selected | 315 bSelect ? dwOldStyle |= FWL_ITEMSTATE_LTB_Selected |
| 316 : dwOldStyle &= ~FWL_ITEMSTATE_LTB_Selected; | 316 : dwOldStyle &= ~FWL_ITEMSTATE_LTB_Selected; |
| 317 pData->SetItemStyles(this, pItem, dwOldStyle); | 317 pData->SetItemStyles(this, pItem, dwOldStyle); |
| 318 } | 318 } |
| 319 | 319 |
| 320 bool IFWL_ListBox::IsItemSelected(IFWL_ListItem* pItem) { | 320 bool IFWL_ListBox::IsItemSelected(CFWL_ListItem* pItem) { |
| 321 IFWL_ListBoxDP* pData = | 321 IFWL_ListBoxDP* pData = |
| 322 static_cast<IFWL_ListBoxDP*>(m_pProperties->m_pDataProvider); | 322 static_cast<IFWL_ListBoxDP*>(m_pProperties->m_pDataProvider); |
| 323 uint32_t dwState = pData->GetItemStyles(this, pItem); | 323 uint32_t dwState = pData->GetItemStyles(this, pItem); |
| 324 return (dwState & FWL_ITEMSTATE_LTB_Selected) != 0; | 324 return (dwState & FWL_ITEMSTATE_LTB_Selected) != 0; |
| 325 } | 325 } |
| 326 | 326 |
| 327 void IFWL_ListBox::ClearSelection() { | 327 void IFWL_ListBox::ClearSelection() { |
| 328 bool bMulti = m_pProperties->m_dwStyleExes & FWL_STYLEEXT_LTB_MultiSelection; | 328 bool bMulti = m_pProperties->m_dwStyleExes & FWL_STYLEEXT_LTB_MultiSelection; |
| 329 IFWL_ListBoxDP* pData = | 329 IFWL_ListBoxDP* pData = |
| 330 static_cast<IFWL_ListBoxDP*>(m_pProperties->m_pDataProvider); | 330 static_cast<IFWL_ListBoxDP*>(m_pProperties->m_pDataProvider); |
| 331 int32_t iCount = pData->CountItems(this); | 331 int32_t iCount = pData->CountItems(this); |
| 332 for (int32_t i = 0; i < iCount; i++) { | 332 for (int32_t i = 0; i < iCount; i++) { |
| 333 IFWL_ListItem* pItem = pData->GetItem(this, i); | 333 CFWL_ListItem* pItem = pData->GetItem(this, i); |
| 334 uint32_t dwState = pData->GetItemStyles(this, pItem); | 334 uint32_t dwState = pData->GetItemStyles(this, pItem); |
| 335 if (!(dwState & FWL_ITEMSTATE_LTB_Selected)) | 335 if (!(dwState & FWL_ITEMSTATE_LTB_Selected)) |
| 336 continue; | 336 continue; |
| 337 SetSelectionDirect(pItem, false); | 337 SetSelectionDirect(pItem, false); |
| 338 if (!bMulti) | 338 if (!bMulti) |
| 339 return; | 339 return; |
| 340 } | 340 } |
| 341 } | 341 } |
| 342 | 342 |
| 343 void IFWL_ListBox::SelectAll() { | 343 void IFWL_ListBox::SelectAll() { |
| 344 bool bMulti = m_pProperties->m_dwStyleExes & FWL_STYLEEXT_LTB_MultiSelection; | 344 bool bMulti = m_pProperties->m_dwStyleExes & FWL_STYLEEXT_LTB_MultiSelection; |
| 345 if (!bMulti) { | 345 if (!bMulti) { |
| 346 return; | 346 return; |
| 347 } | 347 } |
| 348 IFWL_ListBoxDP* pData = | 348 IFWL_ListBoxDP* pData = |
| 349 static_cast<IFWL_ListBoxDP*>(m_pProperties->m_pDataProvider); | 349 static_cast<IFWL_ListBoxDP*>(m_pProperties->m_pDataProvider); |
| 350 int32_t iCount = pData->CountItems(this); | 350 int32_t iCount = pData->CountItems(this); |
| 351 if (iCount > 0) { | 351 if (iCount > 0) { |
| 352 IFWL_ListItem* pItemStart = pData->GetItem(this, 0); | 352 CFWL_ListItem* pItemStart = pData->GetItem(this, 0); |
| 353 IFWL_ListItem* pItemEnd = pData->GetItem(this, iCount - 1); | 353 CFWL_ListItem* pItemEnd = pData->GetItem(this, iCount - 1); |
| 354 SetSelection(pItemStart, pItemEnd, false); | 354 SetSelection(pItemStart, pItemEnd, false); |
| 355 } | 355 } |
| 356 } | 356 } |
| 357 | 357 |
| 358 IFWL_ListItem* IFWL_ListBox::GetFocusedItem() { | 358 CFWL_ListItem* IFWL_ListBox::GetFocusedItem() { |
| 359 IFWL_ListBoxDP* pData = | 359 IFWL_ListBoxDP* pData = |
| 360 static_cast<IFWL_ListBoxDP*>(m_pProperties->m_pDataProvider); | 360 static_cast<IFWL_ListBoxDP*>(m_pProperties->m_pDataProvider); |
| 361 int32_t iCount = pData->CountItems(this); | 361 int32_t iCount = pData->CountItems(this); |
| 362 for (int32_t i = 0; i < iCount; i++) { | 362 for (int32_t i = 0; i < iCount; i++) { |
| 363 IFWL_ListItem* pItem = pData->GetItem(this, i); | 363 CFWL_ListItem* pItem = pData->GetItem(this, i); |
| 364 if (!pItem) | 364 if (!pItem) |
| 365 return nullptr; | 365 return nullptr; |
| 366 if (pData->GetItemStyles(this, pItem) & FWL_ITEMSTATE_LTB_Focused) { | 366 if (pData->GetItemStyles(this, pItem) & FWL_ITEMSTATE_LTB_Focused) { |
| 367 return pItem; | 367 return pItem; |
| 368 } | 368 } |
| 369 } | 369 } |
| 370 return nullptr; | 370 return nullptr; |
| 371 } | 371 } |
| 372 | 372 |
| 373 void IFWL_ListBox::SetFocusItem(IFWL_ListItem* pItem) { | 373 void IFWL_ListBox::SetFocusItem(CFWL_ListItem* pItem) { |
| 374 IFWL_ListBoxDP* pData = | 374 IFWL_ListBoxDP* pData = |
| 375 static_cast<IFWL_ListBoxDP*>(m_pProperties->m_pDataProvider); | 375 static_cast<IFWL_ListBoxDP*>(m_pProperties->m_pDataProvider); |
| 376 IFWL_ListItem* hFocus = GetFocusedItem(); | 376 CFWL_ListItem* hFocus = GetFocusedItem(); |
| 377 if (pItem != hFocus) { | 377 if (pItem != hFocus) { |
| 378 if (hFocus) { | 378 if (hFocus) { |
| 379 uint32_t dwStyle = pData->GetItemStyles(this, hFocus); | 379 uint32_t dwStyle = pData->GetItemStyles(this, hFocus); |
| 380 dwStyle &= ~FWL_ITEMSTATE_LTB_Focused; | 380 dwStyle &= ~FWL_ITEMSTATE_LTB_Focused; |
| 381 pData->SetItemStyles(this, hFocus, dwStyle); | 381 pData->SetItemStyles(this, hFocus, dwStyle); |
| 382 } | 382 } |
| 383 if (pItem) { | 383 if (pItem) { |
| 384 uint32_t dwStyle = pData->GetItemStyles(this, pItem); | 384 uint32_t dwStyle = pData->GetItemStyles(this, pItem); |
| 385 dwStyle |= FWL_ITEMSTATE_LTB_Focused; | 385 dwStyle |= FWL_ITEMSTATE_LTB_Focused; |
| 386 pData->SetItemStyles(this, pItem, dwStyle); | 386 pData->SetItemStyles(this, pItem, dwStyle); |
| 387 } | 387 } |
| 388 } | 388 } |
| 389 } | 389 } |
| 390 | 390 |
| 391 IFWL_ListItem* IFWL_ListBox::GetItemAtPoint(FX_FLOAT fx, FX_FLOAT fy) { | 391 CFWL_ListItem* IFWL_ListBox::GetItemAtPoint(FX_FLOAT fx, FX_FLOAT fy) { |
| 392 fx -= m_rtConent.left, fy -= m_rtConent.top; | 392 fx -= m_rtConent.left, fy -= m_rtConent.top; |
| 393 FX_FLOAT fPosX = 0.0f; | 393 FX_FLOAT fPosX = 0.0f; |
| 394 if (m_pHorzScrollBar) { | 394 if (m_pHorzScrollBar) { |
| 395 fPosX = m_pHorzScrollBar->GetPos(); | 395 fPosX = m_pHorzScrollBar->GetPos(); |
| 396 } | 396 } |
| 397 FX_FLOAT fPosY = 0.0; | 397 FX_FLOAT fPosY = 0.0; |
| 398 if (m_pVertScrollBar) { | 398 if (m_pVertScrollBar) { |
| 399 fPosY = m_pVertScrollBar->GetPos(); | 399 fPosY = m_pVertScrollBar->GetPos(); |
| 400 } | 400 } |
| 401 IFWL_ListBoxDP* pData = | 401 IFWL_ListBoxDP* pData = |
| 402 static_cast<IFWL_ListBoxDP*>(m_pProperties->m_pDataProvider); | 402 static_cast<IFWL_ListBoxDP*>(m_pProperties->m_pDataProvider); |
| 403 int32_t nCount = pData->CountItems(this); | 403 int32_t nCount = pData->CountItems(this); |
| 404 for (int32_t i = 0; i < nCount; i++) { | 404 for (int32_t i = 0; i < nCount; i++) { |
| 405 IFWL_ListItem* pItem = pData->GetItem(this, i); | 405 CFWL_ListItem* pItem = pData->GetItem(this, i); |
| 406 if (!pItem) { | 406 if (!pItem) { |
| 407 continue; | 407 continue; |
| 408 } | 408 } |
| 409 CFX_RectF rtItem; | 409 CFX_RectF rtItem; |
| 410 pData->GetItemRect(this, pItem, rtItem); | 410 pData->GetItemRect(this, pItem, rtItem); |
| 411 rtItem.Offset(-fPosX, -fPosY); | 411 rtItem.Offset(-fPosX, -fPosY); |
| 412 if (rtItem.Contains(fx, fy)) { | 412 if (rtItem.Contains(fx, fy)) { |
| 413 return pItem; | 413 return pItem; |
| 414 } | 414 } |
| 415 } | 415 } |
| 416 return nullptr; | 416 return nullptr; |
| 417 } | 417 } |
| 418 | 418 |
| 419 bool IFWL_ListBox::GetItemCheckRect(IFWL_ListItem* pItem, CFX_RectF& rtCheck) { | 419 bool IFWL_ListBox::GetItemCheckRect(CFWL_ListItem* pItem, CFX_RectF& rtCheck) { |
| 420 if (!m_pProperties->m_pDataProvider) | 420 if (!m_pProperties->m_pDataProvider) |
| 421 return false; | 421 return false; |
| 422 if (!(m_pProperties->m_dwStyleExes & FWL_STYLEEXT_LTB_Check)) { | 422 if (!(m_pProperties->m_dwStyleExes & FWL_STYLEEXT_LTB_Check)) { |
| 423 return false; | 423 return false; |
| 424 } | 424 } |
| 425 IFWL_ListBoxDP* pData = | 425 IFWL_ListBoxDP* pData = |
| 426 static_cast<IFWL_ListBoxDP*>(m_pProperties->m_pDataProvider); | 426 static_cast<IFWL_ListBoxDP*>(m_pProperties->m_pDataProvider); |
| 427 pData->GetItemCheckRect(this, pItem, rtCheck); | 427 pData->GetItemCheckRect(this, pItem, rtCheck); |
| 428 return true; | 428 return true; |
| 429 } | 429 } |
| 430 | 430 |
| 431 bool IFWL_ListBox::GetItemChecked(IFWL_ListItem* pItem) { | 431 bool IFWL_ListBox::GetItemChecked(CFWL_ListItem* pItem) { |
| 432 if (!m_pProperties->m_pDataProvider) | 432 if (!m_pProperties->m_pDataProvider) |
| 433 return false; | 433 return false; |
| 434 if (!(m_pProperties->m_dwStyleExes & FWL_STYLEEXT_LTB_Check)) { | 434 if (!(m_pProperties->m_dwStyleExes & FWL_STYLEEXT_LTB_Check)) { |
| 435 return false; | 435 return false; |
| 436 } | 436 } |
| 437 IFWL_ListBoxDP* pData = | 437 IFWL_ListBoxDP* pData = |
| 438 static_cast<IFWL_ListBoxDP*>(m_pProperties->m_pDataProvider); | 438 static_cast<IFWL_ListBoxDP*>(m_pProperties->m_pDataProvider); |
| 439 return !!(pData->GetItemCheckState(this, pItem) & FWL_ITEMSTATE_LTB_Checked); | 439 return !!(pData->GetItemCheckState(this, pItem) & FWL_ITEMSTATE_LTB_Checked); |
| 440 } | 440 } |
| 441 | 441 |
| 442 bool IFWL_ListBox::SetItemChecked(IFWL_ListItem* pItem, bool bChecked) { | 442 bool IFWL_ListBox::SetItemChecked(CFWL_ListItem* pItem, bool bChecked) { |
| 443 if (!m_pProperties->m_pDataProvider) | 443 if (!m_pProperties->m_pDataProvider) |
| 444 return false; | 444 return false; |
| 445 if (!(m_pProperties->m_dwStyleExes & FWL_STYLEEXT_LTB_Check)) { | 445 if (!(m_pProperties->m_dwStyleExes & FWL_STYLEEXT_LTB_Check)) { |
| 446 return false; | 446 return false; |
| 447 } | 447 } |
| 448 IFWL_ListBoxDP* pData = | 448 IFWL_ListBoxDP* pData = |
| 449 static_cast<IFWL_ListBoxDP*>(m_pProperties->m_pDataProvider); | 449 static_cast<IFWL_ListBoxDP*>(m_pProperties->m_pDataProvider); |
| 450 pData->SetItemCheckState(this, pItem, | 450 pData->SetItemCheckState(this, pItem, |
| 451 bChecked ? FWL_ITEMSTATE_LTB_Checked : 0); | 451 bChecked ? FWL_ITEMSTATE_LTB_Checked : 0); |
| 452 return true; | 452 return true; |
| 453 } | 453 } |
| 454 | 454 |
| 455 bool IFWL_ListBox::ScrollToVisible(IFWL_ListItem* pItem) { | 455 bool IFWL_ListBox::ScrollToVisible(CFWL_ListItem* pItem) { |
| 456 if (!m_pVertScrollBar) | 456 if (!m_pVertScrollBar) |
| 457 return false; | 457 return false; |
| 458 CFX_RectF rtItem; | 458 CFX_RectF rtItem; |
| 459 IFWL_ListBoxDP* pData = | 459 IFWL_ListBoxDP* pData = |
| 460 static_cast<IFWL_ListBoxDP*>(m_pProperties->m_pDataProvider); | 460 static_cast<IFWL_ListBoxDP*>(m_pProperties->m_pDataProvider); |
| 461 pData->GetItemRect(this, pItem, rtItem); | 461 pData->GetItemRect(this, pItem, rtItem); |
| 462 bool bScroll = false; | 462 bool bScroll = false; |
| 463 FX_FLOAT fPosY = m_pVertScrollBar->GetPos(); | 463 FX_FLOAT fPosY = m_pVertScrollBar->GetPos(); |
| 464 rtItem.Offset(0, -fPosY + m_rtConent.top); | 464 rtItem.Offset(0, -fPosY + m_rtConent.top); |
| 465 if (rtItem.top < m_rtConent.top) { | 465 if (rtItem.top < m_rtConent.top) { |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 518 } | 518 } |
| 519 if (m_pVertScrollBar) { | 519 if (m_pVertScrollBar) { |
| 520 rtView.width -= m_fScorllBarWidth; | 520 rtView.width -= m_fScorllBarWidth; |
| 521 } | 521 } |
| 522 bool bMultiCol = | 522 bool bMultiCol = |
| 523 !!(m_pProperties->m_dwStyleExes & FWL_STYLEEXT_LTB_MultiColumn); | 523 !!(m_pProperties->m_dwStyleExes & FWL_STYLEEXT_LTB_MultiColumn); |
| 524 IFWL_ListBoxDP* pData = | 524 IFWL_ListBoxDP* pData = |
| 525 static_cast<IFWL_ListBoxDP*>(m_pProperties->m_pDataProvider); | 525 static_cast<IFWL_ListBoxDP*>(m_pProperties->m_pDataProvider); |
| 526 int32_t iCount = pData->CountItems(this); | 526 int32_t iCount = pData->CountItems(this); |
| 527 for (int32_t i = 0; i < iCount; i++) { | 527 for (int32_t i = 0; i < iCount; i++) { |
| 528 IFWL_ListItem* pItem = pData->GetItem(this, i); | 528 CFWL_ListItem* pItem = pData->GetItem(this, i); |
| 529 if (!pItem) { | 529 if (!pItem) { |
| 530 continue; | 530 continue; |
| 531 } | 531 } |
| 532 CFX_RectF rtItem; | 532 CFX_RectF rtItem; |
| 533 pData->GetItemRect(this, pItem, rtItem); | 533 pData->GetItemRect(this, pItem, rtItem); |
| 534 rtItem.Offset(m_rtConent.left - fPosX, m_rtConent.top - fPosY); | 534 rtItem.Offset(m_rtConent.left - fPosX, m_rtConent.top - fPosY); |
| 535 if (rtItem.bottom() < m_rtConent.top) { | 535 if (rtItem.bottom() < m_rtConent.top) { |
| 536 continue; | 536 continue; |
| 537 } | 537 } |
| 538 if (rtItem.top >= m_rtConent.bottom()) { | 538 if (rtItem.top >= m_rtConent.bottom()) { |
| (...skipping 11 matching lines...) Expand all Loading... |
| 550 ev.m_rect = rtItem; | 550 ev.m_rect = rtItem; |
| 551 DispatchEvent(&ev); | 551 DispatchEvent(&ev); |
| 552 } else { | 552 } else { |
| 553 DrawItem(pGraphics, pTheme, pItem, i, rtItem, pMatrix); | 553 DrawItem(pGraphics, pTheme, pItem, i, rtItem, pMatrix); |
| 554 } | 554 } |
| 555 } | 555 } |
| 556 } | 556 } |
| 557 | 557 |
| 558 void IFWL_ListBox::DrawItem(CFX_Graphics* pGraphics, | 558 void IFWL_ListBox::DrawItem(CFX_Graphics* pGraphics, |
| 559 IFWL_ThemeProvider* pTheme, | 559 IFWL_ThemeProvider* pTheme, |
| 560 IFWL_ListItem* pItem, | 560 CFWL_ListItem* pItem, |
| 561 int32_t Index, | 561 int32_t Index, |
| 562 const CFX_RectF& rtItem, | 562 const CFX_RectF& rtItem, |
| 563 const CFX_Matrix* pMatrix) { | 563 const CFX_Matrix* pMatrix) { |
| 564 IFWL_ListBoxDP* pData = | 564 IFWL_ListBoxDP* pData = |
| 565 static_cast<IFWL_ListBoxDP*>(m_pProperties->m_pDataProvider); | 565 static_cast<IFWL_ListBoxDP*>(m_pProperties->m_pDataProvider); |
| 566 uint32_t dwItemStyles = pData->GetItemStyles(this, pItem); | 566 uint32_t dwItemStyles = pData->GetItemStyles(this, pItem); |
| 567 uint32_t dwPartStates = CFWL_PartState_Normal; | 567 uint32_t dwPartStates = CFWL_PartState_Normal; |
| 568 if (m_pProperties->m_dwStates & FWL_WGTSTATE_Disabled) { | 568 if (m_pProperties->m_dwStates & FWL_WGTSTATE_Disabled) { |
| 569 dwPartStates = CFWL_PartState_Disabled; | 569 dwPartStates = CFWL_PartState_Disabled; |
| 570 } else if (dwItemStyles & FWL_ITEMSTATE_LTB_Selected) { | 570 } else if (dwItemStyles & FWL_ITEMSTATE_LTB_Selected) { |
| (...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 672 m_rtConent.Deflate(pUIMargin->left, pUIMargin->top, pUIMargin->width, | 672 m_rtConent.Deflate(pUIMargin->left, pUIMargin->top, pUIMargin->width, |
| 673 pUIMargin->height); | 673 pUIMargin->height); |
| 674 } | 674 } |
| 675 } | 675 } |
| 676 FX_FLOAT fWidth = 0; | 676 FX_FLOAT fWidth = 0; |
| 677 if (m_pProperties->m_pThemeProvider->IsCustomizedLayout(this)) { | 677 if (m_pProperties->m_pThemeProvider->IsCustomizedLayout(this)) { |
| 678 IFWL_ListBoxDP* pData = | 678 IFWL_ListBoxDP* pData = |
| 679 static_cast<IFWL_ListBoxDP*>(m_pProperties->m_pDataProvider); | 679 static_cast<IFWL_ListBoxDP*>(m_pProperties->m_pDataProvider); |
| 680 int32_t iCount = pData->CountItems(this); | 680 int32_t iCount = pData->CountItems(this); |
| 681 for (int32_t i = 0; i < iCount; i++) { | 681 for (int32_t i = 0; i < iCount; i++) { |
| 682 IFWL_ListItem* pItem = pData->GetItem(this, i); | 682 CFWL_ListItem* pItem = pData->GetItem(this, i); |
| 683 if (!bAutoSize) { | 683 if (!bAutoSize) { |
| 684 CFX_RectF rtItem; | 684 CFX_RectF rtItem; |
| 685 rtItem.Set(m_rtClient.left, m_rtClient.top + fs.y, 0, 0); | 685 rtItem.Set(m_rtClient.left, m_rtClient.top + fs.y, 0, 0); |
| 686 IFWL_ListBoxDP* pBox = | 686 IFWL_ListBoxDP* pBox = |
| 687 static_cast<IFWL_ListBoxDP*>(m_pProperties->m_pDataProvider); | 687 static_cast<IFWL_ListBoxDP*>(m_pProperties->m_pDataProvider); |
| 688 pBox->SetItemRect(this, pItem, rtItem); | 688 pBox->SetItemRect(this, pItem, rtItem); |
| 689 } | 689 } |
| 690 if (fs.x < 0) { | 690 if (fs.x < 0) { |
| 691 fs.x = 0; | 691 fs.x = 0; |
| 692 fWidth = 0; | 692 fWidth = 0; |
| (...skipping 10 matching lines...) Expand all Loading... |
| 703 } | 703 } |
| 704 } | 704 } |
| 705 IFWL_ListBoxDP* pData = | 705 IFWL_ListBoxDP* pData = |
| 706 static_cast<IFWL_ListBoxDP*>(m_pProperties->m_pDataProvider); | 706 static_cast<IFWL_ListBoxDP*>(m_pProperties->m_pDataProvider); |
| 707 m_fItemHeight = GetItemHeigt(); | 707 m_fItemHeight = GetItemHeigt(); |
| 708 if ((GetStylesEx() & FWL_STYLEEXT_LTB_Icon)) | 708 if ((GetStylesEx() & FWL_STYLEEXT_LTB_Icon)) |
| 709 fWidth += m_fItemHeight; | 709 fWidth += m_fItemHeight; |
| 710 | 710 |
| 711 int32_t iCount = pData->CountItems(this); | 711 int32_t iCount = pData->CountItems(this); |
| 712 for (int32_t i = 0; i < iCount; i++) { | 712 for (int32_t i = 0; i < iCount; i++) { |
| 713 IFWL_ListItem* htem = pData->GetItem(this, i); | 713 CFWL_ListItem* htem = pData->GetItem(this, i); |
| 714 GetItemSize(fs, htem, fWidth, m_fItemHeight, bAutoSize); | 714 GetItemSize(fs, htem, fWidth, m_fItemHeight, bAutoSize); |
| 715 } | 715 } |
| 716 } | 716 } |
| 717 if (bAutoSize) { | 717 if (bAutoSize) { |
| 718 return fs; | 718 return fs; |
| 719 } | 719 } |
| 720 FX_FLOAT iWidth = m_rtClient.width - rtUIMargin.left - rtUIMargin.width; | 720 FX_FLOAT iWidth = m_rtClient.width - rtUIMargin.left - rtUIMargin.width; |
| 721 FX_FLOAT iHeight = m_rtClient.height; | 721 FX_FLOAT iHeight = m_rtClient.height; |
| 722 bool bShowVertScr = | 722 bool bShowVertScr = |
| 723 (m_pProperties->m_dwStyleExes & FWL_STYLEEXT_LTB_ShowScrollBarAlaways) && | 723 (m_pProperties->m_dwStyleExes & FWL_STYLEEXT_LTB_ShowScrollBarAlaways) && |
| (...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 808 } | 808 } |
| 809 if (bShowVertScr && bShowHorzScr) { | 809 if (bShowVertScr && bShowHorzScr) { |
| 810 m_rtStatic.Set(m_rtClient.right() - m_fScorllBarWidth, | 810 m_rtStatic.Set(m_rtClient.right() - m_fScorllBarWidth, |
| 811 m_rtClient.bottom() - m_fScorllBarWidth, m_fScorllBarWidth, | 811 m_rtClient.bottom() - m_fScorllBarWidth, m_fScorllBarWidth, |
| 812 m_fScorllBarWidth); | 812 m_fScorllBarWidth); |
| 813 } | 813 } |
| 814 return fs; | 814 return fs; |
| 815 } | 815 } |
| 816 | 816 |
| 817 void IFWL_ListBox::GetItemSize(CFX_SizeF& size, | 817 void IFWL_ListBox::GetItemSize(CFX_SizeF& size, |
| 818 IFWL_ListItem* pItem, | 818 CFWL_ListItem* pItem, |
| 819 FX_FLOAT fWidth, | 819 FX_FLOAT fWidth, |
| 820 FX_FLOAT fItemHeight, | 820 FX_FLOAT fItemHeight, |
| 821 bool bAutoSize) { | 821 bool bAutoSize) { |
| 822 if (m_pProperties->m_dwStyleExes & FWL_STYLEEXT_LTB_MultiColumn) { | 822 if (m_pProperties->m_dwStyleExes & FWL_STYLEEXT_LTB_MultiColumn) { |
| 823 } else { | 823 } else { |
| 824 if (!bAutoSize) { | 824 if (!bAutoSize) { |
| 825 CFX_RectF rtItem; | 825 CFX_RectF rtItem; |
| 826 rtItem.Set(0, size.y, fWidth, fItemHeight); | 826 rtItem.Set(0, size.y, fWidth, fItemHeight); |
| 827 IFWL_ListBoxDP* pData = | 827 IFWL_ListBoxDP* pData = |
| 828 static_cast<IFWL_ListBoxDP*>(m_pProperties->m_pDataProvider); | 828 static_cast<IFWL_ListBoxDP*>(m_pProperties->m_pDataProvider); |
| 829 pData->SetItemRect(this, pItem, rtItem); | 829 pData->SetItemRect(this, pItem, rtItem); |
| 830 } | 830 } |
| 831 size.x = fWidth; | 831 size.x = fWidth; |
| 832 size.y += fItemHeight; | 832 size.y += fItemHeight; |
| 833 } | 833 } |
| 834 } | 834 } |
| 835 | 835 |
| 836 FX_FLOAT IFWL_ListBox::GetMaxTextWidth() { | 836 FX_FLOAT IFWL_ListBox::GetMaxTextWidth() { |
| 837 FX_FLOAT fRet = 0.0f; | 837 FX_FLOAT fRet = 0.0f; |
| 838 IFWL_ListBoxDP* pData = | 838 IFWL_ListBoxDP* pData = |
| 839 static_cast<IFWL_ListBoxDP*>(m_pProperties->m_pDataProvider); | 839 static_cast<IFWL_ListBoxDP*>(m_pProperties->m_pDataProvider); |
| 840 int32_t iCount = pData->CountItems(this); | 840 int32_t iCount = pData->CountItems(this); |
| 841 for (int32_t i = 0; i < iCount; i++) { | 841 for (int32_t i = 0; i < iCount; i++) { |
| 842 IFWL_ListItem* pItem = pData->GetItem(this, i); | 842 CFWL_ListItem* pItem = pData->GetItem(this, i); |
| 843 if (!pItem) { | 843 if (!pItem) { |
| 844 continue; | 844 continue; |
| 845 } | 845 } |
| 846 CFX_WideString wsText; | 846 CFX_WideString wsText; |
| 847 pData->GetItemText(this, pItem, wsText); | 847 pData->GetItemText(this, pItem, wsText); |
| 848 CFX_SizeF sz = CalcTextSize(wsText, m_pProperties->m_pThemeProvider); | 848 CFX_SizeF sz = CalcTextSize(wsText, m_pProperties->m_pThemeProvider); |
| 849 if (sz.x > fRet) { | 849 if (sz.x > fRet) { |
| 850 fRet = sz.x; | 850 fRet = sz.x; |
| 851 } | 851 } |
| 852 } | 852 } |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 892 FWL_STYLEEXT_LTB_ShowScrollBarFocus) || | 892 FWL_STYLEEXT_LTB_ShowScrollBarFocus) || |
| 893 (m_pProperties->m_dwStates & FWL_WGTSTATE_Focused); | 893 (m_pProperties->m_dwStates & FWL_WGTSTATE_Focused); |
| 894 } | 894 } |
| 895 | 895 |
| 896 void IFWL_ListBox::ProcessSelChanged() { | 896 void IFWL_ListBox::ProcessSelChanged() { |
| 897 CFWL_EvtLtbSelChanged selEvent; | 897 CFWL_EvtLtbSelChanged selEvent; |
| 898 selEvent.m_pSrcTarget = this; | 898 selEvent.m_pSrcTarget = this; |
| 899 CFX_Int32Array arrSels; | 899 CFX_Int32Array arrSels; |
| 900 int32_t iCount = CountSelItems(); | 900 int32_t iCount = CountSelItems(); |
| 901 for (int32_t i = 0; i < iCount; i++) { | 901 for (int32_t i = 0; i < iCount; i++) { |
| 902 IFWL_ListItem* item = GetSelItem(i); | 902 CFWL_ListItem* item = GetSelItem(i); |
| 903 if (!item) { | 903 if (!item) { |
| 904 continue; | 904 continue; |
| 905 } | 905 } |
| 906 selEvent.iarraySels.Add(i); | 906 selEvent.iarraySels.Add(i); |
| 907 } | 907 } |
| 908 DispatchEvent(&selEvent); | 908 DispatchEvent(&selEvent); |
| 909 } | 909 } |
| 910 | 910 |
| 911 void IFWL_ListBox::OnProcessMessage(CFWL_Message* pMessage) { | 911 void IFWL_ListBox::OnProcessMessage(CFWL_Message* pMessage) { |
| 912 if (!pMessage) | 912 if (!pMessage) |
| (...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 984 m_pProperties->m_dwStates &= ~(FWL_WGTSTATE_Focused); | 984 m_pProperties->m_dwStates &= ~(FWL_WGTSTATE_Focused); |
| 985 | 985 |
| 986 Repaint(&m_rtClient); | 986 Repaint(&m_rtClient); |
| 987 } | 987 } |
| 988 | 988 |
| 989 void IFWL_ListBox::OnLButtonDown(CFWL_MsgMouse* pMsg) { | 989 void IFWL_ListBox::OnLButtonDown(CFWL_MsgMouse* pMsg) { |
| 990 m_bLButtonDown = true; | 990 m_bLButtonDown = true; |
| 991 if ((m_pProperties->m_dwStates & FWL_WGTSTATE_Focused) == 0) | 991 if ((m_pProperties->m_dwStates & FWL_WGTSTATE_Focused) == 0) |
| 992 SetFocus(true); | 992 SetFocus(true); |
| 993 | 993 |
| 994 IFWL_ListItem* pItem = GetItemAtPoint(pMsg->m_fx, pMsg->m_fy); | 994 CFWL_ListItem* pItem = GetItemAtPoint(pMsg->m_fx, pMsg->m_fy); |
| 995 if (!pItem) | 995 if (!pItem) |
| 996 return; | 996 return; |
| 997 | 997 |
| 998 if (m_pProperties->m_dwStyleExes & FWL_STYLEEXT_LTB_MultiSelection) { | 998 if (m_pProperties->m_dwStyleExes & FWL_STYLEEXT_LTB_MultiSelection) { |
| 999 if (pMsg->m_dwFlags & FWL_KEYFLAG_Ctrl) { | 999 if (pMsg->m_dwFlags & FWL_KEYFLAG_Ctrl) { |
| 1000 bool bSelected = IsItemSelected(pItem); | 1000 bool bSelected = IsItemSelected(pItem); |
| 1001 SetSelectionDirect(pItem, !bSelected); | 1001 SetSelectionDirect(pItem, !bSelected); |
| 1002 m_hAnchor = pItem; | 1002 m_hAnchor = pItem; |
| 1003 } else if (pMsg->m_dwFlags & FWL_KEYFLAG_Shift) { | 1003 } else if (pMsg->m_dwFlags & FWL_KEYFLAG_Shift) { |
| 1004 if (m_hAnchor) | 1004 if (m_hAnchor) |
| 1005 SetSelection(m_hAnchor, pItem, true); | 1005 SetSelection(m_hAnchor, pItem, true); |
| 1006 else | 1006 else |
| 1007 SetSelectionDirect(pItem, true); | 1007 SetSelectionDirect(pItem, true); |
| 1008 } else { | 1008 } else { |
| 1009 SetSelection(pItem, pItem, true); | 1009 SetSelection(pItem, pItem, true); |
| 1010 m_hAnchor = pItem; | 1010 m_hAnchor = pItem; |
| 1011 } | 1011 } |
| 1012 } else { | 1012 } else { |
| 1013 SetSelection(pItem, pItem, true); | 1013 SetSelection(pItem, pItem, true); |
| 1014 } | 1014 } |
| 1015 if (m_pProperties->m_dwStyleExes & FWL_STYLEEXT_LTB_Check) { | 1015 if (m_pProperties->m_dwStyleExes & FWL_STYLEEXT_LTB_Check) { |
| 1016 IFWL_ListItem* hSelectedItem = GetItemAtPoint(pMsg->m_fx, pMsg->m_fy); | 1016 CFWL_ListItem* hSelectedItem = GetItemAtPoint(pMsg->m_fx, pMsg->m_fy); |
| 1017 CFX_RectF rtCheck; | 1017 CFX_RectF rtCheck; |
| 1018 GetItemCheckRect(hSelectedItem, rtCheck); | 1018 GetItemCheckRect(hSelectedItem, rtCheck); |
| 1019 bool bChecked = GetItemChecked(pItem); | 1019 bool bChecked = GetItemChecked(pItem); |
| 1020 if (rtCheck.Contains(pMsg->m_fx, pMsg->m_fy)) { | 1020 if (rtCheck.Contains(pMsg->m_fx, pMsg->m_fy)) { |
| 1021 SetItemChecked(pItem, !bChecked); | 1021 SetItemChecked(pItem, !bChecked); |
| 1022 Update(); | 1022 Update(); |
| 1023 } | 1023 } |
| 1024 } | 1024 } |
| 1025 SetFocusItem(pItem); | 1025 SetFocusItem(pItem); |
| 1026 ScrollToVisible(pItem); | 1026 ScrollToVisible(pItem); |
| (...skipping 17 matching lines...) Expand all Loading... |
| 1044 } | 1044 } |
| 1045 | 1045 |
| 1046 void IFWL_ListBox::OnKeyDown(CFWL_MsgKey* pMsg) { | 1046 void IFWL_ListBox::OnKeyDown(CFWL_MsgKey* pMsg) { |
| 1047 uint32_t dwKeyCode = pMsg->m_dwKeyCode; | 1047 uint32_t dwKeyCode = pMsg->m_dwKeyCode; |
| 1048 switch (dwKeyCode) { | 1048 switch (dwKeyCode) { |
| 1049 case FWL_VKEY_Tab: | 1049 case FWL_VKEY_Tab: |
| 1050 case FWL_VKEY_Up: | 1050 case FWL_VKEY_Up: |
| 1051 case FWL_VKEY_Down: | 1051 case FWL_VKEY_Down: |
| 1052 case FWL_VKEY_Home: | 1052 case FWL_VKEY_Home: |
| 1053 case FWL_VKEY_End: { | 1053 case FWL_VKEY_End: { |
| 1054 IFWL_ListItem* pItem = GetFocusedItem(); | 1054 CFWL_ListItem* pItem = GetFocusedItem(); |
| 1055 pItem = GetItem(pItem, dwKeyCode); | 1055 pItem = GetItem(pItem, dwKeyCode); |
| 1056 bool bShift = !!(pMsg->m_dwFlags & FWL_KEYFLAG_Shift); | 1056 bool bShift = !!(pMsg->m_dwFlags & FWL_KEYFLAG_Shift); |
| 1057 bool bCtrl = !!(pMsg->m_dwFlags & FWL_KEYFLAG_Ctrl); | 1057 bool bCtrl = !!(pMsg->m_dwFlags & FWL_KEYFLAG_Ctrl); |
| 1058 OnVK(pItem, bShift, bCtrl); | 1058 OnVK(pItem, bShift, bCtrl); |
| 1059 DispatchSelChangedEv(); | 1059 DispatchSelChangedEv(); |
| 1060 ProcessSelChanged(); | 1060 ProcessSelChanged(); |
| 1061 break; | 1061 break; |
| 1062 } | 1062 } |
| 1063 default: | 1063 default: |
| 1064 break; | 1064 break; |
| 1065 } | 1065 } |
| 1066 } | 1066 } |
| 1067 | 1067 |
| 1068 void IFWL_ListBox::OnVK(IFWL_ListItem* pItem, bool bShift, bool bCtrl) { | 1068 void IFWL_ListBox::OnVK(CFWL_ListItem* pItem, bool bShift, bool bCtrl) { |
| 1069 if (!pItem) | 1069 if (!pItem) |
| 1070 return; | 1070 return; |
| 1071 | 1071 |
| 1072 if (m_pProperties->m_dwStyleExes & FWL_STYLEEXT_LTB_MultiSelection) { | 1072 if (m_pProperties->m_dwStyleExes & FWL_STYLEEXT_LTB_MultiSelection) { |
| 1073 if (bCtrl) { | 1073 if (bCtrl) { |
| 1074 } else if (bShift) { | 1074 } else if (bShift) { |
| 1075 if (m_hAnchor) | 1075 if (m_hAnchor) |
| 1076 SetSelection(m_hAnchor, pItem, true); | 1076 SetSelection(m_hAnchor, pItem, true); |
| 1077 else | 1077 else |
| 1078 SetSelectionDirect(pItem, true); | 1078 SetSelectionDirect(pItem, true); |
| (...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1145 Repaint(&m_rtClient); | 1145 Repaint(&m_rtClient); |
| 1146 } | 1146 } |
| 1147 return true; | 1147 return true; |
| 1148 } | 1148 } |
| 1149 | 1149 |
| 1150 void IFWL_ListBox::DispatchSelChangedEv() { | 1150 void IFWL_ListBox::DispatchSelChangedEv() { |
| 1151 CFWL_EvtLtbSelChanged ev; | 1151 CFWL_EvtLtbSelChanged ev; |
| 1152 ev.m_pSrcTarget = this; | 1152 ev.m_pSrcTarget = this; |
| 1153 DispatchEvent(&ev); | 1153 DispatchEvent(&ev); |
| 1154 } | 1154 } |
| OLD | NEW |