Yoda/src/Abstract/Entity/Button.php
2024-07-22 14:25:22 +03:00

56 lines
No EOL
1.1 KiB
PHP

<?php
declare(strict_types=1);
namespace Yggverse\Yoda\Abstract\Entity;
abstract class Button
{
public \GtkButton $gtk;
public const SENSITIVE = false;
public const LABEL = 'Button';
public const IMAGE = null;
public function __construct()
{
$this->gtk = new \GtkButton;
if (\GtkIconTheme::get_default()->has_icon($this::IMAGE))
{
$this->gtk->set_image(
\GtkImage::new_from_icon_name(
$this::IMAGE,
\GtkIconSize::BUTTON
)
);
}
$this->gtk->set_sensitive(
$this::SENSITIVE
);
$this->gtk->set_label(
_($this::LABEL)
);
// Render
$this->gtk->show();
// Init events
$this->gtk->connect(
'clicked',
function(
\GtkButton $entity
) {
$this->_onClick(
$entity
);
}
);
}
abstract protected function _onClick(
\GtkButton $entity
): void;
}