Files
luos/thirdparty/html2ps_pdf/postscript/box.button.ps
Paula Quispe 9eb7d6cac2 HOR-2689
2017-08-03 17:00:30 -04:00

144 lines
3.4 KiB
PostScript

/box-button-create {
box-inline-create % => Box
dup box-button-setup-methods
dup /box-button add-type
} def
/box-button-get-max-width { % => Context Box
box-container-get-max-width
} def
/box-button-get-min-width { % => Context Box
box-container-get-max-width
} def
/box-button-line-break-allowed { % => Box
pop false
} def
/box-button-reflow {
% Check if we need a line break here
3 copy /maybe-line-break call-method
pop
% Append to parent line box
dup 2 index box-container-append-line
% Determine coordinates of upper-left corner
2 copy
box-generic-guess-corner % => Context Parent This
% Determine the box width
2 index 1 index
/get-min-width call-method
1 index put-full-width % => Context Parent This
2 index 1 index
box-container-reflow-content % => Context Parent This
% center the button text vertically inside the button
dup get-content 0 get % => Context Parent This Text
dup get-top
1 index get-height 2 div sub % => Context Parent This Text TextMiddle
2 index get-top
3 index get-height 2 div sub % => Context Parent This Text TextMiddle ThisMiddle
sub
neg 0 % => Context Parent This Text -Delta 0
2 index /offset call-method % => Context Parent This Text
pop % => Context Parent This
% Now set the baseline of a button box to align it vertically when flowing isude the text line
dup get-content 0 get
get-default-baseline
1 index get-extra-top add
dup 2 index put-baseline
1 index put-default-baseline
% Offset parent curernt X coordinate
1 index get-current-x
1 index get-full-width
add
2 index put-current-x
% Extend parent height
dup get-bottom-margin
1 index box-generic-extend-height
pop pop pop
} def
/box-button-reflow-obsolete { % => Context Parent This
% append to parent line box
dup 2 index box-container-append-line
% Determine coordinates of upper-left _margin_ corner
2 copy box-generic-guess-corner % => Context Parent This
% Determine the box width
2 index 1 index
/get-min-width call-method
1 index put-full-width % => Context Parent This
2 index 1 index
box-container-reflow-content % => Context Parent This
% Offset content to align vertically in the button
% Make the text centered vertically
dup get-content 0 get % => Context Parent This C0
get-default-baseline 2 div % =>
1 index get-height 2 div add
1 index get-content 0 get
put-baseline
2 index context-pop-collapsed-margin
dup get-margin-bottom
3 index context-push-collapsed-margin
% => Context Parent This
dup get-content 0 get
get-baseline
1 index get-extra-top add % => Context Parent This DB
1 index put-default-baseline % => Context Parent This
% offset parent current X coordinate
dup get-full-width
2 index get-current-x add
2 index put-current-x
% extends parents height
dup get-bottom-margin
2 index box-generic-extend-height
pop pop pop
} def
/box-button-setup-methods {
dup /Methods get
dup /get-max-width {box-button-get-max-width} put
dup /get-min-width {box-button-get-min-width} put
dup /line-break-allowed {box-button-line-break-allowed} put
dup /reflow {box-button-reflow} put
dup /show {box-button-show} put
pop pop
} def
/box-button-show { % => Viewport This
box-container-show
} def