File: box

package info (click to toggle)
libtemplate-perl 2.14-1
  • links: PTS
  • area: main
  • in suites: etch, etch-m68k, sarge
  • size: 5,496 kB
  • ctags: 667
  • sloc: perl: 15,349; makefile: 62; xml: 7; sh: 5
file content (111 lines) | stat: -rw-r--r-- 2,466 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
% blx bly trx try box
% create a new box array
/box {
    4 array astore
} def

% box box-select
% unpacks box to define various box-* variables
/box-select {
    aload pop
    /box-try exch def
    /box-trx exch def
    /box-bly exch def
    /box-blx exch def
    /box-width  box-trx box-blx sub abs def
    /box-height box-try box-bly sub abs def
} def

% box box-rect
% output box as a rect suitable for rectstoke etc.
/box-rect {
    box-select
    box-blx box-bly box-width box-height
} def

% box box-path
% output box as a path suitable for stroke, clip, etc.
/box-path {
    box-select
    newpath
    box-blx box-bly moveto
    box-blx box-try lineto
    box-trx box-try lineto
    box-trx box-bly lineto
    closepath 
} def

% box border box-border
% create a new box bordered within a box
/box-border {
    /border exch def
    box-select
    box-blx border add 
    box-bly border add
    box-trx border sub 
    box-try border sub 
    box
} def

% box tiles space pad box-vsplit
% split box vertically into 'tiles' new boxes, spaced apart by 'space' 
% and padded within the original box by 'pad'
/box-vsplit {
    /box-pad   exch def
    /box-space exch def    
    /box-tiles exch def
    box-select
    /box-height 
      box-try box-bly sub 
      box-pad 2 mul sub 
      box-space box-tiles 1 sub mul sub 
      box-tiles div
      def
    /box-width
      box-trx box-blx sub 
      box-pad 2 mul sub 
      def
    /box-blx box-blx box-pad add def
    /box-bly box-bly box-pad add def
    1 1 box-tiles {
      pop
      box-blx box-bly box-blx box-width add box-bly box-height add box
      /box-bly box-bly box-height add box-space add def
    } for
} def 

% box tiles space pad box-hsplit
% as per box-vsplit, splitting box horizontally
/box-hsplit {
    /box-pad   exch def
    /box-space exch def    
    /box-tiles exch def
    box-select
    /box-height box-height 
      box-pad 2 mul sub 
      def
    /box-width box-width
      box-pad 2 mul sub 
      box-space box-tiles 1 sub mul sub 
      box-tiles div
      def
    /box-blx box-blx box-pad add def
    /box-bly box-bly box-pad add def
    1 1 box-tiles {
      pop
      box-blx box-bly box-blx box-width add box-bly box-height add box
      /box-blx box-blx box-width add box-space add def
    } for
} def 

/box-focus {
    /box-box exch def
    gsave
    box-box box-select
    box-box box-path clip
    box-blx box-bly translate
} def

/box-defocus {
    grestore
} def