samedi 22 février 2014

Sub voyant bouton

un programme de démonstration d'une "sub"
 pour créer un bouton ou un voyant avec différentes couleurs du voyant
 et de l'étiquette  avec le texte de l'étiquette  et aussi
 un coefficient de zoom pour le voyant ou le bouton






Code Panoramic :

' =============================
 dim varcoul,nobj
 label sp_1
' ..................             +Numéro objet
'                                 !    +parent
'                                 !     !   +top
'                                 !     !    !    + left
'                                 !     !    !    !    + b=bouton v=voyant
'                                 !     !    !    !    !    + texte étiquette
'                                 !     !    !    !    !     !      + couleur voyant
'                                 !     !    !    !    !     !      !       + couleur étiquette
'                                 !     !    !    !    !     !      !        !        + coefficient zoom
'                                 !     !    !    !    !     !      !        !        !     +font_size
'                                 !     !    !    !    !     !      !        !        !     !
' sub voyant_button(ntp,par,ttp,ltp,bv$,txt$,colv$,cole$,cf,fz)
width 0,600:height 0,300: color 0,250,150,50
nobj=10:voyant_button(nobj,0,20,50,"b"," Marche","r","j",2.2,5)
nobj=20:voyant_button(nobj,0,20,150,"v"," Marche","v","v",2.4,5)
nobj=30:voyant_button(nobj,0,20,250,"v","   Arrêt","r","r",2.8,5)
nobj=40:voyant_button(nobj,0,20,350,"v"," Pompe 1","b","b",3,4)
 on_click 15,sp_1
' =============================
 end
' =============================
 sp_1:
 varcoul=1-varcoul
 select varcoul
 case 0
 color 25,39,99,37
 color 35 ,113,41,17
 color 45,100,100,255
 case 1
 color 25,0,255,0
 color 35,255,0,0
 color 45,0,200,255
 end_select
return
' =============================
rem ======SUB===================================
' =============================
sub voyant_button(ntp,par,ttp,ltp,bv$,txt$,colv$,cole$,coef,fz)
 dim_local htop
 panel ntp+1 :color ntp+1,55,55,50:top ntp+1,ttp:left ntp+1,ltp
 width ntp+1,30*coef:height ntp+1,40*coef
 panel ntp+2 :parent ntp+2,ntp+1
 if cole$= "j" then color ntp+2,255,255,0
 if cole$= "r" then color ntp+2,255,0,0
 if cole$= "v" then color ntp+2,0,255,0
 if cole$= "b" then color ntp+2,0,200,255
 width ntp+2,26*coef:height ntp+2,9*coef
 left ntp+2,(width(ntp+1)-width(ntp+2))/2
 alpha ntp+3:parent ntp+3,ntp+2:full_space ntp+3
 panel ntp+4 :parent ntp+4,ntp+1:color ntp+4,206,206,206
 left ntp+4,width(ntp+1)-width(ntp+4)/2
 width ntp+4,26*coef:height ntp+4,26*coef
 left ntp+4,(width(ntp+1)-width(ntp+4))/2
 htop=(height(ntp+1)-(height(ntp+2)+height(ntp+4)))/3
 top ntp+2, htop:top ntp+4, htop+top(ntp+2)+height(ntp+2)
 if bv$="b"
    button ntp+5 :parent ntp+5,ntp+4
 else
    panel ntp+5 :parent ntp+5,ntp+4
    if colv$="r"
       color ntp+5,113,41,17:end_if
    if colv$="v"
       color ntp+5,39,99,37:end_if
    if colv$="b"
       color ntp+5,39,99,255:end_if
 end_if
 width ntp+5,22*coef:height ntp+5,22*coef
 top ntp+5,(height(ntp+4)-height(ntp+5))/2
 left ntp+5,(width(ntp+4)-width(ntp+5))/2
 font_size ntp+3,fz*coef : caption ntp+3,txt$
end_sub
' =============================


Aucun commentaire:

Enregistrer un commentaire