Commits

Herbert Breunung committed d1ff653

start to use commandlist

  • Participants
  • Parent commits 8f7aa1f

Comments (0)

Files changed (3)

File lib/Kephra/App/Bar/Menu.pm

     my $bar = Wx::MenuBar->new();
 
     for my $menu_def (@$menu_def) {
-        my @names = keys %{ $menu_def->[0] };
+        my @names = keys %$menu_def;
 
         my $built_menu = Wx::Menu->new();
         my $menuitemID = $menu_ID;
         
-        for my $command_ID (@{ $menu_def->[0]{$names[0]} }) {
+        for my $command_ID (@{ $menu_def->{$names[0]} }) {
             unless ($command_ID and $command_ID) {
                 $built_menu->AppendSeparator;
                 next;

File lib/Kephra/App/Menu.pm

 # build ready to compile data structure from menu definitions (list of commandID)
 sub assemble {
 	my $menu_def = shift;
+	my $menu_data;
+	
+	for my $menu_def (@$menu_def) {
+		my @names = keys %{ $menu_def->[0] };
+
+		my $built_menu = Wx::Menu->new();
+		my $menuitemID = $menu_ID;
+		
+		for my $command_ID (@{ $menu_def->[0]{$names[0]} }) {
+			unless ($command_ID and $command_ID) {
+				$built_menu->AppendSeparator;
+				next;
+			}
+			#print $cmd_list->{$command_ID}{'call'}, "\n";
+			my $item = Wx::MenuItem->new(
+				$built_menu, $menuitemID,
+				$cmd_list->{$command_ID}{'name'}, '',
+				&Wx::wxITEM_NORMAL
+			);
+
+			Wx::Event::EVT_MENU ( 
+				$win, $menuitemID, $cmd_list->{$command_ID}{'callref'}
+			);
+
+			$built_menu->Append( $item );
+			$menuitemID++;
+		}
+
 }
 
 # make real menus from datastructure

File lib/Kephra/Config/Default/MainMenu.pm

 
 sub get {
 	return [
-		[{menu_file => [
+		{menu_file => [
 			'file_new',
 			'file_open',
 			'file_save',
 			'file_close',
 			'',
 			'app_close_save',
-		]}],
-		[{menu_config => [
+		]},
+		{menu_config => [
 			'config_dialog',
-		]}],
-		[{menu_help => [
+		]},
+		{menu_help => [
 			'help_documentation',
 			'help_homepage',
 			'help_bugreport',
 			'',
 			'help_about',
-		]}],
+		]},
 	];
 }