예제 #1
0
bool CDcdFreeLine::getItemSize( IfDcdTarget* pIfDcdTarget , 
							CdDcdSizeXy* pCdDcdSizeXy ) 
{
	CdDcdSizeXy	aCdDcdSizeXy ;
	if ( m_posOrg.getX() < m_posDst.getX() ){
		aCdDcdSizeXy.setX( 
			m_posDst.getX() - m_posOrg.getX() + 1 ) ;
	}	else	{
		aCdDcdSizeXy.setX( 
			m_posOrg.getX() - m_posDst.getX() + 1 ) ;
	}
	if ( m_posOrg.getY() < m_posDst.getY() ){
		aCdDcdSizeXy.setY(
			m_posDst.getY() - m_posOrg.getY() + 1 ) ;
	}	else	{
		aCdDcdSizeXy.setY(
			m_posOrg.getY() - m_posDst.getY() + 1 ) ;
	}
	// --------------------------------
	aCdDcdSizeXy.setX( aCdDcdSizeXy.getX() + 
		( m_CdLineProp.getLogicalunitWidth() - 1 ) ) ;
	aCdDcdSizeXy.setY( aCdDcdSizeXy.getY() - 
		( m_CdLineProp.getLogicalunitWidth() - 1 ) ) ;

	// --------------------------------
	*pCdDcdSizeXy = aCdDcdSizeXy ;
	
	return ( true ) ;
}
예제 #2
0
	// ********************************
	// @name	属性
	// ********************************
	// ********************************
	// @name	操作
	// ********************************
