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

New to list

 [1/7] from: jeperk::swbell::net at: 9-Jun-2003 11:33


Hello all, my name is John Perkins and I have been lurking for quite some time now. Thank you all for the help you have given me without knowing. My question may be rather simple. I do not understand how to add buttons or other named objects to a view interface during execution. Several projects I am working on need to create variables and buttons on the fly since I have no idea how many I will need at run time. A simple example would be a layout with a button for creating a new button. The buttons would need to be accessable in order to change attributes later, such as text, color, size, etc. Sorry if this is vague, I'm dumbing it down so that I get the most simple explanation possible. The most elegant solution will likely confuse me as much as many of the REBOL examples do. All are correct, but many are quite useless and confusing in pactice. Thank you, John

 [2/7] from: patrick::philipot::laposte::net at: 9-Jun 20:21


Hi John I suggest you to have a look at the following threads: http://www.escribe.com/internet/rebol/m27924.html http://www.escribe.com/internet/rebol/m27944.html Ciao Patrick

 [3/7] from: greggirwin:mindspring at: 9-Jun-2003 13:27


Hi John, Welcome out of lurk mode! :) jsnP> My question may be rather simple. I do not understand how to add jsnP> buttons or other named objects to a view interface during execution. jsnP> Several projects I am working on need to create variables and buttons on jsnP> the fly since I have no idea how many I will need at run time. There are lots of variables in that kind of picture. For example, how are the names to be used if you don't know what they are until runtime, and do you need to really create them "on the fly" or is the app data/configuration driven where it's static once a particular session is running? I usually prefer to build a block I can feed to LAYOUT, but there are times when that just isn't a good solution. ; Build a layout block dynamically buttons: [ ; << could be loaded from a file open "Open" [print "Open"] close "Close" [print "Close"] save "Save" [print "Save"] ] block: copy [ size 150x200 ] foreach [name text action] buttons [ append block reduce [ to set-word! join 'b- name 'button text action ] ] view layout block ;======================================================== ; Add faces dynamically at runtime count: 0 view lay: layout [ size 150x400 button "Add Button" [ f: make face append second get-style 'button [state: off] count: count + 1 f/text: join "Button " count set to word! join 'b- count f f/action: reduce ['print f/text] f/offset: to pair! reduce [20 add 30 count * 30] append lay/pane f show lay ] ] HTH! -- Gregg

 [4/7] from: jeperk:swbell at: 9-Jun-2003 16:13


