Skip to content

Commit

Permalink
WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
sdottaka committed Sep 1, 2024
1 parent 10daec4 commit 4bee9e2
Show file tree
Hide file tree
Showing 7 changed files with 116 additions and 6 deletions.
11 changes: 7 additions & 4 deletions Src/Common/MDITabBar.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -491,12 +491,15 @@ void CMDITabBar::OnLButtonUp(UINT nFlags, CPoint point)

LRESULT CMDITabBar::OnSizeParent(WPARAM wParam, LPARAM lParam)
{
CClientDC dc(this);
const int lpx = dc.GetDeviceCaps(LOGPIXELSX);
auto pointToPixel = [lpx](int point) { return MulDiv(point, lpx, 72); };
AFX_SIZEPARENTPARAMS* lpLayout = (AFX_SIZEPARENTPARAMS*)lParam;
// lpLayout->rect.left += 24;
// lpLayout->rect.right -= 24 * 3;
lpLayout->rect.left += pointToPixel(18);
lpLayout->rect.right -= pointToPixel(18) * 3;
LRESULT result = __super::OnSizeParent(wParam, reinterpret_cast<LPARAM>(lpLayout));
// lpLayout->rect.left -= 24;
// lpLayout->rect.right += 24 * 3;
lpLayout->rect.left -= pointToPixel(18);;
lpLayout->rect.right += pointToPixel(18) * 3;
return result;
}

