A2osX/LIB/LIBGUI.S.WND.txt
2020-09-15 16:48:35 +02:00

813 lines
13 KiB
Plaintext
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

NEW
AUTO 3,1
*--------------------------------------
WND.Init >PUSHBI 0
>LDYA L.DEVNAME.GFX
>SYSCALL2 open
bcs .9
sta WND.Screen+S.OBJ.hPARENT
>LDYA L.DCB.GFX
>STYA IOCTL+S.IOCTL.BUFPTR
lda #S.IOCTL.STATCODE.GETDCB
sta IOCTL+S.IOCTL.STATCODE
>PUSHB WND.Screen+S.OBJ.hPARENT
>PUSHBI IOCTL.STATUS
>PUSHW L.IOCTL
>SYSCALL2 IOCTL
.9 rts
*--------------------------------------
WND.Setup >LDYA DCB.GFX+S.DCB.GFX.W
>STYA WND.Screen+S.OBJ.W
>STYA WND.Desktop+S.OBJ.W
>STYA WND.SysBar+S.OBJ.W
lda SYSFON.H
clc
adc #6
sta WND.SysBar+S.OBJ.H
lda DCB.GFX+S.DCB.GFX.H
sta WND.Screen+S.OBJ.H
sec
sbc WND.SysBar+S.OBJ.H
sta WND.Desktop+S.OBJ.H
sta WND.SysBar+S.OBJ.X1
lda DCB.GFX+S.DCB.GFX.H+1
sta WND.SysBar+S.OBJ.H+1
sbc #0
sta WND.Desktop+S.OBJ.H+1
sta WND.SysBar+S.OBJ.X1+1
>LDYA L.WND.Screen
jsr OBJ.SetX2Y2
>LDYA L.WND.Desktop
>STYA WND.Screen.Childs
jsr OBJ.SetX2Y2
>LDYA L.WND.SysBar
>STYA WND.Screen.Childs+2
jsr OBJ.SetX2Y2
lda #CUR.T.ARROW
sta WND.Desktop+S.WND.hCUR
sta WND.SysBar+S.WND.hCUR
stz WND.Stack.Top
rts
*--------------------------------------
WND.Quit lda WND.Screen+S.OBJ.hPARENT
beq .8
pha
>PUSHBI IOCTL.CLOSE
>PUSHWZ
pla
>SYSCALL2 IOCTL
.8 clc
rts
*--------------------------------------
* F8, X116, Y116, W16, H16
*--------------------------------------
WND.Create ldy WND.Stack.Top
cpy #WND.MAX
bcs .90
>LDYAI S.WND
>SYSCALL2 getmem
bcs .9
>STYA ZPWNDPtr
lda #S.OBJ.T.WND
sta (ZPWNDPtr) S.OBJ.T
ldy #S.WND-1
lda #0
.1 sta (ZPWNDPtr),y
dey
bne .1
>PULLA
ldy #S.OBJ.H
sta (ZPWNDPtr),y
>PULLA
iny
sta (ZPWNDPtr),y
>PULLA
ldy #S.OBJ.W
sta (ZPWNDPtr),y
>PULLA
iny
sta (ZPWNDPtr),y
>PULLA
ldy #S.OBJ.Y1
sta (ZPWNDPtr),y
>PULLA
iny
sta (ZPWNDPtr),y
>PULLA
ldy #S.OBJ.X1
and PREFS.BESTVIEWEDX
sta (ZPWNDPtr),y
>PULLA
iny
sta (ZPWNDPtr),y
>PULLA
ldy #S.OBJ.F
sta (ZPWNDPtr),y
ldy #S.PS.PID
lda (pPs),y
ldy #S.OBJ.hOWNER
sta (ZPWNDPtr),y
txa ID
ldy WND.Stack.Top
sta WND.Stack
inc WND.Stack.Top
* clc
rts
.90 lda #E.OOH
.9 >RET 9
*--------------------------------------
* hWND8, Prop8, Value16
*--------------------------------------
WND.SetProp ldy #3
lda (pStack),y hWND
>SYSCALL2 GetMemPtr
>STYA ZPWNDPtr
ldy #2
lda (pStack),y
tay
>PULLA
sta (ZPWNDPtr),y
iny
>PULLA
sta (ZPWNDPtr),y
>RET 2
*--------------------------------------
* hWND8, Prop8
*--------------------------------------
WND.GetProp >PULLA
pha
>PULLA
>SYSCALL2 GetMemPtr
>STYA ZPWNDPtr
ply
lda (ZPWNDPtr),y
pha
iny
lda (ZPWNDPtr),y
ply
rts
*--------------------------------------
* A = hWND
*--------------------------------------
WND.Show >SYSCALL2 GetMemPtr
>STYA ZPWNDPtr
jsr OBJ.SetX2Y2
jsr GetCBBuf
bcs .9
stz Counter X
stz Counter+1 Y
ldy #S.OBJ.F
lda (ZPWNDPtr),y
and #S.WND.F.RESIZE+S.WND.F.BORDER
beq .1
jsr WND.PaintBorders
.1 ldy #S.WND.TITLE+1
lda (ZPWNDPtr),y
bne .2
ldy #S.OBJ.S
lda (ZPWNDPtr),y
and #S.WND.F.MOVE+S.WND.F.CLOSE+S.WND.F.MIN+S.WND.F.MAX
beq .3
.2 lda Counter+1
clc
adc SYSFON.Hp2
sta Counter+1
lda #S.WND.S.HASTOPBAR
jsr WND.SetStatus
jsr WND.PaintTopBar
bcs .9
.3 ldy #S.WND.MENUBAR+1
lda (ZPWNDPtr),y
beq .7
lda Counter+1
clc
adc SYSFON.Hp2
sta Counter+1
lda #S.WND.S.HASMENUBAR
jsr WND.SetStatus
jsr WND.PaintMenuBar
.7 ldy #S.WND.STATUS+1
lda (ZPWNDPtr),y
beq .8
lda Counter+1
clc
adc SYSFON.Hp2
sta Counter+1
lda #S.WND.S.HASSTATUSBAR
jsr WND.SetStatus
jsr WND.PaintStatusBar
.8 lda #0
jsr PutA2CBBuf
>LDYA L.WND.Screen
jsr DrawToYA
lda hCBBuf
>SYSCALL FreeMem
clc
.9 rts
*--------------------------------------
WND.New clc
rts
*--------------------------------------
WND.Paint >STYA ZPWNDPtr
clc
rts
*--------------------------------------
WND.PaintBorders
lda #S.CB.CMD.HLINE TOP
jsr WND.PaintBorders.H
ldy #S.OBJ.X1
jsr WND.PaintPushWYm1
ldy #S.OBJ.Y1
jsr WND.PaintPushWYm1
ldy #S.OBJ.X2
jsr WND.PaintPushWYp1
ldy #S.OBJ.Y1
jsr WND.PaintPushWYm1
lda #S.CB.CMD.VLINE LEFT
jsr WND.PaintBorders.H
ldy #S.OBJ.X1
jsr WND.PaintPushWYm1
ldy #S.OBJ.Y1
jsr WND.PaintPushWYm1
ldy #S.OBJ.X1
jsr WND.PaintPushWYm1
ldy #S.OBJ.Y2
jsr WND.PaintPushWYp1
lda #S.CB.CMD.VLINE RIGHT
jsr WND.PaintBorders.H
ldy #S.OBJ.X2
jsr WND.PaintPushWYp1
ldy #S.OBJ.Y1
jsr WND.PaintPushWYm1
ldy #S.OBJ.X2
jsr WND.PaintPushWYp1
ldy #S.OBJ.Y2
jsr WND.PaintPushWYp1
lda #S.CB.CMD.HLINE BOTTOM
jsr WND.PaintBorders.H
ldy #S.OBJ.X1
jsr WND.PaintPushWYm1
ldy #S.OBJ.Y2
jsr WND.PaintPushWYp1
ldy #S.OBJ.X2
jsr WND.PaintPushWYp1
ldy #S.OBJ.Y2
jsr WND.PaintPushWYp1
rts
WND.PaintBorders.H
jsr PutA2CBBuf
lda #S.CB.OP.SET
jsr PutA2CBBuf
lda #S.CB.M.MONO
jsr PutA2CBBuf
lda PREFS.BORDERCOLOR
jmp PutA2CBBuf
WND.PaintPushWYm1
lda (ZPWNDPtr),y
sec
sbc #1
jsr PutA2CBBuf
iny
lda (ZPWNDPtr),y
sbc #0
jsr PutA2CBBuf
rts
WND.PaintPushWYp1
lda (ZPWNDPtr),y
clc
adc #1
jsr PutA2CBBuf
iny
adc #0
lda (ZPWNDPtr),y
jsr PutA2CBBuf
rts
*--------------------------------------
WND.PaintTopBar lda #S.CB.CMD.FILLRECT
jsr PutA2CBBuf
lda #S.CB.OP.SET
jsr PutA2CBBuf
lda #S.CB.M.C16
jsr PutA2CBBuf
ldx PREFS.TOPBARCOLORI
ldy #S.OBJ.S
lda (ZPWNDPtr),y
and #S.WND.S.ACTIVE
beq .10
ldx PREFS.TOPBARCOLORA
.10 txa
jsr PutA2CBBuf
ldy #S.OBJ.X1
lda (ZPWNDPtr),y
jsr PutA2CBBuf
iny
lda (ZPWNDPtr),y
jsr PutA2CBBuf
iny ldy #S.OBJ.Y1
lda (ZPWNDPtr),y
jsr PutA2CBBuf
iny
lda (ZPWNDPtr),y
jsr PutA2CBBuf
iny ldy #S.OBJ.X2
lda (ZPWNDPtr),y
jsr PutA2CBBuf
iny
lda (ZPWNDPtr),y
jsr PutA2CBBuf
ldy #S.OBJ.Y1
lda (ZPWNDPtr),y
sec
adc SYSFON.H
jsr PutA2CBBuf
iny
lda (ZPWNDPtr),y
adc #0
jsr PutA2CBBuf
* TOP LEFT ICON
ldy #S.WND.ICON+1
lda (ZPWNDPtr),y
tax
dey
ora (ZPWNDPtr),y
bne .1
lda L.BM.Apple
ldx L.BM.Apple+1
bra .2
.1 lda (ZPWNDPtr),y
.2 sta ZPObjPtr
stx ZPObjPtr+1
lda #0
ldx #0
jsr WND.PaintTopBarBMAtAX
jsr WND.PaintTopBarTitle
bcs .9
* TOP RIGHT ICONS
ldy #S.OBJ.F
lda (ZPWNDPtr),y
bit #S.WND.F.CLOSE
beq .3
pha
lda L.BM.Close
ldx L.BM.Close+1
sta ZPObjPtr
stx ZPObjPtr+1
ldy #S.OBJ.W
lda (ZPWNDPtr),y
sec
sbc #16
pha
iny
lda (ZPWNDPtr),y
sbc #0
tax
pla
jsr WND.PaintTopBarBMAtAX
pla
.3 bit #S.WND.F.MIN
beq .4
pha
lda L.BM.Min
ldx L.BM.Min+1
sta ZPObjPtr
stx ZPObjPtr+1
ldy #S.OBJ.W
lda (ZPWNDPtr),y
sec
sbc #32
pha
iny
lda (ZPWNDPtr),y
sbc #0
tax
pla
jsr WND.PaintTopBarBMAtAX
pla
.4 bit #S.WND.F.MAX
beq .8
lda L.BM.Max
ldx L.BM.Max+1
sta ZPObjPtr
stx ZPObjPtr+1
ldy #S.OBJ.W
lda (ZPWNDPtr),y
sec
sbc #48
pha
iny
lda (ZPWNDPtr),y
sbc #0
tax
pla
jsr WND.PaintTopBarBMAtAX
.8 clc
.9 rts
*--------------------------------------
WND.PaintTopBarBMAtAX
clc
ldy #S.OBJ.X1
adc (ZPWNDPtr),y
pha
iny
txa
adc (ZPWNDPtr),y
tax
lda #S.CB.CMD.BITBLT
jsr PutA2CBBuf
lda #S.CB.OP.MASK+S.CB.OP.ORA+S.CB.OP.COLOR
jsr PutA2CBBuf
lda #S.CB.M.C16
jsr PutA2CBBuf
lda #0
jsr PutA2CBBuf
pla S.CB.X1
jsr PutAX2CBBuf
ldy #S.OBJ.Y1 S.CB.Y1
lda (ZPWNDPtr),y
clc
adc #1
jsr PutA2CBBuf
iny
lda (ZPWNDPtr),y
adc #0
jsr PutA2CBBuf
lda #0 S.CB.X2
jsr PutA2CBBuf
jsr PutA2CBBuf
jsr PutA2CBBuf S.CB.Y2
jsr PutA2CBBuf
jsr PutA2CBBuf S.CB.SrcX
jsr PutA2CBBuf
jsr PutA2CBBuf S.CB.SrcY
jsr PutA2CBBuf
ldx #4
ldy #S.BM.W
.1 lda (ZPObjPtr),y S.CB.SrcW,S.CB.SrcH
jsr PutA2CBBuf
iny
dex
bne .1
lda ZPObjPtr S.CB.SrcPtr
jsr PutA2CBBuf
lda ZPObjPtr+1
jsr PutA2CBBuf
lda #0 S.CB.DstPtr
jsr PutA2CBBuf
jsr PutA2CBBuf
rts
*--------------------------------------
WND.PaintTopBarTitle
jsr CB.Clear
lda #S.CB.CMD.DRAWTEXT+S.CB.CMD.OSD
sta CB.Cache+S.CB.CMD
lda #S.CB.OP.SET+S.CB.OP.INVERSE
sta CB.Cache+S.CB.OP
lda #S.CB.M.MONO
sta CB.Cache+S.CB.M
lda hSYSFONB
sta CB.Cache+S.CB.hFont
ldy #S.WND.TITLE
lda (ZPWNDPtr),y
sta CB.Cache+S.CB.TxtPtr
iny
lda (ZPWNDPtr),y
sta CB.Cache+S.CB.TxtPtr+1
jsr GFXWrite.CB
bcs .9
ldy #S.OBJ.W
lda (ZPWNDPtr),y
sec
sbc CB.Cache+S.CB.SrcW
sta DX
iny
lda (ZPWNDPtr),y
sbc CB.Cache+S.CB.SrcW+1
lsr
ror DX
sta DX+1
ldy #S.OBJ.X1
lda (ZPWNDPtr),y
clc
adc DX
and PREFS.BESTVIEWEDX
sta CB.Cache+S.CB.X1
iny
lda (ZPWNDPtr),y
adc DX+1
sta CB.Cache+S.CB.X1+1
ldy #S.OBJ.Y1
lda (ZPWNDPtr),y
clc
adc #1
sta CB.Cache+S.CB.Y1
iny
lda (ZPWNDPtr),y
adc #0
sta CB.Cache+S.CB.Y1+1
jsr PutCBCache2CBBuf
clc
.9 rts
*--------------------------------------
WND.PaintMenuBar
ldy #S.WND.MENUBAR
lda (ZPWNDPtr),y
sta ZPMENUPtr
iny
lda (ZPWNDPtr),y
sta ZPMENUPtr+1
lda (ZPMENUPtr)
bne .1
>LDYA ZPMENUPtr
jsr MENU.MenubarInit
.1
clc
.9 rts
*--------------------------------------
WND.PaintStatusBar
lda #S.CB.CMD.HLINE
jsr WND.PaintBorders.H
ldy #S.OBJ.X1
lda (ZPWNDPtr),y
jsr PutA2CBBuf
iny
lda (ZPWNDPtr),y
jsr PutA2CBBuf
ldy #S.OBJ.Y2
lda (ZPWNDPtr),y
sec
sbc SYSFON.H
jsr PutA2CBBuf
iny
lda (ZPWNDPtr),y
sbc #0
jsr PutA2CBBuf
ldy #S.OBJ.X2
lda (ZPWNDPtr),y
jsr PutA2CBBuf
iny
lda (ZPWNDPtr),y
jsr PutA2CBBuf
lda #0
jsr PutA2CBBuf
jsr PutA2CBBuf
jsr CB.Clear S.CB.Y2
lda #S.CB.CMD.DRAWTEXT+S.CB.CMD.OSD
sta CB.Cache+S.CB.CMD
lda #S.CB.OP.SET+S.CB.OP.INVERSE
sta CB.Cache+S.CB.OP
lda #S.CB.M.MONO
sta CB.Cache+S.CB.M
lda hSYSFON
sta CB.Cache+S.CB.hFont
ldy #S.WND.STATUS
lda (ZPWNDPtr),y
sta CB.Cache+S.CB.TxtPtr
iny
lda (ZPWNDPtr),y
sta CB.Cache+S.CB.TxtPtr+1
jsr GFXWrite.CB
bcs .9
ldy #S.OBJ.X1
lda (ZPWNDPtr),y
sta CB.Cache+S.CB.X1
iny
lda (ZPWNDPtr),y
sta CB.Cache+S.CB.X1+1
ldy #S.OBJ.Y2
lda (ZPWNDPtr),y
sec
sbc SYSFON.Hm1
sta CB.Cache+S.CB.Y1
iny
lda (ZPWNDPtr),y
sbc #0
sta CB.Cache+S.CB.Y1+1
jsr PutCBCache2CBBuf
lda #S.CB.CMD.FILLRECT
sta CB.Cache+S.CB.CMD
lda #S.CB.OP.SET
sta CB.Cache+S.CB.OP
lda #S.CB.M.MONO
sta CB.Cache+S.CB.M
lda #C.WHITE
sta CB.Cache+S.CB.OP.COLOR
lda CB.Cache+S.CB.X1
clc
adc CB.Cache+S.CB.SrcW
sta CB.Cache+S.CB.X1
lda CB.Cache+S.CB.X1+1
adc CB.Cache+S.CB.SrcW+1
sta CB.Cache+S.CB.X1+1
ldy #S.OBJ.X2
lda (ZPWNDPtr),y
sta CB.Cache+S.CB.X2
iny
lda (ZPWNDPtr),y
sta CB.Cache+S.CB.X2+1
ldy #S.OBJ.Y2
lda (ZPWNDPtr),y
sta CB.Cache+S.CB.Y2
iny
lda (ZPWNDPtr),y
sta CB.Cache+S.CB.Y2+1
jsr PutCBCache2CBBuf
clc
.9 rts
*--------------------------------------
WND.ClrStatus ldy #S.OBJ.S
eor #$ff
and (ZPWNDPtr),y
sta (ZPWNDPtr),y
rts
*--------------------------------------
WND.SetStatus ldy #S.OBJ.S
ora (ZPWNDPtr),y
sta (ZPWNDPtr),y
rts
*--------------------------------------
WND.Close clc
rts
*--------------------------------------
MAN
SAVE usr/src/lib/libgui.s.wnd
LOAD usr/src/lib/libgui.s
ASM