/framework/experimental/graphic/GraphicSoftBrokenLine.php

http://zoop.googlecode.com/ · PHP · 85 lines · 39 code · 9 blank · 37 comment · 1 complexity · 75c4b77097d8fcd3784aec11967e3656 MD5 · raw file

  1. <?php
  2. class GraphicSoftBrokenLine extends GraphicObject
  3. {
  4. var $entries;
  5. var $width;
  6. function GraphicSoftBrokenLine()
  7. {
  8. $this->entries = array();
  9. $this->width = 0;
  10. }
  11. function addEntry($member, $start = 0, $length = NULL)
  12. {
  13. $newEntry['member'] = $member;
  14. $newEntry['start'] = $start;
  15. $newEntry['length'] = $length;
  16. $this->entries[] = $newEntry;
  17. // $this->width += $member->getPartWidth($start, $length);
  18. }
  19. function getWidth()
  20. {
  21. return $this->width;
  22. }
  23. function draw($x, $y, $width, $reallyDraw = 1)
  24. {
  25. $curx = $x;
  26. $cury = $y;
  27. $height = 12;
  28. foreach(array_keys($this->entries) as $entryKey)
  29. {
  30. $thisEntry = $this->entries[$entryKey];
  31. assert($thisEntry['member']->isInline());
  32. if($reallyDraw)
  33. {
  34. $thisEntry['member']->drawPart($curx, $cury, $thisEntry['start'], $thisEntry['length']);
  35. $curx += $thisEntry['member']->getPartWidth($thisEntry['start'], $thisEntry['length']);
  36. }
  37. }
  38. /*
  39. if($reallyDraw)
  40. $largestHeight = $this->getHeight($width);
  41. $cury = $y;
  42. $height = 0;
  43. foreach(array_keys($this->entries) as $entryKey)
  44. {
  45. $thisEntry = $this->entries[$entryKey];
  46. assert($thisEntry['member']->isInline());
  47. if($reallyDraw)
  48. {
  49. // if we need to draw the whole object
  50. if($thisEntry['start'] == 0 and $thisEntry['length'] === NULL)
  51. {
  52. trigger_error("I don't think that this actually ever gets called. It's all drawPart, we should remove this section");
  53. $thisEntry['member']->draw($curx, $cury + ($largestHeight - $thisEntry['member']->getHeight()));
  54. $curx = $thisEntry['member']->getWidth();
  55. }
  56. else
  57. {
  58. // echo $thisEntry['member'];
  59. $thisEntry['member']->drawPart($curx, $cury + ($largestHeight - $thisEntry['member']->getHeight()),
  60. $thisEntry['start'], $thisEntry['length']);
  61. $curx += $thisEntry['member']->getPartWidth($thisEntry['start'], $thisEntry['length']);
  62. }
  63. }
  64. if($thisEntry['member']->getHeight() > $height)
  65. {
  66. $height = $thisEntry['member']->getHeight();
  67. }
  68. }
  69. */
  70. return $height;
  71. }
  72. }