Wednesday, November 18, 2015

Date,time digital clock

Date, Time
Digital Clock

========
Main
========

AddLabel("lbl1",0,0,100%x,15%y,"")
SetColor("lbl1",20,ccyan)
SetTextSize("lbl1",24)
Setgravity("lbl1",17)

dateformat("dd/MM/yyyy")
timeformat("hh:mm:ss a")

dim days(8)
days(1)="Sunday"
days(2)="Monday"
days(3)="Tuesday"
days(4)="Wednesday"
days(5)="Thursday"
days(6)="Friday"
days(7)="Saturday"

SetTimerInterval(1000)
SetTimerenabled(true)

=======
Events
=======
Sub Activity_Pause(UserClosed)
End Sub

Sub Activity_Resume
SetTimerenabled(true)
End Sub

Sub Timer_Tick
SetText("lbl1",date(now) & "  " &  days(datedayofweek(now))  & crlf & time(now))
End Sub

=======

Image Button

ImageButton

ဒီတခါေတာ့ label + activity_touch + btn image 2 ပံုသံုးၿပီး animated imageButton ေလး ေရးပါမယ္။

အရင္ဆံုး ေအာက္က link မွာ button အစိမ္း နဲ႔ အ၀ါ ကို ေဒါင္းၿပီး btngreen.png, btnyellow.png ဆိုၿပီး rename လုပ္ထားပါ။ ၿပီးရင္ BMP မွာ add ထားပါ။

http://www.iconarchive.com/show/soft-scraps-icons-by-hopstarter/Button-Blank-Green-icon.html

Main
====

AddPanel("pnl1",0,0,100%x,100%y,"")

AddLabel("lblbtn1",10%x,10%y,80%x,20%y,"pnl1")
Bitmapinit(DirAssets,"btngreen.png")
setBackgroundimage("lblbtn1")
SetText("lblbtn1","Click Me")
SetGravity("lblbtn1",17 )
x11=10%x
x12=90%x
y11=10%y
y12=30%y

=========
Events
=========
Sub Activity_Pause(UserClosed)
End Sub

Sub Activity_Resume
End Sub

sub activity_touch(action,tx,ty)
   
    select action

    case 0

        if (tx>x11) then
        if (tx<x12) then
        if (ty>y11) then
        if (ty<y12) then
       
                    Bitmapinit(DirAssets,"btnyellow.png")
setBackgroundimage("lblbtn1")
            invalidate("lblbtn1")

        end if
        end if
        end if
        end if

    case 1

Bitmapinit(DirAssets,"btngreen.png")
setBackgroundimage("lblbtn1")
        invalidate("lblbtn1")
        MsgBox("You clicked the Button","")
    end select
end sub
==========

Sunday, November 15, 2015

Custom Menu

Custom Menu

Menu key ကိုႏွိပ္လိုက္ရင္ Menu listView ေလး ေအာက္ေျခမွာ ေပၚလာေအာင္ ေရးပါမယ္။ Multiple pages နဲ႔ တြဲျပထားပါတယ္။ ဒီနည္းကို အသံုးျပဳရင္ page တခုတိုင္း အတြက္ ျခားနားတဲ့ menu ေတြကို ဖန္တီးႏိုင္ပါမယ္။

Views
=====
AddPanel("pnlMain",0,0,100%x,100%y,"")

AddPanel("pnl1",0,0,100%x,100%y,"pnlMain")
SetColor( "pnl1",0,cRed)

AddPanel("pnl2",0,0,100%x,100%y,"pnlMain")
SetColor( "pnl2",0,cYellow)
SetVisible( "pnl2",false)

AddPanel("pnl3",0,0,100%x,100%y,"pnlMain")
SetColor( "pnl3",0,cGreen)
SetVisible( "pnl3",false)

AddPanel("pnl4",0,0,100%x,100%y,"pnlMain")
SetColor( "pnl4",0,cBlue)
SetVisible( "pnl4",false)

AddPanel("pnl5",0,0,100%x,100%y,"pnlMain")
SetColor( "pnl5",0,cCyan)
SetVisible( "pnl5",false)

# ###################

AddPanel("pnlMenu",0,60%y,100%x,40%y,"pnlMain")
SetColor( "pnlMenu",0,cyellow)
AddListView("lvMenu", 0,0,100%x,40%y,"pnlMenu")

