Changeset 461


Ignore:
Timestamp:
10/25/08 09:09:15 (3 years ago)
Author:
adamk
Message:

Refactoring Padre::Wx in general.

Added an export call to stimulate the creation of every Wx::wxConstant

Location:
trunk/lib/Padre
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/lib/Padre/Document/Perl.pm

    r451 r461  
    8181 
    8282sub keywords { 
    83     if (not $keywords) { 
    84         my $dir  = Padre::Wx::_dir(); 
    85         my $path = File::Spec->catfile($dir , 'languages', 'perl5', "perl5.yml"); 
    86         $keywords = YAML::Tiny::LoadFile($path); 
     83    unless ( defined $keywords ) { 
     84        $keywords = YAML::Tiny::LoadFile( 
     85            Padre::Wx::sharefile( 'languages', 'perl5', 'perl5.yml' ) 
     86        ); 
    8787    } 
    8888    return $keywords; 
  • trunk/lib/Padre/Wx.pm

    r433 r461  
    66use strict; 
    77use warnings; 
    8 use File::Spec; 
    9 use File::ShareDir; 
    10 use Wx qw{ 
    11     wxBITMAP_TYPE_XPM 
    12 }; 
     8use FindBin; 
     9use File::Spec     (); 
     10use File::ShareDir (); 
     11 
     12# Load every exportable constant into here, so that they come into 
     13# existance in the Wx:: package, allowing everywhere else in the code to 
     14# use them without braces. 
     15use Wx ':everything'; 
    1316 
    1417our $VERSION = '0.12'; 
    1518 
    16 sub _dir { 
    17     return $ENV{PADRE_DEV}      ?  File::Spec->catdir($FindBin::Bin, '..', 'share') 
    18          : $ENV{PADRE_PAR_PATH} ?  File::Spec->catdir($ENV{PADRE_PAR_PATH}, 'inc', 'share') 
    19          :                         File::ShareDir::dist_dir('Padre') 
    20          ; 
     19 
     20 
     21 
     22 
     23##################################################################### 
     24# Shared Resources 
     25 
     26sub share () { 
     27    return File::Spec->catdir( $FindBin::Bin, File::Spec->updir, 'share' ) if $ENV{PADRE_DEV}; 
     28    return File::Spec->catdir( $ENV{PADRE_PAR_PATH}, 'inc', 'share' )      if $ENV{PADRE_PAR_PATH}; 
     29    return File::ShareDir::dist_dir('Padre'); 
    2130} 
    2231 
     32sub sharedir { 
     33    File::Spec->catdir( share, @_ ); 
     34} 
     35 
     36sub sharefile { 
     37    File::Spec->catfile( share, @_ ); 
     38} 
     39 
     40 
     41 
     42 
     43 
     44##################################################################### 
     45# Load Shared Resources 
     46 
    2347sub bitmap { 
    24     my $file = shift; 
    25     my $dir  = _dir(); 
    26     my $path = File::Spec->catfile($dir , 'docview', "$file.xpm"); 
    27     return Wx::Bitmap->new( $path, wxBITMAP_TYPE_XPM ); 
     48    Wx::Bitmap->new( 
     49        sharefile( 'docview', "$_[0].xpm" ), 
     50        Wx::wxBITMAP_TYPE_XPM, 
     51    ); 
    2852} 
    2953 
    3054sub icon { 
    31     my $file = shift; 
    32     my $dir  = _dir(); 
    33     my $path = File::Spec->catfile($dir , 'docview', "$file.xpm"); 
    34     return Wx::Icon->new( $path, wxBITMAP_TYPE_XPM ); 
     55    Wx::Icon->new( 
     56        sharefile( 'docview', "$_[0].xpm" ), 
     57        Wx::wxBITMAP_TYPE_XPM, 
     58    ); 
    3559} 
    3660 
Note: See TracChangeset for help on using the changeset viewer.