Skip to content

Commit f54ed2c

Browse files
committed
印刷での指定桁縦線の適用
1 parent d884ae4 commit f54ed2c

File tree

3 files changed

+76
-20
lines changed

3 files changed

+76
-20
lines changed

sakura_core/print/CPrintPreview.cpp

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@
4949
#include "env/CSakuraEnvironment.h"
5050
// CColorStrategyは本来はCEditViewが必要だが、CEditWnd.hあたりでinclude済み
5151
#include "view/colors/CColorStrategy.h"
52+
#include "view/CTextDrawer.h"
5253
#include "sakura_rc.h"
5354

5455
using namespace std;
@@ -1573,6 +1574,39 @@ CColorStrategy* CPrintPreview::DrawPageText(
15731574
nDirectY * ( nOffY + nLineHeight * i )
15741575
);
15751576
}
1577+
1578+
// 指定桁縦線。段ごとに一度に引く
1579+
const STypeConfig& type = m_typePrint;
1580+
const ColorInfo& vline_cinfo = type.m_ColorInfoArr[COLORIDX_VERTLINE];
1581+
const SColorAttr& vline_color = vline_cinfo.m_sColorAttr;
1582+
const SFontAttr& vline_attr = vline_cinfo.m_sFontAttr;
1583+
if(vline_cinfo.m_bDisp){
1584+
COLORREF pen_color = RGB(0,0,0);
1585+
if(m_pPrintSetting->m_bColorPrint){
1586+
pen_color = vline_color.m_cTEXT;
1587+
}
1588+
HPEN hpNew = ::CreatePen(PS_SOLID, vline_attr.m_bBoldFont ? 2 : 1, pen_color);
1589+
HPEN hpOld = (HPEN)::SelectObject(hdc, hpNew);
1590+
CTextDrawer::DispVerticalLinesImpl(
1591+
hdc, type.m_nVertLineIdx, MAX_VERTLINES,
1592+
false, // BoldはPen幅で対応
1593+
vline_attr.m_bUnderLine,
1594+
0, // nViewLeftCol 横スクロースしないので0固定
1595+
m_pPrintSetting->m_nPrintFontWidth * type.m_nMaxLineKetas, // nWrapLayout
1596+
nBasePosX + m_pPrintSetting->m_nPrintFontWidth * type.m_nMaxLineKetas, // nRightCol
1597+
nBasePosX, // nPosXOffset
1598+
nBasePosX, // nPosXLeft
1599+
nBasePosX + m_pPrintSetting->m_nPrintFontWidth * type.m_nMaxLineKetas, // nPosXRight
1600+
nDirectY * nOffY, // nTop,
1601+
nDirectY * ( nOffY + nLineHeight * i ), // nBottom
1602+
nDirectY,
1603+
false, // bOddLine
1604+
m_pPrintSetting->m_nPrintFontWidth, // nLayoutXDefault
1605+
1 // nCharPx(プロポーショナル版では1固定)
1606+
);
1607+
::SelectObject(hdc, hpOld);
1608+
::DeleteObject(hpNew);
1609+
}
15761610
}
15771611
return pStrategy;
15781612
}

sakura_core/view/CTextDrawer.cpp

Lines changed: 36 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -207,18 +207,37 @@ void CTextDrawer::DispVerticalLines(
207207
gr.SetPen( cVertType.GetTextColor() );
208208
}
209209

