Skip to content

Commit 77ac080

Browse files
committed
Add support for placing the tab bar on the title bar (WinMerge#2428) (5)
1 parent aff4794 commit 77ac080

File tree

2 files changed

+13
-7
lines changed

2 files changed

+13
-7
lines changed

Src/Common/MDITabBar.cpp

+10-7
Original file line numberDiff line numberDiff line change
@@ -90,9 +90,11 @@ static inline COLORREF getTextColor()
9090
return GetSysColor(COLOR_WINDOWTEXT);
9191
}
9292

93-
static COLORREF getBackColor()
93+
static COLORREF getBackColor(bool onTitleBar)
9494
{
9595
const COLORREF clr = GetSysColor(COLOR_3DFACE);
96+
if (!onTitleBar)
97+
return clr;
9698
return RGB(GetRValue(clr), std::clamp(GetGValue(clr) + 8, 0, 255), std::clamp(GetBValue(clr) + 8, 0, 255));
9799
}
98100

@@ -132,7 +134,7 @@ BOOL CMyTabCtrl::OnEraseBkgnd(CDC* pDC)
132134
{
133135
CRect rClient;
134136
GetClientRect(rClient);
135-
pDC->FillSolidRect(rClient, getBackColor());
137+
pDC->FillSolidRect(rClient, getBackColor(m_bOnTitleBar));
136138
return TRUE;
137139
}
138140

@@ -357,17 +359,17 @@ void CMyTabCtrl::DrawItem(LPDRAWITEMSTRUCT lpDrawItemStruct)
357359
CRect rc = lpDraw->rcItem;
358360
if (lpDraw->itemState & ODS_SELECTED)
359361
{
360-
const COLORREF clrShadow = CEColor::GetIntermediateColor(GetSysColor(COLOR_3DSHADOW), getBackColor(), 0.5f);
362+
const COLORREF clrShadow = CEColor::GetIntermediateColor(GetSysColor(COLOR_3DSHADOW), getBackColor(m_bOnTitleBar), 0.5f);
361363
if (GetSysColor(COLOR_3DFACE) == GetSysColor(COLOR_WINDOW))
362364
{
363365
DrawRoundedRectWithShadow(lpDraw->hDC, rc.left + sw, rc.top + sw - 1, rc.Width() - sw * 2, rc.top - sw * 2 + 2, r, sw,
364-
GetSysColor(COLOR_HIGHLIGHT), clrShadow, getBackColor());
366+
GetSysColor(COLOR_HIGHLIGHT), clrShadow, getBackColor(m_bOnTitleBar));
365367
SetTextColor(lpDraw->hDC, GetSysColor(COLOR_HIGHLIGHTTEXT));
366368
}
367369
else
368370
{
369371
DrawRoundedRectWithShadow(lpDraw->hDC, rc.left + sw, rc.top + sw - 1, rc.Width() - sw * 2, rc.Height() - sw * 2 + 2, r, sw,
370-
GetSysColor(COLOR_WINDOW), clrShadow, getBackColor());
372+
GetSysColor(COLOR_WINDOW), clrShadow, getBackColor(m_bOnTitleBar));
371373
SetTextColor(lpDraw->hDC, getTextColor());
372374
}
373375
}
@@ -613,6 +615,7 @@ BOOL CMDITabBar::Update(bool bOnTitleBar, bool bMaximized)
613615
if (m_bMaximized)
614616
AfxGetMainWnd()->GetWindowRect(&rc);
615617
m_top = rc.top;
618+
m_tabCtrl.SetOnTitleBar(bOnTitleBar);
616619
return true;
617620
}
618621

@@ -731,7 +734,7 @@ BOOL CMDITabBar::OnEraseBkgnd(CDC* pDC)
731734
{
732735
CRect rClient;
733736
GetClientRect(rClient);
734-
pDC->FillSolidRect(rClient, getBackColor());
737+
pDC->FillSolidRect(rClient, getBackColor(m_bOnTitleBar));
735738
return TRUE;
736739
}
737740

@@ -741,5 +744,5 @@ void CMDITabBar::OnPaint()
741744
return __super::OnPaint();
742745
CPaintDC dc(this);
743746
m_titleBar.DrawIcon(AfxGetMainWnd(), dc);
744-
m_titleBar.DrawButtons(dc, getTextColor(), getBackColor());
747+
m_titleBar.DrawButtons(dc, getTextColor(), getBackColor(m_bOnTitleBar));
745748
}

Src/Common/MDITabBar.h

+3
Original file line numberDiff line numberDiff line change
@@ -22,13 +22,15 @@ class CMyTabCtrl : public CTabCtrl
2222
, m_nDraggingTabItemIndex(-1)
2323
, m_bInSelchange(false)
2424
, m_nTooltipTabItemIndex(-1)
25+
, m_bOnTitleBar(false)
2526
{}
2627

2728
protected:
2829
bool m_bInSelchange;
2930
bool m_bAutoMaxWidth;
3031
bool m_bMouseTracking;
3132
bool m_bCloseButtonDown;
33+
bool m_bOnTitleBar;
3234
CRect m_rcCurrentCloseButtom;
3335
int m_nDraggingTabItemIndex;
3436
int m_nTooltipTabItemIndex; /**< Index of the tab displaying tooltip */
@@ -40,6 +42,7 @@ class CMyTabCtrl : public CTabCtrl
4042
bool GetAutoMaxWidth() const { return m_bAutoMaxWidth; }
4143
void SetAutoMaxWidth(bool bAutoMaxWidth) { m_bAutoMaxWidth = bAutoMaxWidth; }
4244
void UpdateTabs();
45+
void SetOnTitleBar(bool onTitleBar) { m_bOnTitleBar = onTitleBar; }
4346

4447
// Overrides
4548
// ClassWizard generated virtual function overrides

0 commit comments

Comments
 (0)