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

Side by Side Diff: fpdfsdk/fxedit/fxet_list.cpp

Issue 2453683011: Remove FX_BOOL from fpdfsdk. (Closed)
Patch Set: Regenerate patch after rebase. Created 4 years, 1 month 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
« no previous file with comments | « fpdfsdk/fxedit/fxet_list.h ('k') | fpdfsdk/ipdfsdk_annothandler.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 "fpdfsdk/fxedit/fxet_list.h" 7 #include "fpdfsdk/fxedit/fxet_list.h"
8 8
9 #include "core/fpdfdoc/cpvt_word.h" 9 #include "core/fpdfdoc/cpvt_word.h"
10 #include "fpdfsdk/fxedit/fxet_edit.h" 10 #include "fpdfsdk/fxedit/fxet_edit.h"
11 #include "fpdfsdk/pdfwindow/PWL_ListBox.h" 11 #include "fpdfsdk/pdfwindow/PWL_ListBox.h"
12 12
13 CFX_ListItem::CFX_ListItem() 13 CFX_ListItem::CFX_ListItem()
14 : m_pEdit(new CFX_Edit), 14 : m_pEdit(new CFX_Edit),
15 m_bSelected(FALSE), 15 m_bSelected(false),
16 m_rcListItem(0.0f, 0.0f, 0.0f, 0.0f) { 16 m_rcListItem(0.0f, 0.0f, 0.0f, 0.0f) {
17 m_pEdit->SetAlignmentV(1, TRUE); 17 m_pEdit->SetAlignmentV(1, true);
18 m_pEdit->Initialize(); 18 m_pEdit->Initialize();
19 } 19 }
20 20
21 CFX_ListItem::~CFX_ListItem() { 21 CFX_ListItem::~CFX_ListItem() {
22 } 22 }
23 23
24 void CFX_ListItem::SetFontMap(IPVT_FontMap* pFontMap) { 24 void CFX_ListItem::SetFontMap(IPVT_FontMap* pFontMap) {
25 m_pEdit->SetFontMap(pFontMap); 25 m_pEdit->SetFontMap(pFontMap);
26 } 26 }
27 27
28 CFX_Edit* CFX_ListItem::GetEdit() const { 28 CFX_Edit* CFX_ListItem::GetEdit() const {
29 return m_pEdit.get(); 29 return m_pEdit.get();
30 } 30 }
31 31
32 CFX_Edit_Iterator* CFX_ListItem::GetIterator() const { 32 CFX_Edit_Iterator* CFX_ListItem::GetIterator() const {
33 return m_pEdit->GetIterator(); 33 return m_pEdit->GetIterator();
34 } 34 }
35 35
36 void CFX_ListItem::SetRect(const CLST_Rect& rect) { 36 void CFX_ListItem::SetRect(const CLST_Rect& rect) {
37 m_rcListItem = rect; 37 m_rcListItem = rect;
38 } 38 }
39 39
40 CLST_Rect CFX_ListItem::GetRect() const { 40 CLST_Rect CFX_ListItem::GetRect() const {
41 return m_rcListItem; 41 return m_rcListItem;
42 } 42 }
43 43
44 FX_BOOL CFX_ListItem::IsSelected() const { 44 bool CFX_ListItem::IsSelected() const {
45 return m_bSelected; 45 return m_bSelected;
46 } 46 }
47 47
48 void CFX_ListItem::SetSelect(FX_BOOL bSelected) { 48 void CFX_ListItem::SetSelect(bool bSelected) {
49 m_bSelected = bSelected; 49 m_bSelected = bSelected;
50 } 50 }
51 51
52 void CFX_ListItem::SetText(const CFX_WideString& text) { 52 void CFX_ListItem::SetText(const CFX_WideString& text) {
53 m_pEdit->SetText(text); 53 m_pEdit->SetText(text);
54 } 54 }
55 55
56 void CFX_ListItem::SetFontSize(FX_FLOAT fFontSize) { 56 void CFX_ListItem::SetFontSize(FX_FLOAT fFontSize) {
57 m_pEdit->SetFontSize(fFontSize); 57 m_pEdit->SetFontSize(fFontSize);
58 } 58 }
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
136 for (int32_t i = 0, sz = m_aItems.GetSize(); i < sz; i++) { 136 for (int32_t i = 0, sz = m_aItems.GetSize(); i < sz; i++) {
137 if (CPLST_Select_Item* pItem = m_aItems.GetAt(i)) { 137 if (CPLST_Select_Item* pItem = m_aItems.GetAt(i)) {
138 if (pItem->nItemIndex == nItemIndex) 138 if (pItem->nItemIndex == nItemIndex)
139 return i; 139 return i;
140 } 140 }
141 } 141 }
142 142
143 return -1; 143 return -1;
144 } 144 }
145 145
146 FX_BOOL CPLST_Select::IsExist(int32_t nItemIndex) const { 146 bool CPLST_Select::IsExist(int32_t nItemIndex) const {
147 return Find(nItemIndex) >= 0; 147 return Find(nItemIndex) >= 0;
148 } 148 }
149 149
150 int32_t CPLST_Select::GetCount() const { 150 int32_t CPLST_Select::GetCount() const {
151 return m_aItems.GetSize(); 151 return m_aItems.GetSize();
152 } 152 }
153 153
154 int32_t CPLST_Select::GetItemIndex(int32_t nIndex) const { 154 int32_t CPLST_Select::GetItemIndex(int32_t nIndex) const {
155 if (nIndex >= 0 && nIndex < m_aItems.GetSize()) 155 if (nIndex >= 0 && nIndex < m_aItems.GetSize())
156 if (CPLST_Select_Item* pItem = m_aItems.GetAt(nIndex)) 156 if (CPLST_Select_Item* pItem = m_aItems.GetAt(nIndex))
(...skipping 26 matching lines...) Expand all
183 m_aItems.RemoveAt(i); 183 m_aItems.RemoveAt(i);
184 } else { 184 } else {
185 pItem->nState = 0; 185 pItem->nState = 0;
186 } 186 }
187 } 187 }
188 } 188 }
189 } 189 }
190 190
191 CFX_ListCtrl::CFX_ListCtrl() 191 CFX_ListCtrl::CFX_ListCtrl()
192 : m_pNotify(nullptr), 192 : m_pNotify(nullptr),
193 m_bNotifyFlag(FALSE), 193 m_bNotifyFlag(false),
194 m_nSelItem(-1), 194 m_nSelItem(-1),
195 m_nFootIndex(-1), 195 m_nFootIndex(-1),
196 m_bCtrlSel(FALSE), 196 m_bCtrlSel(false),
197 m_nCaretIndex(-1), 197 m_nCaretIndex(-1),
198 m_fFontSize(0.0f), 198 m_fFontSize(0.0f),
199 m_pFontMap(nullptr), 199 m_pFontMap(nullptr),
200 m_bMultiple(FALSE) {} 200 m_bMultiple(false) {}
201 201
202 CFX_ListCtrl::~CFX_ListCtrl() { 202 CFX_ListCtrl::~CFX_ListCtrl() {
203 Empty(); 203 Empty();
204 } 204 }
205 205
206 void CFX_ListCtrl::SetNotify(CPWL_List_Notify* pNotify) { 206 void CFX_ListCtrl::SetNotify(CPWL_List_Notify* pNotify) {
207 m_pNotify = pNotify; 207 m_pNotify = pNotify;
208 } 208 }
209 209
210 CFX_FloatPoint CFX_ListCtrl::InToOut(const CFX_FloatPoint& point) const { 210 CFX_FloatPoint CFX_ListCtrl::InToOut(const CFX_FloatPoint& point) const {
(...skipping 20 matching lines...) Expand all
231 231
232 CFX_FloatRect CFX_ListCtrl::OutToIn(const CFX_FloatRect& rect) const { 232 CFX_FloatRect CFX_ListCtrl::OutToIn(const CFX_FloatRect& rect) const {
233 CFX_FloatPoint ptLeftBottom = OutToIn(CFX_FloatPoint(rect.left, rect.bottom)); 233 CFX_FloatPoint ptLeftBottom = OutToIn(CFX_FloatPoint(rect.left, rect.bottom));
234 CFX_FloatPoint ptRightTop = OutToIn(CFX_FloatPoint(rect.right, rect.top)); 234 CFX_FloatPoint ptRightTop = OutToIn(CFX_FloatPoint(rect.right, rect.top));
235 235
236 return CFX_FloatRect(ptLeftBottom.x, ptLeftBottom.y, ptRightTop.x, 236 return CFX_FloatRect(ptLeftBottom.x, ptLeftBottom.y, ptRightTop.x,
237 ptRightTop.y); 237 ptRightTop.y);
238 } 238 }
239 239
240 void CFX_ListCtrl::OnMouseDown(const CFX_FloatPoint& point, 240 void CFX_ListCtrl::OnMouseDown(const CFX_FloatPoint& point,
241 FX_BOOL bShift, 241 bool bShift,
242 FX_BOOL bCtrl) { 242 bool bCtrl) {
243 int32_t nHitIndex = GetItemIndex(point); 243 int32_t nHitIndex = GetItemIndex(point);
244 244
245 if (IsMultipleSel()) { 245 if (IsMultipleSel()) {
246 if (bCtrl) { 246 if (bCtrl) {
247 if (IsItemSelected(nHitIndex)) { 247 if (IsItemSelected(nHitIndex)) {
248 m_aSelItems.Sub(nHitIndex); 248 m_aSelItems.Sub(nHitIndex);
249 SelectItems(); 249 SelectItems();
250 m_bCtrlSel = FALSE; 250 m_bCtrlSel = false;
251 } else { 251 } else {
252 m_aSelItems.Add(nHitIndex); 252 m_aSelItems.Add(nHitIndex);
253 SelectItems(); 253 SelectItems();
254 m_bCtrlSel = TRUE; 254 m_bCtrlSel = true;
255 } 255 }
256 256
257 m_nFootIndex = nHitIndex; 257 m_nFootIndex = nHitIndex;
258 } else if (bShift) { 258 } else if (bShift) {
259 m_aSelItems.DeselectAll(); 259 m_aSelItems.DeselectAll();
260 m_aSelItems.Add(m_nFootIndex, nHitIndex); 260 m_aSelItems.Add(m_nFootIndex, nHitIndex);
261 SelectItems(); 261 SelectItems();
262 } else { 262 } else {
263 m_aSelItems.DeselectAll(); 263 m_aSelItems.DeselectAll();
264 m_aSelItems.Add(nHitIndex); 264 m_aSelItems.Add(nHitIndex);
265 SelectItems(); 265 SelectItems();
266 266
267 m_nFootIndex = nHitIndex; 267 m_nFootIndex = nHitIndex;
268 } 268 }
269 269
270 SetCaret(nHitIndex); 270 SetCaret(nHitIndex);
271 } else { 271 } else {
272 SetSingleSelect(nHitIndex); 272 SetSingleSelect(nHitIndex);
273 } 273 }
274 274
275 if (!IsItemVisible(nHitIndex)) 275 if (!IsItemVisible(nHitIndex))
276 ScrollToListItem(nHitIndex); 276 ScrollToListItem(nHitIndex);
277 } 277 }
278 278
279 void CFX_ListCtrl::OnMouseMove(const CFX_FloatPoint& point, 279 void CFX_ListCtrl::OnMouseMove(const CFX_FloatPoint& point,
280 FX_BOOL bShift, 280 bool bShift,
281 FX_BOOL bCtrl) { 281 bool bCtrl) {
282 int32_t nHitIndex = GetItemIndex(point); 282 int32_t nHitIndex = GetItemIndex(point);
283 283
284 if (IsMultipleSel()) { 284 if (IsMultipleSel()) {
285 if (bCtrl) { 285 if (bCtrl) {
286 if (m_bCtrlSel) 286 if (m_bCtrlSel)
287 m_aSelItems.Add(m_nFootIndex, nHitIndex); 287 m_aSelItems.Add(m_nFootIndex, nHitIndex);
288 else 288 else
289 m_aSelItems.Sub(m_nFootIndex, nHitIndex); 289 m_aSelItems.Sub(m_nFootIndex, nHitIndex);
290 290
291 SelectItems(); 291 SelectItems();
292 } else { 292 } else {
293 m_aSelItems.DeselectAll(); 293 m_aSelItems.DeselectAll();
294 m_aSelItems.Add(m_nFootIndex, nHitIndex); 294 m_aSelItems.Add(m_nFootIndex, nHitIndex);
295 SelectItems(); 295 SelectItems();
296 } 296 }
297 297
298 SetCaret(nHitIndex); 298 SetCaret(nHitIndex);
299 } else { 299 } else {
300 SetSingleSelect(nHitIndex); 300 SetSingleSelect(nHitIndex);
301 } 301 }
302 302
303 if (!IsItemVisible(nHitIndex)) 303 if (!IsItemVisible(nHitIndex))
304 ScrollToListItem(nHitIndex); 304 ScrollToListItem(nHitIndex);
305 } 305 }
306 306
307 void CFX_ListCtrl::OnVK(int32_t nItemIndex, FX_BOOL bShift, FX_BOOL bCtrl) { 307 void CFX_ListCtrl::OnVK(int32_t nItemIndex, bool bShift, bool bCtrl) {
308 if (IsMultipleSel()) { 308 if (IsMultipleSel()) {
309 if (nItemIndex >= 0 && nItemIndex < GetCount()) { 309 if (nItemIndex >= 0 && nItemIndex < GetCount()) {
310 if (bCtrl) { 310 if (bCtrl) {
311 } else if (bShift) { 311 } else if (bShift) {
312 m_aSelItems.DeselectAll(); 312 m_aSelItems.DeselectAll();
313 m_aSelItems.Add(m_nFootIndex, nItemIndex); 313 m_aSelItems.Add(m_nFootIndex, nItemIndex);
314 SelectItems(); 314 SelectItems();
315 } else { 315 } else {
316 m_aSelItems.DeselectAll(); 316 m_aSelItems.DeselectAll();
317 m_aSelItems.Add(nItemIndex); 317 m_aSelItems.Add(nItemIndex);
318 SelectItems(); 318 SelectItems();
319 m_nFootIndex = nItemIndex; 319 m_nFootIndex = nItemIndex;
320 } 320 }
321 321
322 SetCaret(nItemIndex); 322 SetCaret(nItemIndex);
323 } 323 }
324 } else { 324 } else {
325 SetSingleSelect(nItemIndex); 325 SetSingleSelect(nItemIndex);
326 } 326 }
327 327
328 if (!IsItemVisible(nItemIndex)) 328 if (!IsItemVisible(nItemIndex))
329 ScrollToListItem(nItemIndex); 329 ScrollToListItem(nItemIndex);
330 } 330 }
331 331
332 void CFX_ListCtrl::OnVK_UP(FX_BOOL bShift, FX_BOOL bCtrl) { 332 void CFX_ListCtrl::OnVK_UP(bool bShift, bool bCtrl) {
333 OnVK(IsMultipleSel() ? GetCaret() - 1 : GetSelect() - 1, bShift, bCtrl); 333 OnVK(IsMultipleSel() ? GetCaret() - 1 : GetSelect() - 1, bShift, bCtrl);
334 } 334 }
335 335
336 void CFX_ListCtrl::OnVK_DOWN(FX_BOOL bShift, FX_BOOL bCtrl) { 336 void CFX_ListCtrl::OnVK_DOWN(bool bShift, bool bCtrl) {
337 OnVK(IsMultipleSel() ? GetCaret() + 1 : GetSelect() + 1, bShift, bCtrl); 337 OnVK(IsMultipleSel() ? GetCaret() + 1 : GetSelect() + 1, bShift, bCtrl);
338 } 338 }
339 339
340 void CFX_ListCtrl::OnVK_LEFT(FX_BOOL bShift, FX_BOOL bCtrl) { 340 void CFX_ListCtrl::OnVK_LEFT(bool bShift, bool bCtrl) {
341 OnVK(0, bShift, bCtrl); 341 OnVK(0, bShift, bCtrl);
342 } 342 }
343 343
344 void CFX_ListCtrl::OnVK_RIGHT(FX_BOOL bShift, FX_BOOL bCtrl) { 344 void CFX_ListCtrl::OnVK_RIGHT(bool bShift, bool bCtrl) {
345 OnVK(GetCount() - 1, bShift, bCtrl); 345 OnVK(GetCount() - 1, bShift, bCtrl);
346 } 346 }
347 347
348 void CFX_ListCtrl::OnVK_HOME(FX_BOOL bShift, FX_BOOL bCtrl) { 348 void CFX_ListCtrl::OnVK_HOME(bool bShift, bool bCtrl) {
349 OnVK(0, bShift, bCtrl); 349 OnVK(0, bShift, bCtrl);
350 } 350 }
351 351
352 void CFX_ListCtrl::OnVK_END(FX_BOOL bShift, FX_BOOL bCtrl) { 352 void CFX_ListCtrl::OnVK_END(bool bShift, bool bCtrl) {
353 OnVK(GetCount() - 1, bShift, bCtrl); 353 OnVK(GetCount() - 1, bShift, bCtrl);
354 } 354 }
355 355
356 FX_BOOL CFX_ListCtrl::OnChar(uint16_t nChar, FX_BOOL bShift, FX_BOOL bCtrl) { 356 bool CFX_ListCtrl::OnChar(uint16_t nChar, bool bShift, bool bCtrl) {
357 int32_t nIndex = GetLastSelected(); 357 int32_t nIndex = GetLastSelected();
358 int32_t nFindIndex = FindNext(nIndex, nChar); 358 int32_t nFindIndex = FindNext(nIndex, nChar);
359 359
360 if (nFindIndex != nIndex) { 360 if (nFindIndex != nIndex) {
361 OnVK(nFindIndex, bShift, bCtrl); 361 OnVK(nFindIndex, bShift, bCtrl);
362 return TRUE; 362 return true;
363 } 363 }
364 return FALSE; 364 return false;
365 } 365 }
366 366
367 void CFX_ListCtrl::SetPlateRect(const CFX_FloatRect& rect) { 367 void CFX_ListCtrl::SetPlateRect(const CFX_FloatRect& rect) {
368 CFX_ListContainer::SetPlateRect(rect); 368 CFX_ListContainer::SetPlateRect(rect);
369 m_ptScrollPos.x = rect.left; 369 m_ptScrollPos.x = rect.left;
370 SetScrollPos(CFX_FloatPoint(rect.left, rect.top)); 370 SetScrollPos(CFX_FloatPoint(rect.left, rect.top));
371 ReArrange(0); 371 ReArrange(0);
372 InvalidateItem(-1); 372 InvalidateItem(-1);
373 } 373 }
374 374
(...skipping 18 matching lines...) Expand all
393 393
394 int32_t CFX_ListCtrl::GetSelect() const { 394 int32_t CFX_ListCtrl::GetSelect() const {
395 return m_nSelItem; 395 return m_nSelItem;
396 } 396 }
397 397
398 void CFX_ListCtrl::AddString(const CFX_WideString& str) { 398 void CFX_ListCtrl::AddString(const CFX_WideString& str) {
399 AddItem(str); 399 AddItem(str);
400 ReArrange(GetCount() - 1); 400 ReArrange(GetCount() - 1);
401 } 401 }
402 402
403 void CFX_ListCtrl::SetMultipleSelect(int32_t nItemIndex, FX_BOOL bSelected) { 403 void CFX_ListCtrl::SetMultipleSelect(int32_t nItemIndex, bool bSelected) {
404 if (!IsValid(nItemIndex)) 404 if (!IsValid(nItemIndex))
405 return; 405 return;
406 406
407 if (bSelected != IsItemSelected(nItemIndex)) { 407 if (bSelected != IsItemSelected(nItemIndex)) {
408 if (bSelected) { 408 if (bSelected) {
409 SetItemSelect(nItemIndex, TRUE); 409 SetItemSelect(nItemIndex, true);
410 InvalidateItem(nItemIndex); 410 InvalidateItem(nItemIndex);
411 } else { 411 } else {
412 SetItemSelect(nItemIndex, FALSE); 412 SetItemSelect(nItemIndex, false);
413 InvalidateItem(nItemIndex); 413 InvalidateItem(nItemIndex);
414 } 414 }
415 } 415 }
416 } 416 }
417 417
418 void CFX_ListCtrl::SetSingleSelect(int32_t nItemIndex) { 418 void CFX_ListCtrl::SetSingleSelect(int32_t nItemIndex) {
419 if (!IsValid(nItemIndex)) 419 if (!IsValid(nItemIndex))
420 return; 420 return;
421 421
422 if (m_nSelItem != nItemIndex) { 422 if (m_nSelItem != nItemIndex) {
423 if (m_nSelItem >= 0) { 423 if (m_nSelItem >= 0) {
424 SetItemSelect(m_nSelItem, FALSE); 424 SetItemSelect(m_nSelItem, false);
425 InvalidateItem(m_nSelItem); 425 InvalidateItem(m_nSelItem);
426 } 426 }
427 427
428 SetItemSelect(nItemIndex, TRUE); 428 SetItemSelect(nItemIndex, true);
429 InvalidateItem(nItemIndex); 429 InvalidateItem(nItemIndex);
430 m_nSelItem = nItemIndex; 430 m_nSelItem = nItemIndex;
431 } 431 }
432 } 432 }
433 433
434 void CFX_ListCtrl::SetCaret(int32_t nItemIndex) { 434 void CFX_ListCtrl::SetCaret(int32_t nItemIndex) {
435 if (!IsValid(nItemIndex)) 435 if (!IsValid(nItemIndex))
436 return; 436 return;
437 437
438 if (IsMultipleSel()) { 438 if (IsMultipleSel()) {
439 int32_t nOldIndex = m_nCaretIndex; 439 int32_t nOldIndex = m_nCaretIndex;
440 440
441 if (nOldIndex != nItemIndex) { 441 if (nOldIndex != nItemIndex) {
442 m_nCaretIndex = nItemIndex; 442 m_nCaretIndex = nItemIndex;
443 InvalidateItem(nOldIndex); 443 InvalidateItem(nOldIndex);
444 InvalidateItem(nItemIndex); 444 InvalidateItem(nItemIndex);
445 } 445 }
446 } 446 }
447 } 447 }
448 448
449 void CFX_ListCtrl::InvalidateItem(int32_t nItemIndex) { 449 void CFX_ListCtrl::InvalidateItem(int32_t nItemIndex) {
450 if (m_pNotify) { 450 if (m_pNotify) {
451 if (nItemIndex == -1) { 451 if (nItemIndex == -1) {
452 if (!m_bNotifyFlag) { 452 if (!m_bNotifyFlag) {
453 m_bNotifyFlag = TRUE; 453 m_bNotifyFlag = true;
454 CFX_FloatRect rcRefresh = GetPlateRect(); 454 CFX_FloatRect rcRefresh = GetPlateRect();
455 m_pNotify->IOnInvalidateRect(&rcRefresh); 455 m_pNotify->IOnInvalidateRect(&rcRefresh);
456 m_bNotifyFlag = FALSE; 456 m_bNotifyFlag = false;
457 } 457 }
458 } else { 458 } else {
459 if (!m_bNotifyFlag) { 459 if (!m_bNotifyFlag) {
460 m_bNotifyFlag = TRUE; 460 m_bNotifyFlag = true;
461 CFX_FloatRect rcRefresh = GetItemRect(nItemIndex); 461 CFX_FloatRect rcRefresh = GetItemRect(nItemIndex);
462 rcRefresh.left -= 1.0f; 462 rcRefresh.left -= 1.0f;
463 rcRefresh.right += 1.0f; 463 rcRefresh.right += 1.0f;
464 rcRefresh.bottom -= 1.0f; 464 rcRefresh.bottom -= 1.0f;
465 rcRefresh.top += 1.0f; 465 rcRefresh.top += 1.0f;
466 466
467 m_pNotify->IOnInvalidateRect(&rcRefresh); 467 m_pNotify->IOnInvalidateRect(&rcRefresh);
468 m_bNotifyFlag = FALSE; 468 m_bNotifyFlag = false;
469 } 469 }
470 } 470 }
471 } 471 }
472 } 472 }
473 473
474 void CFX_ListCtrl::SelectItems() { 474 void CFX_ListCtrl::SelectItems() {
475 for (int32_t i = 0, sz = m_aSelItems.GetCount(); i < sz; i++) { 475 for (int32_t i = 0, sz = m_aSelItems.GetCount(); i < sz; i++) {
476 int32_t nItemIndex = m_aSelItems.GetItemIndex(i); 476 int32_t nItemIndex = m_aSelItems.GetItemIndex(i);
477 int32_t nState = m_aSelItems.GetState(i); 477 int32_t nState = m_aSelItems.GetState(i);
478 478
479 switch (nState) { 479 switch (nState) {
480 case 1: 480 case 1:
481 SetMultipleSelect(nItemIndex, TRUE); 481 SetMultipleSelect(nItemIndex, true);
482 break; 482 break;
483 case -1: 483 case -1:
484 SetMultipleSelect(nItemIndex, FALSE); 484 SetMultipleSelect(nItemIndex, false);
485 break; 485 break;
486 } 486 }
487 } 487 }
488 488
489 m_aSelItems.Done(); 489 m_aSelItems.Done();
490 } 490 }
491 491
492 void CFX_ListCtrl::Select(int32_t nItemIndex) { 492 void CFX_ListCtrl::Select(int32_t nItemIndex) {
493 if (!IsValid(nItemIndex)) 493 if (!IsValid(nItemIndex))
494 return; 494 return;
495 495
496 if (IsMultipleSel()) { 496 if (IsMultipleSel()) {
497 m_aSelItems.Add(nItemIndex); 497 m_aSelItems.Add(nItemIndex);
498 SelectItems(); 498 SelectItems();
499 } else { 499 } else {
500 SetSingleSelect(nItemIndex); 500 SetSingleSelect(nItemIndex);
501 } 501 }
502 } 502 }
503 503
504 FX_BOOL CFX_ListCtrl::IsItemVisible(int32_t nItemIndex) const { 504 bool CFX_ListCtrl::IsItemVisible(int32_t nItemIndex) const {
505 CFX_FloatRect rcPlate = GetPlateRect(); 505 CFX_FloatRect rcPlate = GetPlateRect();
506 CFX_FloatRect rcItem = GetItemRect(nItemIndex); 506 CFX_FloatRect rcItem = GetItemRect(nItemIndex);
507 507
508 return rcItem.bottom >= rcPlate.bottom && rcItem.top <= rcPlate.top; 508 return rcItem.bottom >= rcPlate.bottom && rcItem.top <= rcPlate.top;
509 } 509 }
510 510
511 void CFX_ListCtrl::ScrollToListItem(int32_t nItemIndex) { 511 void CFX_ListCtrl::ScrollToListItem(int32_t nItemIndex) {
512 if (!IsValid(nItemIndex)) 512 if (!IsValid(nItemIndex))
513 return; 513 return;
514 514
(...skipping 11 matching lines...) Expand all
526 } 526 }
527 } 527 }
528 } 528 }
529 529
530 void CFX_ListCtrl::SetScrollInfo() { 530 void CFX_ListCtrl::SetScrollInfo() {
531 if (m_pNotify) { 531 if (m_pNotify) {
532 CFX_FloatRect rcPlate = GetPlateRect(); 532 CFX_FloatRect rcPlate = GetPlateRect();
533 CFX_FloatRect rcContent = GetContentRectInternal(); 533 CFX_FloatRect rcContent = GetContentRectInternal();
534 534
535 if (!m_bNotifyFlag) { 535 if (!m_bNotifyFlag) {
536 m_bNotifyFlag = TRUE; 536 m_bNotifyFlag = true;
537 m_pNotify->IOnSetScrollInfoY(rcPlate.bottom, rcPlate.top, 537 m_pNotify->IOnSetScrollInfoY(rcPlate.bottom, rcPlate.top,
538 rcContent.bottom, rcContent.top, 538 rcContent.bottom, rcContent.top,
539 GetFirstHeight(), rcPlate.Height()); 539 GetFirstHeight(), rcPlate.Height());
540 m_bNotifyFlag = FALSE; 540 m_bNotifyFlag = false;
541 } 541 }
542 } 542 }
543 } 543 }
544 544
545 void CFX_ListCtrl::SetScrollPos(const CFX_FloatPoint& point) { 545 void CFX_ListCtrl::SetScrollPos(const CFX_FloatPoint& point) {
546 SetScrollPosY(point.y); 546 SetScrollPosY(point.y);
547 } 547 }
548 548
549 void CFX_ListCtrl::SetScrollPosY(FX_FLOAT fy) { 549 void CFX_ListCtrl::SetScrollPosY(FX_FLOAT fy) {
550 if (!IsFloatEqual(m_ptScrollPos.y, fy)) { 550 if (!IsFloatEqual(m_ptScrollPos.y, fy)) {
551 CFX_FloatRect rcPlate = GetPlateRect(); 551 CFX_FloatRect rcPlate = GetPlateRect();
552 CFX_FloatRect rcContent = GetContentRectInternal(); 552 CFX_FloatRect rcContent = GetContentRectInternal();
553 553
554 if (rcPlate.Height() > rcContent.Height()) { 554 if (rcPlate.Height() > rcContent.Height()) {
555 fy = rcPlate.top; 555 fy = rcPlate.top;
556 } else { 556 } else {
557 if (IsFloatSmaller(fy - rcPlate.Height(), rcContent.bottom)) { 557 if (IsFloatSmaller(fy - rcPlate.Height(), rcContent.bottom)) {
558 fy = rcContent.bottom + rcPlate.Height(); 558 fy = rcContent.bottom + rcPlate.Height();
559 } else if (IsFloatBigger(fy, rcContent.top)) { 559 } else if (IsFloatBigger(fy, rcContent.top)) {
560 fy = rcContent.top; 560 fy = rcContent.top;
561 } 561 }
562 } 562 }
563 563
564 m_ptScrollPos.y = fy; 564 m_ptScrollPos.y = fy;
565 InvalidateItem(-1); 565 InvalidateItem(-1);
566 566
567 if (m_pNotify) { 567 if (m_pNotify) {
568 if (!m_bNotifyFlag) { 568 if (!m_bNotifyFlag) {
569 m_bNotifyFlag = TRUE; 569 m_bNotifyFlag = true;
570 m_pNotify->IOnSetScrollPosY(fy); 570 m_pNotify->IOnSetScrollPosY(fy);
571 m_bNotifyFlag = FALSE; 571 m_bNotifyFlag = false;
572 } 572 }
573 } 573 }
574 } 574 }
575 } 575 }
576 576
577 CFX_FloatRect CFX_ListCtrl::GetContentRectInternal() const { 577 CFX_FloatRect CFX_ListCtrl::GetContentRectInternal() const {
578 return InnerToOuter(CFX_ListContainer::GetContentRect()); 578 return InnerToOuter(CFX_ListContainer::GetContentRect());
579 } 579 }
580 580
581 CFX_FloatRect CFX_ListCtrl::GetContentRect() const { 581 CFX_FloatRect CFX_ListCtrl::GetContentRect() const {
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
626 InvalidateItem(-1); 626 InvalidateItem(-1);
627 } 627 }
628 628
629 void CFX_ListCtrl::Cancel() { 629 void CFX_ListCtrl::Cancel() {
630 m_aSelItems.DeselectAll(); 630 m_aSelItems.DeselectAll();
631 } 631 }
632 632
633 int32_t CFX_ListCtrl::GetItemIndex(const CFX_FloatPoint& point) const { 633 int32_t CFX_ListCtrl::GetItemIndex(const CFX_FloatPoint& point) const {
634 CFX_FloatPoint pt = OuterToInner(OutToIn(point)); 634 CFX_FloatPoint pt = OuterToInner(OutToIn(point));
635 635
636 FX_BOOL bFirst = TRUE; 636 bool bFirst = true;
637 FX_BOOL bLast = TRUE; 637 bool bLast = true;
638 638
639 for (int32_t i = 0, sz = m_aListItems.GetSize(); i < sz; i++) { 639 for (int32_t i = 0, sz = m_aListItems.GetSize(); i < sz; i++) {
640 if (CFX_ListItem* pListItem = m_aListItems.GetAt(i)) { 640 if (CFX_ListItem* pListItem = m_aListItems.GetAt(i)) {
641 CLST_Rect rcListItem = pListItem->GetRect(); 641 CLST_Rect rcListItem = pListItem->GetRect();
642 642
643 if (IsFloatBigger(pt.y, rcListItem.top)) { 643 if (IsFloatBigger(pt.y, rcListItem.top)) {
644 bFirst = FALSE; 644 bFirst = false;
645 } 645 }
646 646
647 if (IsFloatSmaller(pt.y, rcListItem.bottom)) { 647 if (IsFloatSmaller(pt.y, rcListItem.bottom)) {
648 bLast = FALSE; 648 bLast = false;
649 } 649 }
650 650
651 if (pt.y >= rcListItem.top && pt.y < rcListItem.bottom) { 651 if (pt.y >= rcListItem.top && pt.y < rcListItem.bottom) {
652 return i; 652 return i;
653 } 653 }
654 } 654 }
655 } 655 }
656 656
657 if (bFirst) 657 if (bFirst)
658 return 0; 658 return 0;
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after
748 748
749 if (CFX_ListItem* pListItem = m_aListItems.GetAt(nCircleIndex)) { 749 if (CFX_ListItem* pListItem = m_aListItems.GetAt(nCircleIndex)) {
750 if (Toupper(pListItem->GetFirstChar()) == Toupper(nChar)) 750 if (Toupper(pListItem->GetFirstChar()) == Toupper(nChar))
751 return nCircleIndex; 751 return nCircleIndex;
752 } 752 }
753 } 753 }
754 754
755 return nCircleIndex; 755 return nCircleIndex;
756 } 756 }
757 757
758 FX_BOOL CFX_ListCtrl::IsItemSelected(int32_t nIndex) const { 758 bool CFX_ListCtrl::IsItemSelected(int32_t nIndex) const {
759 if (CFX_ListItem* pListItem = m_aListItems.GetAt(nIndex)) 759 if (CFX_ListItem* pListItem = m_aListItems.GetAt(nIndex))
760 return pListItem->IsSelected(); 760 return pListItem->IsSelected();
761 return FALSE; 761 return false;
762 } 762 }
763 763
764 void CFX_ListCtrl::SetItemSelect(int32_t nItemIndex, FX_BOOL bSelected) { 764 void CFX_ListCtrl::SetItemSelect(int32_t nItemIndex, bool bSelected) {
765 if (CFX_ListItem* pListItem = m_aListItems.GetAt(nItemIndex)) { 765 if (CFX_ListItem* pListItem = m_aListItems.GetAt(nItemIndex)) {
766 pListItem->SetSelect(bSelected); 766 pListItem->SetSelect(bSelected);
767 } 767 }
768 } 768 }
769 769
770 void CFX_ListCtrl::SetMultipleSel(FX_BOOL bMultiple) { 770 void CFX_ListCtrl::SetMultipleSel(bool bMultiple) {
771 m_bMultiple = bMultiple; 771 m_bMultiple = bMultiple;
772 } 772 }
773 773
774 FX_BOOL CFX_ListCtrl::IsMultipleSel() const { 774 bool CFX_ListCtrl::IsMultipleSel() const {
775 return m_bMultiple; 775 return m_bMultiple;
776 } 776 }
777 777
778 FX_BOOL CFX_ListCtrl::IsValid(int32_t nItemIndex) const { 778 bool CFX_ListCtrl::IsValid(int32_t nItemIndex) const {
779 return nItemIndex >= 0 && nItemIndex < m_aListItems.GetSize(); 779 return nItemIndex >= 0 && nItemIndex < m_aListItems.GetSize();
780 } 780 }
781 781
782 CFX_WideString CFX_ListCtrl::GetItemText(int32_t nIndex) const { 782 CFX_WideString CFX_ListCtrl::GetItemText(int32_t nIndex) const {
783 if (CFX_ListItem* pListItem = m_aListItems.GetAt(nIndex)) { 783 if (CFX_ListItem* pListItem = m_aListItems.GetAt(nIndex)) {
784 return pListItem->GetText(); 784 return pListItem->GetText();
785 } 785 }
786 786
787 return L""; 787 return L"";
788 } 788 }
OLDNEW
« no previous file with comments | « fpdfsdk/fxedit/fxet_list.h ('k') | fpdfsdk/ipdfsdk_annothandler.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698