[Classes] [Prev] [Next] [Methods]

CRegion

Methods Index

Heritage
Description
Usage
Protected Data Members
Public Methods
Constructor, Destructor, and Operator Methods
Add/Remove Methods
Resizing Methods
Test Methods
Boolean Operations
Other Methods
Protected Methods

Helper Class
CRegionIterator
Description
Protected Data Members
Public Methods

Helper Class
CRegionCellIterator
Description
Protected Data Members
Public Methods

Helper Class
CRegionRowIterator
Description
Protected Data Members
Public Methods

Helper Class
CRegionColumnIterator
Description
Protected Data Members
Public Methods

CRegion


Heritage

Superclass: None

Subclasses: None

Helper Classes: CRegionCellIterator, CRegionColumnIterator, CRegionIterator, CRegionRowIterator


Description

CRegion is a collection of non-overlapping rectangles (CBounds). This implementation does not combine rectangles, which is the optimal behavior for the CTable object, nor does it maintain any sorted order of rectangles. Subclasses might implement combining, sorting, or other optimizations depending on the class usage.

CRegion includes methods to add cells, rows, and columns, in addition to rectangles. Cells are stored as rectangles with width and height of 1. A row consists of a rectangle with a left bound of 0 and a right bound of MAX_LONG, while a column is a single rectangle with a top bound of 0 and a bottom bound of MAX_LONG.

CTable uses CRegion to maintain the region of selected cells, rows, and columns. Other uses include updating or drawing regions and selecting regions on an image, for example. CRegion methods fall under a few simple headings: Add/Remove Methods, Resizing Methods, Test Methods, and Boolean Operations.

Add/Remove methods add and remove rectangles, rows, columns, or cells from the region. Resizing includes Insert and Delete methods to change the size of a region. CRegion adjusts the internal rectangles as required to accommodate the change. For example, if you call myRegion.InsertRow(4, 1), CRegion will move rectangles below row 4 down one row (top += 1, and bottom += 1). CRegion will also increase the height (bottom += 1) of any rectangles that include row 4. Test methods allow you to check whether a region contains any given cell, row, or column. The last group, boolean operations, provides ways to combine regions (in place) using the methods Union(), Subtract(), and Xor(). CTable's mouse handler uses these methods extensively to compute the update region when it has changed the table's selection region.

Four iterators provide access to the region based on rectangles, cells, rows, or columns. Note that the rectangles are not sorted; therefore, there is no order to iterations.


Usage

#include CRegion_i

CRegion myRegion;

myRegion.AddRow(13);
myRegion.AddCell(CCell(5, 4));

// Iterators
// Region
CRegionIterator anIterator(myRegion);
CBounds aBounds;
while(anIterator.Next(&theBounds)) { ... }

// Cell
CRegionCellIterator anIterator(myRegion);
CCell aCell;
while(anIterator.Next(&aCell)) { ... }

// Row
CRegionRowIterator anIterator(myRegion);
long aRow;
while(anIterator.Next(&aRow)) { ... }

// Column
CRegionColumnIterator anIterator(myRegion);
long aColumn;
while(anIterator.Next(&aColumn)) { ... }

Protected Data Members

CBounds itsBounds; Rectangular union of all rectangles in region.
RWGOrderedVector(CBounds) itsList; Internal list of rectangles.


Public Methods

Constructor, Destructor, and Operator Methods

CRegion();
CRegion(const CRegion& theRegion);
CRegion(const CBounds& theBounds);
const CRegion& operator=(const CRegion& theRegion);
virtual ~CRegion();

Add/Remove Methods

virtual void Add(const CBounds& theBounds);
virtual void Add(const CCell& theCell);
virtual void AddRow(long theRow);
virtual void AddColumn(long theColumn);
virtual void Clear();
virtual void Remove(const CBounds& theBounds);
virtual void Remove(const CCell& theCell);
virtual void RemoveRow(long theRow);
virtual void RemoveColumn(long theColumn);

Resizing Methods

virtual void InsertColumns(long theColumn,
long theCount = 1);
virtual void InsertRows(long theRow,
long theCount = 1);
virtual void DeleteColumns(long theColumn,
long theCount = 1);
virtual void DeleteRows(long theRow,
long theCount = 1);

Test Methods

virtual BOOLEAN Contains(const CCell& theCell) const;
virtual BOOLEAN ContainsRow(long theRow) const;
virtual BOOLEAN ContainsColumn(long theColumn) const;

Boolean Operations

virtual void Union(const CRegion& theRegion);
virtual void Subtract(const CRegion& theRegion);
virtual void Xor(const CRegion& theRegion);

Other Methods

virtual const CBounds& Bounds() const;

Protected Methods

void SetBounds();

Helper Class
CRegionIterator


Description

Iterates over each rectangle (CBounds) in the region. Includes rows and columns.


Protected Data Members

const CRegion& itsRegion;
unsigned itsIterator;


Public Methods

CRegionIterator(const CRegion& theRegion);
BOOLEAN Next(CBounds* theBounds);

Helper Class
CRegionCellIterator


Description

Iterates over each cell (CCell) in the region. Excludes rows and columns.


Protected Data Members

const CRegion& itsRegion;
unsigned itsIterator;
CCell itsLastCell;


Public Methods

CRegionCellIterator(const CRegion& theRegion);
BOOLEAN Next(CCell* theCell);

Helper Class
CRegionRowIterator


Description

Iterates over each row in the region.


Protected Data Members

const CRegion& itsRegion;
unsigned itsIterator;
long itsLastRow;


Public Methods

CRegionRowIterator(const CRegion& theRegion);
BOOLEAN Next(long* theRow);

Helper Class
CRegionColumnIterator


Description

Iterates over each column in the region.


Protected Data Members

const CRegion& itsRegion;
unsigned itsIterator;
long itsLastColumn;


Public Methods

CRegionColumnIterator(const CRegion& theRegion);
BOOLEAN Next(long* theColumn);


[Classes] [Prev] [Next] [Methods]

support@xvt.com


Visit our online help desk for tech support

Copyright © 2009, Providence Software Solutions Inc. All rights reserved.