| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
############################################################################# |
|
2
|
|
|
|
|
|
|
## Name: lib/Wx/DemoModules/wxScrolledWindow.pm |
|
3
|
|
|
|
|
|
|
## Purpose: wxPerl demo helper for Wx::ScrolledWindow |
|
4
|
|
|
|
|
|
|
## Author: Mattia Barbon |
|
5
|
|
|
|
|
|
|
## Modified by: |
|
6
|
|
|
|
|
|
|
## Created: 18/05/2003 |
|
7
|
|
|
|
|
|
|
## RCS-ID: $Id: wxScrolledWindow.pm 2189 2007-08-21 18:15:31Z mbarbon $ |
|
8
|
|
|
|
|
|
|
## Copyright: (c) 2003, 2006 Mattia Barbon |
|
9
|
|
|
|
|
|
|
## Licence: This program is free software; you can redistribute it and/or |
|
10
|
|
|
|
|
|
|
## modify it under the same terms as Perl itself |
|
11
|
|
|
|
|
|
|
############################################################################# |
|
12
|
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
package Wx::DemoModules::wxScrolledWindow; |
|
14
|
|
|
|
|
|
|
|
|
15
|
1
|
|
|
1
|
|
1112
|
use strict; |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
30
|
|
|
16
|
1
|
|
|
1
|
|
5
|
use base qw(Wx::ScrolledWindow); |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
650
|
|
|
17
|
|
|
|
|
|
|
use Wx qw(:sizer wxWHITE wxHORIZONTAL wxVERTICAL); |
|
18
|
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
sub SIZE() { 1000 } |
|
20
|
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
sub log_scroll_event { |
|
22
|
|
|
|
|
|
|
my( $event, $type ) = @_; |
|
23
|
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
Wx::LogMessage( 'Scroll %s event: orientation = %s, position = %d', $type, |
|
25
|
|
|
|
|
|
|
( ( $event->GetOrientation == wxHORIZONTAL ) ? 'horizontal' : 'vertical' ), |
|
26
|
|
|
|
|
|
|
$event->GetPosition ); |
|
27
|
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
# important! skip event for default processing to happen |
|
29
|
|
|
|
|
|
|
$event->Skip; |
|
30
|
|
|
|
|
|
|
} |
|
31
|
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
use Wx::Event qw(/EVT_SCROLLWIN_*/); |
|
33
|
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
sub new { |
|
35
|
|
|
|
|
|
|
my $class = shift; |
|
36
|
|
|
|
|
|
|
my $parent = shift; |
|
37
|
|
|
|
|
|
|
my $this = $class->SUPER::new( $parent, -1 ); |
|
38
|
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
# set the total area the scrolled window will show: note that at any |
|
40
|
|
|
|
|
|
|
# given time the window will only show a part of it |
|
41
|
|
|
|
|
|
|
$this->SetVirtualSize( SIZE, SIZE ); |
|
42
|
|
|
|
|
|
|
# set the numer of pixels the window will scroll at a time |
|
43
|
|
|
|
|
|
|
$this->SetScrollRate( 1, 1 ); |
|
44
|
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
$this->SetBackgroundColour( wxWHITE ); |
|
46
|
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
EVT_SCROLLWIN_TOP( $this, |
|
48
|
|
|
|
|
|
|
sub { log_scroll_event( $_[1], 'to top' ) } ); |
|
49
|
|
|
|
|
|
|
EVT_SCROLLWIN_BOTTOM( $this, |
|
50
|
|
|
|
|
|
|
sub { log_scroll_event( $_[1], 'to bottom' ) } ); |
|
51
|
|
|
|
|
|
|
EVT_SCROLLWIN_LINEUP( $this, |
|
52
|
|
|
|
|
|
|
sub { log_scroll_event( $_[1], 'a line up' ) } ); |
|
53
|
|
|
|
|
|
|
EVT_SCROLLWIN_LINEDOWN( $this, |
|
54
|
|
|
|
|
|
|
sub { log_scroll_event( $_[1], 'a line down' ) } ); |
|
55
|
|
|
|
|
|
|
EVT_SCROLLWIN_PAGEUP( $this, |
|
56
|
|
|
|
|
|
|
sub { log_scroll_event( $_[1], 'a page up' ) } ); |
|
57
|
|
|
|
|
|
|
EVT_SCROLLWIN_PAGEDOWN( $this, |
|
58
|
|
|
|
|
|
|
sub { log_scroll_event( $_[1], 'a page down' ) } ); |
|
59
|
|
|
|
|
|
|
# EVT_SCROLLWIN_THUMBTRACK( $this, |
|
60
|
|
|
|
|
|
|
# sub { log_scroll_event( $_[1], 'thumbtrack' ) } ); |
|
61
|
|
|
|
|
|
|
EVT_SCROLLWIN_THUMBRELEASE( $this, |
|
62
|
|
|
|
|
|
|
sub { log_scroll_event( $_[1], 'thumbrelease' ) } ); |
|
63
|
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
return $this; |
|
65
|
|
|
|
|
|
|
} |
|
66
|
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
# this is the easiest way to use a scrolled window; it is passed a |
|
68
|
|
|
|
|
|
|
# pre-scrolled Wx::DC. Alternatively derived classes may catch |
|
69
|
|
|
|
|
|
|
# paint events and call ->PrepareDC to pre-scroll the DC |
|
70
|
|
|
|
|
|
|
use Wx qw(wxSOLID wxTRANSPARENT_PEN wxBLACK_PEN); |
|
71
|
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
sub OnDraw { |
|
73
|
|
|
|
|
|
|
my( $this, $dc ) = @_; |
|
74
|
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
$dc->SetPen( wxBLACK_PEN ); |
|
76
|
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
for ( 0 .. 10 ) { |
|
78
|
|
|
|
|
|
|
$dc->DrawLine( 0, $_ * 100, SIZE, $_ * 100 ); |
|
79
|
|
|
|
|
|
|
$dc->DrawLine( $_ * 100, 0, $_ * 100, SIZE ); |
|
80
|
|
|
|
|
|
|
} |
|
81
|
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
$dc->SetPen( wxTRANSPARENT_PEN ); |
|
83
|
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
for my $x ( 0 .. 9 ) { |
|
85
|
|
|
|
|
|
|
for my $y ( 0 .. 9 ) { |
|
86
|
|
|
|
|
|
|
my $c = 255 - ( $x + $y ) * 255 / 18; |
|
87
|
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
$dc->SetBrush( Wx::Brush->new( Wx::Colour->new( $c, $c, $c ), |
|
89
|
|
|
|
|
|
|
wxSOLID ) ); |
|
90
|
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
$dc->DrawRectangle( $x * 100 + 1, $y * 100 + 1, |
|
92
|
|
|
|
|
|
|
99, 99 ); |
|
93
|
|
|
|
|
|
|
} |
|
94
|
|
|
|
|
|
|
} |
|
95
|
|
|
|
|
|
|
} |
|
96
|
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
sub add_to_tags { qw(windows) } |
|
98
|
|
|
|
|
|
|
sub title { 'wxScrolledWindow' } |
|
99
|
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
1; |