Bundle-PBib

 view release on metacpan or  search on metacpan

lib/PBibTk/RefDialog.pm  view on Meta::CPAN

sub paper {
	my $self = shift;
#	$self->{'paper'} = $self->converter('refs' => $self->refs())->entries($self->{'paper'}->{'CiteKey'});
	return $self->{'paper'};
#	return $self->{'paper'} = $self->converter('refs' => $self->refs())->entries($self->{'paper'}->{'CiteKey'});
	#  return $self->{'paper'};
}

sub refs {
	my $self = shift;
	my $refs = $self->{'refs'};
	unless( defined($refs) ) {
		$refs = $self->pBibTkUI()->refs();
	}
	return $refs;
}
sub biblio { my $self = shift; $self->pBibTkUI()->biblio(); }

#
# widgets
#


sub initWidgets {
  my ($self, $win) = @_;

  # menu inside a menu frame

  #  my $mf = $win->Frame()->grid(-sticky => 'ew');
  #  $mf->gridColumnconfigure(1, -weight => 1);
  #  $self->initMenu($mf, $win);
  my $mf = $win->Menu(-type => 'menubar');
  $win->configure(-menu => $mf);
  $self->initMenu($mf, $win);

  # text widget

  my $off = 0;
  my $list = $win->Scrolled('TextUndo',
		-scrollbars => 'se',
		-wrap => 'word',
		-setgrid => 'true',
		-exportselection => 'true',
#		-font => $FONT,
	)->form(
	-t => ['%0',0],
	-l => ['%0',0],
	-r => ['%100',0],
	-b => ['%100', $off]);
  $self->{'textWidget'} = $list;
  $list->tag(qw/configure list
			-lmargin1 20m
			-lmargin2 20m
			-spacing1 1p
		/);
  $list->tag(qw/configure field
			-tabs 20m
			-spacing1 3p
			-spacing2 0p
			-spacing3 0p
			-font T_bold
		/);
  $list->tag(qw/configure head
			-font H_big_bold
		/);
}
sub initMenu {
	my ($self, $mf, $win) = @_;
	my $cmd;
	
	# ref menu
	
	#  my $mbr = $mf->Menubutton(-text => 'References');
	#  $mbr->grid(-row => 0, -column => 0, -sticky => 'w');
	my $mbr = $mf->cascade(-label => '~References'); ###, -tearoff => 0);
	$mbr->command(-label => 'Insert Fields', -command => [ $self, 'addPaperFields' ] );
	$mbr->command(-label => 'Insert All Fields', -command => [ $self, 'addPaperFields', undef, 1 ] );
	$mbr->command(-label => 'Insert CSCW Ref.', -command => [ $self, 'addPaperRefCSCW' ] );
	$mbr->command(-label => 'Insert IEEE Ref.', -command => [ $self, 'addPaperRef', undef, 'IEEE' ] );
	$mbr->command(-label => 'Insert IEEETR Ref.', -command => [ $self, 'addPaperRef', undef, 'IEEETR' ] );
	$mbr->command(-label => 'Insert ElsevierJSS Ref.', -command => [ $self, 'addPaperRef', undef, 'ElsevierJSS' ] );
	$mbr->separator;
	$mbr->command(-label => 'Close', -command => sub {$win->destroy();});
	
	# Biblio::BP format menu
	
	my $mb = $mf->cascade(-label => '~Format'); ###, -tearoff => 0);
	$cmd = [ $self, 'importText' ];
	$mb->command(-label => "~Store reference", -command => $cmd,
				 -accelerator => 'Ctrl-S' );
	$win->bind('<Control-Key-S>' => $cmd);
	
	$mb->separator();
	
	my %unsupported_export = qw(
		auto 1 canon 1
		cstra 1
		inspec 1
		inspec4 1
		medline 1
		melvyl 1
		);
	foreach my $f (Biblio::BP::querySupportedFormats()) {
		next if exists($unsupported_export{$f});
		$mb->command(-label => "Export as $f", -command => [$self, "exportAsText", $f]);
	}
}

sub textWidget { my $self = shift; return $self->{'textWidget'}; }


#
# text
#


sub addPaperHeading {
	my ($self, $paper) = @_;
	$paper = $self->paper() unless defined($paper);
	my $title = $self->defaultTitle($paper);
	my $t = substr($paper->{'Title'} || '<<no title>>', 0, 70);
	my $a = substr($paper->{'Authors'} || '<<no author(s)>>', 0, 70);
	my $s = substr($paper->{'SuperTitle'} || $paper->{'Journal'} 
		|| '', 0, 65);



( run in 0.950 second using v1.01-cache-2.11-cpan-39bf76dae61 )