	*««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««*
	*
	*   Example name
	*
	*	DFSuggestWindow.s -- 1.0
	*
	*   Function
	*	The DFSuggestWindow() will calculate the gadget list you will
	*	use in the window and return the suggested window sizes.
	*	Put the values directly into the the WindowStructure/Tags and
	*	then open the window. When you then render the gadgets with
	*	the DFRenderGadgets() function the gadgets will all be within
	*	the window borders.
	*
	*   Inputs
	*	screen - pointer to the screen you want to open your window on
	*	gadgetlist - pointer to the gadget list you will use in window
	*	table - pointer to two LONG words containing sizes (wid/heig)
	*	flags - defult=0, see autodocs for more information
	*
	*   Outputs
	*	Outputs the suggested with and height of the window you will
	*	use the gadgets in. Use these to open your window.
	*
	*   Notes
	*	You may need to modify some of the include paths.
	*	You will of course also need the dfunc package which should
	*	contain includes and macros for the dfunc.library.
	*
	*	Also set UCASE = LCASE for my sources.
	*
	*   Bugs
	*	
	*   Created	: 23.2.96
	*   Last change	: 23.2.96
	*»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»*

*## For the Startup.asm:

StartSkip	=	0		;0=WB/CLI, 1=CLI only  (AsmOne)
Processor	=	0		;0/680x0/0x0
MathProc	=	0		;0/68881/68882/68040/68060

*## Default includes:

		Incdir	""

** external includes and lvos:

		Include	lvo:intuition.lvo

** includes from our DFuncXXXX.library archive:

		Include	lvo:dfunc.lvo

		Incdir	inc:

		Include	digital.macs
		Include	digital.i
		Include	dfunc/dfunc.i

		Include	startup.asm

		Incdir	""

	dc.b	"$VER: DFSuggestWindow 1.0 (23.2.96)",0
	even
*»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»*
Init	DefLib	dfunc,38		;open our library (macro)
	DefLib	intuition,37		;open intuition.library
	DefEnd

Start	LibBase	intuition	;use intuition base in A6 (macro)

* We will here get the frontmost screen

	moveq	#0,d0
	Call	LockIBase	;lock intuition.library base so we can
	move.l	d0,ILock	;examine it.

	move.l	60(a6),ScreenBase	;get frontmost screen

*** This is the dfunc.library function we demostrate:

	LibBase	dfunc

	move.l	ScreenBase(pc),a0
	lea	Gadgets(pc),a1
	lea	Table(pc),a2
	moveq	#sw_noborders,d0
	DCall	SuggestWindow

***
*	You need to get a screen structure
*	You need a gadget list
*	You need to init D0 for flags or 0 (=default flag)
***

	LibBase	intuition

	move.l	ILock(pc),a0
	Call	UnlockIBase	;free intuition base so others can use it

	sub.l	a0,a0			;no structure
	lea	WindowTags(pc),a1	;our tag list

* init the tag list with our values, width, height and the screen pointer:

	lea	Table(pc),a2		;table initialized by DFSuggestWindow()

	move.l	ScreenBase(pc),4(a1)
	move.l	sw_width(a2),12(a1)
	move.l	sw_height(a2),20(a1)

	Call	OpenWindowtaglist	;try open a window
	move.l	d0,WindowBase		;store pointer to window
	beq.b	Close			;if =0 then exit, couldn't open window

	move.l	d0,a1
	move.l	50(a1),Rastport		;rastport of window
	move.l	86(a1),Userport		;userport of window

	LibBase	dfunc

	move.l	Rastport(pc),a0
	lea	Gadgets(pc),a1
	DCall	RenderGadgets		;render gadget list into window

Loop	move.l	Rastport(pc),a0		;pointer to rastport in window
	move.l	Userport(pc),a1		;pointer to IDCMP port
	lea	Gadgets(pc),a2		;pointer to our gadget list
	DCall	WaitGad			;wait for user to do something

* note: the DFGetID() is not necessary in this example since ID 4 = gadget 4

	lea	Gadgets(pc),a1		;
	DCall	GetID			;if gadget, get ID number

	cmp.b	#4,d0
	bne.b	Loop			;if not QUIT, loop some more..
*·············································································*
Close	LibBase	intuition

	move.l	WindowBase(pc),d0
	beq.b	.noWindow
	move.l	d0,a0
	Call	CloseWindow		;close our window if any

.noWindow

	Return	0			;Exit
*»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»*
ILock		dc.l	0
ScreenBase	dc.l	0
WindowBase	dc.l	0

Rastport	dc.l	0
Userport	dc.l	0

Font	dc.l	FontName
	dc.w	8,0

Table		dcb.b	sw_sizeOf	;table for window size
*·············································································*
Gadgets	dc.w	0,0,130,17,1		;sizes and the ID
	dc.l	GText1,0,0,0		;texts and images pointers (pear)
	dc.l	$21101213		;colors
	dc.l	0			;flags
	dc.l	Font			;pointer to FontAttr
	dc.l	0			;link

	dc.w	0,20,130,17,2
	dc.l	GText2,0,0,0
	dc.l	$21101213
	dc.l	0,Font,0

	dc.w	140,20,130,17,3
	dc.l	GText3,0,0,0
	dc.l	$21101213
	dc.l	0,Font,0

	dc.w	140,60,150,17,4
	dc.l	GText4,0,0,0
	dc.l	$21101213
	dc.l	dg_hotkeys,Font,0

	dc.l	-1
*·············································································*
WindowTags

	dc.l	WA_CustomScreen,0
	dc.l	WA_Width,0
	dc.l	WA_Height,0
	dc.l	WA_Left,30
	dc.l	WA_Top,30
	dc.l	WA_Title,WinTitle
	dc.l	WA_Activate,-1
	dc.l	WA_IDCMP,DF_IDCMP
	dc.l	WA_ReportMouse,-1
	dc.l	WA_RMBTrap,-1
	dc.l	WA_Dragbar,-1
	dc.l	0,0
*·············································································*
FontName	dc.b	'topaz.font',0
WinTitle	dc.b	'Example: DFSuggestWindow',0

GText1		dc.b	'Auto adjusted',0
GText2		dc.b	'Hello world',0
GText3		dc.b	'DFSuggestWindow',0
GText4		dc.b	'RqQuit: Press me!',0
*»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»*
