1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
|
# Predefined cursors.
# -*- perl -*-
#
# $Id: $
# Author: Slaven Rezic
#
# Copyright (C) 2006,2008 Slaven Rezic. All rights reserved.
# This program is free software; you can redistribute it and/or
# modify it under the same terms as Perl itself.
#
# Mail: slaven@rezic.de
# WWW: http://www.rezic.de/eserte/
#
use vars qw/$TOP/;
sub cursor {
my($demo) = @_;
$TOP = $MW->WidgetDemo(
-name => $demo,
-text => <<'EOF',
This window displays the names of Tk's built-in
resp. predefined X11 cursors. Click or move on
the names to see the cursor shape.
EOF
-geometry_manager => 'grid',
-title => 'Predefined cursors',
-iconname => 'Predefined cursors',
);
my $fh;
TRY_CURSORFONTH: {
for my $cursorfonth (Tk->findINC("X11/cursorfont.h"),
"/usr/X11R6/include/X11/cursorfont.h",
"/usr/include/X11/cursorfont.h",
) {
last TRY_CURSORFONTH if (open $fh, $cursorfonth);
}
$TOP->Label(-text => "Sorry. I can't find X11/cursorfont.h on this system.")->grid;
return;
}
while(<$fh>) {
chomp;
if (/XC_(\S+)/) {
my $cursorname = $1;
next if $cursorname eq 'num_glyphs';
push @cursors, $cursorname;
}
}
$lb = $TOP->Scrolled("Listbox", -scrollbars => "ose", -selectmode => "browse")->grid(-sticky => "ns");
$lb->insert("end", @cursors);
$lb->bind("<Motion>", sub {
my($inx) = $lb->nearest($lb->Subwidget("scrolled")->XEvent->y);
$lb->configure(-cursor => $cursors[$inx]);
});
$lb->bind("<<ListboxSelect>>", sub {
my($inx) = $lb->curselection;
$lb->configure(-cursor => $cursors[$inx]);
});
}
__END__
|