Leaked source code of windows server 2003
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

100 lines
3.1 KiB

  1. /* @doc INTERNAL
  2. *
  3. * @module _DFREEZE.CPP Implementation for classes handle freezing the display |
  4. *
  5. * This module implements non-inline members used by logic to handle freezing the display
  6. *
  7. * History: <nl>
  8. * 2/8/96 ricksa Created
  9. *
  10. * Copyright (c) 1995-1997, Microsoft Corporation. All rights reserved.
  11. */
  12. #include "_common.h"
  13. #include "_disp.h"
  14. #include "_dfreeze.h"
  15. ASSERTDATA
  16. /*
  17. * CAccumDisplayChanges::GetUpdateRegion(pcpStart, pcchDel, pcchNew,
  18. * pfUpdateCaret, pfScrollIntoView)
  19. * @mfunc
  20. * Get region for display to update
  21. */
  22. void CAccumDisplayChanges::GetUpdateRegion(
  23. LONG *pcpStart, //@parm where to put the cpStart
  24. LONG *pcchDel, //@parm where to put the del char count
  25. LONG *pcchNew, //@parm where to put the new char count
  26. BOOL *pfUpdateCaret, //@parm whether caret update is needed
  27. BOOL *pfScrollIntoView, //@parm whether to scroll caret into view
  28. BOOL *pfNeedRedisplay) //@parm whether it needs redisplay
  29. {
  30. LONG cchDel;
  31. *pcpStart = _cpMin;
  32. if(pfUpdateCaret)
  33. *pfUpdateCaret = _fUpdateCaret;
  34. if(pfScrollIntoView)
  35. *pfScrollIntoView = _fScrollIntoView;
  36. if (pfNeedRedisplay)
  37. *pfNeedRedisplay = _fNeedRedisplay;
  38. if(_cpMin == CP_INFINITE)
  39. return;
  40. cchDel = _cpMax - _cpMin;
  41. if(pcchDel)
  42. *pcchDel = cchDel;
  43. *pcchNew = cchDel + _delta;
  44. _cpMin = CP_INFINITE;
  45. }
  46. /*
  47. * CAccumDisplayChanges::UpdateRecalcRegion(cpStartNew, cchDel, cchNew)
  48. *
  49. * @mfunc
  50. * Merge new update with region to be recalculated
  51. */
  52. void CAccumDisplayChanges::UpdateRecalcRegion(
  53. LONG cpStartNew, //@parm Start of update
  54. LONG cchDel, //@parm Count of chars to delete
  55. LONG cchNew) //@parm Count of chars to add
  56. {
  57. if(CP_INFINITE == _cpMin)
  58. {
  59. // Object is empty so just assign values
  60. _cpMin = cpStartNew;
  61. _cpMax = cpStartNew + cchDel;
  62. _delta = cchNew - cchDel;
  63. return;
  64. }
  65. // The basic idea of this algorithm is to merge the updates so that
  66. // they appear to the display sub-system as if only one replace range
  67. // has occured. To do this we keep track of the start of the update
  68. // (_cpMin) relative to the original text and the end of the update
  69. // (_cpMax) relative to the original text and the change in the count
  70. // of text (_delta). We can recreate cchDel from _cpMost - _cpMin and
  71. // cchNew from cchDel + _delta.
  72. // Do we need to update _cpMin? - we only need to update _cpMin if the
  73. // current update begins before the last update because the final update
  74. // need only know the very start of the range updated.
  75. if(cpStartNew < _cpMin)
  76. _cpMin = cpStartNew;
  77. // Do we need to udpate _cpMax? - we only need to update _cpMax if the
  78. // current update implies a _cpMax that is greater than the current one.
  79. // Note that because prior updates affect where the _cpMax is located
  80. // we need to compare againt the proposed _cpMax against the current
  81. // _cpMax adjusted by the change in the text since the beginning of the
  82. // updates.
  83. if(cpStartNew + cchDel > _cpMax + _delta)
  84. _cpMax = cpStartNew + cchDel - _delta;
  85. // Increment the total change by the change for this update.
  86. _delta += cchNew - cchDel;
  87. }