MFC Grid manual

CHeader Class Reference

This class implements the header. More...

#include <Dapfor/GUI/Header.h>

Inheritance diagram for CHeader:

IAutoDelete

List of all members.


Serialization

virtual void Serialize (CArchive &ar)
 Serializes or deserializes data to/from the archive.
static int GetSerializeVersion ()
 Current serialization version.

Public Types

enum  NotificationType {
  ColumnAdded, ColumnRemoved, ColumnResized, ColumnModified,
  ColumnVisibleChanged, ColumnMoved, FixedCountChanged, SortChanged,
  NavigationColumnChanged, HeaderHeightChanged, FontChanged, ImageListChanged
}
 Notification type. More...

Public Member Functions

 CHeader (bool autoDelete=true)
 Constructor.
 CHeader (const CHeader &header, bool autoDelete=true)
 Copy constructor.
virtual ~CHeader ()
 Virtual destructor.
virtual const CColumnGetHierarchicalColumn () const
 Indicates the current hierarchical column.
virtual bool SetHierarchicalColumn (Common::FID fid)
 Sets a new hierarchical column.
Add/remove colums
virtual bool Add (CColumn *column)
 Adds a new column.
virtual bool Remove (Common::FID fid)
 Removes a column by its identifier.
virtual void RemoveAll ()
 Removes all columns.
Column count and fixed columns
virtual long GetColumnCount () const
 Gets a count of all columns.
virtual long GetVisibleColumnCount () const
 Gets a count of all visible columns.
virtual void SetFixedColumnsCount (int fixedColumnsCount)
 Sets a new count of fixed columns.
virtual int GetFixedColumnsCount () const
 Gets a count of fixed columns.
virtual bool IsFixed (Common::FID fid) const
 Gets the value inficating whether a column is fixed.
Visibility
virtual bool ShowColumn (Common::FID fid)
 Shows an already hidden column.
virtual bool HideColumn (Common::FID fid)
 Hides a column.
Column moving & sizing
virtual bool CanMoveFixedColumns () const
 Gets the value indicating whether fixed columns can be moved.
virtual bool CanMoveScrollableColumns () const
 Gets the value indicating whether scrollable columns can be moved.
virtual bool CanResizeColumn () const
 Gets the value indicating whether columns can be resized.
virtual void AllowFixedColumnMove (bool enable)
 Sets the value indicating that fixed columns can be moved.
virtual void AllowScrollableColumnMove (bool enable)
 Sets the value indicating that scrollable columns can be moved.
virtual void AllowColumnResize (bool enable)
 Sets the value indicating that columns can be resized.
virtual bool MoveBefore (Common::FID toMove, Common::FID before)
 Moves a specified column before another column.
virtual bool MoveAfter (Common::FID toMove, Common::FID after)
 Moves a specified column after another column.
virtual bool MoveToPosition (Common::FID toMove, int position)
 Moves a specified column to the specified location.
virtual bool MoveToVisiblePosition (Common::FID toMove, int position)
 Moves a specified column to the specified visible position.
Fid to index and vice versa
virtual CColumnGetColumnByIndex (int index) const
 Gets a column by its zero-based index.
virtual CColumnGetVisibleColumnByIndex (int index) const
 Gets a visible column by its zero-based index.
virtual CColumnGetColumnByFid (Common::FID fid) const
 Gets a column by its identifier.
virtual CColumnGetVisibleColumnByFid (Common::FID fid) const
 Gets a visible column by its identifier.
virtual int GetColumnIndex (Common::FID fid) const
 Gets an index of a column.
virtual int GetVisibleColumnIndex (Common::FID fid) const
 Gets an index of a visible column. (in range of visible columns).
virtual CColumnGetFirstColumn () const
 Gets the first column.
virtual CColumnGetFirstVisibleColumn () const
 Gets the first visible column.
virtual CColumnGetLastColumn () const
 Gets the last column.
