PageRenderTime 21ms CodeModel.GetById 12ms app.highlight 5ms RepoModel.GetById 1ms app.codeStats 1ms

/framework/experimental/graphic/GraphicObject.php

http://zoop.googlecode.com/
PHP | 200 lines | 43 code | 10 blank | 147 comment | 2 complexity | d0d0921b445530a2443099527082812e MD5 | raw file
  1<?php
  2abstract class GraphicObject
  3{
  4	protected $context;
  5	protected $parent;
  6	
  7	function __construct($init)
  8	{
  9		if(is_a($init, 'GraphicContainer'))
 10		{
 11			$this->parent = $init;
 12			$this->context = $init->getContext();
 13		}
 14		else
 15		{
 16			assert(is_a($init, 'GraphicContext'));
 17			$this->context = $init;
 18		}
 19	}
 20	
 21	//	property accessors
 22	function getContext()
 23	{
 24		return $this->context;
 25	}
 26	
 27	function isInline()
 28	{
 29		return true;
 30	}
 31	
 32	function getHeight($width)
 33	{
 34		$height = $this->draw(0, 0, $width, 0);
 35		return $height;
 36	}
 37	
 38	public function draw($x, $y, $width, $reallyDraw = true)
 39	{
 40		trigger_error("soft abstract function");
 41	}
 42	
 43	function getObjectTree($indentLevel = 0)
 44	{
 45		$tabs = '';
 46		for($i = 0; $i < $indentLevel; $i++)
 47			$tabs .= '&nbsp;&nbsp;&nbsp;&nbsp;';
 48		
 49		echo $tabs . '&lt;' . get_class($this) . '/&gt;<br>';
 50	}
 51	
 52	/*
 53	var $parent;
 54	var $width;
 55	var $position;
 56	var $left;
 57	var $top;
 58	var $repeatable;
 59	
 60	function GraphicObject(&$context)
 61	{
 62		$this->context = &$context;
 63		$this->position = 'static';
 64		$this->left = NULL;
 65		$this->top = NULL;
 66		$this->repeatable = 0;
 67	}
 68	
 69	function forcePageBreak()
 70	{
 71		return 0;
 72	}
 73	
 74	function makeRepeatable()
 75	{
 76		$this->repeatable = 1;
 77	}
 78	
 79	function isRepeatable()
 80	{
 81		return $this->repeatable;
 82	}
 83	
 84	function setParent(&$parent)
 85	{
 86		$this->parent = &$parent;
 87	}
 88	
 89	function &getParent()
 90	{
 91		return $this->parent;
 92	}
 93	
 94	function getAncestor($className)
 95	{
 96		$parent = &$this;
 97		
 98		while($parent)
 99		{
100			if(is_a($parent, $className))
101				return $parent;
102			
103			$parent = &$parent->parent;
104		}
105		
106		return NULL;
107	}
108	
109	function getDocument()
110	{
111		return $this->getAncestor('GraphicDocument');
112	}
113	
114	function setWidth($width)
115	{
116		$this->width = $width;
117	}
118	
119	function getWidth()
120	{
121		return $this->width;
122	}
123	
124	function getContentWidth()
125	{
126		return $this->getWidth();
127	}
128	*/
129	
130	/*
131	function getHeight($width)
132	{
133		if( !isset($this->heightCache[$width]) )
134			$this->heightCache[$width] = $this->draw(0, 0, $width, 0);
135		
136		return $this->heightCache[$width];
137	}
138	*/
139	
140	/*
141	function getHeight($width)
142	{
143		$height = $this->draw(0, 0, $width, 0);
144//		echo get_class($this) . ' ' . $height . '<br>';
145		return $height;
146	}
147	
148	function isInline()
149	{
150		return 0;
151	}
152	
153	function isBreakable()
154	{
155		return 0;
156	}
157	
158	function setPosition($position)
159	{
160		$this->position = $position;
161	}
162	
163	function getPosition()
164	{
165		return $this->position;
166	}
167	
168	function setTop($top)
169	{
170		assert($this->getPosition() != 'static');
171		$this->top = $top;
172	}
173	
174	function getTop()
175	{
176		return $this->top;
177	}
178	
179	function setLeft($left)
180	{
181		assert($this->getPosition() != 'static');
182		$this->left = $left;
183	}
184	
185	function getLeft()
186	{
187		return $this->left;
188	}
189	
190	function doneDrawing()
191	{
192		return 1;
193	}
194	
195	function draw()
196	{
197		trigger_error('abstract method GraphicObject::draw() called');
198	}
199	*/
200}