Tk-MK

 view release on metacpan or  search on metacpan

lib/Tk/Treeplus.pm  view on Meta::CPAN

	);

	$this->SUPER::Populate($args);

	$this->ConfigSpecs(
		#
        -wrapsearch 	 		=> ['PASSIVE', 'wrapsearch', 'Wrapsearch', 0 ],
        #
		-maxselhistory 	 		=> ['PASSIVE', 'maxselhistory', 'Maxselhistory', MAX_HISTORY_SIZE ],
		#
        -clipboardseparator		=> ['PASSIVE', 'clipboardseparator', 'Clipboardseparator', DEFAULT_CLIPBOARD_SEPARATOR ],
		#
		-headerminwidth 		=> ['PASSIVE', 'minwidth', 'MinWidth', 20 ],
		-headerclosedwidth		=> ['PASSIVE', 'closedwidth', 'ClosedMinWidth', 5 ],
        #
		-headerforeground 		=> ['PASSIVE', 'headerForeground', 'HeaderForeground', 'black'],
        -headerbackground 		=> ['PASSIVE', 'headerBackground', 'HeaderBackground', '#d9d9d9'],
        -headeractiveforeground => ['PASSIVE', 'headerActiveforeground', 'HeaderActiveforeground', 'black'],
        -headeractivebackground => ['PASSIVE', 'headerActivebackground', 'HeaderActivebackground', 'gray'],
		#
		# Internal, activates the headers for convenience

lib/Tk/Treeplus.pm  view on Meta::CPAN

		)	    
	}
	#------------------------------------------------------------------------
	$menu->separator;
	$xclip_submenu = $menu->cascade(
			-label => 'X-ClipBoard',
			-tearoff => '0',
	);
	$xclip_submenu->command(
					-label => 'Export Selected Entry(ies)',
					-command => sub { $this->__copy_selection_to_clipboard() },
					-accelerator => 'Ctrl-c'
	);
	$xclip_submenu->command(
					-label => 'Export Selection + Column Headers',
					-command => sub { $this->__copy_selection_to_clipboard('use_header_info') },
					-accelerator => 'Ctrl-C'
	);

	# Set some default bindings
	$this->bind('<Control-c>' => sub { $this->__copy_selection_to_clipboard() } );
	$this->bind('<Control-C>' => sub { $this->__copy_selection_to_clipboard('use_header_info') } );
 	$this->bind('<Control-f>' => sub { $this->__find_hlentry(0) } );


	#------------------------------------------------------------------------
 	$menu->Popup(-popover => 'cursor', -popanchor => 'nw');
}

#--------------------------------------------------------------------------------------------------
# 
#  InitializeSelectHistory()

lib/Tk/Treeplus.pm  view on Meta::CPAN

		$this->__filter_hlentry_r($filter_info, '')
	}
}


#-----------------------------------------------------------------
# Very internal related function, NOT to be invoked by user apps 
#-----------------------------------------------------------------
# Transfers the current selected entries of the given
# widget into the common X11-Clipboard.
sub __copy_selection_to_clipboard
{
    #print "DBG: reached function [__copy_selection_to_clipboard] with >@_<, called by >", caller, "<\n";
	# Parameter
	my ($this, $use_header_info) = @_;

	# Locals
	my (@selitems, $selectforeground, $selectbackground, $text, $clip_txt,
		$wclass, $col_cnt, $clipboard_column_separator, $column, $entry);

	return unless $this;
	@selitems = $this->infoSelection();
	if (@selitems) {
		$selectforeground = $this->cget('-selectforeground');
		$selectbackground = $this->cget('-selectbackground');
		
		$wclass = ref $this; $clip_txt = '';
		$col_cnt = $this->cget('-columns');
		$clipboard_column_separator = $this->cget('-clipboardseparator');
		if ($wclass =~ /HList|Tree/io and $use_header_info and $this->cget('-header')) {
			for ($column = 0; $column < $col_cnt; $column++) {
				$clip_txt .= $clipboard_column_separator if $clip_txt;
				$clip_txt .= $this->headerCget($column, '-text');
			}
			#print "DBG: header: [\$clip_txt] = >$clip_txt<\n";
		}
		# REtrieve all selected items
		foreach (@selitems) {
			if ($wclass =~ /TList/io) {
				$text = $this->entrycget($_, '-text');
			}
			elsif ($wclass =~ /HList|Tree/io) {
				$text = '';
				for ($column = 0; $column < $col_cnt; $column++) {
					$text .= $clipboard_column_separator if length $text;
					$entry  = $this->itemCget($_, $column, '-text'); $entry  = '' unless defined $entry;
					$text .= $entry;
				}
			}
			else {
				last; # don't do anything on unspecific widget types
			}
			$clip_txt .= "\n" if $clip_txt;
			$clip_txt .= $text;
		}
		if ($clip_txt) {
			# Update the global (unix) Clipboard
			$this->clipboardClear();
			$this->clipboardAppend($clip_txt);		    
			$this->configure( -selectforeground => 'black',
								-selectbackground => ($use_header_info ? 'lawngreen' : 'darkgreen'),
			);
			#print "DBG: Copied Entries [$clip_txt] from Widget [$wclass] to global X-clipboard.\n"
		}
		else {
			$this->clipboardClear();
			$this->clipboardAppend($clip_txt);		    
			$this->configure( -selectforeground => 'white',
								-selectbackground => 'darkred',
			);
			carp "Internal Warning: Failed to copy Entries from Widget [$wclass] to global X-clipboard!\n"
		}
		$this->update;
 		usleep(900000);
		$this->configure( -selectforeground => $this->cget('-foreground'),
							-selectbackground => $this->cget('-background'),
		);
		$this->update;
		usleep(300000);

		# Restore original settings

lib/Tk/Treeplus.pm  view on Meta::CPAN

=over 4

=item B<-wrapsearch> 0/1

Decides whether the I<Find> search will restart from the begin of the list in case it reaches the end.

=item B<-maxselhistory> nnn

Specifies the maximum number of I<chached> list-selection operations, which can be recalled via the pop-up-menu.

=item B<-clipboardseparator> CHAR

Specifies the B<colum separator character> which is used if the the current selection is export to the X11 Clipboard.
This operation can be done via CTRl-C or via the pop-up-menu. (default char: '|')

=item B<-headerminwidth> nnn

Specifies the minimum size of a column during custom column resizing operation (default: 20px)

=item B<-headerclosedwidth> nnn



( run in 2.117 seconds using v1.01-cache-2.11-cpan-84e82930d8c )