123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308 |
- /////////////////////////////////////////////////////////////////////////
- //
- // CDockPageBar Version 1.2
- //
- // Created: Mar 16, 2004
- //
- /////////////////////////////////////////////////////////////////////////
- // Copyright (C) 2004 by Cuick. All rights reserved.
- //
- // This code is free for personal and commercial use, providing this
- // notice remains intact in the source files and all eventual changes are
- // clearly marked with comments.
- //
- // Send bug reports, bug fixes, enhancements, requests, flames, etc. to
- // Cuick@163.net
- /////////////////////////////////////////////////////////////////////////
- #if !defined(AFX_DOCKPAGEBAR_H__5125E626_E472_4F93_AC8E_20F121A6D1B9__INCLUDED_)
- #define AFX_DOCKPAGEBAR_H__5125E626_E472_4F93_AC8E_20F121A6D1B9__INCLUDED_
- #if _MSC_VER > 1000
- #pragma once
- #endif // _MSC_VER > 1000
- // DockPageBar.h : header file
- //
- #define HTSTUD 22
- #define HTHIDE 23
- #define HTGRIPPER 24
- #define HTITEMBUTTON 25
- #define HTNCCLIENT 26
- #define CAPTION_HEIGHT 16
- #define ITEMBUTTON_HEIGHT 24
- #define WM_MY_INVALIDATE WM_USER+ 201
- #define WM_MY_SIZECHANGE WM_USER+ 202
- #define WM_MY_SIZECHANGE2 WM_USER+ 203
- #define GET_MAIN_FRAME_PURE_CLIENT(a,b) if((a)->IsKindOf(RUNTIME_CLASS(CMDIAutoHideFrame))) \
- ((CMDIAutoHideFrame*)(a))->GetPureClientRect(b); \
- else if((a)->IsKindOf(RUNTIME_CLASS(CAutoHideFrame))) \
- ((CAutoHideFrame*)(a))->GetPureClientRect(b);
- #define BRING_CLIENT_WINDOW_TO_BOTTOM(a) if((a)->IsKindOf(RUNTIME_CLASS(CAutoHideFrame))) \
- ((CAutoHideFrame*)(a))->BringClientWindowToBottom(); \
- else if((a)->IsKindOf(RUNTIME_CLASS(CMDIAutoHideFrame))) \
- ((CMDIAutoHideFrame*)(a))->BringClientWindowToBottom(); \
- ///////////////////////////////////////////////////////////////////////////
- // 标题栏按钮
- class CMyButton
- {
- public:
- CMyButton();
- void Move(CPoint ptTo) {ptOrg = ptTo; };
- virtual CRect GetRect() { return CRect(ptOrg, CSize(13, 13)); };
- virtual void Paint(CDC* pDC, BOOL isActive);
- BOOL bPushed;
- BOOL bRaised;
- protected:
- CPoint ptOrg;
- };
- //关闭按钮
- class CCloseButton : public CMyButton
- {
- public:
- virtual void Paint(CDC* pDC, BOOL isActive);
- };
- //图钉按钮
- class CStudButton : public CMyButton
- {
- public:
- CStudButton();
- BOOL bFloat;
- virtual void Paint(CDC* pDC, BOOL isActive);
- };
- ///////////////////////////////////////////////////////////////////////////
- // 标签页
- class CPageItem
- {
- public:
- CWnd* m_pWnd; //窗口,可以为NULL
- CString m_sText; //文字
- HICON m_hIcon; //图标
- UINT m_TabWidth; //标签宽度
- CRect m_rect; //标签位置
- CPageItem() { m_pWnd = NULL; }
- public:
- void Draw(CDC *pDC,BOOL bActive);
- };
- /////////////////////////////////////////////////////////////////////////////
- // CDockPageBar control bar
- #ifndef baseCDockPageBar
- #define baseCDockPageBar CSizingControlBar
- #endif
- class CDockPageBar : public baseCDockPageBar
- {
- DECLARE_DYNAMIC(CDockPageBar);
- // Construction
- public:
- CDockPageBar();
- // Attributes
- public:
- int m_cyGripper;
- // Operations
- public:
-
- // Overrides
- // ClassWizard generated virtual function overrides
- virtual BOOL HasGripper() const;
- virtual void UpdateSize();
- virtual void OnUpdateCmdUI(CFrameWnd* pTarget, BOOL bDisableIfNoHndler);
- virtual ~CDockPageBar();
- // Implementation
- public:
- CPtrList m_PageList;
- CPtrList m_pDPBContext; //hengai
- int m_nActivePage;
- BOOL m_isActive;
- bool m_bDrawTitleBar;//是否画菜单栏
- void OnStudClick();
- void EnableDocking(DWORD dwDockStyle);
- BOOL AddPage(CDockPageBar* dockPageBar);
- BOOL AddPage(CPageItem *pPageItem);
- BOOL AddPage(CWnd *pWnd, LPCTSTR sText, UINT IconID);
- CPageItem* GetPageItem(int nIndex);
- CPageItem* DeletePage();
- void DEFLECT_RECT_FOR_STATIC_LINK(CRect &rect);
- CSize & GetHorSize(){ return m_szHorz; }
- CSize & GetVerSize(){ return m_szVert; }
- // Generated message map functions
- protected:
- CRect m_itemGroupRect;
- CString m_Title;
- CCloseButton m_biHide;
- CStudButton m_stud;
- CFont m_font;
- void Move(CPoint pt);
- void CanDrag(CPoint pt);
- void StartDrag(CPoint pt);
- void SetActivePage(int nIndex);
- void UpdateWindow();
- void GetItemGroupRect(LPRECT lpRect);
- void GetCaptionRect(LPRECT lpRect);
-
- // implementation helpers
- virtual void NcCalcClient(LPRECT pRc, UINT nDockBarID);
- virtual void NcPaintGripper(CDC* pDC, CRect rcClient);
- afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct);
- afx_msg void OnSize(UINT nType, int cx, int cy);
- afx_msg void OnNcPaint();
- afx_msg LRESULT OnNcHitTest(CPoint point);
- afx_msg void OnNcLButtonUp(UINT nHitTest, CPoint point);
- afx_msg void OnNcLButtonDown(UINT nFlags, CPoint point);
- afx_msg void OnNcLButtonDblClk(UINT nFlags, CPoint point);
- afx_msg void OnDestroy();
- DECLARE_MESSAGE_MAP()
- virtual LRESULT WindowProc(UINT message, WPARAM wParam, LPARAM lParam);
- };
- class CcHnDockPageBar : public baseCDockPageBar
- {
- DECLARE_DYNAMIC(CcHnDockPageBar);
- // Construction
- public:
- CcHnDockPageBar();
- // Attributes
- public:
- int m_cyGripper;
- // Operations
- public:
-
- // Overrides
- // ClassWizard generated virtual function overrides
- //{{AFX_VIRTUAL(CDockPageBar)
- virtual BOOL HasGripper() const;
- virtual void UpdateSize();
- virtual void OnUpdateCmdUI(CFrameWnd* pTarget, BOOL bDisableIfNoHndler);
- virtual ~CcHnDockPageBar();
- //}}AFX_VIRTUAL
- // Implementation
- public:
- CPtrList m_PageList;
- CPtrList m_pDPBContext; //hengai
- int m_nActivePage;
- BOOL m_isActive;
- bool m_bDrawStudBtn;
- void OnStudClick();
- void EnableDocking(DWORD dwDockStyle);
- BOOL AddPage(CcHnDockPageBar* dockPageBar);
- BOOL AddPage(CPageItem *pPageItem);
- BOOL AddPage(CWnd *pWnd, LPCTSTR sText, UINT IconID);
- CPageItem* GetPageItem(int nIndex);
- CPageItem* DeletePage();
- void DEFLECT_RECT_FOR_STATIC_LINK(CRect &rect);
- CSize & GetHorSize(){ return m_szHorz; }
- CSize & GetVerSize(){ return m_szVert; }
- // Generated message map functions
- protected:
- CRect m_itemGroupRect;
- CString m_Title;
- CCloseButton m_biHide;
- CStudButton m_stud;
- CFont m_font;
- void Move(CPoint pt);
- void CanDrag(CPoint pt);
- void StartDrag(CPoint pt);
- void SetActivePage(int nIndex);
- void UpdateWindow();
- void GetItemGroupRect(LPRECT lpRect);
- void GetCaptionRect(LPRECT lpRect);
-
- // implementation helpers
- virtual void NcCalcClient(LPRECT pRc, UINT nDockBarID);
- virtual void NcPaintGripper(CDC* pDC, CRect rcClient);
- //{{AFX_MSG(CDockPageBar)
- afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct);
- afx_msg void OnSize(UINT nType, int cx, int cy);
- afx_msg void OnNcPaint();
- afx_msg LRESULT OnNcHitTest(CPoint point);
- afx_msg void OnNcLButtonUp(UINT nHitTest, CPoint point);
- afx_msg void OnNcLButtonDown(UINT nFlags, CPoint point);
- afx_msg void OnNcLButtonDblClk(UINT nFlags, CPoint point);
- afx_msg void OnDestroy();
- //}}AFX_MSG
- DECLARE_MESSAGE_MAP()
- virtual LRESULT WindowProc(UINT message, WPARAM wParam, LPARAM lParam);
- };
- /////////////////////////////////////////////////////////////////////////////
- // CDockPageBarContext dockcontext
- #ifndef LAYOUT_LTR
- #define LAYOUT_LTR 0x00000000
- #endif
- class CDockPageBarContext : public CDockContext
- {
- public:
- // Construction
- CDockPageBarContext(CControlBar* pBar) : CDockContext(pBar)
- {
- m_curRect.left=m_curRect.right=0;
- m_curRect.top=m_curRect.bottom=0;
- m_bAdvancedDock=FALSE;
- m_endDragDockStruct.dwDockStyle=0;
- m_endDragDockStruct.pDockPageBar=NULL;
- }
-
- typedef struct END_DRAG_DOCK_STRUCT
- {
- DWORD dwDockStyle;
- CDockPageBar* pDockPageBar;
- }END_DRAG_DOCK_STRUCT;
- BOOL m_isMe;
- BOOL m_isPage;
- CDockPageBar* m_pTgDockPage;
- END_DRAG_DOCK_STRUCT m_endDragDockStruct;
- virtual ~CDockPageBarContext(void);
- void FreeAll();
- // Drag Operations
- virtual void StartDrag(CPoint pt);
- virtual BOOL Track();
- virtual void Move(CPoint pt);
- virtual void EndDrag();
- void DrawFocusRect(BOOL bRemoveRect = FALSE);
- protected:
- CPtrList m_pDPBar; //hengai
- CRect m_addRect;
- CRect m_curRect;
- BOOL m_bAdvancedDock;
- CDockPageBar* CreateNewBar();
- BOOL isDockPage(CPoint pt);
- CDockPageBar * TryToGetDockPageBar(POINT pt);
- };
- #endif // !defined(AFX_DOCKPAGEBAR_H__5125E626_E472_4F93_AC8E_20F121A6D1B9__INCLUDED_)
|