[LON-CAPA-cvs] cvs: loncom /homework drawimage.pm

matthew lon-capa-cvs@mail.lon-capa.org
Tue, 16 Mar 2004 22:27:37 -0000


matthew		Tue Mar 16 17:27:37 2004 EDT

  Modified files:              
    /loncom/homework	drawimage.pm 
  Log:
  Added text support.
  
  
Index: loncom/homework/drawimage.pm
diff -u loncom/homework/drawimage.pm:1.3 loncom/homework/drawimage.pm:1.4
--- loncom/homework/drawimage.pm:1.3	Mon Feb 23 19:16:35 2004
+++ loncom/homework/drawimage.pm	Tue Mar 16 17:27:37 2004
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # programatic image drawing
 #
-# $Id: drawimage.pm,v 1.3 2004/02/24 00:16:35 albertel Exp $
+# $Id: drawimage.pm,v 1.4 2004/03/16 22:27:37 matthew Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -38,7 +38,7 @@
 
 sub start_drawimage {
     my ($target,$token,$tagstack,$parstack,$parser,$safeeval,$style)=@_;
-    &Apache::lonxml::register('Apache::drawimage',('line','rectangle','arc','fill'));
+    &Apache::lonxml::register('Apache::drawimage',('textlabel','line','rectangle','arc','fill'));
     if ($target eq 'web' || $target eq 'tex') {
 	$cgi_id=&Apache::loncommon::get_cgi_id();
 	%args=();
@@ -69,6 +69,29 @@
 	}
     }
     &Apache::lonxml::deregister('Apache::drawimage',('line','rectangle'));
+    return $result;
+}
+
+sub start_textlabel {
+    my ($target,$token,$tagstack,$parstack,$parser,$safeeval,$style)=@_;
+    my $result;
+    if ($target eq 'web' || $target eq 'tex') {
+        my $x     = &Apache::lonxml::get_param('x',$parstack,$safeeval);
+        my $y     = &Apache::lonxml::get_param('y',$parstack,$safeeval);
+        my $font  = &Apache::lonxml::get_param('font',$parstack,$safeeval);
+        my $color = &Apache::lonxml::get_param('color',$parstack,$safeeval);
+	my $text  = &Apache::lonxml::get_all_text("/textlabel",$parser);
+        $text = &Apache::lonnet::escape($text);
+        $args{"cgi.$cgi_id.OBJTYPE"}.='LABEL:';
+	my $i=$args{"cgi.$cgi_id.OBJCOUNT"}++;
+	$args{"cgi.$cgi_id.OBJ$i"}=join(':',($x,$y,$text,$font,$color));
+    }
+    return $result;
+}
+
+sub end_textlabel {
+    my ($target,$token,$tagstack,$parstack,$parser,$safeeval,$style)=@_;
+    my $result;
     return $result;
 }