home *** CD-ROM | disk | FTP | other *** search
/ Falcon 030 Power 2 / F030_POWER2.iso / ST_STE / MAGS / ICTARI10.ARJ / ictari.10 / GFA / GEM_WIND / V109_ENG.LST < prev    next >
File List  |  1994-04-07  |  11KB  |  255 lines

  1. '
  2. ' W_VDI109.GFA        REDRAW  with COPY RASTER (VDI function 109)
  3. '                     Selection with EVNT-MULTI
  4. '
  5. ' Base program for window handling under GEM (without LINE-A)
  6. '
  7. RESERVE FRE(0)
  8. '
  9. xres&=WORK_OUT(0)+1                   ! X resolution
  10. yres&=WORK_OUT(1)+1                   ! Y resolution
  11. '
  12. CONTRL(0)=102                         ! No. of VDI function 102
  13. INTIN(0)=1                            ! 1= extended information owflag
  14. VDISYS                                ! VDI call
  15. bit_pl&=INTOUT(4)                     ! Number of bit planes
  16. '
  17. w_ram%=xres&*yres&*bit_pl&/8          ! RAM memory space for 1 window
  18. logbase%=XBIOS(3)                     ! Logical address of screen
  19. sizeflag!=FALSE                       ! Window size change flag
  20. fullflag!=FALSE                       ! Window fuller flag
  21. DIM s_mfdb&(6),d_mfdb&(6)             ! Memory Form Description Block
  22. '                                     ! (Felder für COPY RASTER-Funktion)
  23. REPEAT
  24.   PRINT AT(2,3);"How many windows do you want (max. 7) ";
  25.   INPUT w_anzahl&
  26.   PRINT AT(2,3);"                                                 "
  27. UNTIL w_anzahl&<=7                    ! max. number of windows
  28. '
  29. DIM w_adr%(12)                        ! Address array for windows
  30. '
  31. DIM message_buffer%(3)                ! 16 Byte
  32. mes_adr%=V:message_buffer%(0)
  33. '
  34. ABSOLUTE word0&,mes_adr%
  35. ABSOLUTE handle&,mes_adr%+6
  36. ABSOLUTE x&,mes_adr%+8
  37. ABSOLUTE y&,mes_adr%+10
  38. ABSOLUTE b&,mes_adr%+12
  39. ABSOLUTE h&,mes_adr%+14
  40. '
  41. DEFFILL 1,2,4                         ! Desktop background draw
  42. PBOX 0,19,xres&,yres&                 ! only for not patched GFA compilers,
  43. DEFFILL 1,0                           ! because damned GFA clears the screen
  44. '
  45. GOSUB beispiel_fenster(45,35,120,80)  ! Sample window creation
  46. '                                     ! Event Multi
  47. DO
  48.   ~EVNT_MULTI(&X110000,0,0,0,0,0,0,0,0,0,0,0,0,0,mes_adr%,100,d%,d%,d%,d%,d%,d%)
  49.   IF word0&>10
  50.     GOSUB window_manager
  51.     word0&=0
  52.   ENDIF
  53. LOOP
  54. '
  55. > PROCEDURE window_manager
  56.   '
  57.   SELECT word0&
  58.     '
  59.   CASE 20                        ! WINDOW REDRAW
  60.     ~WIND_UPDATE(1)                               ! Window updating starts
  61.     '
  62.     ~WIND_GET(handle&,4,ax&,ay&,ab&,ah&)          ! Get window work dimensions
  63.     ~WIND_GET(handle&,11,rx&,ry&,rb&,rh&)         ! 1th entry in the rectangle redraw list
  64.     IF fullflag!=FALSE                                  ! only redraw, if no window fuller
  65.       GOSUB w_restaurieren(handle&,rx&,ry&,rb&-1,rh&-1) ! selected
  66.     ENDIF
  67.     '
  68.     WHILE rb&>0 AND rh&>0                         ! redraw loop, get redraw areas from GEM
  69.       IF sizeflag!=TRUE
  70.         ~WIND_GET(win&,4,x&,y&,b&,h&)             ! get your window dimensions
  71.         GOSUB fuellmuster(x&,y&,b&,h&)            ! fill background
  72.         sizeflag!=FALSE
  73.       ELSE
  74.         ~RC_INTERSECT(ax&,ay&,ab&,ah&,rx&,ry&,rb&,rh&) ! Check rectangle (overlaps it your windows)
  75.         GOSUB w_restaurieren(handle&,rx&,ry&,rb&-1,rh&-1) ! redraw
  76.       ENDIF
  77.       ~WIND_GET(handle&,12,rx&,ry&,rb&,rh&)       ! Next rectangle list element from GEM
  78.     WEND
  79.     '
  80.     ~WIND_UPDATE(0)                               ! Redraw is finished
  81.     '
  82.   CASE 21                        ! WINDOW TOP
  83.     ~WIND_GET(w_top&,4,ax&,ay&,ab&,ah&)           ! get window dimensions
  84.     GOSUB rette_fenster(w_top&,ax&,ay&,ab&,ah&)   ! save window contents
  85.     ~WIND_SET(handle&,10,0,0,0,0)                 ! save GEM-handle of new top window
  86.     w_top&=handle&
  87.     '
  88.   CASE 22                        ! WINDOW CLOSED
  89.     ~WIND_CLOSE(handle&)                          ! close window
  90.     ~WIND_DELETE(handle&)                         ! delete window
  91.     ~MFREE(w_adr%(handle&))                       ! realllocate memory (MFREE)
  92.     RESERVE +w_ram%                               ! Add to Basic memory
  93.     '
  94.     ~WIND_GET(0,10,handle&,ay&,ab&,ah&)           ! get actual top window handle
  95.     w_top&=handle&
  96.     '
  97.   CASE 23                        ! WINDOW FULL
  98.     win&=handle&
  99.     '
  100.     IF fullflag!=FALSE                            ! only if no max. window size
  101.       ~WIND_GET(handle&,4,x&,y&,b&,h&)            ! get window dimensions
  102.       GOSUB rette_fenster(handle&,x&,y&,b&,h&)    ! save window contents
  103.       ~WIND_SET(handle&,5,0,19,xres&,yres&-19)    ! set max. window size
  104.       fullflag!=TRUE
  105.       sizeflag!=TRUE
  106.     ELSE
  107.       ~WIND_GET(handle&,6,ax&,ay&,ab&,ah&)        ! toggle to old window size
  108.       ~WIND_SET(handle&,5,ax&,ay&,ab&,ah&)        ! set old window size
  109.       ~WIND_GET(win&,4,ax&,ay&,ab&,ah&)           ! get window dimensions
  110.       GOSUB w_restaurieren(win&,ax&,ay&,ab&,ah&)  ! redraw window
  111.       fullflag!=FALSE
  112.       sizeflag!=FALSE
  113.     ENDIF
  114.     '
  115.   CASE 27                        ! WINDOW SIZED
  116.     win&=handle&
  117.     sizeflag!=TRUE
  118.     fullflag!=FALSE
  119.     b&=MIN(xres&-x&-2,b&)
  120.     h&=MIN(yres&-y&-2,h&)
  121.     ~WIND_SET(handle&,5,x&,y&,MAX(55,b&),MAX(55,h&))
  122.     ~WIND_GET(handle&,4,x&,y&,b&,h&)               ! get new window dimensions
  123.     GOSUB fuellmuster(x&,y&,b&,h&)
  124.     '
  125.   CASE 28                        ! WINDOW MOVED
  126.     IF fullflag!=FALSE
  127.       sizeflag!=FALSE
  128.       x&=MIN(xres&-b&-2,x&)
  129.       y&=MIN(yres&-h&-2,y&)
  130.       ~WIND_SET(handle&,5,x&,y&,b&,h&)               ! move window
  131.     ENDIF
  132.     '
  133.   ENDSELECT
  134. RETURN
  135. '
  136. > PROCEDURE beispiel_fenster(x&,y&,b&,h&)    ! Sample window
  137.   '
  138.   freier_ram%=FRE(0)                     ! Max. free memory block in bytes
  139.   '
  140.   IF freier_ram%>=w_ram&*w_anzahl&       ! enough memory ?
  141.     RESERVE -w_ram%*w_anzahl&            ! get memory from BASIC
  142.     w_adr%=MALLOC(w_ram%*w_anzahl&)      ! allocate memory for window
  143.     FOR i&=1 TO w_anzahl&
  144.       w_adr%(i&)=w_adr%                  ! window title
  145.       w_title$=" Titel "+STR$(i&)+" "
  146.       w_info$=" Info "+STR$(i&)+" "
  147.       w_top&=i&                          ! window is top
  148.       '
  149.       GOSUB init_window(x&,y&,b&,h&,w_title$,w_info$)   ! create windows
  150.       x&=x&+50                           ! new window dimensions
  151.       y&=y&+40
  152.       b&=b&+40
  153.       h&=h&+15
  154.       w_adr%=w_adr%+w_ram%
  155.     NEXT i&
  156.   ELSE
  157.     ALERT 1,"|Not enough memory free|for the next window",1," ok ",antwort&
  158.   ENDIF
  159. RETURN
  160. '
  161. '
  162. > PROCEDURE init_window(x&,y&,b&,h&,w_titel$,w_info$)
  163.   ~WIND_UPDATE(1)                           ! window updating
  164.   handle&=WIND_CREATE(&X111111,0,19,xres&,yres&-19)   ! create window
  165.   w_titel$=w_titel$+CHR$(0)
  166.   adr_tit%=V:w_titel$
  167.   w_info$=w_info$+CHR$(0)
  168.   adr_inf%=V:w_info$
  169.   '
  170.   ~WIND_SET(handle&,2,CARD(SWAP(adr_tit%)),CARD(adr_tit%),0,0)  ! Title
  171.   ~WIND_SET(handle&,3,CARD(SWAP(adr_inf%)),CARD(adr_inf%),0,0)  ! Info line
  172.   x&=MIN(x&,xres&-40)
  173.   y&=MIN(y&,yres&-40)
  174.   b&=MIN(b&,xres&-2-x&)
  175.   h&=MIN(h&,yres&-2-y&)
  176.   ~WIND_OPEN(handle&,x&,y&,b&,h&)
  177.   '
  178.   ~WIND_GET(handle&,4,x&,y&,b&,h&)          ! get window dimensions
  179.   DEFFILL 1,2,RAND(25)                      ! random fill pattern
  180.   PBOX x&,y&,x&+b&,y&+h&                    ! fill window area
  181.   '
  182.   GOSUB rette_fenster(handle&,x&,y&,b&,h&)  ! save window contents
  183.   '
  184.   ~WIND_UPDATE(0)                           ! update finished
  185. RETURN
  186. '
  187. > PROCEDURE fuellmuster(x&,y&,b&,h&)
  188.   DEFFILL 1,2,RAND(25)                   ! fill pattern
  189.   PBOX x&,y&,x&+b&,y&+h&                 ! fill window area
  190. RETURN
  191. '
  192. '
  193. PROCEDURE rette_fenster(hdl&,x&,y&,b&,h&)
  194.   GOSUB src_mfdb(logbase%,xres&,yres&,bit_pl&)      ! MFDB array source address  (VDI 109)
  195.   GOSUB des_mfdb(w_adr%(hdl&),xres&,yres&,bit_pl&)  ! MFDB array destination address
  196.   GOSUB par_mfdb(x&,y&,b&,h&,x&,y&)                 ! Parameter-Feld
  197.   '
  198.   INTIN(0)=3                            ! raster mode (destination=source)
  199.   CONTRL(0)=109                         ! No. of VDI function 109
  200.   CONTRL(1)=4                           ! entries in ptsin
  201.   CONTRL(3)=1                           ! entries in intin
  202.   CONTRL(6)=GRAF_HANDLE()             ! Handle of VDI workstation
  203.   CONTRL(7)=CARD(SWAP(V:s_mfdb&(0)))  ! pointer to MFDB source address
  204.   CONTRL(8)=CARD(V:s_mfdb&(0))        ! pointer to MFDB source address
  205.   CONTRL(9)=CARD(SWAP(V:d_mfdb&(0)))  ! pointer to MFDB destination address
  206.   CONTRL(10)=CARD(V:d_mfdb&(0))       ! pointer to MFDB destination address
  207.   VDISYS                                ! VDI call
  208. RETURN
  209. '
  210. PROCEDURE w_restaurieren(handle&,x&,y&,b&,h&)          ! redraw window
  211.   GOSUB src_mfdb(w_adr%(handle&),xres&,yres&,bit_pl&)  ! Source      -array
  212.   GOSUB des_mfdb(logbase%,xres&,yres&,bit_pl&)         ! Destination -array
  213.   GOSUB par_mfdb(x&,y&,b&,h&,x&,y&)                    ! Parameter   -array
  214.   '
  215.   INTIN(0)=3                            ! Raster mode (Destination=Source)
  216.   CONTRL(0)=109                         ! No. of VDI function
  217.   CONTRL(1)=4                           ! entries in ptsin
  218.   CONTRL(3)=1                           ! entries in intin
  219.   CONTRL(6)=GRAF_HANDLE()               ! Handle of VDI workstation
  220.   CONTRL(7)=CARD(SWAP(V:s_mfdb&(0)))    ! pointer to MFDB source address
  221.   CONTRL(8)=CARD(V:s_mfdb&(0))          ! pointer to MFDB source address
  222.   CONTRL(9)=CARD(SWAP(V:d_mfdb&(0)))    ! pointer to MFDB destination address
  223.   CONTRL(10)=CARD(V:d_mfdb&(0))         ! pointer to MFDB destination address
  224.   VDISYS                                ! VDI call
  225. RETURN
  226. '
  227. PROCEDURE src_mfdb(s_adr%,x&,y&,bit_pl&)  ! MFDB block source
  228.   LPOKE V:s_mfdb&(0),s_adr%           ! Long pointer to source address
  229.   s_mfdb&(2)=x&              ! max. x-width (divideable by 16 !!)
  230.   s_mfdb&(3)=y&              ! max. y-height
  231.   s_mfdb&(4)=x&/16           ! Raster width in 16-bit words (=Pixel/16)
  232.   s_mfdb&(5)=0               ! reserved, set to 0
  233.   s_mfdb&(6)=bit_pl&         ! Bit planes (Number of color planes)
  234. RETURN
  235. '
  236. PROCEDURE des_mfdb(d_adr%,x&,y&,bit_pl&)  !MFDB block of destination
  237.   LPOKE V:d_mfdb&(0),d_adr%           ! Long pointer to destination address
  238.   d_mfdb&(2)=x&              ! max. x-width (divideable by 16 !!)
  239.   d_mfdb&(3)=y&              ! max. y-height
  240.   d_mfdb&(4)=x&/16           ! raster width in 16-bit words (=Pixel/16)
  241.   d_mfdb&(5)=0               ! reserved, set to 0
  242.   d_mfdb&(6)=bit_pl&         ! Bit planes (Number of color planes)
  243. RETURN
  244. '
  245. PROCEDURE par_mfdb(sx&,sy&,sb&,sh&,dx&,dy&)
  246.   PTSIN(0)=sx&               ! left X-coordinate source raster
  247.   PTSIN(1)=sy&               ! left Y-coordinate source raster
  248.   PTSIN(2)=sx&+sb&           ! right X-coordinate source raster
  249.   PTSIN(3)=sy&+sh&           ! right Y-coordinate source raster
  250.   PTSIN(4)=dx&               ! left X-coordinate destination raster
  251.   PTSIN(5)=dy&               ! left Y-coordinate destination raster
  252.   PTSIN(6)=dx&+sb&           ! right X-Koordinate destination raster
  253.   PTSIN(7)=dy&+sh&           ! right Y-Koordinate destination raster
  254. RETURN
  255.