#!/usr/bin/perl -w

use strict;
use warnings;

use Wx qw( :image );
Wx::InitAllImageHandlers();

use Image::LibRSVG;
use IO::Scalar;

my $formats = Image::LibRSVG->getSupportedFormats();
for (@$formats) { print "$_\n" }


my $bmp = '/usr/share/icons/oxygen/128x128/actions/webcamsend.png';
my $svg = '/usr/share/icons/breeze-dark/mimetypes/22/application-vnd.ms-powerpoint.svg';

my $renderer = Image::LibRSVG->new;
$renderer->loadFromFileAtSize($svg, 128, 128);
my $png = $renderer->getImageBitmap("png", 100);
my $img = Wx::Image->newStreamType(IO::Scalar->new(\$png), wxBITMAP_TYPE_PNG);


package MyIconFrame;
use Wx qw( :frame :textctrl :sizer :panel :window :id :image );
use base qw( Wx::Frame );
use Wx::Event qw( EVT_BUTTON );

sub new {
    my($class, $parent) = @_;
    my $self = $class->SUPER::new(
        $parent,
        -1,
        'Example Frame',
        [-1,-1],
        [-1,-1],
        wxDEFAULT_FRAME_STYLE 
	);
	my $sizer = Wx::BoxSizer->new(wxVERTICAL);
	$self->SetSizer($sizer);
	my $si = Wx::StaticBitmap->new($self, -1, Wx::Bitmap->new($bmp, wxBITMAP_TYPE_PNG));
	$sizer->Add($si);
	my $sj = Wx::StaticBitmap->new($self, -1, Wx::Bitmap->new($img));
	$sizer->Add($sj);

	$self->Layout;
	$self->Fit;
	return $self;
}


package IconDepotTest;

use base qw(Wx::App);   # Inherit from Wx::App

sub OnInit
{
   my $self = shift;
   my $frame = MyIconFrame->new;
   $self->SetTopWindow($frame);    # Define the toplevel window
   $frame->Show(1);                # Show the frame
}

package main;

my $wxobj = IconDepotTest->new(); # New HelloWorld application
$wxobj->MainLoop;
