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

Object viewer

 [1/12] from: jeff:rebol at: 15-Feb-2001 13:11


REBOL [ Title: "Object as Tree" Author: "Jeff Kreis" Email: [jeff--rebol--com] Date: 15-Feb-2001 Purpose: "View an object in tree view" Comment: "Works with any object" ] view-obj: func [ 'objw "A word that refers to an object" /local obj data this-parent this-val this-word expanded? this-depth val new-val ][ if not object? obj: get objw [make error! "View-obj views objects"] data: make block! 300 ;- this-parent this-val this-word expanded? depth repend data [none obj objw off 0] cnt: 0 view/offset this-tree: layout [ backdrop 90.90.240 h2 yellow (reform ["Object Viewer:" objw]) across space 0 lst: list 500x430 [ txt 500 [ ;-- First find parent and from there ; find this thing val: pick face/user-data 2 this-spot: find data face/user-data/1 this-spot: skip find next this-spot :val -2 set [this-parent this-val this-word expanded? this-depth] this-spot either expanded? [ ;-- Remove stuff that has me as a parent spot: skip find/last data :this-val 5 remove/part skip this-spot 5 spot change at this-spot 4 off ][ either object? :this-val [ ;-- Add my stuff to data below me spot: skip this-spot 5 new-data: make block! 50 foreach word next first this-val [ if unset? set/any 'val get/any in this-val word [val: unset!] repend new-data [this-val :val word off this-depth + 1] ] insert spot new-data change at this-spot 4 on ;- Expanded? ][ ;-- Edit my value this-lay: layout [ backdrop 90.90.240 h2 yellow (reform ["Value of:" this-word]) this-area: area 300x300 (mold :this-val) across txt yellow "do?" do-check: check off this-set: button "set" this-close: button "close" ] ;- Use compose to stick the values in ; there so there can be more than ; one of these windows open and each ; button action will refer to its ; own instance values. this-set/action: compose [ set this-val: in (this-parent) (to-lit-word this-word) new-val: load (this-area/text) if get in (do-check) 'data [new-val: set this-val do new-val] change/only at (reduce [this-spot]) 2 :new-val unview/only (this-lay) ] this-close/action: compose [unview/only (this-lay)] center-face this-lay view/new this-lay ] ] show lst ] ] supply [ ;-- Set up each face of the ; iterated pane based on what's in data face/text: none face/font/color: black count: count + cnt face/color: either even? count [200.200.200][ivory] if tail? spot: skip data ((count - 1) * 5) [return none] face/user-data: reduce [spot/1 spot/3] this-val: pick spot 2 face/text: head insert/dup reform [ either object? :this-val [ either spot/4 ["--"]["+-"] ][#] spot/3 ] " " spot/5 ] sld: slider 16x430 [ c: to-integer value * ((length? data) / 5) if c <> cnt [cnt: c show lst] ] return button "quit" [quit] ] 150x50 ] view-obj system

 [2/12] from: allenk:powerup:au at: 16-Feb-2001 8:25


Cool Jeff. I've tinkered with it, see below. I guess it could be extended to present different colours based on type! but I left it with just color coding the objects. Cheers, Allen K REBOL [ Title: "Object as Tree" Author: "Jeff Kreis" Email: [jeff--rebol--com] Date: 15-Feb-2001 Purpose: "View an object in tree view" Comment: "Works with any object" History: [16-Feb-2001 ["Allen K" "Cosmetic changes, coloured text, removed bg alt-rows"]] ] view-obj: func [ 'objw "A word that refers to an object" /local obj data this-parent this-val this-word expanded? this-depth val new-val ][ if not object? obj: get objw [make error! "View-obj views objects"] data: make block! 300 ;- this-parent this-val this-word expanded? depth repend data [none obj objw off 0] cnt: 0 view/offset this-tree: layout [ backdrop 90.90.240 h2 yellow (reform ["Object Viewer:" objw]) across space 0 lst: list 500x430 [ txt 500 black ivory [ ;-- First find parent and from there ; find this thing val: pick face/user-data 2 this-spot: find data face/user-data/1 this-spot: skip find next this-spot :val -2 set [this-parent this-val this-word expanded? this-depth] this-spot either expanded? [ ;-- Remove stuff that has me as a parent spot: skip find/last data :this-val 5 remove/part skip this-spot 5 spot change at this-spot 4 off ][ either object? :this-val [ ;-- Add my stuff to data below me spot: skip this-spot 5 new-data: make block! 50 foreach word next first this-val [ if unset? set/any 'val get/any in this-val word [val: unset!] repend new-data [this-val :val word off this-depth + 1] ] insert spot new-data change at this-spot 4 on ;- Expanded? ][ ;-- Edit my value this-lay: layout [ backdrop 90.90.240 h2 yellow (reform ["Value of:" this-word]) this-area: area 300x300 (mold :this-val) across txt yellow "do?" do-check: check off this-set: button "set" this-close: button "close" ] ;- Use compose to stick the values in ; there so there can be more than ; one of these windows open and each ; button action will refer to its ; own instance values. this-set/action: compose [ set this-val: in (this-parent) (to-lit-word this-word) new-val: load (this-area/text) if get in (do-check) 'data [new-val: set this-val do new-val] change/only at (reduce [this-spot]) 2 :new-val unview/only (this-lay) ] this-close/action: compose [unview/only (this-lay)] center-face this-lay view/new this-lay ] ] show lst ] ] supply [ ;-- Set up each face of the ; iterated pane based on what's in data face/text: none ; face/font/color: black set-font face 'color leaf count: count + cnt ; face/color: either even? count [200.200.200][ivory] if tail? spot: skip data ((count - 1) * 5) [return none] face/user-data: reduce [spot/1 spot/3] this-val: pick spot 2 face/text: head insert/dup reform [ either object? :this-val [ set-font face 'color blue either spot/4 ["--"]["+-"] ][#] spot/3 ] " " spot/5 ] sld: slider 16x430 [ c: to-integer value * ((length? data) / 5) if c <> cnt [cnt: c show lst] ] return button "quit" [quit] ] 150x50 ] view-obj system

 [3/12] from: dvydra2::yahoo at: 15-Feb-2001 14:55


Jeff, This rocks!!! David --- [jeff--rebol--net] wrote:
> REBOL [ > Title: "Object as Tree"
<<quoted lines omitted: 129>>
> [rebol-request--rebol--com] with "unsubscribe" in the > subject, without the quotes.
===== please reply to: [david--vydra--net]

 [4/12] from: gjones05:mail:orion at: 15-Feb-2001 17:59


This is neat. The pop-ups sometimes need to scroll, so I changed to a text-list. I threw in some version numbers. But I also discovered a bug when I click on 'view (and a few others) in any of the versions so far. Maybe I'm tired, but I can't seem to locate the bug. Help?! Thanks Jeff and Allen. REBOL [ Title: "Object as Tree" Author: "Jeff Kreis" Email: [jeff--rebol--com] Date: 15-Feb-2001 Purpose: "View an object in tree view" Comment: "Works with any object" History: [ 0.1.0 [15-Feb-2001 {Script created and placed on list} "Jeff Kreis"] 0.1.1 [16-Feb-2001 {Cosmetic changes, coloured text, removed bg alt-rows} "Allen K"] 0.1.2 [15-Feb-2001 {Changed pop up to a scrollable list, cosmetic changes to sizes, reordered header history to standard. ?? Bug when click on view and a few others.} "G Scott Jones"] ] ] ; modification based on original by Sterling ; updates the bar on the side of a text-list or group of text-lists fix-slider: func [faces [object! block!]] [ foreach list to-block faces [ ; either 0 = length? list/data [ either 0 = length? list/lines [ list/sld/redrag 1 ][ ; list/sld/redrag list/lc / length? list/data list/sld/redrag list/lc / length? list/lines ] ] ] view-obj: func [ 'objw "A word that refers to an object" /local obj data this-parent this-val this-word expanded? this-depth val new-val ][ if not object? obj: get objw [make error! "View-obj views objects"] data: make block! 300 ;- this-parent this-val this-word expanded? depth repend data [none obj objw off 0] cnt: 0 view/offset this-tree: layout [ backdrop 90.90.240 h2 yellow (reform ["Object Viewer:" objw]) across space 0 lst: list 350x430 [ txt 500 black ivory [ ;-- First find parent and from there ; find this thing val: pick face/user-data 2 this-spot: find data face/user-data/1 this-spot: skip find next this-spot :val -2 set [this-parent this-val this-word expanded? this-depth] this-spot either expanded? [ ;-- Remove stuff that has me as a parent spot: skip find/last data :this-val 5 remove/part skip this-spot 5 spot change at this-spot 4 off ][ either object? :this-val [ ;-- Add my stuff to data below me spot: skip this-spot 5 new-data: make block! 50 foreach word next first this-val [ if unset? set/any 'val get/any in this-val word [val: unset!] repend new-data [this-val :val word off this-depth + 1] ] insert spot new-data change at this-spot 4 on ;- Expanded? ][ ;-- Edit my value this-lay: layout [ backdrop 90.90.240 h2 yellow (reform ["Value of:" this-word]) this-area: text-list 500x300 data (parse/all mold :this-val "^/") across txt yellow "do?" do-check: check off this-set: button "set" this-close: button "close" ] ;- Use compose to stick the values in ; there so there can be more than ; one of these windows open and each ; button action will refer to its ; own instance values. this-set/action: compose [ set this-val: in (this-parent) (to-lit-word this-word) new-val: load (this-area/text) if get in (do-check) 'data [new-val: set this-val do new-val] change/only at (reduce [this-spot]) 2 :new-val unview/only (this-lay) ] this-close/action: compose [unview/only (this-lay)] fix-slider this-area center-face this-lay view/new this-lay ] ] show lst ] ] supply [ ;-- Set up each face of the ; iterated pane based on what's in data face/text: none ; face/font/color: black set-font face 'color leaf count: count + cnt ; face/color: either even? count [200.200.200][ivory] if tail? spot: skip data ((count - 1) * 5) [return none] face/user-data: reduce [spot/1 spot/3] this-val: pick spot 2 face/text: head insert/dup reform [ either object? :this-val [ set-font face 'color blue either spot/4 ["--"]["+-"] ][#] spot/3 ] " " spot/5 ] sld: slider 16x430 [ c: to-integer value * ((length? data) / 5) if c <> cnt [cnt: c show lst] ] return button "quit" [quit] ] 150x50 ] view-obj system

 [5/12] from: gjones05:mail:orion at: 15-Feb-2001 18:08


Whoops, just realized that my text-list doesn't allow updates. Oh, well, sorry all. Maybe another day. I obviously AM too tired. As Roseanne Rosanna Dana used to say ... --scott

 [6/12] from: jeff:rebol at: 15-Feb-2001 16:23


Howdy, Scott:
> .. But I also > discovered a bug when I click on 'view (and a few others) > in any of the versions so far. Maybe I'm tired, but I > can't seem to locate the bug. Help?!
I haven't encountered a bug clicking on 'view. What is the error? As you found out, text-list won't let you edit the value there, but areas scroll with the cursor caret. The area could also have a scroll bar, I suppose. Features features.. bloat bloat... ;-) In the latest VIEW (LINK), there's a nice built-in text editor which I would have used instead, but I wanted to be portable. (-: -jeff

 [7/12] from: gjones05:mail:orion at: 15-Feb-2001 21:38


Hi, Jeff,
> > .. But I also > > discovered a bug when I click on 'view (and a few others) > > in any of the versions so far. Maybe I'm tired, but I > > can't seem to locate the bug. Help?! > > I haven't encountered a bug clicking on 'view. What is the > error?
I'm using 0.10.38.3.1 on Windows 98. When I click on view, the console pops up and shows: ** Script Error: insert expected count argument of type: number. ** Where: face/text: head insert/dup reform [ either object? :this-val [ either spot/4 ["--"] ["+-"] ] [#] spot/3 ]
>>
I thought it happened on another target, but now I can't find it.
> As you found out, text-list won't let you edit the value > there, but areas scroll with the cursor caret.
I didn't realize that the cursor caret scrolled the area face. Thanks! All in all, I feel pretty silly for TOTALLY forgetting that one of the purposes was to edit values on the fly (like, golly Mr Wizard, you mean that this car *drives* too?). Won't be the first or last time I make an idiot of myself. =\
> In the latest VIEW (LINK), there's a nice built-in text > editor which I would have used instead, but I wanted to be > portable. (-:
Speaking of which, I cannot seem to get a handle on the distinctions amongst the evolving RT products. It's like I read the text and think, "yeah, that makes sense." But after a moment, I'm thinking, "yeah, but *what* is it?" I mean no offense to the work that someone put in on the web pages, but just as a form of feedback, I don't feel like I'm really "getting it." Of course ... this is the same person who didn't know that the area face scrolls and that overly exuberantly added features only to kill half the usefulness of a program!!! Thanks for your interest and the great script. --Scott

 [8/12] from: agem:crosswinds at: 16-Feb-2001 13:40


[rebol [title: "scroll-area with slider"] context [ s: ta: sv: none ;---some data s: for i 1 130 1 [ insert "" rejoin [i newline]] view layout [ across ta: area 140x480 s sv: slider 16x480 [ scroll-para ta sv] ] ] ] Volker
>>>>>>>>>>>>>>>>>> Ursprüngliche Nachricht <<<<<<<<<<<<<<<<<<
Am 16.02.01, 01:23:20, schrieb [jeff--rebol--net] zum Thema [REBOL] Re: Object viewer:

 [9/12] from: gjones05:mail:orion at: 16-Feb-2001 13:09


From: Volker Nitsch
> [rebol [title: "scroll-area with slider"] > context [
<<quoted lines omitted: 11>>
> ] > Volker
Thanks, Volker, this was exactly what I was looking for earlier today. After seeing your example, I realized that this method was used in many of the built-in dialogs in the source. I just didn't realize what I was looking at. More as an exercise than a necessity, I adapted this approach to Jeff's object viewer (feature creep alert :-). I also widened the dialogs so that it could accommodate the width of some items without needing to scroll horizontally. Jeff used some really neat methods in allowing the creation of multiple pop-ups. I hope I didn't introduce any new problems like yesterday. Still has a bug in my Win98 /View when I click on the view object (I can't figure it out yet). REBOL [ Title: "Object as Tree" Author: "Jeff Kreis" Email: [jeff--rebol--com] Date: 15-Feb-2001 Purpose: "View an object in tree view" Comment: "Works with any object" History: [ 0.1.0 [15-Feb-2001 {Script created and placed on list} "Jeff Kreis"] 0.1.1 [16-Feb-2001 {Suggested change to scrollable areas, changed size of pop-up to accommodate width without need to scroll, reordered header history to standard. ?? Bug when click on view and a few others. Changes suggested by Allen K. not currently included herein} "G Scott Jones, M.D."] ] ] view-obj: func [ 'objw "A word that refers to an object" /local obj data this-parent this-val this-word expanded? this-depth val new-val ][ if not object? obj: get objw [make error! "View-obj views objects"] data: make block! 300 ;- this-parent this-val this-word expanded? depth repend data [none obj objw off 0] cnt: 0 view/offset this-tree: layout [ backdrop 90.90.240 h2 yellow (reform ["Object Viewer:" objw]) across space 0 lst: list 500x430 [ txt 500 [ ;-- First find parent and from there ; find this thing val: pick face/user-data 2 this-spot: find data face/user-data/1 this-spot: skip find next this-spot :val -2 set [this-parent this-val this-word expanded? this-depth] this-spot either expanded? [ ;-- Remove stuff that has me as a parent spot: skip find/last data :this-val 5 remove/part skip this-spot 5 spot change at this-spot 4 off ][ either object? :this-val [ ;-- Add my stuff to data below me spot: skip this-spot 5 new-data: make block! 50 foreach word next first this-val [ if unset? set/any 'val get/any in this-val word [val: unset!] repend new-data [this-val :val word off this-depth + 1] ] insert spot new-data change at this-spot 4 on ;- Expanded? ][ ;-- Edit my value this-lay: layout [ backdrop 90.90.240 h2 yellow (reform ["Value of:" this-word]) across this-area: area 500x300 (mold :this-val) this-slider: slider 16x300 return across txt yellow "do?" do-check: check off this-set: button "set" this-close: button "close" ] ;- Use compose to stick the values in ; there so there can be more than ; one of these windows open and each ; button action will refer to its ; own instance values. this-set/action: compose [ set this-val: in (this-parent) (to-lit-word this-word) new-val: load (this-area/text) if get in (do-check) 'data [new-val: set this-val do new-val] change/only at (reduce [this-spot]) 2 :new-val unview/only (this-lay) ] ;added slider control for pop-up area, and its action defined as follows this-slider/action: compose [scroll-para (this-area) (this-slider)] this-close/action: compose [unview/only (this-lay)] center-face this-lay view/new this-lay ] ] show lst ] ] supply [ ;-- Set up each face of the ; iterated pane based on what's in data face/text: none face/font/color: black count: count + cnt face/color: either even? count [200.200.200][ivory] if tail? spot: skip data ((count - 1) * 5) [return none] face/user-data: reduce [spot/1 spot/3] this-val: pick spot 2 face/text: head insert/dup reform [ either object? :this-val [ either spot/4 ["--"]["+-"] ][#] spot/3 ] " " spot/5 ] sld: slider 16x430 [ c: to-integer value * ((length? data) / 5) if c <> cnt [cnt: c show lst] ] return button "quit" [quit] ] 150x50 ] view-obj system

 [10/12] from: agem:crosswinds at: 16-Feb-2001 20:43


this-slider: slider 16x300 [scroll-para this-area this-slider] instead of this-slider: slider 16x300 .. this-slider/action: compose [scroll-para (this-area) (this-slider)] . and somehow your comment-line is to long for your (my?) mailer. So a new line without »;« was added.. Volker
>>>>>>>>>>>>>>>>>> Ursprüngliche Nachricht <<<<<<<<<<<<<<<<<<
Am 16.02.01, 20:09:10, schrieb "GS Jones" <[gjones05--mail--orion--org]> zum Thema [REBOL] Re: Object viewer:

 [11/12] from: gjones05:mail:orion at: 16-Feb-2001 15:23


From: Volker
> this-slider: slider 16x300 [scroll-para this-area this-slider] > > instead of > > this-slider: slider 16x300 > .. > this-slider/action: compose [scroll-para (this-area) (this-slider)]
Initially this was what I did, but I kept getting an error that scroll-para was undefined. That was when I started paying much closer attention to how Jeff programmed multiple pop-ups to where each dialog could have a distinct action. So I reviewed his style very closely, and experimented and discovered that my solution allowed the scroll-para to be defined and to control its own area. That was when I gained a real appreciation for Jeff's clever programming. This approach works on my set-up (Win98 and /View 0.10.38.3.1). I successfully had multiple dialogs open, changed values (I even got the /View version up to its release version of 1.0 !!! Why didn't RT think of that. ;-) successfully. I just can't click on the view object. Again though thank you for the timely input. I feel as though I have a much better understanding of managing scrolling now for my own projects.
> and somehow your comment-line is to long for your (my?) mailer. > So a new line without »;« was added.. > > Volker
Yes, sorry, I inadvertantly sent it through Outlook Express without changing the paragraph wrap length. I would be happy to resend it if someone needs the fix without the bother of manually fixing the indents. --Scott

 [12/12] from: gjones05:mail:orion at: 16-Feb-2001 6:43


From: jeff
> ...Features features.. bloat bloat... ;-)
Of course I knew that this was said in jest, but this is one of the things I really love about REBOL: it is very easy to add features. I am currently writing automation routines for my wife's new website so that she can list and maintain items on her own (the unstated subtext is so that *I* don't have to do it manually). She tries out a routine, and if she doesn't like the way I've implemented it or wants additonal features, it is so darn easy! After I finish the website stuff (and doing taxes :-( ), I am going to rewrite all her automated routines for listing items on eBay. They are currently written in dos batch, VBScript, and Tcl. They've been difficult to maintain, possibly because they are not so Internet friendly. I like Tcl and Tk, but I am already more productive in REBOL /Core and /View after a couple weeks, than I was in Tcl/Tk after a couple of months. Which really brings me to what I was droning on about in my last message. I am unclear about whether /View will be its own "product" or is it the test-bed for a "larger" system? Have I overlooked some webpage that explains this? Oh, I just realized that I'm getting way off the "topic" for this thread. I've already enjoyed using your version of the object viewer. Thanks again. --Scott

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