Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

XPCE how to resize a picture?

283 views
Skip to first unread message

Jon

unread,
Dec 23, 2009, 8:44:37 PM12/23/09
to
This must be pretty basic... I can create a dialog in SWI-Prolog/XPCE
with buttons and a picture, and use the buttons to request drawing in
the picture and to quit the dialog, etc. The one thing I can't figure
out is how to resize the picture. Sending it recogniser, new
(resize_gesture) does not add any new behavior. Sending it an explicit
width does change the width, but it relocates the picture to the upper
left corner of the dialog! Fiddling with x and y has no effect at all;
x and y return zero no matter where the picture is initially, and
resetting them does not move it. How can I resize a picture? (I know I
have to redraw the contents myself.)

Andreas

unread,
Dec 24, 2009, 3:18:41 AM12/24/09
to
Jon schrieb:

I'd start here (however did not try myself):

area(x=[int], y=[int], width=[int], height=[int])
Combination of X, Y, Width and Height used by graphical to store
the bounding box of the graphical. Also used to communicate with
graphical objects and frames about their dimension.

Good luck
Andreas

Jan Wielemaker

unread,
Dec 24, 2009, 3:19:28 AM12/24/09
to

You can give it a size before opening. After that, it is regulated by the
surrounding frame. If you want to change it from the program, resize the
frame.

--- Jan

Jon

unread,
Dec 24, 2009, 3:33:45 PM12/24/09
to
On Dec 24, 3:19 am, Jan Wielemaker <j...@hppc323.few.vu.nl> wrote:

(In response to Andreas, I tried things with area, no luck.)

The frame behavior seems to apply only to making it smaller.
If the frame is dragged to make it wider, the picture box
does not follow. Sending the pic a greater width (interactively in
Prolog) makes the picture jump to the upper left. Getting
the picture area and setting the width of that has no effect
on the display.

test :-
new(@sd,dialog('Dialog Test')),
send(@sd,append,button(quit,message(@prolog,doquit))),
send(@sd,append,new(@pic,picture(box))),
send(@pic,width(450)),
send(@pic,height(130)),
send(@sd, open).

Jon

unread,
Dec 25, 2009, 1:14:45 PM12/25/09
to
I found a way that works, though there is something strange.
I can free the picture and append a new one with a different
width adjusted to the dialog width. Then I have to do
send(@sd,layout) to see the new picture box.

Strange thing: if the new picture is given a height equal
to that of the old picture, every time the picture is
adjusted, the height gets smaller by 6 pixels. Adding 6
to the height each time preserves the height.
(@sd is the dialog.)

redrawpic :-
get(@sd,width,W),
W1 is W - 30,
get(@pic,height,H),
H1 is H + 6,
send(@pic,free),
send(@sd,append,new(@pic,picture(box,size(W1,H1)))),
send(@sd,layout).

Merry Christmas!

Jan Wielemaker

unread,
Dec 27, 2009, 9:37:31 AM12/27/09
to

But you don't want to append pictures to dialog windows. Windows
are designed to be grouped in frames. So, typically you'll see

send(new(P, picture), below, @sd)

--- Jan

Message has been deleted

Jon

unread,
Dec 27, 2009, 11:34:46 AM12/27/09
to
Ah, that's easier. Put the picture outside the dialog, both in a
frame.
Now the picture always fills the lower part of the window. Thank you.
-Jon

0 new messages