# xisofs v1.3 Perl/Tk Interface to mkisofs / cdwrite # Copyright (c) 1997 Steve Sherwood (pariah@netcomuk.co.uk) # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. # # Bubble.pm will be available soon as a stand-alone module. package Bubble; use Tk; use strict; use Carp; sub new { my ($this,%args) = @_; my $class = ref($this) || $this; my $self = {}; bless $self, $class; $self->initialize(\%args); return $self; } #-------------------- # Initialise Defaults #-------------------- sub initialize { my ($self,$args) = @_; @{$self->{options}} = ( 'relief', 'foreground', 'background', 'bordercolour', 'bordersize', 'font', 'icon', 'iconalign', 'xoffset', 'yoffset', 'delay', 'state', 'contents'); ${$self->{relief}}{'default'} = 'flat'; ${$self->{foreground}}{'default'} = 'white'; ${$self->{background}}{'default'} = 'red'; ${$self->{bordercolour}}{'default'} = 'black'; ${$self->{bordersize}}{'default'} = '1'; ${$self->{font}}{'default'} = 'fixed'; ${$self->{icon}}{'default'} = ''; ${$self->{iconalign}}{'default'} = 'left'; ${$self->{xoffset}}{'default'} = 12; ${$self->{yoffset}}{'default'} = 12; ${$self->{delay}}{'default'} = 1000; ${$self->{state}}{'default'} = 'normal'; ${$self->{contents}}{'default'} = 'full'; $self->get_options('default', $args); } #---------------------------- # Attach a window to a widget #---------------------------- sub attach { my ($self, $parent, %args) = @_; my $popup = $parent->Toplevel; $popup->overrideredirect(1); $popup->withdraw; ${$self->{text}}{$popup} = $args{'-text'} if (defined($args{'-text'})); ${$self->{textvariable}}{$popup} = $args{'-textvariable'} if (defined($args{'-textvariable'})); $self->copy_options($popup); $self->get_options($popup,\%args); ${$self->{status}}{$popup} = 0; my $icn = ${$self->{icon}}{$popup}; if (length($icn) > 0) { unless (defined(${$self->{pixmap}}{$icn})) { ${$self->{pixmap}}{$icn} = $popup->Pixmap(-file => $icn); } } my ($frm,$borderfrm); if ((${$self->{contents}}{$popup} eq 'full') || (${$self->{contents}}{$popup} eq 'partial')) { $borderfrm = $popup->Frame( -background => ${$self->{bordercolour}}{$popup}, -borderwidth => 0, -relief => 'flat')->pack; $frm = $borderfrm->Frame( -background => ${$self->{background}}{$popup}, -borderwidth => 1, -relief => ${$self->{relief}}{$popup})->pack( -padx => ${$self->{bordersize}}{$popup}, -pady => ${$self->{bordersize}}{$popup}); } if (${$self->{contents}}{$popup} eq 'full') { if (length(${$self->{icon}}{$popup}) > 0) { $frm->Label( -background => ${$self->{background}}{$popup}, -image => $self->{pixmap}{${$self->{icon}}{$popup}})->pack( -side => ${$self->{iconalign}}{$popup}); } if (defined($args{'-text'})) { my $text = $frm->Label( -background => ${$self->{background}}{$popup}, -foreground => ${$self->{foreground}}{$popup}, -font => ${$self->{font}}{$popup}, -text => ${$self->{text}}{$popup})->pack(-side => 'left'); } elsif (defined($args{'-textvariable'})) { my $text = $frm->Label( -background => ${$self->{background}}{$popup}, -foreground => ${$self->{foreground}}{$popup}, -font => ${$self->{font}}{$popup}, -textvariable => ${$self->{textvariable}}{$popup})->pack(-side => 'left'); } else { croak "Either -text, or -textvariable must be specified"; } } $parent->bind('',['Bubble::activate',$self,Ev('X'),Ev('Y'),$popup]); $parent->bind('',['Bubble::popleave',$self,Ev('X'),Ev('Y'),$popup]); $parent->bind('',['Bubble::popmove',$self,Ev('X'),Ev('Y'),$popup]); $parent->bind('