Unable to scale an jpeg on a datagrid form

Got a LiveCode personal license? Are you a beginner, hobbyist or educator that's new to LiveCode? This forum is the place to go for help getting started. Welcome!

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller

Post Reply
Simon Knight
Posts: 854
Joined: Wed Nov 04, 2009 11:41 am
Location: Gunthorpe, North Lincs, UK

Unable to scale an jpeg on a datagrid form

Post by Simon Knight » Thu Jul 27, 2023 12:24 pm

I need to display a list of images so I decided to follow the tutorial found here : https://lessons.livecode.com/m/datagrid ... -of-people

My datagrid deviates from the tutorial in that the images available on disk are quite large being approximately 500 pixels on the long edge. My aim is to have them displayed at 180 by 180 pixels but so far I have failed.

I note that the boiler plate comments mention a resizecontrol handler but I am unclear where this is or should be.

Code: Select all

on FillInData pDataArray
   -- This message is sent when the Data Grid needs to populate
   -- this template with the data from a record. pDataArray is an
   -- an array containing the records data.
   -- You do not need to resize any of your template's controls in
   -- this message. All resizing should be handled in resizeControl.
   
   -- Example:
   
   set the text of field "Title" of me to pDataArray["Title"]
   set the text of field "Caption" of me to pDataArray["Caption"]
   set the filename of image "Rowimage" of me to pDataArray["Folderpath"] & "/" & pDataArray["ThumbnailFile"]
   ##set the width of image "Rowimage" to 180  -- Does not work
   ##set the height of image "Rowimage" to 180 -- Does not work
   
   
end FillInData

on LayoutControl pControlRect, pWorkingRect
   local theFieldRect
   
   -- This message is sent when you should layout your template's controls.
   -- This is where you resize the 'Background' graphic, resize fields and 
   -- position objects.
   -- For fixed height data grid forms you can use items 1 through 4 of pControlRect as
   -- boundaries for laying out your controls.
   -- For variable height data grid forms you can use items 1 through 3 of pControlRect as
   -- boundaries, expanding the height of your control as needed.
   -- The working rect is defined area of the control you can safelt use.
   -- Use this rect to make sure your controls don't overlap with any edit mode controls.
   
   -- Example:
   
   set the width of image "Rowimage" to 180  -- does not work
   set the height of image "Rowimage" to 180 -- does not work
   set the right of image "RowImage" of me to item 3 of pControlRect - 5
   put the left of image "RowImage" of me into theLeft
   
   	
   put the rect of field "Title" of me into theRect
   put theLeft - 10 into item 3 of theRect
   set the rect of field "Title" of me to theRect
   	
   put the rect of field "Caption" of me into theRect
   put theLeft - 10 into item 3 of theRect
   set the rect of field "Caption" of me to theRect
   	
   set the rect of graphic "Background" of me to pControlRect
end LayoutControl
I never have liked datagrids!

best wishes
S
best wishes
Skids

stam
Posts: 2722
Joined: Sun Jun 04, 2006 9:39 pm
Location: London, UK

Re: Unable to scale an jpeg on a datagrid form

Post by stam » Thu Jul 27, 2023 7:14 pm

Hi Simon,

I think the 'resizeControl' is just mentioned if you want to resize the entire datagrid, not its controls, which should be done in layoutControl, which in turn I think is triggered by resizing the datagrid.

I haven't tested your code because frankly I don't have the time to create this from scratch (but feel free to share if you have one!)

HOWEVER - I note that you haven't used 'of me' in your resizing code. You must do this as any manipulation of a control is specific to the current row which is identified as 'me' - otherwise only the 1st row is affected. For example, the correct syntax would be

Code: Select all

set the width of image "Rowimage" of me to 180
If that doesn't fix your issue, please consider sharing a test stack (and some images) to help others help you ;)

Best regards
Stam

Simon Knight
Posts: 854
Joined: Wed Nov 04, 2009 11:41 am
Location: Gunthorpe, North Lincs, UK

Re: Unable to scale an jpeg on a datagrid form

Post by Simon Knight » Fri Jul 28, 2023 9:27 am

Hi Stam,

Thanks

School boy error on me:

I foolishly changed an existing datagrid table to a form adding the dodgy code I quoted above. This was a bad bad error. My app, which in mitigation I had rediscovered on my hard drive from a few years ago also contained code that set up the table columns and tried to populate them as well as other stuff.

It seems that a datagrid form does not like being told to modify and populate its non-existent columns. All sorts of odd things happened ending up with Livecode pulling stumps and leaving the field!

Then to top it off I discovered a more recent version of the application that does not use datagrids at all and instead uses a custom control that I designed back when I was obviously sharper than I'm now ;-) .

best wishes
S
best wishes
Skids

stam
Posts: 2722
Joined: Sun Jun 04, 2006 9:39 pm
Location: London, UK

Re: Unable to scale an jpeg on a datagrid form

Post by stam » Fri Jul 28, 2023 10:16 am

Glad u got it sorted ;)

Post Reply

Return to “Getting Started with LiveCode - Complete Beginners”