How to make a layout from a block
[1/8] from: moeller_thorsten::gmx::de at: 18-Apr-2002 12:03
Hi,
i have a block containing layout-information associated with a word like:
a: [title "Test" backcolor red]
i want this block to become the block of a layout like this:
main: layout [title "Test" backcolor red]
How can i do this?
Thanks
Thorsten
[2/8] from: rebol665:ifrance at: 18-Apr-2002 13:04
Hi,
I am not sure I get your problem, but have you try that :
>> a: [title "Test" backcolor red]
>> main: layout a
>> view main
Patrick
[3/8] from: carl:cybercraft at: 19-Apr-2002 0:11
On 18-Apr-02, Thorsten Moeller wrote:
> Hi,
> i have a block containing layout-information associated with a word
<<quoted lines omitted: 3>>
> main: layout [title "Test" backcolor red]
> How can i do this?
main: layout a
Too simple, eh? (:
> Thanks
> Thorsten
--
Carl Read
[4/8] from: moeller_thorsten:gmx at: 18-Apr-2002 15:07
Hi Patrick,
thanks for this. Perhaps you could help with a problem following this.
I have extended the code with like this:
add-seat: func [] [append main/pane make-face 'seat show main]
a: [style seat box 6x6 green title "Test" backcolor silver button "Add Seat"
[add-seat]]
main: layout a
view main
with the button and the function i want to be able to add styles to the face
on click.
for some reasons i haven't found out yet, nothing happens so far on clicking
the button
Any ideas
Thorsten
[5/8] from: ronald:free at: 18-Apr-2002 13:51
Bonjour Thorsten,
Thursday, April 18, 2002, 12:03:17 PM, vous avez écrit:
TM> Hi,
TM> i have a block containing layout-information associated with a word like:
TM> a: [title "Test" backcolor red]
TM> i want this block to become the block of a layout like this:
TM> main: layout [title "Test" backcolor red]
TM> How can i do this?
TM> Thanks
TM> Thorsten
try the following code :
main: layout :a
Hope it's what you wanted !
--
Best regards,
Ronald
[6/8] from: brett:codeconscious at: 19-Apr-2002 13:16
Hi Thorsten,
> I have extended the code with like this:
>
> add-seat: func [] [append main/pane make-face 'seat show main]
> a: [style seat box 6x6 green title "Test" backcolor silver button "Add
Seat"
> [add-seat]]
> main: layout a
> view main
The problem with your code is that make-face is expecting a style name
defined in the master stylesheet. You can specify a different style
sheet using the /STYLES refinement.
So here is some amended code:
stylize/master [seat: box 6x6 green]
add-seat: func [] [
append main/pane make-face 'seat show main
]
a: [
title "Test" backcolor silver
button "Add Seat" [add-seat]
]
main: layout a
view main
Your next issue will be to position the newly made seat face. You will
need to do this by changing the OFFSET of the face you just created or
by using the /SPEC refinement of make-face like this:
stylize/master [seat: box 6x6 green]
add-seat: func [] [
append main/pane make-face/spec 'seat [offset: 25x5]
show main
]
a: [
title "Test" backcolor silver
button "Add Seat" [add-seat]
]
main: layout a
view main
Regards,
Brett.
[7/8] from: moeller_thorsten:gmx at: 19-Apr-2002 10:59
Hi Brett,
thanks for your suggestions. As this code is just the beginning test, how a
small app to create a seat-plan could work, i have a some additional
questions.
I improved my own code, but think it is not very elegant. I added two fields
to to get the number of rows and columns to generate.
Rebol []
;--- defining seat style
saal-styles: stylize [seat: box 6x6 green [seat/color: red]]
;--- Adding seats to layout
add-seats: func [ lines [integer!]
quantity [integer!]
] [
;--- Adding lines
repeat y lines [
;--- Adding seats
repeat x quantity [
append main [seat]
]
append main [below across]
]
;--- generate new window
unview/all
view/options center-face layout main [no-title]
]
;--- Main Layout
main: [ at 2x2 box 220x16 0.0.128 left bold "Seat-Plan-Generator" font
[name: "Arial" size: 11]
below
styles saal-styles
backcolor silver
text bold "How many lines should be created?"
lines: field
text bold "How many seats should be created?"
qty: field
across
at 2x150 button "Quit" effect [gradient 0.0.0] [unview/all]
button "Create" effect [gradient 0.0.0] [add-seats (to-integer
lines/text) (to-integer qty/text)]
return
]
;--- Start program
view/options center-face layout main [no-title]
Your code only generates one seat, even if i click the button several times.
The next problem is that i need the seats to store an information so the
seats have to look like "seat1: seat". If i add the seats like this i get an
error that "seat1" is not defined in this context when the new window is
generated. The second one is that the seat should perform an action on click, like
changing color or so (see style definition in code). For this reason every
seat must be adressable like "seat1" or "seat23" as well, but how can i
implement that when the style is defined. There i just can define a general action,
not knowing the exact seat number?
Perhaps you find a minute to think about it. I will try to solve it on my
own as well.
Best wishes to the other side of this world.
Thorsten
[8/8] from: brett:codeconscious at: 19-Apr-2002 20:26
Hi,
> thanks for your suggestions.
No problem.
> As this code is just the beginning test, how a
> small app to create a seat-plan could work, i have a some additional
> questions.
Oh oh. :^)
> I improved my own code, but think it is not very elegant. I added two
fields
> to to get the number of rows and columns to generate.
At this stage, I think you have gone the right way to build the layout block
dynamically.
> Your code only generates one seat, even if i click the button several
times.
No, actually it produces a seat each time you click. The problem is
that they are all at the same position. This is because with make-face
you have to do more work. With layout the positioning is done for you.
This is why I mentioned offset. But no matter, now that you are using
a generated layout block there is no problem.
> ...every
> seat must be adressable like "seat1" or "seat23" as well, but how can i
> implement that when the style is defined. There i just can define a
general action,
> not knowing the exact seat number?
Ok. Instead of using variables to name each seat, how about we define the
seat
style to include a seat number. We can do this with the WITH statement. Also
the action should refer to FACE. FACE will be the seat that is clicked on.
Try these changes to your code (1) a seat-number variable is added to the
style itself (2) the action is changed to refer to FACE:
;--- defining seat style
saal-styles: stylize [
seat: box 6x6 green with [ seat-number: none ] [
face/color: red
print face/seat-number
]
]
Also you need this to set the seat-number. In this case I have used a pair
to
identify it - but naturally you can use whatever you like. Again I have used
WITH - this time to set seat-number of the face (our seat):
;--- Adding seats
repeat x quantity [
append main compose/deep [
seat with [seat-number: (to-pair reduce [x y])]
]
]
> Best wishes to the other side of this world.
:^) Thanks.
Brett.
Notes
- Quoted lines have been omitted from some messages.
View the message alone to see the lines that have been omitted