Skip to content

Commit

Permalink
Merge pull request #25 from irwir/updates
Browse files Browse the repository at this point in the history
Remove definition of the standard anchors from the header file.
  • Loading branch information
ppescher authored Mar 26, 2020
2 parents 33783d8 + 7c22f84 commit bfbe265
Show file tree
Hide file tree
Showing 22 changed files with 138 additions and 129 deletions.
16 changes: 8 additions & 8 deletions ResizableLib/ResizableDialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CResizableDialog message handlers

BOOL CResizableDialog::OnNcCreate(LPCREATESTRUCT lpCreateStruct)
BOOL CResizableDialog::OnNcCreate(LPCREATESTRUCT lpCreateStruct)
{
if (!CDialog::OnNcCreate(lpCreateStruct))
return FALSE;
Expand All @@ -90,11 +90,11 @@ BOOL CResizableDialog::OnNcCreate(LPCREATESTRUCT lpCreateStruct)
// set the initial size as the min track size
SetMinTrackSize(CSize(lpCreateStruct->cx, lpCreateStruct->cy));
}

return TRUE;
}

void CResizableDialog::OnDestroy()
void CResizableDialog::OnDestroy()
{
if (m_bEnableSaveRestore)
SaveWindowRect(m_sSection, m_bRectOnly);
Expand All @@ -107,10 +107,10 @@ void CResizableDialog::OnDestroy()
CDialog::OnDestroy();
}

void CResizableDialog::OnSize(UINT nType, int cx, int cy)
void CResizableDialog::OnSize(UINT nType, int cx, int cy)
{
CDialog::OnSize(nType, cx, cy);

if (nType == SIZE_MAXHIDE || nType == SIZE_MAXSHOW)
return; // arrangement not needed

Expand All @@ -124,7 +124,7 @@ void CResizableDialog::OnSize(UINT nType, int cx, int cy)
ArrangeLayout();
}

void CResizableDialog::OnGetMinMaxInfo(MINMAXINFO FAR* lpMMI)
void CResizableDialog::OnGetMinMaxInfo(MINMAXINFO FAR* lpMMI)
{
MinMaxInfo(lpMMI);
}
Expand All @@ -142,7 +142,7 @@ void CResizableDialog::EnableSaveRestore(LPCTSTR pszSection, BOOL bRectOnly)
LoadWindowRect(pszSection, bRectOnly);
}

BOOL CResizableDialog::OnEraseBkgnd(CDC* pDC)
BOOL CResizableDialog::OnEraseBkgnd(CDC* pDC)
{
ClipChildren(pDC, FALSE);

Expand All @@ -153,7 +153,7 @@ BOOL CResizableDialog::OnEraseBkgnd(CDC* pDC)
return bRet;
}

