Re-creating vs "blank slate"

Posted by Renny on Thu 23 Aug 2018 07:47 PM — 2 posts, 11,267 views.

Canada #0
In the documentation it says,

Quote:

Once the window has been created by a call to WindowCreate, you can draw to it anytime. You may find it useful to clear the window and start again "on a blank slate". For example:


WindowRectOp (win, miniwin.rect_fill, 0, 0, 0, 0, ColourNameToRGB("white"))
This clears the entire window to white.


If i want to discard everything (save for the loaded font and images) and redraw the "main content" to update the window, should I use WindowCreate or do the above?

Are there any tangible differences? Perhaps to do with memory freed etc.
Australia Forum Administrator #1

There are a few differences. The miniwindow instances (in memory of the client) can have associated with them:

  • Hotspots
  • Fonts
  • Images

These are not deleted if you do a WindowCreate on an existing window. If the miniwindow already exists the only thing that is freed up is the bitmap representing the window contents, and that is then re-created (quite possibly with different dimensions).

A fairly standard technique, for example, is to create a miniwindow of small dimensions (eg. 1x1 pixel), add a desired font to it, find the font dimensions (eg. line height) and then do another WindowCreate to resize the window as required (eg. 2 lines of text high).

The help message about the “blank slate” is intended as a tip for situations where you simply need to clear the window, for example, when drawing chat messages, so that the old text does not get written over previous text. It doesn’t literally mean “as if made from scratch”.