package bit.beelin.browser.ui;

import javafx.scene.control.Menu;
import javafx.scene.control.MenuBar;
import javafx.scene.control.MenuItem;
import javafx.scene.control.SeparatorMenuItem;

import de.codecentric.centerdevice.MenuToolkit;

/**
 *
 */
public class MacMenuBar {

    String appName;

    public MacMenuBar(String appName) {
        this.appName = appName;

        MenuToolkit tk = MenuToolkit.toolkit();

        MenuBar bar = new MenuBar();

        // Application Menu
        // TBD: services menu
        Menu appMenu = new Menu(appName); // Name for appMenu can't be set at
        // Runtime
        MenuItem aboutItem = new MenuItem("About");
        MenuItem prefsItem = new MenuItem("Preferences...");
        appMenu.getItems().addAll(aboutItem, new SeparatorMenuItem(), prefsItem, new SeparatorMenuItem(),
                tk.createHideMenuItem(appName), tk.createHideOthersMenuItem(), tk.createUnhideAllMenuItem(),
                new SeparatorMenuItem(), tk.createQuitMenuItem(appName));

        // File Menu (items TBD)
        Menu fileMenu = new Menu("File");
        MenuItem newItem = new MenuItem("New...");
        fileMenu.getItems().addAll(newItem, new SeparatorMenuItem(), tk.createCloseWindowMenuItem(),
                new SeparatorMenuItem(), new MenuItem("TBD"));

        // Edit (items TBD)
        Menu editMenu = new Menu("Edit");
        editMenu.getItems().addAll(new MenuItem("TBD"));

        // Format (items TBD)
        Menu formatMenu = new Menu("Format");
        formatMenu.getItems().addAll(new MenuItem("TBD"));

        // View Menu (items TBD)
        Menu viewMenu = new Menu("View");
        viewMenu.getItems().addAll(new MenuItem("TBD"));

        // Window Menu
        // TBD standard window menu items
        Menu windowMenu = new Menu("Window");
        windowMenu.getItems().addAll(tk.createMinimizeMenuItem(), tk.createZoomMenuItem(), tk.createCycleWindowsItem(),
                new SeparatorMenuItem(), tk.createBringAllToFrontItem());

        // Help Menu (items TBD)
        Menu helpMenu = new Menu("Help");
        helpMenu.getItems().addAll(new MenuItem("TBD"));

        bar.getMenus().addAll(appMenu, fileMenu, editMenu, formatMenu, viewMenu, windowMenu, helpMenu);

        tk.autoAddWindowMenuItems(windowMenu);
        tk.setGlobalMenuBar(bar);
    }
}

@@ -25,16 +25,76 @@
 er.ui;%0A%0A
+import javafx.event.ActionEvent;%0Aimport javafx.scene.Scene;%0A
 import j
@@ -119,16 +119,16 @@
 l.Menu;%0A
-
 import j
@@ -289,16 +289,209 @@
 Toolkit;
+%0Aimport javafx.scene.layout.BorderPane;%0Aimport javafx.scene.paint.Color;%0Aimport javafx.scene.text.Font;%0Aimport javafx.scene.text.Text;%0Aimport javafx.stage.Stage;%0Aimport javafx.stage.StageStyle;
 %0A%0A/**%0A *
@@ -906,17 +906,79 @@
 m(%22About
-%22
+ %22 + appName);%0A        aboutItem.setOnAction(this::aboutHandler
 );%0A     
@@ -2642,10 +2642,541 @@
 ;%0A    %7D%0A
+%0A    public void aboutHandler(ActionEvent event) %7B%0A        Stage stage = new Stage(StageStyle.UNDECORATED);%0A        stage.setWidth(300);%0A        stage.setHeight(300);%0A        stage.setResizable(false);%0A%0A        Text text = new Text(10, 40, %22About beeL%C4%ABn%22);%0A        text.setFont(new Font(40));%0A        Scene scene = new Scene(new BorderPane(text));%0A        scene.setFill(Color.AQUA);%0A        scene.setOnMousePressed(mouseEvent -%3E %7B%0A            stage.close();%0A        %7D);%0A%0A        stage.setScene(scene);%0A        stage.show();%0A    %7D%0A%0A
 %7D%0A

Add hardcoded “About” box