Mailing List Archive: 49091 messages
  • Home
  • Script library
  • AltME Archive
  • Mailing list
  • Articles Index
  • Site search
 

Question on text formatting

 [1/32] from: andy::flyingcat::com at: 28-Aug-2002 12:37


Hi: I'm just starting to use Rebol to make a prototype UI. I'm trying to do kind of specific visual button arrangements, and the like. Unfortunately, there's not that much documentation that I've found on Rebol/View/VID and how I can get it to do exactly what I want... My current problem is that I want to make a TV channel grid. I've got it mostly working, but I can't quite get the channel names to appear in a vertically oriented box, single spaced, so I can scroll it at the same time as I scroll the channel listing itself. Basically I want to get a vertical info box: NBC CBS KYW CAT DOG TRA RRR CCC FFF And so on. I can set up the box, but when I use 'text (as part of the 'layout) the text gets double spaced. I'm obviously doing it the wrong way. Can anyone help ? --- Another question: 'layout (in the old docs) used to have both DOWN and ACROSS, to control default placements. Now it seems to only have ACROSS. What happened to DOWN ? Was it replaced by another keyword ? Thanks, Andy

 [2/32] from: petr:krenzelok:trz:cz at: 28-Aug-2002 19:44


Andy Finkel wrote:
>Hi: >
Hello Andy, nice to see one of Amiga celebrities here on ml, wow! :-)
>I'm just starting to use Rebol to make a prototype UI. I'm trying to do >kind of specific visual button arrangements, and the like. >Unfortunately, there's not that much documentation that I've found on >Rebol/View/VID and how I can get it to do exactly what I want... >
yes, docs are a bit lacking, try also Escribe mail archive at http://www.escribe.com/internet/rebol/index.html and http://www.rebolforces.com . What about joining IOS Developer server?
>My current problem is that I want to make a TV channel grid. I've got >it mostly working, but I can't quite get the channel names to appear in
<<quoted lines omitted: 14>>
>text gets double spaced. I'm obviously doing it the wrong way. Can >anyone help ?
oh, I am sorry I don't understand what is the problem exactly. I hope some rebollers here step in quickly enough to help you ... Or just - could you post a short example of your code? That could help ...
>--- > >Another question: 'layout (in the old docs) used to have both DOWN and >ACROSS, to control default placements. Now it seems to only have >ACROSS. What happened to DOWN ? Was it replaced by another keyword ? >
'below .... Cheers, -pekr-

 [3/32] from: greggirwin:mindspring at: 28-Aug-2002 12:27


Hi Andy, Welcome to the list! << My current problem is that I want to make a TV channel grid. I've got it mostly working, but I can't quite get the channel names to appear in a vertically oriented box, single spaced, so I can scroll it at the same time as I scroll the channel listing itself. >> Sometimes it helps to provide some sample code so others can tweak it in context, and provide a common basis for reference. In this case, could you use a TEXT-LIST, or perhaps a LIST, to achieve what you want? Another thing to look at is the SPACE facet of the layout. If you set it to 0x0, there will be no spacing between faces by default. --Gregg

 [4/32] from: andy:flyingcat at: 28-Aug-2002 15:18


