Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Newer
Older
100644 67 lines (53 sloc) 1.865 kB
67fc4ff @jmlynesjr Initial Commit
authored
1 #!/usr/bin/perl
2
3 # CppTrial-pg224.pl
4 # Cross-Platform GUI Programming with wxWidgets - Smart, Hock, & Csomor
5 # C++ Example from pg 224 - Font Selection Dialog
6 # Ported to wxPerl by James M. Lynes Jr. - Last Modified 9/25/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-pg224.pl',
18 wxDefaultPosition, wxDefaultSize);
19
20 # Use status bar to indicate button presses
21 my $statusBar = Wx::StatusBar->new($frame, wxID_ANY, wxST_SIZEGRIP);
22 $frame->SetStatusBar($statusBar);
23 my @widths = (250, 100, -1);
24 $statusBar->SetFieldsCount($#widths+1);
25 $statusBar->SetStatusWidths(@widths);
26 $statusBar->SetStatusText("Ready", 0);
27
28 EVT_PAINT($frame, \&myStdDialogs);
29
30 $frame->Show;
31 $app->MainLoop;
32
33 # Example specific code
34 sub myStdDialogs {
35 my ( $self, $event ) = @_;
36
37 my $font = Wx::Font->new(18, wxFONTFAMILY_ROMAN, wxNORMAL, wxNORMAL);
38
39 my $fontData = Wx::FontData->new();
40 $fontData->SetInitialFont($font);
41 $fontData->SetColour(wxGREEN);
42
43 my $fontDialog = Wx::FontDialog->new($self, $fontData);
44
45 my $fontDialogStatus = $fontDialog->ShowModal();
46
47 $fontData = $fontDialog->GetFontData();
48 my $selectedfont = $fontData->GetChosenFont();
49 my $selectedcolour = $fontData->GetColour();
50 #
51 # Code added to provide something to display, drag dialog off of frame to see text displayed
52 #
53 my $dc = Wx::PaintDC->new($self);
54 my $pt=Wx::Point->new(100,200);
55 $dc->SetFont($selectedfont);
56 $dc->SetBackgroundMode(wxTRANSPARENT);
57 $dc->SetTextForeground($selectedcolour);
58 $dc->SetTextBackground(wxWHITE);
59 $dc->DrawText("Font Selection Sample",$pt->x, $pt->y);
60 $self->Refresh();
61
62 #
63 # Loop until Cancel is Selected
64 #
65 if ( $fontDialogStatus == wxID_CANCEL ) {die "Font Selection Terminated"};
66 }
Something went wrong with that request. Please try again.