Reference » Window classes » MWindow » repaint

Elgrint::MWindow::repaint(MRect,bool,bool) method

Declaration (see MWindow.h):

void repaint(const MRect& rect = MaxRect);

Description

Invalidates a portion of the window and/or its descendants, and generates Paint messages as needed.

Parameters:

Name Type Def value Description
rect MRect MaxRect

All the pixels inside this valid rectangle (in window coordinates) will be affected by the repainting.

Details: The rect should be valid or nothing will be repainted.
A valid rect is rounded out to a nearest integral rect, since repainting part of a pixel has no physical sense.
A valid rect is intersected with the window's rectangle. In particular, this means that if rect equals MaxRect (the default value), the entire visible area of the window is invalidated, because MaxRect encompasses any possible window.

Details

If the window is closed (see isOpen), then the function returns immediately. If rect is an invalid MRect, then the function returns, but if both rect.p1() and rect.size() are individually valid, then the function generates a one-time exception 3001 before returning (this often means that rect is invalid because it is too large, which is usually a programming error or a careless usage of MaxSize). If repaint is called during OnPaint, it generates exception 2001 and returns.

Otherwise, the function marks all pixels within the specified rect as invalid and in need to be repainted. This function eventually generates the Paint message, which is why it is not allowed during OnPaint.

The Paint message are still not processed when repaint returns. Usually, a Paint message is received by the relevant window in the next message loop iteration. With this delayed painting, repaint can be called many times during the same loop iteration with different rect parameters without performance penalty, because all these calls will produce only one Paint message with the total invalid area being the union of all these rect parameters. However, if MApp::sleep is called by the main thread, then all the pending repaint operations are executed immediately before the main thread is suspended. So, MApp::sleep can be used as a way to repaint windows immediately (although this is rarely needed).

All the descendant windows of this window, whose rectangles intersect with rect, are repainted fully or partially as well (only the part of the child that intersects with rect is repainted).

Remarks

Let us know

Please Contact us to report any errors on this page, or to suggest any improvements.

Miranor Home | About Miranor | About Elgrint | Create account | Login | Account settings | Contact Us | Privacy Policy | Site map

© Copyright 2014 by Miranor. All rights reserved. By using this site you agree to the Terms of Use.

Page last updated on August 10th, 2014.