| Methods Index |
CSubviewSubclasses:
CFixedGrid, CVariableGrid
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:
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
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);
isClipping parameter takes a BOOLEAN value indicating whether the items placed in the grid are clipped to their cells. By default, clipping is turned off. thePlacement specifies the orientation for placing items in their cells-in the top left corner by default. isGridVisible sets whether the lines of the grid are visible or not. theSizingPolicy takes a value indicating one of the two different sizing policies for grids: ADJUSTCellSize (the default) or ADJUSTCellNumber. The isVisible parameter sets the visibility state for the entire grid object (as opposed to isGridVisible, which pertains to the horizontal and vertical lines within the grid). Finally, this initializer takes a glue type.
virtual void DoDraw(
const CRect& theClippingRegion = MAXRect);
CSubview level. Its behavior is the same as that of CSubview's DoDraw. It takes care of any drawing the grid must do and draws all of the its subviews, ensuring that all of the subviews are clipped to the grid. theClippingRegion is the part of the grid that needs to be refreshed and is in global, window-relative coordinates; if it is set to MAXRect, the entire object is drawn.
virtual void Draw(const CRect& theClippingRegion);
theClippingRegion is the part of the grid that needs to be refreshed.
virtual void SetClipping(BOOLEAN isClipping);
ItIsClipping data member to TRUE or FALSE, which determines whether items in the grid clip to their cells.
virtual BOOLEAN IsClipping(void);
TRUE or FALSE, indicating whether the objects contained in the grid are clipped to their cells.
virtual void SetPlacement(PLACEMENT thePlacement);
virtual PLACEMENT GetPlacement(void) const;
virtual void ShowGrid(void);
virtual void HideGrid(void);
virtual BOOLEAN IsGridVisible(void);
BOOLEAN value indicating whether the row and column lines of the grid are visible.
virtual BOOLEAN DrawsVertical(void) const;
TRUE if the grid draws vertical grid lines, FALSE if not.
virtual BOOLEAN DrawsHorizontal(void) const;
TRUE if the grid draws horizontal grid lines, FALSE if not.
virtual void SetVerticalDrawing(BOOLEAN theSetting);
theSetting.
virtual void SetHorizontalDrawing(
BOOLEAN theSetting);
theSetting.
virtual void SetSnapping(BOOLEAN IsSnapping);
virtual BOOLEAN IsSnapping(void) const;
virtual CView* Remove(int theRow, int theColumn);
NULL.
virtual BOOLEAN Remove(const CView* theView);
theView, from the grid and returns a BOOLEAN value of TRUE if it is successful.
void RemoveSubview(const CView *theView);
theView, from the grid's list of views.
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);
virtual CView* GetContents(int theRow, int theCol) const;
NULL.
virtual CView* GetContents(CPoint theLocation) const;
theLocation, a coordinate that is local to the grid. This method returns a pointer to the view. If the cell has no contents, this method returns NULL.
virtual int GetNumRows(void) const;
virtual int GetNumCols(void) const;
virtual void GetPosition(const CView* theView,
int *theRow, int *theCol) const;
GetPosition, the row and the column. After this method is called, the row and the column designated by the integers will contain the location of that view, if the view happens to be in the grid. If the view is not contained in the grid, then the row and the column are set to -1.
virtual void GetPosition(const CRect& theView,
int *theRow, int *theCol) const;
virtual CRect GetCellSize(int theRow, int theCol) const = NULL;
CRect, which consists of that cell's coordinates, which are local to the grid.
virtual int GetRow(UNITS theVerticalLocation)
const = NULL;
theVerticalLocation. If theVerticalLocation is not in a row, this method returns a -1.
virtual int GetCol(UNITS theHorizontalLocation)
const = NULL;
theHorizontalLocation. If theHorizontalLocation is not in a column, this method returns a -1.
virtual BOOLEAN Validate(int theRow, int theCol);
TRUE or FALSE, depending on whether the given row and column contains a valid grid cell. Validate checks the row and column to verify that they are valid in the grid. This method is called internally whenever a new item is being inserted into the grid. This method can be overridden. One possibility is to override Validate so that it creates a valid row and column to accommodate the inserted object if it does not find them and returns TRUE.
virtual void Size(const CRect& theNewSize);
theNewSize. The sizing of the grid varies according to the sizing policy that has been set. If the sizing policy, which set by SetSizingPolicy, is ADJUSTCellSize, sizing events are handled by resizing the cells and not by changing the number of cells. If the sizing policy is ADJUSTCellNumber, sizing events are handled by adding or removing cells and not changing the size of the existing cells.The reset region can be in a different location and have completely different dimensions-a new width or a new height. The coordinates of the region,
theNewSize, are relative to the enclosure-like the coordinates of the region that is passed in when a view is instantiated.
virtual void SizeCell(UNITS theCellWidth,
UNITS theCellHeight) = 0;
virtual void SetNumCells(int theNumberOfColumns,
int theNumberOfRows,
BOOLEAN theGridWillResize = TRUE);
theGridWillResize is TRUE, SetNumCells enlarges or reduces the size of the entire grid by giving it the specified number of columns and rows. If
theGridWillResize is FALSE, the overall size of the grid does not change. In this case, the sizes of the cells are adjusted to fit theNumberOfRows and theNumberOfColumns.
virtual void AdjustCells(ADJUST theAdjustment);
ADJUST, which can have a value of either MAXIMIZE or MINIMIZE. MAXIMIZE goes through all of the objects contained in the grid, finds the largest one, and makes all of the grid cells that size. MINIMIZE goes through all of the objects contained in the grid, finds the smallest one, and makes all of the grid cells that size.
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);
ADJUSTCellSize or ADJUSTCellNumber.
virtual void SetPlacementOffset(const CPoint& theNewPlacementOffset);
virtual CPoint GetPlacementOffset(void);
virtual void MouseDouble(CPoint theLocation,
short theButton = 0,
BOOLEAN isShiftKey = FALSE,
BOOLEAN isControlKey = FALSE);
theLocation, the grid receives and handles this event.
virtual void MouseDown(CPoint theLocation,
short theButton = 0,
BOOLEAN isShiftKey = FALSE,
BOOLEAN isControlKey = FALSE);
theLocation, the grid receives and handles this event.
virtual void MouseMove(CPoint theLocation,
short theButton = 0,
BOOLEAN isShiftKey = FALSE,
BOOLEAN isControlKey = FALSE);
theLocation, the grid receives and handles this event, whether the mouse button is down or not.
virtual void MouseUp(CPoint theLocation,
short theButton = 0,
BOOLEAN isShiftKey = FALSE,
BOOLEAN isControlKey = FALSE);
theLocation, the grid receives and handles this event. This event is not necessarily preceded by a MouseDown or MouseMove event because those button actions may have taken place outside the grid.
virtual CView* FindEventTarget(const CPoint& theLocation) const;
theLocation. CGrid overrides this method in order to trap all events regardless of the subviews it contains or to change the event targeting algorithm. For example, a list box contains many subviews (text items). When you click on a text item inside a grid, the event does not go to the view. Instead, the grid traps the event by returning this (itself) as the target for the mouse events received. Then, it treats the mouse events as necessary, without sending them on to its subviews.
virtual CView* FindHitView(const CPoint& theLocation) const;
CView method of the same name, which returns the actual view that should receive mouse events. It returns the grid's wire frame if the grid is being sized or dragged.
void Suspend(void);
void Resume(void);
DoDraw to make sure that the grid's on-screen representation is current.
BOOLEAN IsSuspended(void) const;
TRUE if the grid is suspended, FALSE otherwise.
virtual void PlaceView(CView* theView, int theRow, int theCol);
virtual void DoPlaceView(void);
PlaceView for each one. This method is called internally when a grid is sized or moved.
virtual void DoClear(void);
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);
theEnclosure is a pointer to the subview that will contain the grid. theRegion is a coordinate location, local to the enclosure, that is used to place the grid.
CGrid(const CGrid& theGrid);
CGrid& operator=(const CGrid& theGrid);
void SetDragPoint(const CPoint& theLocation);
void ResetCell(CView* theView, int theNewRow=-1,
int theNewCol=-1);
CView* GetHitItem(CPoint theLocation) const;
CSubview level.