home *** CD-ROM | disk | FTP | other *** search
/ Acorn User 10 / AU_CD10.iso / Updates / Perl / RPC / !Perl / riscos / RISCOS / DrawFile / Group.pm < prev    next >
Encoding:
Perl POD Document  |  1999-01-20  |  2.0 KB  |  95 lines

  1. package RISCOS::DrawFile::Group;
  2.  
  3. use strict;
  4. use vars qw ($VERSION @ISA);
  5.  
  6. require RISCOS::DrawFile::Container;
  7. require RISCOS::DrawFile::Object;
  8.  
  9. $VERSION = 0.01;
  10. @ISA =  qw (RISCOS::DrawFile::Container RISCOS::DrawFile::Object);
  11.  
  12. ### use SelfLoader;
  13. sub RISCOS::DrawFile::Group::new ($);
  14. sub RISCOS::DrawFile::Group::Size ;
  15. sub RISCOS::DrawFile::Group::Pack ;
  16. sub RISCOS::DrawFile::Group::Write ;
  17. sub RISCOS::DrawFile::Group::Name ;
  18. 1;
  19. ### __DATA__
  20. sub new ($) {
  21.     my $proto = shift;
  22.     my $class = ref($proto) || $proto;
  23.  
  24.     my ($self, $type) = $class->RISCOS::DrawFile::Object::new (@_);
  25.     return $self if ref ($self) eq 'ARRAY';
  26.  
  27.     $self->{'__NAME'} = unpack 'x24A12', $_[0];
  28.     local $_[0] = \(substr $_[0], 36);
  29.     my ($stuff, $a, $font) = $class->_split_drawobjs (@_);
  30.     $self->Stuff ($stuff);
  31.     $self->{'__TYPE'} = $type;
  32.     
  33.     wantarray ? ($self, $type, $font) : $self;
  34. }
  35.  
  36. sub Size {
  37.     my $self = shift;
  38.     36 + $self->SUPER::Size;
  39. }
  40.  
  41. sub Pack {
  42.     my $self = shift;
  43.     $self->PackTypeSizeBBox()
  44.      . pack ('A12', $self->{'__NAME'})
  45.      . $self->SUPER::Pack(@_);
  46. }
  47.  
  48. sub Write {
  49.     my $self = shift;
  50.     my $good = print {$_[0]} $self->PackTypeSizeBBox(),
  51.                  pack ('A12', $self->{'__NAME'});
  52.     $good & $self->SUPER::Write (@_);    # Pass on args
  53. }
  54.  
  55. sub Name {
  56.     my $self = shift;
  57.     my $name = $self->{'__NAME'};
  58.     $self->{'__NAME'} = $_[0] if defined $_[0];
  59.     $name;
  60. }
  61.  
  62. 1;
  63. __END__
  64.  
  65. =head1 NAME
  66.  
  67. RISCOS::DrawFile::Group
  68.  
  69. =head1 SYNOPSIS
  70.  
  71. Class to handle groups in DrawFiles
  72.  
  73. =head1 DESCRIPTION
  74.  
  75. C<RISCOS::DrawFile::Group> provides a class to group other DrawFile objects. It
  76. is derived from C<RISCOS::DrawFile::Container> and C<RISCOS::DrawFile::Object>.
  77. In addition to their methods it provides one extra method
  78.  
  79. =over 4
  80.  
  81. =item Name [<name>]
  82.  
  83. returns the name of the group. If a new name is supplied it replaces the name
  84. returned. Group names are truncated to 12 characters.
  85.  
  86. =back
  87.  
  88. =head1 BUGS
  89.  
  90. Not tested enough.
  91.  
  92. =head1 AUTHOR
  93.  
  94. Nicholas Clark <F<nick@unfortu.net>>
  95.