コード例 #1
0
ファイル: UGMemMan.cpp プロジェクト: acraig5075/best-fit-demo
/***************************************************
DeleteCol
	This function deletes a column at the specified 
	position. Even if the column does not exist the 
	function will return success. However if there
	are no rows in the grid the function will fail.
Params
	col - column number to delete
Return
	UG_SUCCESS  - success
	UG_ERROR	- failure
****************************************************/
int CUGMem::DeleteCol(int col)
{
	//goto the first row
	while(PrevRow()==UG_SUCCESS);

	//check to see if there is a first row
	if(m_rowInfo == NULL)
		return UG_ERROR;

	//move the 'col' column over 
	UGMemCI *colinfo;
	do{
		if(GotoCol(col) ==UG_SUCCESS)
		{
			// delete the columninfo if there are columns to the right
			if(m_colInfo->next != NULL){
				//update the links
				colinfo = m_colInfo->prev;
				if(colinfo != NULL)
					colinfo->next = m_colInfo->next;

				colinfo = m_colInfo->next;
				if(colinfo != NULL)
					colinfo->prev = m_colInfo->prev;

				if(m_rowInfo->col == m_colInfo)
					m_rowInfo->col = colinfo;
	
				//delete the colinfo
				if(m_colInfo->cell != NULL)
					delete m_colInfo->cell;
				delete m_colInfo;
			}
			// else if there are no more column to the right, then keep the
			// colinfo, but delete the cellinfo within the colinfo
			// since this may be the initial link to the rowinfo list
			else{
				delete m_colInfo->cell;
				m_colInfo->cell = NULL;
			}
		}
	}while(NextRow()==UG_SUCCESS);

	//adjust the column translations
	int numCols = m_ctrl->GetNumberCols();
	if(numCols > 0)
	{
		for(int loop = 0 ; loop < numCols;loop++)
		{
			if(m_ctrl->m_GI->m_colInfo[loop].colTranslation >= col)
				m_ctrl->m_GI->m_colInfo[loop].colTranslation--;
		}
	}

	//update the current column pointer
	m_colInfo		= m_rowInfo->col;
	m_currentCol	= 0; 

	return UG_SUCCESS;
}
コード例 #2
0
NS_IMETHODIMP
morkTableRowCursor::PrevRow( // get row cells from table for cells already in row
  nsIMdbEnv* mev, // context
  nsIMdbRow** acqRow, // acquire previous row in table
  mdb_pos* outRowPos)
{
  mdb_err outErr = 0;
  nsIMdbRow* outRow = 0;
  morkEnv* ev = morkEnv::FromMdbEnv(mev);
  if ( ev )
  {
      
    mdbOid oid; // place to put oid we intend to ignore
    morkRow* row = PrevRow(ev, &oid, outRowPos);
    if ( row )
    {
      morkStore* store = row->GetRowSpaceStore(ev);
      if ( store )
        outRow = row->AcquireRowHandle(ev, store);
    }
    outErr = ev->AsErr();
  }
  if ( acqRow )
    *acqRow = outRow;
  return outErr;
}
コード例 #3
0
ファイル: UGMemMan.cpp プロジェクト: acraig5075/best-fit-demo
/***************************************************
InsertCol
	This function inserts a blank column at the specified
	location. The previous column in that location is 
	pushed right one column. If the specified column does not
	already exist for a given row, then that row will be
	skipped and the insert will continue.
Params
	col - column number where a blank column will be inserted
Return
	UG_SUCCESS  - success
	UG_ERROR	- failure (no rows in grid)
****************************************************/
int CUGMem::InsertCol(int col)
{
	//goto the first row
	while(PrevRow()==UG_SUCCESS);

	//check to see if there is a first row
	if(m_rowInfo == NULL)
		return UG_ERROR;

	//get the screen position column number
	int numCols = m_ctrl->GetNumberCols();
	if(numCols > 0)
	{
		for(int loop = 0 ; loop < numCols;loop++)
		{
			if(m_ctrl->m_GI->m_colInfo[loop].colTranslation == col)
			{
				col = loop;
				break;
			}
		}
	}

	//move the 'col' column over 
	UGMemCI *newcol;
	do
	{
		if(GotoCol(col) ==UG_SUCCESS)
		{
			newcol			= new UGMemCI;
			newcol->cell	= NULL;
			newcol->next	= m_colInfo;
			newcol->prev	= m_colInfo->prev;
			
			if(newcol->prev != NULL)
				newcol->prev->next = newcol;

			if(m_rowInfo->col == m_colInfo)
				m_rowInfo->col = newcol;

			m_colInfo->prev = newcol;
			m_currentCol ++;

		}
	}while(NextRow()==UG_SUCCESS);

	//adjust the column translations
	if(numCols > 0)
	{
		for(int loop = 0 ; loop < numCols;loop++)
		{
			if(m_ctrl->m_GI->m_colInfo[loop].colTranslation >= col)
				m_ctrl->m_GI->m_colInfo[loop].colTranslation++;
		}
	}

	return UG_SUCCESS;
}