Commits

Herbert Breunung  committed b7ed2c6

use wx color db

  • Participants
  • Parent commits c212c2d

Comments (0)

Files changed (2)

File lib/Kephra/App/Helper.pm

     else          { return $method_ref[0] }
 }
 
-sub is_abject { ( ref $_[0] and index(ref $_[0], '=') == -1) ? 1 : 0 }
-sub is_widget { ( ref $_[0] and $_[0]->isa('Wx::Control') ) ? 1 : 0 }
-sub is_panel  { ( ref $_[0] and $_[0]->isa('Wx::Panel') ) ? 1 : 0 }
+sub is_object { ( ref $_[0] and index(ref $_[0], '=') == -1) ? 1 : 0 }
+sub is_widget { ( is_object( $_[0] ) and $_[0]->isa('Wx::Control') ) ? 1 : 0 }
+sub is_panel  { ( is_object( $_[0] ) and $_[0]->isa('Wx::Panel') ) ? 1 : 0 }
 
 sub put_on_panel {
     my $widget = shift;
-    die "no widget given to __PACKAGE__::put_on_panel" unless is_a_widget($widget);
+    die "no widget given to __PACKAGE__::put_on_panel" unless is_widget($widget);
 
     my $panel = Wx::Panel->new( $widget->GetParent );
     $widget->Reparent( $panel );
     return $panel;
 }
 
-sub is_color { ( ref $_[0] and $_[0]->isa('Wx::Colour') ) ? 1 : 0 }
+sub is_color { ( is_object( $_[0] ) and $_[0]->isa('Wx::Colour') and $_[0]->IsOk ) ? 1 : 0 }
 
 sub make_color {
     my ($r, $g, $b, $t ) = @_;
         elsif ( $r =~ /^(\d+),\s*(\d+),\s*(\d+)$/ ) {
             ($r,$g,$b) = ( $1+0, $2+0, $3+0 );
         } else {
+            my $c = Wx::ColourDatabase::Find( $r );
+            return $c if is_color( $c );
             my %color = (
                 'white' => [255, 255, 255],
                 'red'   => [255,   0,   0],

File t/100-apphelper.t

 # making local lib favoured
 BEGIN { unshift @INC, -d 't' ? 'lib' : '../lib' }
 
-use Test::More tests => 12;
+use Test::More tests => 15;
 #use Text::Exception;
 use Test::NoWarnings;
 
 is( $testcolor->( $mk_color->("#0000FF") ), 1, '"#RRGGBB" input layout works');
 is( $testcolor->( $mk_color->("0000ff") ), 1, '"RRGGBB" input layout works');
 is( $testcolor->( $mk_color->("blue") ), 1,'"colorname" input layout works');
+is( $testcolor->( $mk_color->("WHEAT") ), 1,'"colorname" input layout works with db names');
 
-#my $popanel = Kephra::App::Helper::get('put_on_panel');
-#my $b = Wx::Button->new(undef,-1,'');
+# gui contruction helper
+my $popanel = Kephra::App::Helper::get('put_on_panel');
+my $testpanel = Kephra::App::Helper::get('is_panel');
+my $button = Wx::Button->new(undef,-1,'');
+my $panel = Wx::Panel->new(undef);
+is( $testpanel->($white), 0, 'can detect what is not a panel');
+is( $testpanel->($panel), 1, 'can detect panel');
+is( $testpanel->( $popanel->($button) ), 1, 'can detect panel');
 
 exit(0);