Whenever you add or remove a window border, change the size of a window, or change the size of a window's margins, you change the size of the window's interior work area. The size of the memory screen or memory file being used as the window buffer does not change. For a virtual window, this has little impact because the interior work area and the window buffer are not the same size anyway. For a basic window, however, this can cause problems.
The cannot become larger than the window's buffer. If you do something that would attempt to make the size of the work area larger than the buffer (such as removing a border from a basic window), Vermont Views increases the work area so that it is as large as the buffer, and then treats any area beyond the work area as Window:virtual margin. This can give your window a lopsided look. The position of the work area relative to the top left corner of the window does not change; the virtual margins are added at the right side and below the interior work area.
If a basic window's work area shrinks, the entire buffer will no longer be visible. The basic window appears to become a virtual window. Output written to the window goes to the window's buffer, and may cause the buffer to scroll within the work area. However, the processing function for the window has not changed. The user is not allowed to scroll through the buffer, because the processing function for a basic window does not permit scrolling by the user.
These problems can be prevented by calling the window memory screen modify function wn_msmod() to resize the memory screen to the exact size needed for the interior work area.:
|
If there is no memory screen assigned to the window, wn_msmod() allocates a memory screen that matches the size of the interior work area. If there is a memory screen, and if the interior work area is smaller than the existing memory screen, wn_msmod() adjusts the size of the memory screen by changing members in the memory screen structure. A new memory screen will not be allocated. If the interior work area is larger than the existing memory screen, wn_msmod() frees the existing memory screen and allocates another one which is the exact size of the interior work area.
If used on a window that already has a buffer, wn_msmod() can cause some memory fragmentation. You can avoid this problem by the following method:
This method allows you to allocate the memory screen buffer only once, after you know the correct size for the buffer.