A2osX/LIB/LIBGUI.S.WND.txt
2021-06-05 17:48:54 +02:00

995 lines
16 KiB
Plaintext
Raw Permalink 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 >PUSHW L.DEVNAME.GFX
>PUSHBI 0
>SYSCALL2 open
bcs .9
sta WND.Screen+S.OBJ.hPARENT
>LDYA L.DCB.GFX
>STYA IOCTL+S.IOCTL.BUFPTR
lda #S.IOCTL.S.GETDCB
sta IOCTL+S.IOCTL.S
>PUSHB WND.Screen+S.OBJ.hPARENT
>PUSHBI IOCTL.STATUS
>PUSHW L.IOCTL
>SYSCALL2 IOCTL
.9 rts
*--------------------------------------
WND.Setup
* stz WND.Stack.Top
* stz MENU.Stack.Top
>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.Hp2
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.Y1
sta RECT.SysBut+S.RECT.Y1
sta RECT.SysWNDs+S.RECT.Y1
sta RECT.SysClk+S.RECT.Y1
lda DCB.GFX+S.DCB.GFX.H
dec
sta RECT.SysBut+S.RECT.Y2
sta RECT.SysWNDs+S.RECT.Y2
sta RECT.SysClk+S.RECT.Y2
>LDYA L.WND.Screen
>STYA WND.Desktop+S.OBJ.hPARENT
>STYA WND.SysBar+S.OBJ.hPARENT
jsr OBJ.SetX2Y2
>LDYA L.WND.Desktop
jsr OBJ.SetX2Y2
>LDYA L.WND.SysBar
jsr OBJ.SetX2Y2
>LDYA L.WND.SysBar.2osX
ldx hSYSFON
jsr FON.GetTextSize
lda CB.Cache+S.CB.SrcW
clc
adc #24 4 + BM width + 4
sta RECT.SysBut+S.RECT.X2
sta RECT.SysWNDs+S.RECT.X1
>LDYA L.WND.SysBar.Clk
ldx hSYSFON
jsr FON.GetTextSize
lda CB.Cache+S.CB.SrcW
sec for sbc below
adc #8 4 + 00:00 + 4
sta RECT.SysWNDs+S.RECT.X2
lda DCB.GFX+S.DCB.GFX.W
sec
sbc RECT.SysWNDs+S.RECT.X2
sta RECT.SysWNDs+S.RECT.X2
sta RECT.SysClk+S.RECT.X1
lda DCB.GFX+S.DCB.GFX.W+1
sbc #0
sta RECT.SysWNDs+S.RECT.X2+1
sta RECT.SysClk+S.RECT.X1+1
lda DCB.GFX+S.DCB.GFX.W
clc
sbc #0
sta RECT.SysClk+S.RECT.X2
lda DCB.GFX+S.DCB.GFX.W
sbc #0
sta RECT.SysClk+S.RECT.X2+1
jsr SYSBAR.Show
rts
*--------------------------------------
WND.Quit lda WND.Screen+S.OBJ.hPARENT
beq .8
pha
>PUSHBI IOCTL.CLOSE
>PUSHWZ
pla
>SYSCALL2 IOCTL
.8 clc
WND.Quit.RTS rts
*--------------------------------------
* F8, X116, Y116, W16, H16
*--------------------------------------
WND.New >LDYAI S.WND
>SYSCALL2 getmem
bcs .9
>STYA ZPWNDPtr
ldy WND.Stack.Top
cpy #WND.MAX
bcc .10
lda #E.OOH
.9 >POP 9
rts
.10 lda #S.OBJ.T.WND
sta (ZPWNDPtr) S.OBJ.T
ldy #S.WND-1
lda #0
.1 sta (ZPWNDPtr),y
dey
bne .1
ldy #S.WND.fPaint
lda L.WND.fPaint
sta (ZPWNDPtr),y
iny
lda L.WND.fPaint+1
sta (ZPWNDPtr),y
>PULLA
ldy #S.OBJ.H
sta (ZPWNDPtr),y
pha
>PULLA
iny
sta (ZPWNDPtr),y
ldy #S.WND.InnerH+1
sta (ZPWNDPtr),y
pla
dey
sta (ZPWNDPtr),y
>PULLA
ldy #S.OBJ.W
sta (ZPWNDPtr),y
pha
>PULLA
iny
sta (ZPWNDPtr),y
ldy #S.WND.InnerW+1
sta (ZPWNDPtr),y
pla
dey
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
bit #S.WND.F.RESIZE
beq .2
ora #S.WND.F.BORDER
.2 ldy #S.OBJ.F
sta (ZPWNDPtr),y
ldy #S.PS.PID
lda (pPs),y
ldy #S.OBJ.hOWNER
sta (ZPWNDPtr),y
lda L.WND.Desktop
ldy #S.OBJ.hPARENT
sta (ZPWNDPtr),y
iny
lda L.WND.Desktop+1
sta (ZPWNDPtr),y
txa ID
* clc
rts
*--------------------------------------
WND.Destroy clc
rts
*--------------------------------------
WND.Activate >SYSCALL2 GetMemPtr
>STYA ZPWNDPtr
clc
WND.Activate.RTS
rts
*--------------------------------------
WND.Bring2Front ldx WND.Stack.Idx
cpx WND.Stack.Top
beq WND.Activate.RTS
lda WND.Stack-1,x
pha
.1 lda WND.Stack,x
sta WND.Stack-1,x
inx
cpx WND.Stack.Top
bne .1
dec WND.Stack.Top
.2 pla
*--------------------------------------
* A = hWND
*--------------------------------------
WND.Show sta WND.hWND
ldx WND.Stack.Top
beq WND.Show1
lda WND.Stack-1,x
>SYSCALL2 GetMemPtr
>STYA ZPWNDPtr
lda #S.WND.S.ACTIVE
jsr WND.ClrStatus
jsr GetCBBuf
bcs WND.Activate.RTS
jsr WND.PaintTopBar
WND.Show1 lda WND.hWND
ldy WND.Stack.Top
sta WND.Stack,y
inc WND.Stack.Top
>SYSCALL2 GetMemPtr
>STYA ZPWNDPtr
jsr OBJ.SetX2Y2
WND.Show2 jsr GetCBBuf
bcs WND.Activate.RTS
lda #S.WND.S.ACTIVE
jsr WND.SetStatus
ldy #S.OBJ.Y1
lda (ZPWNDPtr),y
tax
iny
lda (ZPWNDPtr),y
ldy #S.WND.TBarY2+1
sta (ZPWNDPtr),y
txa
dey
sta (ZPWNDPtr),y
stz Counter X
stz Counter+1 Y
ldy #S.OBJ.F
lda (ZPWNDPtr),y
and #S.WND.F.BORDER
beq .1
lda #1
jsr WND.ShowBorders
.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
ldy #S.WND.TBarY2
lda (ZPWNDPtr),y
clc
adc SYSFON.Hp2
sta (ZPWNDPtr),y
iny
lda (ZPWNDPtr),y
adc #0
sta (ZPWNDPtr),y
lda #S.WND.S.HASTBAR
jsr WND.SetStatus
jsr WND.PaintTopBar
bcs .9
*--------------------------------------
.3 ldy #S.WND.MBAR+1
lda (ZPWNDPtr),y
beq .7
lda Counter+1
clc
adc SYSFON.Hp2
sta Counter+1
ldy #S.WND.TBarY2
lda (ZPWNDPtr),y
clc
adc SYSFON.H
tax
iny
lda (ZPWNDPtr),y
adc #0
ldy #S.WND.MBarY2+1
sta (ZPWNDPtr),y
txa
dey
sta (ZPWNDPtr),y
lda #S.WND.S.HASMBAR
jsr WND.SetStatus
jsr WND.PaintMBar
*--------------------------------------
.7 ldy #S.WND.STATUS+1
lda (ZPWNDPtr),y
beq .8
lda Counter+1
clc
adc SYSFON.Hp2
sta Counter+1
ldy #S.OBJ.Y2
lda (ZPWNDPtr),y
sec
sbc SYSFON.H
tax
iny
lda (ZPWNDPtr),y
sbc #0
ldy #S.WND.SBarY1+1
sta (ZPWNDPtr),y
txa
dey
sta (ZPWNDPtr),y
lda #S.WND.S.HASSBAR
jsr WND.SetStatus
jsr WND.PaintSBar
*--------------------------------------
.8 ldy #S.WND.InnerH
lda (ZPWNDPtr),y
sec
sbc Counter+1
sta (ZPWNDPtr),y
iny
lda (ZPWNDPtr),y
sbc #0
sta (ZPWNDPtr),y
>LDYA L.WND.Desktop
jsr DrawCBBufToYA
lda WND.hWND
pha
bra WND.Paint1
.9
WND.Show.RTS rts
*--------------------------------------
WND.Paint pha hWND
>SYSCALL2 GetMemPtr
>STYA ZPWNDPtr
WND.Paint1 ldy #S.WND.fPaint
lda (ZPWNDPtr),y
sta ZPPtr1
iny
lda (ZPWNDPtr),y
sta ZPPtr1+1
pla
jmp (ZPPtr1)
*--------------------------------------
WND.fPaint >SYSCALL2 GetMemPtr
>STYA ZPWNDPtr
jsr GetCBBuf
bcs WND.Show.RTS
lda #S.CB.CMD.FILLRECT
sta CB.Cache+S.CB.CMD
lda #S.CB.OP.SET+S.CB.OP.COLOR
sta CB.Cache+S.CB.OP
lda #S.CB.M.MONO
sta CB.Cache+S.CB.M
ldy #S.WND.BGCOLOR
lda (ZPWNDPtr),y
sta CB.Cache+S.CB.COLOR
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.WND.InnerY1
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
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.WND.InnerY2
lda (ZPWNDPtr),y
sec
sbc #1
sta CB.Cache+S.CB.Y2
iny
lda (ZPWNDPtr),y
sbc #0
sta CB.Cache+S.CB.Y2+1
jsr PutCBCache2CBBuf
ldy #S.WND.BGBM
lda (ZPWNDPtr),y
sta CB.Cache+S.CB.SrcPtr
iny
ora (ZPWNDPtr),y
beq .8
lda (ZPWNDPtr),y
sta CB.Cache+S.CB.SrcPtr+1
stz S.CB.SrcX
stz S.CB.SrcX+1
stz S.CB.SrcY
stz S.CB.SrcY+1
ldy #S.WND.InnerW+3
ldx #3
.1 lda (ZPWNDPtr),y
sta CB.Cache+S.CB.SrcW,x
dey
dex
bpl .1
lda #S.CB.CMD.BITBLT
sta CB.Cache+S.CB.CMD
jsr PutCBCache2CBBuf
.8 >LDYA L.WND.Desktop
jmp DrawCBBufToYA
*--------------------------------------
WND.ShowBorders sta IY
lda #S.CB.CMD.HLINE
jsr CB.InitCacheA
lda #S.CB.OP.SET
sta CB.Cache+S.CB.OP
lda #S.CB.M.MONO
sta CB.Cache+S.CB.M
lda PREFS.BORDERCOLOR
sta CB.Cache+S.CB.COLOR
ldy #S.OBJ.X1
lda (ZPWNDPtr),y
sec
sbc IY
sta CB.Cache+S.CB.X1
iny
lda (ZPWNDPtr),y
sbc #0
sta CB.Cache+S.CB.X1+1
iny #S.OBJ.Y1
lda (ZPWNDPtr),y
sec
sbc IY
sta CB.Cache+S.CB.Y1
sta CB.Cache+S.CB.Y2
iny
lda (ZPWNDPtr),y
sbc #0
sta CB.Cache+S.CB.Y1+1
sta CB.Cache+S.CB.Y2+1 top X1-1,Y1-1,X2+1,Y1-1
iny #S.OBJ.X2
lda (ZPWNDPtr),y
clc
adc IY
sta CB.Cache+S.CB.X2
iny
lda (ZPWNDPtr),y
adc #0
sta CB.Cache+S.CB.X2+1
jsr PutCBCache2CBBuf
ldy #S.OBJ.Y2
lda (ZPWNDPtr),y
clc
adc IY
sta CB.Cache+S.CB.Y1
sta CB.Cache+S.CB.Y2
iny
lda (ZPWNDPtr),y
adc #0
sta CB.Cache+S.CB.Y1+1
sta CB.Cache+S.CB.Y2+1 bottom X1-1,Y2+1,X2+1,Y2+1
jsr PutCBCache2CBBuf
lda #S.CB.CMD.VLINE
sta CB.Cache+S.CB.CMD
ldy #S.OBJ.Y1
lda (ZPWNDPtr),y
sec
sbc IY
sta CB.Cache+S.CB.Y1
iny
lda (ZPWNDPtr),y
sbc #0
sta CB.Cache+S.CB.Y1+1
lda CB.Cache+S.CB.X1
sta CB.Cache+S.CB.X2
lda CB.Cache+S.CB.X1+1
sta CB.Cache+S.CB.X2+1 left X1-1,Y1-1,X1-1,Y2+1
jsr PutCBCache2CBBuf
ldy #S.OBJ.X2
lda (ZPWNDPtr),y
clc
adc IY
sta CB.Cache+S.CB.X1
sta CB.Cache+S.CB.X2
iny
lda (ZPWNDPtr),y
adc #0
sta CB.Cache+S.CB.X1+1
sta CB.Cache+S.CB.X2+1 right X2+1,Y1-1,X2+1,Y2+1
jmp PutCBCache2CBBuf
*--------------------------------------
WND.PaintTopBar lda #S.CB.CMD.FILLRECT
jsr CB.InitCacheA
lda #S.CB.OP.SET
sta CB.Cache+S.CB.OP
lda #S.CB.M.C16
sta CB.Cache+S.CB.M
ldx PREFS.TBARCOLORI
ldy #S.OBJ.S
lda (ZPWNDPtr),y
and #S.WND.S.ACTIVE
beq .10
ldx PREFS.TBARCOLORA
.10 stx CB.Cache+S.CB.COLOR
ldy #S.OBJ.X1+5 X1,Y1,X2
ldx #5
.11 lda (ZPWNDPtr),y
sta CB.Cache+S.CB.X1,x
dey
dex
bpl .11
>LDYA CB.Cache+S.CB.X1
>STYA DX
ldy #S.OBJ.Y1
lda (ZPWNDPtr),y
sta DY
sec
adc SYSFON.H
sta CB.Cache+S.CB.Y2
iny
lda (ZPWNDPtr),y
sta DY+1
adc #0
sta CB.Cache+S.CB.Y2+1
jsr PutCBCache2CBBuf
inc DY
bne .12
inc DY+1
* TOP LEFT ICON
.12 ldy #S.WND.ICON+1
lda (ZPWNDPtr),y
tax
dey
ora (ZPWNDPtr),y
bne .1
>LDYA L.BM.Apple
bra .2
.1 lda (ZPWNDPtr),y
tay
txa
.2 jsr DRAW.yaBMAtDXDY
jsr WND.PaintTopBarTitle
bcs .9
* TOP RIGHT ICONS
ldy #S.OBJ.X2
lda (ZPWNDPtr),y
sec
sbc #48
sta DX
iny
lda (ZPWNDPtr),y
sbc #0
sta DX+1
ldy #S.OBJ.F
lda (ZPWNDPtr),y
bit #S.WND.F.MIN
beq .3
ldx #BM.ID.MIN
jsr DRAW.xBMAtDXDY
.3 lda DX
clc
adc #16
sta DX
bcc .31
inc DX+1
.31 ldy #S.OBJ.F
lda (ZPWNDPtr),y
bit #S.WND.F.MAX
beq .4
ldx #BM.ID.MAX
jsr DRAW.xBMAtDXDY
.4 lda DX
clc
adc #16
sta DX
bcc .41
inc DX+1
.41 ldy #S.OBJ.F
lda (ZPWNDPtr),y
bit #S.WND.F.CLOSE
beq .8
ldx #BM.ID.CLOSE
jsr DRAW.xBMAtDXDY
.8 clc
.9 rts
*--------------------------------------
WND.PaintTopBarTitle
ldy #S.WND.TITLE
lda (ZPWNDPtr),y
pha
iny
lda (ZPWNDPtr),y
ply
ldx hSYSFONB
jsr FON.GetTextSize
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 DX
iny
lda (ZPWNDPtr),y
adc DX+1
sta DX+1
ldy #S.WND.TITLE
lda (ZPWNDPtr),y
pha
iny
lda (ZPWNDPtr),y
ply
ldx hSYSFONB
clc
jmp DRAW.YATextAtDXDY
*--------------------------------------
WND.PaintMBar lda #S.CB.CMD.FILLRECT
jsr CB.InitCacheA
lda #S.CB.OP.SET
sta CB.Cache+S.CB.OP
lda #S.CB.M.MONO
sta CB.Cache+S.CB.M
lda PREFS.MBARCOLOR
sta CB.Cache+S.CB.COLOR
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.X2
lda (ZPWNDPtr),y
sta CB.Cache+S.CB.X2
iny
lda (ZPWNDPtr),y
sta CB.Cache+S.CB.X2+1
ldy #S.WND.MBarY1
lda (ZPWNDPtr),y
sta CB.Cache+S.CB.Y1
iny
lda (ZPWNDPtr),y
sta CB.Cache+S.CB.Y1+1
iny #S.WND.MBarY2
lda (ZPWNDPtr),y
sta CB.Cache+S.CB.Y2
iny
lda (ZPWNDPtr),y
sta CB.Cache+S.CB.Y2+1
jsr PutCBCache2CBBuf
ldy #S.WND.MBAR
lda (ZPWNDPtr),y
pha
iny
lda (ZPWNDPtr),y
ply
jsr MBAR.Init
.1 lda (ZPMENUPtr)
beq .8
jsr CB.ClearCache
lda #S.CB.CMD.DRAWTEXT2
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.MBITEM.XT
lda (ZPMENUPtr),y
clc
ldy #S.OBJ.X1
adc (ZPWNDPtr),y
sta CB.CACHE+S.CB.X1
ldy #S.MBITEM.XT+1
lda (ZPMENUPtr),y
ldy #S.OBJ.X1+1
adc (ZPWNDPtr),y
sta CB.CACHE+S.CB.X1+1
ldy #S.WND.MBarY1
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
lda #S.MBITEM.TEXT
clc
adc ZPMENUPtr
sta CB.CACHE+S.CB.TxtPtr
lda #0
adc ZPMENUPtr+1
sta CB.CACHE+S.CB.TxtPtr+1
jsr PutCBCache2CBBuf
lda (ZPMENUPtr)
clc
adc ZPMENUPtr
sta ZPMENUPtr
bcc .1
inc ZPMENUPtr+1
bra .1
.8 clc
rts
*--------------------------------------
WND.PaintSBar lda #S.CB.CMD.HLINE
jsr CB.InitCacheA
lda #S.CB.OP.SET
sta CB.Cache+S.CB.OP
lda #S.CB.M.MONO
sta CB.Cache+S.CB.M
lda PREFS.BORDERCOLOR
sta CB.Cache+S.CB.COLOR
ldy #S.OBJ.X1
lda (ZPWNDPtr),y
sta CB.Cache+S.CB.X1
sta DX
iny
lda (ZPWNDPtr),y
sta CB.Cache+S.CB.X1+1
sta DX+1
ldy #S.WND.SBarY1
lda (ZPWNDPtr),y
sta CB.Cache+S.CB.Y1
clc
adc #1
sta DY
iny
lda (ZPWNDPtr),y
sta CB.Cache+S.CB.Y1+1
adc #0
sta DY+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
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 PREFS.SBARCOLOR
sta CB.Cache+S.CB.COLOR
inc CB.Cache+S.CB.Y1
bne .1
inc CB.Cache+S.CB.Y1+1
.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
ldy #S.WND.STATUS
lda (ZPWNDPtr),y
pha
iny
lda (ZPWNDPtr),y
ply
ldx hSYSFON
clc
jmp DRAW.YATextAtDXDY
*--------------------------------------
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
*--------------------------------------
MAN
SAVE usr/src/lib/libgui.s.wnd
LOAD usr/src/lib/libgui.s
ASM