Skip to content

Commit

Permalink
Initial Commit
Browse files Browse the repository at this point in the history
  • Loading branch information
jmlynesjr committed Sep 27, 2012
0 parents commit 67fc4ff
Show file tree
Hide file tree
Showing 55 changed files with 2,896 additions and 0 deletions.
41 changes: 41 additions & 0 deletions CppTrial-pg019.pl
@@ -0,0 +1,41 @@
#!/usr/bin/perl

# CppTrial-pg019.pl
# Cross-Platform GUI Programming with wxWidgets - Smart, Hock, & Csomor
# C++ Example from pg 19 - Create a basic frame with menus and status bar
# Ported to wxPerl by James M. Lynes Jr. - Last Modified 9/23/2012

use 5.010;
use strict;
use warnings;

use Wx qw(:everything);
use Wx::Event qw(EVT_MOTION);

# create the WxApplication
my $app = Wx::SimpleApp->new;
my $frame = Wx::Frame->new(undef, -1,
'CppTrial-pg19.pl',
wxDefaultPosition, wxDefaultSize);
$frame->Show;

# Example specific code
my $cutIcon = Wx::Icon->new( "cut.xpm", wxBITMAP_TYPE_XPM, -1, -1);
$frame->SetIcon($cutIcon);

my $fileMenu = Wx::Menu->new();
my $helpMenu = Wx::Menu->new();

$fileMenu->Append(wxID_EXIT, "E&xit\tAlt-X", "Quit This Program");
$helpMenu->Append(wxID_ABOUT, "&About...\tF1", "Show About Dialog");

my $menuBar = Wx::MenuBar->new();
$menuBar->Append($fileMenu, "&File");
$menuBar->Append($helpMenu, "&Help");

$frame->SetMenuBar($menuBar);

my $statusBar = Wx::StatusBar->new($frame, wxID_ANY, wxST_SIZEGRIP);
$frame->SetStatusBar($statusBar);
$statusBar->SetStatusText("Welcome to wxWidgets!", 0);
$app->MainLoop;
47 changes: 47 additions & 0 deletions CppTrial-pg065.pl
@@ -0,0 +1,47 @@
#!/usr/bin/perl

# CppTrial-pg065.pl
# Cross-Platform GUI Programming with wxWidgets - Smart, Hock, & Csomor
# C++ Example from pg 65 - MDI Child Frame Example
# Ported to wxPerl by James M. Lynes Jr. - Last Modified 9/23/2012

use 5.010;
use strict;
use warnings;

use Wx qw(:everything);
use Wx::MDI;

# create the WxApplication
my $app = Wx::SimpleApp->new;
my $frame = Wx::Frame->new( undef, -1,
'CppTrial-pg065.pl',
wxDefaultPosition, wxDefaultSize );
mdiChildFrame($frame);
$frame->Show;
$app->MainLoop;

# Example specific code
sub mdiChildFrame {
my ( $self ) = @_;

my $ID_MYFRAME = 1;
my $ID_MYCHILD1 = 2;
my $ID_MYCHILD2 = 3;
my $ID_MYCHILD3 = 4;
my $ID_MYCHILD4 = 5;

my $parentFrame = Wx::MDIParentFrame->new($self, $ID_MYFRAME, "MDI Parent Window");

my $childFrame1 = Wx::MDIChildFrame->new($parentFrame, $ID_MYCHILD1, "Child 1");
my $childFrame2 = Wx::MDIChildFrame->new($parentFrame, $ID_MYCHILD2, "Child 2");
my $childFrame3 = Wx::MDIChildFrame->new($parentFrame, $ID_MYCHILD3, "Child 3");
my $childFrame4 = Wx::MDIChildFrame->new($parentFrame, $ID_MYCHILD4, "Child 4");

$childFrame1->Show(1);
$childFrame2->Show(1);
$childFrame3->Show(1);
$childFrame4->Show(1);
$parentFrame->Show(1);

}
50 changes: 50 additions & 0 deletions CppTrial-pg073.pl
@@ -0,0 +1,50 @@
#!/usr/bin/perl

# CppTrial-pg073.pl
# Cross-Platform GUI Programming with wxWidgets - Smart, Hock, & Csomor
# C++ Example from pg 73 - Notebook Example
# Ported to wxPerl by James M. Lynes Jr. - Last Modified 9/23/2012

use 5.010;
use strict;
use warnings;
use Wx qw(:everything);