virtual CColumnGetLastVisibleColumn () const
 Gets the last visible column.
Position and dimensions
virtual CColumnHitTest (const CGrid &grid, CPoint point) const
 Gets a column of the header located within the given coordinates.
virtual CRect GetVirtualRect (const CGrid &grid, Common::FID fid) const
 Gets virtual coordinates of the column with the specified identifier.
virtual CRect GetVisibleRect (const CGrid &grid, Common::FID fid) const
 Gets visible coordinates of the column with the specified identifier.
virtual int GetHeaderHeight () const
 Gets a height of the header.
virtual void SetHeaderHeight (int height)
 Sets a new height of the header.
virtual int GetFixedColumnWidth () const
 Gets the width occupied by all fixed columns.
virtual int GetScrollableColumnWidth () const
 Gets the width occupied by all scrollable columns.
Navigation column
virtual void SetNavigationColumn (int column)
 Sets a new navigation column.
virtual int GetNavigationColumn () const
 Gets a current navigation column.
Sort functions
virtual void AllowSort (bool enable)
 Sort functions.
virtual bool CanSort () const
 Returns the value indicating if CGrid can perform lines sorting or not.
virtual void AllowMultiSort (bool enable)
 Allows or forbids multiple sorting in the grid.
virtual bool CanMultiSort () const
 Returns the value indicating if CGrid can perform lines multiple sorting or not.
virtual void SetSort (int level, CSortInfo sortInfo)
 Sets or modifies sorting for a specified level.
virtual CSortInfo GetSort (int level) const
 Gets sorting related information for a given level.
virtual int GetSortLevels () const
 Retrieves a count of sorting levels.
virtual void ResetSort ()
 Resets a sort.
Font and images
virtual CFont * SetFont (CFont *font)
 Sets a new font.
virtual CFont * GetFont () const
 Gets a current font.
virtual CImageList * SetImageList (CImageList *imageList)
 Sets a new images list to show icons in header columns.
virtual CImageList * GetImageList () const
 Gets a current images list used to show icons in the header columns.
Notifications
void Subscribe (INotify *callBack)
 Subscribes for events.
void Unsubscribe (INotify *callBack)
 Unsubscribes from events.
IAutoDelete implementation
virtual bool AutoDelete () const
 IAutoDelete implementation. Returns the value, passed in the constructor.

Classes

struct  INotify
 Interface to receive notifications about the header state modification. More...

Detailed Description

This class implements the header.

Stores columns and allows their handling and also stores the necessary information for sorting lines in the grid. All the columns inserted in the header have the identifiers corresponding to the identifiers of data object fields. The given identifiers should not repeat. While replacing headers in the grid, data objects contents can be presented in absolutely another way.

The header allows to do columns invisible, to replace them, to organize unscrolling columns. Also the header stores the information about sorting. While setting a new header the grid automatically makes line sorting according to the rules set in the header. Up to five levels of sorting (up to five columns which take part) are possible. At defining a line location in the grid there is a comparison of the unformatted values returned by data objects fields. This also considers hierarchical structure of the grid.

When columns are added to the header, there is a subscription to dispatch events which are transferred in the grid then. Also the header can generate its own events and notify the subscribers.

It is also important to note, that almost all the functions of CHeader class are thread-safe and can be called from any thread. All events are sent in such a way, that at the moment of their sending synchronizing objects of such type as critical section or mutex are not occupied.


Member Enumeration Documentation

enum NotificationType

Notification type.

Enumerator:
ColumnAdded  A new column has been added to the header.
ColumnRemoved  A column has been removed from the header.
ColumnResized  Column size has been changed.
ColumnModified  Some values in the column have been modified.
ColumnVisibleChanged  The visibility of the column has been changed.
ColumnMoved  The column has been moved.
FixedCountChanged  The count of fixed columns is changed.
SortChanged  Sorting is modified.
NavigationColumnChanged  Navigation column has been changed.
HeaderHeightChanged  Height of the header has been changed.
FontChanged  Header font has been changed.
ImageListChanged  Images list to show that icons in columns are changed.


