Proportional table column spacing upon resizeStack - how to

Eric Chatonet eric.chatonet at sosmartsoftware.com
Tue Mar 18 12:07:26 EDT 2008


Hi Mark,

Here is another approach using a function that respects the first  
column and distributes x other columns according to the width of the  
field:

on resizestack pNewWidth,pNewHeight,pOldWIdth,pOldHeight
  local tRect,tNumOfColumns
  -----
   put the rect of fld "Table" into tRect
   put pNewWidth - 4 into item 3 of tRect
   set the rect of fld "Table" to tRect
   -----
   put <integer> into tNumOfColumns -- columns total wanted
   set the tabStops of fld "Table" to NewTabStops(the tabStops of fld  
"Table", tNumOfColumns,the width of fld "Table") --
end resizestack
-----------------------------------------------------
function NewTabStops pTabStops, pNumOfColumns,pFldWidth
   return item 1 of pTabStops & comma & item 1 of pTabStops + round 
((pFldWidth - item 1 of pTabStops) / (pNumOfColumns - 1))
end NewTabStops

There are so many ways to achieve the goal with Rev :-)

Best regards from Paris,
Eric Chatonet.

Le 18 mars 08 à 16:35, mfstuart a écrit :

>
> Merci Eric, that worked.
> Now I'll play around with that script to resize the columns, but  
> the first
> column.
> Then change it so that the right most columns' right border always  
> is at the
> right most position of the field.
>
> Regards,
> Mark Stuart
>
>
>
> Eric Chatonet wrote:
>>
>> Hi Mark,
>>
>> As the engine sends four params (see below) with the resizestack
>> message, it's quite easy to use them to achieve the goal:
>>
>> on resizestack pNewWidth,pNewHeight,pOldWidth,pOldHeight
>>    local tRect,tTabStops,tTabStop,tNewTabStops
>>    -----
>>    put the rect of fld "Table" into tRect
>>    put pNewWidth - 4 into item 3 of tRect
>>    -- -4: you'll use an appropriate value depending on your context
>>    set the rect of fld "Table" to tRect -- resizes the field
>>    ------
>>    put the tabStops of fld "Table" into tTabStops
>>    repeat for each item tTabStop in tTabStops
>>      put round(tTabStop * (pNewWidth / pOldWidth)) & comma after
>> tNewTabStops
>>      -- a value in pixels (integers) according to the ratio between
>> pNewWidth and pOldWidth
>>    end repeat
>>    delete last char of tNewTabStops -- comma
>>    set the tabStops of fld "Table" to tNewTabStops
>> end resizestack
>>
>> See tabStops in the docs :-)
>>
>> Best regards from Paris,
>> Eric Chatonet.
>>
>> Le 17 mars 08 à 17:35, mfstuart a écrit :
>>
>>> Hi All,
>>>
>>> I'm trying to apply this to my project, where I'm using a table
>>> field object
>>> to display data with several columns.
>>>
>>> What I'd like to do:
>>> Upon the user resizing the stack (the width in this case), I would
>>> like to
>>> resize the table columns proportionally. The table object is  
>>> currently
>>> resized in the stacks "on resizeStack" script.
>>> So this would involve adjusting each item in the tabStops of the  
>>> table
>>> field, during the resizeStack script.
>>>
>>> How do I do this?
>>>
>>> TIA,
>>> Mark Stuart

----------------------------------------------------------------
Plugins and tutorials for Revolution: http://www.sosmartsoftware.com/
Email: eric.chatonet at sosmartsoftware.com/
----------------------------------------------------------------





More information about the Use-livecode mailing list