Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Newer
Older
100644 46 lines (35 sloc) 1.038 kB
67fc4ff @jmlynesjr Initial Commit
authored
1 #!/usr/bin/perl
2
3 # CppTrial-pg135.pl
4 # Cross-Platform GUI Programming with wxWidgets - Smart, Hock, & Csomor
5 # C++ Example from pg 135 - Drawing on Windows with wxPaintDC
6 # Ported to wxPerl by James M. Lynes Jr. - Last Modified 9/23/2012
7
8 use 5.010;
9 use strict;
10 use warnings;
11 use Wx qw(:everything);
12 use Wx::Event qw(EVT_PAINT);
13
14 # create the WxApplication
15 my $app = Wx::SimpleApp->new;
16 my $frame = Wx::Frame->new(undef, -1,
17 'CppTrial-pg135.pl',
18 wxDefaultPosition, wxDefaultSize,);
19 EVT_PAINT($frame,\&OnPaint);
20 $frame->Show;
21 $app->MainLoop;
22
23 # Example specific code
24 sub OnPaint {
25 my ( $self, $event) = @_;
26
27 my $dc = Wx::PaintDC->new($self);
28
29 my $pen = Wx::Pen->new(wxBLACK,1,wxSOLID);
30 $dc->SetPen($pen);
31 my $brush=Wx::Brush->new(wxRED,wxSOLID);
32 $dc->SetBrush($brush);
33
34 my $sz=$self->GetClientSize();
35 my $szx=$sz->x;
36 my $szy=$sz->y;
37
38 my $w=100;
39 my $h=50;
40 my $x=($szx - $w)/2;
41 my $y=($szy - $h)/2;
42
43 $dc->DrawRectangle($x,$y,$w,$h); # Centered on the window, try resizing...
44 }
45
Something went wrong with that request. Please try again.