Thanks for the welcome and the quick responses. Let me post a quick code example, so you can see what I am trying to do (please remember I only started playing with Rebol a couple of weeks ago, so I keep trying to do things the C way, and when that fails, I make it simple/inelegant.... 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. (this is where I want to be able to get the maximum size of the larger page that I am scrolling; so I can stop when I've scrolled through all the entries; and if anyone knows of an easy way to force one of the buttons on the scrolling grid to be "selected" my day would be complete :-) ) Thanks, Andy ------------------------------------------------- REBOL [ ] back_color: blue schedule_list: [ "01" "show title" 00:30 "description" "01" "show 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 [ pad 20 backcolor back_color origin 0x0 size 2000x20 at 010x0 text "12:00" at 100x0 text "01:00" at 190x0 text "02:00" at 250x0 text "03:00" at 330x0 text "04:00" at 410x0 text "05:00" at 490x0 text "06:00" at 570x0 text "07:00" at 650x0 text "08:00" at 730x0 text "09:00" at 810x0 text "10:00" at 890x0 text "11:00" at 0970x0 text "12:00" at 1050x0 text "01:00" at 1130x0 text "02:00" at 1210x0 text "03:00" at 1290x0 text "04:00" at 1370x0 text "05:00" at 1450x0 text "06:00" at 1530x0 text "07:00" at 1610x0 text "08:00" at 1690x0 text "09:00" at 1770x0 text "10:00" at 1850x0 text "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 ] 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 ] 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 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 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

 [5/32] from: gchiu:compkarori at: 29-Aug-2002 8:32


On Wed, 28 Aug 2002 12:37:27 -0400 "Andy Finkel" <[andy--flyingcat--com]> wrote:
>My current problem is that I want to make a TV channel >grid. I've got >it mostly working, but I can't quite get the channel
Welcome to the list. We don't get that many ex Commodore/Amiga employees here! Is this for [Met--box]? -- Graham Chiu

 [6/32] from: andy:flyingcat at: 28-Aug-2002 17:12


Thanks. Nope, not for [Met--box]. This is for something new. I just figured that Rebol would be a good tool to rapidly try out different user interfaces. I still think it will be, once I get past the learning curve. Andy

 [7/32] from: rebologue:yaho:o at: 28-Aug-2002 16:01


Hi Andy-- Looks like you've got the beginnings of a nice EPG (electronic program guide). I've been meaning to get around to one of those.
>> Rebol would be a good tool to rapidly try out
different user interfaces. I'm a usability specialist and at work, and I use Rebol/View to test design prototypes with users. It's quite a good tool for it, and I'm hoping VID will see some improvements in the coming months. As it stands, Rebol/IOS shows lots of promise as an environment for supporting a user-centered design process. FYI, if you need to quickly build interfaces with a native Windows look and feel, I strongly recommend a look at DocKimble's Win95 Skin (thanks Doc!). Otherwise, you'll need to roll up your sleeves do a significant amount of sculpting. This Skin should be available in the Demos folder. Regards, Ed

 [8/32] from: gchiu:compkarori at: 29-Aug-2002 11:36


On Wed, 28 Aug 2002 17:12:11 -0400 "Andy Finkel" <[andy--flyingcat--com]> wrote:
>Nope, not for [Met--box]. This is for something new. I
I purchased Personal Video Station 2 this week ( www.snapstream.com ), and of course the EPG ( electronic programming guides ) interfaces are all for the USA market. I was considering using VID to grab and display TV guides - and do EPG for my area. PVS has a web server to control it's functions, so View would be quite suitable for the task. -- Graham Chiu

 [9/32] from: g:santilli:tiscalinet:it at: 29-Aug-2002 2:02


Hi Andy, On Wednesday, August 28, 2002, 6:37:27 PM, you wrote: Wow, it's really great to have you here Andy. :-) AF> Unfortunately, there's not that much documentation that I've found on AF> Rebol/View/VID and how I can get it to do exactly what I want... We have been waiting for documentation since the release of /View... but luckily with REBOL is so easy to find what's going on by yourself that we (the REBOL community) have been able to understand almost everything. :-) AF> I can set up the box, but when I use 'text (as part of the 'layout) the AF> text gets double spaced. I'm obviously doing it the wrong way. Can AF> anyone help ? I'm not sure if I understand correctly. However, the SPACE keyword lets you set the default space that is applied between styles. I.e. Try with something like: Space 0x0 ; no space Text "CBS" Text "NBC" ; etc. AF> Another question: 'layout (in the old docs) used to have both DOWN and AF> ACROSS, to control default placements. Now it seems to only have AF> ACROSS. What happened to DOWN ? Was it replaced by another keyword ? BELOW replaces the old DOWN. HTH, Gabriele. -- Gabriele Santilli <[g--santilli--tiscalinet--it]> -- REBOL Programmer Amigan -- AGI L'Aquila -- REB: http://web.tiscali.it/rebol/index.r

 [10/32] from: greggirwin:mindspring at: 28-Aug-2002 20:19


