eventtest.bas 1.82 KB
Newer Older
kollo's avatar
kollo committed
1 2 3 4 5
' test of the EVENT command in X11-Basic
' can have different results on different platforms/OS
'

@init
6 7
DO
  IF event?(1+2+4+8+0x40)=true OR true
kollo's avatar
kollo committed
8 9
    t=4711
    EVENT t,x,y,xroot,yroot,s,k,ks,t$,tim
10
    IF t=2
kollo's avatar
kollo committed
11
      @show("Key Press")
12
      PRINT t,x,y,xroot,yroot,s,k,ks,t$,tim
kollo's avatar
kollo committed
13 14
      key(k)=1
      @key
15
    ELSE if t=3
kollo's avatar
kollo committed
16
      @show("Key Release")
17 18
      PRINT t,x,y,xroot,yroot,s,k,ks,t$,tim
      key(k)=0
kollo's avatar
kollo committed
19
      @key
20 21

    ELSE if t=4
kollo's avatar
kollo committed
22 23
      @show("Mouse Button Press")
      mb(k)=1
24 25
      COLOR rot
      PCIRCLE x,y,5
kollo's avatar
kollo committed
26
      @mouse
27
    ELSE if t=5
kollo's avatar
kollo committed
28 29 30
      @show("Mouse Button Release")
      mb(k)=0
      @mouse
31 32

    ELSE if t=6
kollo's avatar
kollo committed
33
      @show("Mouse Motion")
34 35 36
      COLOR gelb
      PCIRCLE x,y,5
    ELSE if t=10
kollo's avatar
kollo committed
37
      @show("Window Moved")
38
    ELSE if t=13
kollo's avatar
kollo committed
39
      @show("Window Resize")
40 41 42 43 44 45 46
      '  sizew ,x,y
      '  vsync
    ELSE
      PRINT t,x,y,xroot,yroot,s,k,ks,t$,tim
      PRINT "Event: typ=0x"+HEX$(t)
    ENDIF
  ENDIF
kollo's avatar
kollo committed
47

48 49
LOOP
PROCEDURE init
kollo's avatar
kollo committed
50 51 52 53
  schwarz=color_RGB(0,0,0)
  rot=color_RGB(1,0,0)
  gelb=color_RGB(1,1,0)
  weiss=color_RGB(1,1,1)
54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82
  COLOR schwarz
  GET_GEOMETRY ,bx%,by%,bw%,bh%
  PRINT "Screen dimensions: ";bx%,by%,bw%,bh%
  PBOX bx%,by%,bw%,bh%
  DIM mb(6)
  DIM key(512)
RETURN
PROCEDURE show(t$)
  COLOR schwarz
  PBOX 10,10,180,32
  COLOR rot
  TEXT 16,25,t$
  VSYNC
RETURN
PROCEDURE mouse
  COLOR weiss
  BOX 10,40,120,120
  FOR i=1 TO 5
    COLOR weiss
    BOX i*20,44,i*20+16,60
    IF mb(i)
      COLOR weiss
    ELSE
      COLOR schwarz
    ENDIF
    PBOX i*20+1,44+1,i*20+16-1,60-1
  NEXT i
  VSYNC
RETURN
kollo's avatar
kollo committed
83

84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100
PROCEDURE key
  COLOR weiss
  BOX 320,60,420,120
  FOR j=0 TO 15
    FOR i=0 TO 31
      COLOR weiss
      BOX 320+i*10,60+j*10,320+i*10+8,60+j*10+8
      IF key(j*32+i)
        COLOR weiss
      ELSE
        COLOR schwarz
      ENDIF
      PBOX 320+i*10+1,60+j*10-1,320+i*10+8+1,60+j*10+8-1
    NEXT i
  NEXT j
  VSYNC
RETURN
kollo's avatar
kollo committed
101