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

Side by Side Diff: xfa/fwl/basewidget/fwl_listboximp.cpp

Issue 2029923002: Replace FWL_HLISTITEM with class IFWL_ListItem {} (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@master
Patch Set: Created 4 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2014 PDFium Authors. All rights reserved. 1 // Copyright 2014 PDFium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com 5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
6 6
7 #include "xfa/fwl/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 28 matching lines...) Expand all
39 IFWL_ListBox* pListBox = new IFWL_ListBox; 39 IFWL_ListBox* pListBox = new IFWL_ListBox;
40 CFWL_ListBoxImp* pComboListImpl = new CFWL_ComboListImp(properties, pOuter); 40 CFWL_ListBoxImp* pComboListImpl = new CFWL_ComboListImp(properties, pOuter);
41 pListBox->SetImpl(pComboListImpl); 41 pListBox->SetImpl(pComboListImpl);
42 pComboListImpl->SetInterface(pListBox); 42 pComboListImpl->SetInterface(pListBox);
43 return pListBox; 43 return pListBox;
44 } 44 }
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 IFWL_ListItem* 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_Error IFWL_ListBox::SetSelItem(FWL_HLISTITEM hItem, FX_BOOL bSelect) { 55 FWL_Error IFWL_ListBox::SetSelItem(IFWL_ListItem* 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_Error IFWL_ListBox::GetItemText(FWL_HLISTITEM hItem, 58 FWL_Error IFWL_ListBox::GetItemText(IFWL_ListItem* hItem,
59 CFX_WideString& wsText) { 59 CFX_WideString& wsText) {
60 return static_cast<CFWL_ListBoxImp*>(GetImpl())->GetItemText(hItem, wsText); 60 return static_cast<CFWL_ListBoxImp*>(GetImpl())->GetItemText(hItem, wsText);
61 } 61 }
62 FWL_Error IFWL_ListBox::GetScrollPos(FX_FLOAT& fPos, FX_BOOL bVert) { 62 FWL_Error IFWL_ListBox::GetScrollPos(FX_FLOAT& fPos, FX_BOOL bVert) {
63 return static_cast<CFWL_ListBoxImp*>(GetImpl())->GetScrollPos(fPos, bVert); 63 return static_cast<CFWL_ListBoxImp*>(GetImpl())->GetScrollPos(fPos, bVert);
64 } 64 }
65 65
66 CFWL_ListBoxImp::CFWL_ListBoxImp(const CFWL_WidgetImpProperties& properties, 66 CFWL_ListBoxImp::CFWL_ListBoxImp(const CFWL_WidgetImpProperties& properties,
67 IFWL_Widget* pOuter) 67 IFWL_Widget* pOuter)
68 : CFWL_WidgetImp(properties, pOuter), 68 : CFWL_WidgetImp(properties, pOuter),
(...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after
210 return FWL_Error::Succeeded; 210 return FWL_Error::Succeeded;
211 } 211 }
212 int32_t CFWL_ListBoxImp::CountSelItems() { 212 int32_t CFWL_ListBoxImp::CountSelItems() {
213 if (!m_pProperties->m_pDataProvider) 213 if (!m_pProperties->m_pDataProvider)
214 return 0; 214 return 0;
215 int32_t iRet = 0; 215 int32_t iRet = 0;
216 IFWL_ListBoxDP* pData = 216 IFWL_ListBoxDP* pData =
217 static_cast<IFWL_ListBoxDP*>(m_pProperties->m_pDataProvider); 217 static_cast<IFWL_ListBoxDP*>(m_pProperties->m_pDataProvider);
218 int32_t iCount = pData->CountItems(m_pInterface); 218 int32_t iCount = pData->CountItems(m_pInterface);
219 for (int32_t i = 0; i < iCount; i++) { 219 for (int32_t i = 0; i < iCount; i++) {
220 FWL_HLISTITEM hItem = pData->GetItem(m_pInterface, i); 220 IFWL_ListItem* hItem = pData->GetItem(m_pInterface, i);
221 if (!hItem) { 221 if (!hItem) {
222 continue; 222 continue;
223 } 223 }
224 uint32_t dwStyle = pData->GetItemStyles(m_pInterface, hItem); 224 uint32_t dwStyle = pData->GetItemStyles(m_pInterface, hItem);
225 if (dwStyle & FWL_ITEMSTATE_LTB_Selected) { 225 if (dwStyle & FWL_ITEMSTATE_LTB_Selected) {
226 iRet++; 226 iRet++;
227 } 227 }
228 } 228 }
229 return iRet; 229 return iRet;
230 } 230 }
231 FWL_HLISTITEM CFWL_ListBoxImp::GetSelItem(int32_t nIndexSel) { 231 IFWL_ListItem* CFWL_ListBoxImp::GetSelItem(int32_t nIndexSel) {
232 if (!m_pProperties->m_pDataProvider) 232 if (!m_pProperties->m_pDataProvider)
233 return NULL; 233 return NULL;
234 int32_t index = 0; 234 int32_t index = 0;
235 IFWL_ListBoxDP* pData = 235 IFWL_ListBoxDP* pData =
236 static_cast<IFWL_ListBoxDP*>(m_pProperties->m_pDataProvider); 236 static_cast<IFWL_ListBoxDP*>(m_pProperties->m_pDataProvider);
237 int32_t iCount = pData->CountItems(m_pInterface); 237 int32_t iCount = pData->CountItems(m_pInterface);
238 for (int32_t i = 0; i < iCount; i++) { 238 for (int32_t i = 0; i < iCount; i++) {
239 FWL_HLISTITEM hItem = pData->GetItem(m_pInterface, i); 239 IFWL_ListItem* hItem = pData->GetItem(m_pInterface, i);
240 if (!hItem) { 240 if (!hItem) {
241 return NULL; 241 return NULL;
242 } 242 }
243 uint32_t dwStyle = pData->GetItemStyles(m_pInterface, hItem); 243 uint32_t dwStyle = pData->GetItemStyles(m_pInterface, hItem);
244 if (dwStyle & FWL_ITEMSTATE_LTB_Selected) { 244 if (dwStyle & FWL_ITEMSTATE_LTB_Selected) {
245 if (index == nIndexSel) { 245 if (index == nIndexSel) {
246 return hItem; 246 return hItem;
247 } else { 247 } else {
248 index++; 248 index++;
249 } 249 }
250 } 250 }
251 } 251 }
252 return NULL; 252 return NULL;
253 } 253 }
254 int32_t CFWL_ListBoxImp::GetSelIndex(int32_t nIndex) { 254 int32_t CFWL_ListBoxImp::GetSelIndex(int32_t nIndex) {
255 if (!m_pProperties->m_pDataProvider) 255 if (!m_pProperties->m_pDataProvider)
256 return -1; 256 return -1;
257 int32_t index = 0; 257 int32_t index = 0;
258 IFWL_ListBoxDP* pData = 258 IFWL_ListBoxDP* pData =
259 static_cast<IFWL_ListBoxDP*>(m_pProperties->m_pDataProvider); 259 static_cast<IFWL_ListBoxDP*>(m_pProperties->m_pDataProvider);
260 int32_t iCount = pData->CountItems(m_pInterface); 260 int32_t iCount = pData->CountItems(m_pInterface);
261 for (int32_t i = 0; i < iCount; i++) { 261 for (int32_t i = 0; i < iCount; i++) {
262 FWL_HLISTITEM hItem = pData->GetItem(m_pInterface, i); 262 IFWL_ListItem* hItem = pData->GetItem(m_pInterface, i);
dsinclair 2016/06/02 01:28:58 Should the variables in here be rename to p instea
Tom Sepez 2016/06/02 21:02:59 Done.
263 if (!hItem) { 263 if (!hItem) {
264 return -1; 264 return -1;
265 } 265 }
266 uint32_t dwStyle = pData->GetItemStyles(m_pInterface, hItem); 266 uint32_t dwStyle = pData->GetItemStyles(m_pInterface, hItem);
267 if (dwStyle & FWL_ITEMSTATE_LTB_Selected) { 267 if (dwStyle & FWL_ITEMSTATE_LTB_Selected) {
268 if (index == nIndex) { 268 if (index == nIndex) {
269 return i; 269 return i;
270 } else { 270 } else {
271 index++; 271 index++;
272 } 272 }
273 } 273 }
274 } 274 }
275 return -1; 275 return -1;
276 } 276 }
277 FWL_Error CFWL_ListBoxImp::SetSelItem(FWL_HLISTITEM hItem, FX_BOOL bSelect) { 277 FWL_Error CFWL_ListBoxImp::SetSelItem(IFWL_ListItem* hItem, FX_BOOL bSelect) {
278 if (!m_pProperties->m_pDataProvider) 278 if (!m_pProperties->m_pDataProvider)
279 return FWL_Error::Indefinite; 279 return FWL_Error::Indefinite;
280 if (!hItem) { 280 if (!hItem) {
281 if (bSelect) { 281 if (bSelect) {
282 SelectAll(); 282 SelectAll();
283 } else { 283 } else {
284 ClearSelection(); 284 ClearSelection();
285 SetFocusItem(NULL); 285 SetFocusItem(NULL);
286 } 286 }
287 return FWL_Error::Indefinite; 287 return FWL_Error::Indefinite;
288 } 288 }
289 if (m_pProperties->m_dwStyleExes & FWL_STYLEEXT_LTB_MultiSelection) { 289 if (m_pProperties->m_dwStyleExes & FWL_STYLEEXT_LTB_MultiSelection) {
290 SetSelectionDirect(hItem, bSelect); 290 SetSelectionDirect(hItem, bSelect);
291 } else { 291 } else {
292 SetSelection(hItem, hItem, bSelect); 292 SetSelection(hItem, hItem, bSelect);
293 } 293 }
294 return FWL_Error::Succeeded; 294 return FWL_Error::Succeeded;
295 } 295 }
296 FWL_Error CFWL_ListBoxImp::GetItemText(FWL_HLISTITEM hItem, 296 FWL_Error CFWL_ListBoxImp::GetItemText(IFWL_ListItem* hItem,
297 CFX_WideString& wsText) { 297 CFX_WideString& wsText) {
298 if (!m_pProperties->m_pDataProvider) 298 if (!m_pProperties->m_pDataProvider)
299 return FWL_Error::Indefinite; 299 return FWL_Error::Indefinite;
300 IFWL_ListBoxDP* pData = 300 IFWL_ListBoxDP* pData =
301 static_cast<IFWL_ListBoxDP*>(m_pProperties->m_pDataProvider); 301 static_cast<IFWL_ListBoxDP*>(m_pProperties->m_pDataProvider);
302 if (!hItem) 302 if (!hItem)
303 return FWL_Error::Indefinite; 303 return FWL_Error::Indefinite;
304 pData->GetItemText(m_pInterface, hItem, wsText); 304 pData->GetItemText(m_pInterface, hItem, wsText);
305 return FWL_Error::Succeeded; 305 return FWL_Error::Succeeded;
306 } 306 }
307 307
308 FWL_Error CFWL_ListBoxImp::GetScrollPos(FX_FLOAT& fPos, FX_BOOL bVert) { 308 FWL_Error CFWL_ListBoxImp::GetScrollPos(FX_FLOAT& fPos, FX_BOOL bVert) {
309 if ((bVert && IsShowScrollBar(TRUE)) || (!bVert && IsShowScrollBar(FALSE))) { 309 if ((bVert && IsShowScrollBar(TRUE)) || (!bVert && IsShowScrollBar(FALSE))) {
310 IFWL_ScrollBar* pScrollBar = 310 IFWL_ScrollBar* pScrollBar =
311 bVert ? m_pVertScrollBar.get() : m_pHorzScrollBar.get(); 311 bVert ? m_pVertScrollBar.get() : m_pHorzScrollBar.get();
312 fPos = pScrollBar->GetPos(); 312 fPos = pScrollBar->GetPos();
313 return FWL_Error::Succeeded; 313 return FWL_Error::Succeeded;
314 } 314 }
315 return FWL_Error::Indefinite; 315 return FWL_Error::Indefinite;
316 } 316 }
317 317
318 FWL_HLISTITEM CFWL_ListBoxImp::GetItem(FWL_HLISTITEM hItem, 318 IFWL_ListItem* CFWL_ListBoxImp::GetItem(IFWL_ListItem* hItem,
319 uint32_t dwKeyCode) { 319 uint32_t dwKeyCode) {
320 FWL_HLISTITEM hRet = NULL; 320 IFWL_ListItem* hRet = NULL;
321 switch (dwKeyCode) { 321 switch (dwKeyCode) {
322 case FWL_VKEY_Up: 322 case FWL_VKEY_Up:
323 case FWL_VKEY_Down: 323 case FWL_VKEY_Down:
324 case FWL_VKEY_Home: 324 case FWL_VKEY_Home:
325 case FWL_VKEY_End: { 325 case FWL_VKEY_End: {
326 const bool bUp = dwKeyCode == FWL_VKEY_Up; 326 const bool bUp = dwKeyCode == FWL_VKEY_Up;
327 const bool bDown = dwKeyCode == FWL_VKEY_Down; 327 const bool bDown = dwKeyCode == FWL_VKEY_Down;
328 const bool bHome = dwKeyCode == FWL_VKEY_Home; 328 const bool bHome = dwKeyCode == FWL_VKEY_Home;
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 iDstItem = -1; 331 int32_t iDstItem = -1;
332 if (bUp || bDown) { 332 if (bUp || bDown) {
333 int32_t index = pData->GetItemIndex(m_pInterface, hItem); 333 int32_t index = pData->GetItemIndex(m_pInterface, hItem);
334 iDstItem = dwKeyCode == FWL_VKEY_Up ? index - 1 : index + 1; 334 iDstItem = dwKeyCode == FWL_VKEY_Up ? index - 1 : index + 1;
335 } else if (bHome) { 335 } else if (bHome) {
336 iDstItem = 0; 336 iDstItem = 0;
337 } else { 337 } else {
338 int32_t iCount = pData->CountItems(m_pInterface); 338 int32_t iCount = pData->CountItems(m_pInterface);
339 iDstItem = iCount - 1; 339 iDstItem = iCount - 1;
340 } 340 }
341 hRet = pData->GetItem(m_pInterface, iDstItem); 341 hRet = pData->GetItem(m_pInterface, iDstItem);
342 break; 342 break;
343 } 343 }
344 default: {} 344 default: {}
345 } 345 }
346 return hRet; 346 return hRet;
347 } 347 }
348 void CFWL_ListBoxImp::SetSelection(FWL_HLISTITEM hStart, 348 void CFWL_ListBoxImp::SetSelection(IFWL_ListItem* hStart,
349 FWL_HLISTITEM hEnd, 349 IFWL_ListItem* hEnd,
350 FX_BOOL bSelected) { 350 FX_BOOL bSelected) {
351 IFWL_ListBoxDP* pData = 351 IFWL_ListBoxDP* pData =
352 static_cast<IFWL_ListBoxDP*>(m_pProperties->m_pDataProvider); 352 static_cast<IFWL_ListBoxDP*>(m_pProperties->m_pDataProvider);
353 int32_t iStart = pData->GetItemIndex(m_pInterface, hStart); 353 int32_t iStart = pData->GetItemIndex(m_pInterface, hStart);
354 int32_t iEnd = pData->GetItemIndex(m_pInterface, hEnd); 354 int32_t iEnd = pData->GetItemIndex(m_pInterface, hEnd);
355 if (iStart > iEnd) { 355 if (iStart > iEnd) {
356 int32_t iTemp = iStart; 356 int32_t iTemp = iStart;
357 iStart = iEnd; 357 iStart = iEnd;
358 iEnd = iTemp; 358 iEnd = iTemp;
359 } 359 }
360 if (bSelected) { 360 if (bSelected) {
361 int32_t iCount = pData->CountItems(m_pInterface); 361 int32_t iCount = pData->CountItems(m_pInterface);
362 for (int32_t i = 0; i < iCount; i++) { 362 for (int32_t i = 0; i < iCount; i++) {
363 FWL_HLISTITEM hItem = pData->GetItem(m_pInterface, i); 363 IFWL_ListItem* hItem = pData->GetItem(m_pInterface, i);
364 SetSelectionDirect(hItem, FALSE); 364 SetSelectionDirect(hItem, FALSE);
365 } 365 }
366 } 366 }
367 for (; iStart <= iEnd; iStart++) { 367 for (; iStart <= iEnd; iStart++) {
368 FWL_HLISTITEM hItem = pData->GetItem(m_pInterface, iStart); 368 IFWL_ListItem* hItem = pData->GetItem(m_pInterface, iStart);
369 SetSelectionDirect(hItem, bSelected); 369 SetSelectionDirect(hItem, bSelected);
370 } 370 }
371 } 371 }
372 void CFWL_ListBoxImp::SetSelectionDirect(FWL_HLISTITEM hItem, FX_BOOL bSelect) { 372 void CFWL_ListBoxImp::SetSelectionDirect(IFWL_ListItem* hItem,
373 FX_BOOL bSelect) {
373 IFWL_ListBoxDP* pData = 374 IFWL_ListBoxDP* pData =
374 static_cast<IFWL_ListBoxDP*>(m_pProperties->m_pDataProvider); 375 static_cast<IFWL_ListBoxDP*>(m_pProperties->m_pDataProvider);
375 uint32_t dwOldStyle = pData->GetItemStyles(m_pInterface, hItem); 376 uint32_t dwOldStyle = pData->GetItemStyles(m_pInterface, hItem);
376 bSelect ? dwOldStyle |= FWL_ITEMSTATE_LTB_Selected 377 bSelect ? dwOldStyle |= FWL_ITEMSTATE_LTB_Selected
377 : dwOldStyle &= ~FWL_ITEMSTATE_LTB_Selected; 378 : dwOldStyle &= ~FWL_ITEMSTATE_LTB_Selected;
378 pData->SetItemStyles(m_pInterface, hItem, dwOldStyle); 379 pData->SetItemStyles(m_pInterface, hItem, dwOldStyle);
379 } 380 }
380 FX_BOOL CFWL_ListBoxImp::IsItemSelected(FWL_HLISTITEM hItem) { 381 FX_BOOL CFWL_ListBoxImp::IsItemSelected(IFWL_ListItem* hItem) {
381 IFWL_ListBoxDP* pData = 382 IFWL_ListBoxDP* pData =
382 static_cast<IFWL_ListBoxDP*>(m_pProperties->m_pDataProvider); 383 static_cast<IFWL_ListBoxDP*>(m_pProperties->m_pDataProvider);
383 uint32_t dwState = pData->GetItemStyles(m_pInterface, hItem); 384 uint32_t dwState = pData->GetItemStyles(m_pInterface, hItem);
384 return (dwState & FWL_ITEMSTATE_LTB_Selected) != 0; 385 return (dwState & FWL_ITEMSTATE_LTB_Selected) != 0;
385 } 386 }
386 void CFWL_ListBoxImp::ClearSelection() { 387 void CFWL_ListBoxImp::ClearSelection() {
387 FX_BOOL bMulti = 388 FX_BOOL bMulti =
388 m_pProperties->m_dwStyleExes & FWL_STYLEEXT_LTB_MultiSelection; 389 m_pProperties->m_dwStyleExes & FWL_STYLEEXT_LTB_MultiSelection;
389 IFWL_ListBoxDP* pData = 390 IFWL_ListBoxDP* pData =
390 static_cast<IFWL_ListBoxDP*>(m_pProperties->m_pDataProvider); 391 static_cast<IFWL_ListBoxDP*>(m_pProperties->m_pDataProvider);
391 int32_t iCount = pData->CountItems(m_pInterface); 392 int32_t iCount = pData->CountItems(m_pInterface);
392 for (int32_t i = 0; i < iCount; i++) { 393 for (int32_t i = 0; i < iCount; i++) {
393 FWL_HLISTITEM hItem = pData->GetItem(m_pInterface, i); 394 IFWL_ListItem* hItem = pData->GetItem(m_pInterface, i);
394 uint32_t dwState = pData->GetItemStyles(m_pInterface, hItem); 395 uint32_t dwState = pData->GetItemStyles(m_pInterface, hItem);
395 if (!(dwState & FWL_ITEMSTATE_LTB_Selected)) 396 if (!(dwState & FWL_ITEMSTATE_LTB_Selected))
396 continue; 397 continue;
397 SetSelectionDirect(hItem, FALSE); 398 SetSelectionDirect(hItem, FALSE);
398 if (!bMulti) 399 if (!bMulti)
399 return; 400 return;
400 } 401 }
401 } 402 }
402 void CFWL_ListBoxImp::SelectAll() { 403 void CFWL_ListBoxImp::SelectAll() {
403 FX_BOOL bMulti = 404 FX_BOOL bMulti =
404 m_pProperties->m_dwStyleExes & FWL_STYLEEXT_LTB_MultiSelection; 405 m_pProperties->m_dwStyleExes & FWL_STYLEEXT_LTB_MultiSelection;
405 if (!bMulti) { 406 if (!bMulti) {
406 return; 407 return;
407 } 408 }
408 IFWL_ListBoxDP* pData = 409 IFWL_ListBoxDP* pData =
409 static_cast<IFWL_ListBoxDP*>(m_pProperties->m_pDataProvider); 410 static_cast<IFWL_ListBoxDP*>(m_pProperties->m_pDataProvider);
410 int32_t iCount = pData->CountItems(m_pInterface); 411 int32_t iCount = pData->CountItems(m_pInterface);
411 if (iCount > 0) { 412 if (iCount > 0) {
412 FWL_HLISTITEM hItemStart = pData->GetItem(m_pInterface, 0); 413 IFWL_ListItem* hItemStart = pData->GetItem(m_pInterface, 0);
413 FWL_HLISTITEM hItemEnd = pData->GetItem(m_pInterface, iCount - 1); 414 IFWL_ListItem* hItemEnd = pData->GetItem(m_pInterface, iCount - 1);
414 SetSelection(hItemStart, hItemEnd, FALSE); 415 SetSelection(hItemStart, hItemEnd, FALSE);
415 } 416 }
416 } 417 }
417 FWL_HLISTITEM CFWL_ListBoxImp::GetFocusedItem() { 418 IFWL_ListItem* CFWL_ListBoxImp::GetFocusedItem() {
418 IFWL_ListBoxDP* pData = 419 IFWL_ListBoxDP* pData =
419 static_cast<IFWL_ListBoxDP*>(m_pProperties->m_pDataProvider); 420 static_cast<IFWL_ListBoxDP*>(m_pProperties->m_pDataProvider);
420 int32_t iCount = pData->CountItems(m_pInterface); 421 int32_t iCount = pData->CountItems(m_pInterface);
421 for (int32_t i = 0; i < iCount; i++) { 422 for (int32_t i = 0; i < iCount; i++) {
422 FWL_HLISTITEM hItem = pData->GetItem(m_pInterface, i); 423 IFWL_ListItem* hItem = pData->GetItem(m_pInterface, i);
423 if (!hItem) 424 if (!hItem)
424 return NULL; 425 return NULL;
425 if (pData->GetItemStyles(m_pInterface, hItem) & FWL_ITEMSTATE_LTB_Focused) { 426 if (pData->GetItemStyles(m_pInterface, hItem) & FWL_ITEMSTATE_LTB_Focused) {
426 return hItem; 427 return hItem;
427 } 428 }
428 } 429 }
429 return NULL; 430 return NULL;
430 } 431 }
431 void CFWL_ListBoxImp::SetFocusItem(FWL_HLISTITEM hItem) { 432 void CFWL_ListBoxImp::SetFocusItem(IFWL_ListItem* hItem) {
432 IFWL_ListBoxDP* pData = 433 IFWL_ListBoxDP* pData =
433 static_cast<IFWL_ListBoxDP*>(m_pProperties->m_pDataProvider); 434 static_cast<IFWL_ListBoxDP*>(m_pProperties->m_pDataProvider);
434 FWL_HLISTITEM hFocus = GetFocusedItem(); 435 IFWL_ListItem* hFocus = GetFocusedItem();
435 if (hItem != hFocus) { 436 if (hItem != hFocus) {
436 if (hFocus) { 437 if (hFocus) {
437 uint32_t dwStyle = pData->GetItemStyles(m_pInterface, hFocus); 438 uint32_t dwStyle = pData->GetItemStyles(m_pInterface, hFocus);
438 dwStyle &= ~FWL_ITEMSTATE_LTB_Focused; 439 dwStyle &= ~FWL_ITEMSTATE_LTB_Focused;
439 pData->SetItemStyles(m_pInterface, hFocus, dwStyle); 440 pData->SetItemStyles(m_pInterface, hFocus, dwStyle);
440 } 441 }
441 if (hItem) { 442 if (hItem) {
442 uint32_t dwStyle = pData->GetItemStyles(m_pInterface, hItem); 443 uint32_t dwStyle = pData->GetItemStyles(m_pInterface, hItem);
443 dwStyle |= FWL_ITEMSTATE_LTB_Focused; 444 dwStyle |= FWL_ITEMSTATE_LTB_Focused;
444 pData->SetItemStyles(m_pInterface, hItem, dwStyle); 445 pData->SetItemStyles(m_pInterface, hItem, dwStyle);
445 } 446 }
446 } 447 }
447 } 448 }
448 FWL_HLISTITEM CFWL_ListBoxImp::GetItemAtPoint(FX_FLOAT fx, FX_FLOAT fy) { 449 IFWL_ListItem* CFWL_ListBoxImp::GetItemAtPoint(FX_FLOAT fx, FX_FLOAT fy) {
449 fx -= m_rtConent.left, fy -= m_rtConent.top; 450 fx -= m_rtConent.left, fy -= m_rtConent.top;
450 FX_FLOAT fPosX = 0.0f; 451 FX_FLOAT fPosX = 0.0f;
451 if (m_pHorzScrollBar) { 452 if (m_pHorzScrollBar) {
452 fPosX = m_pHorzScrollBar->GetPos(); 453 fPosX = m_pHorzScrollBar->GetPos();
453 } 454 }
454 FX_FLOAT fPosY = 0.0; 455 FX_FLOAT fPosY = 0.0;
455 if (m_pVertScrollBar) { 456 if (m_pVertScrollBar) {
456 fPosY = m_pVertScrollBar->GetPos(); 457 fPosY = m_pVertScrollBar->GetPos();
457 } 458 }
458 IFWL_ListBoxDP* pData = 459 IFWL_ListBoxDP* pData =
459 static_cast<IFWL_ListBoxDP*>(m_pProperties->m_pDataProvider); 460 static_cast<IFWL_ListBoxDP*>(m_pProperties->m_pDataProvider);
460 int32_t nCount = pData->CountItems(m_pInterface); 461 int32_t nCount = pData->CountItems(m_pInterface);
461 for (int32_t i = 0; i < nCount; i++) { 462 for (int32_t i = 0; i < nCount; i++) {
462 FWL_HLISTITEM hItem = pData->GetItem(m_pInterface, i); 463 IFWL_ListItem* hItem = pData->GetItem(m_pInterface, i);
463 if (!hItem) { 464 if (!hItem) {
464 continue; 465 continue;
465 } 466 }
466 CFX_RectF rtItem; 467 CFX_RectF rtItem;
467 pData->GetItemRect(m_pInterface, hItem, rtItem); 468 pData->GetItemRect(m_pInterface, hItem, rtItem);
468 rtItem.Offset(-fPosX, -fPosY); 469 rtItem.Offset(-fPosX, -fPosY);
469 if (rtItem.Contains(fx, fy)) { 470 if (rtItem.Contains(fx, fy)) {
470 return hItem; 471 return hItem;
471 } 472 }
472 } 473 }
473 return NULL; 474 return NULL;
474 } 475 }
475 FX_BOOL CFWL_ListBoxImp::GetItemCheckRect(FWL_HLISTITEM hItem, 476 FX_BOOL CFWL_ListBoxImp::GetItemCheckRect(IFWL_ListItem* hItem,
476 CFX_RectF& rtCheck) { 477 CFX_RectF& rtCheck) {
477 if (!m_pProperties->m_pDataProvider) 478 if (!m_pProperties->m_pDataProvider)
478 return FALSE; 479 return FALSE;
479 if (!(m_pProperties->m_dwStyleExes & FWL_STYLEEXT_LTB_Check)) { 480 if (!(m_pProperties->m_dwStyleExes & FWL_STYLEEXT_LTB_Check)) {
480 return FALSE; 481 return FALSE;
481 } 482 }
482 IFWL_ListBoxDP* pData = 483 IFWL_ListBoxDP* pData =
483 static_cast<IFWL_ListBoxDP*>(m_pProperties->m_pDataProvider); 484 static_cast<IFWL_ListBoxDP*>(m_pProperties->m_pDataProvider);
484 pData->GetItemCheckRect(m_pInterface, hItem, rtCheck); 485 pData->GetItemCheckRect(m_pInterface, hItem, rtCheck);
485 return TRUE; 486 return TRUE;
486 } 487 }
487 FX_BOOL CFWL_ListBoxImp::GetItemChecked(FWL_HLISTITEM hItem) { 488 FX_BOOL CFWL_ListBoxImp::GetItemChecked(IFWL_ListItem* hItem) {
488 if (!m_pProperties->m_pDataProvider) 489 if (!m_pProperties->m_pDataProvider)
489 return FALSE; 490 return FALSE;
490 if (!(m_pProperties->m_dwStyleExes & FWL_STYLEEXT_LTB_Check)) { 491 if (!(m_pProperties->m_dwStyleExes & FWL_STYLEEXT_LTB_Check)) {
491 return FALSE; 492 return FALSE;
492 } 493 }
493 IFWL_ListBoxDP* pData = 494 IFWL_ListBoxDP* pData =
494 static_cast<IFWL_ListBoxDP*>(m_pProperties->m_pDataProvider); 495 static_cast<IFWL_ListBoxDP*>(m_pProperties->m_pDataProvider);
495 return (pData->GetItemCheckState(m_pInterface, hItem) & 496 return (pData->GetItemCheckState(m_pInterface, hItem) &
496 FWL_ITEMSTATE_LTB_Checked); 497 FWL_ITEMSTATE_LTB_Checked);
497 } 498 }
498 FX_BOOL CFWL_ListBoxImp::SetItemChecked(FWL_HLISTITEM hItem, FX_BOOL bChecked) { 499 FX_BOOL CFWL_ListBoxImp::SetItemChecked(IFWL_ListItem* hItem,
500 FX_BOOL bChecked) {
499 if (!m_pProperties->m_pDataProvider) 501 if (!m_pProperties->m_pDataProvider)
500 return FALSE; 502 return FALSE;
501 if (!(m_pProperties->m_dwStyleExes & FWL_STYLEEXT_LTB_Check)) { 503 if (!(m_pProperties->m_dwStyleExes & FWL_STYLEEXT_LTB_Check)) {
502 return FALSE; 504 return FALSE;
503 } 505 }
504 IFWL_ListBoxDP* pData = 506 IFWL_ListBoxDP* pData =
505 static_cast<IFWL_ListBoxDP*>(m_pProperties->m_pDataProvider); 507 static_cast<IFWL_ListBoxDP*>(m_pProperties->m_pDataProvider);
506 pData->SetItemCheckState(m_pInterface, hItem, 508 pData->SetItemCheckState(m_pInterface, hItem,
507 bChecked ? FWL_ITEMSTATE_LTB_Checked : 0); 509 bChecked ? FWL_ITEMSTATE_LTB_Checked : 0);
508 return TRUE; 510 return TRUE;
509 } 511 }
510 FX_BOOL CFWL_ListBoxImp::ScrollToVisible(FWL_HLISTITEM hItem) { 512 FX_BOOL CFWL_ListBoxImp::ScrollToVisible(IFWL_ListItem* hItem) {
511 if (!m_pVertScrollBar) 513 if (!m_pVertScrollBar)
512 return FALSE; 514 return FALSE;
513 CFX_RectF rtItem; 515 CFX_RectF rtItem;
514 IFWL_ListBoxDP* pData = 516 IFWL_ListBoxDP* pData =
515 static_cast<IFWL_ListBoxDP*>(m_pProperties->m_pDataProvider); 517 static_cast<IFWL_ListBoxDP*>(m_pProperties->m_pDataProvider);
516 pData->GetItemRect(m_pInterface, hItem, rtItem); 518 pData->GetItemRect(m_pInterface, hItem, rtItem);
517 FX_BOOL bScroll = FALSE; 519 FX_BOOL bScroll = FALSE;
518 FX_FLOAT fPosY = m_pVertScrollBar->GetPos(); 520 FX_FLOAT fPosY = m_pVertScrollBar->GetPos();
519 rtItem.Offset(0, -fPosY + m_rtConent.top); 521 rtItem.Offset(0, -fPosY + m_rtConent.top);
520 if (rtItem.top < m_rtConent.top) { 522 if (rtItem.top < m_rtConent.top) {
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
571 } 573 }
572 if (m_pVertScrollBar) { 574 if (m_pVertScrollBar) {
573 rtView.width -= m_fScorllBarWidth; 575 rtView.width -= m_fScorllBarWidth;
574 } 576 }
575 FX_BOOL bMultiCol = 577 FX_BOOL bMultiCol =
576 m_pProperties->m_dwStyleExes & FWL_STYLEEXT_LTB_MultiColumn; 578 m_pProperties->m_dwStyleExes & FWL_STYLEEXT_LTB_MultiColumn;
577 IFWL_ListBoxDP* pData = 579 IFWL_ListBoxDP* pData =
578 static_cast<IFWL_ListBoxDP*>(m_pProperties->m_pDataProvider); 580 static_cast<IFWL_ListBoxDP*>(m_pProperties->m_pDataProvider);
579 int32_t iCount = pData->CountItems(m_pInterface); 581 int32_t iCount = pData->CountItems(m_pInterface);
580 for (int32_t i = 0; i < iCount; i++) { 582 for (int32_t i = 0; i < iCount; i++) {
581 FWL_HLISTITEM hItem = pData->GetItem(m_pInterface, i); 583 IFWL_ListItem* hItem = pData->GetItem(m_pInterface, i);
582 if (!hItem) { 584 if (!hItem) {
583 continue; 585 continue;
584 } 586 }
585 CFX_RectF rtItem; 587 CFX_RectF rtItem;
586 pData->GetItemRect(m_pInterface, hItem, rtItem); 588 pData->GetItemRect(m_pInterface, hItem, rtItem);
587 rtItem.Offset(m_rtConent.left - fPosX, m_rtConent.top - fPosY); 589 rtItem.Offset(m_rtConent.left - fPosX, m_rtConent.top - fPosY);
588 if (rtItem.bottom() < m_rtConent.top) { 590 if (rtItem.bottom() < m_rtConent.top) {
589 continue; 591 continue;
590 } 592 }
591 if (rtItem.top >= m_rtConent.bottom()) { 593 if (rtItem.top >= m_rtConent.bottom()) {
(...skipping 10 matching lines...) Expand all
602 ev.m_index = i; 604 ev.m_index = i;
603 ev.m_rect = rtItem; 605 ev.m_rect = rtItem;
604 DispatchEvent(&ev); 606 DispatchEvent(&ev);
605 } else { 607 } else {
606 DrawItem(pGraphics, pTheme, hItem, i, rtItem, pMatrix); 608 DrawItem(pGraphics, pTheme, hItem, i, rtItem, pMatrix);
607 } 609 }
608 } 610 }
609 } 611 }
610 void CFWL_ListBoxImp::DrawItem(CFX_Graphics* pGraphics, 612 void CFWL_ListBoxImp::DrawItem(CFX_Graphics* pGraphics,
611 IFWL_ThemeProvider* pTheme, 613 IFWL_ThemeProvider* pTheme,
612 FWL_HLISTITEM hItem, 614 IFWL_ListItem* hItem,
613 int32_t Index, 615 int32_t Index,
614 const CFX_RectF& rtItem, 616 const CFX_RectF& rtItem,
615 const CFX_Matrix* pMatrix) { 617 const CFX_Matrix* pMatrix) {
616 IFWL_ListBoxDP* pData = 618 IFWL_ListBoxDP* pData =
617 static_cast<IFWL_ListBoxDP*>(m_pProperties->m_pDataProvider); 619 static_cast<IFWL_ListBoxDP*>(m_pProperties->m_pDataProvider);
618 uint32_t dwItemStyles = pData->GetItemStyles(m_pInterface, hItem); 620 uint32_t dwItemStyles = pData->GetItemStyles(m_pInterface, hItem);
619 uint32_t dwPartStates = CFWL_PartState_Normal; 621 uint32_t dwPartStates = CFWL_PartState_Normal;
620 if (m_pProperties->m_dwStates & FWL_WGTSTATE_Disabled) { 622 if (m_pProperties->m_dwStates & FWL_WGTSTATE_Disabled) {
621 dwPartStates = CFWL_PartState_Disabled; 623 dwPartStates = CFWL_PartState_Disabled;
622 } else if (dwItemStyles & FWL_ITEMSTATE_LTB_Selected) { 624 } else if (dwItemStyles & FWL_ITEMSTATE_LTB_Selected) {
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after
721 GetThemeCapacity(CFWL_WidgetCapacity::UIMargin)); 723 GetThemeCapacity(CFWL_WidgetCapacity::UIMargin));
722 if (pUIMargin) { 724 if (pUIMargin) {
723 m_rtConent.Deflate(pUIMargin->left, pUIMargin->top, pUIMargin->width, 725 m_rtConent.Deflate(pUIMargin->left, pUIMargin->top, pUIMargin->width,
724 pUIMargin->height); 726 pUIMargin->height);
725 } 727 }
726 } 728 }
727 FX_FLOAT fWidth = 0; 729 FX_FLOAT fWidth = 0;
728 if (m_pProperties->m_pThemeProvider->IsCustomizedLayout(m_pInterface)) { 730 if (m_pProperties->m_pThemeProvider->IsCustomizedLayout(m_pInterface)) {
729 IFWL_ListBoxDP* pData = 731 IFWL_ListBoxDP* pData =
730 static_cast<IFWL_ListBoxDP*>(m_pProperties->m_pDataProvider); 732 static_cast<IFWL_ListBoxDP*>(m_pProperties->m_pDataProvider);
731 if (!bAutoSize) {
732 }
733 int32_t iCount = pData->CountItems(m_pInterface); 733 int32_t iCount = pData->CountItems(m_pInterface);
734 for (int32_t i = 0; i < iCount; i++) { 734 for (int32_t i = 0; i < iCount; i++) {
735 FWL_HLISTITEM hItem = pData->GetItem(m_pInterface, i); 735 IFWL_ListItem* hItem = pData->GetItem(m_pInterface, i);
736 CFWL_ThemePart itemPart; 736 CFWL_ThemePart itemPart;
737 itemPart.m_pWidget = m_pInterface; 737 itemPart.m_pWidget = m_pInterface;
738 itemPart.m_iPart = CFWL_Part::ListItem; 738 itemPart.m_iPart = CFWL_Part::ListItem;
739 itemPart.m_pData = m_pProperties->m_pDataProvider; 739 itemPart.m_pData = m_pProperties->m_pDataProvider;
740 itemPart.m_bMaximize = i > 0; 740 itemPart.m_bMaximize = i > 0;
741 CFX_RectF r; 741 CFX_RectF r;
742 m_pProperties->m_pThemeProvider->GetPartRect(&itemPart, r); 742 m_pProperties->m_pThemeProvider->GetPartRect(&itemPart, r);
743 if (!bAutoSize) { 743 if (!bAutoSize) {
744 CFX_RectF rtItem; 744 CFX_RectF rtItem;
745 rtItem.Set(m_rtClient.left, m_rtClient.top + fs.y, r.width, r.height); 745 rtItem.Set(m_rtClient.left, m_rtClient.top + fs.y, r.width, r.height);
(...skipping 20 matching lines...) Expand all
766 IFWL_ListBoxDP* pData = 766 IFWL_ListBoxDP* pData =
767 static_cast<IFWL_ListBoxDP*>(m_pProperties->m_pDataProvider); 767 static_cast<IFWL_ListBoxDP*>(m_pProperties->m_pDataProvider);
768 m_fItemHeight = GetItemHeigt(); 768 m_fItemHeight = GetItemHeigt();
769 FX_BOOL bHasIcon; 769 FX_BOOL bHasIcon;
770 bHasIcon = GetStylesEx() & FWL_STYLEEXT_LTB_Icon; 770 bHasIcon = GetStylesEx() & FWL_STYLEEXT_LTB_Icon;
771 if (bHasIcon) { 771 if (bHasIcon) {
772 fWidth += m_fItemHeight; 772 fWidth += m_fItemHeight;
773 } 773 }
774 int32_t iCount = pData->CountItems(m_pInterface); 774 int32_t iCount = pData->CountItems(m_pInterface);
775 for (int32_t i = 0; i < iCount; i++) { 775 for (int32_t i = 0; i < iCount; i++) {
776 FWL_HLISTITEM htem = pData->GetItem(m_pInterface, i); 776 IFWL_ListItem* htem = pData->GetItem(m_pInterface, i);
777 GetItemSize(fs, htem, fWidth, m_fItemHeight, bAutoSize); 777 GetItemSize(fs, htem, fWidth, m_fItemHeight, bAutoSize);
778 } 778 }
779 } 779 }
780 if (bAutoSize) { 780 if (bAutoSize) {
781 return fs; 781 return fs;
782 } 782 }
783 FX_FLOAT iWidth = m_rtClient.width - rtUIMargin.left - rtUIMargin.width; 783 FX_FLOAT iWidth = m_rtClient.width - rtUIMargin.left - rtUIMargin.width;
784 FX_FLOAT iHeight = m_rtClient.height; 784 FX_FLOAT iHeight = m_rtClient.height;
785 FX_BOOL bShowVertScr = 785 FX_BOOL bShowVertScr =
786 (m_pProperties->m_dwStyleExes & FWL_STYLEEXT_LTB_ShowScrollBarAlaways) && 786 (m_pProperties->m_dwStyleExes & FWL_STYLEEXT_LTB_ShowScrollBarAlaways) &&
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
870 m_pHorzScrollBar->SetStates(FWL_WGTSTATE_Invisible, TRUE); 870 m_pHorzScrollBar->SetStates(FWL_WGTSTATE_Invisible, TRUE);
871 } 871 }
872 if (bShowVertScr && bShowHorzScr) { 872 if (bShowVertScr && bShowHorzScr) {
873 m_rtStatic.Set(m_rtClient.right() - m_fScorllBarWidth, 873 m_rtStatic.Set(m_rtClient.right() - m_fScorllBarWidth,
874 m_rtClient.bottom() - m_fScorllBarWidth, m_fScorllBarWidth, 874 m_rtClient.bottom() - m_fScorllBarWidth, m_fScorllBarWidth,
875 m_fScorllBarWidth); 875 m_fScorllBarWidth);
876 } 876 }
877 return fs; 877 return fs;
878 } 878 }
879 void CFWL_ListBoxImp::GetItemSize(CFX_SizeF& size, 879 void CFWL_ListBoxImp::GetItemSize(CFX_SizeF& size,
880 FWL_HLISTITEM hItem, 880 IFWL_ListItem* hItem,
881 FX_FLOAT fWidth, 881 FX_FLOAT fWidth,
882 FX_FLOAT m_fItemHeight, 882 FX_FLOAT m_fItemHeight,
883 FX_BOOL bAutoSize) { 883 FX_BOOL bAutoSize) {
884 if (m_pProperties->m_dwStyleExes & FWL_STYLEEXT_LTB_MultiColumn) { 884 if (m_pProperties->m_dwStyleExes & FWL_STYLEEXT_LTB_MultiColumn) {
885 } else { 885 } else {
886 if (!bAutoSize) { 886 if (!bAutoSize) {
887 CFX_RectF rtItem; 887 CFX_RectF rtItem;
888 rtItem.Set(0, size.y, fWidth, m_fItemHeight); 888 rtItem.Set(0, size.y, fWidth, m_fItemHeight);
889 IFWL_ListBoxDP* pData = 889 IFWL_ListBoxDP* pData =
890 static_cast<IFWL_ListBoxDP*>(m_pProperties->m_pDataProvider); 890 static_cast<IFWL_ListBoxDP*>(m_pProperties->m_pDataProvider);
891 pData->SetItemRect(m_pInterface, hItem, rtItem); 891 pData->SetItemRect(m_pInterface, hItem, rtItem);
892 } 892 }
893 size.x = fWidth; 893 size.x = fWidth;
894 size.y += m_fItemHeight; 894 size.y += m_fItemHeight;
895 } 895 }
896 } 896 }
897 FX_FLOAT CFWL_ListBoxImp::GetMaxTextWidth() { 897 FX_FLOAT CFWL_ListBoxImp::GetMaxTextWidth() {
898 FX_FLOAT fRet = 0.0f; 898 FX_FLOAT fRet = 0.0f;
899 IFWL_ListBoxDP* pData = 899 IFWL_ListBoxDP* pData =
900 static_cast<IFWL_ListBoxDP*>(m_pProperties->m_pDataProvider); 900 static_cast<IFWL_ListBoxDP*>(m_pProperties->m_pDataProvider);
901 int32_t iCount = pData->CountItems(m_pInterface); 901 int32_t iCount = pData->CountItems(m_pInterface);
902 for (int32_t i = 0; i < iCount; i++) { 902 for (int32_t i = 0; i < iCount; i++) {
903 FWL_HLISTITEM hItem = pData->GetItem(m_pInterface, i); 903 IFWL_ListItem* hItem = pData->GetItem(m_pInterface, i);
904 if (!hItem) { 904 if (!hItem) {
905 continue; 905 continue;
906 } 906 }
907 CFX_WideString wsText; 907 CFX_WideString wsText;
908 pData->GetItemText(m_pInterface, hItem, wsText); 908 pData->GetItemText(m_pInterface, hItem, wsText);
909 CFX_SizeF sz = CalcTextSize(wsText, m_pProperties->m_pThemeProvider); 909 CFX_SizeF sz = CalcTextSize(wsText, m_pProperties->m_pThemeProvider);
910 if (sz.x > fRet) { 910 if (sz.x > fRet) {
911 fRet = sz.x; 911 fRet = sz.x;
912 } 912 }
913 } 913 }
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
950 return !(m_pProperties->m_dwStyleExes & 950 return !(m_pProperties->m_dwStyleExes &
951 FWL_STYLEEXT_LTB_ShowScrollBarFocus) || 951 FWL_STYLEEXT_LTB_ShowScrollBarFocus) ||
952 (m_pProperties->m_dwStates & FWL_WGTSTATE_Focused); 952 (m_pProperties->m_dwStates & FWL_WGTSTATE_Focused);
953 } 953 }
954 void CFWL_ListBoxImp::ProcessSelChanged() { 954 void CFWL_ListBoxImp::ProcessSelChanged() {
955 CFWL_EvtLtbSelChanged selEvent; 955 CFWL_EvtLtbSelChanged selEvent;
956 selEvent.m_pSrcTarget = m_pInterface; 956 selEvent.m_pSrcTarget = m_pInterface;
957 CFX_Int32Array arrSels; 957 CFX_Int32Array arrSels;
958 int32_t iCount = CountSelItems(); 958 int32_t iCount = CountSelItems();
959 for (int32_t i = 0; i < iCount; i++) { 959 for (int32_t i = 0; i < iCount; i++) {
960 FWL_HLISTITEM item = GetSelItem(i); 960 IFWL_ListItem* item = GetSelItem(i);
961 if (item == NULL) { 961 if (item == NULL) {
962 continue; 962 continue;
963 } 963 }
964 selEvent.iarraySels.Add(i); 964 selEvent.iarraySels.Add(i);
965 } 965 }
966 DispatchEvent(&selEvent); 966 DispatchEvent(&selEvent);
967 } 967 }
968 968
969 CFWL_ListBoxImpDelegate::CFWL_ListBoxImpDelegate(CFWL_ListBoxImp* pOwner) 969 CFWL_ListBoxImpDelegate::CFWL_ListBoxImpDelegate(CFWL_ListBoxImp* pOwner)
970 : m_pOwner(pOwner) {} 970 : m_pOwner(pOwner) {}
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
1054 } else { 1054 } else {
1055 m_pOwner->m_pProperties->m_dwStates &= ~(FWL_WGTSTATE_Focused); 1055 m_pOwner->m_pProperties->m_dwStates &= ~(FWL_WGTSTATE_Focused);
1056 } 1056 }
1057 m_pOwner->Repaint(&m_pOwner->m_rtClient); 1057 m_pOwner->Repaint(&m_pOwner->m_rtClient);
1058 } 1058 }
1059 void CFWL_ListBoxImpDelegate::OnLButtonDown(CFWL_MsgMouse* pMsg) { 1059 void CFWL_ListBoxImpDelegate::OnLButtonDown(CFWL_MsgMouse* pMsg) {
1060 m_pOwner->m_bLButtonDown = TRUE; 1060 m_pOwner->m_bLButtonDown = TRUE;
1061 if ((m_pOwner->m_pProperties->m_dwStates & FWL_WGTSTATE_Focused) == 0) { 1061 if ((m_pOwner->m_pProperties->m_dwStates & FWL_WGTSTATE_Focused) == 0) {
1062 m_pOwner->SetFocus(TRUE); 1062 m_pOwner->SetFocus(TRUE);
1063 } 1063 }
1064 FWL_HLISTITEM hItem = m_pOwner->GetItemAtPoint(pMsg->m_fx, pMsg->m_fy); 1064 IFWL_ListItem* hItem = m_pOwner->GetItemAtPoint(pMsg->m_fx, pMsg->m_fy);
1065 if (!hItem) { 1065 if (!hItem) {
1066 return; 1066 return;
1067 } 1067 }
1068 if (m_pOwner->m_pProperties->m_dwStyleExes & 1068 if (m_pOwner->m_pProperties->m_dwStyleExes &
1069 FWL_STYLEEXT_LTB_MultiSelection) { 1069 FWL_STYLEEXT_LTB_MultiSelection) {
1070 if (pMsg->m_dwFlags & FWL_KEYFLAG_Ctrl) { 1070 if (pMsg->m_dwFlags & FWL_KEYFLAG_Ctrl) {
1071 FX_BOOL bSelected = m_pOwner->IsItemSelected(hItem); 1071 FX_BOOL bSelected = m_pOwner->IsItemSelected(hItem);
1072 m_pOwner->SetSelectionDirect(hItem, !bSelected); 1072 m_pOwner->SetSelectionDirect(hItem, !bSelected);
1073 m_pOwner->m_hAnchor = hItem; 1073 m_pOwner->m_hAnchor = hItem;
1074 } else if (pMsg->m_dwFlags & FWL_KEYFLAG_Shift) { 1074 } else if (pMsg->m_dwFlags & FWL_KEYFLAG_Shift) {
1075 if (m_pOwner->m_hAnchor) { 1075 if (m_pOwner->m_hAnchor) {
1076 m_pOwner->SetSelection(m_pOwner->m_hAnchor, hItem, TRUE); 1076 m_pOwner->SetSelection(m_pOwner->m_hAnchor, hItem, TRUE);
1077 } else { 1077 } else {
1078 m_pOwner->SetSelectionDirect(hItem, TRUE); 1078 m_pOwner->SetSelectionDirect(hItem, TRUE);
1079 } 1079 }
1080 } else { 1080 } else {
1081 m_pOwner->SetSelection(hItem, hItem, TRUE); 1081 m_pOwner->SetSelection(hItem, hItem, TRUE);
1082 m_pOwner->m_hAnchor = hItem; 1082 m_pOwner->m_hAnchor = hItem;
1083 } 1083 }
1084 } else { 1084 } else {
1085 m_pOwner->SetSelection(hItem, hItem, TRUE); 1085 m_pOwner->SetSelection(hItem, hItem, TRUE);
1086 } 1086 }
1087 if (m_pOwner->m_pProperties->m_dwStyleExes & FWL_STYLEEXT_LTB_Check) { 1087 if (m_pOwner->m_pProperties->m_dwStyleExes & FWL_STYLEEXT_LTB_Check) {
1088 FWL_HLISTITEM hSelectedItem = 1088 IFWL_ListItem* hSelectedItem =
1089 m_pOwner->GetItemAtPoint(pMsg->m_fx, pMsg->m_fy); 1089 m_pOwner->GetItemAtPoint(pMsg->m_fx, pMsg->m_fy);
1090 CFX_RectF rtCheck; 1090 CFX_RectF rtCheck;
1091 m_pOwner->GetItemCheckRect(hSelectedItem, rtCheck); 1091 m_pOwner->GetItemCheckRect(hSelectedItem, rtCheck);
1092 FX_BOOL bChecked = m_pOwner->GetItemChecked(hItem); 1092 FX_BOOL bChecked = m_pOwner->GetItemChecked(hItem);
1093 if (rtCheck.Contains(pMsg->m_fx, pMsg->m_fy)) { 1093 if (rtCheck.Contains(pMsg->m_fx, pMsg->m_fy)) {
1094 if (bChecked) { 1094 if (bChecked) {
1095 m_pOwner->SetItemChecked(hItem, FALSE); 1095 m_pOwner->SetItemChecked(hItem, FALSE);
1096 } else { 1096 } else {
1097 m_pOwner->SetItemChecked(hItem, TRUE); 1097 m_pOwner->SetItemChecked(hItem, TRUE);
1098 } 1098 }
(...skipping 22 matching lines...) Expand all
1121 pDelegate->OnProcessMessage(pMsg); 1121 pDelegate->OnProcessMessage(pMsg);
1122 } 1122 }
1123 void CFWL_ListBoxImpDelegate::OnKeyDown(CFWL_MsgKey* pMsg) { 1123 void CFWL_ListBoxImpDelegate::OnKeyDown(CFWL_MsgKey* pMsg) {
1124 uint32_t dwKeyCode = pMsg->m_dwKeyCode; 1124 uint32_t dwKeyCode = pMsg->m_dwKeyCode;
1125 switch (dwKeyCode) { 1125 switch (dwKeyCode) {
1126 case FWL_VKEY_Tab: 1126 case FWL_VKEY_Tab:
1127 case FWL_VKEY_Up: 1127 case FWL_VKEY_Up:
1128 case FWL_VKEY_Down: 1128 case FWL_VKEY_Down:
1129 case FWL_VKEY_Home: 1129 case FWL_VKEY_Home:
1130 case FWL_VKEY_End: { 1130 case FWL_VKEY_End: {
1131 FWL_HLISTITEM hItem = m_pOwner->GetFocusedItem(); 1131 IFWL_ListItem* hItem = m_pOwner->GetFocusedItem();
1132 hItem = m_pOwner->GetItem(hItem, dwKeyCode); 1132 hItem = m_pOwner->GetItem(hItem, dwKeyCode);
1133 FX_BOOL bShift = pMsg->m_dwFlags & FWL_KEYFLAG_Shift; 1133 FX_BOOL bShift = pMsg->m_dwFlags & FWL_KEYFLAG_Shift;
1134 FX_BOOL bCtrl = pMsg->m_dwFlags & FWL_KEYFLAG_Ctrl; 1134 FX_BOOL bCtrl = pMsg->m_dwFlags & FWL_KEYFLAG_Ctrl;
1135 OnVK(hItem, bShift, bCtrl); 1135 OnVK(hItem, bShift, bCtrl);
1136 DispatchSelChangedEv(); 1136 DispatchSelChangedEv();
1137 m_pOwner->ProcessSelChanged(); 1137 m_pOwner->ProcessSelChanged();
1138 break; 1138 break;
1139 } 1139 }
1140 default: {} 1140 default: {}
1141 } 1141 }
1142 } 1142 }
1143 void CFWL_ListBoxImpDelegate::OnVK(FWL_HLISTITEM hItem, 1143 void CFWL_ListBoxImpDelegate::OnVK(IFWL_ListItem* hItem,
1144 FX_BOOL bShift, 1144 FX_BOOL bShift,
1145 FX_BOOL bCtrl) { 1145 FX_BOOL bCtrl) {
1146 if (!hItem) { 1146 if (!hItem) {
1147 return; 1147 return;
1148 } 1148 }
1149 if (m_pOwner->m_pProperties->m_dwStyleExes & 1149 if (m_pOwner->m_pProperties->m_dwStyleExes &
1150 FWL_STYLEEXT_LTB_MultiSelection) { 1150 FWL_STYLEEXT_LTB_MultiSelection) {
1151 if (bCtrl) { 1151 if (bCtrl) {
1152 } else if (bShift) { 1152 } else if (bShift) {
1153 if (m_pOwner->m_hAnchor) { 1153 if (m_pOwner->m_hAnchor) {
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
1226 pScrollBar->SetTrackPos(fPos); 1226 pScrollBar->SetTrackPos(fPos);
1227 m_pOwner->Repaint(&m_pOwner->m_rtClient); 1227 m_pOwner->Repaint(&m_pOwner->m_rtClient);
1228 } 1228 }
1229 return TRUE; 1229 return TRUE;
1230 } 1230 }
1231 void CFWL_ListBoxImpDelegate::DispatchSelChangedEv() { 1231 void CFWL_ListBoxImpDelegate::DispatchSelChangedEv() {
1232 CFWL_EvtLtbSelChanged ev; 1232 CFWL_EvtLtbSelChanged ev;
1233 ev.m_pSrcTarget = m_pOwner->m_pInterface; 1233 ev.m_pSrcTarget = m_pOwner->m_pInterface;
1234 m_pOwner->DispatchEvent(&ev); 1234 m_pOwner->DispatchEvent(&ev);
1235 } 1235 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698