Constructor & Destructor Documentation

CHeader ( bool  autoDelete = true  ) 

Constructor.

Parameters:
[in] autoDelete Value indicating that CGrid manages the live cycle of the header. True - CGrid will destroy the header in its own destructor. False - it is a responsibility of the programmer to destroy the header.

CHeader ( const CHeader header,
bool  autoDelete = true 
)

Copy constructor.

Parameters:
[in] header The header to be copied.
[in] autoDelete Value indicating that CGrid manages the live cycle of the header. True - CGrid will destroy the header in its own destructor. False - it is a responsibility of the programmer to destroy the header.


Member Function Documentation

bool Add ( CColumn column  )  [virtual]

Adds a new column.

The header can't have two columns with the same identifiers. The function can raise CHeader::ColumnAdded notification.

Parameters:
[in] column New column
Returns:
True if the column has been successfully added. Otherwise - false.
Thread safety:
The function is thread safe. All notifications are raised without taking synchronizing objects like critical section or mutex.

bool Remove ( Common::FID  fid  )  [virtual]

Removes a column by its identifier.

The function can raise CHeader::ColumnRemoved notification.

Parameters:
[in] fid Column's identifier
Returns:
True if the column has been successfully removed.
Thread safety:
The function is thread safe. All notifications are raised without taking synchronizing objects like critical section or mutex.

void RemoveAll (  )  [virtual]

Removes all columns.

The function can raise CHeader::ColumnRemoved notification.

Thread safety:
The function is thread safe. All notifications are raised without taking synchronizing objects like critical section or mutex.

long GetColumnCount (  )  const [virtual]

Gets a count of all columns.

Returns:
Count of the columns stored in the header.
Thread safety:
The function is thread safe.

long GetVisibleColumnCount (  )  const [virtual]

Gets a count of all visible columns.

Returns:
Count of visible columns
Thread safety:
The function is thread safe.

void SetFixedColumnsCount ( int  fixedColumnCount  )  [virtual]

Sets a new count of fixed columns.

The function can raise CHeader::FixedCountChanged notification.

Parameters:
[in] fixedColumnCount New count of visible columns.
Thread safety:
The function is thread safe. All notifications are raised without taking synchronizing objects like critical section or mutex.

int GetFixedColumnsCount (  )  const [virtual]

Gets a count of fixed columns.

Returns:
Count of fixed columns
Thread safety:
The function is thread safe.

bool IsFixed ( Common::FID  fid  )  const [virtual]

Gets the value inficating whether a column is fixed.

Parameters:
[in] fid Column's identifier
Returns:
True if the column is fixed. Otherwise - non.
Thread safety:
The function is thread safe.

bool ShowColumn ( Common::FID  fid  )  [virtual]

Shows an already hidden column.

The function can raise CHeader::ColumnVisibleChanged notification.

Parameters:
[in] fid Column's identifier
Returns:
True if the column became visible. Otherwise - false.
Thread safety:
The function is thread safe. All notifications are raised without taking synchronizing objects like critical section or mutex.

bool HideColumn ( Common::FID  fid  )  [virtual]

Hides a column.

The function can raise CHeader::ColumnVisibleChanged notification.

Parameters:
[in] fid Column's identifier
Returns:
True if the column became invisible. Otherwise - false.
Thread safety:
The function is thread safe. All notifications are raised without taking synchronizing objects like critical section or mutex.

bool CanMoveFixedColumns (  )  const [virtual]

Gets the value indicating whether fixed columns can be moved.

Returns:
True if fixed columns can be moved. Otherwise - false.
Thread safety:
The function is thread safe.

bool CanMoveScrollableColumns (  )  const [virtual]

