Source

Kephra / lib / Kephra / App / ToolBar.pm

Full commit
use strict;
use warnings;
use Wx;

use Kephra::API;
use Kephra::CommandList;
use Kephra::Log;


package Kephra::App::ToolBar;

my $bar_ID = 4000;
my %storage;

# build ready to compile data structure from toolbar definitions (list of commandID)
sub assemble {
	
}

# make real toolbars from assembled data structure
sub compile {
	my $tb_data = shift // [];
	Kephra::Log::error('got no array ref') unless ref $tb_data eq 'ARRAY';
	my $parent = shift // Kephra::API::main_window();

	my $item_ID = $bar_ID;
	$bar_ID += 100;
	my $toolbar = Wx::ToolBar->new(
		$parent, -1, [-1,-1], [-1,-1], &Wx::wxTB_HORIZONTAL | &Wx::wxTB_DOCKABLE
	);
	$toolbar->SetToolBitmapSize([16,16]);

	for my $item_data (@$tb_data) {

		if (ref $item_data eq 'ARRAY') {

		} elsif (ref $item_data eq 'HASH' and exists $item_data->{'type'}) {
			#$toolbar->AddTool(
				#$item_ID++, '', &Wx::wxNullBitmap, &Wx::wxNullBitmap, #$item_data->{icon}
				#&Wx::wxITEM_NORMAL, 'label', 'help'
			#);
		} elsif ($item_data eq 'combobox'){
			my $input = Wx::ComboBox->new (
				$toolbar , -1, 'Find', [-1,-1], [200,-1], [],
				&Wx::wxTE_PROCESS_ENTER
			);
			#$input->SetDropTarget( Kephra::Edit::Search::InputTarget->new($input, 'ID'));
			$toolbar->AddControl($input);
		} elsif ($item_data eq 'separator'){
			$toolbar->AddSeparator;
		}
	}
	$toolbar->Realize();

	return wantarray
		? ($toolbar, ucfirst $tb_data->[0]{'bar_ID'})
		:  $toolbar;
}


1;