Hi Andy, << (please remember I only started playing with Rebol a couple of weeks ago, so I keep trying to do things the C way, and when that fails, I make it simple/inelegant.... >> At two weeks...you're way ahead of where I was. :) << 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. >> Change the spacing to 1x1 in your LINEUP block, so it matches the spacing in the grid block. I added a text style to make sure the size matches that of the buttons you set as well. ; build channel lineup lineup: [ backcolor back_color origin 0x0 space 1x1 ;0x0 pad 0 style text text 80x20 ] << (this is where I want to be able to get the maximum size of the larger page that I am scrolling; so I can stop when I've scrolled through all the entries; >> Looks like grid-f/size/y is what you're after. << and if anyone knows of an easy way to force one of the buttons on the scrolling grid to be "selected" my day would be complete :-) >> FOCUS is what you use to select a specific face. I'm not sure it will do what you want here though. Buttons don't respond to many keystroke by default (you can, of course, add that behavior). I think Brett Handley did a grid style that let you move from face to face with the keyboard. Maybe it was Cyphre. So many talented people write great stuff that I lose track. :) view layout [a: button [print "A"] b: button [focus a]] HTH! --Gregg

 [11/32] 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

 [12/32] from: g:santilli:tiscalinet:it at: 29-Aug-2002 15:55


Hi Scott, On Thursday, August 29, 2002, 6:01:09 AM, you wrote: GSJ> Welcome to REBOL. I agree with Gregg: you are way ahead of where I was at GSJ> two weeks! No wonder he is, you're talking to Andy Finkel. :-) Regards, Gabriele. -- Gabriele Santilli <[g--santilli--tiscalinet--it]> -- REBOL Programmer Amigan -- AGI L'Aquila -- REB: http://web.tiscali.it/rebol/index.r

 [13/32] from: andy:flyingcat at: 29-Aug-2002 11:48


Thanks to Gabriele, Petr, Gregg, Ed, Graham, Scott, Jason, Ashley, Steve (and anyone I missed) for your help. I appreciate the friendly 'spirit' and quick answers (including Scott's work on the code itself :-) which are helping me get up to speed on Rebol quickly. Andy

 [14/32] from: andy:flyingcat at: 29-Aug-2002 11:41


Thanks for your help so far! << and if anyone knows of an easy way to force one of the buttons on the scrolling grid to be "selected" my day would be complete :-) >>
>FOCUS is what you use to select a specific face. I'm not sure it will
do
>what you want here though. Buttons don't respond to many keystroke by >default (you can, of course, add that behavior). I think Brett Handley
did a
>grid style that let you move from face to face with the keyboard. Maybe
it
>was Cyphre. So many talented people write great stuff that I lose
track. :)
> view layout [a: button [print "A"] b: button [focus a]]
What I am after is a way to programatically make one of the buttons in the grid appear to be selected. I don't have a mouse for this application; everything is done via a keypad. I was wondering if there were any tricks I could be using to get that effect. (like, is there a way I could iterate through the list of buttons associated with a particular face, and somehow change that buttons color ?) Thanks, Andy

 [15/32] from: gscottjones:mchsi at: 29-Aug-2002 13:59


From: "Andy Finkel"
> What I am after is a way to programatically make one of the buttons in > the grid appear to be selected. I don't have a mouse for this
<<quoted lines omitted: 4>>
> associated with a particular face, and somehow change that buttons color > ?)
Hi, Andy, You are running into what appears to be a limit in the current implimentation of View/VID. Very fiew of the widgets lend themselves well to the task of taking a focus. A button will merely have a caret cursor line. Even when in focus, the button won't automatically accept keyboard commands. As Gregg mentioned, Brett played with a grid layout that accepted tab keys. The grid was composed of fields. His reb site can be found at: REBOL/View -> Desktop -> Sites -> Code C.-> Grids Perhaps you can gleam some tricks from there. And, yes, there is a way to programmatically iterate through the buttons and change behavior. It may be easier to give the buttons identifiers. The following is one quickie way to create a set-word for each button, placed before the button keyword: ... append mygrid to-set-word rejoin ["bn-" channel grid_count] append mygrid [button] append mygrid size append mygrid copy title .. One could also accummulate this list in a separate block or parse the mygrid block to find the labels. But then the fun begins in managing the behavior, because the default set-up will not readily accept what I *think* you are invisioning. You will likely need to create a new button (or more generally a widget) style to behave correctly. This is do-able, but not straight forward for anyone but the guru's. By the reputation that preceeds you on this list, my guess is you'll reach guru status in another 2 days! ;-) Good luck! --Scott Jones

 [16/32] from: anton:lexicon at: 30-Aug-2002 5:28


A while back, when View was upgraded, the button style became more complicated, using a gradient effect. Anyhow, here's an example of how to change the first button in a face containing three buttons. view/new center-face lay: layout [ button button button ] ; modify first button lay/pane/1/effects: [ [gradient 0x1 166.120.192 0.0.200] ; normal [gradient 0x-1 66.120.192 44.80.132] ; pressed ] lay/pane/1/effect: first lay/pane/1/effects show lay/pane/1 wait none ; wait for events see also print mold lay/pane/1/feel Anton.

 [17/32] from: andy:flyingcat at: 29-Aug-2002 17:52