Gets the value indicating whether scrollable columns can be moved.

Returns:
True if scrollable columns can be moved. Otherwise - false.
Thread safety:
The function is thread safe.

bool CanResizeColumn (  )  const [virtual]

Gets the value indicating whether columns can be resized.

Returns:
True if columns can be resized. Otherwise - false.
Thread safety:
The function is thread safe.

void AllowFixedColumnMove ( bool  enable  )  [virtual]

Sets the value indicating that fixed columns can be moved.

Parameters:
[in] enable True - columns can be moved. Otherwise - false.
Thread safety:
The function is thread safe.

void AllowScrollableColumnMove ( bool  enable  )  [virtual]

Sets the value indicating that scrollable columns can be moved.

Parameters:
[in] enable True - columns can be moved. Otherwise - false.
Thread safety:
The function is thread safe.

void AllowColumnResize ( bool  enable  )  [virtual]

Sets the value indicating that columns can be resized.

Parameters:
[in] enable True - columns can be resized. Otherwise - false.
Thread safety:
The function is thread safe.

bool MoveBefore ( Common::FID  toMove,
Common::FID  before 
) [virtual]

Moves a specified column before another column.

The function can raise CHeader::ColumnMoved notification.

Parameters:
[in] toMove The column to be moved
[in] before Position before which the column will be inserted
Returns:
True if the column has been sccessfully moved. Otherwise false.
Thread safety:
The function is thread safe. All notifications are raised without taking synchronizing objects like critical section or mutex.

bool MoveAfter ( Common::FID  toMove,
Common::FID  after 
) [virtual]

Moves a specified column after another column.

The function can raise CHeader::ColumnMoved notification.

Parameters:
[in] toMove The column to be moved
[in] after Position after which the column will be inserted
Returns:
True if the column has been sccessfully moved. Otherwise false.
Thread safety:
The function is thread safe. All notifications are raised without taking synchronizing objects like critical section or mutex.

bool MoveToPosition ( Common::FID  toMove,
int  position 
) [virtual]

Moves a specified column to the specified location.

The function can raise CHeader::ColumnMoved notification.

Parameters:
[in] toMove The column to be moved
[in] position Zero-based index indicating position to which the column will be inserted.
Returns:
True if the column has been sccessfully moved. Otherwise false.
Thread safety:
The function is thread safe. All notifications are raised without taking synchronizing objects like critical section or mutex.

bool MoveToVisiblePosition ( Common::FID  toMove,
int  position 
) [virtual]

Moves a specified column to the specified visible position.

The function can raise CHeader::ColumnMoved notification. The column must be visible.

Parameters:
[in] toMove The column to be moved
[in] position Zero-based index in range of visible columns.
Returns:
True if the column has been sccessfully moved. Otherwise false.
Thread safety:
The function is thread safe. All notifications are raised without taking synchronizing objects like critical section or mutex.

CColumn * GetColumnByIndex ( int  index  )  const [virtual]

Gets a column by its zero-based index.

Parameters:
[in] index - Zero-based index of the columns stored in the header.
Returns:
Column if it is found. Otherwise - 0.
Thread safety:
The function is thread safe.

CColumn * GetVisibleColumnByIndex ( int  index  )  const [virtual]

Gets a visible column by its zero-based index.

Parameters:
[in] index - Zero-based index of visible columns.
Returns:
Column if it is found and is visible. Otherwise - 0.
Thread safety:
The function is thread safe.

CColumn * GetColumnByFid ( Common::FID  fid  )  const [virtual]

Gets a column by its identifier.

Parameters:
[in] fid - identifier of the column.
Returns:
Column if it is found. Otherwise - 0.
Thread safety:
The function is thread safe.

CColumn * GetVisibleColumnByFid ( Common::FID  fid  )  const [virtual]

Gets a visible column by its identifier.

