| 1 |
lars |
1 |
/box-button-create {
|
|
|
2 |
box-inline-create % => Box
|
|
|
3 |
dup box-button-setup-methods
|
|
|
4 |
dup /box-button add-type
|
|
|
5 |
} def
|
|
|
6 |
|
|
|
7 |
/box-button-get-max-width { % => Context Box
|
|
|
8 |
box-container-get-max-width
|
|
|
9 |
} def
|
|
|
10 |
|
|
|
11 |
/box-button-get-min-width { % => Context Box
|
|
|
12 |
box-container-get-max-width
|
|
|
13 |
} def
|
|
|
14 |
|
|
|
15 |
/box-button-line-break-allowed { % => Box
|
|
|
16 |
pop false
|
|
|
17 |
} def
|
|
|
18 |
|
|
|
19 |
/box-button-reflow {
|
|
|
20 |
% Check if we need a line break here
|
|
|
21 |
|
|
|
22 |
3 copy /maybe-line-break call-method
|
|
|
23 |
pop
|
|
|
24 |
|
|
|
25 |
% Append to parent line box
|
|
|
26 |
|
|
|
27 |
dup 2 index box-container-append-line
|
|
|
28 |
|
|
|
29 |
% Determine coordinates of upper-left corner
|
|
|
30 |
|
|
|
31 |
2 copy
|
|
|
32 |
box-generic-guess-corner % => Context Parent This
|
|
|
33 |
|
|
|
34 |
% Determine the box width
|
|
|
35 |
|
|
|
36 |
2 index 1 index
|
|
|
37 |
/get-min-width call-method
|
|
|
38 |
1 index put-full-width % => Context Parent This
|
|
|
39 |
|
|
|
40 |
2 index 1 index
|
|
|
41 |
box-container-reflow-content % => Context Parent This
|
|
|
42 |
|
|
|
43 |
% center the button text vertically inside the button
|
|
|
44 |
|
|
|
45 |
dup get-content 0 get % => Context Parent This Text
|
|
|
46 |
dup get-top
|
|
|
47 |
1 index get-height 2 div sub % => Context Parent This Text TextMiddle
|
|
|
48 |
2 index get-top
|
|
|
49 |
3 index get-height 2 div sub % => Context Parent This Text TextMiddle ThisMiddle
|
|
|
50 |
sub
|
|
|
51 |
|
|
|
52 |
neg 0 % => Context Parent This Text -Delta 0
|
|
|
53 |
2 index /offset call-method % => Context Parent This Text
|
|
|
54 |
pop % => Context Parent This
|
|
|
55 |
|
|
|
56 |
% Now set the baseline of a button box to align it vertically when flowing isude the text line
|
|
|
57 |
|
|
|
58 |
dup get-content 0 get
|
|
|
59 |
get-default-baseline
|
|
|
60 |
1 index get-extra-top add
|
|
|
61 |
dup 2 index put-baseline
|
|
|
62 |
1 index put-default-baseline
|
|
|
63 |
|
|
|
64 |
% Offset parent curernt X coordinate
|
|
|
65 |
|
|
|
66 |
1 index get-current-x
|
|
|
67 |
1 index get-full-width
|
|
|
68 |
add
|
|
|
69 |
2 index put-current-x
|
|
|
70 |
|
|
|
71 |
% Extend parent height
|
|
|
72 |
|
|
|
73 |
dup get-bottom-margin
|
|
|
74 |
1 index box-generic-extend-height
|
|
|
75 |
|
|
|
76 |
pop pop pop
|
|
|
77 |
} def
|
|
|
78 |
|
|
|
79 |
/box-button-reflow-obsolete { % => Context Parent This
|
|
|
80 |
% append to parent line box
|
|
|
81 |
|
|
|
82 |
dup 2 index box-container-append-line
|
|
|
83 |
|
|
|
84 |
% Determine coordinates of upper-left _margin_ corner
|
|
|
85 |
|
|
|
86 |
2 copy box-generic-guess-corner % => Context Parent This
|
|
|
87 |
|
|
|
88 |
% Determine the box width
|
|
|
89 |
|
|
|
90 |
2 index 1 index
|
|
|
91 |
/get-min-width call-method
|
|
|
92 |
1 index put-full-width % => Context Parent This
|
|
|
93 |
|
|
|
94 |
2 index 1 index
|
|
|
95 |
box-container-reflow-content % => Context Parent This
|
|
|
96 |
|
|
|
97 |
% Offset content to align vertically in the button
|
|
|
98 |
% Make the text centered vertically
|
|
|
99 |
|
|
|
100 |
dup get-content 0 get % => Context Parent This C0
|
|
|
101 |
get-default-baseline 2 div % =>
|
|
|
102 |
1 index get-height 2 div add
|
|
|
103 |
|
|
|
104 |
1 index get-content 0 get
|
|
|
105 |
put-baseline
|
|
|
106 |
|
|
|
107 |
2 index context-pop-collapsed-margin
|
|
|
108 |
dup get-margin-bottom
|
|
|
109 |
3 index context-push-collapsed-margin
|
|
|
110 |
% => Context Parent This
|
|
|
111 |
|
|
|
112 |
dup get-content 0 get
|
|
|
113 |
get-baseline
|
|
|
114 |
1 index get-extra-top add % => Context Parent This DB
|
|
|
115 |
1 index put-default-baseline % => Context Parent This
|
|
|
116 |
|
|
|
117 |
% offset parent current X coordinate
|
|
|
118 |
|
|
|
119 |
dup get-full-width
|
|
|
120 |
2 index get-current-x add
|
|
|
121 |
2 index put-current-x
|
|
|
122 |
|
|
|
123 |
% extends parents height
|
|
|
124 |
|
|
|
125 |
dup get-bottom-margin
|
|
|
126 |
2 index box-generic-extend-height
|
|
|
127 |
|
|
|
128 |
pop pop pop
|
|
|
129 |
} def
|
|
|
130 |
|
|
|
131 |
/box-button-setup-methods {
|
|
|
132 |
dup /Methods get
|
|
|
133 |
dup /get-max-width {box-button-get-max-width} put
|
|
|
134 |
dup /get-min-width {box-button-get-min-width} put
|
|
|
135 |
dup /line-break-allowed {box-button-line-break-allowed} put
|
|
|
136 |
dup /reflow {box-button-reflow} put
|
|
|
137 |
dup /show {box-button-show} put
|
|
|
138 |
pop pop
|
|
|
139 |
} def
|
|
|
140 |
|
|
|
141 |
/box-button-show { % => Viewport This
|
|
|
142 |
box-container-show
|
|
|
143 |
} def
|