From b305e90c818562d47f98a079ffe29052b19cb2a2 Mon Sep 17 00:00:00 2001 From: mariot Date: Wed, 26 Nov 2003 13:13:46 +0000 Subject: * Ajout de l'option -smallsize: affichage en 640x480. * Ajout de l'option -position. * Ajout des variables $smallsized $coef --- src/Agent.pm | 18 ++++---- src/ivycontrolpanel | 120 ++++++++++++++++++++++++++++++++-------------------- 2 files changed, 84 insertions(+), 54 deletions(-) (limited to 'src') diff --git a/src/Agent.pm b/src/Agent.pm index 75cf616..4a38434 100644 --- a/src/Agent.pm +++ b/src/Agent.pm @@ -14,7 +14,7 @@ use strict; #---------------------------------------------------------------------- my ($x0, $y0, $wmax, $dx, $dy, $cmin, $rmax, @matrix, @hosts, $tempo_id, $mw, $bg, $fg, $selcolor, $hlbg, $darkbg, $fontspec, @fontspec, - $on_img, $off_img, %instances, @instances, $bus, + $on_img, $off_img, %instances, @instances, $bus, $coef, $hosts_tl, $selected_host, $preselected_host); @@ -22,7 +22,7 @@ my ($x0, $y0, $wmax, $dx, $dy, $cmin, $rmax, @matrix, @hosts, $tempo_id, sub configure { shift; ($mw, $bg, $fg, $selcolor, $hlbg, $darkbg, - $fontspec, $x0, $y0, $wmax, $dy, $cmin, $rmax, $bus) = @_; + $fontspec, $x0, $y0, $wmax, $dy, $cmin, $rmax, $bus, $coef) = @_; @fontspec = @$fontspec if $fontspec; $off_img = $mw->Bitmap('off', -file => Tk::findINC('led.bmp'), -foreground => $bg); @@ -194,15 +194,15 @@ sub setposition { } $matrix[$r][$c]->[0] = $self; my ($x, $y) = ($matrix[$r][$c]->[1], $matrix[$r][$c]->[2]); - my $y2 = $y - 5; - $y2 -= 12 if ($self->{label}->cget(-text) =~ /\n/); + my $y2 = $y - 5*$coef; + $y2 -= 12*$coef if ($self->{label}->cget(-text) =~ /\n/); if ($self->{command}) { - $self->{led}->configure(-highlightthickness => 6); - $self->{led}->place(-x => $x+3, -y => $y+3); + $self->{led}->configure(-highlightthickness => 6*$coef); + $self->{led}->place(-x => $x+3*$coef, -y => $y+3*$coef); } else { - $self->{led}->configure(-highlightthickness => 2); - $self->{led}->place(-x => $x+6, -y => $y+6); + $self->{led}->configure(-highlightthickness => 2*$coef); + $self->{led}->place(-x => $x+6*$coef, -y => $y+6*$coef); } $self->{label}->place(-x => $x + 38, -y => $y2); @@ -219,7 +219,7 @@ sub createlabel { ); $self->{label} = $mw->Label(-text => $self->formatlabel, - -pady => 10, + -pady => 10*$coef, -justify => 'left', -relief => 'flat', -highlightthickness => 0, diff --git a/src/ivycontrolpanel b/src/ivycontrolpanel index 6c565a6..2dd638f 100755 --- a/src/ivycontrolpanel +++ b/src/ivycontrolpanel @@ -42,6 +42,8 @@ use vars qw(%opt); # window size my $width = 1024; my $height = 768; +my $smallsized = 0; +my $coef = 1; # fonts spec my @fontspec34 = (-font => @@ -84,7 +86,8 @@ my $ivylaunch_agent; # #--------------------------------------------------------------------------------- -&usage unless Getopt::Long::GetOptions(\%opt, 'b=s', 'nocursor', 'help'); +Getopt::Long::Configure('pass_through'); +&usage unless Getopt::Long::GetOptions(\%opt, 'b=s', 'nocursor', 'help', 'smallsize', 'position=s'); &usage(1) if $opt{help}; my ($fuguefile) = @ARGV; @@ -102,6 +105,23 @@ IvyIO::init("ivycontrolpanel", $opt{b}, \&connected, \&disconnected); # build the mainwindow # #--------------------------------------------------------------------------------- +if ($opt{smallsize}) +{ + $width = 640; + $height = 480; + $smallsized = 1; + $coef = 0.620; + + @fontspec34 = (-font => + '-b&h-lucida-bold-r-normal-sans-20-140-100-100-p-127-iso8859-1'); + @fontspec20 = (-font => + '-b&h-lucida-bold-r-normal-sans-12-120-75-75-p-79-iso8859-1'); + @fontspec24 = (-font => + '-b&h-lucida-bold-i-normal-sans-15-150-100-100-p-216-iso8859-1'); + @fontspec17 = (-font => + '-adobe-helvetica-medium-r-normal--11-80-100-100-p-60-iso10646-1'); +} + my $mw = MainWindow->new (-bg => 'black'); @@ -120,27 +140,27 @@ if ($opt{nocursor}) { } else { $mw->configure(-cursor => 'circle'); } -$mw->geometry ($width."x".$height."--0+0"); +$mw->geometry ($width."x".$height.$opt{position}); $mw->title ('ivycontrolpanel'); $mw->client ('ivycontrolpanel'); $mw->resizable(0,0); # geometry variables -my $dxleft = 20; -my $dxright = 20; -my $dybot = 90; -my $dytop = 20; -my $ddy = 10; +my $dxleft = 20*$coef; +my $dxright = 20*$coef; +my $dybot = 90*$coef; +my $dytop = 20*$coef; +my $ddy = 10*$coef; my $y; my $x; my $btn_h = $dybot - 3*$ddy; my $btn_w = $btn_h; -my $fm_w = $btn_w + 10; -my $fm_h = $btn_h + 10; +my $fm_w = $btn_w + 10*$coef; +my $fm_h = $btn_h + 10*$coef; # widgets attributes my @frameattr = (-relief => 'flat', - -highlightthickness => 3, + -highlightthickness => 3*$coef, -highlightbackground => $hlbg, -highlightcolor => $hlbg, -height => $height - $dytop - $dybot, @@ -155,7 +175,7 @@ my @labelattr = (-width => 2, -height => 1, my @buttonattr = (@labelattr, -borderwidth => 1, -highlightbackground => $hlbg, - -highlightthickness => 3, + -highlightthickness => 3*$coef, -width => $btn_w, -height => $btn_h, -activebackground => $bg, -activeforeground => $fg); @@ -189,7 +209,7 @@ $fm1->Label(-borderwidth => 0, -text => ' [ Bus ] '.(($opt{b}) ? $opt{b} : 'default').' '. '[ File ] '.(($fuguefile) ? $fuguefile : 'none').' ', @fontspec17, - -foreground => $hlbg)->place(-x => $dxleft+20, -y => $dytop-10); + -foreground => $hlbg)->place(-x => $dxleft+20*$coef, -y => $dytop-10); # build traffic rate frame #--------------------------------------------------------------------------------- @@ -204,19 +224,19 @@ my $btn_prev = $fm1->Button(@buttonattr, -image => $prevbmp, )->place(-x => $x, -y => $y ); -$x += $btn_w + 15; +$x += $btn_w + 15*$coef; my $fm_lab = $fm1->Frame(@frameattr, -width => $fm_w, -height => $fm_h)->place(-x => $x, -y => $y); my $lab_rate = $fm_lab->Label(@labelattr, -anchor => 'center', - -text => 1)->place(-x => 7, -y => 10); + -text => 1)->place(-x => 7*$coef, -y => 10*$coef); -$x += $fm_w + 5; +$x += $fm_w + 5*$coef; my $btn_next = $fm1->Button(@buttonattr, -image => $nextbmp, )->place(-x => $x, -y => $y); -$x += $btn_w + 15; +$x += $btn_w + 15*$coef; &setloopcommand($btn_prev, \&decrease_rate); &setloopcommand($btn_next, \&increase_rate); @@ -231,19 +251,19 @@ $lab_rate->bind('', [sub { # build hour frame #--------------------------------------------------------------------------------- -$x += 90; +$x += 90*$coef; my $xi; # next/prev buttons my $btn_tprev = $fm1->Button(@buttonattr, -image => $prevbmp, - )->place(-x => $x-$fm_w-5, -y => $y + 80); + )->place(-x => $x-$fm_w-5, -y => $y + 80*$coef); my $fm_lab = $fm1->Frame(@frameattr, -width => 3*$fm_w, -height => $fm_h)->place(-x => $x, -y => $y); # separators -$xi = -13 ; +$xi = -13*$coef ; for (my $i=0; $i<2; $i++) { $xi += $fm_w; $fm_lab->Label(@labelattr, @@ -252,28 +272,28 @@ for (my $i=0; $i<2; $i++) { -text => ':')->place(-x => $xi, -y => $ddy); } # hour, minutes, seconds -$xi = 5; +$xi = 5*$coef; my $lab_hour = $fm_lab->Label(@labelattr, -anchor => 'center', -text => '00')->place(-x => $xi, -y => $ddy); $xi += $fm_w; my $lab_min = $fm_lab->Label(@labelattr, -anchor => 'center', - -text => '00')->place(-x => $xi, -y => 10); + -text => '00')->place(-x => $xi, -y => 10*$coef); $xi += $fm_w; my $lab_sec = $fm_lab->Label(@labelattr, -anchor => 'center', - -text => '00')->place(-x => $xi, -y => 10); + -text => '00')->place(-x => $xi, -y => 10*$coef); $lab_hour->bind('<1>', [\&settime, 0]); $lab_min->bind('<1>', [\&settime, 1]); $lab_sec->bind('<1>', [\&settime, 2]); -$x += 3*$fm_w + 10; +$x += 3*$fm_w + 10*$coef; my $btn_tnext = $fm1->Button(@buttonattr, -image => $nextbmp, - )->place(-x => $x-5, -y => $y + 80); + )->place(-x => $x-5, -y => $y + 80*$coef); @@ -289,7 +309,7 @@ IvyIO::bind_for_clock_and_rate_event(sub { # build traffic control frame #--------------------------------------------------------------------------------- -$x += 90; +$x += 90*$coef; my $playbmp = $mw->Bitmap('play', -file => Tk::findINC('play.bmp'), -background => $bg, -foreground => $hlbg); @@ -306,11 +326,11 @@ my $playbtn = $fm1->Button(@buttonattr, -image => $playbmp, )->place(-x => $x, -y => $y); -$x += $btn_w + 20; +$x += $btn_w + 20*$coef; my $pausebtn = $fm1->Button(@buttonattr, -image => $pausebmp, )->place(-x => $x, -y => $y ); -$x += $btn_w + 20; +$x += $btn_w + 20*$coef; $playbtn->configure(-command => \&play); @@ -332,7 +352,7 @@ $fm1->Button(@buttonattr, -image => $quitbmp, -command => \&quitdialogbox, )->place(-x => $x, -y => $y); -$x -= $fm_w + 10; +$x -= $fm_w + 10*$coef; #--------------------------------------------------------------------------------- @@ -347,16 +367,16 @@ if ($fuguefile) { die "Cant' parse fugue config file $fuguefile\n" unless $code; } -my $x0 = $dxleft + 20; -my $y0 = $dytop + 25; -my $rmax = 10; +my $x0 = $dxleft + 20*$coef; +my $y0 = $dytop + 25*$coef; +my $rmax = 10*$coef; my $cmin = 2; my $wmax = ($width-2*$x0); -my $dy = 64; +my $dy = 64*$coef; my %hosts; Agent->configure($mw, $bg, $fg, $selcolor, $hlbg, $darkbg, \@fontspec20, - $x0, $y0, $wmax, $dy, $cmin, $rmax, $opt{b}); + $x0, $y0, $wmax, $dy, $cmin, $rmax, $opt{b}, $coef); for (@fugueconfigdata) { next unless $_->[0] eq 'global' or $_->[0] eq 'local'; @@ -387,6 +407,8 @@ sub usage { print "Options :\n"; print " -b ivybus bus ivy\n"; print " -nocursor hide mouse cursor\n"; + print " -smallsize display the app in 640x480 mode\n"; + print " -position position set the window position\n"; print "\n"; exit 0 if $exitflag ; @@ -440,7 +462,7 @@ sub quitdialogbox { $tl->title('ivycontrolpanel'); $tl->resizable(0, 0); my $fm = $tl->Frame(-background => $darkbg, - -highlightthickness => 3, + -highlightthickness => 3*$coef, -highlightbackground => $hlbg, )->pack(-side => 'top', -padx => 0, -pady => 0); my $fm1 = $fm->Frame(-background => $darkbg)->pack(-side => 'bottom'); @@ -456,24 +478,24 @@ sub quitdialogbox { -foreground => $fg, -borderwidth => 1, -highlightbackground => $hlbg, - -highlightthickness => 3, + -highlightthickness => 3*$coef, -height => 2, -activebackground => $bg, -activeforeground => $fg, @fontspec24); my $l = $fm->Label(@labelattr, -text => "kill all agents ?", - )->pack(-side => 'top', -padx => 20, -pady => 20, + )->pack(-side => 'top', -padx => 20*$coef, -pady => 20*$coef, -expand => 1, -fill => 'both'); $fm1->Button(@buttonattr, -text => 'yes', -command => sub { $l->configure(-text => $l->cget(-text)."...\nwait..."); &killandquit; }, - )->pack(-side => 'left', -padx => 20, -pady => 20, + )->pack(-side => 'left', -padx => 20*$coef, -pady => 20*$coef, -expand => 1, -fill => 'both'); $fm1->Button(@buttonattr, -text => 'cancel', -command => sub { $tl->destroy }, - )->pack(-side => 'left', -padx => 20, -pady => 20, + )->pack(-side => 'left', -padx => 20*$coef, -pady => 20*$coef, -expand => 1, -fill => 'both'); # placement at window center $tl->update; @@ -656,10 +678,10 @@ sub display_rate { $rate =~ s/\.0+$//; if (length($rate) > 2) { $lab_rate->configure(-width => 3, @fontspec24); - $lab_rate->place(-x => 5, -y => 15); + $lab_rate->place(-x => 5*$coef, -y => 15*$coef); } else { $lab_rate->configure(-width => 2, @fontspec34); - $lab_rate->place(-x => 7, -y => 10); + $lab_rate->place(-x => 7*$coef, -y => 10*$coef); } $lab_rate->configure(-text => $rate); if ($rate == 0 and $isplaying) { @@ -691,8 +713,8 @@ sub settime { if ($selectedtimelabel eq $lab) { $selectedtimelabel = undef; $lab->configure(-background => $bg, -foreground => $fg); - $btn_tprev->place(-y => $y + 80); - $btn_tnext->place(-y => $y + 80); + $btn_tprev->place(-y => $y + 80*$coef); + $btn_tnext->place(-y => $y + 80*$coef); &unsetloopcommand($btn_tprev); &unsetloopcommand($btn_tnext); my $time = $lab_hour->cget(-text).':'.$lab_min->cget(-text).':'. @@ -710,8 +732,8 @@ sub settime { } $lab->configure(-background => $fg, -foreground => $bg); unless (defined $selectedtimelabel) { - $btn_tprev->place(-y => $y - 80); - $btn_tnext->place(-y => $y - 80); + $btn_tprev->place(-y => $y - 80*$coef); + $btn_tnext->place(-y => $y - 80*$coef); } $selectedtimelabel = $lab; &setloopcommand($btn_tprev, sub {&decrease_time($lab, $field)}); @@ -767,7 +789,7 @@ ivycontrolpanel - an interface for controlling ivy agents =head1 SYNOPSIS -ivycontrolpanel [-help] [-b bus] [-nocursor] [fugueconfigfile] +ivycontrolpanel [-help] [-b bus] [-nocursor] [-smallsize] [-position pos] [fugueconfigfile] =head1 DESCRIPTION @@ -788,6 +810,14 @@ Specify the ivy bus. Hide mouse cursor (for touchscreen usage). +=item B<-smallsize> + +Set the window size to 640x480 pixels. + +=item B<-position> window position + +Specifie window position (x geometry format ex: -0+200). + =back =head1 FILE FORMAT -- cgit v1.1