***********************************************************************
*
* busybox umenu.aii -- Version 3.0
*
* Copyright (c)
* Apple Computer, Inc.  1986-1990
* All Rights Reserved.
*
* This file contains the code which implements menus in the
* busybox program.
*
***********************************************************************

	case on
	longi on
	longa on

	INCLUDE 'e16.types'
	INCLUDE 'm16.desk'
	INCLUDE 'e16.event'
	INCLUDE 'm16.menu'
	INCLUDE 'm16.window'
	INCLUDE 'busybox.equ'

********************

	EXPORT doQuitItem
doQuitItem	PROC
	import quitFlag

	inc quitFlag	;That's all folks.
	rts

	ENDP

***********************************************************************

	EXPORT doAboutItem
doAboutItem	PROC

	pha	;Pop up the resource Alert.
	pea 4
	pea 0>>16
	pea 0
	pea 1>>16
	pea 1
	_AlertWindow
	pla
	rts

	ENDP

***********************************************************************
* Procedure to handle all menu selections.  Examines the event.TaskData
* menu item ID word	from TaskMaster (from Event Manager) and calls the
* appropriate routine.  While the routine is running the menu title is
* still highlighted.    After the routine returns, we unhilight the
* menu title.

	EXPORT doMenu
doMenu	PROC
	import event, doCloseTop

	lda event+owmTaskData ;Item number
	cmp #AboutItem
	bne aa
	jsr doAboutItem
	jmp zz

aa	cmp #CloseItem
	bne bb
	jsr doCloseTop
	jmp zz

bb	cmp #QuitItem
	bne zz
	jsr doQuitItem

zz	pea 0
	lda event+owmTaskData+2 ;menuNum
	pha
	_HiliteMenu
	rts

	ENDP

***********************************************************************

	EXPORT setupMenus
setupMenus	PROC

	pha	;Get menus from resource
	pha
	pea refIsResource
	pea $1000>>16
	pea $1000
	pea 0>>16
	pea 0
	_NewMenuBar2
	_SetSysBar

	pea 0>>16
	pea 0
	_SetMenuBar

	pea AppleMenuID
	_FixAppleMenu

	pha
	_FixMenuBar
	pla

	_DrawMenuBar
	rts

	ENDP

	END