Now, this is a _very_ interesting clue. If I use a similar example, view/new lay: layout [ button button button ] lay/pane/1/text: "hithere" show lay/pane/1 wait none The text on the button changes. In fact, I can change it to anything I like, again and again. But if I do something like: view/new lay: layout [ button "test" button "test1" button "test" ] lay/pane/1/text: "hithere" show lay/pane/1 wait none Or view/new lay: layout [ button copy "test" button copy "test1" button copy "test" ] lay/pane/1/text: "hithere" show lay/pane/1 wait none Then the text is fixed to be "test". Every time I show, Rebol changes it back to the original text (which was test); Rebol must be storing the original text in some hidden place when I created the button, and always refreshing from that, rather than from the values stored I was expecting. (this also seems to apply to colors). So if I create a grid of blank buttons (or possibly uncolored buttons), I might be able to programatically change the appearance of the button to simulate non-mouse highlighting. Andy

 [18/32] from: gscottjones:mchsi at: 29-Aug-2002 17:10


Hi, Andy, I couldn't quit thinking about this interesting problem, so I managed to kill a good part of the afternoon. But .... I certainly understand event filtering better. Here is what I did. I set up a list of the named buttons in order to allow scrolling with the right and left keys. A space or enter (or any key except the direction keys) open the request box. In order to allow scrolloing down and up with arrow keys, the data will need better structure (it can be done as is, but it is most inelegant) but should be do-able. I changed Button to my own little custom widget based on field. It is markedly ugly as is, but I was focusing on functionality over beauty. Left to be done is restructuring the data (or hacking a kludge that parses the unique aspects of the keys and counts were on a line it is so that it can skip to a similar spot on the line above or below ... whew .. sounds easier to build a smidge more structure into the data!), the filling in the code for up and down arrows captured at the global even level (at bottom of script), changing the focus for mouse click (if desired) to update the index into the data, and beautify/beautify/beautify (most readily done at the style definition at the top ... ??? how to get rid of the caret cursor?). Hope this helps. It sure helped me, but I don't know whether to thank you or curse you for posting such an interesting problem! :-) Listing follows, but there will be major wrap problems!!! I'll send an attachment to to email address. --Scott Jones REBOL [] back_color: blue info-addon: stylize [ my-info: field with [ edge: [size: 1x1 effect: 'bevel] colors: reduce [svvc/field red] ;flags: [field return tabbed on-unfocus] flags: [return tabbed on-unfocus] feel: make feel [ engage: func [face act event index][ switch act [ down [ either not-equal? face ctx-text/view*/focal-face [ focus face ;ctx-text/view*/caret: offset-to-caret face event/offset ][ ;ctx-text/view*/highlight-start: ;ctx-text/view*/highlight-end: none ;ctx-text/view*/caret: offset-to-caret face event/offset ] show face ] ;over [ ; if not-equal? ctx-text/view*/caret offset-to-caret face event/offset [ ; if not ctx-text/view*/highlight-start [ ; ctx-text/view*/highlight-start: ctx-text/view*/caret ; ] ; ctx-text/view*/highlight-end: ; ctx-text/view*/caret: offset-to-caret face event/offset ; show face ; ] ;] key [ do e face/text ] ] ] ] ] ] 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 styles info-addon ] 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 my-but-blk: copy [] 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 to-set-word join "bn-" checksum rejoin [channel title time description] append my-but-blk rejoin ["bn-" channel grid_count] append mygrid to-set-word rejoin ["bn-" channel grid_count] ;append mygrid [button] append mygrid [my-info] append mygrid size append mygrid copy title ;get rid of button text wrapping append mygrid [para [wrap?: false]] ;append mygrid [edge [size: 1x1]] 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 query-before-passing-on: func [face event][ switch/default event/type [ key [ switch/default event/key [ right [ my-but-blk: next my-but-blk if tail? my-but-blk [my-but-blk: head my-but-blk] focus do to-word first my-but-blk return none ] left [ either head? my-but-blk [ my-but-blk: back tail my-but-blk ][ my-but-blk: back my-but-blk ] focus do to-word first my-but-blk return none ] up [ return none ] down [ return none ] ] [return event] ] ] [event] ] focus do to-word first my-but-blk do [insert-event-func :query-before-passing-on ] view main

 [19/32] from: anton:lexicon at: 30-Aug-2002 9:01