# create the WxApplication
my $app = Wx::SimpleApp->new;
my $frame = Wx::Frame->new(undef, -1,
'CppTrial-pg073.pl',
wxDefaultPosition, wxDefaultSize);
Wx::InitAllImageHandlers();
Notebook($frame);
$frame->Show;
$app->MainLoop;

#Example specific code
sub Notebook {
my ( $self ) = @_;

my $noteBook = Wx::Notebook->new($self, -1, wxDefaultPosition, wxDefaultSize);

my $imageList = Wx::ImageList->new(16, 16, 1, 3);

my $cutxpm = Wx::Bitmap->new( "cut.xpm", wxBITMAP_TYPE_XPM );
my $copyxpm = Wx::Bitmap->new( "copy.xpm", wxBITMAP_TYPE_XPM );
my $printxpm = Wx::Bitmap->new( "print.xpm", wxBITMAP_TYPE_XPM );

$imageList->Add($cutxpm);
$imageList->Add($copyxpm);
$imageList->Add($printxpm);

$noteBook->SetImageList($imageList);

my $window1 = Wx::Panel->new($noteBook, wxID_ANY);
my $window2 = Wx::Panel->new($noteBook, wxID_ANY);
my $window3 = Wx::Panel->new($noteBook, wxID_ANY);

$noteBook->AddPage($window1, "Tab One", 1, 0);
$noteBook->AddPage($window2, "Tab Two", 0, 1);
$noteBook->AddPage($window3, "Tab Three", 0, 2);
}


38 changes: 38 additions & 0 deletions CppTrial-pg077.pl
@@ -0,0 +1,38 @@
#!/usr/bin/perl

# CppTrial-pg077.pl
# Cross-Platform GUI Programming with wxWidgets - Smart, Hock, & Csomor
# C++ Example from pg 77 - Scrolled Window Example
# Ported to wxPerl by James M. Lynes Jr. - Last Modfied 9/23/2012

use 5.010;
use strict;
use warnings;
use Wx qw(:everything);

# create the WxApplication
my $app = Wx::SimpleApp->new;
my $frame = Wx::Frame->new(undef, -1,
'CppTrial-pg077.pl',
wxDefaultPosition, wxDefaultSize);
scrolledWindow($frame);
$frame->Show;
$app->MainLoop;

# Example specific code
sub scrolledWindow {
my ( $self ) = @_;

my $scrolledWindow = Wx::ScrolledWindow->new($self, wxID_ANY,
Wx::Point->new(0, 0), Wx::Size->new(400, 400),
wxVSCROLL | wxHSCROLL);

my $pixelsPerUnitX = 10;
my $pixelsPerUnitY = 10;
my $noUnitsX = 1000;
my $noUnitsY = 1000;

$scrolledWindow->SetScrollbars($pixelsPerUnitX, $pixelsPerUnitY,
$noUnitsX, $noUnitsY);
}

42 changes: 42 additions & 0 deletions CppTrial-pg081.pl
@@ -0,0 +1,42 @@
#!/usr/bin/perl

# CppTrial-pg081.pl
# Cross-Platform GUI Programming with wxWidgets - Smart, Hock, & Csomor
# C++ Example from pg 81 - Splitter Window Example
# Ported to wxPerl by James M. Lynes Jr. - Last Modified 9/23/2012

use 5.010;
use strict;
use warnings;
use Wx qw(:everything);


# create the WxApplication
my $app = Wx::SimpleApp->new;
my $frame = Wx::Frame->new(undef, -1,
'CppTrial-pg081.pl',
wxDefaultPosition, wxDefaultSize);
SplitterWindow($frame);
$frame->Show;
$app->MainLoop;

# Example specific code
sub SplitterWindow {
my ( $self ) = @_;

my $splitterWindow = Wx::SplitterWindow->new($self, -1,
Wx::Point->new(0, 0), Wx::Size->new(400, 400),
wxSP_3D);

my $leftWindow = Wx::ScrolledWindow->new($splitterWindow);
$leftWindow->SetScrollbars(20, 20, 50, 50);
$leftWindow->SetBackgroundColour(wxRED);
$leftWindow->Show(1);

my $rightWindow = Wx::ScrolledWindow->new($splitterWindow);
$rightWindow->SetScrollbars(20, 20, 50, 50);
$rightWindow->SetBackgroundColour(wxCYAN);
$rightWindow->Show(0); # Right Window is Hidden

$splitterWindow->Initialize($leftWindow);
}
164 changes: 164 additions & 0 deletions CppTrial-pg086.pl
@@ -0,0 +1,164 @@
#!/usr/bin/perl

