Skip to content

Commit

Permalink
タブ幅が半角単位8桁を超える場合でも下線が最後まで描画されるようにする
Browse files Browse the repository at this point in the history
  • Loading branch information
Kohki Akikaze committed May 22, 2021
1 parent 0843eb9 commit 6b4f0a8
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 32 deletions.
30 changes: 15 additions & 15 deletions sakura_core/view/figures/CFigure_Comma.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,8 @@
#include "types/CTypeSupport.h"
#include "apiwrap/StdApi.h"

void _DispTab( CGraphics& gr, DispPos* pDispPos, const CEditView* pcView );

// -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- //
// CFigure_Comma //
// CFigure_Comma //
// -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- //

bool CFigure_Comma::Match(const wchar_t* pText, int nTextLen) const
Expand All @@ -58,51 +56,53 @@ void CFigure_Comma::DispSpace(CGraphics& gr, DispPos* pDispPos, CEditView* pcVie
DispPos& sPos=*pDispPos;

//必要なインターフェース
const CLayoutMgr& pcLayoutMgr = pcView->GetDocument()->m_cLayoutMgr;
const CTextMetrics* pMetrics=&pcView->GetTextMetrics();
const CTextArea* pArea=&pcView->GetTextArea();

int nLineHeight = pMetrics->GetHankakuDy();
int nCharWidth = pMetrics->GetCharPxWidth(); // Layout→Px

CTypeSupport cTabType(pcView,COLORIDX_TAB);

// これから描画するタブ幅
CLayoutXInt tabDispWidthLayout = pcView->m_pcEditDoc->m_cLayoutMgr.GetActualTsvSpace( sPos.GetDrawCol(), L',' );
int tabDispWidth = (Int)tabDispWidthLayout;
CLayoutXInt nTabLayoutWidth = pcLayoutMgr.GetActualTsvSpace(sPos.GetDrawCol(), L',');
size_t nTabDispWidth = static_cast<Int>(nTabLayoutWidth) / pcLayoutMgr.GetWidthPerKeta();
if( pcView->m_bMiniMap ){
CLayoutMgr mgrTemp;
mgrTemp.SetTabSpaceInfo(pcView->m_pcEditDoc->m_cLayoutMgr.GetTabSpaceKetas(),
CLayoutXInt(pcView->GetTextMetrics().GetHankakuWidth()) );
tabDispWidthLayout = mgrTemp.GetActualTabSpace(sPos.GetDrawCol());
tabDispWidth = (Int)tabDispWidthLayout;
mgrTemp.SetTabSpaceInfo(pcLayoutMgr.GetTabSpaceKetas(), static_cast<CLayoutXInt>(pMetrics->GetHankakuWidth()));
nTabLayoutWidth = mgrTemp.GetActualTabSpace(sPos.GetDrawCol());
nTabDispWidth = static_cast<Int>(nTabLayoutWidth) / mgrTemp.GetWidthPerKeta();
}

// タブ記号領域
RECT rcClip2;
rcClip2.left = sPos.GetDrawPos().x;
rcClip2.right = rcClip2.left + nCharWidth * tabDispWidth;
rcClip2.right = rcClip2.left + static_cast<Int>(nTabLayoutWidth);
if( rcClip2.left < pArea->GetAreaLeft() ){
rcClip2.left = pArea->GetAreaLeft();
}
rcClip2.top = sPos.GetDrawPos().y;
rcClip2.bottom = sPos.GetDrawPos().y + nLineHeight;
int nLen = wcslen( m_pTypeData->m_szTabViewString );

if( pArea->IsRectIntersected(rcClip2) ){
if( cTabType.IsDisp() ){ //CSVモード
std::wstring szViewString = L",";
if (szViewString.length() < nTabDispWidth) {
szViewString.append(nTabDispWidth - szViewString.length(), L' ');
}
::ExtTextOut(
gr,
sPos.GetDrawPos().x,
sPos.GetDrawPos().y,
ExtTextOutOption() & ~(bTrans? ETO_OPAQUE: 0),
&rcClip2,
L", ",
tabDispWidth <= 8 ? tabDispWidth : 8, // Sep. 22, 2002 genta
szViewString.c_str(),
static_cast<UINT>(szViewString.length()),
pMetrics->GetDxArray_AllHankaku()
);
}
}

//Xを進める
sPos.ForwardDrawCol(tabDispWidthLayout);
sPos.ForwardDrawCol(nTabLayoutWidth);
}
36 changes: 19 additions & 17 deletions sakura_core/view/figures/CFigure_Tab.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -61,39 +61,41 @@ void CFigure_Tab::DispSpace(CGraphics& gr, DispPos* pDispPos, CEditView* pcView,
DispPos& sPos=*pDispPos;

//必要なインターフェース
const CLayoutMgr& pcLayoutMgr = pcView->GetDocument()->m_cLayoutMgr;
const CTextMetrics* pMetrics=&pcView->GetTextMetrics();
const CTextArea* pArea=&pcView->GetTextArea();

int nLineHeight = pMetrics->GetHankakuDy();
int nCharWidth = pMetrics->GetCharPxWidth(); // Layout→Px

CTypeSupport cTabType(pcView,COLORIDX_TAB);

// これから描画するタブ幅
CLayoutXInt tabDispWidthLayout = pcView->m_pcEditDoc->m_cLayoutMgr.GetActualTsvSpace( sPos.GetDrawCol(), WCODE::TAB );
int tabDispWidth = (Int)tabDispWidthLayout;
CLayoutXInt nTabLayoutWidth = pcLayoutMgr.GetActualTsvSpace(sPos.GetDrawCol(), WCODE::TAB);
size_t nTabDispWidth = static_cast<Int>(nTabLayoutWidth) / pcLayoutMgr.GetWidthPerKeta();
if( pcView->m_bMiniMap ){
CLayoutMgr mgrTemp;
mgrTemp.SetTabSpaceInfo(pcView->m_pcEditDoc->m_cLayoutMgr.GetTabSpaceKetas(),
CLayoutXInt(pcView->GetTextMetrics().GetHankakuWidth()) );
tabDispWidthLayout = mgrTemp.GetActualTabSpace(sPos.GetDrawCol());
tabDispWidth = (Int)tabDispWidthLayout;
mgrTemp.SetTabSpaceInfo(pcLayoutMgr.GetTabSpaceKetas(), static_cast<CLayoutXInt>(pMetrics->GetHankakuWidth()));
nTabLayoutWidth = mgrTemp.GetActualTabSpace(sPos.GetDrawCol());
nTabDispWidth = static_cast<Int>(nTabLayoutWidth) / mgrTemp.GetWidthPerKeta();
}

// タブ記号領域
RECT rcClip2;
rcClip2.left = sPos.GetDrawPos().x;
rcClip2.right = rcClip2.left + nCharWidth * tabDispWidth;
rcClip2.right = rcClip2.left + static_cast<Int>(nTabLayoutWidth);
if( rcClip2.left < pArea->GetAreaLeft() ){
rcClip2.left = pArea->GetAreaLeft();
}
rcClip2.top = sPos.GetDrawPos().y;
rcClip2.bottom = sPos.GetDrawPos().y + nLineHeight;
int nLen = wcslen( m_pTypeData->m_szTabViewString );

if( pArea->IsRectIntersected(rcClip2) ){
if( cTabType.IsDisp() && TABARROW_STRING == m_pTypeData->m_bTabArrow ){ //タブ通常表示 //@@@ 2003.03.26 MIK
int fontNo = WCODE::GetFontNo(m_pTypeData->m_szTabViewString[0]);
std::wstring szForeViewString = m_pTypeData->m_szTabViewString;
if (szForeViewString.length() < nTabDispWidth) {
szForeViewString.append(nTabDispWidth - szForeViewString.length(), L' ');
}
int fontNo = WCODE::GetFontNo(szForeViewString[0]);
if( fontNo ){
SFONT sFont;
sFont.m_sFontAttr = gr.GetCurrentMyFontAttr();
Expand All @@ -108,24 +110,24 @@ void CFigure_Tab::DispSpace(CGraphics& gr, DispPos* pDispPos, CEditView* pcView,
sPos.GetDrawPos().y + nHeightMargin,
ExtTextOutOption() & ~(bTrans? ETO_OPAQUE: 0),
&rcClip2,
m_pTypeData->m_szTabViewString,
// tabDispWidth <= 8 ? tabDispWidth : 8, // Sep. 22, 2002 genta
nLen,
szForeViewString.c_str(),
static_cast<UINT>(szForeViewString.length()),
pMetrics->GetDxArray_AllHankaku() // FIXME:半角固定?
);
if( fontNo ){
gr.PopMyFont();
}
}else{
//背景
std::wstring szBackViewString(nTabDispWidth, L' ');
::ExtTextOut(
gr,
sPos.GetDrawPos().x,
sPos.GetDrawPos().y,
ExtTextOutOption() & ~(bTrans? ETO_OPAQUE: 0),
&rcClip2,
L" ",
8,
szBackViewString.c_str(),
static_cast<UINT>(szBackViewString.length()),
pMetrics->GetDxArray_AllHankaku()
);

Expand Down Expand Up @@ -154,7 +156,7 @@ void CFigure_Tab::DispSpace(CGraphics& gr, DispPos* pDispPos, CEditView* pcView,
gr,
nPosLeft,
sPos.GetDrawPos().y,
nCharWidth * tabDispWidth - (nPosLeft - sPos.GetDrawPos().x), // Tab Area一杯に 2013/4/11 Uchi
static_cast<Int>(nTabLayoutWidth) - (nPosLeft - sPos.GetDrawPos().x), // Tab Area一杯に 2013/4/11 Uchi
pMetrics->GetHankakuHeight(),
gr.GetCurrentMyFontBold() || m_pTypeData->m_ColorInfoArr[COLORIDX_TAB].m_sFontAttr.m_bBoldFont,
gr.GetCurrentTextForeColor()
Expand All @@ -165,7 +167,7 @@ void CFigure_Tab::DispSpace(CGraphics& gr, DispPos* pDispPos, CEditView* pcView,
}

//Xを進める
sPos.ForwardDrawCol(tabDispWidthLayout);
sPos.ForwardDrawCol(nTabLayoutWidth);
}

/*
Expand Down

0 comments on commit 6b4f0a8

Please sign in to comment.