I've played around with TheGUILoft and was impressed with what it does for
the most part. My biggest problem is that it doesn't export win32-gui
code. I'd like the option of beging able to do both.
The script below converts a .gld file into perl code. The script itself is a
bit of a hack...:) The idea of this script is that I'm able to design
(complex) windows in loft and use the output in my code, with no runtime
dependency on loft.
Cheers,
jez.
-------------
use Storable qw(nstore store_fd nstore_fd freeze thaw dclone store);
use Cwd;
use Win32::GUI;
use Win32::GUI::Loft;
my $filename='your.gld';
print "package Windows; \n";
my $design=Win32::GUI::Loft::Design->newLoad($filename) or die("Could not
open window file ($filename)");
stripdesign($design);
print "return 1; \n";
sub stripdesign {
my $objDesign=shift;
#Window, dialog, or toolbar?
my $dialog = $objDesign->objControlWindow()->prop("DialogBox");
my $pkgNew = "Win32::GUI::Window"; #"window"
if($dialog eq "dialog") {
$pkgNew = "Win32::GUI::DialogBox";
$widthChange += -3;
$heightChange += -1;
}
elsif($dialog eq "toolbar") {
$pkgNew = "Win32::GUI::ToolbarWindow";
$widthChange += -1;
$heightChange += -4;
}
#Adjust the window size
#$objDesign->objControlWindow()->propIncSnap("Width", $widthChange, 0);
#$objDesign->objControlWindow()->propIncSnap("Height", $heightChange, 0);
my @aOptionRaw=$objDesign->objControlWindow()->buildOptions($objDesign);
my $name = $objDesign->objControlWindow()->runtimeName($objDesign);
print "sub $name { \n";
print 'my $w='.$pkgNew."->new('".join("','",@aOptionRaw)."'".',@_);'." \n";
for my $objControl (@{$objDesign->raControl()}) {
my @aOptionRaw = ($objControl->buildOptions($objDesign),
$objControl->buildOptionsSpecial($objDesign));
my $tip=$objControl->{rhControlProperty}{'Tip'};
if ($tip) {
#print $tip.'WE HAVE TIP';
my $tipvalue=$objControl->{rhControlProperty}{'Tip'}->value;
push @aOptionRaw,('-tip' => "$tipvalue" ) if $tipvalue;
}
my $method=$objControl->addMethod();
if ($method eq 'Win32::GUI::Graphic') {
$method='AddGraphic';
}
print '$w->'.$method."('".join("','",@aOptionRaw)."'); \n";
}
#do clusters
print 'my $cl;'."\n";
for my $objCluster (@{$objDesign->raCluster()}) {
#print 'cluster name'.$objCluster->name().'<';
my @controls;
for my $objControl (values %{$objCluster->rhControl()}) {
push @controls,'$w->'.$objControl->runtimeName($objDesign);
}
print '$cl->{'."'".$objCluster->name()."'".'}=['.join(',',@controls)."];
\n";
}
print 'return ($w,$cl) if $cl; return $w;}'."\n";
}