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

CGrid

Methods Index

Heritage
Description
Usage
Enums
Adjust
Placement
Policy
Protected Data Members
Public Methods
Destructor and Initializer Methods
Inherited Drawing Methods
Clipping Methods
Placement Policy Methods
Visibility Methods
Snapping Methods
Removal Functions
Placement Methods
Cell Get Operations
Inherited Sizing Methods
Sizing (Varies Among Grid Types)
Mouse Event Methods (All Inherited)
Suspension Methods
Protected Methods
Constructor Methods
Other Methods

CGrid


Heritage

Superclass: CSubview

Subclasses: CFixedGrid, CVariableGrid


Description

CGrid is an abstract class that provides the means to arrange other CView objects into defined grid cells.

A CGrid in its abstract sense is simply an area of the screen that has been divided into rows and columns. These are the only assumptions made at the CGrid level. Each view object contained in the grid is placed inside an individual grid cell. A cell is a rectangular location comprised of the intersection of a certain row with a certain column. Objects inserted into cells can either be clipped to their cells or simply placed inside. If the objects are not clipped and are too big to fit into their cells they overlap from cell to cell. An object can be placed inside a cell relative to its top left, top right, bottom left, or bottom right corner.

When rows and columns are being counted in a grid, the top-most row and the left-most column are both counted as zero (0); thus, counting proceeds from zero.

Depending on its attributes, a grid can have the following characteristics:

There are two different sizing policies for grids. One policy sizes the grid by sizing its cells; the number of cells remains constant and the size of the cells is adjusted as necessary when the grid is enlarged or shrunk. A second sizing policy adjusts the number of cells, keeping the size of the cells constant while adding cells to enlarge the grid or removing cells to shrink it.


Usage

This is a virtual base class that is used to implement two different types of grids: grids with cells of homogeneous size (CFixedGrid) and grids with cells of heterogeneous size (CVariableGrid). Thus, objects of this class cannot be instantiated directly. All row and column operations assume that 0,0 is the coordinate of the top-left cell.

For any view created using a grid as its enclosure, you must call one of the placement methods to indicate the cell in which it belongs.


Enums

These enums are used by the CGrid methods:

Adjust

MAXIMIZE Adjust cell size to equal the size of the largest view
MINIMIZE Adjust cell size to equal the size of the smallest view

Placement

TOPLEFT Give contents top-left justification
TOPRIGHT Give contents top-right justification
BOTTOMLEFT Give contents bottom-left justification
BOTTOMRIGHT Give contents bottom-right justification

Policy

ADJUSTCellSize Handle sizing events by resizing each individual cell
ADJUSTCellNumber Handle sizing events by adding or removing cells


Protected Data Members

UNITS itsCellWidth; The width of each cell
UNITS itsCellHeight; The height of each cell
int itsRowNumber; The number of rows
int itsColumnNumber; The number of columns
POLICY itsSizingPolicy; Type of size behavior
CSparseArray* itsCells; matrix of cells
BOOLEAN itDrawsVertical; Whether the grid draws vertical grid lines
BOOLEAN itDrawsHorizontal; Whether the grid draws horizontal grid lines
BOOLEAN itIsSuspended; Whether the grid is suspended
BOOLEAN itIsClipping; Whether an item clips to a cell
PLACEMENT itsPlacement; Snapping corner
CPoint itsPlacementOffset; Snap corner offset
CPoint* itsDragPoint; Snapping point for mouse drags
CPoint itsStartPoint; Starting point for dragging
BOOLEAN itIsHit; Keeps track of mouse event state
BOOLEAN itIsGridVisible; Whether the grid lines are drawn
BOOLEAN itIsSnapping BOOLEAN for tracking snapping state


Public Methods

Destructor and Initializer Methods

Because CGrid is an abstract class, it has no public constructors.

virtual ~CGrid(void);
BOOLEAN IGrid(BOOLEAN isClipping 	= FALSE,
PLACEMENT thePlacement = TOPLEFT,
BOOLEAN isGridVisible = FALSE,
POLICY theSizingPolicy = ADJUSTCellSize,
BOOLEAN isVisible = TRUE,
GLUETYPE theGlue = NULLSTICKY);

Inherited Drawing Methods

virtual void DoDraw(
const CRect& theClippingRegion = MAXRect);
virtual void Draw(const CRect& theClippingRegion);

Clipping Methods

virtual void SetClipping(BOOLEAN isClipping);
virtual BOOLEAN IsClipping(void);

Placement Policy Methods

virtual void SetPlacement(PLACEMENT thePlacement);
virtual PLACEMENT GetPlacement(void) const;

Visibility Methods

virtual void ShowGrid(void);
virtual void HideGrid(void);
virtual BOOLEAN IsGridVisible(void);
virtual BOOLEAN DrawsVertical(void) const;
virtual BOOLEAN DrawsHorizontal(void) const;
virtual void SetVerticalDrawing(BOOLEAN theSetting);
virtual void SetHorizontalDrawing(
BOOLEAN theSetting);

