WxPerl beyond Frames and Buttons „analyze this“ feeling like ... feeling like ... feeling like ... feeling like ... feeling like ... feeling like ... Perl-Community.de the guy with the editor thing the WxPerl guy write about Perl 6 WxPerl WxPerl beyond Frames and Buttons WxPerl beyond Frames and Buttons WxPerl beyond Frames and Buttons native crossplatform native crossplatform native crossplatform What offers ● WxWidgets ??? Wx gives a native look 'n feel What offers WxWidgets ??? ● Wx gives a native look 'n feel ● fast & slim (compiled + delegates Rendering) What offers WxWidgets ??? ● Wx gives a native look 'n feel ● fast & slim (compiled + delegates Rendering) ● featurerich (Framework for Apps) What offers WxWidgets ??? ● Wx gives a native look 'n feel ● fast & slim (compiled + delegates Rendering) ● featurerich (Framework for Apps) Usual GUI Stuff ● Buttons, Label, Inputfield ● Frames, Menu, Toolbar, Statusbar ● Dialogs, Selectors ● compound widgets Extra Feature ? ● easy array / String / text file handling ● Regex / Unicode ● XML parser ● FTP / TCP / Zip / DateTime WxWidgets – the Factsheet ● foundet 1992 by Julian Smart using C++ WxWidgets – the Factsheet ● foundet 1992 by Julian Smart using C++ ● Windows (W32, CE), Unix(Gtk,Motif, X11) & Mac (9&X) WxWidgets – the Factsheet ● foundet 1992 by Julian Smart using C++ ● Windows (W32, CE), Unix(Gtk,Motif, X11) & Mac (9&X) ● LGPL (WxWdgets License) WxWidgets – the Factsheet ● foundet 1992 by Julian Smart using C++ ● Windows (W32, CE), Unix(Gtk,Motif, X11) & Mac (9&X) ● LGPL (WxWdgets License) ● mature, complete, in vital development WxPerl – the Factsheet ● work of Matia Barbon (MBARBON) since Nov 2000 WxPerl – the Factsheet ● work of Matia Barbon (MBARBON) since Nov 2000 ● XS - Wrapper + Helper Classes WxPerl – the Factsheet ● work of Matia Barbon (MBARBON) since Nov 2000 ● XS - Wrapper + Helper Classes ● CPAN Module Wx WxPerl – the Factsheet ● work of Matia Barbon (MBARBON) since Nov 2000 ● XS - Wrapper + Helper Classes ● CPAN Module Wx ● uses Alien::wxWidgets since 0.57 WxPerl – the Factsheet ● work of Matia Barbon (MBARBON) since Nov 2000 ● XS - Wrapper + Helper Classes ● CPAN Module Wx ● uses Alien::wxWidgets since 0.57 ● all inclucive let us code ... Erich Schubert Splashscreen my $bitmap = Wx::Bitmap->new ( 'splash/logo.jpg', wxBITMAP_TYPE_JPEG ); Wx::SplashScreen->new ( $bitmap , wxSPLASH_CENTRE_ON_SCREEN | wxSPLASH_TIMEOUT, ); 5000, undef, -1 fast Splashscreen use Wx::Perl::SplashFast ( 'logo.jpg', 2000 ); XRC – XML Ressource Compiler ● What is Wx::XRC? <?xml <?xmlversion..> version..> <resource> <resource> <object <objectclass class=> => <style></style> <style></style> XRC </object> </object> </resource> </resource> XRC - File Wx - GUI Linux & Win : wxFormBuilder and Mac: DialogBlocks all the Code you need ... use Wx::XRC; our @ISA = 'Wx::App'; # XRC anmelden sub OnInit { my $app = shift; Wx::InitAllImageHandlers(); my $xr = Wx::XmlResource->new(); $xr->InitAllHandlers(); $xr->Load('cont.xrc'); } ... # Bildhandling # Kompilerobjekt erzeugen # initialisieren # XRC-Datei Laden my $frame = $xr->LoadFrame(undef, 'ConFrame'); $frame->Show(1); ... all the Code you need ... use Wx::XRC; our @ISA = 'Wx::App'; # XRC anmelden sub OnInit { my $app = shift; Wx::InitAllImageHandlers(); my $xr = Wx::XmlResource->new(); $xr->InitAllHandlers(); $xr->Load('cont.xrc'); } ... # Bildhandling # Kompilerobjekt erzeugen # initialisieren # XRC-Datei Laden my $frame = $xr->LoadFrame(undef, 'ConFrame'); $frame->Show(1); ... < 100 lines XML catch Events ... use Wx::Event qw/ :everything /; ... # Eventkonstanten anmelden sub OnInit { ... my $frame = $xr->LoadFrame(undef, 'ConFrame'); } ... EVT_BUTTON($frame, Wx::XmlResource::GetXRCID('id'), sub { ... }) get Widgets by ID ... use Pod::Html; sub OnInit { ... my $XID = \&Wx::XmlResource::GetXRCID; EVT_BUTTON($frame, &$XID('m_button2'), sub { my $source = $frame->FindWindow(&$XID('m_textCtrl1'))->GetValue; my $target = $frame->FindWindow(&$XID('m_textCtrl2'))->GetValue; pod2html(”--infile=$source”, ”--outfile=$target”); } ... } ); ... WxHtmlWindow my $win = Wx::HtmlWindow->new($parent, -1); ● ● $win->SetPage($content); ●$win->LoadFile($file_path); ● ● $win->HistoryBack if $win->HistoryCanBack; ● ● EVT_HTML_LINK_CLICKED($frame, $win->GetId, sub {} ); ● WxHtmlWindow sub OnLinkClicked { ● my ($self , $event ) = @_; ● my $ctrl = $event->GetEventObject(); ● my $link = $event->GetLinkInfo()->GetHref(); ● Wx::DC ● Wx::DC ● WxPaintDC Wx::DC ● WxPaintDC ● ->SetBrush( wxBrush ) Wx::DC ● WxPaintDC ● ->SetBrush( wxBrush ) ● DrawPoint / DrawLine ● DrawRectangle / DrawRoundedRectangle ● DrawCircle / DrawEllipse / DrawSpline Wx::DC ● WxPaintDC ● ->SetBrush( wxBrush ) ● DrawPoint / DrawLine ● DrawRectangle / DrawRoundedRectangle ● DrawCircle / DrawEllipse / DrawSpline ● DrawText / DrawRotatedText / DrawBitmap Wx::DC ● copy / scale / stretch / clip ● ● fill areas map with pixelmaps Printing WxPrinter ● ● my $printer = Wx::Printer->new; ● my $printout = Printout->new (wxPrinterDC, `label`); ● $printer->Print( $mframe, $printout, 1 ); ● $printout->Destroy; ● WxPrintPreview ● wxPrintDialog ● wxHtmlEasyPrinting ● ● ● ->PrintFile( `filepath`); ● ● ->PrintText ( $html ); WxTextControl ● ● ● core simple fonts, style, colors, tabs (wxTextAttr) WxRichTextControl ● ● ● core can more (methods*3) fonts, style, colors, tabs (wxTextAttr) STC – StyledTextControl aka Scintilla STC – StyledTextControl ● WxGrid use Wx::Grid; ● ● my $grid = Wx::Grid->new(); ●$grid->CreateGrid( 100, 100 ); ● ● $grid->SetCellValue( 1, 1, "wise quote" ); ● ● $grid->SetColAttr( 2, $attr1 ); ●$grid->SetRowAttr( 3, $attr2 ); ● ● WxGrid use Wx::Event qw( ); ● ● EVT_GRID_CELL_LEFT_CLICK( $grid, sub {} ); ●EVT_GRID_COL_SIZE(); ●EVT_GRID_CELL_CHANGE(); ● EVT_GRID_RANGE_SELECT(); ● ● ● ● wxGridRangeSelectEvent DND – Drag 'N Drop ● ● $ep->DragAcceptFiles(1); ● ● $widget->SetDropTarget ( ● ● ); ● TargetClass->new( $widget, 'id') DND – Drag 'N Drop package SearchInputTarget; ● use base qw( Wx::TextDropTarget ); # wxFileDropTarget ● ● sub new { ● ● my ($class, ....) = @_; ● my $self = $class->SUPER::new(@_); ● return $self; } ● sub OnDropText { OnLeave ● # OnDragOver, DND – Drag 'N Drop package ........; ● ● use base qw( Wx::DropSource ); ● sub new { ● ● ... } ● sub DoDragDrop { ● ● ... Clipboard use qw( wxTheClipboard :dnd ); ● use Wx::DND; ● ● wxTheClipboard->Open; ● wxTheClipboard->SetData( $data ); ● wxTheClipboard->GetData( $data ); ● wxTheClipboard->Close; ● ● wxTheClipboard->Flush; ● Clipboard - copy sub OnCopy { ● ● wxTheClipboard->Open; ● my $data = Wx::DataObjectComposite->new; ● ● $data->Add( Wx::TextDataObject>new( $text ) ); $data->Add( Wx::BitmapDataObject->new – ( Wx::Bitmap->new( 100, 100 ) ), 1 ); – ● wxTheClipboard->Close; ● ... Clipboard - paste sub OnPaste { ● ● ● wxTheClipboard->Open; if ( wxTheClipboard->IsSupported( wxDF_TEXT )){ ● my $data = Wx::TextDataObject->new; ● my $ok = wxTheClipboard->GetData( $data ); ● if ( $ok ) { $text = $data->GetText; ● } else { ... } ● ● ● } wxTheClipboard->Close; Logging ● ● ● ● see Log4Perl ● Logging ● ● WxLog->SetActiveTarget( $widget ); wxLogTextCtrl ● Suspend / Resume ● SetActiveTarget( wxLogNull ) ● ● SetLogLevel ● SetRepetitionCounting ● SetVerbose ● SetTimestamp # AUI – Advanced User Interface ● AUI – Advanced User Interface ● AUI – Advanced User Interface ● AUI – Advanced User Interface ● AUI – How we do that? use Wx::AUI; AUI – How we do that? use Wx::AUI; sub new { $self->manager ( Wx::AuiManager->new ); $self->manager->SetManagedWindow ( $self ); my $book = Wx::AuiNotebook->new( ... more Examples: CPAN> install Wx::Demo shell> wxperl_demo[.pl] best Documentation: www.wxwidgets.org/downloads/ Thanks