Guidance
指路人
g.yi.org
software / rapidq / Examples / Graphics & Animation / QVU.bas

Register 
注册
Search 搜索
首页 
Home Home
Software
Upload

  
     $INCLUDE <rapidq.INC>

' AKX Rapid-Q VU Meter ''''''''''''''''''''''''''''''''''''''''''''
' akx@theakx.tk | www.theakx.tk

     TYPE QVU EXTENDS QCANVAS
      Segments AS INTEGER
      Value AS INTEGER
      Limit AS INTEGER

      Border AS INTEGER

      BorderColorLight AS INTEGER
      BorderColorDark AS INTEGER
      BelowColorOff AS INTEGER
      BelowColorOn AS INTEGER
      AboveColorOff AS INTEGER
      AboveColorOn AS INTEGER
      SpaceColor AS INTEGER


      CONSTRUCTOR
       Segments=50
       Value=25
       Limit=40
       BorderColorLight=cl3DLight
       BorderColorDark=clBtnShadow
       Border=1

       BelowColorOff=RGB(0,96,0)
       BelowColorOn=RGB(0,255,0)

       AboveColorOff=RGB(96,0,0)
       AboveColorOn=RGB(255,0,0)


       SpaceColor=RGB(0,0,0)

      END CONSTRUCTOR

      SUB DrawComponent
       DIM i AS INTEGER
       DIM c AS INTEGER
       DIM ys AS INTEGER
       DIM ye AS INTEGER

       FOR i=0 TO this.Segments
        ys=this.Height-(this.Height/this.Segments*i)
        ye=this.Height-(this.Height/this.Segments*(i+1))


        IF this.Value>=i THEN
         c=this.BelowColorOn
         IF i>=this.Limit THEN c=this.AboveColorOn
         this.FillRect 0,ys+1,this.Width,ye,c
        ELSE
         c=this.BelowColorOff
         IF i>=this.Limit THEN c=this.AboveColorOff
         this.FillRect 0,ys+1,this.Width,ye,c
        END IF
        this.Line 0,ys,this.Width,ys,this.SpaceColor

       NEXT i
       IF this.Border THEN
        this.Line 0,0,this.Width,0,this.BorderColorDark
        this.Line 0,0,0,this.Height,this.BorderColorDark

        this.Line this.Width-1,0,this.Width-1,this.Height,this.BorderColorLight
        this.Line 0,this.Height-1,this.Width-1,this.Height-1,this.BorderColorLight
       END IF

      END SUB


      EVENT OnPaint
       this.DrawComponent
      END EVENT
     END TYPE

'' END OF COMPONENT -- START OF DEMO '''''''''''''''''''''''''''''''''''


     CREATE VUTest AS QFORM
      Width=50
      Height=350
      Center
      CAPTION="VU Test Form"
      CREATE VU1 AS QVU
       Width=16
       Height=300
       Top=10
       Left=5
       Segments=100
       Limit=70
       AboveColorOn=RGB(255,255,0)
       AboveColorOff=RGB(96,96,0)
      END CREATE
      CREATE VU2 AS QVU
       Width=16
       Height=300
       Top=10
       Left=25
       Segments=100
       Limit=80
      END CREATE
      CREATE Btn AS QBUTTON
       Left=45
       Top=10
       Width=30
       Height=25
       CAPTION="<"

      END CREATE
     END CREATE

     SUB ChangeVUs
      VU1.Value=RND*100
      VU2.Value=RND*100
      VUTest.Repaint
     END SUB



     Application.Title="Rapid-Q VU Component by AKX"

     Btn.OnClick=ChangeVUs
     VUTest.SHOWMODAL

     DOEVENTS
掌柜推荐
 
 
 
 
 
 
 
 
 
 
 
 
© Sat 2024-10-12  Guidance Laboratory Inc.
Email:webmaster1g.yi.org Hits:0 Last modified:2009-07-25 17:30:10