DcdSize	CDcdGridXBorder::getColumnBorderSize( IfDcdTarget* pIfDcdTarget ) 
{
	int	iRv = 0 ;
	if ( m_bAutoColumnBorderSize ){
		CdDcdSizeXy	aCdDcdSizeXy ;
		if ( m_pIfDcDraw->getItemSize( pIfDcdTarget, &aCdDcdSizeXy ) ){
			iRv = aCdDcdSizeXy.getX() ;
		}
	}	else	{
		iRv = m_iColumnBorderSize ;
	}
	return ( iRv ) ;
}
int CDcdTargetCompatibleBitmap::resetSize( 
		const CdDcdSizeXy& aCdDcdSizeXy , HDC hDc ) 
{
	int	iRv = 0 ;
	// ********************************
	//	既存のDC・BITMAPを破棄
	// ********************************
	if ( iRv == 0 ){
		m_CdDcdSizeXy.setX( 0 ).setY( 0 ) ;

		if ( m_hBitmapSid != NULL ){
			SelectObject( m_hDc , m_hBitmapSid ) ;
			m_hBitmapSid = NULL ;
		}	
		if ( m_hBitmap != NULL ){
			DeleteObject( m_hBitmap ) ;
			m_hBitmap = NULL ;
		}
		if ( m_hDc != NULL ){
			DeleteDC( m_hDc ) ;
			m_hDc = NULL ;
		}
	}
	// ********************************
	//	新しいDC・BITMAPを作成
	// ********************************
	if ( aCdDcdSizeXy.getX() > 0 && aCdDcdSizeXy.getY() > 0 ){
		bool	bhDcDeleteObligatory = false ;
		if ( hDc == NULL ){
			hDc = GetDC( NULL ) ;
			bhDcDeleteObligatory = true ;
		}

		if ( iRv == 0 ){
			m_hDc = CreateCompatibleDC( hDc ) ;
			if ( m_hDc == NULL ){
				iRv = -1 ;	//	DCの作成に失敗しました
			}
		}	
		if ( iRv == 0 ){
			m_hBitmap = CreateCompatibleBitmap( hDc , aCdDcdSizeXy.getX() , aCdDcdSizeXy.getY() ) ;
			if ( m_hBitmap == NULL ){
				iRv = -2 ;	//	BITMAPの作成に失敗しました
			}
			
		}
		if ( iRv == 0 ){
			m_hBitmapSid = (HBITMAP)SelectObject( m_hDc , m_hBitmap ) ;
		}
		if ( iRv == 0 ){
			m_CdDcdSizeXy = aCdDcdSizeXy ;
		}	
		// --------------------------------
		if ( bhDcDeleteObligatory ){
			ReleaseDC( NULL , hDc ) ;
			hDc = NULL ;
		}
	}	
	
	return ( iRv ) ;
}
예제 #4
0
void CEkiView::OnPrint(CDC* pDC, CPrintInfo* pInfo) 
{
	LogMsg( L"CEkiView::OnPrint() " ) ;
	LogMsg( CDcdTargetMfcPrintInfo::stringOf( pInfo ).c_str() ) ;

	// --------------------------------
	//	描画面を作成
	// --------------------------------
	CDcdTargetMfcPrintInfo	aCDcdTargetMfcPrintInfo( pDC, pInfo ) ;

	// --------------------------------
	//	余白を除いた領域を作成
	// --------------------------------
	CaDcdTargetItemPosition	aTargetInnerMargin( &aCDcdTargetMfcPrintInfo , 
		CdDcdZoneXy() ) ;
	{
		LogMsg( DeviceCapsToString( 
			aCDcdTargetMfcPrintInfo.getPrinterHdc() ).c_str() ) ;
	
		CconvCdPrintPageProp aCconvCdPrintPageProp ;
		CdDcdZoneXy	zonexyInneraMargin = 
			aCconvCdPrintPageProp.calcZoneInnerMargin( 
				getCDiagramEditApp()->getCdPrintPageProp() , 
				aCDcdTargetMfcPrintInfo.getPrinterHdc() ) ;
		if ( zonexyInneraMargin.getX().getSize() <= 0 ){
			zonexyInneraMargin.setX( 
				aCDcdTargetMfcPrintInfo.getZone().getX() ) ;
		}
		if ( zonexyInneraMargin.getY().getSize() <= 0 ){
			zonexyInneraMargin.setY( 
				aCDcdTargetMfcPrintInfo.getZone().getY() ) ;
		}

		aTargetInnerMargin.setZone( zonexyInneraMargin ) ;

	}

	//aTargetInnerMargin = 余白部分を除いた描画領域。
	//	単位はプリンタのピクセルです。

	// --------------------------------
	//	論理座標を設定
	// --------------------------------
	CaDcdTargetZoomDisplay	aCaDcdTargetZoomDisplay( 
		&aTargetInnerMargin , 
		aCDcdTargetMfcPrintInfo.getPrinterHdc() ) ;
	//aCaDcdTargetZoomDisplay = 余白部分を除いた描画領域。
	//	単位は、画面上の1ピクセル相当になりました。

	// --------------------------------
	//	キャプションとページ番号の部品を作成
	// --------------------------------
	Ou<CDcdText>	pdcdCaption ;
	Ou<CDcdText>	pdcdPage ;
	{
		const CentDedRosen* pCentDedRosen = 
			getCDiagramEditDoc()->getCDedRosenFileData()->getCentDedRosen() ;
		CJikokuhyouDoc* pCJikokuhyouDoc = (CJikokuhyouDoc*)GetDocument() ;

		wstring	strText ;
		//	路線名
		if ( !pCentDedRosen->getName().empty() ){
			strText += pCentDedRosen->getName() ;
			strText += L" " ;

			CString	aString ;
			aString.LoadString( IDS_WORD_EKI ) ;
			strText += (LPCTSTR)aString ;
		}
		pdcdCaption = OuNew<CDcdText>( new CDcdText( 
			strText , getCdDrawTextPropStandard() ) ) ;
	}
	// --------------------------------
	{
		CdDrawTextProp	aProp = getCdDrawTextPropStandard() ;
		CdDrawTextFormat	aFormat = aProp.getCdDrawTextFormat() ;
		aFormat.setHorizontal( aFormat.H_CENTER ) ;
		aProp.setCdDrawTextFormat( aFormat ) ;
		pdcdPage = OuNew<CDcdText>( new CDcdText( L"" ,aProp , L"99" ) ) ;
	}

	// --------------------------------
	//	キャプションとページ番号の部品・
	//	グリッドのレイアウトを決める	
	// --------------------------------
	Ou<IfDcdTarget>	pTargetCaption ;
	Ou<IfDcdTarget>	pTargetGrid ;
	Ou<IfDcdTarget>	pTargetPage ;
	{
		CdDcdZoneXy	zoneGrid = aCaDcdTargetZoomDisplay.getZone() ;
		CdDcdSizeXy	aSize ;

		pdcdCaption->getItemSize( &aCaDcdTargetZoomDisplay , &aSize ) ;
		CdDcdZoneXy zoneCaption( zoneGrid.getX() , 
			CdDcdZone( zoneGrid.getY().getPos() , aSize.getY() ) ) ;
		zoneGrid.setY( CdDcdZone().setBeginEndPos( 
			zoneCaption.getY().getEndPos() , zoneGrid.getY().getEndPos() ) ) ;
		//zoneCaption = 全領域の上部を、キャプション用に割り当てています。
		//zoneGrid = 全領域から、上部のキャプション領域を除いた領域です。

		pdcdPage->getItemSize( &aCaDcdTargetZoomDisplay , &aSize ) ;
		CdDcdZoneXy zonePage( zoneGrid.getX() , 
			CdDcdZone( zoneGrid.getY().getEndPos() - aSize.getY() , aSize.getY() ) ) ;
		zoneGrid.setY( CdDcdZone().setBeginEndPos( 
			zoneCaption.getY().getEndPos() , zonePage.getY().getPos() ) ) ;
		//zonePage = 全領域の下部を、ページ用に割り当てています。
		//zoneGrid = 上部のキャプションに続いて、下部のページ領域も除いた領域です。


		pTargetCaption = OuNew<CaDcdTargetItemPosition>( 
			new CaDcdTargetItemPosition( &aCaDcdTargetZoomDisplay , zoneCaption ) ) ;
		pTargetGrid = OuNew<CaDcdTargetItemPosition>( 
			new CaDcdTargetItemPosition( &aCaDcdTargetZoomDisplay , zoneGrid ) ) ;
		pTargetPage = OuNew<CaDcdTargetItemPosition>(
			new CaDcdTargetItemPosition( &aCaDcdTargetZoomDisplay , zonePage ) ) ;
	}
	// --------------------------------
	//	グリッドを描画
	// --------------------------------
	int iPage = 0 ;
	{
		CDcdGrid*	pCDcdGrid = m_pCWndDcdGrid->getCXDcdGrid() ;
		CaDcdGrid_PageSelector	aCaDcdGrid_PageSelector( pCDcdGrid , pTargetGrid ) ;
		aCaDcdGrid_PageSelector.setPage( pInfo->m_nCurPage - 1 ) ;
		aCaDcdGrid_PageSelector.DcDraw() ;

		if ( (int)pInfo->m_nCurPage >= aCaDcdGrid_PageSelector.getPageCount() ){
			//最終ページを印刷したら、印刷ループを終わります。
			//OnPrint() で 
			//pInfo->SetMaxPage( aCaDcdGrid_PageSelector.getPageCount() ) ;
			//	をしても効果はありません。

			pInfo->m_bContinuePrinting = false ;
		}	else	{
			pInfo->m_bContinuePrinting = true ;
		}
		
		iPage = aCaDcdGrid_PageSelector.getPage() ;
	}
	// --------------------------------
	//	キャプションとページ番号のテキストを作成
	// --------------------------------
	{
		//ページ番号を決定
		{
			wstring	strPage = wstringOf( iPage + 1) ;
			pdcdPage->setText( strPage ) ;
		}
	}
	// --------------------------------
	//	キャプションとページ番号を描画
	// --------------------------------
	{
			pdcdCaption->DcDraw( pTargetCaption ) ;
			pdcdPage->DcDraw( pTargetPage ) ;
	}
}