Same idea as effect and effects, so text and texts. You need to update both the current TEXT and the TEXTS facets.... Try these, and click the button: view layout [b: button "text" [probe b/texts]] ;== ["text"] view layout [b: button "text" "alt text" [probe b/texts]] ;== ["text" "alt text"] same? b/text b/texts/1 ;== true To see how it all works, you must look at the feel of the button style. probe b/feel You can see what happens when you click. Read carefully, you will see EFFECT and EFFECTS, TEXT and TEXTS, and COLOR & COLORS mentioned. It's also useful to see what facets are in a face object: print mold first b and to see what value one of them has: b/style ;== button also check the init code of the face: print mold b/init Anton.

 [20/32] from: gscottjones:mchsi at: 29-Aug-2002 18:07


Hi, Andy, From: "Andy Finkel"
> Now, this is a _very_ interesting clue. > If I use a similar example,
<<quoted lines omitted: 24>>
> I might be able to programatically change the appearance of the button > to simulate non-mouse highlighting.
You appear to have stumbled on one of those gray areas that is an exception (or possibly a "bug" or an under appreciated "feature"). I do not recall if there is a way to get *to* this data. Here is another work around to defining the button text in the layout and still being able to get at it. Hopefully a wizard can elucidate that real nature of this beast. view/new lay: layout [ b: button with [text: "test"] button "change above" [ lay/pane/1/text: "dither" show b ] button "change top" [ ; the following is another way to change the info b/text: "yon" show b ] ] lay/pane/1/text: "hither" show b do-events --Scott Jones

 [21/32] from: g:santilli:tiscalinet:it at: 30-Aug-2002 1:15


Hi Andy, On Thursday, August 29, 2002, 5:41:57 PM, you wrote: AF> What I am after is a way to programatically make one of the buttons in AF> the grid appear to be selected. I don't have a mouse for this AF> application; everything is done via a keypad. Have a look at this: view layout [ btn: button "Test button" button "Go down" [btn/state: on show btn] button "Go up" [btn/state: off show btn] ] I hope it can get you started. AF> (like, is there a way I could iterate through the list of buttons AF> associated with a particular face, and somehow change that buttons color AF> ?) face/pane contains all the sub-faces; you can look at face/style to see if a face is a button and act accordingly. Regards, Gabriele. -- Gabriele Santilli <[g--santilli--tiscalinet--it]> -- REBOL Programmer Amigan -- AGI L'Aquila -- REB: http://web.tiscali.it/rebol/index.r

 [22/32] from: g:santilli:tiscalinet:it at: 30-Aug-2002 1:35


Hi Andy, On Thursday, August 29, 2002, 11:52:16 PM, you wrote: AF> Then the text is fixed to be "test". Every time I show, Rebol changes AF> it back to the original text (which was test); Rebol must be storing AF> the original text in some hidden place when I created the button, and AF> always refreshing from that, rather than from the values stored I was AF> expecting. This is because the BUTTON style supports two texts, like in:
>> view layout [btn: button "Text 1" "Text 2"]
(You see the second text by clicking on the button) They are in:
>> btn/texts
== ["Text 1" "Text 2"] so you need to change that to make it work as you expect. If you don't, you text is reset in the REDRAW feel: redraw: func [face act pos /local state][ face/edge/effect: pick [ibevel bevel] face/state if face/texts [face/text: face/texts/1] all [face/state face/texts face/text: any [face/texts/2 face/texts/1]] state: either not face/state [face/blinker] [true] if face/colors [face/color: pick face/colors not state] if face/effects [face/effect: pick face/effects not state] ] AF> (this also seems to apply to colors). Indeed, see above. AF> So if I create a grid of blank buttons (or possibly uncolored buttons), AF> I might be able to programatically change the appearance of the button AF> to simulate non-mouse highlighting. That's not needed, you just need to act on /texts and /colors. Also, see my other message about /state to make a button look pressed (this is in the REDRAW feel too). HTH, Gabriele. -- Gabriele Santilli <[g--santilli--tiscalinet--it]> -- REBOL Programmer Amigan -- AGI L'Aquila -- REB: http://web.tiscali.it/rebol/index.r

 [23/32] from: greggirwin:mindspring at: 29-Aug-2002 17:26


