
;structure example


	include	"baselibs.i"
	include	"intuition.i"
	include	"baseintuition.i"
	include	"basegfx.i"


	

	#define		IDCMPflags,NEWSIZE|REFRESHWINDOW|MOUSEBUTTONS|CLOSEWINDOW|VANILLAKEY
	#define		flags,WINDOWSIZING|WINDOWDRAG|WINDOWCLOSE|ACTIVATE


		DATAAREA
	{
		structset	myscreen
		{
		dc.w	0,0	;ns_LeftEdge ns_TopEdge
		dc.w	640,256	;ns_Width ns_Height
		dc.w	3	;ns_Depth
		dc.b	1	;ns_DetailPen
		dc.b	3	;ns_BlockPen
		dc.w	$8000	;ns_ViewModes
		dc.w	15	;ns_Type
		dc.l	0	;ns_Font
		dc.l	0	;ns_DefaultTitle
		dc.l	0	;ns_Gadgets
		dc.l	64	;ns_CustomBitMap
		}
		structset	mywindow
		{
		dc.w	0,0		;nw_LeftEd nw_TopEdge
		dc.w	640,240		;nw_Width nw_Height
		dc.b	1		;nw_DetailPen
		dc.b	3		;nw_BlockPen
		dc.l	IDCMPflags	;nw_IDCMPFlags
		dc.l	flags		;nw_Flags
		dc.l	0		;nw_FirstGadget
		dc.l	0		;nw_CheckMark
		dc.l	windowtext	;nw_Title
		dc.l	0		;nw_Screen
		dc.l	0		;nw_BitMap
		dc.w	200,200		;nw_MinWidth nw_MinHeight
		dc.w	640,256		;nw_MaxWidth nw_MaxHeight
		dc.w	15		;nw_Type
		}

		structset	overtext
		{
		dc.b	0	;overtext,->,it_FrontPen,=,0,b
		dc.b	1	;overtext,->,it_BackPen,=,1,b
		dc.b	4	;overtext,->,it_DrawMode,=,4,b
		dc.b	0	;even
		dc.w	20	;overtext,->,it_LeftEdge,=,20,w
		dc.w	5	;overtext,->,it_TopEdge,=,5,w
		dc.l	0	;overtext,->,it_ITextFont,=,0,l
		dc.l	otext	;overtext,->,it_IText,=,>otext,l
		dc.l	0	;overtext,->,it_NextText,=,0,l
		}
		structset	lefttext
		{
		dc.b	0	;lefttext,->,it_FrontPen,=,0,b
		dc.b	1	;lefttext,->,it_BackPen,=,1,b
		dc.b	0	;it_DrawMode,=,0,b
		dc.b	0	;even
		dc.w	5	;lefttext,->,it_LeftEdge,=,5,w
		dc.w	4	;lefttext,->,it_TopEdge,=,4,w
		dc.l	0	;lefttext,->,it_ITextFont,=,0,l
		dc.l	ltext	;lefttext,->,it_IText,=,>ltext,l
		dc.l	0	;lefttext,->,it_NextText,=,0,l
		}
		structset	righttext
		{
		dc.b	0	;righttext,->,it_FrontPen,=,0,b
		dc.b	1	;righttext,->,it_BackPen,=,1,b
		dc.b	0	;righttext,->,it_DrawMode,=,0,b
		dc.b	0	;even
		dc.w	5	;righttext,->,it_LeftEdge,=,5,w
		dc.w	4	;righttext,->,it_TopEdge,=,4,w
		dc.l	0	;righttext,->,it_ITextFont,=,0,l
		dc.l	rtext	;righttext,->,it_IText,=,>rtext,l
		dc.l	0	;righttext,->,it_NextText,=,0,l
		}

windowtext	dc.b	"request_window",0
otext		dc.b	"do you like draw",0
ltext		dc.b	"draw",0
rtext		dc.b	"exit",0
	
	}
	
	variables

	CPTR	_IntuitionBase
	CPTR	_GfxBase

	main()
	
	CPTR	rp
	CPTR	screenl,windowl
	CPTR	message
	{
		func	_IntuitionBase,=,openlibrary,"intuition.library",0
		if	_IntuitionBase,!=,0,1
		{
				func	screenl,=,openscreen,myscreen

			if	screenl,!=,0,2
			{
				structput	mywindow,.,nw_Screen,=,screenl
				func	windowl,=,openwindow,mywindow
				if	windowl,!=,0,3
				{
					structput	rp,=,windowl,->,wd_RPort
		
					func	message,=,AutoRequest,windowl,overtext,lefttext,righttext,0,0,180,80
					if	message,!=,0,4
						{
						ROUTINE	draw,rp,windowl
						}	
						ifend	4
				}
				ifend	3
				closewindow	windowl
			}
			ifend	2
			closescreen	screenl
		}
		ifend	1
		closelibrary	_IntuitionBase
	}


;draw graphic into a window

		VOID	draw,rp,windowl

		CPTR	rp,windowl
		int	xa,ya
		int	xb,yb
		int	count
		{
		func	_GfxBase,=,openlibrary,"graphics.library",0
			if	_GfxBase,!=,0,11
			{
			calc	xa,=,380
			calc	ya,=,180
			calc	xb,=,40
			calc	yb,=,80
			calc	count,=,0
				while	count,«,80,1
				{
					calc	count,++
					setapen		rp,count
					drawellipse	rp,xa,ya,xb,yb
					calc	xa,--
					calc	ya,--
					calc	xb,=,xb,+,2
					calc	yb,=,yb,-,2
				}	1	
				GetIntuiMsg	windowl
			}	
			ifend	11
		closelibrary	_GfxBase
		}

	
	end