Subversion Repositories Kolibri OS

Rev

Rev 7858 | Go to most recent revision | Blame | Last modification | View Log | Download | RSS feed

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