-
Notifications
You must be signed in to change notification settings - Fork 8
/
CppTrial-pg157.pl
55 lines (44 loc) · 1.45 KB
/
CppTrial-pg157.pl
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
#!/usr/bin/perl
# CppTrial-pg157.pl
# Cross-Platform GUI Programming with wxWidgets - Smart, Hock, & Csomor
# C++ Example from pg 157 - Drawing Bitmaps - Extends pg 150 example
# C++ Example from pg 150 - Drawing Text - Extends pg 135 example
# C++ Example from pg 135 - Drawing on Windows with wxPaintDC
# Ported to wxPerl by James M. Lynes Jr. - Last Modified 9/24/2012
use 5.010;
use strict;
use warnings;
use Wx qw(:everything);
use Wx::Event qw(EVT_PAINT);
# create the WxApplication
my $app = Wx::SimpleApp->new;
Wx::InitAllImageHandlers();
my $frame = Wx::Frame->new(undef, -1,
'CppTrial-pg157.pl',
wxDefaultPosition, wxDefaultSize);
EVT_PAINT($frame,\&OnPaint);
$frame->Show;
$app->MainLoop;
# Example specific code
sub OnPaint {
my ( $self, $event) = @_;
my $dc = Wx::PaintDC->new($self);
my $pen = Wx::Pen->new(wxBLACK,1,wxSOLID);
$dc->SetPen($pen);
my $brush=Wx::Brush->new(wxRED,wxSOLID);
$dc->SetBrush($brush);
my $font = Wx::Font->new(10, wxFONTFAMILY_ROMAN, wxNORMAL, wxNORMAL);
$dc->SetFont($font);
$dc->SetBackgroundMode(wxTRANSPARENT);
$dc->SetTextForeground(wxBLACK);
$dc->SetTextBackground(wxWHITE);
my $msg = "Some text will appear mixed in the image's shadow...";
my $bmp = Wx::Bitmap->new("padre_logo_64x64.png", wxBITMAP_TYPE_PNG);
my $y = 75;
for (0..9) {
$y += $dc->GetCharHeight() +5;
$dc->DrawText($msg, 10, $y);
}
$dc->DrawBitmap($bmp, 150, 175, 1);
return;
}