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.

137 lines
3.9 KiB

  1. /**************************** Module Header ********************************\
  2. * Module Name: lboxmult.c
  3. *
  4. * Copyright (c) 1985 - 1999, Microsoft Corporation
  5. *
  6. * Multi column list box routines
  7. *
  8. * History:
  9. * ??-???-???? ianja Ported from Win 3.0 sources
  10. * 14-Feb-1991 mikeke Added Revalidation code
  11. \***************************************************************************/
  12. #include "precomp.h"
  13. #pragma hdrstop
  14. /***************************************************************************\
  15. * LBCalcItemRowsAndColumns
  16. *
  17. * Calculates the number of columns (including partially visible)
  18. * in the listbox and calculates the number of items per column
  19. *
  20. * History:
  21. \***************************************************************************/
  22. void LBCalcItemRowsAndColumns(
  23. PLBIV plb)
  24. {
  25. RECT rc;
  26. _GetClientRect(plb->spwnd, &rc);
  27. //
  28. // B#4155
  29. // We need to check if plb->cyChar has been initialized. This is because
  30. // we remove WS_BORDER from old listboxes and add on WS_EX_CLIENTEDGE.
  31. // Since listboxes are always inflated by CXBORDER and CYBORDER, a
  32. // listbox that was created empty always ends up 2 x 2. Since this isn't
  33. // big enough to fit the entire client border, we don't mark it as
  34. // present. Thus the client isn't empty in VER40, although it was in
  35. // VER31 and before. It is possible to get to this spot without
  36. // plb->cyChar having been initialized yet if the listbox is
  37. // multicolumn && ownerdraw variable.
  38. //
  39. if (rc.bottom && rc.right && plb->cyChar) {
  40. /*
  41. * Only make these calculations if the width & height are positive
  42. */
  43. plb->itemsPerColumn = (INT)max(rc.bottom / plb->cyChar, 1);
  44. plb->numberOfColumns = (INT)max(rc.right / plb->cxColumn, 1);
  45. plb->cItemFullMax = plb->itemsPerColumn * plb->numberOfColumns;
  46. /*
  47. * Adjust iTop so it's at the top of a column
  48. */
  49. xxxNewITop(plb, plb->iTop);
  50. }
  51. }
  52. /***************************************************************************\
  53. * xxxLBoxCtlHScrollMultiColumn
  54. *
  55. * Supports horizontal scrolling of multicolumn listboxes
  56. *
  57. * History:
  58. \***************************************************************************/
  59. void xxxLBoxCtlHScrollMultiColumn(
  60. PLBIV plb,
  61. INT cmd,
  62. INT xAmt)
  63. {
  64. INT iTop = plb->iTop;
  65. CheckLock(plb->spwnd);
  66. if (!plb->cMac) return;
  67. switch (cmd) {
  68. case SB_LINEUP:
  69. if (plb->fRightAlign)
  70. goto ReallyLineDown;
  71. ReallyLineUp:
  72. iTop -= plb->itemsPerColumn;
  73. break;
  74. case SB_LINEDOWN:
  75. if (plb->fRightAlign)
  76. goto ReallyLineUp;
  77. ReallyLineDown:
  78. iTop += plb->itemsPerColumn;
  79. break;
  80. case SB_PAGEUP:
  81. if (plb->fRightAlign)
  82. goto ReallyPageDown;
  83. ReallyPageUp:
  84. iTop -= plb->itemsPerColumn * plb->numberOfColumns;
  85. break;
  86. case SB_PAGEDOWN:
  87. if (plb->fRightAlign)
  88. goto ReallyPageUp;
  89. ReallyPageDown:
  90. iTop += plb->itemsPerColumn * plb->numberOfColumns;
  91. break;
  92. case SB_THUMBTRACK:
  93. case SB_THUMBPOSITION:
  94. if (plb->fRightAlign) {
  95. int iCols = plb->cMac ? ((plb->cMac-1) / plb->itemsPerColumn) + 1 : 0;
  96. xAmt = iCols - (xAmt + plb->numberOfColumns);
  97. if (xAmt<0)
  98. xAmt=0;
  99. }
  100. iTop = xAmt * plb->itemsPerColumn;
  101. break;
  102. case SB_TOP:
  103. if (plb->fRightAlign)
  104. goto ReallyBottom;
  105. ReallyTop:
  106. iTop = 0;
  107. break;
  108. case SB_BOTTOM:
  109. if (plb->fRightAlign)
  110. goto ReallyTop;
  111. ReallyBottom:
  112. iTop = plb->cMac - 1 - ((plb->cMac - 1) % plb->itemsPerColumn);
  113. break;
  114. case SB_ENDSCROLL:
  115. plb->fSmoothScroll = TRUE;
  116. xxxLBShowHideScrollBars(plb);
  117. break;
  118. }
  119. xxxNewITop(plb, iTop);
  120. }