Subversion Repositories Kolibri OS

Rev

Blame | Last modification | View Log | Download | RSS feed

  1. package kernel
  2.  
  3. import "os"
  4. import "colors"
  5.  
  6. const (
  7.     Btn1=2;
  8.     Btn2=3;
  9.     BtnExit=1;
  10. )
  11.  
  12. func RedrawAll(bar_pos int){
  13.     btn_txt1:=" <- "
  14.     btn_txt2:=" -> "
  15.     str:="I love KolibriOS"
  16.     title:="Test Golang"            
  17.     os.Redraw(1)       
  18.     os.Window(500,250,420,200, title)
  19.     os.WriteText(32,32, 0x11000000 | colors.Green,str, 10)
  20.     os.DrawLine(32, 80, 150, 80, colors.Green)
  21.     os.CreateButton(32, 128, 80, 30, Btn1, colors.Blue);
  22.     os.CreateButton(300, 128, 80, 30, Btn2, colors.Blue);
  23.     os.WriteText(32,128, 0x11000000 | colors.White,btn_txt1, 10)
  24.     os.WriteText(320,128, 0x11000000 | colors.White,btn_txt2, 10)
  25.     os.DrawBar(uint32(bar_pos), 90, 100, 30, colors.Red);
  26. }
  27.  
  28. func Load() {
  29.     time := os.GetTime()
  30.     os.DebugOutStr("Time: ")
  31.     os.DebugOutHex(time)
  32.     var pos=32;
  33.     for true {
  34.         switch os.Event() {
  35.                         case os.EVENT_REDRAW:
  36.                 RedrawAll(pos)
  37.                 break
  38.             case os.EVENT_BUTTON:
  39.                 switch os.GetButtonID() {
  40.                     case Btn1:
  41.                         pos-=32
  42.                         RedrawAll(pos)
  43.                         break
  44.                     case Btn2:
  45.                         pos+=32
  46.                         RedrawAll(pos);
  47.                         break
  48.                     case BtnExit:
  49.                         os.Exit()
  50.                 }
  51.                 }
  52.         }
  53. }
  54.