Add("lvMenu","Page 1" )
Add("lvMenu","Page 2" )
Add("lvMenu","Page 3" )
Add("lvMenu","Page 4" )
Add("lvMenu","Page 5" )
SetVisible( "pnlMenu",false)

currentpage="pnl1"
MenuVisible=false

Events
======
Sub Activity_Pause(UserClosed)
End Sub

Sub Activity_Resume
End Sub

Sub Activity_KeyPress(key)
if key=82  then
SetVisible("pnlMenu",true )
MenuVisible=true
end if

if key =4 then
if MenuVisible=true then
SetVisible("pnlMenu",false )
MenuVisible=false
else
activityfinish
end if
end if

End Sub

Sub ListView_ItemClick(who, pos, value)
select value
case "Page 1"

SetVisible( currentpage,false)
currentpage="pnl1"
SetVisible( currentpage,true)
SetVisible( "pnlMenu",false)

case "Page 2"

SetVisible( currentpage,false)
currentpage="pnl2"
SetVisible( currentpage,true)
SetVisible( "pnlMenu",false)

case "Page 3"

SetVisible( currentpage,false)
currentpage="pnl3"
SetVisible( currentpage,true)
SetVisible( "pnlMenu",false)

case "Page 4"

SetVisible( currentpage,false)
currentpage="pnl4"
SetVisible( currentpage,true)
SetVisible( "pnlMenu",false)

case "Page 5"

SetVisible( currentpage,false)
currentpage="pnl5"
SetVisible( currentpage,true)
SetVisible( "pnlMenu",false)

end select
MenuVisible=false
End Sub

========

Saturday, November 14, 2015

Multiple pages ကို style တမ်ိဳးနဲ႔ ေရးၾကမယ္

Multiple pages ကို style တမ်ိဳးနဲ႔ ေရးၾကမယ္

screen ရဲ့ေအာက္ေျခမွာ button ၅ခု ရွိမယ္။ button တခုကို ႏွိပ္လိုက္ရင္ သက္ဆိုင္ရာ page ကို ေျပာင္းျပမယ္။

Main
====
AddPanel("pnlMain",0,0,100%x,100%y,"")

AddPanel("pnl1",0,0,100%x,90%y,"pnlMain")
SetColor( "pnl1",0,cRed)

AddPanel("pnl2",0,0,100%x,90%y,"pnlMain")
SetColor( "pnl2",0,cYellow)
SetVisible( "pnl2",false)

AddPanel("pnl3",0,0,100%x,90%y,"pnlMain")
SetColor( "pnl3",0,cGreen)
SetVisible( "pnl3",false)

AddPanel("pnl4",0,0,100%x,90%y,"pnlMain")
SetColor( "pnl4",0,cBlue)
SetVisible( "pnl4",false)

AddPanel("pnl5",0,0,100%x,90%y,"pnlMain")
SetColor( "pnl5",0,cCyan)
SetVisible( "pnl5",false)

# ###################

AddPanel("pnlsel",0,90%y,20%x,10%y,"pnlMain")
SetColor( "pnlsel",0,cyellow)

AddButton("btn1",0,90%y,20%x,10%y,"pnlMain")
SetText("btn1","1" )

AddButton("btn2",20%x,90%y,20%x,10%y,"pnlMain")
SetText("btn2","2" )

AddButton("btn3",40%x,90%y,20%x,10%y,"pnlMain")
SetText("btn3","3" )

AddButton("btn4",60%x,90%y,20%x,10%y,"pnlMain")
SetText("btn4","4" )

AddButton("btn5",80%x,90%y,20%x,10%y,"pnlMain")
SetText("btn5","5" )

currentpage="pnl1"

Events
======
Sub Activity_Pause(UserClosed)
End Sub

Sub Activity_Resume
End Sub

Sub Button_Click(Who)
select who

case "btn1"

SetVisible( currentpage,false)
currentpage="pnl1"
SetVisible( currentpage,true)
Setleft("pnlsel",getleft("btn1"))

case "btn2"

SetVisible( currentpage,false)
currentpage="pnl2"
SetVisible( currentpage,true)
Setleft("pnlsel",getleft("btn2"))

case "btn3"

SetVisible( currentpage,false)
currentpage="pnl3"
SetVisible( currentpage,true)
Setleft("pnlsel",getleft("btn3"))

case "btn4"

SetVisible( currentpage,false)
currentpage="pnl4"
SetVisible( currentpage,true)
Setleft("pnlsel",getleft("btn4"))

case "btn5"

