# WimpWorks Information File
# WimpWorks  Jaffa Software 1997. All rights reserved.

DEF TASKdetails
	Name		ShowDraw
	Purpose		Display Draw files
	Author		 Jaffa Software 1997
	Licence		
	Version		1.00 (15-Dec-1997)
	Compress	False
	Memory		0K
	IconbarSide	Right
	IconbarPriority	&00000000
	IconbarSprite	!showdraw
	IconbarText	
ENDTASK

DEF WEMinclude
	Starter Pack
ENDWEM

DEF MENUiconMenu%
	ShowDraw
	Info
		S(infoWindow%)
		
	Quit
		
		CLOSEDOWN
ENDMENU

DEF SUBR_PROCfile_dragged
	Event	4
	Every	-1
DEF PROCfile_dragged(window%, icon%, file$, type%)
  LOCAL size%

  ' Is it a Draw file? If not, then we can't proceed
  IF type%<>&AFF THEN WARNING(TOKEN("NotDraw"),"Message from ShowDraw")

  ' If there is already a file open, then close it (see FNwindow_close)
  IF OPENQUERY(display) THEN CLOSEWINDOW(display)

  ' Use LOADFILE from the Starter Pack WEM, producing an error if there
  ' is not enough memory available - then find the size of the file, to
  ' pass on to DRAW
  drawMem%=LOADFILE(file$)
  IF drawMem%=-1 THEN WARNING(TOKEN("NoMem"),"Message from ShowDraw")
  SYS "OS_File",17,file$ TO ,,,,size%

  ' Display the file in the 'display' and open it
  DRAW(display,0,0,100,100,drawMem%,size%)
  OPENWINDOW(display)
ENDPROC
ENDSUBR

DEF SUBR_FNwindow_close
	Event	11
	Every	-1
DEF FNwindow_close(window%)
  ' Should the window be open, clear the window and gives
  ' the memory back to the system

  IF window%=display THEN CLWIN(display):RELEASE(drawMem%)
=TRUE
ENDSUBR

