Showing results for Code - The Old New Thing

Jul 30, 2003
0
0

Answer to yesterday's exercise

Raymond Chen
Raymond Chen

iMin is the lowest-index element which intersects the paint rectangle, so a simple truncating division produces the desired index. The formula for iMax can be interpreted two ways. One is that it is the roundup of the first invisible line. Recall the rectangles are exclusive of the endpoint, s...

Code
Jul 29, 2003
0
0

Scrollbars, part 3: Optimizing the paint cycle

Raymond Chen
Raymond Chen

Observe that we paint all 100 lines in our paint handler, even though most of them aren't visible. This is a problem if there are a large number of items, or if painting an item is time-consuming. So instead, we optimize our paint cycle so as to paint only the elements which intersect the pain...

Code
Jul 25, 2003
0
0

Scrollbars, part 2

Raymond Chen
Raymond Chen

Managing scrollbars is not hard in principle. The basic idea is not that difficult, but there are a lot of small details that need to be ironed out. If you don't get the details just right, your program will feel odd in a strange way that you often can't pinpoint, much like a subtle background hum that makes yo...

Code
Jul 23, 2003
0
2

The scratch program

Raymond Chen
Raymond Chen

Occasionally, there is need to illustrate a point with a full program. To avoid reproducing the boring parts of the program, let's agree on using the following template for our sample programs. For expository purposes, I won't use a C++ class. I'll just keep all my variables global. In a real program, of course, instance data would be attached to ...

Code