SetVisible( currentpage,false)
currentpage="pnl5"
SetVisible( currentpage,true)
Setleft("pnlsel",getleft("btn5"))

end select
End Sub
========

Friday, November 13, 2015

Animated Color LabelButton

Animated Color LabelButton

အရင္တေခါက္က User interaction နဲ႔ button click လုပ္တဲ့အခါ color/image ထည့္ထားရင္ animation ရေအာင္  timer သံုးၿပီး ေရးျပခဲ့ပါတယ္။ အခုတခါေတာ့ ဒီထက္ပိုေကာင္းတဲ့ Label  + activity_touch event ကိုသံုးၿပီး ေရးျပပါမယ္။

activity_touch(action,tx,ty) event မွာ action=0 က down, 1=up, နဲ႔ 2=drag ျဖစ္ပါတယ္။ tx နဲ႔ ty ကေတာ့ touch point ရဲ့ x နဲ႔ y တန္ဖိုးပါ။ tx နဲ႔ ty တန္ဖိုးေတြဟာ Label ရဲ့ အတိုင္းအတာ အတြင္းမွာ ရွိရင္ color ေျပာင္းျပၿပီး click တဲ့ ပံုစံမ်ိဳ း ျဖစ္ေအာင္ ေရးပါမယ္။

Views Panel
==========

AddPanel("pnl1",0,0,100%x,100%y,"")

AddLabel("lblbtn1",10%x,10%y,80%x,20%y,"pnl1")
SetColor( "lblbtn1",60,cyellow)
SetText("lblbtn1","Menu 1")
SetGravity("lblbtn1",17 )
x11=10%x
x12=90%x
y11=10%y
y12=30%y

AddLabel ("lblbtn2",10%x,40%y,80%x,20%y,"pnl1")
SetColor( "lblbtn2",60,cyellow)
SetText("lblbtn2","Menu 2")
SetGravity("lblbtn2",17 )
x21=10%x
x22=90%x
y21=40%y
y22=60%y

currentlblbtn=""

===========
Events Panel
===========

Sub Activity_Pause(UserClosed)
End Sub

Sub Activity_Resume
End Sub

sub activity_touch(action,tx,ty)
   
    select action

    case 0

        if (tx>x11) then
        if (tx<x12) then
        if (ty>y11) then
        if (ty<y12) then
       
            SetColor("lblbtn1",60,cgreen)
            invalidate("lblbtn1")
            currentlblbtn="lblbtn1"

        end if
        end if
        end if
        end if

        if (tx>x21) then
        if (tx<x22) then
        if (ty>y21) then
        if (ty<y22) then
       
            SetColor("lblbtn2",60,cgreen)
            invalidate("lblbtn2")
            currentlblbtn="lblbtn2"

        end if
        end if
        end if
        end if

    case 1

            SetColor(currentlblbtn,60,cyellow)
        invalidate(currentlblbtn)

        if currentlblbtn="lblbtn1" then
        MsgBox("You choose Menu1","")

        else if currentlblbtn ="lblbtn2" then
        MsgBox("You choose Menu2","")

    end if
    end select
end sub
================

Monday, November 9, 2015

ScrollView တြင္ image ၁၀ ပံု ထည့္ျပျခင္း

ScrollView တြင္ image ၁၀ ပံု  ထည့္ျပျခင္း

အခု project မွာေတာ့ scrollView တခုထဲမွာ image ၁၀ ပံု ထည့္ျပဖို႔ ေရးပါမယ္။ Image ေတြကို အလ်ား၊ အနံ အခ်ိဳ း 4:3 နဲ႔ ညီတူ ေဖာ္ျပမွာ ျဖစ္လို႔၊ ကန္႔လန္႔ပံု ၁၀ ပံုကို 4:3 အခ်ိဳ းနဲ႔ ျပင္ဆင္ထားပါ။ ၿပီးရင္ BMP မွာ AddFiles နဲ႔ ထည့္ပါ။ (img1.png, img2.png, ..., img10.png)

Views Panel
==========

AddScrollView("scr",0,0,100%x,100%y,"")
GetPanel("scr","pnlScr")

AddPanel("pnl1",0,0,100%x,75%x,"pnlScr")
BitmapInit(DirAssets,"img1.png")
SetBackgroundImage("pnl1")

AddPanel("pnl2",0,75%x,100%x,75%x,"pnlScr")
BitmapInit(DirAssets,"img2.png")
SetBackgroundImage("pnl2")

