
; Opens 3 windows. To finish hit the close gadget on the main window.
; One window is fully functional, one is borderless and the other has no
;system gadgets at all.

; M.Meany  1 December 1990

		incdir		sys:include/
		include		exec/exec_lib.i
		include		intuition/intuition.i
		include		intuition/intuition_lib.i
		
; Open Intuition library ( use macro ).

		lea		intname,a1
		moveq.l		#0,d0
		CALLEXEC	OpenLibrary
		move.l		d0,_IntuitionBase
		beq		quit_fast
		
; Open the main window
		
		lea		window,a0
		CALLINT		OpenWindow
		move.l		d0,window.ptr	window structure
		beq		no_window
		move.l		d0,a0
		move.l		wd_UserPort(a0),window.up	user port
		
; Open other two windows

		lea		window1,a0
		CALLINT		OpenWindow
		move.l		d0,window1.ptr
		beq		error1
		
		lea		window2,a0
		CALLINT		OpenWindow
		move.l		d0,window2.ptr
		beq		error2

; Note that in this Event Loop, we are only testing for Messages from
;one of the available windows.
		
WaitForMsg	move.l		window.up,a0	a0-->user port
		CALLEXEC	WaitPort	wait for something to happen
		move.l		window.up,a0	a0-->window pointer
		CALLEXEC	GetMsg		get any messages
		tst.l		d0		was there a message ?
		beq		WaitForMsg	if not loop back
		move.l		d0,a1		a1-->message
		move.l		im_Class(a1),d2	d2=IDCMP flags
		CALLEXEC	ReplyMsg	answer os or it get angry

		cmp.l		#CLOSEWINDOW,d2	window closed ?
		bne.s		WaitForMsg
		

; Close two windows

		move.l		window2.ptr,a0
		CALLINT		CloseWindow
		
error2		move.l		window1.ptr,a0
		CALLINT		CloseWindow	
		
; Close the main window

error1		move.l		window.ptr,a0
		CALLINT		CloseWindow
		
; Close Intuition window before finishing ( use macro ).

no_window	move.l		_IntuitionBase,a1
		CALLEXEC	CloseLibrary
		
quit_fast	rts

; Variables and data defenition area

intname		INTNAME
_IntuitionBase	dc.l		0

window.ptr	dc.l		0
window.up	dc.l		0

window1.ptr	dc.l		0
window2.ptr	dc.l		0

; Window data definition

window		dc.w		0,10	
		dc.w		640,230	
		dc.b		0,2
		dc.l		CLOSEWINDOW
		dc.l		WINDOWSIZING+WINDOWDRAG+WINDOWDEPTH+WINDOWCLOSE+SIZEBRIGHT+ACTIVATE+NOCAREREFRESH
		dc.l		0	
		dc.l		0	
		dc.l		windowname
		dc.l		0	
		dc.l		0	
		dc.w		50,50	
		dc.w		640,250	
		dc.w		WBENCHSCREEN

windowname	dc.b		'A Test Window  © M.Meany 1990',0
		even

window1		dc.w		10,50	
		dc.w		200,100	
		dc.b		0,3
		dc.l		0
		dc.l		BORDERLESS+WINDOWSIZING+WINDOWDRAG+WINDOWDEPTH+SIZEBRIGHT+NOCAREREFRESH
		dc.l		0	
		dc.l		0	
		dc.l		window1name
		dc.l		0	
		dc.l		0	
		dc.w		50,50	
		dc.w		640,250	
		dc.w		WBENCHSCREEN

window1name	dc.b		'Borderless Window',0
		even

window2		dc.w		300,50	
		dc.w		200,100	
		dc.b		0,1
		dc.l		0
		dc.l		NOCAREREFRESH
		dc.l		0	
		dc.l		0	
		dc.l		window2name
		dc.l		0	
		dc.l		0	
		dc.w		50,50	
		dc.w		640,250	
		dc.w		WBENCHSCREEN

window2name	dc.b		'No Gadgets',0
		even

