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 "../../include/fxedit/fxet_stub.h" | 7 #include "../../include/fxedit/fxet_stub.h" |
8 #include "../../include/fxedit/fxet_edit.h" | 8 #include "../../include/fxedit/fxet_edit.h" |
9 #include "../../include/fxedit/fxet_list.h" | 9 #include "../../include/fxedit/fxet_list.h" |
10 | 10 |
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
123 { | 123 { |
124 } | 124 } |
125 | 125 |
126 CFX_List::~CFX_List() | 126 CFX_List::~CFX_List() |
127 { | 127 { |
128 Empty(); | 128 Empty(); |
129 } | 129 } |
130 | 130 |
131 void CFX_List::Empty() | 131 void CFX_List::Empty() |
132 { | 132 { |
133 » for (FX_INT32 i=0,sz=m_aListItems.GetSize(); i<sz; i++) | 133 » for (int32_t i=0,sz=m_aListItems.GetSize(); i<sz; i++) |
134 delete m_aListItems.GetAt(i); | 134 delete m_aListItems.GetAt(i); |
135 | 135 |
136 m_aListItems.RemoveAll(); | 136 m_aListItems.RemoveAll(); |
137 } | 137 } |
138 | 138 |
139 void CFX_List::SetFontMap(IFX_Edit_FontMap * pFontMap) | 139 void CFX_List::SetFontMap(IFX_Edit_FontMap * pFontMap) |
140 { | 140 { |
141 m_pFontMap = pFontMap; | 141 m_pFontMap = pFontMap; |
142 } | 142 } |
143 | 143 |
144 void CFX_List::SetFontSize(FX_FLOAT fFontSize) | 144 void CFX_List::SetFontSize(FX_FLOAT fFontSize) |
145 { | 145 { |
146 m_fFontSize = fFontSize; | 146 m_fFontSize = fFontSize; |
147 } | 147 } |
148 | 148 |
149 void CFX_List::AddItem(FX_LPCWSTR str) | 149 void CFX_List::AddItem(FX_LPCWSTR str) |
150 { | 150 { |
151 if (CFX_ListItem * pListItem = new CFX_ListItem()) | 151 if (CFX_ListItem * pListItem = new CFX_ListItem()) |
152 { | 152 { |
153 pListItem->SetFontMap(m_pFontMap); | 153 pListItem->SetFontMap(m_pFontMap); |
154 pListItem->SetFontSize(m_fFontSize); | 154 pListItem->SetFontSize(m_fFontSize); |
155 pListItem->SetText(str); | 155 pListItem->SetText(str); |
156 m_aListItems.Add(pListItem); | 156 m_aListItems.Add(pListItem); |
157 } | 157 } |
158 } | 158 } |
159 | 159 |
160 void CFX_List::ReArrange(FX_INT32 nItemIndex) | 160 void CFX_List::ReArrange(int32_t nItemIndex) |
161 { | 161 { |
162 FX_FLOAT fPosY = 0.0f; | 162 FX_FLOAT fPosY = 0.0f; |
163 | 163 |
164 if (CFX_ListItem * pPrevItem = m_aListItems.GetAt(nItemIndex - 1)) | 164 if (CFX_ListItem * pPrevItem = m_aListItems.GetAt(nItemIndex - 1)) |
165 fPosY = pPrevItem->GetRect().bottom; | 165 fPosY = pPrevItem->GetRect().bottom; |
166 | 166 |
167 » for (FX_INT32 i=nItemIndex,sz=m_aListItems.GetSize(); i<sz; i++) | 167 » for (int32_t i=nItemIndex,sz=m_aListItems.GetSize(); i<sz; i++) |
168 { | 168 { |
169 if (CFX_ListItem * pListItem = m_aListItems.GetAt(i)) | 169 if (CFX_ListItem * pListItem = m_aListItems.GetAt(i)) |
170 { | 170 { |
171 FX_FLOAT fListItemHeight = pListItem->GetItemHeight(); | 171 FX_FLOAT fListItemHeight = pListItem->GetItemHeight(); |
172 pListItem->SetRect(CLST_Rect(0.0f,fPosY,0.0f,fPosY + fLi
stItemHeight)); | 172 pListItem->SetRect(CLST_Rect(0.0f,fPosY,0.0f,fPosY + fLi
stItemHeight)); |
173 fPosY += fListItemHeight; | 173 fPosY += fListItemHeight; |
174 } | 174 } |
175 } | 175 } |
176 | 176 |
177 SetContentRect(CLST_Rect(0.0f,0.0f,0.0f,fPosY)); | 177 SetContentRect(CLST_Rect(0.0f,0.0f,0.0f,fPosY)); |
178 } | 178 } |
179 | 179 |
180 IFX_Edit * CFX_List::GetItemEdit(FX_INT32 nIndex) const | 180 IFX_Edit * CFX_List::GetItemEdit(int32_t nIndex) const |
181 { | 181 { |
182 if (CFX_ListItem * pListItem = m_aListItems.GetAt(nIndex)) | 182 if (CFX_ListItem * pListItem = m_aListItems.GetAt(nIndex)) |
183 { | 183 { |
184 return pListItem->GetEdit(); | 184 return pListItem->GetEdit(); |
185 } | 185 } |
186 | 186 |
187 return NULL; | 187 return NULL; |
188 } | 188 } |
189 | 189 |
190 FX_INT32 CFX_List::GetCount() const | 190 int32_t CFX_List::GetCount() const |
191 { | 191 { |
192 return m_aListItems.GetSize(); | 192 return m_aListItems.GetSize(); |
193 } | 193 } |
194 | 194 |
195 CPDF_Rect CFX_List::GetPlateRect() const | 195 CPDF_Rect CFX_List::GetPlateRect() const |
196 { | 196 { |
197 return CFX_ListContainer::GetPlateRect(); | 197 return CFX_ListContainer::GetPlateRect(); |
198 } | 198 } |
199 | 199 |
200 CPDF_Rect CFX_List::GetContentRect() const | 200 CPDF_Rect CFX_List::GetContentRect() const |
201 { | 201 { |
202 return InnerToOuter(CFX_ListContainer::GetContentRect()); | 202 return InnerToOuter(CFX_ListContainer::GetContentRect()); |
203 } | 203 } |
204 | 204 |
205 FX_FLOAT CFX_List::GetFontSize() const | 205 FX_FLOAT CFX_List::GetFontSize() const |
206 { | 206 { |
207 return m_fFontSize; | 207 return m_fFontSize; |
208 } | 208 } |
209 | 209 |
210 FX_INT32 CFX_List::GetItemIndex(const CPDF_Point & point) const | 210 int32_t CFX_List::GetItemIndex(const CPDF_Point & point) const |
211 { | 211 { |
212 CPDF_Point pt = OuterToInner(point); | 212 CPDF_Point pt = OuterToInner(point); |
213 | 213 |
214 FX_BOOL bFirst = TRUE; | 214 FX_BOOL bFirst = TRUE; |
215 FX_BOOL bLast = TRUE; | 215 FX_BOOL bLast = TRUE; |
216 | 216 |
217 » for (FX_INT32 i=0,sz=m_aListItems.GetSize(); i<sz; i++) | 217 » for (int32_t i=0,sz=m_aListItems.GetSize(); i<sz; i++) |
218 { | 218 { |
219 if (CFX_ListItem * pListItem = m_aListItems.GetAt(i)) | 219 if (CFX_ListItem * pListItem = m_aListItems.GetAt(i)) |
220 { | 220 { |
221 CLST_Rect rcListItem = pListItem->GetRect(); | 221 CLST_Rect rcListItem = pListItem->GetRect(); |
222 | 222 |
223 if (FX_EDIT_IsFloatBigger(pt.y, rcListItem.top)) | 223 if (FX_EDIT_IsFloatBigger(pt.y, rcListItem.top)) |
224 { | 224 { |
225 bFirst = FALSE; | 225 bFirst = FALSE; |
226 } | 226 } |
227 | 227 |
(...skipping 18 matching lines...) Expand all Loading... |
246 FX_FLOAT CFX_List::GetFirstHeight() const | 246 FX_FLOAT CFX_List::GetFirstHeight() const |
247 { | 247 { |
248 if (CFX_ListItem * pListItem = m_aListItems.GetAt(0)) | 248 if (CFX_ListItem * pListItem = m_aListItems.GetAt(0)) |
249 { | 249 { |
250 return pListItem->GetItemHeight(); | 250 return pListItem->GetItemHeight(); |
251 } | 251 } |
252 | 252 |
253 return 1.0f; | 253 return 1.0f; |
254 } | 254 } |
255 | 255 |
256 FX_INT32 CFX_List::GetFirstSelected() const | 256 int32_t CFX_List::GetFirstSelected() const |
257 { | 257 { |
258 » for (FX_INT32 i=0,sz=m_aListItems.GetSize(); i<sz; i++) | 258 » for (int32_t i=0,sz=m_aListItems.GetSize(); i<sz; i++) |
259 { | 259 { |
260 if (CFX_ListItem * pListItem = m_aListItems.GetAt(i)) | 260 if (CFX_ListItem * pListItem = m_aListItems.GetAt(i)) |
261 { | 261 { |
262 if (pListItem->IsSelected()) | 262 if (pListItem->IsSelected()) |
263 return i; | 263 return i; |
264 } | 264 } |
265 } | 265 } |
266 return -1; | 266 return -1; |
267 } | 267 } |
268 | 268 |
269 FX_INT32 CFX_List::GetLastSelected() const | 269 int32_t CFX_List::GetLastSelected() const |
270 { | 270 { |
271 » for (FX_INT32 i=m_aListItems.GetSize()-1; i>=0; i--) | 271 » for (int32_t i=m_aListItems.GetSize()-1; i>=0; i--) |
272 { | 272 { |
273 if (CFX_ListItem * pListItem = m_aListItems.GetAt(i)) | 273 if (CFX_ListItem * pListItem = m_aListItems.GetAt(i)) |
274 { | 274 { |
275 if (pListItem->IsSelected()) | 275 if (pListItem->IsSelected()) |
276 return i; | 276 return i; |
277 } | 277 } |
278 } | 278 } |
279 return -1; | 279 return -1; |
280 } | 280 } |
281 | 281 |
282 FX_WCHAR CFX_List::Toupper(FX_WCHAR c) const | 282 FX_WCHAR CFX_List::Toupper(FX_WCHAR c) const |
283 { | 283 { |
284 if ( (c >= 'a') && (c <= 'z') ) | 284 if ( (c >= 'a') && (c <= 'z') ) |
285 c = c - ('a' - 'A'); | 285 c = c - ('a' - 'A'); |
286 return c; | 286 return c; |
287 } | 287 } |
288 | 288 |
289 FX_INT32 CFX_List::FindNext(FX_INT32 nIndex,FX_WCHAR nChar) const | 289 int32_t CFX_List::FindNext(int32_t nIndex,FX_WCHAR nChar) const |
290 { | 290 { |
291 » FX_INT32 nCircleIndex = nIndex; | 291 » int32_t nCircleIndex = nIndex; |
292 | 292 |
293 » for (FX_INT32 i=0,sz=m_aListItems.GetSize(); i<sz; i++) | 293 » for (int32_t i=0,sz=m_aListItems.GetSize(); i<sz; i++) |
294 { | 294 { |
295 nCircleIndex ++; | 295 nCircleIndex ++; |
296 if (nCircleIndex >= sz) nCircleIndex = 0; | 296 if (nCircleIndex >= sz) nCircleIndex = 0; |
297 | 297 |
298 if (CFX_ListItem * pListItem = m_aListItems.GetAt(nCircleIndex)) | 298 if (CFX_ListItem * pListItem = m_aListItems.GetAt(nCircleIndex)) |
299 { | 299 { |
300 if (Toupper(pListItem->GetFirstChar()) == Toupper(nChar)
) | 300 if (Toupper(pListItem->GetFirstChar()) == Toupper(nChar)
) |
301 return nCircleIndex; | 301 return nCircleIndex; |
302 } | 302 } |
303 } | 303 } |
304 | 304 |
305 return nCircleIndex; | 305 return nCircleIndex; |
306 } | 306 } |
307 | 307 |
308 CPDF_Rect CFX_List::GetItemRect(FX_INT32 nIndex) const | 308 CPDF_Rect CFX_List::GetItemRect(int32_t nIndex) const |
309 { | 309 { |
310 if (CFX_ListItem * pListItem = m_aListItems.GetAt(nIndex)) | 310 if (CFX_ListItem * pListItem = m_aListItems.GetAt(nIndex)) |
311 { | 311 { |
312 CPDF_Rect rcItem = pListItem->GetRect(); | 312 CPDF_Rect rcItem = pListItem->GetRect(); |
313 rcItem.left = 0.0f; | 313 rcItem.left = 0.0f; |
314 rcItem.right = GetPlateRect().Width(); | 314 rcItem.right = GetPlateRect().Width(); |
315 return InnerToOuter(rcItem); | 315 return InnerToOuter(rcItem); |
316 } | 316 } |
317 | 317 |
318 return CPDF_Rect(); | 318 return CPDF_Rect(); |
319 } | 319 } |
320 | 320 |
321 FX_BOOL CFX_List::IsItemSelected(FX_INT32 nIndex) const | 321 FX_BOOL CFX_List::IsItemSelected(int32_t nIndex) const |
322 { | 322 { |
323 if (CFX_ListItem * pListItem = m_aListItems.GetAt(nIndex)) | 323 if (CFX_ListItem * pListItem = m_aListItems.GetAt(nIndex)) |
324 { | 324 { |
325 return pListItem->IsSelected(); | 325 return pListItem->IsSelected(); |
326 } | 326 } |
327 | 327 |
328 return FALSE; | 328 return FALSE; |
329 } | 329 } |
330 | 330 |
331 void CFX_List::SetItemSelect(FX_INT32 nItemIndex, FX_BOOL bSelected) | 331 void CFX_List::SetItemSelect(int32_t nItemIndex, FX_BOOL bSelected) |
332 { | 332 { |
333 if (CFX_ListItem * pListItem = m_aListItems.GetAt(nItemIndex)) | 333 if (CFX_ListItem * pListItem = m_aListItems.GetAt(nItemIndex)) |
334 { | 334 { |
335 pListItem->SetSelect(bSelected); | 335 pListItem->SetSelect(bSelected); |
336 } | 336 } |
337 } | 337 } |
338 | 338 |
339 void CFX_List::SetItemCaret(FX_INT32 nItemIndex, FX_BOOL bCaret) | 339 void CFX_List::SetItemCaret(int32_t nItemIndex, FX_BOOL bCaret) |
340 { | 340 { |
341 if (CFX_ListItem * pListItem = m_aListItems.GetAt(nItemIndex)) | 341 if (CFX_ListItem * pListItem = m_aListItems.GetAt(nItemIndex)) |
342 { | 342 { |
343 pListItem->SetCaret(bCaret); | 343 pListItem->SetCaret(bCaret); |
344 } | 344 } |
345 } | 345 } |
346 | 346 |
347 void CFX_List::SetMultipleSel(FX_BOOL bMultiple) | 347 void CFX_List::SetMultipleSel(FX_BOOL bMultiple) |
348 { | 348 { |
349 m_bMultiple = bMultiple; | 349 m_bMultiple = bMultiple; |
350 } | 350 } |
351 | 351 |
352 FX_BOOL CFX_List::IsMultipleSel() const | 352 FX_BOOL CFX_List::IsMultipleSel() const |
353 { | 353 { |
354 return m_bMultiple; | 354 return m_bMultiple; |
355 } | 355 } |
356 | 356 |
357 FX_BOOL CFX_List::IsValid(FX_INT32 nItemIndex) const | 357 FX_BOOL CFX_List::IsValid(int32_t nItemIndex) const |
358 { | 358 { |
359 return nItemIndex >= 0 && nItemIndex < m_aListItems.GetSize(); | 359 return nItemIndex >= 0 && nItemIndex < m_aListItems.GetSize(); |
360 } | 360 } |
361 | 361 |
362 CFX_WideString CFX_List::GetItemText(FX_INT32 nIndex) const | 362 CFX_WideString CFX_List::GetItemText(int32_t nIndex) const |
363 { | 363 { |
364 if (CFX_ListItem * pListItem = m_aListItems.GetAt(nIndex)) | 364 if (CFX_ListItem * pListItem = m_aListItems.GetAt(nIndex)) |
365 { | 365 { |
366 return pListItem->GetText(); | 366 return pListItem->GetText(); |
367 } | 367 } |
368 | 368 |
369 return L""; | 369 return L""; |
370 } | 370 } |
371 | 371 |
372 /* ------------------------------------ CPLST_Select ---------------------------
------- */ | 372 /* ------------------------------------ CPLST_Select ---------------------------
------- */ |
373 | 373 |
374 CPLST_Select::CPLST_Select() | 374 CPLST_Select::CPLST_Select() |
375 { | 375 { |
376 } | 376 } |
377 | 377 |
378 CPLST_Select::~CPLST_Select() | 378 CPLST_Select::~CPLST_Select() |
379 { | 379 { |
380 » for (FX_INT32 i=0,sz=m_aItems.GetSize(); i<sz; i++) | 380 » for (int32_t i=0,sz=m_aItems.GetSize(); i<sz; i++) |
381 delete m_aItems.GetAt(i); | 381 delete m_aItems.GetAt(i); |
382 | 382 |
383 m_aItems.RemoveAll(); | 383 m_aItems.RemoveAll(); |
384 } | 384 } |
385 | 385 |
386 void CPLST_Select::Add(FX_INT32 nItemIndex) | 386 void CPLST_Select::Add(int32_t nItemIndex) |
387 { | 387 { |
388 » FX_INT32 nIndex = Find(nItemIndex); | 388 » int32_t nIndex = Find(nItemIndex); |
389 | 389 |
390 if (nIndex < 0) | 390 if (nIndex < 0) |
391 m_aItems.Add(new CPLST_Select_Item(nItemIndex,1)); | 391 m_aItems.Add(new CPLST_Select_Item(nItemIndex,1)); |
392 else | 392 else |
393 { | 393 { |
394 if (CPLST_Select_Item * pItem = m_aItems.GetAt(nIndex)) | 394 if (CPLST_Select_Item * pItem = m_aItems.GetAt(nIndex)) |
395 { | 395 { |
396 pItem->nState = 1; | 396 pItem->nState = 1; |
397 } | 397 } |
398 } | 398 } |
399 } | 399 } |
400 | 400 |
401 void CPLST_Select::Add(FX_INT32 nBeginIndex, FX_INT32 nEndIndex) | 401 void CPLST_Select::Add(int32_t nBeginIndex, int32_t nEndIndex) |
402 { | 402 { |
403 if (nBeginIndex > nEndIndex) | 403 if (nBeginIndex > nEndIndex) |
404 { | 404 { |
405 » » FX_INT32 nTemp = nEndIndex; | 405 » » int32_t nTemp = nEndIndex; |
406 nEndIndex = nBeginIndex; | 406 nEndIndex = nBeginIndex; |
407 nBeginIndex = nTemp; | 407 nBeginIndex = nTemp; |
408 } | 408 } |
409 | 409 |
410 » for (FX_INT32 i=nBeginIndex; i<=nEndIndex; i++)»Add(i); | 410 » for (int32_t i=nBeginIndex; i<=nEndIndex; i++)» Add(i); |
411 } | 411 } |
412 | 412 |
413 void CPLST_Select::Sub(FX_INT32 nItemIndex) | 413 void CPLST_Select::Sub(int32_t nItemIndex) |
414 { | 414 { |
415 » for (FX_INT32 i=m_aItems.GetSize()-1; i>=0; i--) | 415 » for (int32_t i=m_aItems.GetSize()-1; i>=0; i--) |
416 { | 416 { |
417 if (CPLST_Select_Item * pItem = m_aItems.GetAt(i)) | 417 if (CPLST_Select_Item * pItem = m_aItems.GetAt(i)) |
418 if (pItem->nItemIndex == nItemIndex) | 418 if (pItem->nItemIndex == nItemIndex) |
419 pItem->nState = -1; | 419 pItem->nState = -1; |
420 } | 420 } |
421 } | 421 } |
422 | 422 |
423 void CPLST_Select::Sub(FX_INT32 nBeginIndex, FX_INT32 nEndIndex) | 423 void CPLST_Select::Sub(int32_t nBeginIndex, int32_t nEndIndex) |
424 { | 424 { |
425 if (nBeginIndex > nEndIndex) | 425 if (nBeginIndex > nEndIndex) |
426 { | 426 { |
427 » » FX_INT32 nTemp = nEndIndex; | 427 » » int32_t nTemp = nEndIndex; |
428 nEndIndex = nBeginIndex; | 428 nEndIndex = nBeginIndex; |
429 nBeginIndex = nTemp; | 429 nBeginIndex = nTemp; |
430 } | 430 } |
431 | 431 |
432 » for (FX_INT32 i=nBeginIndex; i<=nEndIndex; i++)»Sub(i); | 432 » for (int32_t i=nBeginIndex; i<=nEndIndex; i++)» Sub(i); |
433 } | 433 } |
434 | 434 |
435 FX_INT32 CPLST_Select::Find(FX_INT32 nItemIndex) const | 435 int32_t CPLST_Select::Find(int32_t nItemIndex) const |
436 { | 436 { |
437 » for (FX_INT32 i=0,sz=m_aItems.GetSize(); i<sz; i++) | 437 » for (int32_t i=0,sz=m_aItems.GetSize(); i<sz; i++) |
438 { | 438 { |
439 if (CPLST_Select_Item * pItem = m_aItems.GetAt(i)) | 439 if (CPLST_Select_Item * pItem = m_aItems.GetAt(i)) |
440 { | 440 { |
441 if (pItem->nItemIndex == nItemIndex) | 441 if (pItem->nItemIndex == nItemIndex) |
442 return i; | 442 return i; |
443 } | 443 } |
444 } | 444 } |
445 | 445 |
446 return -1; | 446 return -1; |
447 } | 447 } |
448 | 448 |
449 FX_BOOL CPLST_Select::IsExist(FX_INT32 nItemIndex) const | 449 FX_BOOL CPLST_Select::IsExist(int32_t nItemIndex) const |
450 { | 450 { |
451 return Find(nItemIndex) >= 0; | 451 return Find(nItemIndex) >= 0; |
452 } | 452 } |
453 | 453 |
454 FX_INT32 CPLST_Select::GetCount() const | 454 int32_t CPLST_Select::GetCount() const |
455 { | 455 { |
456 return m_aItems.GetSize(); | 456 return m_aItems.GetSize(); |
457 } | 457 } |
458 | 458 |
459 FX_INT32 CPLST_Select::GetItemIndex(FX_INT32 nIndex) const | 459 int32_t CPLST_Select::GetItemIndex(int32_t nIndex) const |
460 { | 460 { |
461 if (nIndex >= 0 && nIndex < m_aItems.GetSize()) | 461 if (nIndex >= 0 && nIndex < m_aItems.GetSize()) |
462 if (CPLST_Select_Item * pItem = m_aItems.GetAt(nIndex)) | 462 if (CPLST_Select_Item * pItem = m_aItems.GetAt(nIndex)) |
463 return pItem->nItemIndex; | 463 return pItem->nItemIndex; |
464 | 464 |
465 return -1; | 465 return -1; |
466 } | 466 } |
467 | 467 |
468 FX_INT32 CPLST_Select::GetState(FX_INT32 nIndex) const | 468 int32_t CPLST_Select::GetState(int32_t nIndex) const |
469 { | 469 { |
470 if (nIndex >= 0 && nIndex < m_aItems.GetSize()) | 470 if (nIndex >= 0 && nIndex < m_aItems.GetSize()) |
471 if (CPLST_Select_Item * pItem = m_aItems.GetAt(nIndex)) | 471 if (CPLST_Select_Item * pItem = m_aItems.GetAt(nIndex)) |
472 return pItem->nState; | 472 return pItem->nState; |
473 | 473 |
474 return 0; | 474 return 0; |
475 } | 475 } |
476 | 476 |
477 void CPLST_Select::DeselectAll() | 477 void CPLST_Select::DeselectAll() |
478 { | 478 { |
479 » for (FX_INT32 i=0,sz=m_aItems.GetSize(); i<sz; i++) | 479 » for (int32_t i=0,sz=m_aItems.GetSize(); i<sz; i++) |
480 { | 480 { |
481 if (CPLST_Select_Item * pItem = m_aItems.GetAt(i)) | 481 if (CPLST_Select_Item * pItem = m_aItems.GetAt(i)) |
482 { | 482 { |
483 pItem->nState = -1; | 483 pItem->nState = -1; |
484 } | 484 } |
485 } | 485 } |
486 } | 486 } |
487 | 487 |
488 void CPLST_Select::Done() | 488 void CPLST_Select::Done() |
489 { | 489 { |
490 » for (FX_INT32 i=m_aItems.GetSize()-1; i>=0; i--) | 490 » for (int32_t i=m_aItems.GetSize()-1; i>=0; i--) |
491 { | 491 { |
492 if (CPLST_Select_Item * pItem = m_aItems.GetAt(i)) | 492 if (CPLST_Select_Item * pItem = m_aItems.GetAt(i)) |
493 { | 493 { |
494 if (pItem->nState == -1) | 494 if (pItem->nState == -1) |
495 { | 495 { |
496 delete pItem; | 496 delete pItem; |
497 m_aItems.RemoveAt(i); | 497 m_aItems.RemoveAt(i); |
498 } | 498 } |
499 else | 499 else |
500 { | 500 { |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
552 CPDF_Rect CFX_ListCtrl::OutToIn(const CPDF_Rect & rect) const | 552 CPDF_Rect CFX_ListCtrl::OutToIn(const CPDF_Rect & rect) const |
553 { | 553 { |
554 CPDF_Point ptLeftBottom = OutToIn(CPDF_Point(rect.left,rect.bottom)); | 554 CPDF_Point ptLeftBottom = OutToIn(CPDF_Point(rect.left,rect.bottom)); |
555 CPDF_Point ptRightTop = OutToIn(CPDF_Point(rect.right,rect.top)); | 555 CPDF_Point ptRightTop = OutToIn(CPDF_Point(rect.right,rect.top)); |
556 | 556 |
557 return CPDF_Rect(ptLeftBottom.x,ptLeftBottom.y,ptRightTop.x,ptRightTop.y
); | 557 return CPDF_Rect(ptLeftBottom.x,ptLeftBottom.y,ptRightTop.x,ptRightTop.y
); |
558 } | 558 } |
559 | 559 |
560 void CFX_ListCtrl::OnMouseDown(const CPDF_Point & point,FX_BOOL bShift,FX_BOOL b
Ctrl) | 560 void CFX_ListCtrl::OnMouseDown(const CPDF_Point & point,FX_BOOL bShift,FX_BOOL b
Ctrl) |
561 { | 561 { |
562 » FX_INT32 nHitIndex = this->GetItemIndex(point); | 562 » int32_t nHitIndex = this->GetItemIndex(point); |
563 | 563 |
564 if (IsMultipleSel()) | 564 if (IsMultipleSel()) |
565 { | 565 { |
566 if (bCtrl) | 566 if (bCtrl) |
567 { | 567 { |
568 if (IsItemSelected(nHitIndex)) | 568 if (IsItemSelected(nHitIndex)) |
569 { | 569 { |
570 m_aSelItems.Sub(nHitIndex); | 570 m_aSelItems.Sub(nHitIndex); |
571 SelectItems(); | 571 SelectItems(); |
572 m_bCtrlSel = FALSE; | 572 m_bCtrlSel = FALSE; |
(...skipping 28 matching lines...) Expand all Loading... |
601 { | 601 { |
602 SetSingleSelect(nHitIndex); | 602 SetSingleSelect(nHitIndex); |
603 } | 603 } |
604 | 604 |
605 if (!this->IsItemVisible(nHitIndex)) | 605 if (!this->IsItemVisible(nHitIndex)) |
606 this->ScrollToListItem(nHitIndex); | 606 this->ScrollToListItem(nHitIndex); |
607 } | 607 } |
608 | 608 |
609 void CFX_ListCtrl::OnMouseMove(const CPDF_Point & point,FX_BOOL bShift,FX_BOOL b
Ctrl) | 609 void CFX_ListCtrl::OnMouseMove(const CPDF_Point & point,FX_BOOL bShift,FX_BOOL b
Ctrl) |
610 { | 610 { |
611 » FX_INT32 nHitIndex = this->GetItemIndex(point); | 611 » int32_t nHitIndex = this->GetItemIndex(point); |
612 | 612 |
613 if (IsMultipleSel()) | 613 if (IsMultipleSel()) |
614 { | 614 { |
615 if (bCtrl) | 615 if (bCtrl) |
616 { | 616 { |
617 if (m_bCtrlSel) | 617 if (m_bCtrlSel) |
618 m_aSelItems.Add(m_nFootIndex,nHitIndex); | 618 m_aSelItems.Add(m_nFootIndex,nHitIndex); |
619 else | 619 else |
620 m_aSelItems.Sub(m_nFootIndex,nHitIndex);
| 620 m_aSelItems.Sub(m_nFootIndex,nHitIndex);
|
621 | 621 |
(...skipping 10 matching lines...) Expand all Loading... |
632 } | 632 } |
633 else | 633 else |
634 { | 634 { |
635 SetSingleSelect(nHitIndex); | 635 SetSingleSelect(nHitIndex); |
636 } | 636 } |
637 | 637 |
638 if (!this->IsItemVisible(nHitIndex)) | 638 if (!this->IsItemVisible(nHitIndex)) |
639 this->ScrollToListItem(nHitIndex); | 639 this->ScrollToListItem(nHitIndex); |
640 } | 640 } |
641 | 641 |
642 void CFX_ListCtrl::OnVK(FX_INT32 nItemIndex,FX_BOOL bShift,FX_BOOL bCtrl) | 642 void CFX_ListCtrl::OnVK(int32_t nItemIndex,FX_BOOL bShift,FX_BOOL bCtrl) |
643 { | 643 { |
644 if (IsMultipleSel()) | 644 if (IsMultipleSel()) |
645 { | 645 { |
646 if (nItemIndex >= 0 && nItemIndex < GetCount()) | 646 if (nItemIndex >= 0 && nItemIndex < GetCount()) |
647 { | 647 { |
648 if (bCtrl) | 648 if (bCtrl) |
649 { | 649 { |
650 } | 650 } |
651 else if (bShift) | 651 else if (bShift) |
652 { | 652 { |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
699 OnVK(0, bShift, bCtrl); | 699 OnVK(0, bShift, bCtrl); |
700 } | 700 } |
701 | 701 |
702 void CFX_ListCtrl::OnVK_END(FX_BOOL bShift,FX_BOOL bCtrl) | 702 void CFX_ListCtrl::OnVK_END(FX_BOOL bShift,FX_BOOL bCtrl) |
703 { | 703 { |
704 OnVK(GetCount()-1, bShift, bCtrl); | 704 OnVK(GetCount()-1, bShift, bCtrl); |
705 } | 705 } |
706 | 706 |
707 FX_BOOL CFX_ListCtrl::OnChar(FX_WORD nChar,FX_BOOL bShift,FX_BOOL bCtrl) | 707 FX_BOOL CFX_ListCtrl::OnChar(FX_WORD nChar,FX_BOOL bShift,FX_BOOL bCtrl) |
708 { | 708 { |
709 » FX_INT32 nIndex = GetLastSelected();» | 709 » int32_t nIndex = GetLastSelected();» |
710 » FX_INT32 nFindIndex = FindNext(nIndex,nChar); | 710 » int32_t nFindIndex = FindNext(nIndex,nChar); |
711 | 711 |
712 if (nFindIndex != nIndex) | 712 if (nFindIndex != nIndex) |
713 { | 713 { |
714 OnVK(nFindIndex, bShift, bCtrl); | 714 OnVK(nFindIndex, bShift, bCtrl); |
715 return TRUE; | 715 return TRUE; |
716 } | 716 } |
717 return FALSE; | 717 return FALSE; |
718 } | 718 } |
719 | 719 |
720 /* -------- inner methods ------- */ | 720 /* -------- inner methods ------- */ |
721 | 721 |
722 void CFX_ListCtrl::SetPlateRect(const CPDF_Rect & rect) | 722 void CFX_ListCtrl::SetPlateRect(const CPDF_Rect & rect) |
723 { | 723 { |
724 CFX_ListContainer::SetPlateRect(rect); | 724 CFX_ListContainer::SetPlateRect(rect); |
725 m_ptScrollPos.x = rect.left; | 725 m_ptScrollPos.x = rect.left; |
726 SetScrollPos(CPDF_Point(rect.left,rect.top)); | 726 SetScrollPos(CPDF_Point(rect.left,rect.top)); |
727 ReArrange(0); | 727 ReArrange(0); |
728 InvalidateItem(-1); | 728 InvalidateItem(-1); |
729 } | 729 } |
730 | 730 |
731 CPDF_Rect CFX_ListCtrl::GetItemRect(FX_INT32 nIndex) const | 731 CPDF_Rect CFX_ListCtrl::GetItemRect(int32_t nIndex) const |
732 { | 732 { |
733 return InToOut(CFX_List::GetItemRect(nIndex)); | 733 return InToOut(CFX_List::GetItemRect(nIndex)); |
734 } | 734 } |
735 | 735 |
736 void CFX_ListCtrl::AddString(FX_LPCWSTR string) | 736 void CFX_ListCtrl::AddString(FX_LPCWSTR string) |
737 { | 737 { |
738 AddItem(string); | 738 AddItem(string); |
739 ReArrange(GetCount() - 1); | 739 ReArrange(GetCount() - 1); |
740 } | 740 } |
741 | 741 |
742 void CFX_ListCtrl::SetMultipleSelect(FX_INT32 nItemIndex, FX_BOOL bSelected) | 742 void CFX_ListCtrl::SetMultipleSelect(int32_t nItemIndex, FX_BOOL bSelected) |
743 { | 743 { |
744 if (!IsValid(nItemIndex)) return; | 744 if (!IsValid(nItemIndex)) return; |
745 | 745 |
746 if (bSelected != this->IsItemSelected(nItemIndex)) | 746 if (bSelected != this->IsItemSelected(nItemIndex)) |
747 { | 747 { |
748 if (bSelected) | 748 if (bSelected) |
749 { | 749 { |
750 SetItemSelect(nItemIndex,TRUE); | 750 SetItemSelect(nItemIndex,TRUE); |
751 InvalidateItem(nItemIndex); | 751 InvalidateItem(nItemIndex); |
752 } | 752 } |
753 else | 753 else |
754 { | 754 { |
755 SetItemSelect(nItemIndex,FALSE); | 755 SetItemSelect(nItemIndex,FALSE); |
756 InvalidateItem(nItemIndex); | 756 InvalidateItem(nItemIndex); |
757 } | 757 } |
758 } | 758 } |
759 } | 759 } |
760 | 760 |
761 void CFX_ListCtrl::SetSingleSelect(FX_INT32 nItemIndex) | 761 void CFX_ListCtrl::SetSingleSelect(int32_t nItemIndex) |
762 { | 762 { |
763 if (!IsValid(nItemIndex)) return; | 763 if (!IsValid(nItemIndex)) return; |
764 | 764 |
765 if (m_nSelItem != nItemIndex) | 765 if (m_nSelItem != nItemIndex) |
766 { | 766 { |
767 if (m_nSelItem >= 0) | 767 if (m_nSelItem >= 0) |
768 { | 768 { |
769 SetItemSelect(m_nSelItem,FALSE); | 769 SetItemSelect(m_nSelItem,FALSE); |
770 InvalidateItem(m_nSelItem); | 770 InvalidateItem(m_nSelItem); |
771 } | 771 } |
772 | 772 |
773 SetItemSelect(nItemIndex,TRUE); | 773 SetItemSelect(nItemIndex,TRUE); |
774 InvalidateItem(nItemIndex); | 774 InvalidateItem(nItemIndex); |
775 m_nSelItem = nItemIndex; | 775 m_nSelItem = nItemIndex; |
776 } | 776 } |
777 } | 777 } |
778 | 778 |
779 void CFX_ListCtrl::SetCaret(FX_INT32 nItemIndex) | 779 void CFX_ListCtrl::SetCaret(int32_t nItemIndex) |
780 { | 780 { |
781 if (!IsValid(nItemIndex)) return; | 781 if (!IsValid(nItemIndex)) return; |
782 | 782 |
783 if (this->IsMultipleSel()) | 783 if (this->IsMultipleSel()) |
784 { | 784 { |
785 » » FX_INT32 nOldIndex = m_nCaretIndex; | 785 » » int32_t nOldIndex = m_nCaretIndex; |
786 | 786 |
787 if (nOldIndex != nItemIndex) | 787 if (nOldIndex != nItemIndex) |
788 { | 788 { |
789 m_nCaretIndex = nItemIndex; | 789 m_nCaretIndex = nItemIndex; |
790 | 790 |
791 SetItemCaret(nOldIndex, FALSE); | 791 SetItemCaret(nOldIndex, FALSE); |
792 SetItemCaret(nItemIndex,TRUE); | 792 SetItemCaret(nItemIndex,TRUE); |
793 | 793 |
794 InvalidateItem(nOldIndex); | 794 InvalidateItem(nOldIndex); |
795 InvalidateItem(nItemIndex); | 795 InvalidateItem(nItemIndex); |
796 } | 796 } |
797 } | 797 } |
798 } | 798 } |
799 | 799 |
800 void CFX_ListCtrl::InvalidateItem(FX_INT32 nItemIndex) | 800 void CFX_ListCtrl::InvalidateItem(int32_t nItemIndex) |
801 { | 801 { |
802 if (m_pNotify) | 802 if (m_pNotify) |
803 { | 803 { |
804 if (nItemIndex == -1) | 804 if (nItemIndex == -1) |
805 { | 805 { |
806 if (!m_bNotifyFlag) | 806 if (!m_bNotifyFlag) |
807 { | 807 { |
808 m_bNotifyFlag = TRUE; | 808 m_bNotifyFlag = TRUE; |
809 CPDF_Rect rcRefresh = GetPlateRect(); | 809 CPDF_Rect rcRefresh = GetPlateRect(); |
810 m_pNotify->IOnInvalidateRect(&rcRefresh); | 810 m_pNotify->IOnInvalidateRect(&rcRefresh); |
(...skipping 13 matching lines...) Expand all Loading... |
824 | 824 |
825 m_pNotify->IOnInvalidateRect(&rcRefresh); | 825 m_pNotify->IOnInvalidateRect(&rcRefresh); |
826 m_bNotifyFlag = FALSE; | 826 m_bNotifyFlag = FALSE; |
827 } | 827 } |
828 } | 828 } |
829 } | 829 } |
830 } | 830 } |
831 | 831 |
832 void CFX_ListCtrl::SelectItems() | 832 void CFX_ListCtrl::SelectItems() |
833 { | 833 { |
834 » for (FX_INT32 i=0,sz=m_aSelItems.GetCount(); i<sz; i++) | 834 » for (int32_t i=0,sz=m_aSelItems.GetCount(); i<sz; i++) |
835 { | 835 { |
836 » » FX_INT32 nItemIndex = m_aSelItems.GetItemIndex(i); | 836 » » int32_t nItemIndex = m_aSelItems.GetItemIndex(i); |
837 » » FX_INT32 nState = m_aSelItems.GetState(i); | 837 » » int32_t nState = m_aSelItems.GetState(i); |
838 | 838 |
839 switch(nState) | 839 switch(nState) |
840 { | 840 { |
841 case 1: | 841 case 1: |
842 SetMultipleSelect(nItemIndex, TRUE); | 842 SetMultipleSelect(nItemIndex, TRUE); |
843 break; | 843 break; |
844 case -1: | 844 case -1: |
845 SetMultipleSelect(nItemIndex, FALSE); | 845 SetMultipleSelect(nItemIndex, FALSE); |
846 break; | 846 break; |
847 } | 847 } |
848 } | 848 } |
849 | 849 |
850 m_aSelItems.Done(); | 850 m_aSelItems.Done(); |
851 } | 851 } |
852 | 852 |
853 void CFX_ListCtrl::Select(FX_INT32 nItemIndex) | 853 void CFX_ListCtrl::Select(int32_t nItemIndex) |
854 { | 854 { |
855 if (!IsValid(nItemIndex)) return; | 855 if (!IsValid(nItemIndex)) return; |
856 | 856 |
857 if (this->IsMultipleSel()) | 857 if (this->IsMultipleSel()) |
858 { | 858 { |
859 m_aSelItems.Add(nItemIndex); | 859 m_aSelItems.Add(nItemIndex); |
860 SelectItems(); | 860 SelectItems(); |
861 } | 861 } |
862 else | 862 else |
863 SetSingleSelect(nItemIndex); | 863 SetSingleSelect(nItemIndex); |
864 } | 864 } |
865 | 865 |
866 FX_BOOL»CFX_ListCtrl::IsItemVisible(FX_INT32 nItemIndex) const | 866 FX_BOOL»CFX_ListCtrl::IsItemVisible(int32_t nItemIndex) const |
867 { | 867 { |
868 CPDF_Rect rcPlate = this->GetPlateRect(); | 868 CPDF_Rect rcPlate = this->GetPlateRect(); |
869 CPDF_Rect rcItem = this->GetItemRect(nItemIndex); | 869 CPDF_Rect rcItem = this->GetItemRect(nItemIndex); |
870 | 870 |
871 return rcItem.bottom >= rcPlate.bottom && rcItem.top <= rcPlate.top; | 871 return rcItem.bottom >= rcPlate.bottom && rcItem.top <= rcPlate.top; |
872 } | 872 } |
873 | 873 |
874 void CFX_ListCtrl::ScrollToListItem(FX_INT32 nItemIndex) | 874 void CFX_ListCtrl::ScrollToListItem(int32_t nItemIndex) |
875 { | 875 { |
876 if (!IsValid(nItemIndex)) return; | 876 if (!IsValid(nItemIndex)) return; |
877 | 877 |
878 CPDF_Rect rcPlate = this->GetPlateRect(); | 878 CPDF_Rect rcPlate = this->GetPlateRect(); |
879 CPDF_Rect rcItem = CFX_List::GetItemRect(nItemIndex); | 879 CPDF_Rect rcItem = CFX_List::GetItemRect(nItemIndex); |
880 CPDF_Rect rcItemCtrl = GetItemRect(nItemIndex); | 880 CPDF_Rect rcItemCtrl = GetItemRect(nItemIndex); |
881 | 881 |
882 if (FX_EDIT_IsFloatSmaller(rcItemCtrl.bottom, rcPlate.bottom)) | 882 if (FX_EDIT_IsFloatSmaller(rcItemCtrl.bottom, rcPlate.bottom)) |
883 { | 883 { |
884 if (FX_EDIT_IsFloatSmaller(rcItemCtrl.top, rcPlate.top)) | 884 if (FX_EDIT_IsFloatSmaller(rcItemCtrl.top, rcPlate.top)) |
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
953 } | 953 } |
954 } | 954 } |
955 } | 955 } |
956 } | 956 } |
957 | 957 |
958 CPDF_Rect CFX_ListCtrl::GetContentRect() const | 958 CPDF_Rect CFX_ListCtrl::GetContentRect() const |
959 { | 959 { |
960 return InToOut(CFX_List::GetContentRect()); | 960 return InToOut(CFX_List::GetContentRect()); |
961 } | 961 } |
962 | 962 |
963 void CFX_ListCtrl::ReArrange(FX_INT32 nItemIndex) | 963 void CFX_ListCtrl::ReArrange(int32_t nItemIndex) |
964 { | 964 { |
965 CFX_List::ReArrange(nItemIndex); | 965 CFX_List::ReArrange(nItemIndex); |
966 SetScrollInfo(); | 966 SetScrollInfo(); |
967 } | 967 } |
968 | 968 |
969 void CFX_ListCtrl::SetTopItem(FX_INT32 nIndex) | 969 void CFX_ListCtrl::SetTopItem(int32_t nIndex) |
970 { | 970 { |
971 if (IsValid(nIndex)) | 971 if (IsValid(nIndex)) |
972 { | 972 { |
973 this->GetPlateRect(); | 973 this->GetPlateRect(); |
974 CPDF_Rect rcItem = CFX_List::GetItemRect(nIndex); | 974 CPDF_Rect rcItem = CFX_List::GetItemRect(nIndex); |
975 SetScrollPosY(rcItem.top); | 975 SetScrollPosY(rcItem.top); |
976 } | 976 } |
977 } | 977 } |
978 | 978 |
979 FX_INT32 CFX_ListCtrl::GetTopItem() const | 979 int32_t CFX_ListCtrl::GetTopItem() const |
980 { | 980 { |
981 » FX_INT32 nItemIndex = this->GetItemIndex(this->GetBTPoint()); | 981 » int32_t nItemIndex = this->GetItemIndex(this->GetBTPoint()); |
982 | 982 |
983 if (!IsItemVisible(nItemIndex) && IsItemVisible(nItemIndex + 1)) | 983 if (!IsItemVisible(nItemIndex) && IsItemVisible(nItemIndex + 1)) |
984 nItemIndex += 1; | 984 nItemIndex += 1; |
985 | 985 |
986 return nItemIndex; | 986 return nItemIndex; |
987 } | 987 } |
988 | 988 |
989 void CFX_ListCtrl::Empty() | 989 void CFX_ListCtrl::Empty() |
990 { | 990 { |
991 CFX_List::Empty(); | 991 CFX_List::Empty(); |
992 InvalidateItem(-1); | 992 InvalidateItem(-1); |
993 } | 993 } |
994 | 994 |
995 void CFX_ListCtrl::Cancel() | 995 void CFX_ListCtrl::Cancel() |
996 { | 996 { |
997 m_aSelItems.DeselectAll(); | 997 m_aSelItems.DeselectAll(); |
998 } | 998 } |
999 | 999 |
1000 FX_INT32 CFX_ListCtrl::GetItemIndex(const CPDF_Point & point) const | 1000 int32_t CFX_ListCtrl::GetItemIndex(const CPDF_Point & point) const |
1001 { | 1001 { |
1002 return CFX_List::GetItemIndex(OutToIn(point)); | 1002 return CFX_List::GetItemIndex(OutToIn(point)); |
1003 } | 1003 } |
1004 | 1004 |
1005 CFX_WideString CFX_ListCtrl::GetText() const | 1005 CFX_WideString CFX_ListCtrl::GetText() const |
1006 { | 1006 { |
1007 if (this->IsMultipleSel()) | 1007 if (this->IsMultipleSel()) |
1008 return this->GetItemText(this->m_nCaretIndex); | 1008 return this->GetItemText(this->m_nCaretIndex); |
1009 else | 1009 else |
1010 return this->GetItemText(this->m_nSelItem); | 1010 return this->GetItemText(this->m_nSelItem); |
1011 } | 1011 } |
1012 | 1012 |
OLD | NEW |