mirror of
https://github.com/YGGverse/Yoda.git
synced 2026-04-01 00:55:28 +00:00
118 lines
2.2 KiB
PHP
118 lines
2.2 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace Yggverse\Yoda\Abstract\Entity\Browser\Container\Page\Content;
|
|
|
|
use \GdkEvent;
|
|
use \GtkLabel;
|
|
|
|
use \Yggverse\Yoda\Entity\Browser\Container\Page\Content;
|
|
|
|
abstract class Markup
|
|
{
|
|
public GtkLabel $gtk;
|
|
|
|
// Dependencies
|
|
public Content $content;
|
|
|
|
// Defaults
|
|
public const WRAP = 140;
|
|
|
|
public function __construct(
|
|
Content $content
|
|
) {
|
|
// Init dependency
|
|
$this->content = $content;
|
|
|
|
// Init markup label
|
|
$this->gtk = new GtkLabel;
|
|
|
|
$this->gtk->set_use_markup(
|
|
true
|
|
);
|
|
|
|
$this->gtk->set_selectable(
|
|
true
|
|
);
|
|
|
|
$this->gtk->set_track_visited_links(
|
|
true
|
|
);
|
|
|
|
$this->gtk->set_xalign(
|
|
0
|
|
);
|
|
|
|
$this->gtk->set_yalign(
|
|
0
|
|
);
|
|
|
|
$this->gtk->show();
|
|
|
|
// Init events
|
|
$this->gtk->connect(
|
|
'activate-link',
|
|
function(
|
|
GtkLabel $label,
|
|
string $href
|
|
) {
|
|
return $this->_onActivateLink(
|
|
$label,
|
|
$href
|
|
);
|
|
}
|
|
);
|
|
|
|
$this->gtk->connect(
|
|
'button-press-event',
|
|
function(
|
|
GtkLabel $label,
|
|
GdkEvent $event
|
|
) {
|
|
return $this->_onButtonPress(
|
|
$label,
|
|
$event
|
|
);
|
|
}
|
|
);
|
|
|
|
$this->gtk->connect(
|
|
'configure-event',
|
|
function(
|
|
GtkWindow $window,
|
|
GdkEvent $event
|
|
) {
|
|
return $this->_onConfigure(
|
|
$label,
|
|
$event
|
|
);
|
|
}
|
|
);
|
|
}
|
|
|
|
protected function _onActivateLink(
|
|
GtkLabel $label,
|
|
string $href
|
|
): bool
|
|
{
|
|
return false;
|
|
}
|
|
|
|
protected function _onButtonPress(
|
|
GtkLabel $label,
|
|
GdkEvent $event
|
|
): bool
|
|
{
|
|
return false;
|
|
}
|
|
|
|
abstract protected function _onConfigure(
|
|
GtkLabel $label,
|
|
GdkEvent $event
|
|
): bool;
|
|
|
|
abstract public function set(
|
|
string $value
|
|
): void;
|
|
}
|