[Gambas-user] Need help with resizing Picutre contained by a resizable scrollview

B. Jack gau_veldt at ...67...
Tue Apr 8 00:40:23 CEST 2008


Hotmail has a tag bug...  it truncated some of my pseudocode:

Then what I want to do is have the size and position of Picture1 in an Arrange handler such that:
when Picture1.Image.W < ScrollView1.W move Picutre1 so that Picture1.X=Int(ScrollView.W - Picutre1.W / 2)
when Picture1.Image.W>= ScrollView1.W set Picture1.X=0
when Picture1.Image.H < ScrollView1.H move Picutre1 so that Picture1.Y=Int(ScrollView.H - Picutre1.H / 2)
when Picture1.Image.H>= ScrollView1.H set Picture1.Y=0

< is escaped so it doesn't truncate again

----------------------------------------
> From: gau_veldt at ...67...
> To: gambas-user at lists.sourceforge.net
> Date: Mon, 7 Apr 2008 15:34:24 -0700
> Subject: Re: [Gambas-user] Need help with resizing Picutre contained by a resizable scrollview
>
>
> Skeleton project:
> Form1->ScrollView1->Picture1
> Set the border type of the form to resizable and set ScrollView1 Arrange=True
> Load an Image into Picutre1
>
> Then what I want to do is have the size and position of Picture1 in an Arrange handler such that:
> when Picture1.Image.W=ScrollView1.W set Picture1.X=0
> when Picture1.Image.H=ScrollView1.H set Picture1.Y=0
[this got truncated.  see above.]
>
> The idea being that when the parent of ScrollView1 (in this skeleton it is Form1) resizes I want Picutre1 to resize so the image it currently contains centers when it is smaller then the client area of ScrollView1 and moves to 0,0 when the current image is larger than the ScrollView.
>
> So from a user perspective the image in the window is centered when the image is smaller than the window and scrolls when the image is larger than the window.
>
> Problem is that code like the above is always getting the dimensions wrong setting ScrollView1.H (and W) to Picutre1.Image.H (and W) doesn't set ScrollView1 to the size of the Image in Picture1. In other words the unit for Picture1->Image.H (and W) is not the same as ScrollView1.H (and W)
>
>> On dimanche 6 avril 2008, B. Jack wrote:
>>> I am having trouble with resizing images to resized parents because the
>>> image size units are not the same as the window/form size units.
>>
>> What are you talking about? Everything is in pixels. Or maybe you want to talk
>> about the fact that control dimensions are, by default, multiples of
>> Desktop.Scale and not absolute pixels values? If you don't want this
>> behaviour in a specific form, you just have to change the "(Scaled)"
>> property.
>>
>>>
>>> I have a form with various V-Slide and H-Slide partitioned child objects.
>>> The image preview pane is a child of a scrollview (so large images may be
>>> panned). This scrollview is ultimately a child of one of the
>>> VSliders/HSliders on the form.
>>>
>>> What I need to do is have a Picture within the scrollview that centers any
>>> image smaller than the client area after any Arrange activity. For any
>>> image larger than the client area the Picture object is maximized to the
>>> image size so the ScrollView will make the image pannable. The problem
>>> with just setting the Extend attribute is then that a larger image will be
>>> cut off (and won't be scrollable). Trying to set the H and W (or Width and
>>> Height) of the child Picture in an Arrange handler also doesn't seem to
>>> work right since the unit size of the image in the Picture and the Parent
>>> container do not correlate.
>>>
>>> Is the only option to set the stretch attribute and have it chunky-scaled?
>>>
>>
>> Can you send your project? All that is not very clear for me...
>>
>> --
>> Benoit Minisini
>>
>> -------------------------------------------------------------------------
>> This SF.net email is sponsored by the 2008 JavaOne(SM) Conference
>> Register now and save $200. Hurry, offer ends at 11:59 p.m.,
>> Monday, April 7! Use priority code J8TLD2.
>> http://ad.doubleclick.net/clk;198757673;13503038;p?http://java.sun.com/javaone
>> _______________________________________________
>> Gambas-user mailing list
>> Gambas-user at lists.sourceforge.net
>> https://lists.sourceforge.net/lists/listinfo/gambas-user
>
> _________________________________________________________________
> Find hidden words, unscramble celebrity names, or try the ultimate crossword puzzle with Live Search Games. Play now!
> http://g.msn.ca/ca55/212
> -------------------------------------------------------------------------
> This SF.net email is sponsored by the 2008 JavaOne(SM) Conference
> Register now and save $200. Hurry, offer ends at 11:59 p.m.,
> Monday, April 7! Use priority code J8TLD2.
> http://ad.doubleclick.net/clk;198757673;13503038;p?http://java.sun.com/javaone
> _______________________________________________
> Gambas-user mailing list
> Gambas-user at lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/gambas-user

_________________________________________________________________
Try Chicktionary, a game that tests how many words you can form from the letters given. Find this and more puzzles at Live Search Games!
http://g.msn.ca/ca55/207



More information about the User mailing list