Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[WIP]指定桁縦線の印刷対応 #1412

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 36 additions & 0 deletions sakura_core/print/CPrintPreview.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@
#include "util/shell.h"
#include "env/CSakuraEnvironment.h"
// CColorStrategyは本来はCEditViewが必要だが、CEditWnd.hあたりでinclude済み
#include "view/CTextDrawer.h"
#include "view/colors/CColorStrategy.h"
#include "apiwrap/StdApi.h"
#include "apiwrap/StdControl.h"
Expand Down Expand Up @@ -1467,6 +1468,41 @@ CColorStrategy* CPrintPreview::DrawPageText(
const int nBasePosX = nOffX + nDanWidth * nDan + nLineNumWidth * (nDan + 1);

const int charWidth = m_pPrintSetting->m_nPrintFontWidth;

// 指定桁縦線。段ごとに一度に引く
// 文字より下に描画、先に線を引いておく、背景色は透明に限る
if(m_typePrint.m_ColorInfoArr[COLORIDX_VERTLINE].m_bDisp){
const STypeConfig& type = m_typePrint;
const ColorInfo& vline_cinfo = type.m_ColorInfoArr[COLORIDX_VERTLINE];
const SColorAttr& vline_color = vline_cinfo.m_sColorAttr;
const SFontAttr& vline_attr = vline_cinfo.m_sFontAttr;
COLORREF pen_color = RGB(0,0,0);
if(m_pPrintSetting->m_bColorPrint){
pen_color = vline_color.m_cTEXT;
}
HPEN hpNew = ::CreatePen(PS_SOLID, vline_attr.m_bBoldFont ? 2 : 1, pen_color);
HPEN hpOld = (HPEN)::SelectObject(hdc, hpNew);
CTextDrawer::DispVerticalLinesImpl(
hdc, type.m_nVertLineIdx, MAX_VERTLINES,
false, // BoldはPen幅で対応
vline_attr.m_bUnderLine,
0, // nViewLeftCol 横スクロースしないので0固定
m_pPrintSetting->m_nPrintFontWidth * type.m_nMaxLineKetas, // nWrapLayout
nBasePosX + m_pPrintSetting->m_nPrintFontWidth * type.m_nMaxLineKetas, // nRightCol
nBasePosX, // nPosXOffset
nBasePosX, // nPosXLeft
nBasePosX + m_pPrintSetting->m_nPrintFontWidth * type.m_nMaxLineKetas, // nPosXRight
nDirectY * nOffY, // nTop,
nDirectY * (nOffY + nLineHeight * m_bPreview_EnableLines), // nBottom
nDirectY,
false, // bOddLine
m_pPrintSetting->m_nPrintFontWidth, // nLayoutXDefault
1 // nCharPx(プロポーショナル版では1固定)
);
::SelectObject(hdc, hpOld);
::DeleteObject(hpNew);
}

for( i = 0; i < m_bPreview_EnableLines; ++i ){
if( NULL != pCDlgCancel ){
/* 処理中のユーザー操作を可能にする */
Expand Down
61 changes: 39 additions & 22 deletions sakura_core/view/CTextDrawer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -209,18 +209,37 @@ void CTextDrawer::DispVerticalLines(
gr.SetPen( cVertType.GetTextColor() );
}

// 1半角文字に対応するレイアウト座標数(プロポーショナル版ではルーラー文字幅px)
int nXDefault = (Int)pView->GetTextMetrics().GetLayoutXDefault();
// レイアウト座標数に対応するpx数(プロポーショナル版では絶えず1)
int px = pView->GetTextMetrics().GetCharPxWidth();

DispVerticalLinesImpl(gr, typeData.m_nVertLineIdx, MAX_VERTLINES, bBold, bDot,
(Int)nViewLeftCol, (Int)nWrapLayout, (Int)nRightCol, nPosXOffset, nPosXLeft, nPosXRight, nTop, nBottom, 1, bOddLine,
nXDefault, px);

if( bExorPen ){
::SetROP2( gr, nROP_Old );
}
}

void CTextDrawer::DispVerticalLinesImpl(HDC hdc, const int *nArrVertLineIdx, int nArrVertLineSize,
bool bBold,bool bDot, int nViewLeftCol, int nWrapLayout, int nRightCol,
int nPosXOffset, int nPosXLeft, int nPosXRight, int nTop, int nBottom, int nDirectY, bool bOddLine,
int nLayoutXDefault, int nCharPx)
{
int k;
for( k = 0; k < MAX_VERTLINES && typeData.m_nVertLineIdx[k] != 0; k++ ){
for( k = 0; k < nArrVertLineSize && nArrVertLineIdx[k] != 0; k++ ){
// nXColは1開始。GetTextArea().GetViewLeftCol()は0開始なので注意。
CLayoutXInt nXCol = pView->GetTextMetrics().GetLayoutXDefault(typeData.m_nVertLineIdx[k]);
CLayoutXInt nXColEnd = nXCol;
CLayoutXInt nXColAdd = pView->GetTextMetrics().GetLayoutXDefault();
int nXCol = nLayoutXDefault * nArrVertLineIdx[k];
int nXColEnd = nXCol;
int nXColAdd = nLayoutXDefault;
// nXColがマイナスだと繰り返し。k+1を終了値、k+2をステップ幅として利用する
if( nXCol < 0 ){
if( k < MAX_VERTLINES - 2 ){
if( k < nArrVertLineSize - 2 ){
nXCol = -nXCol;
nXColEnd = pView->GetTextMetrics().GetLayoutXDefault(typeData.m_nVertLineIdx[++k]);
nXColAdd = pView->GetTextMetrics().GetLayoutXDefault(typeData.m_nVertLineIdx[++k]);
nXColEnd = nLayoutXDefault * nArrVertLineIdx[++k];
nXColAdd = nLayoutXDefault * nArrVertLineIdx[++k];
if( nXColEnd < nXCol || nXColAdd <= 0 ){
continue;
}
Expand All @@ -237,7 +256,7 @@ void CTextDrawer::DispVerticalLines(
if( nWrapLayout < nXCol ){
break;
}
int nPosX = nPosXOffset + pView->GetTextMetrics().GetCharPxWidth(nXCol - pView->GetTextMetrics().GetLayoutXDefault() - nViewLeftCol);
int nPosX = nPosXOffset + nCharPx * (nXCol - nLayoutXDefault - nViewLeftCol);
// 2006.04.30 Moca 線の引く範囲・方法を変更
// 太線の場合、半分だけ作画する可能性がある。
int nPosXBold = nPosX;
Expand All @@ -250,37 +269,35 @@ void CTextDrawer::DispVerticalLines(
if( nPosXLeft <= nPosX ){
if( bDot ){
// 点線で作画。1ドットの線を作成
int y = nTop;
int y_org = nDirectY * nTop;
// スクロールしても線が切れないように座標を調整
if( bOddLine ){
y++;
y_org += nDirectY;
}
for( ; y < nBottom; y += 2 ){
for( ; y_org < nDirectY * nBottom; y_org += 2 ){
int y = nDirectY * y_org;
if( nPosX < nPosXRight ){
::MoveToEx( gr, nPosX, y, NULL );
::LineTo( gr, nPosX, y + 1 );
::MoveToEx( hdc, nPosX, y, NULL );
::LineTo( hdc, nPosX, y + nDirectY );
}
if( bBold && nPosXLeft <= nPosXBold ){
::MoveToEx( gr, nPosXBold, y, NULL );
::LineTo( gr, nPosXBold, y + 1 );
::MoveToEx( hdc, nPosXBold, y, NULL );
::LineTo( hdc, nPosXBold, y + nDirectY );
}
}
}else{
if( nPosX < nPosXRight ){
::MoveToEx( gr, nPosX, nTop, NULL );
::LineTo( gr, nPosX, nBottom );
::MoveToEx( hdc, nPosX, nTop, NULL );
::LineTo( hdc, nPosX, nBottom );
}
if( bBold && nPosXLeft <= nPosXBold ){
::MoveToEx( gr, nPosXBold, nTop, NULL );
::LineTo( gr, nPosXBold, nBottom );
::MoveToEx( hdc, nPosXBold, nTop, NULL );
::LineTo( hdc, nPosXBold, nBottom );
}
}
}
}
}
if( bExorPen ){
::SetROP2( gr, nROP_Old );
}
}

void CTextDrawer::DispNoteLine(
Expand Down
6 changes: 6 additions & 0 deletions sakura_core/view/CTextDrawer.h
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,12 @@ class CTextDrawer{
//! 指定桁縦線描画関数 // 2005.11.08 Moca
void DispVerticalLines( CGraphics& gr, int nTop, int nBottom, CLayoutInt nLeftCol, CLayoutInt nRightCol ) const;

static void DispVerticalLinesImpl(HDC hdc, const int *nArrVertLineIdx, int nArrVertLineSize,
bool bBold, bool bDot, int nViewLeftCol, int nWrapLayout, int nRightCol,
int nPosXOffset, int nPosXLeft, int nPosXRight, int nTop, int nBottom, int nDirectY, bool bOddLine,
int nLayoutXDefault, int nCharPx);


// -- -- 折り返し桁縦線描画 -- -- //
void DispWrapLine( CGraphics& gr, int nTop, int nBottom ) const;

Expand Down