void RecalcLayout(); void ChangePos(HWND hWnd, int dx, int dy); void ChangePos(CWnd* pWnd, int dx, int dy); void ChangeWidth(HWND hWnd, int dx, int nAlignPane); void ChangeWidth(CWnd* pWnd, int dx, int nAlignPane); void ChangeHeight(HWND hWnd, int dy, int nAlignPane); void ChangeHeight(CWnd* pWnd, int dy, int nAlignPane);// Overrides and Protected Methods protected: // ClassWizard generated virtual function overrides //{{AFX_VIRTUAL(CSplitterControl) protected: virtual void PreSubclassWindow(); //}}AFX_VIRTUAL
// Generated message map functions //{{AFX_MSG(CSplitterControl) afx_msg void OnPaint(); afx_msg void OnMouseMove(UINT nFlags, CPoint point); afx_msg BOOL OnSetCursor(CWnd* pWnd, UINT nHitTest, UINT message); afx_msg void OnLButtonDown(UINT nFlags, CPoint point); afx_msg void OnLButtonUp(UINT nFlags, CPoint point); afx_msg void OnMove(int x, int y); //}}AFX_MSG DECLARE_MESSAGE_MAP() HWND GetCommonParent(); void LoadDefaultCursors(); void SetDraggingPos(CPoint& point); void DrawRubberBand(BOOL bDraw); void MoveSplitter(int nDelta); void ResizeControls(int nDelta, int nPanes = PANE_ALL, BOOL bMoveSplitter = TRUE); void ShowControls(int nPane, BOOL bShow); void CalcRange(HWND hWnd, int nPane, int nSplitterPos); int CalcHiddenRange(int nPane, BOOL bShow); void CalcHiddenRange(HWND hWnd, int nPane);// Members private: int m_nType; //horizontal or vertical splitter? BOOL m_bUpdateWhileDragging; //update controls while dragging mouse? BOOL m_bDrawSplitter; //draw splitter seperator? BOOL m_bDrawRubberband; //draw rubberband when dragging mouse? HWND m_hWndParent; //parent of controls (a dialog usualy) std::vector m_ControlsArray; //array of handled controls BOOL m_bNotify; //parent wants notify? BOOL m_bPaneLeftTopVisible; //controls left/top from splitter currently visible? BOOL m_bPaneRightBottomVisible; //controls right/bottom from splitter currently visible? BOOL m_bButtonPressed; //mouse button pressed? BOOL m_bUpdating; //currently updating controls? int m_nBorderLeftTop; //outer border to left/top controls (pixels) int m_nBorderRightBottom; //outer border to right/bottom controls (pixels) int m_nParentPosMin, m_nParentPosMax; //possible range to drag splitter (parent coordinates) int m_nParentPanePosMin, m_nParentPanePosMax; //new splitter range when hiding a pane (parent coordinates) int m_nDistanceLeftTop; //smallest distance from splitter to next left/top control (pixels) int m_nDistanceRightBottom; //smallest distance from splitter to next right/bottom control (pixels) int m_nDragPosStart; //start position when dragging splitter (screen coordinates) int m_nDragPosStartOfset; //ofset from left/top edge of splitter (pixels) int m_nDragPosX, m_nDragPosY; //current position while dragging (screen coordinates) int m_nDraggedDelta; //already dragged distance (pixels) HCURSOR m_hCursorHorizontal; //used cursors HCURSOR m_hCursorVertical; };///////////////////////////////////////////////////////////////////////////////{{AFX_INSERT_LOCATION}} // Microsoft Visual C++ will insert additional declarations immediately before the previous line.#endif // !defined(AFX_SPLITTERCONTROL_H__C5E28DD6_B347_44F2_9DA0_20C4CFD50B5D__INCLUDED_)
#if !defined(AFX_SPLITTERCONTROL_H__C5E28DD6_B347_44F2_9DA0_20C4CFD50B5D__INCLUDED_)
#define AFX_SPLITTERCONTROL_H__C5E28DD6_B347_44F2_9DA0_20C4CFD50B5D__INCLUDED_#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
// SplitterControl.h : header file
////#include // STL Standard Template Library (add to StdAfx.h)/////////////////////////////////////////////////////////////////////////////
// CSplitterControlclass CSplitterControl : public CStatic
{
// Construction
public:
CSplitterControl();
virtual ~CSplitterControl();
//type of splitter
enum { TYPE_VERTICAL = 0, TYPE_HORIZONTAL };
enum { PANE_NONE = 0, //orientation of handled control
PANE_LEFT = 1, PANE_RIGHT,
PANE_TOP = 1, PANE_BOTTOM,
PANE_ALL = 3
};
//action when dragging splitter
enum { DRAGGING_NOCHANGE = 0, DRAGGING_RESIZE, DRAGGING_REPOSITION }; typedef struct { //handled control entry
HWND hWnd; //window handle of control
int nPane; //orientation of control (left/right or top/bottom from splitter)
int nDraggingAction; //resize, reposition, etc control?
} SCO_SplitterEntry;// Operations
public:
void GetType(BOOL& bUpdateWhileDragging, BOOL& bDrawSplitter, BOOL& bDrawRubberband) const
{ bUpdateWhileDragging = m_bUpdateWhileDragging;
bDrawSplitter = m_bDrawSplitter;
bDrawRubberband = m_bDrawRubberband;
}
void SetType(BOOL bUpdateWhileDragging = TRUE, BOOL bDrawSplitter = FALSE, BOOL bDrawRubberband = FALSE)
{ m_bUpdateWhileDragging = bUpdateWhileDragging;
m_bDrawSplitter = bDrawSplitter;
m_bDrawRubberband = bDrawRubberband;
}
void SetBorder(int nBorderLeftTop = 0, int nBorderRightBottom = 0);
void SetRangeRelative(int nDiffNegative, int nDiffPositive);
void SetResize(BOOL bLeft, BOOL bTop, BOOL bWidth, BOOL bHeight);
int GetSplitterPos();
void SetSplitterPos(int nPos); BOOL Add(HWND hWnd, int nPane, BOOL bResize = TRUE, BOOL bDragChange = TRUE);
BOOL Add(CWnd* pWnd, int nPane, BOOL bResize = TRUE, BOOL bDragChange = TRUE);
BOOL Add(UINT nID, int nPane, BOOL bResize = TRUE, BOOL bDragChange = TRUE);
BOOL Remove(HWND hWnd);
BOOL Remove(CWnd* pWnd);
BOOL Remove(UINT nID);
BOOL IsChildControl(HWND hWnd) const;
BOOL IsChildControl(CWnd* pWnd) const;
BOOL IsChildControl(UINT nID) const;
BOOL ShowPane(int nPane, BOOL bShow = TRUE);
BOOL HidePane(int nPane) { return ShowPane(nPane, FALSE); }
int GetHiddenPane() const;
int GetOtherPane(int nPane) const;
BOOL IsValidPane(int nPane) const { return nPane>=PANE_LEFT && nPane<=PANE_BOTTOM; }
BOOL IsPaneVisible(int nPane) const;
void RecalcLayout();
void ChangePos(HWND hWnd, int dx, int dy);
void ChangePos(CWnd* pWnd, int dx, int dy);
void ChangeWidth(HWND hWnd, int dx, int nAlignPane);
void ChangeWidth(CWnd* pWnd, int dx, int nAlignPane);
void ChangeHeight(HWND hWnd, int dy, int nAlignPane);
void ChangeHeight(CWnd* pWnd, int dy, int nAlignPane);// Overrides and Protected Methods
protected:
// ClassWizard generated virtual function overrides
//{{AFX_VIRTUAL(CSplitterControl)
protected:
virtual void PreSubclassWindow();
//}}AFX_VIRTUAL
//{{AFX_MSG(CSplitterControl)
afx_msg void OnPaint();
afx_msg void OnMouseMove(UINT nFlags, CPoint point);
afx_msg BOOL OnSetCursor(CWnd* pWnd, UINT nHitTest, UINT message);
afx_msg void OnLButtonDown(UINT nFlags, CPoint point);
afx_msg void OnLButtonUp(UINT nFlags, CPoint point);
afx_msg void OnMove(int x, int y);
//}}AFX_MSG
DECLARE_MESSAGE_MAP() HWND GetCommonParent();
void LoadDefaultCursors();
void SetDraggingPos(CPoint& point);
void DrawRubberBand(BOOL bDraw);
void MoveSplitter(int nDelta);
void ResizeControls(int nDelta, int nPanes = PANE_ALL, BOOL bMoveSplitter = TRUE);
void ShowControls(int nPane, BOOL bShow);
void CalcRange(HWND hWnd, int nPane, int nSplitterPos);
int CalcHiddenRange(int nPane, BOOL bShow);
void CalcHiddenRange(HWND hWnd, int nPane);// Members
private:
int m_nType; //horizontal or vertical splitter?
BOOL m_bUpdateWhileDragging; //update controls while dragging mouse?
BOOL m_bDrawSplitter; //draw splitter seperator?
BOOL m_bDrawRubberband; //draw rubberband when dragging mouse? HWND m_hWndParent; //parent of controls (a dialog usualy)
std::vector m_ControlsArray; //array of handled controls
BOOL m_bNotify; //parent wants notify?
BOOL m_bPaneLeftTopVisible; //controls left/top from splitter currently visible?
BOOL m_bPaneRightBottomVisible; //controls right/bottom from splitter currently visible?
BOOL m_bButtonPressed; //mouse button pressed?
BOOL m_bUpdating; //currently updating controls? int m_nBorderLeftTop; //outer border to left/top controls (pixels)
int m_nBorderRightBottom; //outer border to right/bottom controls (pixels) int m_nParentPosMin, m_nParentPosMax; //possible range to drag splitter (parent coordinates)
int m_nParentPanePosMin, m_nParentPanePosMax; //new splitter range when hiding a pane (parent coordinates)
int m_nDistanceLeftTop; //smallest distance from splitter to next left/top control (pixels)
int m_nDistanceRightBottom; //smallest distance from splitter to next right/bottom control (pixels) int m_nDragPosStart; //start position when dragging splitter (screen coordinates)
int m_nDragPosStartOfset; //ofset from left/top edge of splitter (pixels)
int m_nDragPosX, m_nDragPosY; //current position while dragging (screen coordinates)
int m_nDraggedDelta; //already dragged distance (pixels) HCURSOR m_hCursorHorizontal; //used cursors
HCURSOR m_hCursorVertical;
};///////////////////////////////////////////////////////////////////////////////{{AFX_INSERT_LOCATION}}
// Microsoft Visual C++ will insert additional declarations immediately before the previous line.#endif // !defined(AFX_SPLITTERCONTROL_H__C5E28DD6_B347_44F2_9DA0_20C4CFD50B5D__INCLUDED_)