| 1 | # ----------------------------------------------------------------------------- | ||||||||||
| 2 | |||||||||||
| 3 | =encoding utf8 | ||||||||||
| 4 | |||||||||||
| 5 | =head1 NAME | ||||||||||
| 6 | |||||||||||
| 7 | Quiq::Html::Widget - Basisklasse für HTML-Widgets | ||||||||||
| 8 | |||||||||||
| 9 | =head1 BASE CLASS | ||||||||||
| 10 | |||||||||||
| 11 | L<Quiq::Hash> | ||||||||||
| 12 | |||||||||||
| 13 | =head1 DESCRIPTION | ||||||||||
| 14 | |||||||||||
| 15 | Die Klasse implementiert Funktionalität, die allen Widget-Klassen | ||||||||||
| 16 | gemeinsam ist. Sie besitzt keinen Konstruktor, setzt also in den | ||||||||||
| 17 | abgeleiteten Widget-Klassen die Existenz gewisser Attribute | ||||||||||
| 18 | voraus. | ||||||||||
| 19 | |||||||||||
| 20 | =head2 Grundsätzliches über Widget-Klassen | ||||||||||
| 21 | |||||||||||
| 22 | Die Klassen generieren HTML ohne visuelle Eigenschaften. Visuelle | ||||||||||
| 23 | Eigenschaften sollten per CSS definiert werden. Die Verbindung zur | ||||||||||
| 24 | Stylesheet-Definition wird über die Objektattribute C<class> und | ||||||||||
| 25 | C<id> hergestellt. Das Attribut C<style> existiert, sollte aber | ||||||||||
| 26 | möglichst nicht benutzt werden, damit der HTML-Quelltext frei von | ||||||||||
| 27 | CSS-Eigenschaften bleibt. | ||||||||||
| 28 | |||||||||||
| 29 | =over 2 | ||||||||||
| 30 | |||||||||||
| 31 | =item * | ||||||||||
| 32 | |||||||||||
| 33 | Jedes Widget hat einen Namen, der mit $w->name() abgefragt | ||||||||||
| 34 | werden kann. | ||||||||||
| 35 | |||||||||||
| 36 | =item * | ||||||||||
| 37 | |||||||||||
| 38 | Jedes Widget hat einen Wert, der mit $w->value() abgefragt und | ||||||||||
| 39 | gesetzt werden kann. Dieser Wert ist entweder ein skalarer Wert | ||||||||||
| 40 | oder ein Array von Werten. | ||||||||||
| 41 | |||||||||||
| 42 | =item * | ||||||||||
| 43 | |||||||||||
| 44 | Jedes Widget ist entweder sichtbar oder unsichtbar, was mit | ||||||||||
| 45 | $w->hidden() geprüft werden kann. | ||||||||||
| 46 | |||||||||||
| 47 | =item * | ||||||||||
| 48 | |||||||||||
| 49 | Jedes Widget ist entweder dekativiert oder aktiviert, was mit | ||||||||||
| 50 | $w->disabled() festgestellt werden kann. | ||||||||||
| 51 | |||||||||||
| 52 | =item * | ||||||||||
| 53 | |||||||||||
| 54 | Jedes Widget kann auf C<undef> reduziert werden, wenn das | ||||||||||
| 55 | Attribut undefIf=>$bool wahr ist. | ||||||||||
| 56 | |||||||||||
| 57 | =back | ||||||||||
| 58 | |||||||||||
| 59 | =cut | ||||||||||
| 60 | |||||||||||
| 61 | # ----------------------------------------------------------------------------- | ||||||||||
| 62 | |||||||||||
| 63 | package Quiq::Html::Widget; | ||||||||||
| 64 | 17 | ▶ | use base qw/Quiq::Hash/; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 65 | |||||||||||
| 66 | 17 | ▶ | use v5.10; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 67 | 17 | ▶ | use strict; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 68 | 17 | ▶ | use warnings; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 69 | |||||||||||
| 70 | 17 | our $VERSION = '1.240'; | |||||||||
| 71 | |||||||||||
| 72 | # ----------------------------------------------------------------------------- | ||||||||||
| 73 | |||||||||||
| 74 | =head1 METHODS | ||||||||||
| 75 | |||||||||||
| 76 | =head2 Objektmethoden | ||||||||||
| 77 | |||||||||||
| 78 | =head3 name() - Name des Widget | ||||||||||
| 79 | |||||||||||
| 80 | =head4 Synopsis | ||||||||||
| 81 | |||||||||||
| 82 | $name = $w->name; | ||||||||||
| 83 | $name = $w->name($name); | ||||||||||
| 84 | |||||||||||
| 85 | =head4 Description | ||||||||||
| 86 | |||||||||||
| 87 | Liefere/Setze den Namen des Widget. | ||||||||||
| 88 | |||||||||||
| 89 | =cut | ||||||||||
| 90 | |||||||||||
| 91 | # ----------------------------------------------------------------------------- | ||||||||||
| 92 | |||||||||||
| 93 | 11 | ▶ | sub name { | ||||||||
|
Subroutine
name: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||
| 94 | 11 | my $self = shift; | |||||||||
| 95 | # @_: $name | ||||||||||
| 96 | |||||||||||
| 97 | 11 | ▶ | if (@_) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 98 | 3 | $self->set(name=>shift); | |||||||||
| 99 | } | ||||||||||
| 100 | |||||||||||
| 101 | 11 | return $self->get('name'); | |||||||||
| 102 | } | ||||||||||
| 103 | |||||||||||
| 104 | # ----------------------------------------------------------------------------- | ||||||||||
| 105 | |||||||||||
| 106 | =head3 value() - Wert des Widget | ||||||||||
| 107 | |||||||||||
| 108 | =head4 Synopsis | ||||||||||
| 109 | |||||||||||
| 110 | $value | $valueA = $w->value; | ||||||||||
| 111 | $value = $w->value($value); | ||||||||||
| 112 | $valueA = $w->value(\@values); | ||||||||||
| 113 | |||||||||||
| 114 | =head4 Description | ||||||||||
| 115 | |||||||||||
| 116 | Liefere und/oder setze den Wert des Widget. | ||||||||||
| 117 | |||||||||||
| 118 | =cut | ||||||||||
| 119 | |||||||||||
| 120 | # ----------------------------------------------------------------------------- | ||||||||||
| 121 | |||||||||||
| 122 | 3 | ▶ | sub value { | ||||||||
|
Subroutine
value: called CC=8 SCAR=28.8
Pod
documented
| |||||||||||
| 123 | 3 | my $self = shift; | |||||||||
| 124 | # @_: $value -or- $valueA | ||||||||||
| 125 | |||||||||||
| 126 | 3 | ▶ | my $multi = $self->exists('values')? 1: 0; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 127 | |||||||||||
| 128 | 3 | ▶ | if (@_) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 129 | 3 | my $arg = shift; | |||||||||
| 130 | 3 | ▶ | if ($multi) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 131 | 0 | ▶ | if (!ref $arg) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 132 | 0 | $arg = [$arg]; | |||||||||
| 133 | } | ||||||||||
| 134 | 0 | $self->{'values'} = $arg; | |||||||||
| 135 | } | ||||||||||
| 136 | else { | ||||||||||
| 137 | 3 | ▶ | if (ref $arg) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 138 | 0 | ▶ | if (@$arg > 1) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 139 | 0 | $self->throw; | |||||||||
| 140 | } | ||||||||||
| 141 | 0 | $arg = $arg->[0]; | |||||||||
| 142 | } | ||||||||||
| 143 | 3 | $self->{'value'} = $arg; | |||||||||
| 144 | } | ||||||||||
| 145 | } | ||||||||||
| 146 | |||||||||||
| 147 | 3 | ▶ | return $multi? $self->{'values'}: $self->{'value'}; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 148 | } | ||||||||||
| 149 | |||||||||||
| 150 | # ----------------------------------------------------------------------------- | ||||||||||
| 151 | |||||||||||
| 152 | =head3 hidden() - Hidden-Eingenschaft des Widget | ||||||||||
| 153 | |||||||||||
| 154 | =head4 Synopsis | ||||||||||
| 155 | |||||||||||
| 156 | $bool = $w->hidden; | ||||||||||
| 157 | |||||||||||
| 158 | =head4 Description | ||||||||||
| 159 | |||||||||||
| 160 | Liefere die Hidden-Eigenschaft des Widget. | ||||||||||
| 161 | |||||||||||
| 162 | =cut | ||||||||||
| 163 | |||||||||||
| 164 | # ----------------------------------------------------------------------------- | ||||||||||
| 165 | |||||||||||
| 166 | 8 | ▶ | sub hidden { | ||||||||
|
Subroutine
hidden: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||
| 167 | 8 | return shift->get('hidden'); | |||||||||
| 168 | } | ||||||||||
| 169 | |||||||||||
| 170 | # ----------------------------------------------------------------------------- | ||||||||||
| 171 | |||||||||||
| 172 | =head3 disabled() - Disabled-Eingenschaft des Widget | ||||||||||
| 173 | |||||||||||
| 174 | =head4 Synopsis | ||||||||||
| 175 | |||||||||||
| 176 | $bool = $w->disabled; | ||||||||||
| 177 | |||||||||||
| 178 | =head4 Description | ||||||||||
| 179 | |||||||||||
| 180 | Liefere die Disabled-Eigenschaft des Widget. | ||||||||||
| 181 | |||||||||||
| 182 | =cut | ||||||||||
| 183 | |||||||||||
| 184 | # ----------------------------------------------------------------------------- | ||||||||||
| 185 | |||||||||||
| 186 | 0 | ▶ | sub disabled { | ||||||||
|
Subroutine
disabled: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||
| 187 | 0 | return shift->get('disabled'); | |||||||||
| 188 | } | ||||||||||
| 189 | |||||||||||
| 190 | # ----------------------------------------------------------------------------- | ||||||||||
| 191 | |||||||||||
| 192 | =head1 VERSION | ||||||||||
| 193 | |||||||||||
| 194 | 1.240 | ||||||||||
| 195 | |||||||||||
| 196 | =head1 AUTHOR | ||||||||||
| 197 | |||||||||||
| 198 | Frank Seitz, L<http://fseitz.de/> | ||||||||||
| 199 | |||||||||||
| 200 | =head1 COPYRIGHT | ||||||||||
| 201 | |||||||||||
| 202 | Copyright (C) 2026 Frank Seitz | ||||||||||
| 203 | |||||||||||
| 204 | =head1 LICENSE | ||||||||||
| 205 | |||||||||||
| 206 | This code is free software; you can redistribute it and/or modify | ||||||||||
| 207 | it under the same terms as Perl itself. | ||||||||||
| 208 | |||||||||||
| 209 | =cut | ||||||||||
| 210 | |||||||||||
| 211 | # ----------------------------------------------------------------------------- | ||||||||||
| 212 | |||||||||||
| 213 | 17 | 1; | |||||||||
| 214 | |||||||||||
| 215 | # eof | ||||||||||