Source code of Windows XP (NT5)
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.

94 lines
2.1 KiB

  1. //$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$
  2. //
  3. // Copyright (c) 2001 Microsoft Corporation. All rights reserved.
  4. //
  5. // Module:
  6. // volcano/dll/strkutil.c
  7. //
  8. // Description:
  9. // Functions to implement the functionality of managing breakpoint structures.
  10. //
  11. // Author:
  12. // hrowley & ahmadab 12/05/01
  13. //
  14. //$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$
  15. #include "common.h"
  16. #include "volcanop.h"
  17. // Make a copy of the points in a stroke. Used so that when we free
  18. // the glyph we don't free the passed in points.
  19. POINT *
  20. DupPoints(POINT *pOldPoints, int nPoints)
  21. {
  22. int ii;
  23. POINT *pPoints;
  24. // Alloc space.
  25. pPoints = (POINT *) ExternAlloc(nPoints * sizeof(POINT));
  26. if (!pPoints) {
  27. return (POINT *)0;
  28. }
  29. // Copy point data.
  30. for (ii = 0; ii < nPoints; ++ii) {
  31. pPoints[ii] = pOldPoints[ii];
  32. }
  33. // Return the new copy.
  34. return pPoints;
  35. }
  36. // Build glyph structure from stroke array.
  37. GLYPH *
  38. GlyphFromStrokes(UINT cStrokes, STROKE *pStrokes)
  39. {
  40. int ii;
  41. GLYPH *pGlyph;
  42. // Convert strokes to GLYPHs and FRAMEs so that we can call the
  43. // old code.
  44. pGlyph = (GLYPH *)0;
  45. for (ii = cStrokes - 1; ii >= 0; --ii) {
  46. STROKE *pStroke;
  47. GLYPH *pGlyphCur;
  48. // Alloc glyph.
  49. pGlyphCur = NewGLYPH();
  50. if (!pGlyphCur) {
  51. goto error;
  52. }
  53. // Add to list, and alloc frame
  54. pGlyphCur->next = pGlyph;
  55. pGlyph = pGlyphCur;
  56. pGlyphCur->frame = NewFRAME();
  57. if (!pGlyphCur->frame) {
  58. goto error;
  59. }
  60. // Get stroke to process.
  61. pStroke = pStrokes + ii;
  62. // Fill in frame. We just fill in what we need, and ignore
  63. // fields not used by Otter and Zilla, or are set by them.
  64. pGlyphCur->frame->info.cPnt = pStroke->nInk;
  65. pGlyphCur->frame->info.wPdk = PDK_TRANSITION | PDK_DOWN;
  66. pGlyphCur->frame->rgrawxy = DupPoints(pStroke->pts, pStroke->nInk);
  67. pGlyphCur->frame->rect = pStroke->bbox;
  68. pGlyphCur->frame->iframe = ii;
  69. if (pGlyphCur->frame->rgrawxy == NULL) {
  70. goto error;
  71. }
  72. }
  73. return pGlyph;
  74. error:
  75. // Cleanup glyphs on error.
  76. if (pGlyph) {
  77. DestroyFramesGLYPH(pGlyph);
  78. DestroyGLYPH(pGlyph);
  79. }
  80. return (GLYPH *)0;
  81. }