PageRenderTime 82ms CodeModel.GetById 75ms app.highlight 5ms RepoModel.GetById 1ms app.codeStats 0ms

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