home *** CD-ROM | disk | FTP | other *** search
/ Mega Top 1 / os2_top1.zip / os2_top1 / APPS / TEKST / CMTEX330 / SOURCE / BOX.H < prev    next >
C/C++ Source or Header  |  1992-02-19  |  6KB  |  290 lines

  1.  
  2. /*
  3.  * %Y%:%M%:%I%:%Q%
  4.  *
  5.  * Copyright 1987,1988,1991 Pat J Monardo
  6.  *
  7.  * Redistribution of this file is permitted through
  8.  * the specifications in the file COPYING.
  9.  *
  10.  *
  11.  */
  12.  
  13. #define is_char_node(P)        ((P) != null && type(P) >= FONT_BASE)
  14. #define safe_is_char_node(P)    (type(P) >= FONT_BASE)
  15.  
  16. #define font            type
  17. #define character        subtype
  18.  
  19. #define HLIST_NODE        0
  20. #define VLIST_NODE        1
  21.  
  22. struct box_t {
  23.     mcell    node_field;
  24.     scal    width_field;
  25.     scal    depth_field;
  26.     scal    height_field;
  27.     scal    shift_field;
  28.     mcell    node_list_field;
  29.     ratio    glue_set_field;
  30. };
  31. typedef struct box_t box_t;
  32.  
  33. #define BOX_NODE_SIZE        (sizeof(box_t))
  34. #define box_width(B)        ((box_t *) (B))->width_field
  35. #define box_depth(B)        ((box_t *) (B))->depth_field
  36. #define box_height(B)        ((box_t *) (B))->height_field
  37. #define shift_amount(B)        ((box_t *) (B))->shift_field
  38. #define node_list(B)        ((ptr) & ((box_t *) (B))->node_list_field)
  39. #define list_ptr(B)        link(node_list(B))
  40. #define glue_order(B)        type(node_list(B))
  41. #define glue_sign(B)        subtype(node_list(B))
  42. #define glue_set(B)        ((box_t *) (B))->glue_set_field
  43. #define NORMAL            0
  44. #define STRETCHING        1
  45. #define SHRINKING        2
  46.  
  47. ptr    new_null_box();
  48.  
  49. #define RULE_NODE        2
  50.  
  51. struct rule_t {
  52.     mcell    node_field;
  53.     scal    width_field;
  54.     scal    depth_field;
  55.     scal    height_field;
  56. };
  57. typedef struct rule_t rule_t;
  58.  
  59. #define RULE_NODE_SIZE        (sizeof(rule_t))
  60. #define rule_width(R)        ((rule_t *) (R))->width_field
  61. #define rule_depth(R)        ((rule_t *) (R))->depth_field
  62. #define rule_height(R)        ((rule_t *) (R))->height_field
  63. #define NULL_FLAG        -010000000000
  64. #define is_running(R)        ((R) == NULL_FLAG)
  65.  
  66. ptr    new_rule();
  67.  
  68. #define INS_NODE        3
  69.  
  70. struct ins_t {
  71.     mcell    node_field;
  72.     int    cost_field;
  73.     scal    height_field;
  74.     scal    depth_field;
  75.     ptr    ins_field;
  76.     ptr    split_top_field;
  77. };
  78. typedef struct ins_t ins_t;
  79.  
  80. #define INS_NODE_SIZE        (sizeof(ins_t))
  81. #define float_cost(I)        ((ins_t *) (I))->cost_field
  82. #define ins_height(I)        ((ins_t *) (I))->height_field
  83. #define ins_depth(I)        ((ins_t *) (I))->depth_field
  84. #define ins_ptr(I)        ((ins_t *) (I))->ins_field
  85. #define split_top_ptr(I)    ((ins_t *) (I))->split_top_field
  86.  
  87. #define SMALL_NODE_SIZE        (2 * sizeof(mcell))
  88.  
  89. #define MARK_NODE        4
  90.  
  91. struct mark_t {
  92.     mcell    node_field;
  93.     ptr    mark_field;
  94.     int    fill_field;
  95. };
  96. typedef struct mark_t mark_t;
  97.  
  98. #define mark_ptr(M)        ((mark_t *) (M))->mark_field
  99.     
  100. #define ADJUST_NODE        5
  101.  
  102. struct adjust_t {
  103.     mcell    node_field;
  104.     ptr    adjust_field;
  105.     int    fill_field;
  106. };
  107. typedef struct adjust_t adjust_t;
  108.  
  109. #define adjust_ptr(A)        ((adjust_t *) (A))->adjust_field
  110.  
  111. #define LIGATURE_NODE        6
  112.  
  113. struct lig_t {
  114.     mcell    node_field;
  115.     mcell    lig_field;
  116. };
  117. typedef struct lig_t lig_t;
  118.  
  119. ptr    new_ligature();
  120. ptr    make_char_from_lig();
  121.     
  122. #define lig_char(L)        ((ptr) &((lig_t *) (L))->lig_field)
  123. #define lig_ptr(L)        link(lig_char(L))
  124.  
  125. struct disc_t {
  126.     mcell    node_field;
  127.     ptr    pre_field;
  128.     ptr    post_field;
  129. };
  130. typedef struct disc_t disc_t;
  131.  
  132. ptr    new_disc();
  133.  
  134. #define DISC_NODE        7
  135. #define replace_count        subtype
  136. #define pre_break(D)        ((disc_t *) (D))->pre_field
  137. #define post_break(D)        ((disc_t *) (D))->post_field
  138.  
  139. #define WHATSIT_NODE        8
  140.  
  141. #define MATH_NODE        9
  142.  
  143. struct math_t {
  144.     mcell    node_field;
  145.     scal    width_field;
  146.     int    fill_field;
  147. };
  148. typedef struct math_t math_t;
  149.  
  150. #define math_width(M)        ((math_t *) (M))->width_field
  151. #define BEFORE            0
  152. #define AFTER            1
  153.  
  154. ptr    new_math();
  155.  
  156. #define precedes_break(M)    (type(M) < MATH_NODE)
  157. #define non_discardable(M)    (type(M) < MATH_NODE)
  158.  
  159. #define GLUE_NODE        10
  160.  
  161. struct glue_t {
  162.     mcell    node_field;
  163.     ptr    glue_field;
  164.     ptr    leader_field;
  165. };
  166. typedef struct glue_t glue_t;
  167.  
  168. #define glue_ptr(G)        ((glue_t *) (G))->glue_field
  169. #define leader_ptr(G)        ((glue_t *) (G))->leader_field
  170. #define COND_MATH_GLUE        98
  171. #define MU_GLUE            99
  172. #define A_LEADERS        100
  173. #define C_LEADERS        101
  174. #define X_LEADERS        102
  175.  
  176. struct spec_t {
  177.     int    ref_count_field;
  178.     short    stretch_order_field;
  179.     short    shrink_order_field;
  180.     scal    width_field;
  181.     scal    stretch_field;
  182.     scal    shrink_field;
  183. };
  184. typedef struct spec_t spec_t;
  185.  
  186. #define GLUE_SPEC_SIZE        sizeof(spec_t)
  187. #define stretch_order(S)    ((spec_t *) (S))->stretch_order_field
  188. #define shrink_order(S)        ((spec_t *) (S))->shrink_order_field
  189. #define glue_ref_count(S)    ((spec_t *) (S))->ref_count_field
  190. #define glue_width(S)        ((spec_t *) (S))->width_field
  191. #define stretch(S)        ((spec_t *) (S))->stretch_field
  192. #define shrink(S)        ((spec_t *) (S))->shrink_field
  193. #define FIL            1
  194. #define FILL            2
  195. #define FILLL            3
  196.  
  197. ptr    new_spec();
  198. ptr    new_glue();
  199. ptr    new_param_glue();
  200. ptr    new_skip_param();
  201.  
  202. #define KERN_NODE        11
  203.  
  204. struct kern_t {
  205.     mcell    node_field;
  206.     scal    kern_field;
  207.     int    fill_field;
  208. };
  209. typedef struct kern_t kern_t;
  210.  
  211. #define kern_width(K)        ((kern_t *) (K))->kern_field
  212. #define EXPLICIT        1
  213. #define ACC_KERN        2
  214.  
  215. ptr    new_kern();
  216.  
  217. #define PENALTY_NODE        12
  218.  
  219. struct pen_t {
  220.     mcell    node_field;
  221.     int    penalty_field;
  222.     int    fill_field;
  223. };
  224. typedef struct pen_t pen_t;
  225.  
  226. #define penalty(P)        ((pen_t *) (P))->penalty_field
  227. #define INF_PENALTY        10000
  228. #define EJECT_PENALTY        -INF_PENALTY
  229.  
  230. ptr    new_penalty();
  231.  
  232. #define UNSET_NODE        13
  233.  
  234. struct unset_t {
  235.     mcell    node_field;
  236.     scal    width_field;
  237.     ptr    u_ptr_field;
  238.     ptr    v_ptr_field;
  239.     scal    stretch_field;
  240.     mcell    info_field;
  241.     scal    shrink_field;
  242. };
  243. typedef struct unset_t unset_t;
  244.  
  245. #define unset_span_count    subtype
  246. #define unset_span_list        llink
  247. #define    end_link        llink
  248. #define unset_width(U)        ((unset_t *) (U))->width_field
  249. #define u_part(U)        ((unset_t *) (U))->u_ptr_field
  250. #define v_part(U)        ((unset_t *) (U))->v_ptr_field
  251. #define unset_info(U)        info((ptr)&((unset_t *) (U))->info_field)
  252. #define unset_stretch(U)    ((unset_t *) (U))->stretch_field
  253. #define unset_shrink(U)        ((unset_t *) (U))->shrink_field
  254.  
  255. void    print_short_display();
  256. void    print_font_and_char();
  257. void    print_mark();
  258. void    print_rule_dimen();
  259. void    print_glue();
  260. void    print_spec(); 
  261. void    print_skip_param();
  262.  
  263. #define node_list_display(N) \
  264.     {append_char('.'); show_node_list(N); flush_char();}
  265.  
  266. global    fnt    font_in_short_display;
  267. global    int    depth_threshold;
  268. global    int    breadth_max;
  269.  
  270. void    show_box();
  271. void    short_display();
  272. void    show_node_list();
  273. ptr    copy_node_list();
  274. void    flush_node_list();
  275.  
  276. void    delete_glue_ref();
  277. #define fast_delete_glue_ref(G)    \
  278. {    if (glue_ref_count(G) == 0) { \
  279.         free_node(G, GLUE_SPEC_SIZE); \
  280.     } else { \
  281.         decr(glue_ref_count(G)); \
  282.     } \
  283. }
  284.  
  285. #define add_glue_ref(G) \
  286.     (incr(glue_ref_count(G)))
  287.  
  288. void    _box_init();
  289. void    _box_init_once();
  290.