Skip to content

Commit

Permalink
First pass at splitter pane
Browse files Browse the repository at this point in the history
  • Loading branch information
stephenegriffin committed Sep 13, 2018
1 parent ab3fbd2 commit 46898c7
Show file tree
Hide file tree
Showing 13 changed files with 280 additions and 81 deletions.
2 changes: 2 additions & 0 deletions MFCMapi.vcxproj
Expand Up @@ -654,6 +654,7 @@ copy "$(TargetDir)$(TargetName).pdb" "$(SolutionDir)"
<ClInclude Include="UI\ViewPane\DropDownPane.h" />
<ClInclude Include="UI\ViewPane\ListPane.h" />
<ClInclude Include="UI\ViewPane\SmartViewPane.h" />
<ClInclude Include="UI\ViewPane\SplitterPane.h" />
<ClInclude Include="UI\ViewPane\TextPane.h" />
<ClInclude Include="UI\ViewPane\ViewPane.h" />
<ClInclude Include="UI\Dialogs\ContentsTable\MsgServiceTableDlg.h" />
Expand Down Expand Up @@ -845,6 +846,7 @@ copy "$(TargetDir)$(TargetName).pdb" "$(SolutionDir)"
<ClCompile Include="UI\ViewPane\DropDownPane.cpp" />
<ClCompile Include="UI\ViewPane\ListPane.cpp" />
<ClCompile Include="UI\ViewPane\SmartViewPane.cpp" />
<ClCompile Include="UI\ViewPane\SplitterPane.cpp" />
<ClCompile Include="UI\ViewPane\TextPane.cpp" />
<ClCompile Include="UI\ViewPane\ViewPane.cpp" />
</ItemGroup>
Expand Down
4 changes: 4 additions & 0 deletions MFCMapi.vcxproj.filters
Expand Up @@ -118,6 +118,7 @@
<ClInclude Include="MAPI\StubUtils.h" />
<ClInclude Include="MAPI\Version.h" />
<ClInclude Include="MAPI\MapiMemory.h" />
<ClInclude Include="UI\ViewPane\SplitterPane.h" />
</ItemGroup>
<ItemGroup>
<ClCompile Include="AddIns.cpp">
Expand Down Expand Up @@ -156,6 +157,9 @@
<ClCompile Include="MAPI\Version.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="UI\ViewPane\SplitterPane.cpp">
<Filter>Source Files</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<ClCompile Include="IO\Error.cpp">
Expand Down
9 changes: 5 additions & 4 deletions UI/Dialogs/BaseDialog.cpp
Expand Up @@ -149,15 +149,16 @@ namespace dialog

SetIcon(m_hIcon, false); // Set small icon - large icon isn't used

m_lpFakeSplitter = new controls::CFakeSplitter(this);

m_lpFakeSplitter = new controls::CFakeSplitter();
if (m_lpFakeSplitter)
{
m_lpFakeSplitter->Init(m_hWnd);
m_lpPropDisplay =
new controls::sortlistctrl::CSingleMAPIPropListCtrl(m_lpFakeSplitter, this, m_lpMapiObjects, m_bIsAB);

if (m_lpPropDisplay) m_lpFakeSplitter->SetPaneTwo(m_lpPropDisplay);
if (m_lpPropDisplay) m_lpFakeSplitter->SetPaneTwo(m_lpPropDisplay->GetSafeHwnd());
}

return false;
}

Expand Down Expand Up @@ -1019,4 +1020,4 @@ namespace dialog
_Check_return_ ui::CParentWnd* CBaseDialog::GetParentWnd() const { return m_lpParent; }

_Check_return_ cache::CMapiObjects* CBaseDialog::GetMapiObjects() const { return m_lpMapiObjects; }
}
} // namespace dialog
4 changes: 2 additions & 2 deletions UI/Dialogs/ContentsTable/ContentsTableDlg.cpp
Expand Up @@ -100,7 +100,7 @@ namespace dialog

if (m_lpContentsTableListCtrl && m_lpFakeSplitter)
{
m_lpFakeSplitter->SetPaneOne(m_lpContentsTableListCtrl);
m_lpFakeSplitter->SetPaneOne(m_lpContentsTableListCtrl->GetSafeHwnd());
m_lpFakeSplitter->SetPercent(static_cast<FLOAT>(0.40));
m_lpFakeSplitter->SetSplitType(controls::SplitVertical);
}
Expand Down Expand Up @@ -623,4 +623,4 @@ namespace dialog

return false;
}
}
} // namespace dialog
13 changes: 9 additions & 4 deletions UI/Dialogs/Editors/HexEditor.cpp
Expand Up @@ -3,6 +3,7 @@
#include <UI/FileDialogEx.h>
#include <UI/ViewPane/CountedTextPane.h>
#include <UI/ViewPane/SmartViewPane.h>
#include <UI/ViewPane/SplitterPane.h>
#include <MAPI/Cache/GlobalCache.h>
#include <MAPI/MAPIFunctions.h>

