From dedbe2f5cee33431c1299c7f0dbef4e247dc2447 Mon Sep 17 00:00:00 2001 From: polo Date: Mon, 19 Dec 2022 02:51:03 +0100 Subject: nouveau client main.php en cours --- src/view/Zenity.php | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) (limited to 'src/view/Zenity.php') diff --git a/src/view/Zenity.php b/src/view/Zenity.php index a04b794..04c9221 100644 --- a/src/view/Zenity.php +++ b/src/view/Zenity.php @@ -13,7 +13,7 @@ abstract class ZenityCmd protected $width = 300; protected $height = 200; // recalculée en fonction du contenu, vaut au minimum 150 - protected function __construct($text, array $rows = []) // $rows est optionnel + protected function __construct(string $text, array $rows = []) // $rows est optionnel { $this->text = $text; $this->rows= $rows; @@ -31,7 +31,7 @@ abstract class ZenityCmd class ZenityList extends ZenityCmd { - public function __construct($text, array $rows) + public function __construct(string $text, array $rows) { $this->command_type = ' --list'; parent::__construct($text, $rows); @@ -39,15 +39,17 @@ class ZenityList extends ZenityCmd $this->command .= ' --width=' . $this->width; $this->command .= ' --height=' . $this->height; $this->command .= ' --hide-header'; // ligne inutile, il y a déjà le --text - self::one_column_zenity_list($this->rows); + self::oneColumnZenityList($this->rows); } - public function set_entries($rows_set) // variable renseignée après la construction + // cas ou $this->rows est renseignée après + public function setEntries(array $rows_set) { $this->rows = $rows_set; } - private function one_column_zenity_list($rows) + // cas où on veut une seule colonne + private function oneColumnZenityList(array $rows) { $output = ' --column=""'; foreach($rows as $entry) @@ -56,6 +58,8 @@ class ZenityList extends ZenityCmd } $this->command .= $output; } + + // cas où on veut plusieurs colonnes, le remplissage est horizontal, oui c'est tordu! } class ZenityQuestion extends ZenityCmd @@ -70,6 +74,8 @@ class ZenityQuestion extends ZenityCmd } } +// note: le formulaire renvoie une chaine avecdes pipes | entre les zones de texte (qui peuvent être vides) +// si on clique sur 'Annuler', renvoie une chaine vide class ZenityForms extends ZenityCmd { public function __construct($text, array $rows) @@ -77,10 +83,10 @@ class ZenityForms extends ZenityCmd $this->command_type = ' --forms'; parent::__construct($text, $rows); //$this->height = 80 + count($this->rows) * 25; // à tester, mais devrait produire le rendu attendu - self::entries_zenity_forms($this->rows); + self::entriesZenityForms($this->rows); } - private function entries_zenity_forms($entries) + private function entriesZenityForms($entries) { $output = ''; foreach($entries as $one_entry) -- cgit v1.2.3