Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why use the word "invalidate" to request a view to be redrawn?

In GUI, when a view is required to be redraw. We usually do this as follows:

View v = View (); 
v.invalidate() 

I have no idea that the operation "invalidate()" is such named. In English, "invalidate" means to make something not valid. But "invalidate a view" in GUI programming is meant to make the view to be redrawn. I am not a native English speaker. Please give me hints. Tks.

like image 269
alwayssmile68 Avatar asked Sep 08 '11 02:09

alwayssmile68


2 Answers

To "invalidate a view" means that any data that may already be drawn is no longer valid. The view of the data is invalid, hence invalidate() to mark it as such. It's less that the function is making it invalid so much as it is already invalid, but no-one except the caller to invalidate() knows that yet. The purpose of the function is to tell the rest of the code that the views data is now invalid.

like image 166
Matthew Scharley Avatar answered Oct 29 '22 10:10

Matthew Scharley


Invalidate is semantically different from redrawing in that it usually only marks something to be redrawn later, as opposed to redrawing at call-time. The idea is that when several possibly overlapping areas are invalidated, the amount of redrawing at a later time can then be made equal to only the sum of non-overlapping areas. That is, we may redraw only once for several subsequent invalidations. Hence the distinction between redrawing and invalidation exists.

like image 38
dragonroot Avatar answered Oct 29 '22 10:10

dragonroot