Parameters:
[in] fid - identifier of the column.
Returns:
Column if it is found and is visible. Otherwise - 0.
Thread safety:
The function is thread safe.

int GetColumnIndex ( Common::FID  fid  )  const [virtual]

Gets an index of a column.

Parameters:
[in] fid - identifier of the column.
Returns:
Zero-based index if the column is found. Otherwise -1.
Thread safety:
The function is thread safe.

int GetVisibleColumnIndex ( Common::FID  fid  )  const [virtual]

Gets an index of a visible column. (in range of visible columns).

Parameters:
[in] fid - identifier of the column.
Returns:
Zero-based index if the column is found and visible. Otherwise -1.
Thread safety:
The function is thread safe.

CColumn * GetFirstColumn (  )  const [virtual]

Gets the first column.

Returns:
The first column in the header. The column can be visible and invisible as well.
Thread safety:
The function is thread safe.

CColumn * GetFirstVisibleColumn (  )  const [virtual]

Gets the first visible column.

Returns:
The first visible column in the header.
Thread safety:
The function is thread safe.

CColumn * GetLastColumn (  )  const [virtual]

Gets the last column.

Returns:
The last column in the header. The column can be visible and invisible as well.
Thread safety:
The function is thread safe.

CColumn * GetLastVisibleColumn (  )  const [virtual]

Gets the last visible column.

Returns:
The last visible column in the header.
Thread safety:
The function is thread safe.

CColumn * HitTest ( const CGrid grid,
CPoint  point 
) const [virtual]

Gets a column of the header located within the given coordinates.

Parameters:
[in] grid The grid, which holds the header.
[in] point the coordinates counted in the client's area of the grid.
Returns:
Found column. Otherwise - 0.
Thread safety:
The function is thread safe.

CRect GetVirtualRect ( const CGrid grid,
Common::FID  fid 
) const [virtual]

Gets virtual coordinates of the column with the specified identifier.

Parameters:
[in] grid The grid, which holds the header.
[in] fid - identifier of the column.
Returns:
Rectangle occupied by a given column without taking the size of the client's grid area and scrolling into consideration.
Thread safety:
The function is thread safe.

CRect GetVisibleRect ( const CGrid grid,
Common::FID  fid 
) const [virtual]

Gets visible coordinates of the column with the specified identifier.

Parameters:
[in] grid The grid, which holds the header.
[in] fid - identifier of the column.
Returns:
Rectangle occupied by a given column taking the size of the client's grid area and scrolling into consideration.
Thread safety:
The function is thread safe.

int GetHeaderHeight (  )  const [virtual]

Gets a height of the header.

Returns:
Height of the header in pixels.
Thread safety:
The function is thread safe.

void SetHeaderHeight ( int  height  )  [virtual]

Sets a new height of the header.

The function can raise CHeader::HeaderHeightChanged notification.

Parameters:
[in] height New height of the header
Thread safety:
The function is thread safe. All notifications are raised without taking synchronizing objects like critical section or mutex.

int GetFixedColumnWidth (  )  const [virtual]

Gets the width occupied by all fixed columns.

Returns:
Width in pixels
Thread safety:
The function is thread safe.

int GetScrollableColumnWidth (  )  const [virtual]

Gets the width occupied by all scrollable columns.

Returns:
Width in pixels
Thread safety:
The function is thread safe.

void SetNavigationColumn ( int  column  )  [virtual]

Sets a new navigation column.

Parameters:
[in] column New navigation column
Thread safety:
The function is thread safe.

int GetNavigationColumn (  )  const [virtual]

Gets a current navigation column.

Returns:
Current navigation column
Thread safety:
The function is thread safe.

const CColumn * GetHierarchicalColumn (  )  const [virtual]

Indicates the current hierarchical column.

Returns:
Current hierarchical column

bool SetHierarchicalColumn ( Common::FID  fid  )  [virtual]

Sets a new hierarchical column.

Returns:
True if success.