Expand All @@ -14,6 +15,7 @@ namespace dialog

enum __HexEditorFields
{
HEXED_TEXT,
HEXED_ANSI,
HEXED_UNICODE,
HEXED_BASE64,
Expand All @@ -35,8 +37,10 @@ namespace dialog
m_lpMapiObjects = lpMapiObjects;
if (m_lpMapiObjects) m_lpMapiObjects->AddRef();

InitPane(HEXED_ANSI, viewpane::TextPane::CreateCollapsibleTextPane(IDS_ANSISTRING, false));
InitPane(HEXED_UNICODE, viewpane::TextPane::CreateCollapsibleTextPane(IDS_UNISTRING, false));
auto splitter = viewpane::SplitterPane::CreateHorizontalPane();
InitPane(HEXED_TEXT, splitter);
splitter->SetPaneOne(HEXED_ANSI, viewpane::TextPane::CreateCollapsibleTextPane(IDS_ANSISTRING, false));
splitter->SetPaneTwo(HEXED_UNICODE, viewpane::TextPane::CreateCollapsibleTextPane(IDS_UNISTRING, false));
InitPane(HEXED_BASE64, viewpane::CountedTextPane::Create(IDS_BASE64STRING, false, IDS_CCH));
InitPane(HEXED_HEX, viewpane::CountedTextPane::Create(IDS_HEX, false, IDS_CB));
InitPane(HEXED_SMARTVIEW, viewpane::SmartViewPane::Create(IDS_SMARTVIEW));
Expand Down Expand Up @@ -70,6 +74,7 @@ namespace dialog
size_t cchEncodeStr = 0;
switch (i)
{
// TODO: Get these routed into our splitter
case HEXED_ANSI:
{
auto text = GetStringA(HEXED_ANSI);
Expand Down Expand Up @@ -248,5 +253,5 @@ namespace dialog

// Close
void CHexEditor::OnEditAction3() { OnOK(); }
}
}
} // namespace editor
} // namespace dialog
4 changes: 2 additions & 2 deletions UI/Dialogs/HierarchyTable/HierarchyTableDlg.cpp
Expand Up @@ -208,7 +208,7 @@ namespace dialog

if (m_lpHierarchyTableTreeCtrl)
{
m_lpFakeSplitter->SetPaneOne(m_lpHierarchyTableTreeCtrl);
m_lpFakeSplitter->SetPaneOne(m_lpHierarchyTableTreeCtrl->GetSafeHwnd());

m_lpFakeSplitter->SetPercent(0.25);
}
Expand Down Expand Up @@ -327,4 +327,4 @@ namespace dialog
{
addin::InvokeAddInMenu(lpParams);
}
}
} // namespace dialog
95 changes: 47 additions & 48 deletions UI/FakeSplitter.cpp
Expand Up @@ -14,28 +14,16 @@ namespace controls
SplitterHit = 1
};

CFakeSplitter::CFakeSplitter(_In_ dialog::CBaseDialog* lpHostDlg)
CFakeSplitter::~CFakeSplitter()
{
TRACE_CONSTRUCTOR(CLASS);
CRect pRect;

m_bTracking = false;

m_lpHostDlg = lpHostDlg;
m_lpHostDlg->AddRef();

m_lpHostDlg->GetClientRect(pRect);

m_flSplitPercent = 0.5;

m_iSplitWidth = 0;

m_PaneOne = nullptr;
m_PaneTwo = nullptr;

m_SplitType = SplitHorizontal; // this doesn't mean anything yet
m_iSplitPos = 1;
TRACE_DESTRUCTOR(CLASS);
(void) DestroyCursor(m_hSplitCursorH);
(void) DestroyCursor(m_hSplitCursorV);
CWnd::DestroyWindow();
}

void CFakeSplitter::Init(HWND hWnd)
{
WNDCLASSEX wc = {0};
const auto hInst = AfxGetInstanceHandle();
if (!::GetClassInfoEx(hInst, _T("FakeSplitter"), &wc)) // STRING_OK
Expand All @@ -49,14 +37,19 @@ namespace controls
RegisterClassEx(&wc);
}

EC_B_S(Create(
// WS_CLIPCHILDREN is used to reduce flicker
EC_B_S(CreateEx(
0,
_T("FakeSplitter"), // STRING_OK
_T("FakeSplitter"), // STRING_OK
WS_CHILD | WS_CLIPSIBLINGS | WS_CLIPCHILDREN // required to reduce flicker
| WS_VISIBLE,
pRect,
lpHostDlg,
IDC_FAKE_SPLITTER));
WS_CHILD | WS_CLIPSIBLINGS | WS_CLIPCHILDREN | WS_VISIBLE,
0,
0,
0,
0,
hWnd,
reinterpret_cast<HMENU>(static_cast<INT_PTR>(IDC_FAKE_SPLITTER)),
nullptr));

