summaryrefslogtreecommitdiffstats
path: root/perl-install/mouse.pm
diff options
context:
space:
mode:
authordamien <damien@mandriva.com>2001-09-10 18:07:34 +0000
committerdamien <damien@mandriva.com>2001-09-10 18:07:34 +0000
commit63688b8ae2a600c329145bad26e2377a6ea9df14 (patch)
treedbcd3f997a77170cb1cac9aad40258854b089f92 /perl-install/mouse.pm
parent37b4a6af5d84be4dc98f03ea34e0639e5300b54f (diff)
downloaddrakx-backup-do-not-use-63688b8ae2a600c329145bad26e2377a6ea9df14.tar
drakx-backup-do-not-use-63688b8ae2a600c329145bad26e2377a6ea9df14.tar.gz
drakx-backup-do-not-use-63688b8ae2a600c329145bad26e2377a6ea9df14.tar.bz2
drakx-backup-do-not-use-63688b8ae2a600c329145bad26e2377a6ea9df14.tar.xz
drakx-backup-do-not-use-63688b8ae2a600c329145bad26e2377a6ea9df14.zip
test_mouse moved
Diffstat (limited to 'perl-install/mouse.pm')
-rw-r--r--perl-install/mouse.pm114
1 files changed, 114 insertions, 0 deletions
diff --git a/perl-install/mouse.pm b/perl-install/mouse.pm
index 6d80964b4..75516c507 100644
--- a/perl-install/mouse.pm
+++ b/perl-install/mouse.pm
@@ -415,3 +415,117 @@ EndSection
};
$update_mouse->($mouse);
}
+
+sub test_mouse_install {
+ my ($mouse) = @_;
+ require my_gtk;
+ my_gtk->import(qw(:wrappers :helpers));
+ my $w = my_gtk->new;
+ my ($width, $height, $offset) = (210, round_up(min(350, $::windowheight - 150), 6), 25);
+ my $darea = new Gtk::DrawingArea;
+ $darea->set_events([ 'button_press_mask', 'button_release_mask' ]); #$darea must be unrealized.
+ gtkadd($w->{window},
+ gtkpack(my $vbox_grab = new Gtk::VBox(0,0),
+ gtksize(gtkset_usize($darea, $width+1, $height+1), $width+1, $height+1),
+ my $okcancel = gtkset_sensitive(create_okcancel($w, '', '', "edge"), 0),
+ ),
+ );
+ $okcancel->set_uposition(7, $height-23);
+ Gtk->timeout_add(2000, sub { gtkset_sensitive($okcancel, 1) });
+ test_mouse($mouse, $w, $darea, $width, $height, $vbox_grab);
+}
+
+sub test_mouse_standalone {
+ my ($mouse, $hbox) = @_;
+ require my_gtk;
+ my_gtk->import(qw(:wrappers));
+ my ($width, $height, $offset) = (210, round_up(min(350, $::windowheight - 150), 6), 25);
+ my $darea = new Gtk::DrawingArea;
+ $darea->set_events([ 'button_press_mask', 'button_release_mask' ]); #$darea must be unrealized.
+ gtkpack($hbox,
+ gtkpack(gtkset_border_width(new Gtk::VBox(0,10), 10),
+ gtksize(gtkset_usize($darea, $width+1, $height+1), $width, $height)
+ )
+ );
+ test_mouse($mouse, $hbox, $darea, $width, $height);
+}
+
+sub test_mouse {
+ my ($mouse, $w, $darea, $width, $height, $vbox_grab) = @_;
+
+ $darea->realize();
+ my ($m3_image, $m3_mask) = gtkcreate_xpm($darea, 'mouse_3b.xpm');
+ my ($m3_imagep, $m3_maskp) = gtkcreate_xpm($darea, 'mouse_3b+.xpm');
+ my ($m3_left, $m3_left_mask) = gtkcreate_xpm($darea, 'mouse_left.xpm');
+ my ($m3_right, $m3_right_mask) = gtkcreate_xpm($darea, 'mouse_right.xpm');
+ my ($m3_middle, $m3_middle_mask) = gtkcreate_xpm($darea, 'mouse_middle.xpm');
+ my $image = $m3_image;
+ $mouse->{nbuttons} > 3 and $image = $m3_imagep;
+ my $draw_text = sub {
+ my ($t, $y) = @_;
+ my $font = $darea->style->font;
+ my $w = $font->string_width($t);
+ $darea->window->draw_string($font, $darea->style->black_gc, ($width - $w) / 2, $y, $t);
+ };
+ my $drawarea; $drawarea = sub { $darea->window->draw_pixmap ($darea->style->bg_gc('normal'),
+ $image, 0, 0,
+ ($darea->allocation->[2]-$width)/2, ($darea->allocation->[3]-$height)/2,
+ 210, 350);
+ $draw_text->(_("Please test the mouse"), $height - 80);
+ $draw_text->(_("To activate the mouse,"), $height - 65) if $mouse->{XMOUSETYPE} eq 'IMPS/2';
+ $draw_text->(_("MOVE YOUR WHEEL!"), $height - 50) if $mouse->{XMOUSETYPE} eq 'IMPS/2';
+ };
+
+ my $paintButton = sub {
+ my ($nb, $pressed) = @_;
+ my $x = 60 + $nb*33;
+ $drawarea->();
+ if ($nb == 0) {
+ $darea->window->draw_pixmap ($darea->style->bg_gc('normal'),
+ $m3_left, 0, 0,
+ ($darea->allocation->[2]-$width)/2+31, ($darea->allocation->[3]-$height)/2 + 52,
+ 59, 91);
+ } elsif ($nb == 2) {
+ $darea->window->draw_pixmap ($darea->style->bg_gc('normal'),
+ $m3_right, 0, 0,
+ ($darea->allocation->[2]-$width)/2+117, ($darea->allocation->[3]-$height)/2 + 52,
+ 61, 91);
+ } elsif ($nb == 1) {
+ if ($mouse->{nbuttons} > 3) {
+ $darea->window->draw_pixmap ($darea->style->bg_gc('normal'),
+ $m3_middle, 0, 0,
+ ($darea->allocation->[2]-$width)/2+98, ($darea->allocation->[3]-$height)/2 + 67,
+ 13, 62);
+ } else {
+ $darea->window->draw_arc ( $darea->style->black_gc,
+ 1, ($darea->allocation->[2]-$width)/2 + $x, ($darea->allocation->[3]-$height)/2 + 90, 20, 25,
+ 0, 360*64);
+ }
+ } elsif ($nb == 4) {
+ $darea->window->draw_pixmap ($darea->style->bg_gc('normal'),
+ $m3_middle, 0, 0,
+ ($darea->allocation->[2]-$width)/2+98, ($darea->allocation->[3]-$height)/2 + 67,
+ 13, 62)
+ } elsif ($nb == 5) {
+ $darea->window->draw_pixmap ($darea->style->bg_gc('normal'),
+ $m3_middle, 0, 0,
+ ($darea->allocation->[2]-$width)/2+98, ($darea->allocation->[3]-$height)/2 + 67,
+ 13, 62)
+ }
+ };
+ $darea->signal_connect(button_press_event => sub {
+ my $b = $_[1]{button};
+ $paintButton->($b - 1);
+ });
+ $darea->signal_connect(button_release_event => sub {
+ $drawarea->()
+ });
+ $darea->signal_connect(expose_event => sub { $drawarea->() });
+ $darea->size($width, $height);
+ $darea->set_events([ 'button_press_mask', 'button_release_mask' ]);
+ $w->sync; # HACK
+ $vbox_grab and Gtk::Gdk->pointer_grab($darea->window, 1,
+ [ 'pointer_motion_mask'],
+ $darea->window, undef ,0);
+ $w->main;
+}