Snapping Methods

virtual void SetSnapping(BOOLEAN IsSnapping);
virtual BOOLEAN IsSnapping(void) const;

Removal Functions

virtual CView* Remove(int theRow, int theColumn);
virtual BOOLEAN Remove(const CView* theView);
void RemoveSubview(const CView *theView);

Placement Methods

The placement methods, which must be called for each subview, include both insert and replace functions. The replace methods are similar to the insert methods, with an importance difference. The insert function inserts the object into the cell even if the cell is occupied. Thus, there can be more than one view per cell. The replace methods remove any object already occupying the cell and replace it with the new object, returning a pointer to the object that was removed. If there is no object to be removed, the replace methods return NULL.

virtual void Insert(CView* theView, int theRow, 
int theColumn);
virtual void Insert(CView* theView);
virtual CView* Replace(CView* theView, int theRow, int theColumn);
virtual CView* Replace(CView* theView);

Cell Get Operations

virtual CView* GetContents(int theRow, int theCol) const;
virtual CView* GetContents(CPoint theLocation) const;
virtual int GetNumRows(void) const;
virtual int GetNumCols(void) const;
virtual void GetPosition(const CView* theView, 
int *theRow, int *theCol) const;
virtual void GetPosition(const CRect& theView,
int *theRow, int *theCol) const;
virtual CRect GetCellSize(int theRow, int theCol) const = NULL;
virtual int GetRow(UNITS theVerticalLocation)
const = NULL;
virtual int GetCol(UNITS theHorizontalLocation)
const = NULL;
virtual BOOLEAN Validate(int theRow, int theCol);

Inherited Sizing Methods

virtual void Size(const CRect& theNewSize);

Sizing (Varies Among Grid Types)

virtual void SizeCell(UNITS theCellWidth, 
UNITS theCellHeight) = 0;
virtual void SetNumCells(int theNumberOfColumns,
int theNumberOfRows,
BOOLEAN theGridWillResize = TRUE);
virtual void AdjustCells(ADJUST theAdjustment);
virtual UNITS GetWidth(int theColumn = 0) 
const = NULL;
virtual UNITS GetHeight(int theRow = 0) const = NULL;
virtual POLICY GetSizingPolicy(void) const;
virtual void SetSizingPolicy(POLICY thePolicy);
virtual void SetPlacementOffset(const CPoint& theNewPlacementOffset);

virtual CPoint GetPlacementOffset(void);

Mouse Event Methods (All Inherited)

All of the following mouse methods override the corresponding CSubview methods because grid-snapping has been implemented for movable and sizable objects contained in a grid. Snapping means that as the user drags an object across a grid, it snaps to each cell; the object cannot be dragged halfway between one cell and another.

Mouse events are passed directly to the view at the location where the event occurs. Each of the following methods has a theButton argument that specifies which mouse button is used and can have the values 0 (left), 1 (middle), or 2 (right). By default, neither the Shift key nor the Control key is used in conjunction with the mouse button.

virtual void MouseDouble(CPoint theLocation,
short theButton = 0,
BOOLEAN isShiftKey = FALSE,
BOOLEAN isControlKey = FALSE);
virtual void MouseDown(CPoint theLocation,
short theButton = 0,
BOOLEAN isShiftKey = FALSE,
BOOLEAN isControlKey = FALSE);
virtual void MouseMove(CPoint theLocation,
short theButton = 0,
BOOLEAN isShiftKey = FALSE,
BOOLEAN isControlKey = FALSE);
virtual void MouseUp(CPoint theLocation,
short theButton = 0,
BOOLEAN isShiftKey = FALSE,
BOOLEAN isControlKey = FALSE);
virtual CView* FindEventTarget(const CPoint& theLocation) const;
virtual CView* FindHitView(const CPoint& theLocation) const;

Suspension Methods

void Suspend(void);
void Resume(void);
BOOLEAN IsSuspended(void) const;
virtual void PlaceView(CView* theView, int theRow, int theCol);
virtual void DoPlaceView(void);
virtual void DoClear(void);

Protected Methods

Constructor Methods

The copy constructors and equal operators of all classes in the CView hierarchy, including the grid classes, copy all of a view's attributes-size, color, active state, whether it is movable or sizable-but they do not copy all the objects that are inside of it.

CGrid(CSubview* theEnclosure, const CRect& theRegion);
CGrid(const CGrid& theGrid);
CGrid& operator=(const CGrid& theGrid);

Other Methods

void SetDragPoint(const CPoint& theLocation);
void ResetCell(CView* theView, int theNewRow=-1, 
int theNewCol=-1);
CView* GetHitItem(CPoint theLocation) const;


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

support@xvt.com


Visit our online help desk for tech support

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