Hi Andy, You should be able to change it no matter what. If nobody else responds with an answer (I'm chronically short of time lately) post a reminder for me. --Gregg

 [24/32] from: carl:cybercraft at: 30-Aug-2002 12:31


On 30-Aug-02, Andy Finkel wrote:
> Now, this is a _very_ interesting clue. > If I use a similar example,
<<quoted lines omitted: 20>>
> button, and always refreshing from that, rather than from the values > stored I was expecting.
Hi Andy, There's a simple way around that. Your lay/pane/1/text: "hithere" creates a new reference to the new string, which is why it doesn't display, (layman talking here so take that description with a pinch of salt:), but if you just clear the current string and insert the new one it will be shown... view/new lay: layout [ button "test" button "test1" button "test" ] insert clear lay/pane/1/text "hithere" show lay/pane/1 wait none HTH.
> (this also seems to apply to colors). > So if I create a grid of blank buttons (or possibly uncolored > buttons), I might be able to programatically change the appearance > of the button to simulate non-mouse highlighting. > Andy
-- Carl Read

 [25/32] from: ptretter:charter at: 29-Aug-2002 22:02


Actually, I get it as intended even in your second example, I still get hithere as the first buttons text. You are referncing the first facet with pane/1. Paul Tretter

 [26/32] from: anton:lexicon at: 30-Aug-2002 21:09


Andy, and anyone else who's interested, I just hacked together an example of a grid of buttons that responds to keys: url: http://www.lexicon.net/anton/rebol/gui/highlight-button.r load-thru url do path-thru url Anton.

 [27/32] from: andy:flyingcat at: 30-Aug-2002 12:05


Well, this list has been great so far :-) The interface and my understanding of the tricks available in rebol are both growing :-) Let me ask another question, then... Let's say I'm waiting on a tcp port for a character string. Currently, in my clock update feel, I'm checking if there are any characters available on the port. This works pretty well, but isn't elegant. (I hate polling :-) ) Is there any way to set rebol up to trigger a call to a routine automatically if any characters are received at the port ? Thanks, Andy

 [28/32] from: greggirwin:mindspring at: 30-Aug-2002 10:58


Hi Andy, << Let's say I'm waiting on a tcp port for a character string. Currently, in my clock update feel, I'm checking if there are any characters available on the port. This works pretty well, but isn't elegant. (I hate polling :-) ) Is there any way to set rebol up to trigger a call to a routine automatically if any characters are received at the port ? >> Have you tried WAIT. It works on ports as well as time intervals. --Gregg

 [29/32] from: g:santilli:tiscalinet:it at: 30-Aug-2002 19:49


Hi Andy, On Friday, August 30, 2002, 6:05:37 PM, you wrote: AF> hate polling :-) ) Is there any way to set rebol up to trigger a call AF> to a routine automatically if any characters are received at the port ? You bet. :-) port: open tcp://etc. port/awake: func [port] [ ; this is called each time you have new data in the port ; if you open the port as NO-WAIT now you can just get the ; data with COPY PORT print copy port ; you should return TRUE or FALSE. returning TRUE makes ; REBOL exit from the wait function call, while with FALSE ; you keep waiting ] ; now you either use: wait port ; and get your awake called when there's data, with WAIT ; returning only if your awake function returns TRUE, ; or you can: insert tail system/ports/wait-list port ; and your port will be automatically "waited" every time ; you call WAIT, i.e. also when you show a window; this is ; probably what you are interested in. Regards, Gabriele. -- Gabriele Santilli <[g--santilli--tiscalinet--it]> -- REBOL Programmer Amigan -- AGI L'Aquila -- REB: http://web.tiscali.it/rebol/index.r

 [30/32] from: anton:lexicon at: 31-Aug-2002 4:45


That's interesting - if you clear that wait-list, windows no longer respond to user interface events - mouse-clicks etc. Anton.

 [31/32] from: g:santilli:tiscalinet:it at: 31-Aug-2002 0:48


Hi Anton, On Friday, August 30, 2002, 8:45:44 PM, you wrote: A> That's interesting - if you clear that A> wait-list, windows no longer respond to A> user interface events - mouse-clicks etc. Yup, because DO-EVENTS is just WAIT [], so if you remove the event port from the wait list the event port is no more waited for and events are not processed. Regards, Gabriele. -- Gabriele Santilli <[g--santilli--tiscalinet--it]> -- REBOL Programmer Amigan -- AGI L'Aquila -- REB: http://web.tiscali.it/rebol/index.r

 [32/32] from: andy:flyingcat at: 9-Sep-2002 23:43


Hi: Using VID to grab and display TV guides would be something that would be really useful. Where would you get your data ? How would you process it into a useful list ? Andy

Notes
  • Quoted lines have been omitted from some messages.
    View the message alone to see the lines that have been omitted