// Necessary for TAB to work. Without this, all TABS get stuck on the fake splitter control
// instead of passing to the children. Haven't tested with nested splitters.
Expand All @@ -67,15 +60,6 @@ namespace controls
m_hSplitCursorH = EC_D(HCURSOR, ::LoadCursor(GetModuleHandle(nullptr), MAKEINTRESOURCE(IDC_SPLITH)));
}

CFakeSplitter::~CFakeSplitter()
{
TRACE_DESTRUCTOR(CLASS);
(void) DestroyCursor(m_hSplitCursorH);
(void) DestroyCursor(m_hSplitCursorV);
CWnd::DestroyWindow();
if (m_lpHostDlg) m_lpHostDlg->Release();
}

BEGIN_MESSAGE_MAP(CFakeSplitter, CWnd)
ON_WM_MOUSEMOVE()
ON_WM_SIZE()
Expand Down Expand Up @@ -107,9 +91,9 @@ namespace controls
return CWnd::WindowProc(message, wParam, lParam);
}

void CFakeSplitter::SetPaneOne(CWnd* PaneOne)
void CFakeSplitter::SetPaneOne(HWND paneOne)
{
m_PaneOne = PaneOne;
m_PaneOne = paneOne;
if (m_PaneOne)
{
m_iSplitWidth = 7;
Expand All @@ -120,7 +104,7 @@ namespace controls
}
}

void CFakeSplitter::SetPaneTwo(CWnd* PaneTwo) { m_PaneTwo = PaneTwo; }
void CFakeSplitter::SetPaneTwo(HWND paneTwo) { m_PaneTwo = paneTwo; }

void CFakeSplitter::OnSize(UINT /*nType*/, int cx, int cy)
{
Expand All @@ -129,7 +113,7 @@ namespace controls
const auto hdwp = WC_D(HDWP, BeginDeferWindowPos(2));
if (hdwp)
{
if (m_PaneOne && m_PaneOne->m_hWnd)
if (m_PaneOne || m_ViewPaneOne)
{
CRect r1;
if (SplitHorizontal == m_SplitType)
Expand All @@ -141,10 +125,18 @@ namespace controls
r1.SetRect(0, 0, cx, m_iSplitPos);
}

DeferWindowPos(hdwp, m_PaneOne->m_hWnd, nullptr, 0, 0, r1.Width(), r1.Height(), SWP_NOZORDER);
if (m_PaneOne)
{
DeferWindowPos(hdwp, m_PaneOne, nullptr, 0, 0, r1.Width(), r1.Height(), SWP_NOZORDER);
}

if (m_ViewPaneOne)
{
m_ViewPaneOne->DeferWindowPos(hdwp, 0, 0, r1.Width(), r1.Height());
}
}

if (m_PaneTwo && m_PaneTwo->m_hWnd)
if (m_PaneTwo || m_ViewPaneTwo)
{
CRect r2;
if (SplitHorizontal == m_SplitType)
Expand All @@ -164,14 +156,21 @@ namespace controls
cy); // bottom right corner
}

DeferWindowPos(
hdwp, m_PaneTwo->m_hWnd, nullptr, r2.left, r2.top, r2.Width(), r2.Height(), SWP_NOZORDER);
if (m_PaneTwo)
{
DeferWindowPos(hdwp, m_PaneTwo, nullptr, r2.left, r2.top, r2.Width(), r2.Height(), SWP_NOZORDER);
}

if (m_ViewPaneTwo)
{
m_ViewPaneTwo->DeferWindowPos(hdwp, r2.left, r2.top, r2.Width(), r2.Height());
}
}

EC_B_S(EndDeferWindowPos(hdwp));
}

if (m_PaneOne && m_PaneTwo)
if ((m_PaneOne || m_ViewPaneOne) && (m_PaneTwo || m_ViewPaneTwo))
{
// Invalidate our splitter region to force a redraw
if (SplitHorizontal == m_SplitType)
Expand All @@ -187,7 +186,7 @@ namespace controls

void CFakeSplitter::CalcSplitPos()
{
if (!m_PaneOne)
if (!m_PaneOne && !m_ViewPaneOne)
{
m_iSplitPos = 0;
return;
Expand Down Expand Up @@ -230,7 +229,7 @@ namespace controls

_Check_return_ int CFakeSplitter::HitTest(LONG x, LONG y) const
{
if (!m_PaneOne) return noHit;
if (!m_PaneOne && !m_ViewPaneOne) return noHit;

LONG lTestPos;

Expand All @@ -250,7 +249,7 @@ namespace controls

void CFakeSplitter::OnMouseMove(UINT /*nFlags*/, CPoint point)
{
if (!m_PaneOne) return;
if (!m_PaneOne && !m_ViewPaneOne) return;

// If we don't have GetCapture, then we don't want to track right now.
if (GetCapture() != this) StopTracking();
Expand Down Expand Up @@ -355,4 +354,4 @@ namespace controls

::EndPaint(m_hWnd, &ps);
}
}
} // namespace controls

0 comments on commit 46898c7

Please sign in to comment.