Skip to content

Commit

Permalink
Change refactaring
Browse files Browse the repository at this point in the history
  • Loading branch information
niki committed Apr 16, 2024
1 parent 570e1a1 commit 8cbd6c3
Showing 1 changed file with 116 additions and 106 deletions.
222 changes: 116 additions & 106 deletions sakura_core/view/figures/CFigure_Eol.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -312,125 +312,135 @@ void _DrawEOL(
//2007.08.30 kobake 追加
void _DispEOL(CGraphics& gr, DispPos* pDispPos, CEol cEol, const CEditView* pcView, bool bTrans)
{
if( CTypeSupport(pcView,COLORIDX_EOL).IsDisp() ){
CTypeSupport cTextType(pcView,COLORIDX_TEXT);
COLORREF crText = cTextType.GetTextColor();
COLORREF crBack = cTextType.GetBackColor();
//! 色をマージする
//! @param colText テキスト色
//! @param colBase ベースとなる色
//! @return 合成後の色
auto fnMeargeColor = [](COLORREF colText, COLORREF colBase, int blendPer)
{
COLORREF c1 = colText;
COLORREF c2 = colBase;
float blendPerN = 1.0f / 100.0f * blendPer;
const float r1 = (float)GetRValue(c1);
const float g1 = (float)GetGValue(c1);
const float b1 = (float)GetBValue(c1);
const float r2 = (float)GetRValue(c2);
const float g2 = (float)GetGValue(c2);
const float b2 = (float)GetBValue(c2);
float r = r2 + (r1 - r2) * blendPerN;
float g = g2 + (g1 - g2) * blendPerN;
float b = b2 + (b1 - b2) * blendPerN;
return RGB( (BYTE)r, (BYTE)g, (BYTE)b );
};
if (!CTypeSupport(pcView,COLORIDX_EOL).IsDisp())
return;

CTypeSupport cTextType(pcView,COLORIDX_TEXT);
COLORREF crText = cTextType.GetTextColor();
COLORREF crBack = cTextType.GetBackColor();
//! 色をマージする
//! @param colText テキスト色
//! @param colBase ベースとなる色
//! @return 合成後の色
auto fnMeargeColor = [](COLORREF colText, COLORREF colBase, int blendPer)
{
COLORREF c1 = colText;
COLORREF c2 = colBase;
float blendPerN = 1.0f / 100.0f * blendPer;
const float r1 = (float)GetRValue(c1);
const float g1 = (float)GetGValue(c1);
const float b1 = (float)GetBValue(c1);
const float r2 = (float)GetRValue(c2);
const float g2 = (float)GetGValue(c2);
const float b2 = (float)GetBValue(c2);
float r = r2 + (r1 - r2) * blendPerN;
float g = g2 + (g1 - g2) * blendPerN;
float b = b2 + (b1 - b2) * blendPerN;
return RGB( (BYTE)r, (BYTE)g, (BYTE)b );
};

static int nBlendPer = RegKey(NKMM_REGKEY).get(_T("WhiteSpaceBlendPer"), NKMM_WS_BLEND_PER);
// 現在のテキスト色と現在の背景色をブレンドする (空白TABのカラー設定は無視されます)
COLORREF col1 = cTextType.GetTextColor();
COLORREF col2 = crBack; // 合成済みの色を使用する
crText = fnMeargeColor(col1, col2, nBlendPer);

RECT rcClip2;
int fontNo = WCODE::GetFontNo('E');
int nHeightMargin = pcView->GetTextMetrics().GetCharHeightMarginByFontNo(fontNo);
CLayoutXInt width = CLayoutXInt(pcView->GetTextMetrics().CalcTextWidth3(L"", 1));
int nDx[1] = {(Int)width};
if(pcView->GetTextArea().GenerateClipRect(&rcClip2, *pDispPos, width)) {
switch( cEol.GetType() ){
case EOL_CRLF: // 下左矢印
{
static const wchar_t szEol[] = L"";
::ExtTextOutW_AnyBuild(
gr,
pDispPos->GetDrawPos().x - 2,
static int nBlendPer = RegKey(NKMM_REGKEY).get(_T("WhiteSpaceBlendPer"), NKMM_WS_BLEND_PER);
// 現在のテキスト色と現在の背景色をブレンドする (空白TABのカラー設定は無視されます)
COLORREF col1 = cTextType.GetTextColor();
COLORREF col2 = crBack; // 合成済みの色を使用する
crText = fnMeargeColor(col1, col2, nBlendPer);

RECT rcClip2;
int fontNo = WCODE::GetFontNo('E');
int nHeightMargin = pcView->GetTextMetrics().GetCharHeightMarginByFontNo(fontNo);
CLayoutXInt width = CLayoutXInt(pcView->GetTextMetrics().CalcTextWidth3(L"", 1));
int nDx[1] = {(Int)width};

if (!pcView->GetTextArea().GenerateClipRect(&rcClip2, *pDispPos, width))
return;

gr.PushTextForeColor(crText);

switch( cEol.GetType() ){
case EOL_CRLF: // 下左矢印
{
static const wchar_t szEol[] = L"";

::ExtTextOutW_AnyBuild(
gr,
pDispPos->GetDrawPos().x,
#ifdef NKMM_LINE_MARGIN_TOP
pcView->GetLineMargin() +
pcView->GetLineMargin() +
#endif // NKMM_
pDispPos->GetDrawPos().y + nHeightMargin,
ExtTextOutOption() & ~(bTrans? ETO_OPAQUE: 0),
&rcClip2,
szEol,
wcslen(szEol),
nDx
);
break;
}
case EOL_CR: // 左向き矢印
{
static const wchar_t szEol[] = L"";
pDispPos->GetDrawPos().y + nHeightMargin,
ExtTextOutOption() & ~(bTrans? ETO_OPAQUE: 0),
&rcClip2,
szEol,
wcslen(szEol),
nDx
);
break;
}
case EOL_CR: // 左向き矢印
{
static const wchar_t szEol[] = L"";

::ExtTextOutW_AnyBuild(
gr,
pDispPos->GetDrawPos().x - 2,
::ExtTextOutW_AnyBuild(
gr,
pDispPos->GetDrawPos().x,
#ifdef NKMM_LINE_MARGIN_TOP
pcView->GetLineMargin() +
pcView->GetLineMargin() +
#endif // NKMM_
pDispPos->GetDrawPos().y + nHeightMargin,
ExtTextOutOption() & ~(bTrans? ETO_OPAQUE: 0),
&rcClip2,
szEol,
wcslen(szEol),
nDx
);
break;
}
case EOL_LF: // 下向き矢印
{
static const wchar_t szEol[] = L"";
pDispPos->GetDrawPos().y + nHeightMargin,
ExtTextOutOption() & ~(bTrans? ETO_OPAQUE: 0),
&rcClip2,
szEol,
wcslen(szEol),
nDx
);
break;
}
case EOL_LF: // 下向き矢印
{
static const wchar_t szEol[] = L"";

::ExtTextOutW_AnyBuild(
gr,
pDispPos->GetDrawPos().x - 2,
::ExtTextOutW_AnyBuild(
gr,
pDispPos->GetDrawPos().x,
#ifdef NKMM_LINE_MARGIN_TOP
pcView->GetLineMargin() +
pcView->GetLineMargin() +
#endif // NKMM_
pDispPos->GetDrawPos().y + nHeightMargin,
ExtTextOutOption() & ~(bTrans? ETO_OPAQUE: 0),
&rcClip2,
szEol,
wcslen(szEol),
nDx
);
break;
}
case EOL_NEL:
case EOL_LS:
case EOL_PS:
{
// 左下矢印(折れ曲がりなし)
static const wchar_t szEol[] = L"";

::ExtTextOutW_AnyBuild(
gr,
pDispPos->GetDrawPos().x - 2,
pDispPos->GetDrawPos().y + nHeightMargin,
ExtTextOutOption() & ~(bTrans? ETO_OPAQUE: 0),
&rcClip2,
szEol,
wcslen(szEol),
nDx
);
break;
}
case EOL_NEL:
case EOL_LS:
case EOL_PS:
{
// 左下矢印(折れ曲がりなし)
static const wchar_t szEol[] = L"";

::ExtTextOutW_AnyBuild(
gr,
pDispPos->GetDrawPos().x,
#ifdef NKMM_LINE_MARGIN_TOP
pcView->GetLineMargin() +
pcView->GetLineMargin() +
#endif // NKMM_
pDispPos->GetDrawPos().y + nHeightMargin,
ExtTextOutOption() & ~(bTrans? ETO_OPAQUE: 0),
&rcClip2,
szEol,
wcslen(szEol),
nDx
);
break;
}
}
pDispPos->GetDrawPos().y + nHeightMargin,
ExtTextOutOption() & ~(bTrans? ETO_OPAQUE: 0),
&rcClip2,
szEol,
wcslen(szEol),
nDx
);
break;
}
}

gr.PopTextForeColor();

pDispPos->ForwardDrawCol(width);
}


Expand Down

0 comments on commit 8cbd6c3

Please sign in to comment.