diff options
Diffstat (limited to 'src/view/Zenity.php')
-rw-r--r-- | src/view/Zenity.php | 30 |
1 files changed, 20 insertions, 10 deletions
diff --git a/src/view/Zenity.php b/src/view/Zenity.php index 73c8c3e..858dfa9 100644 --- a/src/view/Zenity.php +++ b/src/view/Zenity.php | |||
@@ -26,6 +26,11 @@ abstract class ZenityCmd | |||
26 | { | 26 | { |
27 | return($this->command); | 27 | return($this->command); |
28 | } | 28 | } |
29 | // pré-remlir un formulaire zenity --forms | ||
30 | //~ public function formSet() | ||
31 | //~ { | ||
32 | //~ return($this->command); | ||
33 | //~ } | ||
29 | } | 34 | } |
30 | 35 | ||
31 | 36 | ||
@@ -37,7 +42,7 @@ class ZenityList extends ZenityCmd | |||
37 | { | 42 | { |
38 | $this->command_type = ' --list'; | 43 | $this->command_type = ' --list'; |
39 | parent::__construct($text, $rows); | 44 | parent::__construct($text, $rows); |
40 | $this->columns = 1; | 45 | //$this->columns = 1; |
41 | $this->command .= ' --hide-header'; // ligne inutile, il y a déjà le --text | 46 | $this->command .= ' --hide-header'; // ligne inutile, il y a déjà le --text |
42 | if($this->rows !== []) | 47 | if($this->rows !== []) |
43 | { | 48 | { |
@@ -48,25 +53,29 @@ class ZenityList extends ZenityCmd | |||
48 | } | 53 | } |
49 | } | 54 | } |
50 | 55 | ||
51 | // cas ou $this->rows est renseignée après | 56 | // cas ou $this->rows n'est pas renseignée dans le constructeur |
52 | // la valeur de $columns n'est plus nécessairement celle apr défaut | 57 | // la valeur de $columns n'est plus nécessairement celle par défaut |
53 | public function setListRows(array $rows, string $table) | 58 | public function setListRows(array $rows, int $columns, float $widen = 1) |
54 | { | 59 | { |
60 | // si 1 colonne, $rows = tableau à une dimension | ||
61 | // si 2 colonnes ou plus, $rows = tableau à deux dimensions | ||
55 | $this->rows = $rows; | 62 | $this->rows = $rows; |
56 | $this->columns = count(StructTablesDB::$structureOfTables[$table]); | 63 | $this->columns = $columns; |
57 | $this->width = 800; | 64 | |
65 | $this->width = $this->columns * 120 * $widen; | ||
66 | $this->height = 91 + count($this->rows) * 25; // inclut les lignes et la barre de défilement horizontale | ||
67 | |||
58 | $this->command .= ' --width=' . $this->width; | 68 | $this->command .= ' --width=' . $this->width; |
59 | $this->height = 80 + count($this->rows) * 25; | ||
60 | $this->command .= ' --height=' . $this->height; | 69 | $this->command .= ' --height=' . $this->height; |
61 | $this->fillZenityList(); | 70 | $this->fillZenityList(); |
62 | } | 71 | } |
63 | 72 | ||
64 | // noter que la syntaxe de zentity --list est déroutante! | 73 | // noter que la syntaxe de zenity --list est déroutante! |
65 | // le remplissage est horizontal et le nombre de colonne dépend du nombre d'occurence de --column="" | 74 | // le remplissage est horizontal et le nombre de colonne dépend du nombre d'occurence de --column="" |
66 | public function fillZenityList() | 75 | public function fillZenityList() |
67 | { | 76 | { |
68 | $output = ''; | 77 | $output = ''; |
69 | if($this->columns === 1) | 78 | if($this->columns === 1) // $this->rows doit être un tableau |
70 | { | 79 | { |
71 | $output .= ' --column=""'; | 80 | $output .= ' --column=""'; |
72 | // remplissage vertical | 81 | // remplissage vertical |
@@ -75,7 +84,8 @@ class ZenityList extends ZenityCmd | |||
75 | $output .= ' "' . $one_row . '"'; // forme: ' "choix 1" "choix 2"' | 84 | $output .= ' "' . $one_row . '"'; // forme: ' "choix 1" "choix 2"' |
76 | } | 85 | } |
77 | } | 86 | } |
78 | elseif($this->columns >= 2) // marche quelque soit le nombre de colonnes | 87 | elseif($this->columns >= 2) // $this->rows doit être un tableau à deux dimensions |
88 | // marche quelque soit le nombre de colonnes | ||
79 | { | 89 | { |
80 | for($i = 0; $i < $this->columns; $i++) | 90 | for($i = 0; $i < $this->columns; $i++) |
81 | { | 91 | { |