Skip to content

Commit

Permalink
Merge pull request #11 from irwir/updates
Browse files Browse the repository at this point in the history
Minor changes related to code style
  • Loading branch information
ppescher authored Jan 9, 2019
2 parents c0f2ae8 + 7fca8c3 commit ad4b6ab
Show file tree
Hide file tree
Showing 5 changed files with 40 additions and 48 deletions.
6 changes: 2 additions & 4 deletions ResizableLib/ResizableGrip.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -235,10 +235,8 @@ LRESULT CResizableGrip::CSizeGrip::WindowProc(UINT message,
BeginPaint(&ps) : CDC::FromHandle((HDC)wParam);

// select bitmaps
CBitmap *pOldGrip, *pOldMask;

pOldGrip = m_dcGrip.SelectObject(&m_bmGrip);
pOldMask = m_dcMask.SelectObject(&m_bmMask);
CBitmap *pOldGrip = m_dcGrip.SelectObject(&m_bmGrip);
CBitmap *pOldMask = m_dcMask.SelectObject(&m_bmMask);

// obtain original grip bitmap, make the mask and prepare masked bitmap
CScrollBar::WindowProc(message, (WPARAM)m_dcGrip.GetSafeHdc(), lParam);
Expand Down
21 changes: 8 additions & 13 deletions ResizableLib/ResizableLayout.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -75,18 +75,13 @@ void CResizableLayout::AddAnchor(HWND hWnd, ANCHOR anchorTopLeft, ANCHOR anchorB
// adjust position, if client area has been scrolled
rectChild.OffsetRect(-rectParent.TopLeft());

// go calculate margins
CSize marginTopLeft, marginBottomRight;

// calculate margin for the top-left corner

marginTopLeft.cx = rectChild.left - rectParent.Width() * anchorTopLeft.cx / 100;
marginTopLeft.cy = rectChild.top - rectParent.Height() * anchorTopLeft.cy / 100;
CSize marginTopLeft(rectChild.left - rectParent.Width() * anchorTopLeft.cx / 100,
rectChild.top - rectParent.Height() * anchorTopLeft.cy / 100);

// calculate margin for the bottom-right corner

marginBottomRight.cx = rectChild.right - rectParent.Width() * anchorBottomRight.cx / 100;
marginBottomRight.cy = rectChild.bottom - rectParent.Height() * anchorBottomRight.cy / 100;
CSize marginBottomRight(rectChild.right - rectParent.Width() * anchorBottomRight.cx / 100,
rectChild.bottom - rectParent.Height() * anchorBottomRight.cy / 100);

// prepare the structure
LAYOUTINFO layout(hWnd, anchorTopLeft, marginTopLeft,
Expand Down Expand Up @@ -214,14 +209,12 @@ BOOL CResizableLayout::ArrangeLayoutCallback(LAYOUTINFO& layout) const
*/
void CResizableLayout::ArrangeLayout() const
{
// common vars
UINT uFlags;
CRect rectParent, rectChild;
const INT_PTR count = m_listLayout.GetCount() + m_listLayoutCB.GetCount();

if (count <= 0)
return;

CRect rectParent, rectChild;

// get parent window's rect
GetTotalClientRect(&rectParent);

Expand All @@ -233,6 +226,7 @@ void CResizableLayout::ArrangeLayout() const
// get layout info
const LAYOUTINFO layout = m_listLayout.GetNext(pos);

UINT uFlags;
// calculate new child's position, size and flags for SetWindowPos
CalcNewChildPosition(layout, rectParent, rectChild, &uFlags);

Expand All @@ -255,6 +249,7 @@ void CResizableLayout::ArrangeLayout() const
if (!ArrangeLayoutCallback(layout))
continue;

UINT uFlags;
// calculate new child's position, size and flags for SetWindowPos
CalcNewChildPosition(layout, rectParent, rectChild, &uFlags);

Expand Down
30 changes: 15 additions & 15 deletions ResizableLib/ResizableSheet.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -399,24 +399,24 @@ int CResizableSheet::GetMinWidth()

int max = 0, min = rectSheet.Width();
// search for leftmost and rightmost button margins
for (int i = 0; i < 7; i++)
for (int i = 0; i < 7; ++i)
{
const CWnd* pWnd = GetDlgItem(_propButtons[i]);
// exclude not present or hidden buttons
if (pWnd == NULL || !(pWnd->GetStyle() & WS_VISIBLE))
continue;

// left position is relative to the right border
// of the parent window (negative value)
pWnd->GetWindowRect(&rectWnd);
::MapWindowPoints(NULL, m_hWnd, (LPPOINT)&rectWnd, 2);
const int left = rectSheet.right - rectWnd.left;
const int right = rectSheet.right - rectWnd.right;

if (left > max)
max = left;
if (right < min)
min = right;
if (pWnd != NULL && (pWnd->GetStyle() & WS_VISIBLE))
{
// left position is relative to the right border
// of the parent window (negative value)
pWnd->GetWindowRect(&rectWnd);
::MapWindowPoints(NULL, m_hWnd, (LPPOINT)&rectWnd, 2);
const int left = rectSheet.right - rectWnd.left;
const int right = rectSheet.right - rectWnd.right;

if (left > max)
max = left;
if (right < min)
min = right;
}
}

// sizing border width
Expand Down
1 change: 0 additions & 1 deletion ResizableLib/ResizableSheet.h
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,6 @@ class CResizableSheet : public CPropertySheet, public CResizableLayout,
protected:
virtual LRESULT WindowProc(UINT message, WPARAM wParam, LPARAM lParam);
//}}AFX_VIRTUAL
protected:

// Implementation
public:
Expand Down
30 changes: 15 additions & 15 deletions ResizableLib/ResizableSheetEx.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -579,24 +579,24 @@ int CResizableSheetEx::GetMinWidth()

int max = 0, min = rectSheet.Width();
// search for leftmost and rightmost button margins
for (int i = 0; i < 7; i++)
for (int i = 0; i < 7; ++i)
{
const CWnd* pWnd = GetDlgItem(_propButtons[i]);
// exclude not present or hidden buttons
if (pWnd == NULL || !(pWnd->GetStyle() & WS_VISIBLE))
continue;

// left position is relative to the right border
// of the parent window (negative value)
pWnd->GetWindowRect(&rectWnd);
::MapWindowPoints(NULL, m_hWnd, (LPPOINT)&rectWnd, 2);
const int left = rectSheet.right - rectWnd.left;
const int right = rectSheet.right - rectWnd.right;

if (left > max)
max = left;
if (right < min)
min = right;
if (pWnd != NULL && (pWnd->GetStyle() & WS_VISIBLE))
{
// left position is relative to the right border
// of the parent window (negative value)
pWnd->GetWindowRect(&rectWnd);
::MapWindowPoints(NULL, m_hWnd, (LPPOINT)&rectWnd, 2);
const int left = rectSheet.right - rectWnd.left;
const int right = rectSheet.right - rectWnd.right;
if (left > max)
max = left;
if (right < min)
min = right;
}
}

// sizing border width
Expand Down

0 comments on commit ad4b6ab

Please sign in to comment.