210+
// 1半角文字に対応するレイアウト座標数(プロポーショナル版ではルーラー文字幅px)
211+
int nXDefault = (Int)pView->GetTextMetrics().GetLayoutXDefault();
212+
// レイアウト座標数に対応するpx数(プロポーショナル版では絶えず1)
213+
int px = pView->GetTextMetrics().GetCharPxWidth();
214+
215+
DispVerticalLinesImpl(gr, typeData.m_nVertLineIdx, MAX_VERTLINES, bBold, bDot,
216+
(Int)nViewLeftCol, (Int)nWrapLayout, (Int)nRightCol, nPosXOffset, nPosXLeft, nPosXRight, nTop, nBottom, 1, bOddLine,
217+
nXDefault, px);
218+
219+
if( bExorPen ){
220+
::SetROP2( gr, nROP_Old );
221+
}
222+
}
223+
224+
void CTextDrawer::DispVerticalLinesImpl(HDC hdc, const int *nArrVertLineIdx, int nArrVertLineSize,
225+
bool bBold,bool bDot, int nViewLeftCol, int nWrapLayout, int nRightCol,
226+
int nPosXOffset, int nPosXLeft, int nPosXRight, int nTop, int nBottom, int nDirectY, bool bOddLine,
227+
int nLayoutXDefault, int nCharPx)
228+
{
210229
int k;
211-
for( k = 0; k < MAX_VERTLINES && typeData.m_nVertLineIdx[k] != 0; k++ ){
230+
for( k = 0; k < nArrVertLineSize && nArrVertLineIdx[k] != 0; k++ ){
212231
// nXColは1開始。GetTextArea().GetViewLeftCol()は0開始なので注意。
213-
CLayoutXInt nXCol = pView->GetTextMetrics().GetLayoutXDefault(typeData.m_nVertLineIdx[k]);
214-
CLayoutXInt nXColEnd = nXCol;
215-
CLayoutXInt nXColAdd = pView->GetTextMetrics().GetLayoutXDefault();
232+
int nXCol = nLayoutXDefault * nArrVertLineIdx[k];
233+
int nXColEnd = nXCol;
234+
int nXColAdd = nLayoutXDefault;
216235
// nXColがマイナスだと繰り返し。k+1を終了値、k+2をステップ幅として利用する
217236
if( nXCol < 0 ){
218-
if( k < MAX_VERTLINES - 2 ){
237+
if( k < nArrVertLineSize - 2 ){
219238
nXCol = -nXCol;
220-
nXColEnd = pView->GetTextMetrics().GetLayoutXDefault(typeData.m_nVertLineIdx[++k]);
221-
nXColAdd = pView->GetTextMetrics().GetLayoutXDefault(typeData.m_nVertLineIdx[++k]);
239+
nXColEnd = nLayoutXDefault * nArrVertLineIdx[++k];
240+
nXColAdd = nLayoutXDefault * nArrVertLineIdx[++k];
222241
if( nXColEnd < nXCol || nXColAdd <= 0 ){
223242
continue;
224243
}
@@ -235,7 +254,7 @@ void CTextDrawer::DispVerticalLines(
235254
if( nWrapLayout < nXCol ){
236255
break;
237256
}
238-
int nPosX = nPosXOffset + pView->GetTextMetrics().GetCharPxWidth(nXCol - pView->GetTextMetrics().GetLayoutXDefault() - nViewLeftCol);
257+
int nPosX = nPosXOffset + nCharPx * (nXCol - nLayoutXDefault - nViewLeftCol);
239258
// 2006.04.30 Moca 線の引く範囲・方法を変更
240259
// 太線の場合、半分だけ作画する可能性がある。
241260
int nPosXBold = nPosX;
@@ -253,32 +272,29 @@ void CTextDrawer::DispVerticalLines(
253272
if( bOddLine ){
254273
y++;
255274
}
256-
for( ; y < nBottom; y += 2 ){
275+
for( ; y < nBottom; y += nDirectY * 2 ){
257276
if( nPosX < nPosXRight ){
258-
::MoveToEx( gr, nPosX, y, NULL );
259-
::LineTo( gr, nPosX, y + 1 );
277+
::MoveToEx( hdc, nPosX, y, NULL );
278+
::LineTo( hdc, nPosX, y + nDirectY );
260279
}
261280
if( bBold && nPosXLeft <= nPosXBold ){
262-
::MoveToEx( gr, nPosXBold, y, NULL );
263-
::LineTo( gr, nPosXBold, y + 1 );
281+
::MoveToEx( hdc, nPosXBold, y, NULL );
282+
::LineTo( hdc, nPosXBold, y + nDirectY );
264283
}
265284
}
266285
}else{
267286
if( nPosX < nPosXRight ){
268-
::MoveToEx( gr, nPosX, nTop, NULL );
269-
::LineTo( gr, nPosX, nBottom );
287+
::MoveToEx( hdc, nPosX, nTop, NULL );
288+
::LineTo( hdc, nPosX, nBottom );
270289
}
271290
if( bBold && nPosXLeft <= nPosXBold ){
272-
::MoveToEx( gr, nPosXBold, nTop, NULL );
273-
::LineTo( gr, nPosXBold, nBottom );
291+
::MoveToEx( hdc, nPosXBold, nTop, NULL );
292+
::LineTo( hdc, nPosXBold, nBottom );
274293
}
275294
}
276295
}
277296
}
278297
}
279-
if( bExorPen ){
280-
::SetROP2( gr, nROP_Old );
281-
}
282298
}
283299

284300
void CTextDrawer::DispNoteLine(

sakura_core/view/CTextDrawer.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,12 @@ class CTextDrawer{
6262
//! 指定桁縦線描画関数 // 2005.11.08 Moca
6363
void DispVerticalLines( CGraphics& gr, int nTop, int nBottom, CLayoutInt nLeftCol, CLayoutInt nRightCol ) const;
6464

65+
static void DispVerticalLinesImpl(HDC hdc, const int *nArrVertLineIdx, int nArrVertLineSize,
66+
bool bBold, bool bDot, int nViewLeftCol, int nWrapLayout, int nRightCol,
67+
int nPosXOffset, int nPosXLeft, int nPosXRight, int nTop, int nBottom, int nDirectY, bool bOddLine,
68+
int nLayoutXDefault, int nCharPx);
69+
70+
6571
// -- -- 折り返し桁縦線描画 -- -- //
6672
void DispWrapLine( CGraphics& gr, int nTop, int nBottom ) const;
6773

0 commit comments

Comments
 (0)