antoine-source/appleworksgs/WP/Src/PageDlg.aii
2023-03-04 03:45:20 +01:00

1 line
16 KiB
Plaintext
Executable File

load 'macros.dump'
include 'driver.equ'
include 'wp.equ'
;-----------------------------------------------
;
; Imported addresses
;
;-----------------------------------------------
IMPORT D_CloseDialog
IMPORT D_DigitsOnly
IMPORT D_GetNewModalDialog
;-----------------------------------------------
;
; Forward addresses and entries
;
;-----------------------------------------------
ENTRY W_AllStr
ENTRY W_DrawRectItem
ENTRY W_EvenStr
ENTRY W_FirstStr
ENTRY W_HeaderStr
ENTRY W_NoneStr
ENTRY W_OddStr
ENTRY W_pagedlg
ENTRY W_PageDlgFilter
ENTRY W_def_page
ENTRY W_f_all
ENTRY W_f_allval
ENTRY W_f_even
ENTRY W_f_evenval
ENTRY W_f_first
ENTRY W_f_firstval
ENTRY W_f_none
ENTRY W_f_noneval
ENTRY W_f_odd
ENTRY W_f_oddval
ENTRY W_ffdimmed
ENTRY W_FootRect
ENTRY W_FootRectItem
ENTRY W_footerStr
ENTRY W_footerTitle
ENTRY W_h_all
ENTRY W_h_allval
ENTRY W_h_even
ENTRY W_h_evenval
ENTRY W_h_first
ENTRY W_h_firstval
ENTRY W_h_none
ENTRY W_h_noneval
ENTRY W_h_odd
ENTRY W_h_oddval
ENTRY W_HeadRect
ENTRY W_HeadRectItem
ENTRY W_headerTitle
ENTRY W_hfdimmed
ENTRY W_pageTitle
ENTRY W_PageTstr
ENTRY W_pageEdit
ENTRY W_pd_cancelstr
ENTRY W_pd_okstr
ENTRY W_pd_cancel
ENTRY W_pd_ok
ENTRY W_thepage
****************************************************************
* ;
* W_pagedlg -- goto and set page dialogs ;
* ;
****************************************************************
********************************************************************
* Includes...
*
* Tuesday, May 2, 1989 11:34:22 PM
********************************************************************
****************************************************************
*
* W_GotoPage -> pagenum:w -- prompts the user for a page number
* and returns it. If the user cancels, returns -1.
*
****************************************************************
W_GotoPage PROC EXPORT
local dialog:l,theitem:w
output pagenum:w
begin +b
spacelong
pushlong #w_go2pdlog
jsl D_GetNewModalDialog
pulllong dialog
loop spaceword
pushlong #D_DigitsOnly+$80000000
_ModalDialog
pullword theitem
beq loop
cmp #3 ; is it a button?
bge loop
button cmp #1 ; OK?
beq done
moveword #-1,pagenum
brl bye ; must be Cancel
done pushlong dialog
pushword #4
pushlong #pagestring
_GetIText
spaceword
pushlong #pagestring+1
lda pagestring
and #$ff
pha
pushword #0
_Dec2Int
pullword pagenum
bye pushlong dialog
jsl D_CloseDialog
return
pagestring str ' '
;---------------------------------------------------------------------------
; Goto Page Dialog >>> STOLEN FROM PAGE LAYOUT <<<
;
; 1 = OK
; 2 = Cancel
; 3 = 'Go to page'
; 4 = PageCount
w_Go2PDlog
DC.W 48,185,101,462
DC.W 1
DC.L 0
DC.L w_GotoOK,w_GotoCancel,w_GotoText,w_GotoPgCnt
DC.L 0
w_GotoOK
DC.W 1
DC.W 34,165,47,230
DC.W $000A
DC.L w_OKTxt
DC.W 0
DC.W 0
DC.L 0
w_oktxt str 'OK'
w_GotoCancel
DC.W 2
DC.W 34,40,47,105
DC.W $000A
DC.L w_CancelTxt
DC.W 0
DC.W 0
DC.L 0
w_canceltxt str 'Cancel'
w_GotoText
DC.W 3
DC.W 10,80,23,161
DC.W $800F
DC.L w_GotoTextMsg
DC.W 0
DC.W 0
DC.L 0
w_GotoTextMsg STR 'Go to page'
w_GotoPgCnt
DC.W 4
DC.W 8,165,21,203
DC.W $8011
DC.L w_Pages2
DC.W 3
DC.W 0
DC.W 0
w_Pages2 STR '1'
ENDP
****************************************************************
*
* W_PageDialog(oldpage:w,oldstat:w) -> pagenum:w,status:w
*
* Pagenum is the page number typed by the user.
* Status is a bit Q_Mask containing some combination of
* the bit flags HksipFirst, W_HonEven, W_HonOdd,....
* If the user cancels, pagenum = -1, status = 0.
*
****************************************************************
W_PageDialog PROC EXPORT
EXPORT SetPage
SetPage ;
;Using W_PageDlgData
input oldpage:w,oldstat:w
output pagenum:w,status:w
local dialog:l,theitem:w
begin +b
stz W_hfdimmed
stz W_ffdimmed
stz status
moveword #-1,pagenum
pushword oldpage
pushlong #W_def_page+1
lda oldpage ; find string length
cmp #100
blt notthree
lda #3
bra gotlen
notthree cmp #10
blt nottwo
lda #2
bra gotlen
nottwo lda #1
gotlen sta W_def_page
pha
pushword #0 ; unsigned
_Int2Dec
stz W_f_firstval
stz W_f_oddval
stz W_f_evenval
stz W_f_allval
stz W_f_noneval
stz W_h_firstval
stz W_h_oddval
stz W_h_evenval
stz W_h_allval
stz W_h_noneval
lda oldstat
bit #W_HSkipFirst
beq nohfirst
inc W_h_firstval
nohfirst bit #W_HonOdd
beq nohodd
bit #W_HonEven
beq nohall
inc W_h_allval
bra getfeet
nohall inc W_h_oddval
bra getfeet
nohodd bit #W_HonEven
beq noheven
inc W_h_evenval
bra getfeet
noheven inc W_h_noneval
getfeet bit #W_FSkipFirst
beq noffirst
inc W_f_firstval
noffirst bit #W_FonOdd
beq nofodd
bit #W_FonEven
beq nofall
inc W_f_allval
bra gotvals
nofall inc W_f_oddval
bra gotvals
nofodd bit #W_FonEven
beq nofeven
inc W_f_evenval
bra gotvals
nofeven inc W_f_noneval
gotvals spacelong
pushlong #W_pagedlg
jsl D_GetNewModalDialog
pulllong dialog
loop spaceword
pushlong #W_PageDlgFilter+$80000000
_ModalDialog
pullword theitem
beq loop
lda theitem
cmp #$100 ; button?
jlt bye
cmp #$200 ; radio?
bge notradio
pushword #1
pushlong dialog
pushword theitem
_SetDitemValue
bra loop
notradio cmp #$300 ; check?
bge loop
spaceword
pushlong dialog
pushword theItem
_GetDitemValue
pla
eor #1
pha
pushlong dialog
pushword theitem
_SetDitemValue
bra loop
bye cmp #1
bne exit
lda #0
clc
ldx W_h_firstval
beq hnofirst
adc #W_HSkipFirst
hnofirst ldx W_h_noneval
bne putfeet
ldx W_h_allval
beq hnoall
adc #W_HonEven+W_HonOdd
bra putfeet
hnoall ldx W_h_evenval
beq hnoeven
adc #W_HonEven
bra putfeet
hnoeven adc #W_HonOdd
putfeet ldx W_f_firstval
beq fnofirst
adc #W_FSkipFirst
fnofirst ldx W_f_noneval
bne gotstat
ldx W_f_allval
beq fnoall
adc #W_FonEven+W_FonOdd
bra gotstat
fnoall ldx W_f_evenval
beq fnoeven
adc #W_FonEven
bra gotstat
fnoeven adc #W_FonOdd
gotstat sta status
moveword W_thepage,pagenum
exit pushlong dialog
jsl D_CloseDialog
return
ENDP
****************************************************************
*
* W_PageDlgFilter -- maintain the First Page check boxes
*
****************************************************************
W_PageDlgFilter PROC EXPORT
;Using W_PageDlgData
input dlgptr:l,eventptr:l,itemptr:l
output handled:w
local parity:w
begin +b
spaceword
pushlong dlgptr
pushlong eventptr
pushlong itemptr
jsl D_DigitsOnly
pla
sta handled
jne exit ; if D_DigitsOnly took it, just exit.
spaceword
pushlong dlgptr
pushword W_h_none
_GetDItemValue
pullword W_h_noneval
spaceword
pushlong dlgptr
pushword W_h_even
_GetDItemValue
pullword W_h_evenval
spaceword
pushlong dlgptr
pushword W_h_odd
_GetDItemValue
pullword W_h_oddval
spaceword
pushlong dlgptr
pushword W_h_all
_GetDItemValue
pullword W_h_allval
spaceword
pushlong dlgptr
pushword W_h_first
_GetDItemValue
pullword W_h_firstval
spaceword
pushlong dlgptr
pushword W_f_none
_GetDItemValue
pullword W_f_noneval
spaceword
pushlong dlgptr
pushword W_f_even
_GetDItemValue
pullword W_f_evenval
spaceword
pushlong dlgptr
pushword W_f_odd
_GetDItemValue
pullword W_f_oddval
spaceword
pushlong dlgptr
pushword W_f_all
_GetDItemValue
pullword W_f_allval
spaceword
pushlong dlgptr
pushword W_f_first
_GetDItemValue
pullword W_f_firstval
pushlong dlgptr
pushword W_pageEdit
pushlong #W_def_page
_GetIText
spaceword
pushlong #W_def_page+1 ; pointer to Q_Text
lda W_def_page ; length
and #$ff
pha
pushword #0 ; unsigned
_Dec2Int
pullword W_thepage
lda W_thepage
and #1
sta parity
lda W_h_noneval
bne dimhfirst
lda W_h_allval
bne usehfirst
cmpw parity,W_h_oddval
bne dimhfirst
usehfirst lda W_hfdimmed
beq getfeet
pushword #0 ; D_Activate the control
spacelong
pushlong dlgptr
pushword W_h_first
_GetControlDItem
_HiliteControl
stz W_hfdimmed
bra getfeet
dimhfirst lda W_hfdimmed
bne getfeet
pushword #255 ; deactivate the control
spacelong
pushlong dlgptr
pushword W_h_first
_GetControlDItem
_HiliteControl
inc W_hfdimmed
getfeet lda W_f_noneval
bne dimffirst
lda W_f_allval
bne useffirst
cmpw parity,W_f_oddval
bne dimffirst
useffirst lda W_ffdimmed
beq exit
pushword #0 ; D_Activate the control
spacelong
pushlong dlgptr
pushword W_f_first
_GetControlDItem
_HiliteControl
stz W_ffdimmed
bra exit
dimffirst lda W_ffdimmed
bne exit
pushword #255 ; deactivate the control
spacelong
pushlong dlgptr
pushword W_f_first
_GetControlDItem
_HiliteControl
inc W_ffdimmed
exit return
ENDP
****************************************************************
*
* W_DrawRectItem -- draw the rectangle
*
****************************************************************
W_DrawRectItem PROC EXPORT
;Using W_PageDlgData
input dlgport:l,id:w
local rectptr:l
begin +b
pushlong dlgport
_SetPort
cmpw id,#$501 ; which Q_Rect?
bne foot
movelong #W_HeadRect,rectptr
bra drawit
foot movelong #W_FootRect,rectptr
drawit _PenNormal
pushlong rectptr
_EraseRect
pushword #2
pushword #1
_SetPenSize
pushlong rectptr
_FrameRect
return
ENDP
****************************************************************
*
* W_PageDlgData
*
****************************************************************
W_PageDlgData PROC EXPORT
EXPORT W_thepage
EXPORT W_hfdimmed
EXPORT W_ffdimmed
EXPORT W_pagedlg
EXPORT W_pd_ok
EXPORT W_pd_okstr
EXPORT W_pd_cancel
EXPORT W_pd_cancelstr
EXPORT W_h_none
EXPORT W_h_noneval
EXPORT W_h_even
EXPORT W_h_evenval
EXPORT W_h_odd
EXPORT W_h_oddval
EXPORT W_h_all
EXPORT W_h_allval
EXPORT W_f_none
EXPORT W_f_noneval
EXPORT W_f_even
EXPORT W_f_evenval
EXPORT W_f_odd
EXPORT W_f_oddval
EXPORT W_f_all
EXPORT W_f_allval
EXPORT W_NoneStr
EXPORT W_EvenStr
EXPORT W_OddStr
EXPORT W_AllStr
EXPORT W_h_first
EXPORT W_h_firstval
EXPORT W_f_first
EXPORT W_f_firstval
EXPORT W_FirstStr
EXPORT W_headerTitle
EXPORT W_HeaderStr
EXPORT W_footerTitle
EXPORT W_footerStr
EXPORT W_pageTitle
EXPORT W_PageTstr
EXPORT W_pageEdit
EXPORT W_def_page
EXPORT W_HeadRectItem
EXPORT W_HeadRect
EXPORT W_FootRectItem
EXPORT W_FootRect
W_thepage DC.W 1
W_hfdimmed DS.B 2
W_ffdimmed DS.B 2
W_pagedlg
DC.W 48,152,172,488 ; --- DIALOG TEMPLATE ---
DC.W 1 ; visible
DC.L 666 ; refcon
DC.L W_pageEdit ; edit lines ($3xx)
DC.L W_pd_ok ; W_Buttons ($0xx)
DC.L W_pd_cancel
DC.L W_h_none ; radio W_Buttons ($1xx)
DC.L W_h_even
DC.L W_h_odd
DC.L W_h_all
DC.L W_f_none
DC.L W_f_even
DC.L W_f_odd
DC.L W_f_all
DC.L W_h_first ; check boxes ($2xx)
DC.L W_f_first
DC.L W_headerTitle ; static Q_Text ($4xx)
DC.L W_footerTitle
DC.L W_pageTitle
DC.L W_HeadRectItem ; user items ($5xx)
DC.L W_FootRectItem
DC.L 0
*--------------------------------------------------------------*
W_pd_ok
DC.W 1 ; Item id
DC.W 105,192,118,268 ; Item bounds
DC.W $000A ; item type (Button)
DC.L W_pd_okstr ; item descriptor
DC.W 0 ; item value
DC.W 0 ; bit vector
DC.L 0 ; default color table
W_pd_okstr str 'OK'
W_pd_cancel
DC.W 2 ; Item id
DC.W 105,68,118,144 ; Item bounds
DC.W $000A ; item type (Button)
DC.L W_pd_cancelstr ; item descriptor
DC.W 0 ; item value
DC.W 0 ; bit vector
DC.L 0 ; default color table
W_pd_cancelstr str 'Cancel'
*--------------------------------------------------------------*
W_h_none
DC.W $101 ; Item id
DC.W 51,18,62,146 ; Item bounds
DC.W $000C ; item type (RadioItem)
DC.L W_NoneStr ; item descriptor
W_h_noneval
DC.W 1 ; item value
DC.W 1 ; bit vector (family)
DC.L 0 ; default color table
W_h_even
DC.W $102 ; Item id
DC.W 27,18,38,146 ; Item bounds
DC.W $000C ; item type (RadioItem)
DC.L W_EvenStr ; item descriptor
W_h_evenval
DC.W 0 ; item value
DC.W 1 ; bit vector (family)
DC.L 0 ; default color table
W_h_odd
DC.W $103 ; Item id
DC.W 39,18,50,146 ; Item bounds
DC.W $000C ; item type (RadioItem)
DC.L W_OddStr ; item descriptor
W_h_oddval DC.W 0 ; item value
DC.W 1 ; bit vector (family)
DC.L 0 ; default color table
W_h_all
DC.W $104 ; Item id
DC.W 15,18,26,146 ; Item bounds
DC.W $000C ; item type (RadioItem)
DC.L W_AllStr ; item descriptor
W_h_allval DC.W 0 ; item value
DC.W 1 ; bit vector (family)
DC.L 0 ; default color table
W_f_none
DC.W $111 ; Item id
DC.W 51,184,62,292 ; Item bounds
DC.W $000C ; item type (RadioItem)
DC.L W_NoneStr ; item descriptor
W_f_noneval
DC.W 1 ; item value
DC.W 2 ; bit vector (family)
DC.L 0 ; default color table
W_f_even
DC.W $112 ; Item id
DC.W 27,184,38,292 ; Item bounds
DC.W $000C ; item type (RadioItem)
DC.L W_EvenStr ; item descriptor
W_f_evenval
DC.W 0 ; item value
DC.W 2 ; bit vector (family)
DC.L 0 ; default color table
W_f_odd
DC.W $113 ; Item id
DC.W 39,184,50,292 ; Item bounds
DC.W $000C ; item type (RadioItem)
DC.L W_OddStr ; item descriptor
W_f_oddval
DC.W 0 ; item value
DC.W 2 ; bit vector (family)
DC.L 0 ; default color table
W_f_all
DC.W $114 ; Item id
DC.W 15,184,26,292 ; Item bounds
DC.W $000C ; item type (RadioItem)
DC.L W_AllStr ; item descriptor
W_f_allval
DC.W 0 ; item value
DC.W 2 ; bit vector (family)
DC.L 0 ; default color table
W_NoneStr str 'None'
W_EvenStr str 'Even Pages Only'
W_OddStr str 'Odd Pages Only'
W_AllStr str 'All Pages'
*--------------------------------------------------------------*
W_h_first
DC.W $201 ; Item id
DC.W 66,18,77,150 ; Item bounds
DC.W $000B ; item type (CheckItem)
DC.L W_FirstStr ; item descriptor
W_h_firstval
DC.W 0 ; item value
DC.W 2 ; bit vector
DC.L 0 ; default color table
W_f_first
DC.W $211 ; Item id
DC.W 66,184,77,320 ; Item bounds
DC.W $000B ; item type (CheckItem)
DC.L W_FirstStr ; item descriptor
W_f_firstval
DC.W 0 ; item value
DC.W 2 ; bit vector
DC.L 0 ; default color table
W_FirstStr str 'Skip First Page'
*--------------------------------------------------------------*
W_headerTitle
DC.W $301 ; Item id
DC.W 5,20,16,86 ; Item bounds
DC.W $800f ; item type (StatText+Disable)
DC.L W_HeaderStr ; item descriptor
DC.W 0 ; item value
DC.W 0 ; bit vector
DC.L 0 ; default color table
W_HeaderStr str ' Headers:'
W_footerTitle
DC.W $302 ; Item id
DC.W 5,186,16,252 ; Item bounds
DC.W $800f ; item type (StatText+Disable)
DC.L W_footerStr ; item descriptor
DC.W 0 ; item value
DC.W 0 ; bit vector
DC.L 0 ; default color table
W_footerStr str ' Footers:'
W_pageTitle
DC.W $303 ; Item id
DC.W 88,82,99,216 ; Item bounds
DC.W $800f ; item type (StatText+Disable)
DC.L W_PageTstr ; item descriptor
DC.W 0 ; item value
DC.W 0 ; bit vector
DC.L 0 ; default color table
W_PageTstr str 'First Page Number:'
*--------------------------------------------------------------*
W_pageEdit
DC.W $401 ; Item id
DC.W 86,216,99,252 ; Item bounds
DC.W $0011 ; item type (EditLine)
DC.L W_def_page ; item descriptor
DC.W 3 ; item value
DC.W 0 ; bit vector
DC.L 0 ; default color table
W_def_page str '666' ; default string
*--------------------------------------------------------------*
W_HeadRectItem
DC.W $501 ; Item id
W_HeadRect
DC.W 10,10,80,160 ; Item bounds
DC.W $8014 ; item type (UserItem+Disable)
DC.L W_DrawRectItem ; item descriptor
DC.W 0 ; item value
DC.W 0 ; bit vector
DC.L 0 ; default color table
W_FootRectItem
DC.W $502 ; Item id
W_FootRect
DC.W 10,176,80,326 ; Item bounds
DC.W $8014 ; item type (UserItem+Disable)
DC.L W_DrawRectItem ; item descriptor
DC.W 0 ; item value
DC.W 0 ; bit vector
DC.L 0 ; default color table
ENDP
END