Exemple #1
0
// ********************************
//	IfDcDraw
// ********************************
bool CDcdFillrect::DcDraw( IfDcdTarget* pIfDcdTarget ) 
{
	int		iRv = 0 ;
	bool	bRv = false ;
	
	// --------------------------------
	//	ブラシの生成
	// --------------------------------
	Ou<CGdiHBrushHolder>	pCGdiHBrushHolder ;
	if ( iRv >= 0 ){
		pCGdiHBrushHolder = pIfDcdTarget->createGdiHBrushHolder( m_CdBrushProp ) ;
		if ( pCGdiHBrushHolder == NULL ){
			iRv = -1 ;	//	ペンの作成に失敗しました。
		}
	}
	HBRUSH		hBrushSid = NULL ;
	if ( iRv >= 0 ){
		hBrushSid = (HBRUSH)SelectObject( pIfDcdTarget->getHdc() , pCGdiHBrushHolder->getHBrush() ) ;
	}

	// --------------------------------
	//	描画
	// --------------------------------
	if ( iRv >= 0 ){
		CdDcdZoneXy	aCdDcdZoneXy = pIfDcdTarget->getZone() ;
		RECT	LRect ;
		LRect.left   = aCdDcdZoneXy.getX().getPos() ;
		LRect.top    = aCdDcdZoneXy.getY().getPos() ;
		LRect.right  = aCdDcdZoneXy.getX().getEndPos() ;
		LRect.bottom = aCdDcdZoneXy.getY().getEndPos() ;
		
		FillRect( pIfDcdTarget->getHdc() , &LRect , pCGdiHBrushHolder->getHBrush() ) ;
		
	}
	if ( iRv >= 0 ){
		bRv = true ;
	}
	// --------------------------------
	if ( hBrushSid != NULL )
	{
		SelectObject( pIfDcdTarget->getHdc() , hBrushSid ) ;
		hBrushSid = NULL ;
	}
	return ( bRv ) ;
}
int CconvCdDedDispProp::fromOuPropertiesText( 
			CdDedDispProp* pCdDedDispProp ,
			const OuPropertiesText::IfNodeContainerConst* pCNodeContainer ,
			OuPropertiesText::ErrorInfo::COuErrorInfoContainer* pCOuErrorInfoContainer ) 
{
	int iRv = 0 ;
	
	CdDedDispProp aCdDedDispProp ;	

	// --------------------------------
	//1.JikokuhyouFont
	//	数が足りない場合、指定のない要素は設定をしません。
	for ( int idx = 0 ; iRv >= 0 && idx < CentDedRessyasyubetsu::JIKOKUHYOUFONT_COUNT ; idx ++ )
	{

		Ou< const OuPropertiesText::CNode > pNode = pCNodeContainer->getInName(
			nameJikokuhyouFont , idx ) ;
		Ou< const OuPropertiesText::CPropertyString > pPropertyString = 
			dynamic_castOu< const OuPropertiesText::CPropertyString >( pNode ) ;

		if ( pPropertyString != NULL )
		{

			wstring	strValue = pPropertyString->getValue() ;
			CdFontProp	aCdFontProp ;
			int iResult = CdFontProp_from_string( &aCdFontProp , strValue ) ;
			if ( iResult < 0 ){
				COuErrorInfo aCOuErrorInfo( ERRREASON_InvalidValue() ) ;
				aCOuErrorInfo.getProp()->setValue( ERRPROP_Name() , nameJikokuhyouFont ) ; 
				aCOuErrorInfo.getProp()->setValue( ERRPROP_Value() , strValue ) ; 
				iRv = -12 ;	//	JikokuhyouFont の内容が不正です。
			}	else	{
				aCdDedDispProp.setJikokuhyouFont( idx , aCdFontProp ) ;
			}		
		}
	}

	//JikokuhyouVFont
	{
		wstring	strValue = pCNodeContainer->getValue(	nameJikokuhyouVFont ) ; 
		if ( strValue.length() > 0 )
		{
			CdFontProp	aCdFontProp ;
			int iResult = CdFontProp_from_string( &aCdFontProp , strValue ) ;
			if ( iResult < 0 ){
				COuErrorInfo aCOuErrorInfo( ERRREASON_InvalidValue() ) ;
				aCOuErrorInfo.getProp()->setValue( ERRPROP_Name() , nameJikokuhyouVFont ) ; 
				aCOuErrorInfo.getProp()->setValue( ERRPROP_Value() , strValue ) ; 
				iRv = -13 ;	//	JikokuhyouVFont の内容が不正です。
			}	else	{
				aCdDedDispProp.setJikokuhyouVFont( aCdFontProp ) ;
			}
		}
	}
	//2.DiaEkimeiFont
	if ( iRv >= 0 ){
		wstring	strValue = pCNodeContainer->getValue( nameDiaEkimeiFont ) ;
		CdFontProp	aCdFontProp ;
		int iResult = CdFontProp_from_string( &aCdFontProp , strValue ) ;
		if ( iResult < 0 ){
			COuErrorInfo aCOuErrorInfo( ERRREASON_InvalidValue() ) ;
			aCOuErrorInfo.getProp()->setValue( ERRPROP_Name() , nameDiaEkimeiFont ) ; 
			aCOuErrorInfo.getProp()->setValue( ERRPROP_Value() , strValue ) ; 
			iRv = -22 ;	//	DiaEkimeiFont の内容が不正です。
		}	else	{
			aCdDedDispProp.setDiaEkimeiFont( aCdFontProp ) ;
		}		
	}
	//3.DiaJikokuFont
	if ( iRv >= 0 ){
		wstring	strValue = pCNodeContainer->getValue( nameDiaJikokuFont ) ;
		CdFontProp	aCdFontProp ;
		int iResult = CdFontProp_from_string( &aCdFontProp , strValue ) ;
		if ( iResult < 0 ){
			COuErrorInfo aCOuErrorInfo( ERRREASON_InvalidValue() ) ;
			aCOuErrorInfo.getProp()->setValue( ERRPROP_Name() , nameDiaJikokuFont ) ; 
			aCOuErrorInfo.getProp()->setValue( ERRPROP_Value() , strValue ) ; 
			iRv = -32 ;	//	DiaJikokuFont の内容が不正です。
		}	else	{
			aCdDedDispProp.setDiaJikokuFont( aCdFontProp ) ;
		}		
	}
	//4.DiaRessyaFont
	if ( iRv >= 0 ){
		wstring	strValue = pCNodeContainer->getValue( nameDiaRessyaFont ) ;
		
		//	この属性は、あとから追加したため、空の場合でもエラーにはしません
		if ( !strValue.empty() ){
			CdFontProp	aCdFontProp ;
			int iResult = CdFontProp_from_string( &aCdFontProp , strValue ) ;
			if ( iResult < 0 ){
				COuErrorInfo aCOuErrorInfo( ERRREASON_InvalidValue() ) ;
				aCOuErrorInfo.getProp()->setValue( ERRPROP_Name() , nameDiaRessyaFont ) ; 
				aCOuErrorInfo.getProp()->setValue( ERRPROP_Value() , strValue ) ; 
				iRv = -32 ;	//	DiaRessyaFont の内容が不正です。
			}	else	{
				aCdDedDispProp.setDiaRessyaFont( aCdFontProp ) ;
			}
		}
	}
	//5.CommentFont
	if ( iRv >= 0 ){
		wstring	strValue = pCNodeContainer->getValue( nameCommentFont ) ;
		CdFontProp	aCdFontProp ;
		int iResult = CdFontProp_from_string( &aCdFontProp , strValue ) ;
		if ( iResult < 0 ){
				COuErrorInfo aCOuErrorInfo( ERRREASON_InvalidValue() ) ;
				aCOuErrorInfo.getProp()->setValue( ERRPROP_Name() , nameCommentFont ) ; 
				aCOuErrorInfo.getProp()->setValue( ERRPROP_Value() , strValue ) ; 
			iRv = -32 ;	//	CommentFont の内容が不正です。
		}	else	{
			aCdDedDispProp.setViewCommentFont( aCdFontProp ) ;
		}		
	}
	//6.DiaMojiColor
	if ( iRv >= 0 )
	{
		wstring	strValue = pCNodeContainer->getValue( nameDiaMojiColor ) ;
		aCdDedDispProp.setDiaMojiColor( 
			CdColorProp_from_string( strValue ) ) ;
	}
	//7.DiaHaikeiColor
	if ( iRv >= 0 )
	{
		wstring	strValue = pCNodeContainer->getValue( nameDiaHaikeiColor ) ;
		aCdDedDispProp.setDiaHaikeiColor( 
			CdColorProp_from_string( strValue ) ) ;
	}
	//8.DiaRessyaColor
	if ( iRv >= 0 )
	{
		wstring	strValue = pCNodeContainer->getValue( nameDiaRessyaColor ) ;
		aCdDedDispProp.setDiaRessyaColor( 
			CdColorProp_from_string( strValue ) ) ;
	}
	//9.DiaJikuColor
	if ( iRv >= 0 )
	{
		wstring	strValue = pCNodeContainer->getValue( nameDiaJikuColor ) ;
		aCdDedDispProp.setDiaJikuColor( 
			CdColorProp_from_string( strValue ) ) ;
	}
	//10.EkimeiLength
	if ( iRv >= 0 ){
		wstring	strValue = pCNodeContainer->getValue( nameEkimeiLength ) ;
		if ( !strValue.empty() ){
			int iValue = intOf( strValue ) ;
			if ( iValue > 0 ){
				aCdDedDispProp.setEkimeiLength( iValue ) ;
			}
		}	
	}
	//11.EkimeiLength
	if ( iRv >= 0 )
	{
		wstring	strValue = pCNodeContainer->getValue( nameJikokuhyouRessyaWidth ) ;
		if ( !strValue.empty() )
		{
			int iValue = intOf( strValue ) ;
			if ( iValue > 0 )
			{
				aCdDedDispProp.setJikokuhyouRessyaWidth( iValue ) ;
			}
		}	
	}
	// --------------------------------
	if ( iRv >= 0 ){
		*pCdDedDispProp = aCdDedDispProp ;	
	}

	return ( iRv ) ;
}
Exemple #3
0
// ********************************
//	IfDcDraw
// ********************************
bool CDcdRectangle::DcDraw( IfDcdTarget* pIfDcdTarget ) 
{
	int		iRv = 0 ;
	bool	bRv = false ;
	

	// --------------------------------
	//	ペン・ブラシの生成
	// --------------------------------
	Ou<CGdiHPenHolder>	pHPenHolder  ;
	if ( iRv >= 0 ){
		pHPenHolder = pIfDcdTarget->createGdiHPenHolder( m_CdPenProp ) ;
		if ( pHPenHolder == NULL ){
			iRv = -1 ;	//	ペンの作成に失敗しました。
		}
	}
	Ou<CGdiHBrushHolder>	pHBrushHolder ;
	if ( iRv >= 0 ){
		pHBrushHolder = pIfDcdTarget->createGdiHBrushHolder( m_CdBrushProp ) ;
		if ( pHBrushHolder == NULL ){
			iRv = -2 ;	//	ブラシの作成に失敗しました。
		}
	}
	HBRUSH		hBrushSid = NULL ;
	if ( iRv >= 0 ){
		hBrushSid = (HBRUSH)SelectObject( pIfDcdTarget->getHdc() , pHBrushHolder->getHBrush() ) ;
	}
	HPEN		hPenSid = NULL ;
	if ( iRv >= 0 ){
		hPenSid = (HPEN)SelectObject( pIfDcdTarget->getHdc() , pHPenHolder->getHPen() ) ;
	}
	int iBkModeSid = -1 ;
	if ( iRv >= 0 ){
		 iBkModeSid = SetBkMode( pIfDcdTarget->getHdc() , TRANSPARENT ) ;
	}
	// --------------------------------
	//	描画
	// --------------------------------
	if ( iRv >= 0 ){
		CdDcdZoneXy	aCdDcdZoneXy = pIfDcdTarget->getZone() ;
		RECT	LRect ;
		LRect.left   = aCdDcdZoneXy.getX().getPos() + 
					m_CdPenProp.getLogicalunitWidth() / 2 ;
		LRect.top    = aCdDcdZoneXy.getY().getPos() +
					m_CdPenProp.getLogicalunitWidth() / 2 ;
		LRect.right  = aCdDcdZoneXy.getX().getEndPos() -
					m_CdPenProp.getLogicalunitWidth() / 2 ;
		LRect.bottom = aCdDcdZoneXy.getY().getEndPos() -
					m_CdPenProp.getLogicalunitWidth() / 2 ;
		
		Rectangle( pIfDcdTarget->getHdc() , 
			LRect.left , LRect.top , LRect.right , LRect.bottom ) ;
		
	}
	if ( iRv >= 0 ){
		bRv = true ;
	}
	// --------------------------------
	if ( iBkModeSid != -1 ) {
		SetBkMode( pIfDcdTarget->getHdc() , iBkModeSid ) ;
	}
	if ( hBrushSid != NULL ){
		SelectObject( pIfDcdTarget->getHdc() , hBrushSid ) ;
		hBrushSid = NULL ;
	}
	if ( hPenSid != NULL ){
		SelectObject( pIfDcdTarget->getHdc() , hPenSid ) ;
		hPenSid = NULL ;
	}
	return ( bRv ) ;
}
Exemple #4
0
// ********************************
///@name	IfDcDraw
// ********************************
bool CDcdFreeLine::DcDraw( IfDcdTarget* pIfDcdTarget ) 
{
	bool	bRv = 0 ;
	CConverter_WinGdi	aConverter ;

	// --------------------------------
	//	m_iLogicalunitWidth が
	//	0 なら、何も描画しません。
	// --------------------------------
	if ( m_CdLineProp.getLogicalunitWidth() <= 0 ){
		return ( false ) ;
	}


	
	// --------------------------------
	//	描画のための論理ペンを生成
	//	(サイズは、物理座標とします)
	// --------------------------------
	Ou<CGdiHPenHolder>	pHPenHolder ;
	int iDeviceunitPenWidth = 
			CDcDeviceUnitSizeX( pIfDcdTarget->getHdc() ).
			setLogicalUnitSize( m_CdLineProp.getLogicalunitWidth() ).
			getDeviceUnitSize() ;
	if ( iDeviceunitPenWidth <= 0 ){
		iDeviceunitPenWidth = 1 ;
	}
	{
		CdPenProp	aCdPenProp ;
		aCdPenProp.setLogicalunitWidth( iDeviceunitPenWidth ) ;
			
		aCdPenProp.setColor( m_CdLineProp.getColor() ) ;
		aCdPenProp.setStyle( CdPenProp::SOLID ) ;
		pHPenHolder = pIfDcdTarget->createGdiHPenHolder( aCdPenProp ) ;
	}
	//iDeviceunitPenWidth  = デバイス座標系での
	//	ペンの太さ


	// --------------------------------
	CdDcdPosXy	posOrg = m_posOrg ;
	CdDcdPosXy	posDst = m_posDst ;
	//posOrg,posDst = 起点と終点の座標(論理座標)

	// --------------------------------
	//	DcdTargetの範囲に、起点と終点を補正
	// --------------------------------
	if ( m_bAdjustForDcdTarget ){
		//X方向をDcdTargetの範囲に収める
		{
			CdDcdZone	zoneX( posOrg.getX() , posDst.getX() - posOrg.getX() );
			CdDcdZone	zoneXTarget = pIfDcdTarget->getZone().getX() ;
			CdDcdZone	zoneXCrossed = zoneX.CrossZone( zoneXTarget ) ;
			//X座標を、デバイス領域内に正規化しました。
			if ( zoneXCrossed.getSize() != 0 ){
				CLineFunc	aCLineFunc( m_posOrg , m_posDst ) ;
				
				//	zoneXCrossed が描画領域にあり、
				//	しかも斜線である場合は、
				//	起点・終点それぞれにおいて、
				//	デバイス領域内に正規化した
				//	X座標からY座標を求めます。
				//
				//	(zoneXCrossed.Sizeが0の場合(垂線の場合)は、
				//	対応する特定のY座標を求めることができませんので、
				//	calcLineYofX() を呼び出してはいけません)
				if ( zoneX.getPos() != zoneXCrossed.getPos() ){
					posOrg.setX( zoneXCrossed.getPos() ) ;
					posOrg.setY( aCLineFunc.calcYofX( 
						zoneXCrossed.getPos() ) );
				}
				if ( zoneX.getEndPos() != zoneXCrossed.getEndPos() ){
					posDst.setX( zoneXCrossed.getEndPos() ) ;
					posDst.setY( aCLineFunc.calcYofX( 
						zoneXCrossed.getEndPos() ) ) ;
				}
			}
			if ( zoneXCrossed.getSize() == 0 && 
					!zoneXTarget.IsInner( zoneXCrossed.getPos() ) ){
				//	zoneXCrossed が描画領域外である場合は、
				//	直線の描画はできませんので、偽でリターンします。
				return ( false ) ;
			}
	
		}
		//Y方向をDcdTargetの範囲に収める
		{
			CdDcdZone	zoneY( posOrg.getY() , posDst.getY() - posOrg.getY() );
			CdDcdZone	zoneYTarget = pIfDcdTarget->getZone().getY() ;
			CdDcdZone	zoneYCrossed = zoneY.CrossZone( zoneYTarget ) ;
			//Y座標を、デバイス領域内に正規化しました。
			if ( zoneYCrossed.getSize() != 0 ){
				CLineFunc	aCLineFunc( m_posOrg , m_posDst ) ;

				//	zoneYCrossed が描画領域にあり、
				//	しかも斜線である場合は、
				//	起点・終点それぞれにおいて、
				//	デバイス領域内に正規化した
				//	Y座標からX座標を求めます。
				//
				//	(zoneYCrossed.Sizeが0の場合(水平線の場合)は、
				//	対応する特定のX座標を求めることができませんので、
				//	calcLineXofY() を呼び出してはいけません)
				if ( zoneY.getPos() != zoneYCrossed.getPos() ){
					posOrg.setX( aCLineFunc.calcXofY(
						zoneYCrossed.getPos() ) ) ;
					posOrg.setY( zoneYCrossed.getPos() ) ;
				}
				if ( zoneY.getEndPos() != zoneYCrossed.getEndPos() ){
					posDst.setX( aCLineFunc.calcXofY( 
						zoneYCrossed.getEndPos() ) ) ;
					posDst.setY( zoneYCrossed.getEndPos() ) ;
				}
			}
			if ( zoneYCrossed.getSize() == 0 && 
					!zoneYTarget.IsInner( zoneYCrossed.getPos() ) ){
				//	zoneYCrossed が描画領域外である場合は、
				//	直線の描画はできませんので、偽でリターンします。
				return ( false ) ;
			}
		}
		//posOrg,posDst = 
		//	DcdTargetの範囲に、起点と終点を補正しました。
	}

	// --------------------------------
	//	デバイス座標系での
	//	線の座標を求める
	// --------------------------------
	{
		POINT	aPoint = aConverter.POINTOf( posOrg ) ;
		::LPtoDP( pIfDcdTarget->getHdc() , &aPoint , 1 ) ;
		posOrg = aConverter.CdDcdPosXyOf( aPoint ) ;
	}
	{
		POINT	aPoint = aConverter.POINTOf( posDst ) ;
		::LPtoDP( pIfDcdTarget->getHdc() , &aPoint ,1 ) ;
		posDst = aConverter.CdDcdPosXyOf( aPoint ) ;
	}
	//posOrg,posDst = デバイス座標に変換しました。
	
	// --------------------------------
	//	DCの属性を変更
	// --------------------------------
	int idSave = SaveDC(  pIfDcdTarget->getHdc() ) ;
	int iMapModePrev = SetMapMode(  pIfDcdTarget->getHdc() , MM_TEXT ) ;
	//	SetMapMode() で MM_TEXT モードに移行すると、
	//	論理単位とデバイス単位の比は1:1に変更されますが、
	//	座標の原点値は変更されません。
	//
	//	LPtoDP() で変換されたデバイス座標は、デバイスコンテキストの
	//	左上隅を原点とした座標を返します。
	//	この座標を使って描画を行うためには、デバイスコンテキストの
	//	論理座標の原点も、デバイス座標 0,0 (左上隅)に設定しなくては
	//	なりません。
	//※  原点の設定は、マッピングモードが MM_TEXT であっても可能です。
	//	ここが、SetViewportExtEx() , SetWindowExtEx() との違いです。
	SetViewportOrgEx( pIfDcdTarget->getHdc() , 0 , 0 , NULL ) ;

	HPEN	hPenSid = (HPEN)SelectObject( pIfDcdTarget->getHdc() , pHPenHolder->getHPen() ) ;

	// --------------------------------
	//	線の描画
	// --------------------------------
	int iLongWidth = 0 ;
	bool	bYIsLong = false ;
	{
		int iXWidth = abs( posDst.getX() - posOrg.getX() ) ;	
		int iYWidth = abs( posDst.getY() - posOrg.getY() ) ;	
		//iXWidth, iYWidth = X,Yの両座標の差。
		//	起点・終点が同一座標の場合は0
		if ( iXWidth > iYWidth ){
			iLongWidth = iXWidth ;
			bYIsLong = false ;
		}	else	{
			iLongWidth = iYWidth ;
			bYIsLong = true ;
		}
	}
	//iLongWidth = X,Y の座標の差のうち、長いほう
	//iShortWidth = X,Y の座標の差のうち、短いほう
	//	起点・終点が同一座標の場合は0
	//bYIsLong = false iLongWidthがX,iShortWidthがY
	//	true iLongWidthがY,iShortWidthがX

	
	if ( m_CdLineProp.isSolidLineStyle() ){
		// ********************************
		//	実線
		// ********************************
		MoveToEx( pIfDcdTarget->getHdc() , posOrg.getX() , posOrg.getY() , 
			NULL ) ;
		LineTo(pIfDcdTarget->getHdc() , posDst.getX() , posDst.getY() ) ;
	}	else	{
		// ********************************
		//	破線
		// ********************************
		wstring	aLINESTYLE = m_CdLineProp.getLinestyle() ;

		int idxStyle = 0 ;
		int iLongCurr ;
		for ( iLongCurr = 0 ; iLongCurr < iLongWidth ; ){
			CLineFunc	aCLineFunc( posOrg , posDst ) ;
			// --------------------------------
			//	破線部分
			// --------------------------------
			{
				int iLongDst = iLongCurr + 
					( aLINESTYLE[idxStyle] - '0' ) * iDeviceunitPenWidth ; 
				iLongDst -=  ( iDeviceunitPenWidth - 1 ) ;
				idxStyle ++ ;
				if ( idxStyle >= (int)aLINESTYLE.size() ){
					iLongDst += ( aLINESTYLE[0] - '0' ) ; 
					idxStyle = 1 ;
				}

				if ( iLongDst > iLongWidth ){
					iLongDst = iLongWidth ;
				}
				//iLongDst = 
				//	今回描画を行う線は、iLongCurr ~ iLongDst の範囲です。

				
				int iXSrc = 0 ;
				int iYSrc = 0 ;
				int iXDst = 0 ;
				int iYDst = 0 ;
				if ( bYIsLong ){
					iYSrc = posOrg.getY() + 
						iLongCurr  * sign( posDst.getY() -  posOrg.getY() ) ;
					iYDst = posOrg.getY() + 
						iLongDst  * sign( posDst.getY() -  posOrg.getY() ) ;
					iXSrc = aCLineFunc.calcXofY( iYSrc ) ;
					iXDst = aCLineFunc.calcXofY( iYDst ) ;
				}	else	{
					iXSrc = posOrg.getX() + 
						iLongCurr * sign( posDst.getX() -  posOrg.getX() ) ;
					iXDst = posOrg.getX() + 
						iLongDst * sign( posDst.getX() -  posOrg.getX() ) ;
					iYSrc = aCLineFunc.calcYofX( iXSrc ) ;
					iYDst = aCLineFunc.calcYofX( iXDst ) ;
				}	
				MoveToEx( pIfDcdTarget->getHdc() , iXSrc , iYSrc , NULL ) ;
				LineTo(pIfDcdTarget->getHdc() , iXDst, iYDst) ;

				iLongCurr = iLongDst ;
			}
			// --------------------------------
			//	空白部分
			// --------------------------------
			{
				int iLongDst = iLongCurr + 
					( aLINESTYLE[idxStyle] - '0' ) * iDeviceunitPenWidth ;
				iLongDst += ( iDeviceunitPenWidth - 1 ) ;
				idxStyle ++ ;
				if ( idxStyle >= (int)aLINESTYLE.size() ){
					idxStyle = 0 ;
				}
				if ( iLongDst > iLongWidth ){
					iLongDst = iLongWidth ;
				}
				iLongCurr = iLongDst ;
			}
		}
		

	}
	// --------------------------------
	//	DCの属性を復帰
	// --------------------------------
	SelectObject( pIfDcdTarget->getHdc() , hPenSid ) ;
	hPenSid = NULL ;
	if ( idSave != 0 ){
		RestoreDC( pIfDcdTarget->getHdc() , idSave ) ;
		idSave = 0 ;
	}


	return ( true ) ;
}
Exemple #5
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 ) ;
	}
}
int CconvCDedRosenFileData::CDedRosenFileData_from_OuPropertiesText( 
			CDedRosenFileData* pCDedRosenFileData ,
			const OuPropertiesText::CNodeContainer* pCNodeContainer ,
			OuPropertiesText::ErrorInfo::COuErrorInfoContainer* pCOuErrorInfoContainer ) 
{
	int iRv = 0 ;

	if ( iRv >= 0 )
	{
		int iResult = isEncodeAbleFormat( pCNodeContainer ) ;
		if ( iResult < 0 )
		{
			COuErrorInfo aCOuErrorInfo( ERRREASON_FileTypeIsInvalid() ) ;
			aCOuErrorInfo.getProp()->setValue( 
				ERRPROP_FileType() , pCNodeContainer->getValue( nameFileType ) ) ;
			pCOuErrorInfoContainer->insert( aCOuErrorInfo ) ;
			iRv = -1 ;	//	FileType が正しくありません。
		}
	}
	if ( iRv >= 0 )
	{
		pCDedRosenFileData->clear() ;
	}
	
	//1.Rosen

	if ( iRv >= 0 )
	{
		Ou<const CDirectory> pCDirectory = dynamic_castOu<const CDirectory>( 
			pCNodeContainer->getInName( nameRosen , 0 ) ) ;
		if ( pCDirectory == NULL )
		{
			COuErrorInfo aCOuErrorInfo( ERRREASON_RosenDirectoryIsNotFound() ) ;
			pCOuErrorInfoContainer->insert( aCOuErrorInfo ) ;
			iRv = -2 ;	//	Rosen Directoryが見つかりません。
		}
		else
		{
			CentDedRosen	aCentDedRosen ;
			CconvCentDed aCconvCentDed ;
			int iResult = aCconvCentDed.CentDedRosen_From_OuPropertiesText( 
				&aCentDedRosen ,
				pCDirectory->getIfNodeContainerConst() ,
				pCOuErrorInfoContainer ) ;
			//-	-11 ;	//	Ekimei が指定されていません。
			//-	-22 ;	//	Ekijikokukeisiki の値が不正です。
			//-	-32 ;	//	Ekikibo の値が不正です。
			//-	-101 ;	//	Eki がディレクトリではありません。
			//-	-111 ;	//	Syubetsumei が指定されていません。
			//-	-152 ;	//	DiagramSenStyle の値が不正です。
			//-	-201 ;	//	Ressyasyubetsu がディレクトリではありません。
			//-	-211 ;	//	DiaName が指定されていません。
			//-	-212 ;	//	RessyaContが見つかりません。
			//-	-352 ;	//	起点時刻の設定が不適切です。
			if ( iResult < 0 )
			{
				//-	-11 ;	//	Ekimei が指定されていません。
				//-	-22 ;	//	Ekijikokukeisiki の値が不正です。
				//-	-32 ;	//	Ekikibo の値が不正です。
				//-	-101 ;	//	Eki がディレクトリではありません。
				//-	-111 ;	//	Syubetsumei が指定されていません。
				//-	-152 ;	//	DiagramSenStyle の値が不正です。
				//-	-201 ;	//	Ressyasyubetsu がディレクトリではありません。
				//-	-211 ;	//	DiaName が指定されていません。
				//-	-212 ;	//	RessyaContが見つかりません。
				//-	-352 ;	//	起点時刻の設定が不適切です。
				iRv = iResult ;
			}
			else
			{
				*pCDedRosenFileData->getCentDedRosen() = aCentDedRosen ;
			}
		}
	}
	//2.DispProp
	if ( iRv >= 0 )
	{
		Ou<const CDirectory> pCDirectory = dynamic_castOu<const CDirectory>( 
			pCNodeContainer->getInName( nameDispProp , 0 ) ) ;
		if ( pCDirectory == NULL )
		{
			COuErrorInfo aCOuErrorInfo( ERRREASON_DispPropnDirectoryIsNotFound() ) ;
			pCOuErrorInfoContainer->insert( aCOuErrorInfo ) ;
			iRv = -3 ;	//	DispProp Directoryが見つかりません。
		}
		else
		{
			CconvCdDedDispProp	aCconvCdDedDispProp ;
			CdDedDispProp	aCdDedDispProp ;
			int iResult = aCconvCdDedDispProp.fromOuPropertiesText( 
				&aCdDedDispProp ,
				pCDirectory->getIfNodeContainerConst() , 
				pCOuErrorInfoContainer ) ;
			//-	-12 ;	//	JikokuhyouFont の内容が不正です。
			//-	-22 ;	//	DiaEkimeiFont の内容が不正です。
			//-	-32 ;	//	DiaJikokuFont の内容が不正です。
			//-	-82 ;	//	DisplayRessyabangou が不正です。
			//-	-92 ;	//	DisplayRessyamei が不正です。
			//-	-102 ;	//	DiaRessyajouhouHyoujiEkiOrderKudari が不正です。
			//-	-112 ;	//	DiaRessyajouhouHyoujiEkiOrderNobori が不正です。
			if ( iResult < 0 )
			{
				//-	-512 ;	//	JikokuhyouFont の内容が不正です。
				//-	-522 ;	//	DiaEkimeiFont の内容が不正です。
				//-	-532 ;	//	DiaJikokuFont の内容が不正です。
				//-	-582 ;	//	DisplayRessyabangou が不正です。
				//-	-592 ;	//	DisplayRessyamei が不正です。
				//-	-602 ;	//	DiaRessyajouhouHyoujiEkiOrderKudari が不正です。
				//-	-612 ;	//	DiaRessyajouhouHyoujiEkiOrderNobori が不正です。
				iRv = -500 ;	//	DispProp の内容が不正
			}
			else
			{
				pCDedRosenFileData->setCdDedDispProp( aCdDedDispProp ) ;
			}
		}
	}

	return ( iRv ) ;
}
int CconvCDedRosenFileData::CDedRosenFileData_to_OuPropertiesText( 
			const CDedRosenFileData* pCDedRosenFileData , 
			OuPropertiesText::CNodeContainer* pCNodeContainer ) 
{
	LogMsg( "CDedRosenFileData_to_CdConnectedString()" ) ;
	int iRv = 0 ;

	//	FileType
	if ( iRv >= 0 )
	{
		pCNodeContainer->setValue( nameFileType , getFileType() ) ;

	}
	//1.Rosen
	if ( iRv >= 0 ){
		Ou<CDirectory> pCDirectory = OuNew<CDirectory>( 
			new CDirectory( nameRosen ) ) ;
		CconvCentDed aConv ;
		int iResult = aConv.CentDedRosen_To_OuPropertiesText( 
			pCDedRosenFileData->getCentDedRosen() ,
			pCDirectory->getCNodeContainer() ) ;
		//	-	-11 ;	//	Ekimei が指定されていません。
		//	-	-22 ;	//	Ekijikokukeisiki の値が不正です。
		//	-	-32 ;	//	Ekikibo の値が不正です。
		//	-	-111 ;	//	Syubetsumei が指定されていません。
		//	-	-152 ;	//	DiagramSenStyle の値が不正です。
		//	-	-212 ;	//	DiagramEkiatsukai の値が不正です。
		if ( iResult < 0 )
		{
			//	-	-11 ;	//	Ekimei が指定されていません。
			//	-	-22 ;	//	Ekijikokukeisiki の値が不正です。
			//	-	-32 ;	//	Ekikibo の値が不正です。
			//	-	-111 ;	//	Syubetsumei が指定されていません。
			//	-	-152 ;	//	DiagramSenStyle の値が不正です。
			//	-	-212 ;	//	DiagramEkiatsukai の値が不正です。
			iRv = iResult ;
		}
		else
		{
			pCNodeContainer->insert( pCDirectory ) ;
		}
	}
	//2.DispProp
	LogMsg( "CDedRosenFileData_to_CdConnectedString()1" ) ;
	if ( iRv >= 0 )
	{
		Ou<CDirectory> pCDirectory = OuNew<CDirectory>( 
			new CDirectory( nameDispProp ) ) ;
		CconvCdDedDispProp	aCconvCdDedDispProp ;
		int iResult = aCconvCdDedDispProp.toOuPropertiesText( 
			pCDedRosenFileData->getCdDedDispProp() ,
			pCDirectory->getCNodeContainer() ) ;
		//	現在は負の数が返されることはありません。
		if ( iResult < 0 )
		{
			assert( false ) ;
		}
		else
		{
			pCNodeContainer->insert( pCDirectory ) ;
		}
	}


	LogMsg( "CDedRosenFileData_to_CdConnectedString()=%d" , iRv ) ;
	return ( iRv ) ;
}