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

[REBOL] Re: layout refinements

From: brett::codeconscious::com at: 29-Jul-2001 12:52

Hi Doug,
> Can someone provide short examples of the > refinements to "layout" which are in the view > developers guide, section 3.1:
Here's some examples...
> /size A PAIR!
Sets the size of the face returned by layout: view layout/size [text "my text"] 500x100 which is equivalent to: view layout [size 500x100 text "my text"]
> /offset A PAIR! >
view layout/offset [text "my text"] 100x100 which offsets the face returned by layout from the top left corner of the screen (0x0).
> /styles A stylesheet block that was created with the > STYLIZE function.
my-styles: stylize [text: text green] view layout/styles [text "my text"] my-styles which is like: my-styles: stylize [text: text green] view layout [styles my-styles text "my text"] But note that using the /styles refinement appears to contrain your use of styles to only what is available in the specified stylesheet, whereas using the styles keyword inside a layout specification adds those styles to what you have available by default. For example this is ok (NICE-TEXT is added to the default styles including TEXT): my-styles: stylize [ nice-text: text orange] view layout [styles my-styles nice-text "orange text" text "normal text"] but the following results in an error because the TEXT keyword is no longer available: my-styles: stylize [ nice-text: text orange] view layout/styles [nice-text "orange text" text "normal text"] my-styles
> /origin A PAIR! >
view layout/origin [text "my text"] 0x0 which is equivalent to: view layout [origin 0x0 text "my text" text "text 2"] Compare the results of this with earlier examples. You'll see that the text inside the face butts up into the top left corner of the face returned by layout. Origin defines the starting point for laying out the various layout elements within the face that layout constructs.
> /parent Specifies the style of the top-level face that > is produced from the layout. The parent can be > specified as a style name or as an actual instance of > the style.
First a little background. The LAYOUT function reads the keywords you supply in your layout specification to create face objects!. These face objects are contained within a single face object! that is returned by the LAYOUT function. This face object is then supplied to the VIEW layout to display your window. It is this face object that is returned from LAYOUT which is affected by the /parent refinement. Without specifying /parent the LAYOUT function will create a face to contain your specified elements according to a default style (like panel). Using /parent allows you to instruct LAYOUT to create this containing face according to your specified style or face. For example I create a box: layout [ b: box red ] view b And I have this layout: view layout [title "parent example" text "this is a test"] I decide that the face returned by layout should in fact look like my nice red box: view layout/parent [title "parent example" text "this is a test"] b I don't know too much more about this because I haven't really used it. I think though that it is used in VID when you create a PANEL.
> /options Specifies the VIEW options when the face is > displayed with the VIEW function. >
The /OPTIONS refinement belongs to the VIEW function. I'll leave that to someone else right now because I have to go :) HTH Brett.