# CppTrial-pg086.pl
# Cross-Platform GUI Programming with wxWidgets - Smart, Hock, & Csomor
# C++ Example from pg 86 - 20 Assorted Static & Non-Static Controls Examples
# Several small examples combined into one source file covers pg86 - pg116
# Ported to wxPerl by James M. Lynes Jr. - Last Modified 9/23/2012

use 5.010;
use strict;
use warnings;
use Wx qw(:everything);

# create the WxApplication
my $app = Wx::SimpleApp->new;
my $frame = Wx::Frame->new(undef, -1,
'CppTrial-pg086.pl',
wxDefaultPosition, Wx::Size->new(500,700));
assortedControls($frame);
$frame->Show;
$app->MainLoop;

# Example specific code
sub assortedControls {
my ( $self ) = @_;

# Create a panel to place all of the controls on
my $panel= Wx::Panel->new($self, wxID_ANY, wxDefaultPosition, wxDefaultSize);

# pg86----- Plain Button
my $button = Wx::Button->new($panel, wxID_OK, "Ok",
Wx::Point->new(10, 10), wxDefaultSize);

# pg89----- Bitmap Button
my $bmp1 = Wx::Bitmap->new("print.xpm", wxBITMAP_TYPE_XPM);
my $picButton = Wx::BitmapButton->new($panel, wxID_OK, $bmp1,
Wx::Point->new(150, 10), wxDefaultSize, wxBU_AUTODRAW);

# pg91----- Choice Control
my $ID_CHOICEBOX = 1;
my @strings1 = ("One", "Two", "Three", "Four", "Five");
my $choice = Wx::Choice->new($panel, $ID_CHOICEBOX,
Wx::Point->new(250, 10), wxDefaultSize, \@strings1);

# pg92----- ComboBox Control
my $ID_COMBOBOX = 2;
my @strings2 = ("Apple", "Orange", "Pear", "Grapefruit");
my $combo = Wx::ComboBox->new($panel, $ID_COMBOBOX, "Apple",
Wx::Point->new(10,50), wxDefaultSize, \@strings2, wxCB_DROPDOWN);

# pg94----- CheckBox Control
my $ID_CHECKBOX = 3;
my $checkBox = Wx::CheckBox->new($panel, $ID_CHECKBOX, "&Check Me",
Wx::Point->new(10,200), wxDefaultSize);
$checkBox->SetValue(1);

# pg95----- ListBox Control
my $ID_LISTBOX = 4;
my @strings3 = ("First String", "Second String", "Third String",
"Fourth String", "Fifth String", "Sixth String");
my $listbox = Wx::ListBox->new($panel, $ID_LISTBOX,
Wx::Point->new(200,200), Wx::Size->new(180,80),
\@strings3, wxLB_SINGLE);

# pg96----- CheckListBox Control
my $ID_CHECKLISTBOX = 5;
my @strings4 = ("1st String", "2nd String", "3rd String",
"4th String", "5th String", "6th String");
my $checklistbox = Wx::CheckListBox->new($panel, $ID_CHECKLISTBOX,
Wx::Point->new(200,300), Wx::Size->new(180,80),
\@strings4, wxLB_SINGLE);

# pg99----- RadioBox Control
my $ID_RADIOBOX = 6;
my @strings5 = ("&One", "&Two", "T&hree", "&Four", "F&ive","&Six");
my $radiobox = Wx::RadioBox->new($panel, $ID_RADIOBOX, "RadioBox",
Wx::Point->new(10,300), wxDefaultSize, \@strings5,
3, wxRA_SPECIFY_COLS);

# pg101---- Radio Button Control (Spacing forced for display purposes - Sizers want to use whole window)
my $ID_RADIOBUTTON1 = 7;
my $ID_RADIOBUTTON2 = 8;
my $radioButton1 = Wx::RadioButton->new($panel, $ID_RADIOBUTTON1,
"&Male", Wx::Point->new(10,400), wxDefaultSize, wxRB_GROUP);
$radioButton1->SetValue(1);
my $radioButton2 = Wx::RadioButton->new($panel, $ID_RADIOBUTTON2,
"&Female", Wx::Point->new(75,400));
my $topSizer = Wx::BoxSizer->new(wxHORIZONTAL);
my $boxSizer = Wx::BoxSizer->new(wxHORIZONTAL);
$boxSizer->Add($radioButton1, 0, wxALIGN_CENTER_VERTICAL | wxALL, 5);
$boxSizer->Add($radioButton2, 0, wxALIGN_CENTER_VERTICAL | wxALL, 5);
# $topSizer->Add($boxSizer, 0, wxALIGN_CENTER_VERTICAL | wxALL, 5);
# $self->SetSizer($topSizer);

# pg102---- ScrollBar Control
my $ID_SCROLLBAR = 9;
my $scrollbar = Wx::ScrollBar->new($panel, $ID_SCROLLBAR,
Wx::Point->new(10,450), Wx::Size->new(200,20), wxSB_HORIZONTAL);

# pg103---- Spin Button Control
my $ID_SPINBUTTON = 10;
my $spinbutton = Wx::SpinButton->new($panel, $ID_SPINBUTTON,
Wx::Point->new(330,400), wxDefaultSize, wxSP_VERTICAL);

# pg105---- Spin Control
my $ID_SPINCONTROL = 11;
my $spincontrol = Wx::SpinCtrl->new($panel, $ID_SPINCONTROL, "5",
Wx::Point->new(250,450), wxDefaultSize,
wxSP_ARROW_KEYS, 0, 100, 5);

# pg106---- Slider Control
my $ID_SLIDERCONTROL = 12;
my $slidercontrol = Wx::Slider->new($panel, $ID_SLIDERCONTROL, 16, 0, 40,
Wx::Point->new(10,500), Wx::Size->new(200, -1),
wxSL_HORIZONTAL | wxSL_AUTOTICKS | wxSL_LABELS);

# pg108---- Text Control (w/pg109 also)
my $ID_TEXTCONTROL = 13;
my $textcontrol = Wx::TextCtrl->new($panel, $ID_TEXTCONTROL, "",
Wx::Point->new(250,500), Wx::Size->new(240, 100),
wxTE_MULTILINE);
$textcontrol->SetDefaultStyle(Wx::TextAttr->new(wxRED));
$textcontrol->AppendText("Red Text\n");
$textcontrol->SetDefaultStyle(Wx::TextAttr->new(wxNullColour, wxLIGHT_GREY));
$textcontrol->AppendText("Red on Gray Text\n");
$textcontrol->SetDefaultStyle(Wx::TextAttr->new(wxBLUE));
$textcontrol->AppendText("Blue on Gray Text\n");

# pg111---- Toggle Button
my $ID_TOGGLEBUTTON = 14;
my $togglebutton = Wx::ToggleButton->new($panel, $ID_TOGGLEBUTTON, "&Toggle Button",
Wx::Point->new(10,550), wxDefaultSize);
$togglebutton->SetValue(1);

# pg112---- Guage Control
my $ID_GAUGE = 15;
my $gauge = Wx::Gauge->new($panel, $ID_GAUGE, 200,
Wx::Point->new(10,600), wxDefaultSize, wxGA_HORIZONTAL);
$gauge->SetValue(50);

# pg113---- Static Text Control
my $ID_STATICTEXT = 16;
my $statictext = Wx::StaticText->new($panel, $ID_STATICTEXT,
"This is my &static text label",
Wx::Point->new(250,600), wxDefaultSize, wxALIGN_LEFT);

# pg114---- Static Bitmap Control
my $ID_STATICBITMAP = 17;
my $bmp2 = Wx::Bitmap->new("print.xpm", wxBITMAP_TYPE_XPM);
my $staticbitmap = Wx::StaticBitmap->new($panel, $ID_STATICBITMAP, $bmp2,
Wx::Point->new(175, 600), wxDefaultSize);

# pg115---- Static Line Control
my $ID_STATICLINE = 18;
my $staticline = Wx::StaticLine->new($panel, $ID_STATICLINE,
Wx::Point->new(10, 650), Wx::Size->new(450,-1),
wxLI_HORIZONTAL);

# pg116---- Static Box Control
my $ID_STATICBOX = 19;
my $staticbox = Wx::StaticBox->new($panel, $ID_STATICBOX,
"&Static Box",
Wx::Point->new(350, 10), Wx::Size->new(100, 100));
}

0 comments on commit 67fc4ff

Please sign in to comment.