NEW
  AUTO 3,1
				.LIST OFF
				.OP	65C02
				.OR	$2000
				.TF sbin/gui
*--------------------------------------
				.INB inc/io.i
				.INB inc/macros.i
				.INB inc/a2osx.i
				.INB inc/gfx.i
				.INB inc/libgui.i
*--------------------------------------
* Zero Page Segment, up to 32 bytes
*--------------------------------------
				.DUMMY
				.OR ZPBIN
ZS.START
hWND			.BS 1
ZS.END
				.ED
*--------------------------------------
*			File Header (16 Bytes)
*--------------------------------------
CS.START		cld
				jmp (.1,x)
				.DA #$61				6502,Level 1 (65c02)
				.DA #1					BIN Layout Version 1
				.DA #S.PS.F.EVENT
				.DA #0
				.DA CS.END-CS.START		Code Size (without Constants)
				.DA DS.END-DS.START		Data SegmentSize
				.DA #64					Stack Size
				.DA #ZS.END-ZS.START	Zero Page Size
				.DA 0
*--------------------------------------
* Relocation Table
*--------------------------------------
.1				.DA CS.INIT
				.DA CS.RUN
				.DA CS.DOEVENT
				.DA	CS.QUIT
L.LIBGUI		.DA LIBGUI
L.MouseData		.DA MouseData
L.WND.TITLE		.DA WND.TITLE
L.WND.MBAR		.DA WND.MBAR
L.WND.STATUS	.DA WND.STATUS
				.DA 0
*--------------------------------------
CS.INIT			>LDYA L.LIBGUI
				>SYSCALL LoadLib
				bcs .9

				sta hLIBGUI

*				clc
.9
CS.INIT.RTS		rts
*--------------------------------------
CS.RUN			>SLEEP

				>PUSHW L.MouseData
				>LIBCALL hLIBGUI,LIBGUI.ReadMouse
				bcs CS.RUN

				lda MouseData+S.MOUSE.S
				bit #S.MOUSE.S.MOVE
				beq .1

				>PUSHW L.MouseData
				>LIBCALL hLIBGUI,LIBGUI.SetCursorPos

				lda MouseData+S.MOUSE.S

.1				bit #S.MOUSE.S.DCLK
				beq CS.RUN

				jsr WND.Test

				bra CS.RUN

				clc
				rts
*--------------------------------------
CS.DOEVENT		lda (pEvent)
				bpl .9

				>LIBCALL hLIBGUI,LIBGUI.UpdateCursor

.9				sec
				rts
*--------------------------------------
CS.QUIT			clc
CS.QUIT.RTS		rts
*--------------------------------------
WND.Test		>PUSHBI S.WND.F.RESIZE+S.WND.F.MOVE+S.WND.F.CLOSE+S.WND.F.MAX+S.WND.F.MIN

				>PUSHW MouseData+S.MOUSE.X1
				>PUSHW MouseData+S.MOUSE.Y1
				>PUSHWI 360				witdh
				>PUSHWI 96				height
				>LIBCALL hLIBGUI,LIBGUI.WND.New
				bcs CS.QUIT.RTS
				sta hWND

				>PUSHA					A = hWND
				>PUSHBI S.WND.BGCOLOR
				>PUSHWI C.WHITE
				>LIBCALL hLIBGUI,LIBGUI.OBJ.SetProp

				>PUSHB hWND
				>PUSHBI S.WND.TITLE
				>PUSHW L.WND.TITLE
				>LIBCALL hLIBGUI,LIBGUI.OBJ.SetProp

				>PUSHB hWND
				>PUSHBI S.WND.MBAR
				>PUSHW L.WND.MBAR
				>LIBCALL hLIBGUI,LIBGUI.OBJ.SetProp

				>PUSHB hWND
				>PUSHBI S.WND.STATUS
				>PUSHW L.WND.STATUS
				>LIBCALL hLIBGUI,LIBGUI.OBJ.SetProp

				lda hWND
				>LIBCALL hLIBGUI,LIBGUI.WND.Show

				rts
*--------------------------------------
CS.END
LIBGUI			.AZ "libgui"
hLIBGUI			.BS 1
*--------------------------------------
MouseData		.BS S.MOUSE
*--------------------------------------
WND.TITLE		.AZ "Window Title"
*--------------------------------------
WND.MBAR		.DA #.1-*				next
				.DA #0					status
				.DA 0					X1
				.DA 0					XT
				.DA 0					X2
				.DA 0					MENU
				.AZ "File"

.1				.DA #.2-*				next
				.DA #0					status
				.DA 0					X1
				.DA 0					XT
				.DA 0					X2
				.DA 0					MENU
				.AZ "Edit"

.2				.DA #.3-*				next
				.DA #0					status
				.DA 0					X1
				.DA 0					XT
				.DA 0					X2
				.DA 0					MENU
				.AZ "Options"

.3				.DA #.4-*				next
				.DA #0					status
				.DA 0					X1
				.DA 0					XT
				.DA 0					X2
				.DA 0					MENU
				.AZ "?"

.4				.DA #0
*--------------------------------------
WND.STATUS		.AZ "Window status bar message"
*--------------------------------------
WND.MENU.FILE	.DA #02				ID
				.DA #S.MITEM.KEYMOD.CTRL
				.DA #'N'
				.AZ "New"
				.DA #04				ID
				.DA #S.MITEM.KEYMOD.CTRL
				.DA #'O'
				.AZ "Open..."
				.DA #06				ID
				.DA #S.MITEM.KEYMOD.CTRL
				.DA #'S'
				.AZ "Save"
				.DA #08				ID
				.DA #S.MITEM.KEYMOD.OA+S.MITEM.KEYMOD.CTRL
				.DA #'S'
				.AZ "Save As..."
				.DA #10				ID
				.DA #S.MITEM.KEYMOD.CTRL
				.DA #'Q'
				.AZ "Quit"
				.DA #0
*--------------------------------------
WND.MENU.EDIT	.DA #12				ID
				.DA #S.MITEM.KEYMOD.OA
				.DA #'X'
				.AZ "Cut"
				.DA #14				ID
				.DA #S.MITEM.KEYMOD.OA
				.DA #'C'
				.AZ "Copy"
				.DA #16				ID
				.DA #S.MITEM.KEYMOD.OA
				.DA #'V'
				.AZ "Paste"
				.DA #0
*--------------------------------------
WND.MENU.OPTIONS	.DA #18				ID
				.DA #0
				.DA #0
				.AZ "Check Me"
				.DA #0
*--------------------------------------
WND.MENU.HELP	.DA #20				ID
				.DA #0
				.DA #0
				.AZ "About..."
				.DA #0
*--------------------------------------
				.DUMMY
				.OR 0
DS.START

DS.END			.ED
MAN
SAVE usr/src/sbin/gui.s
ASM