void AllowSort ( bool  enable  )  [virtual]

Sort functions.

Allows or forbids sorting in the grid.

Parameters:
[in] enable Allows sorting in the grid. True - sorting is allowed, false - forbidden.
Thread safety:
The function is thread safe.

bool CanSort (  )  const [virtual]

Returns the value indicating if CGrid can perform lines sorting or not.

Returns:
True - sorting is allowed, false - forbidden.
Thread safety:
The function is thread safe.

void AllowMultiSort ( bool  enable  )  [virtual]

Allows or forbids multiple sorting in the grid.

Parameters:
[in] enable Allows multiple sorting in the grid. True - multiple sorting is allowed, false - forbidden.
Thread safety:
The function is thread safe.

bool CanMultiSort (  )  const [virtual]

Returns the value indicating if CGrid can perform lines multiple sorting or not.

Returns:
True - multiple sorting is allowed, false - forbidden.
Thread safety:
The function is thread safe.

void SetSort ( int  level,
GUI::CSortInfo  sortInfo 
) [virtual]

Sets or modifies sorting for a specified level.

If CSortInfo::SetFid() returns the value equal to Common::fieldNotSpecified, then sorting is disabled on a given level. The function can raise CHeader::SortChanged notification.

Parameters:
[in] level zero-based sorting level.
[in] sortInfo Sorting related information (field identifier, direction, ...)
Thread safety:
The function is thread safe. All notifications are raised without taking synchronizing objects like critical section or mutex.

GUI::CSortInfo GetSort ( int  level  )  const [virtual]

Gets sorting related information for a given level.

Parameters:
[in] level zero-based sorting level.
Returns:
Sorting related information.
Thread safety:
The function is thread safe.

int GetSortLevels (  )  const [virtual]

Retrieves a count of sorting levels.

Returns:
Count of sorting levels
Thread safety:
The function is thread safe.

void ResetSort (  )  [virtual]

Resets a sort.

The function can raise CHeader::SortChanged notification.

Thread safety:
The function is thread safe. All notifications are raised without taking synchronizing objects like critical section or mutex.

CFont * SetFont ( CFont *  font  )  [virtual]

Sets a new font.

The function can raise CHeader::FontChanged notification.

Parameters:
[in] font New font
Returns:
Previous font is returned.
Thread safety:
The function is thread safe. All notifications are raised without taking synchronizing objects like critical section or mutex.

CFont * GetFont (  )  const [virtual]

Gets a current font.

Returns:
Current font
Thread safety:
The function is thread safe.

CImageList * SetImageList ( CImageList *  imageList  )  [virtual]

Sets a new images list to show icons in header columns.

Parameters:
[in] imageList New images list
Returns:
Previous images list
Thread safety:
The function is thread safe.

CImageList * GetImageList (  )  const [virtual]

Gets a current images list used to show icons in the header columns.

Returns:
Current images list
Thread safety:
The function is thread safe.

void Subscribe ( INotify callBack  ) 

Subscribes for events.

Parameters:
[in] callBack Callback interface to be called when an event is raised.
Thread safety:
The function is thread safe.

void Unsubscribe ( INotify callBack  ) 

Unsubscribes from events.

Parameters:
[in] callBack Callback interface to be unsubscribed from events receiving.
Thread safety:
The function is thread safe.

void Serialize ( CArchive &  ar  )  [virtual]

Serializes or deserializes data to/from the archive.

Parameters:
[in] ar Archive to store or restore the header's data.
Thread safety:
The function is not thread safe.

int GetSerializeVersion (  )  [static]

Current serialization version.

Returns:
Current serialization version
Thread safety:
The function is thread safe.

bool AutoDelete (  )  const [virtual]

IAutoDelete implementation. Returns the value, passed in the constructor.

Returns:
value, passed in the constructor.
Thread safety:
The function is thread safe.

Implements IAutoDelete.