-
Notifications
You must be signed in to change notification settings - Fork 0
/
Window.php
76 lines (58 loc) · 2.05 KB
/
Window.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
<?php
declare(strict_types=1);
namespace Ardillo\Examples\Dns\Prefs;
use Ardillo\Examples\Dns\App;
use Ardillo\{
Align,
Entry,
Checkbox,
Grid,
Label,
Window as ArdilloWindow,
};
class Window extends ArdilloWindow
{
/** @var array<int, Checkbox> */
public array $typeBoxes;
public Entry $nsField;
public Grid $grid;
public Label $nsLabel;
public Label $qLabel;
public OkButton $okButton;
public CancelButton $cancelButton;
public function onClosing(): int
{
return 1;
}
public function setup(): void
{
assert($this->app instanceof App);
$this->grid = new Grid;
$this->grid->setPadded(true);
$this->nsLabel = new Label('Nameserver');
$this->grid->append($this->nsLabel, 0, 0, 2, 1, true, Align::Fill, false, Align::Center);
$this->nsField = new Entry();
$this->nsField->setText($this->app->nameserver);
$this->grid->append($this->nsField, 1, 0, 2, 1, false, Align::End, false, Align::Fill);
$this->qLabel = new Label('Lookup queries');
$this->grid->append($this->qLabel, 0, 3, 2, 1, false, Align::Fill, false, Align::Fill);
$x = $y = 0;
foreach ($this->app::QUERY_TYPES as $k => $v) {
assert(is_integer($k));
$this->typeBoxes[$k] = new Checkbox($v);
$this->typeBoxes[$k]->setChecked($this->app->querySelection[$k]);
$this->grid->append($this->typeBoxes[$k], $x + 0, $y + 4, 1, 1, false, Align::Fill, false, Align::Fill);
if (++$x == 3) {
$y++;
$x = 0;
}
}
$this->okButton = new OkButton('OK');
$this->grid->append($this->okButton, 0, $y + 4, 1, 1, false, Align::Fill, false, Align::Start);
$this->cancelButton = new CancelButton('Cancel');
$this->grid->append($this->cancelButton, 2, $y + 4, 1, 1, false, Align::Fill, false, Align::End);
$this->setResizeable(false);
$this->setMargined(true);
$this->setChild($this->grid);
}
}