AddPanel("pnl3",0,150%x,100%x,75%x,"pnlScr")
BitmapInit(DirAssets,"img3.png")
SetBackgroundImage("pnl3")

AddPanel("pnl4",0,225%x,100%x,75%x,"pnlScr")
BitmapInit(DirAssets,"img4.png")
SetBackgroundImage("pnl4")

AddPanel("pnl5",0,300%x,100%x,75%x,"pnlScr")
BitmapInit(DirAssets,"img5.png")
SetBackgroundImage("pnl5")

AddPanel("pnl6",0,375%x,100%x,75%x,"pnlScr")
BitmapInit(DirAssets,"img6.png")
SetBackgroundImage("pnl6")

AddPanel("pnl7",0,450%x,100%x,75%x,"pnlScr")
BitmapInit(DirAssets,"img7.png")
SetBackgroundImage("pnl7")

AddPanel("pnl8",0,525%x,100%x,75%x,"pnlScr")
BitmapInit(DirAssets,"img8.png")
SetBackgroundImage("pnl8")

AddPanel("pnl9",0,600%x,100%x,75%x,"pnlScr")
BitmapInit(DirAssets,"img9.png")
SetBackgroundImage("pnl9")

AddPanel("pnl10",0,675%x,100%x,75%x,"pnlScr")
BitmapInit(DirAssets,"img10.png")
SetBackgroundImage("pnl10")

SetHeight("pnlScr",750%x)

================

No codes for Events Panel

================

ပံု တခုနဲ႔ တခုၾကားမွာ 5%x gap ထည့္ၾကည့္ပါ။

Sunday, November 8, 2015

Sliding Drawer Menu

Sliding Drawer Menu

အရင္ တေခါက္က menu button ႏွိပ္လိုက္ရင္ menu panel ေလး တခု ထြက္လာေအာင္ timer သံုးၿပီး ေရးျပခဲ့ပါတယ္။ အခုတခါေတာ့ menu panel ကို လက္နဲ႔ drag ဆြဲထုတ္ရတဲ့ Sliding Drawer Menu တခု ေရးျပပါမယ္။

# Views Panel
# #########

in=-50%x+50
Visible=50
pwidth=50%x

# ###########

AddPanel("pnlMain",0,0,100%x,100%y,"")

AddPanel("pnlPage1",50,0,100%x-50,100%y,"pnlMain")
SetColor("pnlPage1",0,cgreen)

AddPanel("pnlPage2",50,0,100%x-50,100%y,"pnlMain")
SetColor("pnlPage2",0,cyellow)

AddPanel("pnlPage3",50,0,100%x-50,100%y,"pnlMain")
SetColor("pnlPage3",0,cred)

SetVisible("pnlPage2",false)
SetVisible("pnlPage3",false)

# ##########

AddPanel("pnlDrawer",in,0,pwidth,100%y,"")
SetColor("pnlDrawer",0,cblue)
AddLabel("lbl1",10,100,300,100,"pnlDrawer")
SetText("lbl1","Select page")
AddButton("btn1",10,200,300,100,"pnlDrawer")
SetText("btn1","Page1")

AddButton("btn2",10,300,300,100,"pnlDrawer")
SetText("btn2","Page2")

AddButton("btn3",10,400,300,100,"pnlDrawer")
SetText("btn3","Page3")

# ##########

dx=0
dy=0
x=0
y=0
draggable=false
oldl=in
newl=0
currentpage="pnlPage1"

# Events Panel
# ###########
Sub Activity_Pause(UserClosed)
End Sub

Sub Activity_Resume
End Sub

sub activity_touch(action,tx,ty)

select action

case 0
if tx< Visible then
draggable=true
dx=tx
end if

case 1
draggable=false

case 2
if draggable=true then
oldl=getleft("pnlDrawer")
newl=oldl+tx-dx
if newl>0 then
newl=0
end if
if newl<in then
newl=in
end if
Visible=pwidth-newl
Setleft("pnlDrawer",newl)

end if

end select

end sub

Sub Button_Click(Who)
select who

case "btn1"
SetVisible( currentpage,false)
SetVisible( "pnlPage1",true)
currentpage="pnlPage1"

case "btn2"

SetVisible( currentpage,false)
SetVisible( "pnlPage2",true)
currentpage="pnlPage2"

case "btn3"

SetVisible( currentpage,false)
SetVisible( "pnlPage3",true)
currentpage="pnlPage3"

end select
End Sub
# #########