diff options
| author | Andrew <forkk@forkk.net> | 2013-12-09 12:04:05 -0600 |
|---|---|---|
| committer | Andrew <forkk@forkk.net> | 2013-12-09 12:04:05 -0600 |
| commit | 7f52bed9e3f559adcbcf3f3c1c7ac2251964db8c (patch) | |
| tree | 52097b57dc7d18ec4e35ef3a8e554af2d91545e8 /mmc_updater/depends/win32cpp/docking.h | |
| parent | 9410dd042ea62224fa3e0eb3b525abbdf0c316ee (diff) | |
| parent | 220e07aef4a34dca9f31ae0c5bb994e5c594125d (diff) | |
| download | PrismLauncher-7f52bed9e3f559adcbcf3f3c1c7ac2251964db8c.tar.gz PrismLauncher-7f52bed9e3f559adcbcf3f3c1c7ac2251964db8c.tar.bz2 PrismLauncher-7f52bed9e3f559adcbcf3f3c1c7ac2251964db8c.zip | |
Merge branch 'feature_updater' into develop
Diffstat (limited to 'mmc_updater/depends/win32cpp/docking.h')
| -rw-r--r-- | mmc_updater/depends/win32cpp/docking.h | 4214 |
1 files changed, 4214 insertions, 0 deletions
diff --git a/mmc_updater/depends/win32cpp/docking.h b/mmc_updater/depends/win32cpp/docking.h new file mode 100644 index 00000000..9e7c4486 --- /dev/null +++ b/mmc_updater/depends/win32cpp/docking.h @@ -0,0 +1,4214 @@ +// Win32++ Version 7.2 +// Released: 5th AUgust 2011 +// +// David Nash +// email: dnash@bigpond.net.au +// url: https://sourceforge.net/projects/win32-framework +// +// +// Copyright (c) 2005-2011 David Nash +// +// Permission is hereby granted, free of charge, to +// any person obtaining a copy of this software and +// associated documentation files (the "Software"), +// to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, +// merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom +// the Software is furnished to do so, subject to the +// following conditions: +// +// The above copyright notice and this permission notice +// shall be included in all copies or substantial portions +// of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF +// ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED +// TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A +// PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT +// SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR +// ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN +// ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE +// OR OTHER DEALINGS IN THE SOFTWARE. +// +//////////////////////////////////////////////////////// + + +/////////////////////////////////////////////////////// +// docking.h +// Declaration of the CDocker class + +#ifndef _WIN32XX_DOCKING_H_ +#define _WIN32XX_DOCKING_H_ + + +#include "wincore.h" +#include "gdi.h" +#include "toolbar.h" +#include "tab.h" +#include "frame.h" +#include "default_resource.h" + + +// Docking Styles +#define DS_DOCKED_LEFT 0x0001 // Dock the child left +#define DS_DOCKED_RIGHT 0x0002 // Dock the child right +#define DS_DOCKED_TOP 0x0004 // Dock the child top +#define DS_DOCKED_BOTTOM 0x0008 // Dock the child bottom +#define DS_NO_DOCKCHILD_LEFT 0x0010 // Prevent a child docking left +#define DS_NO_DOCKCHILD_RIGHT 0x0020 // Prevent a child docking right +#define DS_NO_DOCKCHILD_TOP 0x0040 // Prevent a child docking at the top +#define DS_NO_DOCKCHILD_BOTTOM 0x0080 // Prevent a child docking at the bottom +#define DS_NO_RESIZE 0x0100 // Prevent resizing +#define DS_NO_CAPTION 0x0200 // Prevent display of caption when docked +#define DS_NO_CLOSE 0x0400 // Prevent closing of a docker while docked +#define DS_NO_UNDOCK 0x0800 // Prevent undocking and dock closing +#define DS_CLIENTEDGE 0x1000 // Has a 3D border when docked +#define DS_FIXED_RESIZE 0x2000 // Perfomed a fixed resize instead of a proportional resize on dock children +#define DS_DOCKED_CONTAINER 0x4000 // Dock a container within a container +#define DS_DOCKED_LEFTMOST 0x10000 // Leftmost outer docking +#define DS_DOCKED_RIGHTMOST 0x20000 // Rightmost outer docking +#define DS_DOCKED_TOPMOST 0x40000 // Topmost outer docking +#define DS_DOCKED_BOTTOMMOST 0x80000 // Bottommost outer docking + +// Required for Dev-C++ +#ifndef TME_NONCLIENT + #define TME_NONCLIENT 0x00000010 +#endif +#ifndef TME_LEAVE + #define TME_LEAVE 0x000000002 +#endif +#ifndef WM_NCMOUSELEAVE + #define WM_NCMOUSELEAVE 0x000002A2 +#endif + +namespace Win32xx +{ + // Class declarations + class CDockContainer; + class CDocker; + + typedef Shared_Ptr<CDocker> DockPtr; + + struct ContainerInfo + { + TCHAR szTitle[MAX_MENU_STRING]; + int iImage; + CDockContainer* pContainer; + }; + + /////////////////////////////////////// + // Declaration of the CDockContainer class + // A CDockContainer is a CTab window. A CTab has a view window, and optionally a toolbar control. + // A top level CDockContainer can contain other CDockContainers. The view for each container + // (including the top level container) along with possibly its toolbar, is displayed + // within the container parent's view page. + class CDockContainer : public CTab + { + public: + + // Nested class. This is the Wnd for the window displayed over the client area + // of the tab control. The toolbar and view window are child windows of the + // viewpage window. Only the ViewPage of the parent CDockContainer is displayed. It's + // contents are updated with the view window of the relevant container whenever + // a different tab is selected. + class CViewPage : public CWnd + { + + public: + CViewPage() : m_pView(NULL), m_pTab(NULL) {} + virtual ~CViewPage() {} + virtual CToolBar& GetToolBar() const {return (CToolBar&)m_ToolBar;} + virtual CWnd* GetView() const {return m_pView;} + virtual BOOL OnCommand(WPARAM wParam, LPARAM lParam); + virtual void OnCreate(); + virtual LRESULT OnNotify(WPARAM wParam, LPARAM lParam); + virtual void PreRegisterClass(WNDCLASS &wc); + virtual void RecalcLayout(); + virtual void SetView(CWnd& wndView); + virtual LRESULT WndProcDefault(UINT uMsg, WPARAM wParam, LPARAM lParam); + + CWnd* GetTabCtrl() const { return m_pTab;} + + private: + CToolBar m_ToolBar; + tString m_tsTooltip; + CWnd* m_pView; + CWnd* m_pTab; + }; + + public: + CDockContainer(); + virtual ~CDockContainer(); + virtual void AddContainer(CDockContainer* pContainer); + virtual void AddToolBarButton(UINT nID, BOOL bEnabled = TRUE); + virtual CDockContainer* GetContainerFromIndex(UINT nPage); + virtual CDockContainer* GetContainerFromView(CWnd* pView) const; + virtual int GetContainerIndex(CDockContainer* pContainer); + virtual SIZE GetMaxTabTextSize(); + virtual CViewPage& GetViewPage() const { return (CViewPage&)m_ViewPage; } + virtual void RecalcLayout(); + virtual void RemoveContainer(CDockContainer* pWnd); + virtual void SelectPage(int nPage); + virtual void SetTabSize(); + virtual void SetupToolBar(); + + // Attributes + CDockContainer* GetActiveContainer() const {return GetContainerFromView(GetActiveView());} + CWnd* GetActiveView() const; + std::vector<ContainerInfo>& GetAllContainers() const {return m_pContainerParent->m_vContainerInfo;} + CDockContainer* GetContainerParent() const { return m_pContainerParent; } + CString& GetDockCaption() const { return (CString&)m_csCaption; } + HICON GetTabIcon() const { return m_hTabIcon; } + LPCTSTR GetTabText() const { return m_tsTabText.c_str(); } + virtual CToolBar& GetToolBar() const { return GetViewPage().GetToolBar(); } + CWnd* GetView() const { return GetViewPage().GetView(); } + void SetActiveContainer(CDockContainer* pContainer); + void SetDockCaption(LPCTSTR szCaption) { m_csCaption = szCaption; } + void SetTabIcon(HICON hTabIcon) { m_hTabIcon = hTabIcon; } + void SetTabIcon(UINT nID_Icon); + void SetTabIcon(int i, HICON hIcon) { CTab::SetTabIcon(i, hIcon); } + void SetTabText(LPCTSTR szText) { m_tsTabText = szText; } + void SetTabText(UINT nTab, LPCTSTR szText); + void SetView(CWnd& Wnd); + + protected: + virtual void OnCreate(); + virtual void OnLButtonDown(WPARAM wParam, LPARAM lParam); + virtual void OnLButtonUp(WPARAM wParam, LPARAM lParam); + virtual void OnMouseLeave(WPARAM wParam, LPARAM lParam); + virtual LRESULT OnNotifyReflect(WPARAM wParam, LPARAM lParam); + virtual void PreCreate(CREATESTRUCT &cs); + virtual LRESULT WndProcDefault(UINT uMsg, WPARAM wParam, LPARAM lParam); + + private: + std::vector<ContainerInfo> m_vContainerInfo; + tString m_tsTabText; + CString m_csCaption; + CViewPage m_ViewPage; + int m_iCurrentPage; + CDockContainer* m_pContainerParent; + HICON m_hTabIcon; + int m_nTabPressed; + + }; + + typedef struct DRAGPOS + { + NMHDR hdr; + POINT ptPos; + UINT DockZone; + } *LPDRAGPOS; + + + ///////////////////////////////////////// + // Declaration of the CDocker class + // A CDocker window allows other CDocker windows to be "docked" inside it. + // A CDocker can dock on the top, left, right or bottom side of a parent CDocker. + // There is no theoretical limit to the number of CDockers within CDockers. + class CDocker : public CWnd + { + public: + // A nested class for the splitter bar that seperates the docked panes. + class CDockBar : public CWnd + { + public: + CDockBar(); + virtual ~CDockBar(); + virtual void OnDraw(CDC* pDC); + virtual void PreCreate(CREATESTRUCT &cs); + virtual void PreRegisterClass(WNDCLASS& wc); + virtual void SendNotify(UINT nMessageID); + virtual void SetColor(COLORREF color); + virtual LRESULT WndProcDefault(UINT uMsg, WPARAM wParam, LPARAM lParam); + + CDocker* GetDock() {return m_pDock;} + int GetWidth() {return m_DockBarWidth;} + void SetDock(CDocker* pDock) {m_pDock = pDock;} + void SetWidth(int nWidth) {m_DockBarWidth = nWidth;} + + private: + CDockBar(const CDockBar&); // Disable copy construction + CDockBar& operator = (const CDockBar&); // Disable assignment operator + + CDocker* m_pDock; + DRAGPOS m_DragPos; + CBrush m_brBackground; + int m_DockBarWidth; + }; + + // A nested class for the window inside a CDocker which includes all of this docked client. + // It's the remaining part of the CDocker that doesn't belong to the CDocker's children. + // The Docker's view window is a child window of CDockClient. + class CDockClient : public CWnd + { + public: + CDockClient(); + virtual ~CDockClient() {} + virtual void Draw3DBorder(RECT& Rect); + virtual void DrawCaption(WPARAM wParam); + virtual void DrawCloseButton(CDC& DrawDC, BOOL bFocus); + virtual CRect GetCloseRect(); + virtual void SendNotify(UINT nMessageID); + + CString& GetCaption() const { return (CString&)m_csCaption; } + CWnd* GetView() const { return m_pView; } + void SetDock(CDocker* pDock) { m_pDock = pDock;} + void SetCaption(LPCTSTR szCaption) { m_csCaption = szCaption; } + void SetCaptionColors(COLORREF Foregnd1, COLORREF Backgnd1, COLORREF ForeGnd2, COLORREF BackGnd2); + void SetClosePressed() { m_IsClosePressed = TRUE; } + void SetView(CWnd& Wnd) { m_pView = &Wnd; } + + protected: + virtual void OnLButtonDown(WPARAM wParam, LPARAM lParam); + virtual void OnLButtonUp(WPARAM wParam, LPARAM lParam); + virtual void OnMouseActivate(WPARAM wParam, LPARAM lParam); + virtual void OnMouseMove(WPARAM wParam, LPARAM lParam); + virtual void OnNCCalcSize(WPARAM& wParam, LPARAM& lParam); + virtual LRESULT OnNCHitTest(WPARAM wParam, LPARAM lParam); + virtual LRESULT OnNCLButtonDown(WPARAM wParam, LPARAM lParam); + virtual void OnNCMouseLeave(WPARAM wParam, LPARAM lParam); + virtual LRESULT OnNCMouseMove(WPARAM wParam, LPARAM lParam); + virtual LRESULT OnNCPaint(WPARAM wParam, LPARAM lParam); + virtual void OnWindowPosChanged(WPARAM wParam, LPARAM lParam); + virtual void PreRegisterClass(WNDCLASS& wc); + virtual void PreCreate(CREATESTRUCT& cs); + virtual LRESULT WndProcDefault(UINT uMsg, WPARAM wParam, LPARAM lParam); + + private: + CDockClient(const CDockClient&); // Disable copy construction + CDockClient& operator = (const CDockClient&); // Disable assignment operator + + CString m_csCaption; + CPoint m_Oldpt; + CDocker* m_pDock; + CWnd* m_pView; + BOOL m_IsClosePressed; + BOOL m_bOldFocus; + BOOL m_bCaptionPressed; + BOOL m_IsTracking; + COLORREF m_Foregnd1; + COLORREF m_Backgnd1; + COLORREF m_Foregnd2; + COLORREF m_Backgnd2; + }; + + // This nested class is used to indicate where a window could dock by + // displaying a blue tinted window. + class CDockHint : public CWnd + { + public: + CDockHint(); + virtual ~CDockHint(); + virtual RECT CalcHintRectContainer(CDocker* pDockTarget); + virtual RECT CalcHintRectInner(CDocker* pDockTarget, CDocker* pDockDrag, UINT uDockSide); + virtual RECT CalcHintRectOuter(CDocker* pDockDrag, UINT uDockSide); + virtual void DisplayHint(CDocker* pDockTarget, CDocker* pDockDrag, UINT uDockSide); + virtual void OnDraw(CDC* pDC); + virtual void PreCreate(CREATESTRUCT &cs); + virtual void ShowHintWindow(CDocker* pDockTarget, CRect rcHint); + + private: + CDockHint(const CDockHint&); // Disable copy construction + CDockHint& operator = (const CDockHint&); // Disable assignment operator + + CBitmap m_bmBlueTint; + UINT m_uDockSideOld; + }; + + class CTarget : public CWnd + { + public: + CTarget() {} + virtual ~CTarget(); + virtual void OnDraw(CDC* pDC); + virtual void PreCreate(CREATESTRUCT &cs); + + protected: + CBitmap m_bmImage; + + private: + CTarget(const CTarget&); // Disable copy construction + CTarget& operator = (const CTarget&); // Disable assignment operator + }; + + class CTargetCentre : public CTarget + { + public: + CTargetCentre(); + virtual ~CTargetCentre(); + virtual void OnDraw(CDC* pDC); + virtual void OnCreate(); + virtual BOOL CheckTarget(LPDRAGPOS pDragPos); + BOOL IsOverContainer() { return m_bIsOverContainer; } + + private: + CTargetCentre(const CTargetCentre&); // Disable copy construction + CTargetCentre& operator = (const CTargetCentre&); // Disable assignment operator + + BOOL m_bIsOverContainer; + CDocker* m_pOldDockTarget; + }; + + class CTargetLeft : public CTarget + { + public: + CTargetLeft() {m_bmImage.LoadImage(IDW_SDLEFT,0,0,0);} + virtual BOOL CheckTarget(LPDRAGPOS pDragPos); + + private: + CTargetLeft(const CTargetLeft&); // Disable copy construction + CTargetLeft& operator = (const CTargetLeft&); // Disable assignment operator + }; + + class CTargetTop : public CTarget + { + public: + CTargetTop() {m_bmImage.LoadImage(IDW_SDTOP,0,0,0);} + virtual BOOL CheckTarget(LPDRAGPOS pDragPos); + private: + CTargetTop(const CTargetTop&); // Disable copy construction + CTargetTop& operator = (const CTargetTop&); // Disable assignment operator + }; + + class CTargetRight : public CTarget + { + public: + CTargetRight() {m_bmImage.LoadImage(IDW_SDRIGHT,0,0,0);} + virtual BOOL CheckTarget(LPDRAGPOS pDragPos); + + private: + CTargetRight(const CTargetRight&); // Disable copy construction + CTargetRight& operator = (const CTargetRight&); // Disable assignment operator + }; + + class CTargetBottom : public CTarget + { + public: + CTargetBottom() {m_bmImage.LoadImage(IDW_SDBOTTOM,0,0,0);} + virtual BOOL CheckTarget(LPDRAGPOS pDragPos); + }; + + friend class CTargetCentre; + friend class CTargetLeft; + friend class CTargetTop; + friend class CTargetRight; + friend class CTargetBottom; + friend class CDockClient; + friend class CDockContainer; + + public: + // Operations + CDocker(); + virtual ~CDocker(); + virtual CDocker* AddDockedChild(CDocker* pDocker, DWORD dwDockStyle, int DockSize, int nDockID = 0); + virtual CDocker* AddUndockedChild(CDocker* pDocker, DWORD dwDockStyle, int DockSize, RECT rc, int nDockID = 0); + virtual void Close(); + virtual void CloseAllDockers(); + virtual void Dock(CDocker* pDocker, UINT uDockSide); + virtual void DockInContainer(CDocker* pDock, DWORD dwDockStyle); + virtual CDockContainer* GetContainer() const; + virtual CDocker* GetActiveDocker() const; + virtual CDocker* GetDockAncestor() const; + virtual CDocker* GetDockFromID(int n_DockID) const; + virtual CDocker* GetDockFromPoint(POINT pt) const; + virtual CDocker* GetDockFromView(CWnd* pView) const; + virtual CDocker* GetTopmostDocker() const; + virtual int GetDockSize() const; + virtual CTabbedMDI* GetTabbedMDI() const; + virtual int GetTextHeight(); + virtual void Hide(); + virtual BOOL LoadRegistrySettings(tString tsRegistryKeyName); + virtual void RecalcDockLayout(); + virtual BOOL SaveRegistrySettings(tString tsRegistryKeyName); + virtual void Undock(CPoint pt, BOOL bShowUndocked = TRUE); + virtual void UndockContainer(CDockContainer* pContainer, CPoint pt, BOOL bShowUndocked); + virtual BOOL VerifyDockers(); + + // Attributes + virtual CDockBar& GetDockBar() const {return (CDockBar&)m_DockBar;} + virtual CDockClient& GetDockClient() const {return (CDockClient&)m_DockClient;} + virtual CDockHint& GetDockHint() const {return m_pDockAncestor->m_DockHint;} + + + std::vector <DockPtr> & GetAllDockers() const {return GetDockAncestor()->m_vAllDockers;} + int GetBarWidth() const {return GetDockBar().GetWidth();} + CString& GetCaption() const {return GetDockClient().GetCaption();} + std::vector <CDocker*> & GetDockChildren() const {return (std::vector <CDocker*> &)m_vDockChildren;} + int GetDockID() const {return m_nDockID;} + CDocker* GetDockParent() const {return m_pDockParent;} + DWORD GetDockStyle() const {return m_DockStyle;} + CWnd* GetView() const {return GetDockClient().GetView();} + BOOL IsChildOfDocker(CWnd* pWnd) const; + BOOL IsDocked() const; + BOOL IsDragAutoResize(); + BOOL IsRelated(CWnd* pWnd) const; + BOOL IsUndocked() const; + void SetBarColor(COLORREF color) {GetDockBar().SetColor(color);} + void SetBarWidth(int nWidth) {GetDockBar().SetWidth(nWidth);} + void SetCaption(LPCTSTR szCaption); + void SetCaptionColors(COLORREF Foregnd1, COLORREF Backgnd1, COLORREF ForeGnd2, COLORREF BackGnd2); + void SetCaptionHeight(int nHeight); + void SetDockStyle(DWORD dwDockStyle); + void SetDockSize(int DockSize); + void SetDragAutoResize(BOOL bAutoResize); + void SetView(CWnd& wndView); + + protected: + virtual CDocker* NewDockerFromID(int idDock); + virtual void OnActivate(WPARAM wParam, LPARAM lParam); + virtual void OnCaptionTimer(WPARAM wParam, LPARAM lParam); + virtual void OnCreate(); + virtual void OnDestroy(WPARAM wParam, LPARAM lParam); + virtual void OnDockDestroyed(WPARAM wParam, LPARAM lParam); + virtual void OnExitSizeMove(WPARAM wParam, LPARAM lParam); + virtual LRESULT OnNotify(WPARAM wParam, LPARAM lParam); + virtual void OnSetFocus(WPARAM wParam, LPARAM lParam); + virtual void OnSysColorChange(WPARAM wParam, LPARAM lParam); + virtual LRESULT OnSysCommand(WPARAM wParam, LPARAM lParam); + virtual LRESULT OnWindowPosChanging(WPARAM wParam, LPARAM lParam); + virtual void OnWindowPosChanged(WPARAM wParam, LPARAM lParam); + virtual void PreCreate(CREATESTRUCT &cs); + virtual void PreRegisterClass(WNDCLASS &wc); + virtual LRESULT WndProcDefault(UINT uMsg, WPARAM wParam, LPARAM lParam); + + private: + CDocker(const CDocker&); // Disable copy construction + CDocker& operator = (const CDocker&); // Disable assignment operator + void CheckAllTargets(LPDRAGPOS pDragPos); + void CloseAllTargets(); + void DockOuter(CDocker* pDocker, DWORD dwDockStyle); + void DrawAllCaptions(); + void DrawHashBar(HWND hBar, POINT Pos); + void ConvertToChild(HWND hWndParent); + void ConvertToPopup(RECT rc); + void MoveDockChildren(CDocker* pDockTarget); + void PromoteFirstChild(); + void RecalcDockChildLayout(CRect rc); + void ResizeDockers(LPDRAGPOS pdp); + CDocker* SeparateFromDock(); + void SendNotify(UINT nMessageID); + void SetUndockPosition(CPoint pt); + std::vector<CDocker*> SortDockers(); + + CDockBar m_DockBar; + CDockHint m_DockHint; + CDockClient m_DockClient; + CTargetCentre m_TargetCentre; + CTargetLeft m_TargetLeft; + CTargetTop m_TargetTop; + CTargetRight m_TargetRight; + CPoint m_OldPoint; + CTargetBottom m_TargetBottom; + CDocker* m_pDockParent; + CDocker* m_pDockAncestor; + CDocker* m_pDockActive; + + std::vector <CDocker*> m_vDockChildren; + std::vector <DockPtr> m_vAllDockers; // Only used in DockAncestor + + CRect m_rcBar; + CRect m_rcChild; + + BOOL m_BlockMove; + BOOL m_Undocking; + BOOL m_bIsClosing; + BOOL m_bIsDragging; + BOOL m_bDragAutoResize; + int m_DockStartSize; + int m_nDockID; + int m_nTimerCount; + int m_NCHeight; + DWORD m_dwDockZone; + double m_DockSizeRatio; + DWORD m_DockStyle; + HWND m_hOldFocus; + + }; // class CDocker + + struct DockInfo + { + DWORD DockStyle; + int DockSize; + int DockID; + int DockParentID; + RECT Rect; + }; + +} + +//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +namespace Win32xx +{ + + ///////////////////////////////////////////////////////////// + // Definitions for the CDockBar class nested within CDocker + // + inline CDocker::CDockBar::CDockBar() : m_pDock(NULL), m_DockBarWidth(4) + { + m_brBackground.CreateSolidBrush(RGB(192,192,192)); + } + + inline CDocker::CDockBar::~CDockBar() + { + } + + inline void CDocker::CDockBar::OnDraw(CDC* pDC) + { + CRect rcClient = GetClientRect(); + pDC->SelectObject(&m_brBackground); + pDC->PatBlt(0, 0, rcClient.Width(), rcClient.Height(), PATCOPY); + } + + inline void CDocker::CDockBar::PreCreate(CREATESTRUCT &cs) + { + // Create a child window, initially hidden + cs.style = WS_CHILD; + } + + inline void CDocker::CDockBar::PreRegisterClass(WNDCLASS& wc) + { + wc.lpszClassName = _T("Win32++ Bar"); + wc.hbrBackground = m_brBackground; + } + + inline void CDocker::CDockBar::SendNotify(UINT nMessageID) + { + // Send a splitter bar notification to the parent + m_DragPos.hdr.code = nMessageID; + m_DragPos.hdr.hwndFrom = m_hWnd; + m_DragPos.ptPos = GetCursorPos(); + m_DragPos.ptPos.x += 1; + GetParent()->SendMessage(WM_NOTIFY, 0L, (LPARAM)&m_DragPos); + } + + inline void CDocker::CDockBar::SetColor(COLORREF color) + { + // Useful colors: + // GetSysColor(COLOR_BTNFACE) // Default Grey + // RGB(196, 215, 250) // Default Blue + + m_brBackground.CreateSolidBrush(color); + } + + inline LRESULT CDocker::CDockBar::WndProcDefault(UINT uMsg, WPARAM wParam, LPARAM lParam) + { + { + switch (uMsg) + { + case WM_SETCURSOR: + { + if (!(m_pDock->GetDockStyle() & DS_NO_RESIZE)) + { + HCURSOR hCursor; + DWORD dwSide = GetDock()->GetDockStyle() & 0xF; + if ((dwSide == DS_DOCKED_LEFT) || (dwSide == DS_DOCKED_RIGHT)) + hCursor = LoadCursor(GetApp()->GetResourceHandle(), MAKEINTRESOURCE(IDW_SPLITH)); + else + hCursor = LoadCursor(GetApp()->GetResourceHandle(), MAKEINTRESOURCE(IDW_SPLITV)); + + if (hCursor) SetCursor(hCursor); + else TRACE(_T("**WARNING** Missing cursor resource for slider bar\n")); + + return TRUE; + } + else + SetCursor(LoadCursor(NULL, IDC_ARROW)); + } + break; + + case WM_ERASEBKGND: + return 0; + + case WM_LBUTTONDOWN: + { + if (!(m_pDock->GetDockStyle() & DS_NO_RESIZE)) + { + SendNotify(UWM_BAR_START); + SetCapture(); + } + } + break; + + case WM_LBUTTONUP: + if (!(m_pDock->GetDockStyle() & DS_NO_RESIZE) && (GetCapture() == this)) + { + SendNotify(UWM_BAR_END); + ReleaseCapture(); + } + break; + + case WM_MOUSEMOVE: + if (!(m_pDock->GetDockStyle() & DS_NO_RESIZE) && (GetCapture() == this)) + { + SendNotify(UWM_BAR_MOVE); + } + break; + } + } + + // pass unhandled messages on for default processing + return CWnd::WndProcDefault(uMsg, wParam, lParam); + } + + + //////////////////////////////////////////////////////////////// + // Definitions for the CDockClient class nested within CDocker + // + inline CDocker::CDockClient::CDockClient() : m_pView(0), m_IsClosePressed(FALSE), + m_bOldFocus(FALSE), m_bCaptionPressed(FALSE), m_IsTracking(FALSE) + { + m_Foregnd1 = RGB(32,32,32); + m_Backgnd1 = RGB(190,207,227); + m_Foregnd2 = GetSysColor(COLOR_BTNTEXT); + m_Backgnd2 = GetSysColor(COLOR_BTNFACE); + } + + inline void CDocker::CDockClient::Draw3DBorder(RECT& Rect) + { + // Imitates the drawing of the WS_EX_CLIENTEDGE extended style + // This draws a 2 pixel border around the specified Rect + CWindowDC dc(this); + CRect rcw = Rect; + dc.CreatePen(PS_SOLID, 1, GetSysColor(COLOR_3DSHADOW)); + dc.MoveTo(0, rcw.Height()); + dc.LineTo(0, 0); + dc.LineTo(rcw.Width(), 0); + dc.CreatePen(PS_SOLID,1, GetSysColor(COLOR_3DDKSHADOW)); + dc.MoveTo(1, rcw.Height()-2); + dc.LineTo(1, 1); + dc.LineTo(rcw.Width()-2, 1); + dc.CreatePen(PS_SOLID,1, GetSysColor(COLOR_3DHILIGHT)); + dc.MoveTo(rcw.Width()-1, 0); + dc.LineTo(rcw.Width()-1, rcw.Height()-1); + dc.LineTo(0, rcw.Height()-1); + dc.CreatePen(PS_SOLID,1, GetSysColor(COLOR_3DLIGHT)); + dc.MoveTo(rcw.Width()-2, 1); + dc.LineTo(rcw.Width()-2, rcw.Height()-2); + dc.LineTo(1, rcw.Height()-2); + } + + inline CRect CDocker::CDockClient::GetCloseRect() + { + // Calculate the close rect position in screen co-ordinates + CRect rcClose; + + int gap = 4; + CRect rc = GetWindowRect(); + int cx = GetSystemMetrics(SM_CXSMICON); + int cy = GetSystemMetrics(SM_CYSMICON); + + rcClose.top = 2 + rc.top + m_pDock->m_NCHeight/2 - cy/2; + rcClose.bottom = 2 + rc.top + m_pDock->m_NCHeight/2 + cy/2; + rcClose.right = rc.right - gap; + rcClose.left = rcClose.right - cx; + +#if defined(WINVER) && defined (WS_EX_LAYOUTRTL) && (WINVER >= 0x0500) + if (GetWindowLongPtr(GWL_EXSTYLE) & WS_EX_LAYOUTRTL) + { + rcClose.left = rc.left + gap; + rcClose.right = rcClose.left + cx; + } +#endif + + + return rcClose; + } + + inline void CDocker::CDockClient::DrawCaption(WPARAM wParam) + { + if (IsWindow() && m_pDock->IsDocked() && !(m_pDock->GetDockStyle() & DS_NO_CAPTION)) + { + BOOL bFocus = m_pDock->IsChildOfDocker(GetFocus()); + m_bOldFocus = FALSE; + + // Acquire the DC for our NonClient painting + CDC* pDC; + if ((wParam != 1) && (bFocus == m_bOldFocus)) + pDC = GetDCEx((HRGN)wParam, DCX_WINDOW|DCX_INTERSECTRGN|DCX_PARENTCLIP); + else + pDC = GetWindowDC(); + + // Create and set up our memory DC + CRect rc = GetWindowRect(); + CMemDC dcMem(pDC); + int rcAdjust = (GetWindowLongPtr(GWL_EXSTYLE) & WS_EX_CLIENTEDGE)? 2 : 0; + int Width = MAX(rc.Width() -rcAdjust, 0); + int Height = m_pDock->m_NCHeight + rcAdjust; + dcMem.CreateCompatibleBitmap(pDC, Width, Height); + m_bOldFocus = bFocus; + + // Set the font for the title + NONCLIENTMETRICS info = {0}; + info.cbSize = GetSizeofNonClientMetrics(); + SystemParametersInfo(SPI_GETNONCLIENTMETRICS, sizeof(info), &info, 0); + dcMem.CreateFontIndirect(&info.lfStatusFont); + + // Set the Colours + if (bFocus) + { + dcMem.SetTextColor(m_Foregnd1); + dcMem.CreateSolidBrush(m_Backgnd1); + dcMem.SetBkColor(m_Backgnd1); + } + else + { + dcMem.SetTextColor(m_Foregnd2); + dcMem.CreateSolidBrush(m_Backgnd2); + dcMem.SetBkColor(m_Backgnd2); + } + + // Draw the rectangle + dcMem.CreatePen(PS_SOLID, 1, RGB(160, 150, 140)); + dcMem.Rectangle(rcAdjust, rcAdjust, rc.Width() -rcAdjust, m_pDock->m_NCHeight +rcAdjust); + + // Display the caption + int cx = (m_pDock->GetDockStyle() & DS_NO_CLOSE)? 0 : GetSystemMetrics(SM_CXSMICON); + CRect rcText(4 +rcAdjust, rcAdjust, rc.Width() -4 - cx -rcAdjust, m_pDock->m_NCHeight +rcAdjust); + dcMem.DrawText(m_csCaption, m_csCaption.GetLength(), rcText, DT_LEFT|DT_VCENTER|DT_SINGLELINE|DT_END_ELLIPSIS); + + // Draw the close button + if ((0 != m_pDock) && !(m_pDock->GetDockStyle() & DS_NO_CLOSE)) + DrawCloseButton(dcMem, bFocus); + + // Draw the 3D border + if (GetWindowLongPtr(GWL_EXSTYLE) & WS_EX_CLIENTEDGE) + Draw3DBorder(rc); + + // Copy the Memory DC to the window's DC + pDC->BitBlt(rcAdjust, rcAdjust, Width, Height, &dcMem, rcAdjust, rcAdjust, SRCCOPY); + + // Required for Win98/WinME + pDC->Destroy(); + } + } + + inline void CDocker::CDockClient::DrawCloseButton(CDC& DrawDC, BOOL bFocus) + { + // The close button isn't displayed on Win95 + if (GetWinVersion() == 1400) return; + + if (m_pDock->IsDocked() && !(m_pDock->GetDockStyle() & DS_NO_CAPTION)) + { + // Determine the close button's drawing position relative to the window + CRect rcClose = GetCloseRect(); + UINT uState = GetCloseRect().PtInRect(GetCursorPos())? m_IsClosePressed && IsLeftButtonDown()? 2 : 1 : 0; + ScreenToClient(rcClose); + + if (GetWindowLongPtr(GWL_EXSTYLE) & WS_EX_CLIENTEDGE) + { + rcClose.OffsetRect(2, m_pDock->m_NCHeight+2); + if (GetWindowRect().Height() < (m_pDock->m_NCHeight+4)) + rcClose.OffsetRect(-2, -2); + } + else + rcClose.OffsetRect(0, m_pDock->m_NCHeight-2); + + // Draw the outer highlight for the close button + if (!IsRectEmpty(&rcClose)) + { + switch (uState) + { + case 0: + { + // Normal button + DrawDC.CreatePen(PS_SOLID, 1, RGB(232, 228, 220)); + DrawDC.MoveTo(rcClose.left, rcClose.bottom); + DrawDC.LineTo(rcClose.right, rcClose.bottom); + DrawDC.LineTo(rcClose.right, rcClose.top); + DrawDC.LineTo(rcClose.left, rcClose.top); + DrawDC.LineTo(rcClose.left, rcClose.bottom); + break; + } + + case 1: + { + // Popped up button + // Draw outline, white at top, black on bottom + DrawDC.CreatePen(PS_SOLID, 1, RGB(0, 0, 0)); + DrawDC.MoveTo(rcClose.left, rcClose.bottom); + DrawDC.LineTo(rcClose.right, rcClose.bottom); + DrawDC.LineTo(rcClose.right, rcClose.top); + DrawDC.CreatePen(PS_SOLID, 1, RGB(255, 255, 255)); + DrawDC.LineTo(rcClose.left, rcClose.top); + DrawDC.LineTo(rcClose.left, rcClose.bottom); + } + + break; + case 2: + { + // Pressed button + // Draw outline, black on top, white on bottom + DrawDC.CreatePen(PS_SOLID, 1, RGB(255, 255, 255)); + DrawDC.MoveTo(rcClose.left, rcClose.bottom); + DrawDC.LineTo(rcClose.right, rcClose.bottom); + DrawDC.LineTo(rcClose.right, rcClose.top); + DrawDC.CreatePen(PS_SOLID, 1, RGB(0, 0, 0)); + DrawDC.LineTo(rcClose.left, rcClose.top); + DrawDC.LineTo(rcClose.left, rcClose.bottom); + } + break; + } + + // Manually Draw Close Button + if (bFocus) + DrawDC.CreatePen(PS_SOLID, 1, m_Foregnd1); + else + DrawDC.CreatePen(PS_SOLID, 1, m_Foregnd2); + + DrawDC.MoveTo(rcClose.left + 3, rcClose.top +3); + DrawDC.LineTo(rcClose.right - 2, rcClose.bottom -2); + + DrawDC.MoveTo(rcClose.left + 4, rcClose.top +3); + DrawDC.LineTo(rcClose.right - 2, rcClose.bottom -3); + + DrawDC.MoveTo(rcClose.left + 3, rcClose.top +4); + DrawDC.LineTo(rcClose.right - 3, rcClose.bottom -2); + + DrawDC.MoveTo(rcClose.right -3, rcClose.top +3); + DrawDC.LineTo(rcClose.left + 2, rcClose.bottom -2); + + DrawDC.MoveTo(rcClose.right -3, rcClose.top +4); + DrawDC.LineTo(rcClose.left + 3, rcClose.bottom -2); + + DrawDC.MoveTo(rcClose.right -4, rcClose.top +3); + DrawDC.LineTo(rcClose.left + 2, rcClose.bottom -3); + } + } + } + + inline void CDocker::CDockClient::OnNCCalcSize(WPARAM& wParam, LPARAM& lParam) + { + // Sets the non-client area (and hence sets the client area) + // This function modifies lParam + + UNREFERENCED_PARAMETER(wParam); + + if ((0 != m_pDock) && !(m_pDock->GetDockStyle() & DS_NO_CAPTION)) + { + if (m_pDock->IsDocked()) + { + LPRECT rc = (LPRECT)lParam; + rc->top += m_pDock->m_NCHeight; + } + } + } + + inline LRESULT CDocker::CDockClient::OnNCHitTest(WPARAM wParam, LPARAM lParam) + { + // Identify which part of the non-client area the cursor is over + if ((0 != m_pDock) && !(m_pDock->GetDockStyle() & DS_NO_CAPTION)) + { + if (m_pDock->IsDocked()) + { + CPoint pt(GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam)); + + // Indicate if the point is in the close button (except for Win95) + if ((GetWinVersion() > 1400) && (GetCloseRect().PtInRect(pt))) + return HTCLOSE; + + ScreenToClient(pt); + + // Indicate if the point is in the caption + if (pt.y < 0) + return HTCAPTION; + } + } + return CWnd::WndProcDefault(WM_NCHITTEST, wParam, lParam); + } + + inline LRESULT CDocker::CDockClient::OnNCLButtonDown(WPARAM wParam, LPARAM lParam) + { + if ((0 != m_pDock) && !(m_pDock->GetDockStyle() & DS_NO_CAPTION)) + { + if ((HTCLOSE == wParam) && !(m_pDock->GetDockStyle() & DS_NO_CLOSE)) + { + m_IsClosePressed = TRUE; + SetCapture(); + } + + m_bCaptionPressed = TRUE; + m_Oldpt.x = GET_X_LPARAM(lParam); + m_Oldpt.y = GET_Y_LPARAM(lParam); + if (m_pDock->IsDocked()) + { + CPoint pt(GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam)); + ScreenToClient(pt); + m_pView->SetFocus(); + + // Update the close button + if ((0 != m_pDock) && !(m_pDock->GetDockStyle() & DS_NO_CLOSE)) + { + CWindowDC dc(this); + DrawCloseButton(dc, m_bOldFocus); + } + + return 0L; + } + } + return CWnd::WndProcDefault(WM_NCLBUTTONDOWN, wParam, lParam); + } + + inline void CDocker::CDockClient::OnLButtonUp(WPARAM wParam, LPARAM lParam) + { + UNREFERENCED_PARAMETER(wParam); + UNREFERENCED_PARAMETER(lParam); + + if ((0 != m_pDock) && !(m_pDock->GetDockStyle() & (DS_NO_CAPTION|DS_NO_CLOSE))) + { + m_bCaptionPressed = FALSE; + if (m_IsClosePressed && GetCloseRect().PtInRect(GetCursorPos())) + { + // Destroy the docker + if (dynamic_cast<CDockContainer*>(m_pDock->GetView())) + { + CDockContainer* pContainer = ((CDockContainer*)m_pDock->GetView())->GetActiveContainer(); + CDocker* pDock = m_pDock->GetDockFromView(pContainer); + pDock->GetDockClient().SetClosePressed(); + m_pDock->UndockContainer(pContainer, GetCursorPos(), FALSE); + pDock->Destroy(); + } + else + { + m_pDock->Hide(); + m_pDock->Destroy(); + } + } + } + } + + inline void CDocker::CDockClient::OnLButtonDown(WPARAM wParam, LPARAM lParam) + { + UNREFERENCED_PARAMETER(wParam); + UNREFERENCED_PARAMETER(lParam); + + m_IsClosePressed = FALSE; + ReleaseCapture(); + CWindowDC dc(this); + DrawCloseButton(dc, m_bOldFocus); + } + + inline void CDocker::CDockClient::OnMouseActivate(WPARAM wParam, LPARAM lParam) + // Focus changed, so redraw the captions + { + UNREFERENCED_PARAMETER(wParam); + UNREFERENCED_PARAMETER(lParam); + + if ((0 != m_pDock) && !(m_pDock->GetDockStyle() & DS_NO_CAPTION)) + { + m_pDock->GetDockAncestor()->PostMessage(UWM_DOCK_ACTIVATED, 0, 0); + } + } + + inline void CDocker::CDockClient::OnMouseMove(WPARAM wParam, LPARAM lParam) + { + OnNCMouseMove(wParam, lParam); + } + + inline void CDocker::CDockClient::OnNCMouseLeave(WPARAM wParam, LPARAM lParam) + { + UNREFERENCED_PARAMETER(wParam); + UNREFERENCED_PARAMETER(lParam); |
