ajaxp = $ajaxp;
}
function set_graphicsp($graphicsp)
{
$this->imagep = $graphicsp->imagep;
$this->imagemapp = $graphicsp->imagemapp;
}
function set_offset_scale($xoffset,$yoffset,$scale)
{
$this->scale = 1;
$this->xoffset = $xoffset;
$this->yoffset = $yoffset;
$t = "
set offset scale ($this->xoffset,$this->yoffset) scale $this->scale
\r\n";
return $t;
}
function adjust_position($p)
{
list($x,$y) = $p;
$np = $this->compute_position($x,$y);
return $np;
}
function compute_position($x,$y)
{
$p[0] = $this->xoffset + $x * $this->scale;
$p[1] = $this->yoffset + $y * $this->scale;
return $p;
}
function compute_size($w,$h=1)
{
$s[0] = $w * $this->scale;
$s[1] = $h * $this->scale;
return $s;
}
function compute_thickness($thickness)
{
$thickness = $this->scale * $thickness;
if($thickness < 1) $thickness = 1;
$thickness = intval($thickness);
return $thickness;
}
function adjustion_points($points)
{
foreach($points as $k => $v)
{
list($x,$y) = $v;
$p = $this->compute_position($x,$y);
$a[] = $p;
}
return $a;
}
function gen_color2($color)
{
$ret = $this->imagep->gen_color2($color);
return $ret;
}
function test()
{
$t = $this->gen_circle(100,100,100,20,'lblue');
$t .= $this->gen_ellipse(300,200,300,200,10,'blue');
$t .= $this->gen_arc(500,500,200,10,0,180,'white');
$t .= $this->gen_earc(400,400,100,50,20,180,0,'red');
$t .= $this->gen_filled_triangle(100,600,600,300,700,100,'orange');
return $t;
}
function set_control_colors($id,$bgcolor,$frcolor,$tcolor)
{
$this->colors[$id] = array($bgcolor,$frcolor,$tcolor);
}
function set_button_sizes($id,$w,$h,$thickness)
{
$this->sizes[$id] = array($w,$h,$thickness);
}
function set_control_styles($id,$sid,$cid)
{
$this->styles[$id] = array($sid,$cid);
}
function gen_control($id,$x,$y,$text,$event)
{
list($sid,$cid) = $this->styles[$id];
$t = $this->gen_button2($sid,$cid,$x,$y,$text,$event);
return $t;
}
function gen_keyboard($x,$y)
{
$t = $this->gen_button2($sid,$cid,100,100,'1','keypad','1');
$t = $this->gen_button2($sid,$cid,100,100,'1','keypad','1');
$t = $this->gen_button2($sid,$cid,100,100,'1','keypad','1');
$t = $this->gen_button2($sid,$cid,100,100,'1','keypad','1');
$t = $this->gen_button2($sid,$cid,100,100,'1','keypad','1');
$t = $this->gen_button2($sid,$cid,100,100,'1','keypad','1');
$t = $this->gen_button2($sid,$cid,100,100,'1','keypad','1');
$t = $this->gen_button2($sid,$cid,100,100,'1','keypad','1');
return $t;
}
function gen_button_page($sid,$cid,$x,$y,$text,$loc1,$loc2 = NULL)
{
$t = $this->gen_button2($sid,$cid,$x,$y,$text,'button_page',$loc1,$loc2);
return $t;
}
function gen_control_keypressed($sid,$cid,$x,$y,$text,$loc1,$loc2 = NULL)
{
$t = $this->gen_button2($sid,$cid,$x,$y,$text,'button_keypressed',$loc1,$loc2);
return $t;
}
function gen_button2($sid,$cid,$x,$y,$text,$btype,$loc1,$loc2 = NULL)
{
list($bgcolor,$frcolor,$tcolor) = $this->colors[$cid];
list($w,$h,$thickness) = $this->sizes[$sid];
$button = array($btype,$loc1,$loc2);
$t = $this->gen_button_full($x,$y,$w,$h,$thickness,$bgcolor,$frcolor,$tcolor,$text,$button);
return $t;
}
function gen_control_full($x,$y,$w,$h,$thickness,$bgcolor,$frcolor,$tcolor,$text,$button)
{
$t = "buttons::gen_button_full $id $x $y $w $h $thickness $text
\r\n";
// $w = 300;
// $h = 40;
// $thickness = 5;
$x2 = $x + $w;
$y2 = $y + $h;
$tx = $x + 20;
$ty = $y + 30;
$size = 20;
$angle = 0;
$t .= "colors $bgcolor $frcolor $tcolor
\r\n";
$t .= $this->imagep->gen_filled_rect($x,$y,$w,$h,$bgcolor);
$t .= $this->imagep->gen_rect($x,$y,$w,$h,$frcolor,$thickness);
$t .= $this->imagep->gen_ttf_text2($tx,$ty,$size,$angle,$tcolor,$text);
$t .= $this->gen_map_info($x,$y,$w,$h,$text,$button);
return $t;
}
function gen_control_debug($x,$y,$w,$h,$thickness,$bgcolor,$frcolor,$tcolor,$text,$event)
{
$t = "buttons::gen_button_full $id $x $y $w $h $thickness $text
\r\n";
list($sx,$sy) = $this->compute_position($x,$y);
list($sw,$sh) = $this->compute_size($w,$h);
$x2 = $sx + $sw;
$y2 = $sy + $sh;
$tx = $sx + 20;
$ty = $sy + 30;
$size = 20;
$angle = 0;
$t .= "colors $bgcolor $frcolor $tcolor
\r\n";
$t .= $this->imagep->gen_rect($sx,$sy,$x2,$y2,$thickness,$frcolor);
$t .= $this->imagep->gen_ttf_text($tx,$ty,$size,$angle,$tcolor,$text);
$t .= $this->gen_map_info($x,$y,$w,$h,$loc1,$loc2);
return $t;
}
function gen_map_info($x,$y,$w,$h,$title,$button)
{
$area = array('button_rect',$x,$y,$w,$h);
$j = array('button_area',$id,$area,$color,$title,$button);
$t .= $this->imagemapp->store_area_array($j);
return $t;
}
}
?>