74 lines
2.0 KiB
PHP
74 lines
2.0 KiB
PHP
<?php
|
|
|
|
require_once __DIR__ . '/../vendor/autoload.php';
|
|
|
|
use PHPNative\Framework\Application;
|
|
use PHPNative\Ui\Widget\Container;
|
|
use PHPNative\Ui\Widget\Label;
|
|
use PHPNative\Ui\Widget\Menu;
|
|
use PHPNative\Ui\Widget\MenuBar;
|
|
use PHPNative\Ui\Widget\StatusBar;
|
|
use PHPNative\Ui\Widget\TabContainer;
|
|
use PHPNative\Ui\Widget\Table;
|
|
use PHPNative\Ui\Window;
|
|
|
|
$app = new Application();
|
|
$window = new Window('Windows Application Example', 800, 600);
|
|
|
|
$mainContainer = new Container('bg-gray-100');
|
|
|
|
// === 1. MenuBar ===
|
|
$menuBar = new MenuBar();
|
|
|
|
// File Menu
|
|
$fileMenu = new Menu(title: 'Datei');
|
|
$fileMenu->addItem('Neu', function () {
|
|
echo "Neu clicked\n";
|
|
});
|
|
$fileMenu->addItem('Öffnen', function () {
|
|
echo "Öffnen clicked\n";
|
|
});
|
|
$fileMenu->addSeparator();
|
|
$fileMenu->addItem('Beenden', function () use ($app) {
|
|
echo "Beenden clicked\n";
|
|
exit(0);
|
|
});
|
|
|
|
// Settings Menu
|
|
$settingsMenu = new Menu(title: 'Einstellungen');
|
|
$settingsMenu->addItem('Optionen', function () {
|
|
echo "Optionen clicked\n";
|
|
});
|
|
$settingsMenu->addItem('Sprache', function () {
|
|
echo "Sprache clicked\n";
|
|
});
|
|
$menuBar->addMenu($fileMenu);
|
|
$menuBar->addMenu($settingsMenu);
|
|
|
|
$mainContainer->addComponent($menuBar);
|
|
|
|
$statusBar = new StatusBar();
|
|
$statusLabel = new Label(
|
|
text: 'Fenster: ' . $window->getViewport()->windowWidth . 'x' . $window->getViewport()->windowHeight,
|
|
style: 'basis-2/8 text-black',
|
|
);
|
|
$statusBar->addSegment($statusLabel);
|
|
$statusBar->addSegment(new Label(
|
|
text: 'Zeilen: 10',
|
|
style: 'basis-4/8 text-black border-l',
|
|
)); // Fixed width
|
|
$statusBar->addSegment(new Label(
|
|
text: 'Version 1.0',
|
|
style: 'border-l text-black basis-2/8',
|
|
));
|
|
$mainContainer->addComponent($statusBar);
|
|
$window->setOnResize(function (Window $window) use (&$statusLabel) {
|
|
$statusLabel->setText(
|
|
'Fenster: ' . $window->getViewport()->windowWidth . 'x' . $window->getViewport()->windowHeight,
|
|
);
|
|
});
|
|
// Set root and run
|
|
$window->setRoot($mainContainer);
|
|
$app->addWindow($window);
|
|
$app->run();
|