public:
View * owner; Region * next;
};
class Map {
Region * pool; // pool of regions
int poolSize; // # of structures allocated
Region * firstAvailable; // pointer to 1st struct after all allocated
Region * lastAvailable; // last item in the pool
Region * free; // pointer to free structs list (below firstA
Region * start; // first region in the list
public:
Map (int mapSize )
/ i
pool = new Region [poolSize = mapSize];
firstAvailable = pool;
lastAvailable = pool + poolSize -1;
free = NULL;
start = NULL;
}
-Map 0 {
delete [] pool;
}
void freeAII () // free all used regions
{
firstAvailable - pool; free = NULL;
start = NULL;

5. Принципы построения пользовательского интерфейса

Region * allocRegion (); // allocate unused region
// deallocate region (return to free list) void freeRegion ( Region * reg )
{
reg -> next = free; free = reg;
}
void rebuildMap (); // rebuild map from beginning
. // redraw given screen rectangle void redrawRect ( const Rect& ) const;
// find window, containg point View * findView ( const Point& ) const;
// find 1 st region of view list ' Region * findViewArea ( const View * view ) const;
// add view (with all subviews) to screen map void addView ( View *, Rect&, int ');
friend class View;
};
/////////////////////// Map methods ////////////////////
Region * Map :: allocRegion () { // when no free spans
if (free == NULL )
if (firstAvailable <= lastAvailable ) return firstAvailable++;
else
return NULL;
Region * res = free;
free = free -> next; return res;
}
void Map :: rebuildMap () {
freeAII ();
addView ( deskTop, screenRect, 0 );
}
void Map :: addView ( View * view, Rect& viewRect, int recLevel) {
int updatePrev; // whether we should update prev Rect r;
Rect splittingRect; View * owner; Region * reg, * next; Region * prev = NULL;
if ('view -> isVisible ()) // if not vivible return; // nothing to add
viewRect & ~ screenRect; // dip area to screen

⇐ Предыдущая| |Следующая ⇒