ban2/png

tutor/gif
Home

cell/gif

Drawing using drawfiles

cell/gif
1/gif Create an application
Create an application which opens a window which has its auto-redraw flag deselected; see Example 2.3.a
2/gif Add an “Initial” event-handler
The following procedure sets aside a 100K block of memory (starting at address drawfile) where drawfiles can be stored. It also loads a drawfile, stored in the application's resources directory, into memory
DEF PROCDealWith_InitialEvent
length=0
maxlength=100*1024
DIM drawfile maxlength
PROCFile_Load("<BasicApp$Dir>.DrawFile",maxlength)
ENDPROC

3/gif Add a “File” utility library
A drawfile, whose pathname is file$, can be loaded into memory by calling the utility procedures
DEF PROCFile_Load(file$,maxlength)
IF FNFile_Length(file$)<=maxlength THEN
  SYS "OS_File",12,file$,drawfile TO ,,,,length : REM Loads file
  ELSE
  PROCUtils_Alert("File too big!")
  ENDIF
ENDPROC

DEF FNFile_Length(file$)
LOCAL length
SYS "OS_File",13,file$ TO ,,,,length
=length
4/gif Add a “WindowRedraw” event-handler
The method PROCWindow_DrawfileRedraw method uses the RISCOS Draw module to render drawfiles:
DEF PROCDealWith_WindowRedraw(object,a%,b%,h%)
IF length<>0 PROCWindow_DrawfileRedraw(drawfile,length,a%,b%)
ENDPROC

draw/png

5/gif Worked solution