LRESULT CResizableDialog::WindowProc(UINT message, WPARAM wParam, LPARAM lParam)
LRESULT CResizableDialog::WindowProc(UINT message, WPARAM wParam, LPARAM lParam)
{
if (message != WM_NCCALCSIZE || wParam == 0)
return CDialog::WindowProc(message, wParam, lParam);
Expand Down
16 changes: 8 additions & 8 deletions ResizableLib/ResizableFormView.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ void CResizableFormView::Dump(CDumpContext& dc) const
/////////////////////////////////////////////////////////////////////////////
// CResizableFormView message handlers

void CResizableFormView::OnSize(UINT nType, int cx, int cy)
void CResizableFormView::OnSize(UINT nType, int cx, int cy)
{
CFormView::OnSize(nType, cx, cy);

Expand Down Expand Up @@ -151,7 +151,7 @@ void CResizableFormView::GetTotalClientRect(LPRECT lpRect) const
*lpRect = rect;
}

BOOL CResizableFormView::OnEraseBkgnd(CDC* pDC)
BOOL CResizableFormView::OnEraseBkgnd(CDC* pDC)
{
ClipChildren(pDC, FALSE);

Expand All @@ -162,12 +162,12 @@ BOOL CResizableFormView::OnEraseBkgnd(CDC* pDC)
return bRet;
}

void CResizableFormView::OnGetMinMaxInfo(MINMAXINFO FAR* lpMMI)
void CResizableFormView::OnGetMinMaxInfo(MINMAXINFO FAR* lpMMI)
{
MinMaxInfo(lpMMI);
}

void CResizableFormView::OnDestroy()
void CResizableFormView::OnDestroy()
{
// reset instance data
RemoveAllAnchors();
Expand All @@ -177,7 +177,7 @@ void CResizableFormView::OnDestroy()
CFormView::OnDestroy();
}

LRESULT CResizableFormView::WindowProc(UINT message, WPARAM wParam, LPARAM lParam)
LRESULT CResizableFormView::WindowProc(UINT message, WPARAM wParam, LPARAM lParam)
{
if (message == WM_INITDIALOG)
return static_cast<LRESULT>(OnInitDialog());
Expand All @@ -193,15 +193,15 @@ LRESULT CResizableFormView::WindowProc(UINT message, WPARAM wParam, LPARAM lPara
return lResult;
}

BOOL CResizableFormView::OnInitDialog()
BOOL CResizableFormView::OnInitDialog()
{
const MSG* pMsg = GetCurrentMessage();

BOOL bRet = CFormView::WindowProc(pMsg->message, pMsg->wParam, pMsg->lParam) != 0;

// we need to associate member variables with control IDs
UpdateData(FALSE);

// set default scroll size
CRect rectTemplate;
GetWindowRect(rectTemplate);
Expand All @@ -210,7 +210,7 @@ BOOL CResizableFormView::OnInitDialog()
return bRet;
}

BOOL CResizableFormView::OnNcCreate(LPCREATESTRUCT lpCreateStruct)
BOOL CResizableFormView::OnNcCreate(LPCREATESTRUCT lpCreateStruct)
{
return CFormView::OnNcCreate(lpCreateStruct) && CreateSizeGrip(); // create and init the size-grip
}
4 changes: 2 additions & 2 deletions ResizableLib/ResizableFormView.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
#include <afxext.h>

class CResizableFormView : public CFormView, public CResizableLayout,
public CResizableGrip, public CResizableMinMax
public CResizableGrip, public CResizableMinMax
{
DECLARE_DYNAMIC(CResizableFormView)

Expand Down Expand Up @@ -74,6 +74,7 @@ class CResizableFormView : public CFormView, public CResizableLayout,

// Overrides
public:
virtual BOOL OnInitDialog();
// ClassWizard generated virtual function overrides
//{{AFX_VIRTUAL(CResizableFormView)
protected:
Expand All @@ -94,7 +95,6 @@ class CResizableFormView : public CFormView, public CResizableLayout,
afx_msg BOOL OnEraseBkgnd(CDC* pDC);
afx_msg void OnGetMinMaxInfo(MINMAXINFO FAR* lpMMI);
afx_msg void OnDestroy();
virtual BOOL OnInitDialog();
afx_msg BOOL OnNcCreate(LPCREATESTRUCT lpCreateStruct);
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
Expand Down
10 changes: 5 additions & 5 deletions ResizableLib/ResizableFrame.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CResizableFrame message handlers

void CResizableFrame::OnGetMinMaxInfo(MINMAXINFO FAR* lpMMI)
void CResizableFrame::OnGetMinMaxInfo(MINMAXINFO FAR* lpMMI)
{
MinMaxInfo(lpMMI);

Expand All @@ -76,7 +76,7 @@ BOOL CResizableFrame::EnableSaveRestore(LPCTSTR pszSection, BOOL bRectOnly)
return LoadWindowRect(pszSection, bRectOnly);
}

void CResizableFrame::OnDestroy()
void CResizableFrame::OnDestroy()
{
if (m_bEnableSaveRestore)
SaveWindowRect(m_sSection, m_bRectOnly);
Expand All @@ -89,7 +89,7 @@ void CResizableFrame::OnDestroy()
CFrameWnd::OnDestroy();
}

BOOL CResizableFrame::OnNcCreate(LPCREATESTRUCT lpCreateStruct)
BOOL CResizableFrame::OnNcCreate(LPCREATESTRUCT lpCreateStruct)
{
if (!CFrameWnd::OnNcCreate(lpCreateStruct))
return FALSE;
Expand All @@ -99,7 +99,7 @@ BOOL CResizableFrame::OnNcCreate(LPCREATESTRUCT lpCreateStruct)
return TRUE;
}

LRESULT CResizableFrame::WindowProc(UINT message, WPARAM wParam, LPARAM lParam)
LRESULT CResizableFrame::WindowProc(UINT message, WPARAM wParam, LPARAM lParam)
{
if (message != WM_NCCALCSIZE || wParam == 0)
return CFrameWnd::WindowProc(message, wParam, lParam);
Expand All @@ -114,7 +114,7 @@ LRESULT CResizableFrame::WindowProc(UINT message, WPARAM wParam, LPARAM lParam)

// TODO: implement this in CResizableMinMax
// We definitely need pluggable message handlers ala WTL!
void CResizableFrame::OnWindowPosChanging(WINDOWPOS FAR* lpwndpos)
void CResizableFrame::OnWindowPosChanging(WINDOWPOS FAR* lpwndpos)
{
if ((lpwndpos->flags & (SWP_NOSIZE|SWP_NOMOVE)) != (SWP_NOSIZE|SWP_NOMOVE))
CFrameWnd::OnWindowPosChanging(lpwndpos);
Expand Down
21 changes: 17 additions & 4 deletions ResizableLib/ResizableLayout.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,19 @@ static char THIS_FILE[]=__FILE__;
#define new DEBUG_NEW
#endif

/*!
* Definition of the standard anchors
*/
const ANCHOR TOP_LEFT(0, 0);
const ANCHOR TOP_CENTER(50, 0);
const ANCHOR TOP_RIGHT(100, 0);
const ANCHOR MIDDLE_LEFT(0, 50);
const ANCHOR MIDDLE_CENTER(50, 50);
const ANCHOR MIDDLE_RIGHT(100, 50);
const ANCHOR BOTTOM_LEFT(0, 100);
const ANCHOR BOTTOM_CENTER(50, 100);
const ANCHOR BOTTOM_RIGHT(100, 100);

/*!
* @internal Constant used to detect clipping and refresh properties
*
Expand Down Expand Up @@ -350,7 +363,7 @@ void CResizableLayout::GetClippingRegion(CRgn* pRegion) const
if (::IsWindowVisible(layout.hWnd))
ClipChildWindow(layout, pRegion);
}

for (POSITION pos = m_listLayoutCB.GetHeadPosition(); pos != NULL;)
{
// get layout info
Expand Down Expand Up @@ -599,7 +612,7 @@ BOOL CResizableLayout::LikesClipping(const LAYOUTINFO& layout) const
return clipping.bLikesClipping;
}

LONG_PTR style = ::GetWindowLongPtr(layout.hWnd, GWL_STYLE);
const LONG_PTR style = ::GetWindowLongPtr(layout.hWnd, GWL_STYLE);

// skip windows that wants background repainted
if (0 == lstrcmp(layout.sWndClass, WC_BUTTON))
Expand Down Expand Up @@ -727,10 +740,10 @@ BOOL CResizableLayout::GetAnchorMargins(HWND hWnd, const CSize &sizeChild, CRect
const LAYOUTINFO& layout = m_listLayout.GetAt(pos);

// augmented size, relative to anchor points
CSize size = sizeChild + layout.marginTopLeft - layout.marginBottomRight;
const CSize size = sizeChild + layout.marginTopLeft - layout.marginBottomRight;

// percent of parent size occupied by this control
CSize percent(layout.anchorBottomRight.cx - layout.anchorTopLeft.cx,
const CSize percent(layout.anchorBottomRight.cx - layout.anchorTopLeft.cx,
layout.anchorBottomRight.cy - layout.anchorTopLeft.cy);

// calculate total margins
Expand Down
22 changes: 11 additions & 11 deletions ResizableLib/ResizableLayout.h
Original file line number Diff line number Diff line change
Expand Up @@ -54,27 +54,27 @@ typedef struct tagANCHOR
} ANCHOR, *PANCHOR, *LPANCHOR;

/*! @defgroup ConstAnchors Alignment Constants
* Define common layout alignment constants for anchor points.
* Declare common layout alignment constants for anchor points.
* @{
*/
//! Anchor to the top-left corner
const ANCHOR TOP_LEFT(0, 0);
extern const ANCHOR TOP_LEFT;
//! Anchor to the top edge and center horizontally
const ANCHOR TOP_CENTER(50, 0);
extern const ANCHOR TOP_CENTER;
//! Anchor to the top-right corner
const ANCHOR TOP_RIGHT(100, 0);
extern const ANCHOR TOP_RIGHT;
//! Anchor to the left edge and center vertically
const ANCHOR MIDDLE_LEFT(0, 50);
extern const ANCHOR MIDDLE_LEFT;
//! Anchor to the center
const ANCHOR MIDDLE_CENTER(50, 50);
extern const ANCHOR MIDDLE_CENTER;
//! Anchor to the right edge and center vertically
const ANCHOR MIDDLE_RIGHT(100, 50);
extern const ANCHOR MIDDLE_RIGHT;
//! Anchor to the bottom-left corner
const ANCHOR BOTTOM_LEFT(0, 100);
extern const ANCHOR BOTTOM_LEFT;
//! Anchor to the bottom edge and center horizontally
const ANCHOR BOTTOM_CENTER(50, 100);
extern const ANCHOR BOTTOM_CENTER;
//! Anchor to the bottom-right corner
const ANCHOR BOTTOM_RIGHT(100, 100);
extern const ANCHOR BOTTOM_RIGHT;
// @}

//! @brief Holds a control layout settings
Expand Down Expand Up @@ -207,7 +207,7 @@ class CResizableLayout
//@{
//! @brief Add anchor points for all the remaining controls to the layout
void AddAllOtherAnchors(ANCHOR anchorTopLeft, ANCHOR anchorBottomRight);

void AddAllOtherAnchors(ANCHOR anchor)
{
AddAllOtherAnchors(anchor, anchor);
Expand Down
10 changes: 5 additions & 5 deletions ResizableLib/ResizableMDIChild.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CResizableMDIChild message handlers

void CResizableMDIChild::OnGetMinMaxInfo(MINMAXINFO FAR* lpMMI)
void CResizableMDIChild::OnGetMinMaxInfo(MINMAXINFO FAR* lpMMI)
{
// MDI should call default implementation
CMDIChildWnd::OnGetMinMaxInfo(lpMMI);
Expand All @@ -64,7 +64,7 @@ void CResizableMDIChild::OnGetMinMaxInfo(MINMAXINFO FAR* lpMMI)
ChainMinMaxInfo(lpMMI, this, pView);
}

void CResizableMDIChild::OnSize(UINT nType, int cx, int cy)
void CResizableMDIChild::OnSize(UINT nType, int cx, int cy)
{
CMDIChildWnd::OnSize(nType, cx, cy);

Expand Down Expand Up @@ -96,7 +96,7 @@ BOOL CResizableMDIChild::EnableSaveRestore(LPCTSTR pszSection, BOOL bRectOnly)
return LoadWindowRect(pszSection, bRectOnly);
}

void CResizableMDIChild::OnDestroy()
void CResizableMDIChild::OnDestroy()
{
if (m_bEnableSaveRestore)
SaveWindowRect(m_sSection, m_bRectOnly);
Expand All @@ -110,7 +110,7 @@ void CResizableMDIChild::OnDestroy()
}


LRESULT CResizableMDIChild::WindowProc(UINT message, WPARAM wParam, LPARAM lParam)
LRESULT CResizableMDIChild::WindowProc(UINT message, WPARAM wParam, LPARAM lParam)
{
if (message != WM_NCCALCSIZE || wParam == 0)
return CMDIChildWnd::WindowProc(message, wParam, lParam);
Expand All @@ -123,7 +123,7 @@ LRESULT CResizableMDIChild::WindowProc(UINT message, WPARAM wParam, LPARAM lPara
return lResult;
}

BOOL CResizableMDIChild::OnNcCreate(LPCREATESTRUCT lpCreateStruct)
BOOL CResizableMDIChild::OnNcCreate(LPCREATESTRUCT lpCreateStruct)
{
if (!CMDIChildWnd::OnNcCreate(lpCreateStruct))
return FALSE;
Expand Down
12 changes: 6 additions & 6 deletions ResizableLib/ResizableMDIFrame.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CResizableMDIFrame message handlers

void CResizableMDIFrame::OnGetMinMaxInfo(MINMAXINFO FAR* lpMMI)
void CResizableMDIFrame::OnGetMinMaxInfo(MINMAXINFO FAR* lpMMI)
{
// MDI should call default implementation
CMDIFrameWnd::OnGetMinMaxInfo(lpMMI);
Expand All @@ -78,7 +78,7 @@ BOOL CResizableMDIFrame::EnableSaveRestore(LPCTSTR pszSection, BOOL bRectOnly)
return LoadWindowRect(pszSection, bRectOnly);
}

void CResizableMDIFrame::OnDestroy()
void CResizableMDIFrame::OnDestroy()
{
if (m_bEnableSaveRestore)
SaveWindowRect(m_sSection, m_bRectOnly);
Expand All @@ -91,17 +91,17 @@ void CResizableMDIFrame::OnDestroy()
CMDIFrameWnd::OnDestroy();
}

BOOL CResizableMDIFrame::OnNcCreate(LPCREATESTRUCT lpCreateStruct)
BOOL CResizableMDIFrame::OnNcCreate(LPCREATESTRUCT lpCreateStruct)
{
if (!CMDIFrameWnd::OnNcCreate(lpCreateStruct))
return FALSE;

MakeResizable(lpCreateStruct);

return TRUE;
}

LRESULT CResizableMDIFrame::WindowProc(UINT message, WPARAM wParam, LPARAM lParam)
LRESULT CResizableMDIFrame::WindowProc(UINT message, WPARAM wParam, LPARAM lParam)
{
if (message != WM_NCCALCSIZE || wParam == 0)
return CMDIFrameWnd::WindowProc(message, wParam, lParam);
Expand All @@ -114,7 +114,7 @@ LRESULT CResizableMDIFrame::WindowProc(UINT message, WPARAM wParam, LPARAM lPara
return lResult;
}

void CResizableMDIFrame::OnWindowPosChanging(WINDOWPOS FAR* lpwndpos)
void CResizableMDIFrame::OnWindowPosChanging(WINDOWPOS FAR* lpwndpos)
{
CMDIFrameWnd::OnWindowPosChanging(lpwndpos);

Expand Down
Loading

0 comments on commit bfbe265

Please sign in to comment.