See the example below. A few comments,
- it's good to have standard form definition editable with Form editor
- overlapping isigraph canvases may not be a good idea
- observe painting stragegy using state and a rendering
verb, callable both from paint event and programmatically.
require 'gl2'
coinsert 'jgl2'
RECT=: _4 ]\ 10 10 20 70,20 15 50 40,16 18 65 11
COLS=: 16bff0000 16b00a000 16b0000ff
FG=: 16bffffff
BK=: 16ba0a0a0 16be0e0e0
glrgbx=: [: glrgb 256 256 256&#:
F=: 0 : 0
pc f;
xywh 7 6 50 50;cc lst listbox lbs_extendedsel lbs_multiplesel bottommove;
xywh 65 7 50 50;cc g isigraph rightmove bottommove;
pas 6 6;pcenter;
rem form end;
)
f_run=: 3 : 0
SEL=: 0
wd F
wd 'set lst *',;<@(,&LF)@":"1 RECT
wd 'setselect lst 0'
wd 'pshow;'
)
f_close=: 3 : 0
wd'pclose'
)
f_lst_select=: 3 : 0
SEL=: 0".lst_select
show'' NB. wd'setinvalid g' -- alternative
)
f_g_paint=: show
show=: 3 : 0
glclear ''
glpen 1,PS_SOLID [ glrgbx 0{BK
glbrush '' [ glrgbx 1{BK
glrect 5 5,10-~glqwh''
glbrush '' [ glrgbx FG
for_i. SEL do.
glpen 1,PS_SOLID [ glrgbx i{ COLS
glrect i{RECT
end.
glpaint ''
)
f_run''
--- Brian Schott <[EMAIL PROTECTED]> wrote:
> In the code snippet below, the verb "paint" is meant
> to produce rectangles that are defined in the noun "rects",
> but only the first rectangle is painted, for me.
>
> So first I would like to know how to produce the other
> rectangles.
>
> And second I would like to know how to produce rectangles
> that have dimensions that are compatible with the dimensions
> of isigraph controls created with "xywh" dimensions. I think
> there is a difference caused by measures in "pixels" and in
> "units", but I cannot find a conversion between the two
> measurement scales.
>
> ************test script below**************
>
> NB. rectangles.ijs
> NB. 5/23/7
>
> require'gl2'
> coinsert'jgl2'
>
> GL2LAB=: 0 : 0
> pc gl2lab closeok;
> xywh 0 0 500 500;cc g isigraph rightmove bottommove;
> cc pic isigraph;setxywhx pic 10 30 40 70;
> pas 0 0;
> rem form end;
> )
>
> gl2lab_run=: 3 : 0
> wd GL2LAB
> wd'pshow;'
> )
>
> gl2lab_g_paint=: 3 : 0
> glrgb 255 0 0 NB. RGB red
> glbrush '' NB. red brush
> glrect 10 30 40 70 NB. red rectangle
> )
>
> rects =: 70 70,"1~15 15, 95 15,: 175 15
>
> paint=:4 : 0
> NB. wd'psel paledit;pactive;pshow'
> glsel 'pic'
> glrgb x
> glbrush ''
> glrect y{rects
> glpaint ''
> wd 'pshow;'
> )
>
> NB. create form (or just repaint if it already exists)
> gl2lab=: 3 : 0
> try.
> wd'psel gl2lab'
> glclear'' NB. clear out old drawing
> gl2lab_g_paint'' NB. new drawing
> glpaint'' NB. copy to screen
> catch.
> gl2lab_run''
> end.
> )
>
> Note 'demo'
> gl2lab_run''
> 255 0 0 paint 0 NB. paints
> 255 255 0 paint 1 NB. NO paint
> 255 0 255 paint 2 NB. NO paint
> )
>
> ************test script above**************
>
> (B=)
>
> Brian Schott
> Atlanta, GA, USA
> schott DOT bee are eye eh en AT gee em ae eye el DOT com
> http://schott.selfip.net/~brian/
> ----------------------------------------------------------------------
> For information about J forums see http://www.jsoftware.com/forums.htm
>
____________________________________________________________________________________Fussy?
Opinionated? Impossible to please? Perfect. Join Yahoo!'s user panel and lay
it on us. http://surveylink.yahoo.com/gmrs/yahoo_panel_invite.asp?a=7
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm