milkbone57 22 years ago
parent
commit
7999d8b12d
  1. 2
      Milkbone.pm
  2. 9
      plugins/Tk-GUI/Tk-GUI.pl
  3. 7
      plugins/Tk-GUI/Tk/Browser.pm
  4. 16
      plugins/Tk-GUI/test.pl

2
Milkbone.pm

@ -20,6 +20,8 @@ use Benchmark; @@ -20,6 +20,8 @@ use Benchmark;
our $VERSION = "0.355";
require Exporter;
our @ISA = qw( Exporter );

9
plugins/Tk-GUI/Tk-GUI.pl

@ -28,6 +28,9 @@ else @@ -28,6 +28,9 @@ else
$defaultFont = 'arial';
}
my %fonts;
map { $fonts{$_} = 1 } $mw->fontFamilies;
$mw->optionAdd("*font", "-*-$defaultFont-norma-r-*-*-*-120-*-*-*-*-*-*");
$mw->optionAdd("*borderWidth", 1);
$mw->optionAdd("*highlightThickness", 0);
@ -43,6 +46,12 @@ register_hook("tick", \&tick); @@ -43,6 +46,12 @@ register_hook("tick", \&tick);
register_hook("tk_getmain", sub {
return $mw;
});
register_hook("tk_getfont". sub {
print "getfont called with" . $ARGS{-font};
return $ARGS{-font} if exists($fonts{$ARGS{-font}});
print "font doesn't exist - here's the default";
return $defaultFont;
});
register_hook("tk_bindwheel", sub {
if($^O =~ /win32/i)

7
plugins/Tk-GUI/Tk/Browser.pm

@ -5,6 +5,8 @@ use Tk::Font; @@ -5,6 +5,8 @@ use Tk::Font;
use base 'Tk::ROText';
use Cwd qw(abs_path);
use Milkbone;
use strict;
use warnings;
@ -15,7 +17,7 @@ sub insertHTML @@ -15,7 +17,7 @@ sub insertHTML
my ($self, $pos, $html) = @_;
my @insert;
$self->configure(-selectforeground => 'white', -selectbackground => 'black', -background => 'white');
$self->configure(-selectforeground => 'white', -selectbackground => 'black');
$html =~ s/<br>/\n/gi;
$html =~ s/<body bgcolor=/<font back=/gi;
@ -179,7 +181,8 @@ sub font_begin @@ -179,7 +181,8 @@ sub font_begin
$realsize = int((8, 10, 12, 14, 18, 24, 38) [int($size) + 1]) if $size and $^O !~ /Win32/;
$font->{-family} = "{$family}" if $family;
$font->{-family} = "{" . hook("tk_getfont", -font => $family) . "}"
if $family;
$font->{-size} = $realsize if $size;
my %opts;

16
plugins/Tk-GUI/test.pl

@ -1,20 +1,10 @@ @@ -1,20 +1,10 @@
use Tk;
use Tk::Text;
use Tk::Browser;
$mw = MainWindow->new;
$edit = $mw->TextUndo->pack;
$edit = $mw->Browser->pack;
$edit->insert('end', 't');
$edit->tagConfigure('<b>', -font => $mw->Font(-family => 'times', -weight => 'bold'));
$edit->tagConfigure('elide', -elide => 1);
$tag = "<b>";
$mw->Button(-text => 'bold', -command => sub {
$edit->insert('insert', 'de', [$tag, 'elide']);
$edit->tagAdd($tag, 'insert');
})->pack;
$edit->insertHTML('end', "<font face='garamond'>erererr");
MainLoop;
Loading…
Cancel
Save