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

[ALLY] Re: Scrolling views

From: bo::rebol::com at: 16-Feb-2001 10:07

Brett, Here is a handy function (with examples) that may help you or others make scrolling views easier. Last I heard VID was going to get scrolling built in by default, but until then this function can be used. REBOL [ Title: "Automated scrolling" Date: 22-Dec-2000 Author: "Bohdan Lechnowsky" Email: [bo--rebol--com] File: %scroll-face.r Version: 1.0.0 Purpose: { Demonstrates a way to write a scrollable face. } Comments: { This is a generalized function with 100% environmentally-friendly local variables. It can operate on any number of scrollable windows in the same main face--even scrollable windows nested inside other scrollable windows--as the example shows. } History: [ 0.9.0 ["Initial concept explored" "Bohdan Lechnowsky"] 0.9.1 ["Tweaks" "Bohdan Lechnowsky"] 1.0.0 ["Fully working version" "Bohdan Lechnowsky"] 1.1.0 ["Added arrows and size option plus minor mods" "Bohdan Lechnowsky"] 1.1.1 ["Bug fix with local variable" "Bohdan Lechnowsky"] 1.1.2 ["Another bug fix with local variable" "Bohdan Lechnowsky"] ] ] scroll-face: func [ {Returns vertically scrollable version of input face.} at {Face to attach scroll-face bar to} v {Visible size of the attach-to face} /arrows {Include up and down arrows} /size {Change size of scroll bar/arrows} s {New size for scroll bar/arrows} /local l a f ][ if not size [s: 16] l: layout/offset [ backdrop 0.0.0 across at 0x0 space 0 size (v + (s * 1x0)) box (v) slider (v * 0x1 + (s * 1x0)) [] ] 0x0 if arrows [ l/pane/3/size/y: l/pane/3/size/y - (s * 2) arrow: layout/offset [ arrow up (s * 1x1) [ f: face/parent-face/pane f/2/offset/y: min 0 f/2/offset/y + 15 f/3/data: negate f/2/offset/y / (f/2/size/y - v/y) show face/parent-face ] arrow down (s * 1x1) [ f: face/parent-face/pane f/2/offset/y: max v/y - f/2/size/y f/2/offset/y - 15 f/3/data: negate f/2/offset/y / (f/2/size/y - v/y) show face/parent-face ] ] 0x0 arrow/pane/1/offset: l/pane/3/offset * 1x0 + (l/pane/3/size * 0x1) arrow/pane/2/offset: l/pane/3/offset * 1x0 + (l/pane/3/size * 0x1 + (s * 0x1)) append l/pane arrow/pane ] l/pane/2: at l/pane/3/action: func [f a] compose [ f/parent-face/pane/2/offset/y: (negate at/size/y - v/y) * f/data show f/parent-face ] l/pane/3/redrag v/y / at/size/y l ] ; Simple example (JOL): view scroll-face/arrows/size layout/offset [text "system/view/VID/vid-styles" 300 txt mold system/view/VID/vid-styles 300 as-is] 0x0 300x500 25 ; Another easy example: e: func [t][request/ok rejoin ["Thank you for selecting button " t "!"]] ee: [e face/text] f: layout [ txt "Please select a button" button "A" ee button "B" ee button "C" ee button "D" ee ] view scroll-face f 180x100 ; Nested scroller example: f1: layout/offset [at 0x0 txt system/license 300 as-is] 0x0 f2: layout/offset [at 0x0 txt mold system/options 300 as-is] 0x0 g: scroll-face/arrows/size f1 300x150 10 h: scroll-face/arrows/size f2 300x150 10 i: layout/offset [backdrop black size 340x340 box 300x150 box 300x150] 0x0 i/pane/2: g i/pane/3: h i/pane/2/offset: 10x10 i/pane/3/offset: 10x170 view scroll-face/arrows/size i 340x150 50 On 16-Feb-2001/14:01:57+11:00, [brett--codeconscious--com] wrote:
>I admit I still haven't had a lot of time with view yet. > >But I now have need to understand it throughly. One immediate concern I have >is how a scrolling view is achieved. > >What I want to do is build an entry form that is longer than the screen. >Scroll bars should appear automatically, and function to scroll the viewable >area. > >Another thing I might want (not sure yet) is a scrollable multiline entry >area. > >Can someone explain it to me please? > >Thanks for your time. >Brett. > >-- >To unsubscribe from this list, please send an email to >[ally-request--rebol--com] with "unsubscribe" in the >subject, without the quotes. >
-- Bohdan "Bo" Lechnowsky REBOL Adventure Guide REBOL Technologies 707-467-8000 (http://www.rebol.com) The Official Source for REBOL Books (http://www.REBOLpress.com)