What is the correct way to update window after changing extent?
Aleksey Murushkin (Cloverleaf) (8233) 41 posts |
Hello. I do the following. |
Steve Fryatt (216) 2107 posts |
Without seeing the code that you’re using to do the redraw and set the extent, it’s quite hard to say. |
Aleksey Murushkin (Cloverleaf) (8233) 41 posts |
so the pseudo code looks like this calcNewHeight(); here are the details of functions
The code that i was trying to update the window after all of this
|
Steve Fryatt (216) 2107 posts |
A few thoughts… This area is a minefield, and since none of the following is tested, it could be complete rubbish. First, there’s a gotcha with Wimp_SetExtent, which might (or might not) apply to the Toolbox’s
except for the situation where you’re reducing the extent. In that case, you have to make sure that you call Wimp_OpenWindow first with the yoffset such that the area to be lost is out of view, then change the extent. If the new extent is smaller than the visible area, you have to increase the extent that you ask for to match the visible area, or use Wimp_OpenWindow to reduce the size of the visible area first. Otherwise, the Wimp will resist you. I’d expect to see something like this:
The scroll to bottom call seems to be calculating the scroll offset wrong, too. You’re not taking into account the height of the visible area: the extent is the bottom of the area, while the scroll offset points to the top.
Finally, and this may well be the significant one, I don’t think Wimp_UpdateWindow does what you think it does. Unless there’s some code missing (the redraw loop and calls to Wimp_GetRectangle which must follow Wimp_UpdateWindow), then you don’t want to be using Wimp_UpdateWindow. It is actually an alternative to Wimp_RedrawWindow, which can trigger a set of redraw events immediately (compared to Wimp_RedrawWindow, which is called in response to the Wimp raising a Window_Redraw_Request event). If you just wish to trigger a redraw to happen at some point in the future via your window’s normal redraw code, then you need Wimp_ForceRedraw. Something like this:
This will then trigger a Window_Redraw_Request event to your normal redraw code when the Wimp finds it convenient to do it. |
Aleksey Murushkin (Cloverleaf) (8233) 41 posts |
Thanks to your answer. as my visible area does not changed yet it seems your code did not change anything. |
Aleksey Murushkin (Cloverleaf) (8233) 41 posts |
I made it work. for those who interested, i call wimp_force_redraw not with state.visible params but put there extent values. and it worked. |
Alan Adams (2486) 1150 posts |
Adjusting window sizes always makes my head hurt. I can never remember which bits need extent and which visible area. Fortunately I now have a BASIC library function which scans through the icons, find the highest and lowest coordinates in each direction, then resizes the window 32 units bigger all round and opens it full screen.
One small gotcha – if I’ve hidden icons offscreen the window opens up to show them. |
nemo (145) 2569 posts |
Steve claimed
This is not correct. You absolutely can make an open window smaller than its currently displayed size (subject to the window’s defined minimum size) but Wimp_SetExtend alone does not cause the window to change on-screen – you must call OpenWindow at some point (but it does not have to be before). Aleksey realised
Yes, there are two important bounding boxes exposed1 in the window API – the visible coordinates on the screen, and the extent of the work-area inside the window. OpenWindow deals in screen coordinates, GetRectangle returns both the screen coordinates and the work-area coordinates, and ForceRedraw uses only work-area coordinates. 1 Three, if you include the GetWindowOutline bounding box. There’s a lot more than that internally though, as this frightening image may indicate (the bit below the line is the external definition of a window, the rest is the Wimp’s internal model): |