1
2
3
4
5
6
7
8
9
10
11
12
13
14\writestatus{loading}{ConTeXt Packaging Macros Objects}
15
16\unprotect
17
18\registerctxluafile{packobj}{}
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40\installcorenamespace {objects}
41
42\newif \ifinobject
43\newbox \objectbox
44
45\def\objectoffset{1cm}
46
47\newdimen\objectoff \def\objectmargin{\the\objectoff}
48\newdimen\objectwd \def\objectwidth {\the\objectwd}
49\newdimen\objectht \def\objectheight{\the\objectht}
50\newdimen\objectdp \def\objectdepth {\the\objectdp}
51
52
53
54
55\unexpanded\def\setreferencedobject #1#2{\begingroup\synctexpause\objectoff\objectoffset\inobjecttrue\dowithnextbox{\pack_objects_set_yes{#1}{#2}}}
56\unexpanded\def\settightreferencedobject #1#2{\begingroup\synctexpause\objectoff\zeropoint \inobjecttrue\dowithnextbox{\pack_objects_set_yes{#1}{#2}}}
57\unexpanded\def\setunreferencedobject #1#2{\begingroup\synctexpause\objectoff\objectoffset\inobjecttrue\dowithnextbox{\pack_objects_set_nop{#1}{#2}}}
58\unexpanded\def\settightunreferencedobject#1#2{\begingroup\synctexpause\objectoff\zeropoint \inobjecttrue\dowithnextbox{\pack_objects_set_nop{#1}{#2}}}
59
60\let\setobject \setreferencedobject
61\let\settightobject\settightreferencedobject
62
63
64
65\newconstant\c_pack_objects_offset_mode
66
67\unexpanded\def\pack_objects_set_yes#1#2
68 {\ifcase\c_pack_objects_offset_mode
69 \ifzeropt\objectoff
70 \pack_objects_package_nop\nextbox
71 \else
72 \pack_objects_package_yes\nextbox
73 \fi
74 \else
75 \pack_objects_package_nop\nextbox
76 \fi
77 \clf_registerreferencedobject{#1}{#2}\objectbox\objectoff\c_pack_objects_offset_mode
78 \synctexresume
79 \endgroup}
80
81\unexpanded\def\pack_objects_set_nop#1#2
82 {\ifcase\c_pack_objects_offset_mode
83 \ifzeropt\objectoff
84 \pack_objects_package_nop\nextbox
85 \else
86 \pack_objects_package_yes\nextbox
87 \fi
88 \else
89 \pack_objects_package_nop\nextbox
90 \fi
91 \clf_registerobject{#1}{#2}\objectbox\objectoff\c_pack_objects_offset_mode
92 \synctexresume
93 \endgroup}
94
95\def\pack_objects_package_nop#1
96 {\setbox\objectbox\hpack{\box#1}}
97
98\def\pack_objects_package_yes#1
99 {\objectwd\dimexpr\wd#12\objectoff\relax
100 \objectht\dimexpr\ht#1 \objectoff\relax
101 \objectdp\dimexpr\dp#1 \objectoff\relax
102 \setbox\objectbox\hpack
103 {\hskip\objectoff
104 \box#1}
105 \wd\objectbox\objectwd
106 \ht\objectbox\objectht
107 \dp\objectbox\objectdp}
108
109\unexpanded\def\getobject#1#2
110 {\begingroup
111 \synctexpause
112 \clf_restoreobject{#1}{#2}
113 \ifzeropt\objectoff\else
114 \objectoff\objectoff
115 \pack_objects_package_yes\objectbox
116 \fi
117 \box\objectbox
118 \synctexresume
119 \endgroup}
120
121
122
123
124
125
126
127
128
129
130\unexpanded\def\getobjectdimensions#1#2
131 {\clf_getobjectdimensions{#1}{#2}}
132
133
134
135
136
137
138
139
140
141
142
143\def\defaultobjectreference{0}
144\def\defaultobjectpage {\realfolio}
145
146\unexpanded\def\dogetobjectreference {\clf_getobjectreference}
147\unexpanded\def\dogetobjectreferencepage {\clf_getobjectreferencepage}
148
149\unexpanded\def\doifelseobjectfound {\clf_doifelseobject}
150\unexpanded\def\doifelseobjectreferencefound{\clf_doifelseobjectreference}
151
152\let\doifobjectfoundelse \doifelseobjectfound
153\let\doifobjectreferencefoundelse\doifelseobjectreferencefound
154
155
156
157\let\lastpredefinedsymbol\empty
158
159\unexpanded\def\predefinesymbol[#1]
160 {\begingroup
161 \xdef\lastpredefinedsymbol{#1}
162 \settightobject{SYM}{#1}\hbox{\symbol[#1]}
163 \dogetobjectreference{SYM}{#1}\m_back_object_reference
164 \clf_registerbackendsymbol{#1}\m_back_object_reference\relax
165 \endgroup}
166
167\protect \endinput
168 |