/**********************************************************************/ /** Microsoft Windows/NT **/ /** Copyright(c) Microsoft Corporation, 1997 - 1999 **/ /**********************************************************************/ /* ipstrm.cpp FILE HISTORY: */ #include "stdafx.h" #include "column.h" #include "xstream.h" /*--------------------------------------------------------------------------- ViewInfo implementation ---------------------------------------------------------------------------*/ ViewInfo::ViewInfo() { m_cColumns = 0; m_prgColumns = NULL; m_dwSortColumn = 0; m_dwSortDirection = TRUE; m_pViewColumnInfo = NULL; m_cVisibleColumns = 0; m_prgSubitems = NULL; m_fConfigurable = TRUE; } ViewInfo::~ViewInfo() { delete [] m_prgColumns; delete [] m_prgSubitems; m_pViewColumnInfo = NULL; } /*!-------------------------------------------------------------------------- ViewInfo::InitViewInfo - Author: KennT ---------------------------------------------------------------------------*/ void ViewInfo::InitViewInfo(ULONG cColumns, BOOL fConfigurable, BOOL fDefaultSortDirectionDescending, const ContainerColumnInfo *pViewColInfo) { m_cColumns = cColumns; delete [] m_prgColumns; m_prgColumns = new ColumnData[cColumns]; delete [] m_prgSubitems; m_prgSubitems = new ULONG[cColumns]; m_pViewColumnInfo = pViewColInfo; m_fDefaultSortDirection = fDefaultSortDirectionDescending; m_fConfigurable = fConfigurable; InitNew(); } /*!-------------------------------------------------------------------------- ViewInfo::InitNew - Author: KennT ---------------------------------------------------------------------------*/ void ViewInfo::InitNew() { // setup the defaults for this column for (int i=0; i<(int) m_cColumns; i++) { if (m_pViewColumnInfo[i].m_fVisibleByDefault) m_prgColumns[i].m_nPosition = i+1; else m_prgColumns[i].m_nPosition = -(i+1); m_prgColumns[i].m_dwWidth = AUTO_WIDTH; } m_dwSortDirection = m_fDefaultSortDirection; UpdateSubitemMap(); } ULONG ViewInfo::MapSubitemToColumn(ULONG nSubitemId) { for (ULONG i=0; i= m_cColumns) continue; m_prgSubitems[cVisible++] = j; } m_cVisibleColumns = cVisible; } HRESULT ViewInfo::Xfer(XferStream *pxstm, ULONG ulSortColumnId, ULONG ulSortAscendingId, ULONG ulColumnsId) { Assert(pxstm); HRESULT hr = hrOK; ULONG cColumns; // Xfer the column data Assert(m_prgColumns); cColumns = m_cColumns; CORg( pxstm->XferColumnData(ulColumnsId, &m_cColumns, m_prgColumns) ); // The number of columns shouldn't change! Assert(m_cColumns == cColumns); // Use the old number of columns (this is for as we change our code) m_cColumns = cColumns; // Xfer the sort column CORg( pxstm->XferDWORD( ulSortColumnId, &m_dwSortColumn) ); // Xfer the ascending data CORg( pxstm->XferDWORD( ulSortAscendingId, &m_dwSortDirection) ); UpdateSubitemMap(); Error: return hr; } /*--------------------------------------------------------------------------- ConfigStream implementation ---------------------------------------------------------------------------*/ /*!-------------------------------------------------------------------------- ConfigStream::ConfigStream - Author: KennT ---------------------------------------------------------------------------*/ ConfigStream::ConfigStream() : m_nVersion(0x00020000), m_nVersionAdmin(0x0002000), m_fDirty(FALSE), m_rgViewInfo(NULL), m_cColumnSetsMax(0), m_prgrc(NULL) { } ConfigStream::~ConfigStream() { delete [] m_rgViewInfo; delete [] m_prgrc; m_cColumnSetsMax = 0; } void ConfigStream::Init(ULONG cColumnSetsMax) { delete [] m_rgViewInfo; m_rgViewInfo = NULL; m_rgViewInfo = new ViewInfo[cColumnSetsMax]; delete [] m_prgrc; m_prgrc = NULL; m_prgrc = new RECT[cColumnSetsMax]; m_cColumnSetsMax = cColumnSetsMax; } /*!-------------------------------------------------------------------------- ConfigStream::InitViewInfo Initializes the static data. This is not the same as InitNew. This will initialize the data for a single view. Author: KennT ---------------------------------------------------------------------------*/ void ConfigStream::InitViewInfo(ULONG ulId, BOOL fConfigurableColumns, ULONG cColumns, BOOL fSortDirection, const ContainerColumnInfo *pViewColumnInfo) { Assert(ulId < m_cColumnSetsMax); m_fConfigurableColumns = fConfigurableColumns; m_rgViewInfo[ulId].InitViewInfo(cColumns, fConfigurableColumns, fSortDirection, pViewColumnInfo); } /*!-------------------------------------------------------------------------- ConfigStream::InitNew - Author: KennT ---------------------------------------------------------------------------*/ HRESULT ConfigStream::InitNew() { int iVisible=0; // Setup the appropriate defaults for (UINT i=0; i