May 07, 2024, 04:15:34 AM

News:

Own IWBasic 2.x ? -----> Get your free upgrade to 3.x now.........


Move panel

Started by aurelCB, August 18, 2008, 03:06:27 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

aurelCB

Hi guys...
Here is code wich look like console program.
regards
aurel :)
'MOOVING PANEL
DEF w1:window
const true=1
const false=0
'------------------
DEF px,py,pw,ph:int
DEF pfx,pfy,pfw,pfh:int
DEF px1,py1,pw1,ph1:int
DEF p1down,p1up,startp,ocounter:int
DEF cn,t:int
'values--------------------
px=400:py=50:pw=190:ph=240
px1=5:py1=50:pw1=390:ph1=240
'------------------------------------------------------
WINDOW w1,0,0,600,480,@minbox,0,"Console Panels",main
SetWindowColor w1,rgb(80,100,80)
SETFONT w1,"Lucida Console",9, 400,0
Frontpen w1,rgb(172,240,170)
move w1,20,5
print w1,"Move panel with arrow keys (UP/DOWN)"
move w1,20,25
print w1,"Show progress bar - press key 3"
'-------------------------------------------------------
RECT w1,px,py,pw,ph,rgb(172,240,170)
RECT w1,px1,py1,pw1,ph1,rgb(172,240,170)
'-------------------------------------------------------
CONTROL w1,"B,Start Panel,420,9,115,20,0x50000001,1"
SETCONTROLCOLOR w1,1,rgb(172,240,170),rgb(80,100,80)
SETFONT w1,"Lucida Console",9, 400,0,1

'----------------------------------
run=1
WAITUNTIL run=0
CLOSEWINDOW w1
END
'----------------------------------
SUB main
SELECT @class
case @idclosewindow
run=0
case @idcreate
centerwindow w1
'-----------------------
case @idcontrol
IF (@CONTROLID = 1)
'startp=true
IF startp=false then startpanel()              
ENDIF
'startp=false
setfocus w1
'------------------------------------------------------
Case @idkeydown

'if p1 down then panel(1) UP arrow key
IF (@CODE = 0x26)&(startp=true)
IF p1down=true then movep1up()
p1down=false
ENDIF
'if p1 up then panel(1) DOWN arrow key
IF (@CODE = 0x28)&(startp=true)
IF p1down=false then movep1down()
ENDIF
'open counters
IF (@CODE = ASC("3"))&(startp=true)
OpenCounter()
ENDIF

ENDSELECT
RETURN
'::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
'::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
Sub startpanel
If startp=true then return
For n=54 to 284 step 2
Line w1,404,n,586,n,rgb(107,117,130)
Next n
move w1,410,60:print w1, " Select Option        "
move w1,410,100:print w1," 1. PanelUp-KeyUp     "
move w1,410,140:print w1," 2. PanelDown-KeyDown "
move w1,410,180:print w1," 3. ProgressBar-Key3  "
startp=true
Return
'::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
Sub movep1down

For n= 50 to 200
RECT w1,px,n,pw,ph,rgb(172,240,170)
RECT w1,px,n,pw,ph,rgb(80,100,80)
If (startp=true)& (ocounter=true)
move w1,130,295:print w1," " + str$(n)
Endif
  If n=200  then RECT w1,px,n,pw,ph,rgb(172,240,170),rgb(80,100,80)
Next n
p1down=true
IF p1down=true
For n=204 to 434 step 2
Line w1,404,n,586,n,rgb(107,117,130)
Next n
'panel is down and you can select option
move w1,410,210:print w1," Select Option        "
move w1,410,240:print w1," 1. PanelUp-KeyUp     "
move w1,410,280:print w1," 2. PanelDown-KeyDown "
move w1,410,320:print w1," 3. ProgressBar-Key3  "
If ocounter=true then progress()
ENDIF
Return
':::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
Sub movep1up
For n= 200 to 50 step -1
RECT w1,px,n,pw,ph,rgb(172,240,170)
RECT w1,px,n,pw,ph,rgb(80,100,80)
If (startp=true)&(ocounter=true)
move w1,130,295:print w1," " + str$(n)+" "
Endif
  If n=50  then RECT w1,px,n,pw,ph,rgb(172,240,170),rgb(80,100,80)
Next n
p1up=true
IF p1up=true
For n=54 to 284 step 2
Line w1,404,n,586,n,rgb(107,117,130)
Next n
'panel is down and you can select option
move w1,410,60:print w1, " Select Option        "
move w1,410,100:print w1," 1. PanelUp-KeyUp     "
move w1,410,140:print w1," 2. PanelDown-KeyDown "
move w1,410,180:print w1," 3. ProgressBar-Key3  "
If ocounter=true then progress()
ENDIF
Return
'::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
Sub OpenCounter
move w1,5,295:print w1,"  Ready > "
move w1,130,295:print w1," " + str$(py)
RECT w1,5,315,390,14,rgb(172,240,170),rgb(80,100,80)
ocounter=true
'progress bar
For n=8 to 384 step 8
RECT w1,n,318,8,8,rgb(172,240,170),rgb(80,100,80)
Next n
Return
'::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
Sub progress
'progress point
'cn=cn + 8
For cn = 8 to 384 step 8
For p=0 to 40
RECT w1,cn,318,8,8,rgb(172,240,170),rgb(250,250,250)
Next p
RECT w1,cn,318,8,8,rgb(172,240,170),rgb(80,100,80)
Next cn
Return