Expand Down
39 changes: 37 additions & 2 deletions Src/MainFrm.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -224,6 +224,7 @@ BEGIN_MESSAGE_MAP(CMainFrame, CMDIFrameWnd)
ON_WM_ACTIVATE()
ON_WM_NCCALCSIZE()
ON_WM_NCHITTEST()
ON_WM_PAINT()
ON_UPDATE_COMMAND_UI_RANGE(CMenuBar::FIRST_MENUID, CMenuBar::FIRST_MENUID + 10, OnUpdateMenuBarMenuItem)
// [File] menu
ON_COMMAND(ID_FILE_NEW, (OnFileNew<2, ID_MERGE_COMPARE_TEXT>))
Expand Down Expand Up @@ -2516,9 +2517,14 @@ LRESULT CMainFrame::OnNcHitTest(CPoint point)
//return (UINT)res;
CRect rc;
GetWindowRect(&rc);
if (point.y < rc.top + 32)
CClientDC dc(this);
const int lpx = dc.GetDeviceCaps(LOGPIXELSX);
auto pointToPixel = [lpx](int point) { return MulDiv(point, lpx, 72); };
const int height = pointToPixel(24);
const int buttonWidth = pointToPixel(24);
if (point.y < rc.top + height)
{
const int bw = 32;
const int bw = buttonWidth;
const int m = 4;
if (point.y < rc.top + 4)
{
Expand Down Expand Up @@ -2557,6 +2563,35 @@ LRESULT CMainFrame::OnNcHitTest(CPoint point)
return __super::OnNcHitTest(point);
}

void CMainFrame::OnPaint()
{
__super::OnPaint();
CRect rcClient;
GetClientRect(&rcClient);
CClientDC dc(this);
dc.FillSolidRect(&rcClient, GetSysColor(COLOR_3DFACE));
dc.DrawIcon(CPoint{ 0, 0 }, GetIcon(true));
const int bw = 64;
CRect rc1{ rcClient.right - bw, 0, rcClient.right, bw };
CRect rc2{ rcClient.right - bw * 2, 0, rcClient.right - bw * 1, bw };
CRect rc3{ rcClient.right - bw * 3, 0, rcClient.right - bw * 2, bw };
HTHEME hTheme = OpenThemeData(m_hWnd, L"WINDOW");
if (hTheme)
{
int state = CBS_NORMAL;
DrawThemeBackground(hTheme, dc.m_hDC, WP_CLOSEBUTTON, state, &rc1, nullptr);
DrawThemeBackground(hTheme, dc.m_hDC, WP_RESTOREBUTTON, state, &rc2, nullptr);
DrawThemeBackground(hTheme, dc.m_hDC, WP_MINBUTTON, state, &rc3, nullptr);
CloseThemeData(hTheme);
}
else
{
DrawFrameControl(dc.m_hDC, &rc1, DFC_CAPTION, DFCS_CAPTIONCLOSE);
DrawFrameControl(dc.m_hDC, &rc2, DFC_CAPTION, DFCS_CAPTIONMAX);
DrawFrameControl(dc.m_hDC, &rc3, DFC_CAPTION, DFCS_CAPTIONMIN);
}
}

BOOL CMainFrame::CreateToolbar()
{
if (!m_wndMenuBar.Create(this))
Expand Down
1 change: 1 addition & 0 deletions Src/MainFrm.h
Original file line number Diff line number Diff line change
Expand Up @@ -383,6 +383,7 @@ class CMainFrame : public CMDIFrameWnd
afx_msg void OnActivateApp(BOOL bActive, DWORD dwThreadID);
afx_msg void OnActivate(UINT nState, CWnd *pWndOther, BOOL bMinimized);
afx_msg LRESULT OnNcHitTest(CPoint point);
afx_msg void OnPaint();
afx_msg void OnNcCalcSize(BOOL bCalcValidRects, NCCALCSIZE_PARAMS FAR* lpncsp);
afx_msg void OnToolbarSize(UINT id);
afx_msg void OnUpdateToolbarSize(CCmdUI* pCmdUI);
Expand Down
2 changes: 2 additions & 0 deletions Src/Merge.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -1404,6 +1404,7 @@
<PrecompiledHeaderOutputFile>$(IntDir)$(TargetName)2.pch</PrecompiledHeaderOutputFile>
</ClCompile>
<ClCompile Include="TestMain.cpp" />
<ClCompile Include="TitleBarHelper.cpp" />
<ClCompile Include="TrDialogs.cpp" />
<ClCompile Include="Common\varprop.cpp">
<PrecompiledHeader>Use</PrecompiledHeader>
Expand Down Expand Up @@ -1647,6 +1648,7 @@
<ClInclude Include="Common\unicoder.h" />
<ClInclude Include="Common\UnicodeString.h" />
<ClInclude Include="Common\UniFile.h" />
<ClInclude Include="TitleBarHelper.h" />
<ClInclude Include="TrDialogs.h" />
<ClInclude Include="Common\varprop.h" />
<ClInclude Include="Common\VersionInfo.h" />
Expand Down
6 changes: 6 additions & 0 deletions Src/Merge.vcxproj.filters
Original file line number Diff line number Diff line change
Expand Up @@ -735,6 +735,9 @@
<ClCompile Include="MyReBar.cpp">
<Filter>MFCGui\Common\Source Files</Filter>
</ClCompile>
<ClCompile Include="TitleBarHelper.cpp">
<Filter>MFCGui\Common\Source Files</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<ClInclude Include="charsets.h">
Expand Down Expand Up @@ -1406,6 +1409,9 @@
<ClInclude Include="MyReBar.h">
<Filter>MFCGui\Common\Header Files</Filter>
</ClInclude>
<ClInclude Include="TitleBarHelper.h">
<Filter>MFCGui\Common\Header Files</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<None Include="res\binarydiff.ico">
Expand Down
37 changes: 37 additions & 0 deletions Src/TitleBarHelper.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
// Copyright (c) 2024 Takashi Sawanaka
// SPDX-License-Identifier: BSL-1.0
/**
* @file TitleBarHelper.cpp
*
* @brief Implementation of the CTitleBarHelper class
*/

#include "StdAfx.h"
#include "TitleBarHelper.h"

void CTitleBarHelper::DrawIcon(CDC& dc)
{
}

void CTitleBarHelper::DrawButtons(CDC& dc)
{
}

CRect CTitleBarHelper::GetIconRect()
{
return CRect{};
}

CRect CTitleBarHelper::GetButtonsRect()
{
return CRect{};
}

void CTitleBarHelper::Update(CSize size, bool maxmized)
{
}

int CTitleBarHelper::HitTest(CPoint pt)
{
return HTTOP;
}
26 changes: 26 additions & 0 deletions Src/TitleBarHelper.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
/**
* @file TitleBarHelper.h
*
* @brief Declaration file for CTitleBarHelper
*
*/
#pragma once

#include <afxwin.h>
#include <afxext.h>
#include <vector>

class CTitleBarHelper {
public:
CTitleBarHelper() {}
void DrawIcon(CDC& dc);
void DrawButtons(CDC& dc);
CRect GetIconRect();
CRect GetButtonsRect();
void Update(CSize size, bool maxmized);
int HitTest(CPoint pt);

private:
CSize m_size;
int m_iconSize;
};

0 comments on commit 4bee9e2

Please sign in to comment.