TabsDlg.h 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120
  1. /*
  2. ===========================================================================
  3. Doom 3 GPL Source Code
  4. Copyright (C) 1999-2011 id Software LLC, a ZeniMax Media company.
  5. This file is part of the Doom 3 GPL Source Code (?Doom 3 Source Code?).
  6. Doom 3 Source Code is free software: you can redistribute it and/or modify
  7. it under the terms of the GNU General Public License as published by
  8. the Free Software Foundation, either version 3 of the License, or
  9. (at your option) any later version.
  10. Doom 3 Source Code is distributed in the hope that it will be useful,
  11. but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. GNU General Public License for more details.
  14. You should have received a copy of the GNU General Public License
  15. along with Doom 3 Source Code. If not, see <http://www.gnu.org/licenses/>.
  16. In addition, the Doom 3 Source Code is also subject to certain additional terms. You should have received a copy of these additional terms immediately following the terms and conditions of the GNU General Public License which accompanied the Doom 3 Source Code. If not, please request a copy in writing from id Software at the address below.
  17. If you have questions concerning this license or the applicable additional terms, you may contact in writing id Software LLC, c/o ZeniMax Media Inc., Suite 120, Rockville, Maryland 20850 USA.
  18. ===========================================================================
  19. */
  20. #pragma once
  21. #include "afxcmn.h"
  22. #include "TearoffContainerWindow.h"
  23. // CTabsDlg dialog
  24. class CTabsDlg : public CDialog
  25. {
  26. // DECLARE_DYNAMIC ( CTabsDlg )
  27. // Construction
  28. public:
  29. CTabsDlg(UINT ID ,CWnd* pParent = NULL); // standard constructor
  30. typedef void (*pfnOnDockEvent)( bool , int , CWnd* );
  31. void AddDockedWindow ( CWnd* wnd , int ID , int imageID , const CString& title , bool dock , pfnOnDockEvent dockCallback = NULL);
  32. void DockWindow ( int ID , bool dock );
  33. bool RectWithinDockManager ( CRect& rect );
  34. void FocusWindow ( int ID );
  35. void SetImageList ( CImageList* list )
  36. {
  37. ASSERT ( list );
  38. m_Tabs.SetImageList( list );
  39. }
  40. bool IsDocked ( CWnd* wnd );
  41. protected:
  42. int CTabsDlg::PreTranslateMessage ( MSG* msg );
  43. // Implementation
  44. protected:
  45. CImageList m_TabImages;
  46. CPoint m_DragDownPoint;
  47. CMapWordToPtr m_Windows;
  48. bool m_DragTabActive;
  49. void DoDataExchange(CDataExchange* pDX);
  50. //private struct that holds the info we need about each window
  51. struct DockedWindowInfo {
  52. DockedWindowInfo ( CWnd* wnd , int ID , int imageID , const CString& title = "" , pfnOnDockEvent dockCallback = NULL)
  53. {
  54. ASSERT ( wnd );
  55. m_Window = wnd;
  56. m_ID = ID;
  57. m_ImageID = imageID;
  58. m_TabControlIndex = -1;
  59. if ( title.GetLength() == 0 )
  60. {
  61. m_Window->GetWindowText( m_Title );
  62. }
  63. else
  64. {
  65. m_Title = title;
  66. }
  67. m_State = DOCKED;
  68. m_DockCallback = dockCallback;
  69. }
  70. enum eState {DOCKED,FLOATING} ;
  71. CTearoffContainerWindow m_Container; //the floating window that will hold m_Window when it's undocked
  72. CWnd* m_Window;
  73. CString m_Title;
  74. int m_ImageID;
  75. int m_ID;
  76. int m_TabControlIndex;
  77. eState m_State;
  78. pfnOnDockEvent m_DockCallback;
  79. };
  80. void ShowAllWindows ( bool show = true );
  81. void HandleUndock ();
  82. void UpdateTabControlIndices ();
  83. // Generated message map functions
  84. virtual BOOL OnInitDialog();
  85. DECLARE_MESSAGE_MAP()
  86. public:
  87. CTabCtrl m_Tabs;
  88. afx_msg void OnTcnSelchange(NMHDR *pNMHDR, LRESULT *pResult);
  89. afx_msg void OnLButtonDown(UINT nFlags, CPoint point);
  90. afx_msg void OnLButtonUp(UINT nFlags, CPoint point);
  91. afx_msg void OnMouseMove(UINT nFlags, CPoint point);
  92. afx_msg void OnDestroy();
  93. void SaveWindowPlacement ( int ID = -1 );
  94. };