2010-05-26 89 views
0

我想用3個參數爲以下徽標徽章創建嚮導。我可以使標題動態,但對於圖像和漸變,它是硬編碼的,因爲我看不出如何使它們變爲動態。圖片後的代碼如下:如何爲此徽標創建嚮導創建動態面板佈局?

alt text http://reboltutorial.com/bugs/wizard1.png

alt text http://reboltutorial.com/bugs/wizard2.png

custom-styles: stylize [ 
    lab: label 60x20 right bold middle font-size 11 
    btn: button 64x20 font-size 11 edge [size: 1x1] 
    fld: field 200x20 font-size 11 middle edge [size: 1x1] 
    inf: info font-size 11 middle edge [size: 1x1] 
    ari: field wrap font-size 11 edge [size: 1x1] with [flags: [field tabbed]] 
] 

panel1: layout/size [ 

    origin 0 space 2x2 across 
     styles custom-styles 
    h3 "Parameters" font-size 14 return 
    lab "Title" fld_title: fld "EXPERIMENT" return 
    lab "Logo" fld_logo: fld "http://www.rebol.com/graphics/reb-logo.gif" return 
    lab "Gradient" fld_gradient: fld "5 55 5 10 10 71.0.6 30.10.10 71.0.6" 
] 278x170 

panel2: layout/size [ 
    ;layout (window client area) size is 278x170 at the end of the spec block 
    at 0x0 ;put the banner on the top left corner 
    box 278x170 effect [ ; default box face size is 100x100 
     draw [ 
     anti-alias on 
     line-width 2.5 ; number of pixels in width of the border 
     pen black  ; color of the edge of the next draw element 

     fill-pen radial 100x50 5 55 5 10 10 71.0.6 30.10.10 71.0.6 

     ; the draw element 
     box  ; another box drawn as an effect 
      15  ; size of rounding in pixels 
      0x0 ; upper left corner 
      278x170 ; lower right corner 
     ] 
    ] 
    pad 30x-150 
    Text fld_title/text font [name: "Impact" size: 24 color: white] 
    image http://www.rebol.com/graphics/reb-logo.gif 
] 278x170 

main: layout [ 
    vh2 "Logo Badge Wizard" 
    guide 
    pad 20 
    button "Parameters" [panels/pane: panel1 show panels ] 
    button "Rendering" [show panel2 panels/pane: panel2 show panels] 
    button "Quit" [Unview] 
    return 
    box 2x170 maroon 
    return 
    panels: box 278x170 
] 

panel1/offset: 0x0 
panel2/offset: 0x0 

panels/pane: panel1 

view main 
+0

我還沒有使用繪製方言,所以我對自己在這裏會做些什麼感到困惑。有一些使用* compose *和繪製方言來構建規範的示例,但沒有一個在構建規範後對其進行了修改。也許是在AltME上提出的一個問題。 – HostileFork 2010-05-27 18:27:05

回答

1

使該塊用於第二佈局的模板。

把你想要有變量,並與()

渲染時,做一個拷貝/深做一個模板拷貝,然後撰寫/深,以取代從參數屏幕所採取的變量,創建環繞從您的模板副本中進行佈局,並將窗格設置爲新佈局。