Skip to main content
1 of 2
Caleb
  • 39.3k
  • 8
  • 96
  • 153

GUI frameworks typically have some sort of 'View' class that represents things drawn on the screen, and that class usually provides a method like invalidateRect(Rect r) to mark part of its drawing area as needing to be redrawn. Clients might call that method to request an update to part of the view. But a view might also call its own method, like:

invalidateRect(this->frame);

to cause redrawing of the entire area. For example, it might do this when it's first added to the view hierarchy.

There's nothing wrong with doing this -- the view's frame is a valid rectangle, and the view itself knows that it wants to redraw itself. The View class could provide a separate method that takes no parameters and uses the view's frame instead:

invalidateFrame();

But why add a special method just for this when you can use the more general invalidateRect()?

Caleb
  • 39.3k
  • 8
  • 96
  • 153