Here is some code you might be interested in. It should also give you an idea of exactly what I am trying to do. I am making a (for lack of a better word) "gummy" widget. It stretches and slides to show length, start and end information visually. I planned to use it in a GUI for Linux fdisk, a scheduler, audio/video applications, anything that could display multiple linear pieces. As you can see, you never know how many you would need before hand. I've been playing with Linux configuration tools for a while and worked out a deal with REBOL to allow the source code to be released under GPL with the understanding that to recompile the apps would require the Linux REBOL SDK. You would get the executable and the source, but to make changes, you have to buy the SDK. If anyone knows how to integrate this as a normal "button" type thing, please let me know. If REBOL wants to include a working version in REBOL/VIEW, you have my full permission, free of charge. (just clean it up and help me make it work!) I have added a hack to allow the right mouse button menu to work under Linux. On Linux view, the right mouse events behave differently than in Windows. It constantly sends over and away messages. This runs with the current stable VIEW releases. Thanks, John Here is the code: REBOL [ Title: "Gummy" Date: 27-May-2003 Version: 0.0000001 File: %gummy.r Author: "John Perkins" Purpose: {Trying to create a widget for showing length, start, end, etc. It would be useful for audio/video apps, GUI for linux fdisk, scheduling, who knows what else. Buggy as hell at the moment. } Email: [jeperk--swbell--net] Note: "Help? How can I make this usable like a button or slider? So that I can include it multiple times simply?" ] ;#include %../source/mezz.r ;#include %../source/prot.r ;#include %../source/view.r ; I mostly use SDK. Why does Linux /VIEW(not SDK) make such HUGE fonts?" rc: false view layout [ size 300x300 style inpoint box 6x40 font-size 11 feel [ engage: func [face action event] [ if action = 'down [face/data: event/offset] if find [over away] action [ face/offset/x: face/offset/x + event/offset/x - face/data/x if face/offset/x > op1/offset/x [face/offset/x: op1/offset/x - 1] mp1/size/x: op1/offset/x - face/offset/x mp1/offset/x: face/offset/x mp1/text: mp1/size/x ip1/text: ip1/offset/x show system/view/screen-face/pane/1 ; <----Have to show everything, or else I get BAD redraw errors ] ] ] style outpoint box 6x40 font-size 11 feel [ engage: func [face action event] [ if action = 'down [face/data: event/offset] if find [over away] action [ face/offset/x: face/offset/x + event/offset/x - face/data/x if face/offset/x < ip1/offset/x [face/offset/x: ip1/offset/x + 1] mp1/size/x: face/offset/x - mp1/offset/x mp1/text: mp1/size/x op1/text: op1/offset/x show system/view/screen-face/pane/1 ] ] ] style midpoint box font-size 11 feel [ engage: func [face action event] [ if action = 'down [face/data: event/offset] if find [over away] action [ if rc = false [ face/offset/x: face/offset/x + event/offset/x - face/data/x ip1/offset/x: face/offset/x op1/offset/x: face/offset/x + face/size/x mp1/text: mp1/size/x ip1/text: ip1/offset/x op1/text: op1/offset/x show system/view/screen-face/pane/1 ] ] ; ------------------------------help me below - alt-down is also triggering the drag code with over and away if action = 'alt-down [rc: true inform layout [ text "Some kind of menu goes here, but it won't let go and clicking in the main window sends it out of range!" button "I feel your pain" [ rc: false hide-popup] ] rc: false ] ;------------------------------to right here (fixed with rc toggle, now works in win and lin) ] ] across mp1: midpoint "Drag Me" 40x40 black at mp1/offset ip1: inpoint "IN" navy at 60x20 ;<-------------------How to avoid hard coding this? op1: outpoint "OUT" teal at 60x90 below text "Drag the IN and OUT points to adjust length." text "Drag the middle to adjust position." text "Right-click for a broken menu." text "The values are shown for debugging." text "Still to add things like max length, etc." ;button "probe it" [print "debug" probe mp1/offset probe mp1/size probe op1/offset] ]

 [5/7] from: antonr:iinet:au at: 10-Jun-2003 11:39


1) This is kind of hard coded: show system/view/screen-face/pane/1 The widget doesn't know that it's parent window is the first window that has been opened. At least, it's brittle code. I recommend: show face/parent-face Or you could name your window: view lay: layout [... then just: show lay 2) ;at 60x20 ;<------------How to avoid hard coding this? at ip1/offset + (mp1/size * 1x0) 3) To be totally self contained, your widget should create the two endpoints (as faces) and put them in its pane block. That way, they are all treated as one. Or you could use the draw dialect to draw your endpoints, but that's probably more complicated. A way for the midpoint to suck in the in/outpoints, still using the existing layout code is to do this: style midpoint box ... with [ pane: get in layout [ origin 0 space 0 box 6x40 font-size 11 feel [...] ; inpoint (pane/1) box 6x40 font-size 11 feel [...] ; outpoint (pane/2) ] 'pane ] That steals the pane block from a new layout face (which is then forgotten). The midpoint widget then takes that pane for itself. You will have to modify the feel code to be relative. ie. convert mp1/size/x -> face/parent-face op1/offset/x -> face/parent-face/pane/2 Anton.

 [6/7] from: jeperk:swbell at: 10-Jun-2003 1:23


It is amazing how much you know with so little documentation. Where did you learn this? I would love to find this kind of information. I've made the first two changes. Those were very easy to do. This one looks like a bit of reworking and I don't fully understand how it functions. Anton wrote:
>A way for the midpoint to suck in the in/outpoints, still using the existing >layout code is to do this:
<<quoted lines omitted: 12>>
> mp1/size/x -> face/parent-face > op1/offset/x -> face/parent-face/pane/2
I hate to seem dense, but my original code, modified to be relative should replace the ". . ." in the three sections? Don't get me wrong, I appreciate your input very much. I just don't like to make large changes without understanding why I am doing it. Could you explain this somewhat? For example, I can find nothing on the word "with" in any of the REBOL docs. Also I still have the problem of adding and removing these during execution in such a way that I can individually address them. If anyone knows how to do this, please enlighten me. Thanks again, John

 [7/7] from: antonr:iinet:au at: 11-Jun-2003 0:38


Hi John,
> It is amazing how much you know with so little documentation. > Where did you learn this? I would love to find this kind of information.
By trying and making my own styles over and again, I learned gradually. I also had to stare at some other people's code for a while before it began to make sense. I recommend to persevere.
> I've made the first two changes. Those were very easy to do. > This one looks like a bit of reworking and I don't fully understand how
<<quoted lines omitted: 24>>
> I hate to seem dense, but my original code, modified to be relative > should replace the ". . ." in the three sections?
Yep, just move the code you had for each of your in/outpoints, but their feel code should be converted as I said above. I tried to show the main point of stealing the panes. Sorry for any confusion.
> Don't get me wrong, I appreciate your input very much. I just don't > like to make large changes without understanding why I am doing it. > Could you explain this somewhat? For example, I can find nothing on the > word "with" in any of the REBOL docs.
Well, it is mentioned, though briefly, just before section 7, in: http://www.rebol.com/docs/view-guide.html I probably picked it up from code examples more than the docs. I've got lots of examples of my own on rebsite "Anton": Determine rebsite "Anton" now and in the future with: select load-thru http://www.reboltech.com/index.r [folder "Anton"] ;== http://www.lexicon.net/anton/rebol/index.r Take your View desktop to the returned url, and navigate to the gui/ folder. There are some simple examples of new styles in there. Do this: probe face You can see a primordial face and its facets within. 'with is just the layout dialect's way of allowing you to easily set the facets of a face (or a style) you are building. These two examples are equivalent: layout [box "hello" red] layout [box with [text: "hello" color: red]] In the first example above, the string "hello" was placed in the block directly after 'box. The layout dialect sees that string and sets the box face's text facet to that string. The second example does the same thing more explicitly.
> Also I still have the problem of adding and removing these during > execution in such a way that I can individually address them. > If anyone knows how to do this, please enlighten me. > > Thanks again, > John
Anton Rolls.

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