weird influence of the gridsize and the grid on the drawing ofsquares by script

MisterX b.xavier at internet.lu
Wed Jun 29 15:21:59 EDT 2005


Eric, everyone,

This approach is ultra fast. I use it all the time ;)

The next thing you might ask is how do i know where i clicked? ;)

This is an example taken from my XOSMediaLib. When you click either on the
item in the grid or the grid. This script is in the group script that
contains the "grid" field and the images i display in between hthis grid.

cheers
Dont forget to change the linecolors to your liking ;)
Xav

Hopefully the script is self explanatory - it was writen to be templated
into other image groups the oop way in RunRev (see how i refer to
"thisgroup"... I think there's an error in it though because i dont always
get the right square hilited ;)...

so if it helps, help me back ;)

on mouseup
  put "ImgList" into subgroup
  put the long name of me into thisgroup
  get the short name of the target
  
  if it is "Gridfield" then
    put the clickLoc into xy
     
    put the tabstops of fld "gridfield" of thisgroup into fgw
    put the textheight of fld "gridfield" of thisgroup into fgh

    put the left of fld "GridField" of thisgroup into MinW
    put the top of fld "Gridfield" of thisgroup into MinH
    
    put (item 1 of xy - MinW) into deltaX
    put (item 2 of xy - MinH) into deltaY
     
    put deltaX div fgw + 1 into thiscolumn
    put deltaY div fgh + 1 into thisrow
     
    put the width  of fld "GridField" of thisgroup div fgw into columns
    put the height of fld "GridField" of thisgroup div fgh into rows
    
    get (thisrow-1) * columns + thiscolumn
    set the hilitedline of fld "images" of grp subgroup to it
    
  else
    
    put the short id of the target & tab & it into thisimage
    put lineoffset(thisimage,fld "images" of grp subgroup) into x
    
    if x < 1 then
      ShowImageList
      put lineoffset(thisimage,fld "images" of grp subgroup) into x
    end if
    
    set the hilitedline of fld "images" of grp subgroup to x
     
  end if
  
  send "mouseup" to fld "images" of grp subgroup
  
end mouseup

oh yes, this is a scrolling group. This poses other problems...

If you want to help, i have an bonus external stack with 1500 icons to plug
in to it anytime for testing ;)

You can download the whole stack directly from here
http://monsieurx.com/modules.php?name=Downloads&d_op=getit&lid=82

For the real challenge, i have a 15000 icon HyperCard stack i can't port to
Metacard or runrev... i'm just scared to recucitate my mac ;)

Note: XOSMediaLib requires GIM to resize correctly on MetaCard or RunRev.

Join the fun of object oriented modular shared libraries or GUIs across any
app anytime in RunRev at

http://monsieurx.com


> -----Original Message-----
> From: use-revolution-bounces at lists.runrev.com 
> [mailto:use-revolution-bounces at lists.runrev.com] On Behalf Of 
> Eric Chatonet
> Sent: Wednesday, June 29, 2005 21:02
> To: How to use Revolution
> Subject: Re: weird influence of the gridsize and the grid on 
> the drawing ofsquares by script
> 
> Hi Wouter,
> 
> When I need a grid I use a field the borderColor of which I set.
> For instance with a field named "Grid" which is 141 pixels high and
> 281 pixels broad (I picked this handler in a project):
> 
> on creategrid pGridValue
>    local tLoc
>    -----
>    lock screen
>    put the loc of fld "Grid" into tLoc
>    set the textHeight of fld "Grid" to pGridValue
>    set the tabstops of fld "Grid" to pGridValue-1,2 * pGridValue - 1
>    set the height of fld "Grid" to (140 div pGridValue) * 
> pGridValue + 1
>    set the width of fld "Grid" to (280 div pGridValue) * 
> pGridValue + 1
>    set the loc of fld "Grid" to tLoc
>    unlock screen
> end creategrid
> 
> Another approach which don't misunderstand the bug but can help?
> 
> Le 29 juin 05 à 20:45, Wouter a écrit :
> 
> > Hi all,
> >
> > After reinvestigating bug 2683 for which Mark Waddingham asked a 
> > recipe,  the weird influence of the gridsize and the grid on the 
> > drawing of squares by script surfaced. Will it become an 
> "undocumented 
> > feature" or is this a bug?  Anyway I didn't know until now.
> > 1 new stack and 1 button with the following script will show:
> >
> > on mouseUp
> >   put gridsize into  tOldgridsize
> >   put the grid into tOldgrid
> >   set the grid to true  ### Mark Schonewille for this detail
> >   if there is no img "test" then create img "test"
> >   set the rect of img "test" to 0,0,400,400
> >   set gridsize to 1
> >   creategrid 50,50
> >   set gridsize to 2
> >   creategrid 160,50
> >   set gridsize to 3
> >   creategrid 50,160
> >   set gridsize to 4
> >   creategrid 160,160
> >   set gridsize to 6
> >   creategrid 50,270
> >   set gridsize to 10
> >   creategrid 160,270
> >   set gridsize to  tOldgridsize
> >   set the grid to tOldgrid
> > end mouseUp
> >
> > on createGrid x,y  ### topleft of grid
> >   choose the rectangle tool
> >   set the filled to true
> >   set the brushcolor to 255,255,255
> >   set the pencolor to 0,0,0
> >   put 10 into tCol   ### number of columns
> >   put 10 into tRow   ### number of rows
> >   put 10 into tSq    ### tSq = size of square
> >   put 1 into tCY
> >   repeat tRow
> >     put (y + (tCY * tSq) - tSq) into tY
> >     put 1 into tCX
> >     repeat tCol
> >       put (x + (tCX * tSq) - tSq) into tX
> >       drag from tX,tY to tX + tSq ,tY + tSq
> >       add 1 to tCX
> >     end repeat
> >     add 1 to tCY
> >   end repeat
> >   choose browser tool
> > end createGrid
> >
> > So when drawing by script, the gridsize and/or the grid should be 
> > taken care of.
> > May be the influence of those settings have a bigger scope 
> (not tested 
> > yet).
> >
> > Greetings,
> > Wouter
> > _______________________________________________
> > use-revolution mailing list
> > use-revolution at lists.runrev.com
> > Please visit this url to subscribe, unsubscribe and manage your 
> > subscription preferences:
> > http://lists.runrev.com/mailman/listinfo/use-revolution
> >
> >
> 
> _______________________________________________
> use-revolution mailing list
> use-revolution at lists.runrev.com
> Please visit this url to subscribe, unsubscribe and manage 
> your subscription preferences:
> http://lists.runrev.com/mailman/listinfo/use-revolution
> 




More information about the use-livecode mailing list