root/morphix/trunk/gfxboot-grub/button.inc

Revision 2, 2.8 kB (checked in by nextime, 2 years ago)

Initial import, branching from morphix svn

Line 
1 % - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
2 %
3 % button handling
4 %
5 % - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
6
7
8 % - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
9 % Button templates.
10 %
11 % [ x y width height label selected hotkey action ]
12 %
13 /button.ok       { [ 0 0 85 25 txt_ok       false 0      0 ] } def
14 /button.cancel   { [ 0 0 85 25 txt_cancel   false keyEsc 0 ] } def
15 /button.reboot   { [ 0 0 85 25 txt_reboot   false 0      0 ] } def
16 /button.continue { [ 0 0 85 25 txt_continue false 0      0 ] } def
17 % /button.eject    { [ 0 0 85 25 "Eject"      false 0      0 ] } def
18
19
20 % - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
21 % Set default button.
22 %
23 % ( button ) => ( button )
24 %
25 /button.default {
26   dup 5 true put
27 } def
28
29
30 % - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
31 % Make it _not_ the default button.
32 %
33 % ( button ) => ( button )
34 %
35 /button.notdefault {
36   dup 5 false put
37 } def
38
39
40 % - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
41 % Set button position.
42 %
43 % ( button x y ) ==> ( button )
44 %
45 /button.moveto {
46   rot dup 0 5 -1 roll put exch over 1 rot put
47 } def
48
49
50 % - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
51 % Assign action to button.
52 %
53 % ( button action ) => ( button )
54 %
55 /button.setaction {
56   over 7 rot put
57 } def
58
59
60 % - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
61 % Draw button.
62 %
63 % ( button ) ==> ( )
64 %
65 /button.show {
66   /bt.x over 0 get def
67   /bt.y over 1 get def
68   /bt.width over 2 get def
69   /bt.height over 3 get def
70   /bt.text over 4 get def
71   /bt.default exch 5 get def
72
73   bt.text strsize
74   bt.height sub neg 2 div /bt.y.textofs exch def
75   bt.width sub neg 2 div /bt.x.textofs exch def
76
77   bt.x bt.y moveto
78   currentpoint currentpoint currentpoint
79
80   currentpoint bt.width bt.height window.current .color.bg get setcolor fillrect moveto
81
82   bt.default {
83     black black
84   } {
85     window.current .color.bg get dup
86   } ifelse
87   bt.width bt.height drawborder
88   moveto 1 1 rmoveto white black bt.width 2 sub bt.height 2 sub drawborder
89   moveto
90   % 2 2 rmoveto white black bt.width 4 sub bt.height 4 sub drawborder
91
92   window.current .color.fg get setcolor
93   moveto bt.x.textofs bt.y.textofs rmoveto bt.text show
94 } def
95
96
97 % - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
98 % Press button.
99 %
100 % ( button ) ==> ( )
101 %
102 /button.press {
103   /bt.x over 0 get def
104   /bt.y over 1 get def
105   /bt.width over 2 get def
106   /bt.height exch 3 get def
107
108   bt.x 3 add bt.y 3 add moveto
109   bt.width 7 sub bt.height 7 sub savescreen
110   1 1 rmoveto dup restorescreen free
111
112   bt.x 1 add bt.y 1 add moveto black white bt.width 2 sub bt.height 2 sub drawborder
113   % bt.x 2 add bt.y 2 add moveto black white bt.width 4 sub bt.height 4 sub drawborder
114 } def
115
116
Note: See TracBrowser for help on using the browser.