Ce code permet de dessiner des listes dans des @win.
Vous pouvez utilisez les commandes suivantes :
/xlist @ N,> x y w h tf nf sch scv asv
Cela permet de crée une liste
@ = nom de la fenetre
Si vous donné un nombre N, cela supprime la Neme liste pour en refaire une avec les parametre spécifié
Sinon mettez > et le numero de la liste sera alors le total du nombre de liste pour cette fenetre plus 1
x y w h = coordonné + taille de la liste
tf = taille de l'ecriture
nf = nom de la police d'écriture
sch = si vous voulez une barre horizontal
scv = si vous voulez une barre vertical
asv = la liste descendra automatiquement vers le bas
Les 3 derniers parametres sont facultatifs
/xsuppr @ N
Cela permet de supprimer une liste d'une fenetre
@ = nom de la fenetre
N = n° de la liste dans cette fenetre
/xadd @ N rgb Text
Cela vous permet d'ajouter du text dans une liste
@ = nom de la fenetre
N = n° de la liste dans cette fenetre
rgb = valeur rgb de la couleur d'ecriture
Text = le texte a ajouté
/xdel @ N N1
Cela permet de supprimé une ligne
@ = nom de la fenetre
N = n° de la liste dans cette fenetre
N1 = n° de la ligne a supprimé
/xins @ N N1 rgb Text
Cela permet d'inséré une ligne
@ = nom de la fenetre
N = n° de la liste dans cette fenetre
N1 = n° de la ligne ou l'on insere le texte
rgb = valeur rgb de la couleur du texte
Text = texte a inséré
/xrep @ N space N1 text
Cela permet d'ajouter du texte a une ligne deja existante
@ = nom de la fenetre
N = n° de la liste dans cette fenetre
space = si vous voulez un espace entre le texte déja present et le texte que vous rajoutez ( facultatif )
N1 = n° de la ligne a modifié
text = le texte a rajoutez
$xsel(@,N) retourne le n° de la ligne selectioné de la Neme liste dans la fenetre spécifié
$xseltext(@,N) retourne le texte séléctionné de la Neme liste dans la fenetre spécifié
Lorsque vous cliquer ,l'alias xsclickp se declenche , vous pouvez y faire ce que vous voulez
Idem pour le double click avec l'alias xdclickp
Dans ces alias , $1 = nom de la fenetre , $2 = n° de la liste concerné , $3 = $mouse.x et $4 = $mouse.y
Source / Exemple :
alias xsuppr {
;xsuppr @ N
var %@ = $1 ,%N = $2
tokenize 32 $hget($+(xlist,%@,%N),cc)
drawrect -f %@ 0 0 $1-2 $calc($3 + 12) $calc($4 + 12)
hfree $+(xlist,%@,%N)
hdec -m xlist %@
}
alias xlist {
; syntaxe : xlist @ >,N x y w h tf nf sch scv asv
hinc -m xlist $1
if ($2 == $chr(62)) { var %a = $hget(xlist,$1) }
else xsuppr $1 $2
drawrect $1 1 2 $3-6
hadd -m $+(xlist,$1,$iif(%a,$v1,$2)) name $1
hadd -m $+(xlist,$1,$iif(%a,$v1,$2)) CC $3-6
hadd -m $+(xlist,$1,$iif(%a,$v1,$2)) tf $7
hadd -m $+(xlist,$1,$iif(%a,$v1,$2)) nf $8
hadd -m $+(xlist,$1,$iif(%a,$v1,$2)) placeh 1 1
hadd -m $+(xlist,$1,$iif(%a,$v1,$2)) placev 1 1
hadd -m $+(xlist,$1,$iif(%a,$v1,$2)) sch $istok($9-,sch,32)
hadd -m $+(xlist,$1,$iif(%a,$v1,$2)) scv $istok($9-,scv,32)
hadd -m $+(xlist,$1,$iif(%a,$v1,$2)) asv $istok($9-,asv,32)
if ($hget($+(xlist,$1,$iif(%a,$v1,$2)),sch)) {
drawrect $1 1 2 $3 $calc($4 + $6 - 2) $5 12
drawline $1 1 2 $calc($3 + 12) $calc($4 + $6) $calc($3 + 12) $calc($4 + $6 + 12 - 4)
drawline $1 1 2 $calc($3 + $5 - 12) $calc($4 + $6) $calc($3 + $5 - 12) $calc($4 + $6 + 12 - 4)
drawtext $1 1 verdana 14 $calc($3 + 1) $calc($4 + $6 - 5) <
drawtext $1 1 verdana 14 $calc($3 + $5 - 12) $calc($4 + $6 - 5) >
}
if ($hget($+(xlist,$1,$iif(%a,$v1,$2)),scv)) {
drawrect $1 1 2 $calc($3 + $5 - 2) $4 12 $6
drawline $1 1 2 $calc($3 + $5) $calc($4 + 12) $calc($3 + $5 + 12 - 4) $calc($4 + 12)
drawline $1 1 2 $calc($3 + $5) $calc($4 + $6 - 12) $calc($3 + $5 + 12 - 4) $calc($4 + $6 - 12)
drawtext $1 1 verdana 10 $calc($3 + $5) $4 /\
drawtext $1 1 verdana 10 $calc($3 + $5) $calc($4 + $6 - 12 - 1) \/
}
}
menu * {
sclick : $iif($hget(xlist,$menu),xsclick $menu $mouse.x $mouse.y)
dclick : $iif($hget(xlist,$menu),xdclick $menu $mouse.x $mouse.y)
uclick : $iif($hget(xlist,$menu),.timerdc off)
}
alias xdclick {
var %a 1 ,%b = $hget(xlist,$1) ,%c = $1 ,%x = $2 ,%y = $3
while (%a <= %b) {
tokenize 32 $hget($+(xlist,%c,%a),Cc)
if ($inrect(%x,%y,$1,$2,$3,$4)) {
xdclickp %c %a %x %y
}
inc %a
}
}
alias xsclick {
var %a 1 ,%b = $hget(xlist,$1) ,%c = $1 ,%x = $2 ,%y = $3
while (%a <= %b) {
tokenize 32 $hget($+(xlist,%c,%a),Cc)
if ($hget($+(xlist,%c,%a),sch)) {
if ($inrect(%x,%y,$1,$calc($2 + $4),12,12)) { decalh %c %a gauche }
elseif ($inrect(%x,%y,$calc($1 + $3 - 12),$calc($2 + $4),12,12)) { decalh %c %a droite }
}
if ($hget($+(xlist,%c,%a),scv)) {
if ($inrect(%x,%y,$calc($1 + $3),$2,12,12)) { decalv %c %a haut }
elseif ($inrect(%x,%y,$calc($1 + $3),$calc($2 + $4 - 12),12,12)) { decalv %c %a bas }
}
if ($inrect(%x,%y,$1,$2,$3,$4)) {
tokenize 32 $hget($+(xlist,%c,%a),placev)
if ($xsel(click,%c,%a,%y) != 0) {
hadd -m $+(xlist,%c,%a) xsels $calc($ifmatch - $1 + 1)
hadd -m $+(xlist,%c,%a) xsel $ifmatch
xfresh %c %a $calc($hget($+(xlist,%c,%a),xsels) $iif($token($hget($+(xlist,%c,%a),placev),1,32) > 1,+1))
}
else xfresh %c %a
xsclickp %c %a %x %y
}
inc %a
}
}
alias xsel {
var %@ = $iif($1 == click,$2,$1) ,%N = $iif($1 == click,$3,$2)
if ($1 == click) {
var %a 1 ,%b = $4 ,%d = $hget(xlist,$2)
while (%a <= %d) {
tokenize 32 $hget($+(xlist,%@,%N),Cc)
var %c = $calc($2 + 3) ,%j = $calc($2 + $4) ,%mirc ,%t = $token($hget($+(xlist,%@,%N),placev),1,32)
while (%c <= %j) {
inc %mirc
if (%b isnum $+(%c,-,$calc(%c + $hget($+(xlist,%@,%N),tf)))) { return $calc(%mirc + %t - 1) }
inc %c $calc($hget($+(xlist,%@,%N),tf) + 1)
}
inc %a
}
}
else return $hget($+(xlist,%@,%N),xsel)
}
alias xseltext {
tokenize 160 $hget($+(xlist,$1,$2),$xsel($1,$2))
return $3-
}
alias decalv {
var %@ = $1 ,%N = $2
if ($hget($+(xlist,%@,%N),n°) == $hget($+(xlist,%@,%N),mvplace)) return
var %dir = $3
tokenize 32 $hget($+(xlist,%@,%N),placev)
if ($1 < 2 && %dir == haut) return
if ($calc($1 + $2) > $calc($hget($+(xlist,%@,%N),n°) + $1 - 1) && %dir == bas) return
tokenize 32 $hget($+(xlist,%@,%N),placev)
hadd -m $+(xlist,%@,%N) placev $calc($1 $iif(%dir == bas,+,-) 1) $calc($2 $iif(%dir == bas,+,-) 1)
xfresh %@ %N $xsel(%@,%N) %dir
if ($mouse.key & 1) .timerdc 0 0 decalv %@ %N %dir
}
alias decalh {
var %@ = $1 ,%N = $2
var %dir = $3 ,%t1 = $token($hget($+(xlist,%@,%N),mhplace),1,32) ,%t2 = $token($hget($+(xlist,%@,%N),mhplace),2,32)
tokenize 160 $hget($+(xlist,%@,%N),%t1)
var %z = $numtok($3-,160) ,%len = $len($3-)
tokenize 32 $hget($+(xlist,%@,%N),placeh)
if (%t2 == $2 || (!$hget($+(xlist,%@,%N),n°))) return
if ($1 < 2 && %dir == gauche) return
if ($calc($2 + $1) > $int($calc(%t2 + 1 - %z / %t2)) && %dir == droite) return
hadd -m $+(xlist,%@,%N) placeh $calc($1 $iif(%dir == droite,+,-) 1) $2
xfresh %@ %N $xsel(%@,%N)
if ($mouse.key & 1) .timerdc 0 0 decalh %@ %N %dir
}
;xadd @ N rgb Text
alias xadd {
var %@ = $1 ,%N = $2
if ($hget($+(xlist,%@,%N),stopv)) return
hinc -m $+(xlist,%@,%N) n°
hadd -m $+(xlist,%@,%N) $hget($+(xlist,%@,%N),n°) $replace($3-,$chr(32),$chr(160))
var %a = $len($4-) ,%n° = $hget($+(xlist,%@,%N),n°) ,%aa = $len($4-)
while (1 <= %a) {
tokenize 160 $hget($+(xlist,%@,%N),%n°)
var %mid = $mid($2-,1,%a) ,%height = $height(%mid,$hget($+(xlist,%@,%N),nf),$hget($+(xlist,%@,%N),tf))
var %width = $width(%mid,$hget($+(xlist,%@,%N),nf),$hget($+(xlist,%@,%N),tf))
tokenize 32 $hget($+(xlist,%@,%N),CC)
if (%width < $calc($3 - 1)) {
if ($calc((%height - (%height - $hget($+(xlist,%@,%N),tf))) * $hget($+(xlist,%@,%N),n°) + $hget($+(xlist,%@,%N),n°)) < $4) {
hadd -m $+(xlist,%@,%N) mvplace $hget($+(xlist,%@,%N),n°)
hadd -m $+(xlist,%@,%N) placev $token($hget($+(xlist,%@,%N),placev),1,32) $hget($+(xlist,%@,%N),n°)
if ($calc((%height - (%height - $hget($+(xlist,%@,%N),tf))) * ($hget($+(xlist,%@,%N),n°) + 1) + ($hget($+(xlist,%@,%N),n°) + 1)) > $4 && (!$hget($+(xlist,%@,%N),scv))) {
hadd -m $+(xlist,%@,%N) stopv $true
}
}
else {
if ($hget($+(xlist,%@,%N),asv)) {
hadd -m $+(xlist,%@,%N) placev $calc($hget($+(xlist,%@,%N),n°) - $hget($+(xlist,%@,%N),mvplace) + 1) $hget($+(xlist,%@,%N),n°)
}
}
hadd -m $+(xlist,%@,%N) $hget($+(xlist,%@,%N),n°) $replace(%a $hget($+(xlist,%@,%N),$hget($+(xlist,%@,%N),n°)),$chr(32),$chr(160))
hadd -m $+(xlist,%@,%N) placeh 1 $token($hget($+(xlist,%@,%N),placeh),2,32)
if (%aa > $token($hget($+(xlist,%@,%N),mhplace),2,32) || !$hget($+(xlist,%@,%N),mhplace)) {
hadd -m $+(xlist,%@,%N) placeh 1 %a
hadd -m $+(xlist,%@,%N) mhplace $hget($+(xlist,%@,%N),n°) %aa
}
xfresh %@ %N
break
}
else dec %a
}
}
alias xfresh {
var %@ = $1 ,%N = $2
if (!$hget($+(xlist,%@,%N),1)) return
if ($3) var %fresh = $3-
tokenize 32 $hget($+(xlist,%@,%N),Cc)
drawrect -nf $hget($+(xlist,%@,%N),name) 0 0 $calc($1 + 2) $calc($2 + 2) $calc($3 - 4) $calc($4 - 4)
var %a = $token($hget($+(xlist,%@,%N),placev),1,32) ,%b = $token($hget($+(xlist,%@,%N),placev),2,32) ,%mirc
while (%a <= %b) {
tokenize 160 $hget($+(xlist,%@,%N),%a)
var %len = $len($3-)
inc %mirc
var %text = $3- ,%mid = $mid(%text,$token($hget($+(xlist,%@,%N),placeh),1,32),$1)
var %height = $height(%mid,$hget($+(xlist,%@,%N),nf),$hget($+(xlist,%@,%N),tf)) ,%width = $width(%mid,$hget($+(xlist,%@,%N),nf),$hget($+(xlist,%@,%N),tf))
var %w = $token($hget($+(xlist,%@,%N),CC),3,32) ,%x = $token($hget($+(xlist,%@,%N),CC),1,32)
var %y = $token($hget($+(xlist,%@,%N),CC),2,32) ,%h = $token($hget($+(xlist,%@,%N),CC),4,32)
tokenize 32 $hget($+(xlist,%@,%N),Cc)
if (%fresh) { var %token = $token($hget($+(xlist,%@,%N),placev),1,32) ,%1 = $token(%fresh,1,32) ,%2 = $iif($token(%fresh,2,32),$ifmatch,$null) }
if (!%2 && %1) { var %g = $calc(%1 + %token - 1 - $iif(%token > 1,%token)) }
elseif (%1 && %2) { var %g = $calc(%1 - %token + 1) }
drawtext $+(-nr,$iif(%g == %mirc,b)) $hget($+(xlist,%@,%N),name) $iif(%g == %mirc,16777215,$token($hget($+(xlist,%@,%N),%a),2,160)) $iif(%g == %mirc,16256048) $hget($+(xlist,%@,%N),nf) $hget($+(xlist,%@,%N),tf) $calc(%x + 1) $calc($iif(%mirc == 1,0,$calc($v1 - 1)) + %y + (%mirc - 1) * (%height - (%height - $hget($+(xlist,%@,%N),tf)))) %mid
inc %a
}
drawdot $hget($+(xlist,%@,%N),name)
tokenize 32 $hget($+(xlist,%@,%N),Cc)
drawrect $hget($+(xlist,%@,%N),name) 1 2 $1-
}
;xdel @ N N1
alias xdel {
var %@ = $1 ,%N = $2
if (!$hget($+(xlist,%@,%N),$3)) return
var %1 = $3
tokenize 32 $hget($+(xlist,%@,%N),placev)
hdel $+(xlist,%@,%N) %1
var %b = $hget($+(xlist,%@,%N),n°)
while (%1 < %b) {
hadd -m $+(xlist,%@,%N) %1 $hget($+(xlist,%@,%N),$calc(%1 + 1))
inc %1
}
hdec -m $+(xlist,%@,%N) n°
tokenize 32 $hget($+(xlist,%@,%N),placev)
if ($hget($+(xlist,%@,%N),mvplace) > $hget($+(xlist,%@,%N),n°)) { hdel $+(xlist,%@,%N) stopv }
if ($hget($+(xlist,%@,%N),n°) < $hget($+(xlist,%@,%N),mvplace)) hdec -m $+(xlist,%@,%N) mvplace
if ($hget($+(xlist,%@,%N),n°) == $hget($+(xlist,%@,%N),mvplace)) hadd -m $+(xlist,%@,%N) placev 1 $hget($+(xlist,%@,%N),n°)
else hadd -m $+(xlist,%@,%N) placev $iif($hget($+(xlist,%@,%N),n°) == $calc($2 - 1),$calc($1 - 1),$1) $calc($2 $iif($hget($+(xlist,%@,%N),n°) == $calc($2 - 1),-1))
tokenize 32 $hget($+(xlist,%@,%N),Cc)
drawrect -f $hget($+(xlist,%@,%N),name) 0 0 $calc($1 + 2) $calc($2 + 2) $calc($3 - 4) $calc($4 - 4)
xfresh %@ %N
}
;xins @ N N1 rgb Text
alias xins {
var %@ = $1 ,%N = $2
if ($hget($+(xlist,%@,%N),stopv) || (!$hget($+(xlist,%@,%N),$3))) return
var %M = $3 ,%b = $hget($+(xlist,%@,%N),n°) ,%a = $3 ,%c = $replace($4-,$chr(32),$chr(160))
while (%b >= %M) {
hadd -m $+(xlist,%@,%N) $calc(%b + 1) $hget($+(xlist,%@,%N),%b)
dec %b
}
hinc $+(xlist,%@,%N) n°
var %len = $len($5-)
while (1 <= %len) {
var %mid = $mid($5-,1,%len)
var %height = $height(%mid,$hget($+(xlist,%@,%N),nf),$hget($+(xlist,%@,%N),tf))
var %width = $width(%mid,$hget($+(xlist,%@,%N),nf),$hget($+(xlist,%@,%N),tf))
var %w = $token($hget($+(xlist,%@,%N),CC),3,32) ,%x = $token($hget($+(xlist,%@,%N),CC),1,32)
var %y = $token($hget($+(xlist,%@,%N),CC),2,32) ,%h = $token($hget($+(xlist,%@,%N),CC),4,32)
if (%width < $calc(%w - 1)) {
if ($calc((%height - (%height - $hget($+(xlist,%@,%N),tf))) * $hget($+(xlist,%@,%N),n°) + $hget($+(xlist,%@,%N),n°)) < %h) { hadd -m $+(xlist,%@,%N) mvplace $hget($+(xlist,%@,%N),n°) | hadd -m $+(xlist,%@,%N) placev $token($hget($+(xlist,%@,%N),placev),1,32) $hget($+(xlist,%@,%N),n°) }
else {
hadd -m $+(xlist,%@,%N) stopv $true
if ($hget($+(xlist,%@,%N),asv)) {
hadd -m $+(xlist,%@,%N) placev $calc($hget($+(xlist,%@,%N),n°) - $hget($+(xlist,%@,%N),mvplace) + 1) $hget($+(xlist,%@,%N),n°)
}
}
hadd -m $+(xlist,%@,%N) %a $replace(%len %c,$chr(32),$chr(160))
hadd -m $+(xlist,%@,%N) placeh 1 $token($hget($+(xlist,%@,%N),placeh),2,32)
if ($len($5-) > $token($hget($+(xlist,%@,%N),mhplace),2,32) || !$hget($+(xlist,%@,%N),mhplace)) {
hadd -m $+(xlist,%@,%N) placeh 1 %len
hadd -m $+(xlist,%@,%N) mhplace $hget($+(xlist,%@,%N),n°) $len($5-)
}
break
}
}
xfresh %@ %N
}
;xrep @ N space N1 text
alias xrep {
var %@ = $1 ,%N = $2 ,%sp = $iif($3 == space,$4-,$3-) ,%sp1 = $iif($3 == space,$true,$false) ,%sp2 = $iif($3 == space,$4,$3)
tokenize 32 %sp
if (!$hget($+(xlist,%@,%N),$1)) return
var %a = $1 ,%b = $2-
tokenize 160 $hget($+(xlist,%@,%N),%a)
echo -a $1-
hadd -m $+(xlist,%@,%N) %a $replace($+($1-,$iif(%sp1,$chr(160)),%b),$chr(32),$chr(160))
tokenize 160 $hget($+(xlist,%@,%N),%a)
echo -a $1-
var %len = $len($3-) ,%wtf = $2-
while (1 <= %len) {
var %mid = $mid($3-,1,%len)
var %height = $height(%mid,$hget($+(xlist,%@,%N),nf),$hget($+(xlist,%@,%N),tf))
var %width = $width(%mid,$hget($+(xlist,%@,%N),nf),$hget($+(xlist,%@,%N),tf))
var %w = $token($hget($+(xlist,%@,%N),CC),3,32) ,%x = $token($hget($+(xlist,%@,%N),CC),1,32)
var %y = $token($hget($+(xlist,%@,%N),CC),2,32) ,%h = $token($hget($+(xlist,%@,%N),CC),4,32)
if (%width < $calc(%w - 1)) {
if ($calc((%height - (%height - $hget($+(xlist,%@,%N),tf))) * $hget($+(xlist,%@,%N),n°) + $hget($+(xlist,%@,%N),n°)) < %h) { hadd -m $+(xlist,%@,%N) mvplace $hget($+(xlist,%@,%N),n°) | hadd -m $+(xlist,%@,%N) placev $token($hget($+(xlist,%@,%N),placev),1,32) $hget($+(xlist,%@,%N),n°) }
hadd -m $+(xlist,%@,%N) %a $replace(%len %wtf,$chr(32),$chr(160))
hadd -m $+(xlist,%@,%N) placeh 1 $token($hget($+(xlist,%@,%N),placeh),2,32)
if ($len($3-) > $token($hget($+(xlist,%@,%N),mhplace),2,32) || !$hget($+(xlist,%@,%N),mhplace)) {
hadd -m $+(xlist,%@,%N) placeh 1 %len
hadd -m $+(xlist,%@,%N) mhplace $hget($+(xlist,%@,%N),n°) $len($3-)
}
break
}
dec %len
}
xfresh %@ %N
}
;alias perso
alias xsclickp {
}
alias xdclickp {
}
Conclusion :
Il y aurait peux etre un bug quand on click sur la derniere ligne visible mais je ne l'ai pas chez moi.
S'il manque des choses, hesiter pas :)
Vous n'êtes pas encore membre ?
inscrivez-vous, c'est gratuit et ça prend moins d'une minute !
Les membres obtiennent plus de réponses que les utilisateurs anonymes.
Le fait d'être membre vous permet d'avoir un suivi détaillé de vos demandes et codes sources.
Le fait d'être membre vous permet d'avoir des options supplémentaires.