[REBOL] Re: Question on text formatting
From: gscottjones:mchsi at: 28-Aug-2002 23:01
Hi, Andy,
Welcome to REBOL. I agree with Gregg: you are way ahead of where I was at
two weeks!
I was already hacking some suggestions when Greggs email rolled in. I took
a slightly different approach in a few areas, mainly as a way to show some
short-cuts. Altered listing follows at end.
From: "Andy Finkel"
> I can't quite manage the same spacing on the leftmost scrolling box
> (lineup_box) as on the buttons. While I could make the lineup_box a
> scrolling list of buttons, it seems like too much overhead.
Like Gregg, I made the text in the info box match the button height, but I
had also taken out the space between the buttons so that the time line could
more carefully match the buttons.
In addition, I showed a different way to format the time bar. I inserted a
more generic way to make the length of the button match the length of the
show (using a combination of "time" math and pairs). I also turned off
wrapping of the text in the button, in case that would be of some use. I
made a few other tweaks that I don't recall right off, but I put comments
where ever I made a tweak.
Very impressive effort. You'll outclass me within just a few more days!!
Good luck.
--Scott Jones
REBOL [ ]
back_color: blue
schedule_list: [
"01" "show title" 00:30 "description"
"01" "show extra long title 1" 00:30 "description"
"01" "show title 2" 01:00 "description"
"01" "show title 3" 00:30 "description"
"01" "show title 4" 00:30 "description"
"01" "show title 5" 00:30 "description"
"01" "show title 6" 00:30 "description"
"01" "show title 7" 01:00 "description"
"01" "show title 8" 00:30 "description"
"01" "show title 9" 00:30 "description"
"02" "2 show title" 00:30 "description"
"02" "2 show title 1" 00:30 "description"
"02" "2 show title 2" 00:30 "description"
"02" "2 show title 3" 00:30 "description"
"02" "2 show title 4" 00:30 "description"
"02" "2 show title 5" 00:30 "description"
"02" "2 show title 6" 01:30 "description"
"02" "2 show title 7" 00:30 "description"
"02" "2 show title 8" 00:30 "description"
"02" "2 show title 9" 00:30 "description"
"03" "2 show title" 00:30 "description"
"03" "3 show title 1" 00:30 "description"
"03" "3 show title 2" 00:30 "description"
"03" "3 show title 3" 00:30 "description"
"03" "3 show title 4" 00:30 "description"
"03" "3 show title 5" 00:30 "description"
"03" "3 show title 6" 00:30 "description"
"03" "3 show title 7" 02:30 "description"
"03" "3 show title 8" 00:30 "description"
"03" "3 show title 9" 00:30 "description"
"04" "4 show title" 00:30 "description"
"04" "4 show title 1" 00:30 "description"
"04" "4 show title 2" 00:30 "description"
"04" "4 show title 3" 00:30 "description"
"04" "4 show title 4" 00:30 "description"
"04" "4 show title 5" 00:30 "description"
"04" "4 show title 6" 00:30 "description"
"04" "4 show title 7" 00:30 "description"
"04" "4 show title 8" 01:30 "description"
"04" "4 show title 9" 01:00 "description"
"11" "show title" 00:30 "description"
"11" "show title 1" 00:30 "description"
"11" "show title 2" 00:30 "description"
"11" "show title 3" 00:30 "description"
"11" "show title 4" 00:30 "description"
"11" "show title 5" 00:30 "description"
"12" "show title" 00:30 "description"
"12" "show title 1" 00:30 "description"
"12" "show title 2" 00:30 "description"
"12" "show title 3" 00:30 "description"
"12" "show title 4" 00:30 "description"
"13" "show title" 00:30 "description"
"13" "show title 1" 00:30 "description"
"13" "show title 2" 00:30 "description"
"13" "show title 3" 00:30 "description"
"14" "show title 8" 00:30 "description"
"14" "show title 9" 00:30 "description"
"21" "show title" 00:30 "description"
"21" "show title 1" 00:30 "description"
"21" "show title 2" 00:30 "description"
"21" "show title 7" 00:30 "description"
"21" "show title 8" 00:30 "description"
"21" "show title 9" 00:30 "description"
"22" "show title" 00:30 "description"
"22" "show title 1" 00:30 "description"
"22" "show title 9" 00:30 "description"
"23" "show title" 00:30 "description"
"23" "show title 1" 00:30 "description"
"23" "show title 2" 00:30 "description"
"23" "show title 3" 00:30 "description"
"23" "show title 4" 00:30 "description"
"24" "show title 3" 00:30 "description"
"24" "show title 4" 00:30 "description"
"24" "show title 6" 00:30 "description"
"24" "show title 7" 00:30 "description"
"24" "show title 8" 00:30 "description"
"24" "show title 9" 00:30 "description"
]
e: func [t][request/ok rejoin ["Program selected is " t "!"]]
ee: [e face/text]
; build timeline
timeline: layout [
backcolor back_color
origin 0x0
;make sure no added space
space 0x0
across
;used a little less brute force
;(moving with the force :-)
text 80 "12:00"
text 80 "01:00"
text 80 "02:00"
text 80 "03:00"
text 80 "04:00"
text 80 "05:00"
text 80 "06:00"
text 80 "07:00"
text 80 "08:00"
text 80 "09:00"
text 80 "10:00"
text 80 "11:00"
text 80 "12:00"
text 80 "01:00"
text 80 "02:00"
text 80 "03:00"
text 80 "04:00"
text 80 "05:00"
text 80 "06:00"
text 80 "07:00"
text 80 "08:00"
text 80 "09:00"
text 80 "10:00"
text 80 "11:00"
]
; build channel lineup
lineup: [
backcolor back_color
origin 0x0 space 0x0
pad 0
]
; build grid page
mygrid: [backcolor gray]
append mygrid [origin 0x0 ]
;append mygrid [space 1x1 across]
;needed to be consistent with the time line
append mygrid [space 0x0 across]
last-channel: 0
grid_count: 0
grid_v_max: -1
grid_h_max: 0
foreach [channel title time description ] schedule_list [
if (last-channel <> channel) [
append mygrid [ return ]
grid_v_max: grid_v_max + 1
if(grid_count > grid_h_max) [ grid_h_max: grid_count]
grid_count: 0
append lineup [ text ]
append lineup channel
;add vertical height of text to match button height
append lineup [20x20]
]
;more generic length creation routine
size: 80x20 * to-pair append append copy [] ( time / :30) 1
; size: 80x20
; if (time >= 1:00) [ size: 160x20 ]
; if (time >= 1:30) [ size: 240x20 ]
; if (time >= 1:30) [ size: 320x20 ]
append mygrid [ button ]
append mygrid size
append mygrid copy title
;get rid of button text wrapping
append mygrid [para [wrap?: false]]
append mygrid [ ee ]
last-channel: channel
grid_count: grid_count + 1
]
grid-f: layout load mygrid
grid_h_max: grid_h_max * 2
lineup-f: layout load lineup
main: layout [
size 720x400
backcolor back_color
across
; guide
pad 0
button "cursor-up" [
if(current_grid_count > 0) [
grid-f/offset/2: grid-f/offset/2 + 10
current_grid_count: current_grid_count - 1
grid-f/changes: 'offset
lineup-f/offset/2: lineup-f/offset/2 + 10
show grid-small-f show lineup_box
]
]
button "cursor-down" [
if(current_grid_count < grid_v_max) [
grid-f/offset/2: grid-f/offset/2 - 10
current_grid_count: current_grid_count + 1
grid-f/changes: 'offset
lineup-f/offset/2: lineup-f/offset/2 - 10
show grid-small-f show lineup_box
]
]
button "cursor-left" [
if(current_h_grid_count > 0) [
current_h_grid_count: current_h_grid_count - 1
grid-f/offset/1: grid-f/offset/1 + 40
grid-f/changes: 'offset
timeline/offset/1: timeline/offset/1 + 40
show grid-small-f show time_box
]
]
button "cursor-right" [
if(current_h_grid_count < grid_h_max) [
current_h_grid_count: current_h_grid_count + 1
grid-f/changes: 'offset
grid-f/offset/1: grid-f/offset/1 - 40
timeline/offset/1: timeline/offset/1 - 40
show grid-small-f
show time_box
]
]
button "halt" font [colors: [100.100.100]] [ halt ]
at 105x90 lineup_box: info 30x196
at 160x50 time_box: info 400x30 back_color
at 150x80 panels: box 540x400
]
setpanel: func [ a [object!] ] [
panels/pane: a
grid-f/offset: 0x0
current_grid_count: 0
current_h_grid_count: 0
timeline/offset: 0x0
time_box/pane: timeline
;;; lineup-f/offset: 0x4
;can now be set to 0 since text correct height
lineup-f/offset: 0x0
lineup_box/pane: lineup-f
show time_box
show lineup_box
]
print_times: func [ start_time ] [
curr_pos: 10
for curr_time start_time (start_time + 05:00) 00:30 [
reduce [at curr_pos x 10 text curr_time]
curr_pos: curr_pos + 80
]
]
panel_grid: layout [
origin 10x8
backcolor back_color
below
grid-small-f: box 400x200 gray edge [size: 5x5 white]
do [
grid-small-f/pane: grid-f
grid-f/offset: 0x0
current_grid_count: 0
current_h_grid_count: 0
]
return
]
panel_grid/offset: 0x0
setpanel panel_grid
view main