freeRegion (reg );
updatePrev = FALSE;
}
else
reg -> next = next;
}
if (updatePrev) prev = reg;
}
// now append viewRect to the end of list reg = allocRegion (); // allocate new block & add it to the list
* (Rect *) reg = viewRect; reg -> owner = view; reg -> next = NULL;
Компьютерная графика. Полигональные модели
if ( prev != NULL ) // append it to the end of the list
prev -> next = reg;
else
start = reg;
if ( view -> isFloating () && recLevel == 0 ) floaters.insert ( view );
if (view -> child != NULL ) // now add it's subviews { // find downmost view
for (View * c = view -> child; c -> prev != NULL;) c =.c -> prev;
// start adding from downmost subview for (; c != NULL; c = c -> next) { // get subview's rect
r = c -> getScreenRect (); r &= viewRect; // clip to parent's rect
// add to map addView ( c, r, recLevel + 1 );
}
}
if (recLevel == 0 ) {
for (int i = 0; i < floaters.getCount (); i++ ) {
View * v = (View *) floaters [i];
addView ( v, v -> getScreenRect (), -10000 );
}
floaters.deleteAII ();
}
}
void Map :: redrawRect ( const Rect& r) const {
if (r.isEmpty ()) return;
screenSurface -> beginDraw ();
for ( Region * reg = start; reg != NULL; reg = reg -> next) {
Rect clipRect (* reg ); Point org ( 0, 0 );
clipRect &= r;
if ( clipRect.isEmpty ()) continue;
screenSurface -> setClipRect (clipRect);
Rect drawRect ( clipRect);
reg -> owner -> screen2Local ( drawRect); reg -> owner -> beginDraw (); reg -> owner -> draw ( drawRect);
5. Принципы построения пользовательского интерфейс
reg -> owner -> endDraw ();
}
screenSurface -> endDraw ();
}
View * Map :: findView ( const Point& p ) const {
for (Region * reg = start; reg != NULL; reg = reg -> next) if (reg -> contains ( p )) return reg -> owner;
return NULL;
}
Region * Map :: findViewArea ( const View * view ) const {
for ( Region * reg = start; reg != NULL; reg = reg -> next) if (reg -> owner == view ) return reg;
return NULL;