HierarchyView.h 6.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157
  1. /*
  2. ** Command & Conquer Generals(tm)
  3. ** Copyright 2025 Electronic Arts Inc.
  4. **
  5. ** This program is free software: you can redistribute it and/or modify
  6. ** it under the terms of the GNU General Public License as published by
  7. ** the Free Software Foundation, either version 3 of the License, or
  8. ** (at your option) any later version.
  9. **
  10. ** This program 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. **
  15. ** You should have received a copy of the GNU General Public License
  16. ** along with this program. If not, see <http://www.gnu.org/licenses/>.
  17. */
  18. ////////////////////////////////////////////////////////////////////////////////
  19. // //
  20. // (c) 2001-2003 Electronic Arts Inc. //
  21. // //
  22. ////////////////////////////////////////////////////////////////////////////////
  23. // FILE: HierarchyView.h //////////////////////////////////////////////////////
  24. //-----------------------------------------------------------------------------
  25. //
  26. // Westwood Studios Pacific.
  27. //
  28. // Confidential Information
  29. // Copyright (C) 2001 - All Rights Reserved
  30. //
  31. //-----------------------------------------------------------------------------
  32. //
  33. // Project: GUIEdit
  34. //
  35. // File name: HierarchyView.h
  36. //
  37. // Created: Colin Day, July 2001
  38. //
  39. // Desc: Manipulation the widows heirarchy through the tree
  40. //
  41. //-----------------------------------------------------------------------------
  42. ///////////////////////////////////////////////////////////////////////////////
  43. #pragma once
  44. #ifndef __HIERARCHYVIEW_H_
  45. #define __HIERARCHYVIEW_H_
  46. // SYSTEM INCLUDES ////////////////////////////////////////////////////////////
  47. #include <windows.h>
  48. #include <commctrl.h>
  49. // USER INCLUDES //////////////////////////////////////////////////////////////
  50. #include "Lib/BaseType.h"
  51. #include "GameClient/GameWindow.h"
  52. // FORWARD REFERENCES /////////////////////////////////////////////////////////
  53. ///////////////////////////////////////////////////////////////////////////////
  54. // TYPE DEFINES ///////////////////////////////////////////////////////////////
  55. ///////////////////////////////////////////////////////////////////////////////
  56. // HierarchyOption ------------------------------------------------------------
  57. //-----------------------------------------------------------------------------
  58. typedef enum
  59. {
  60. HIERARCHY_ADD_AT_TOP,
  61. HIERARCHY_ADD_AT_BOTTOM,
  62. } HierarchyOption;
  63. // HierarchyView --------------------------------------------------------------
  64. /** This view allows users to manipulate the windows hierarchy using
  65. * a tree view control */
  66. //-----------------------------------------------------------------------------
  67. class HierarchyView
  68. {
  69. public:
  70. HierarchyView( void );
  71. ~HierarchyView( void );
  72. void init( void );
  73. void reset( void );
  74. void shutdown( void );
  75. char *getWindowTreeName( GameWindow *window );
  76. void addWindow( GameWindow *window, HierarchyOption option ); ///< add a window to the view
  77. void removeWindow( GameWindow *window ); ///< remove window from tree
  78. void bringWindowToTop( GameWindow *window ); ///< bring window to top of parent list
  79. void updateWindowName( GameWindow *window ); ///< update tree entry based on name
  80. void selectWindow( GameWindow *window ); ///< select window
  81. HWND getTreeHandle( void ); ///< get the tree control handle
  82. HWND getHierarchyHandle( void ); ///< get window handle for the whole dialog
  83. void setDialogPos( ICoord2D *pos );
  84. void getDialogPos( ICoord2D *pos );
  85. void setDialogSize( ICoord2D *size );
  86. void getDialogSize( ICoord2D *size );
  87. void setDragWindow( GameWindow *window );
  88. void setDragTarget( GameWindow *window );
  89. GameWindow *getDragWindow( void );
  90. GameWindow *getDragTarget( void );
  91. void moveWindowAheadOf( GameWindow *window, GameWindow *aheadOf ); ///< move hierarchy representation
  92. void moveWindowChildOf( GameWindow *window, GameWindow *parent ); ///< move hierarchy representation
  93. Bool validateDragDropOperation( GameWindow *source, GameWindow *target );
  94. void setPopupTarget( GameWindow *window ); ///< set target for popup menu
  95. GameWindow *getPopupTarget( void ); ///< get the popup target window
  96. HTREEITEM treePointToItem( Int x, Int y ); ///< translate mouse pos to item location
  97. GameWindow *getWindowFromItem( HTREEITEM treeItem ); ///< get game window from user data in the tree item
  98. protected:
  99. static LRESULT CALLBACK dialogProc( HWND hWndDialog, UINT message,
  100. WPARAM wParam, LPARAM lParam );
  101. void addWindowToTree( GameWindow *window, HTREEITEM treeParent,
  102. HierarchyOption option, Bool addChildren,
  103. Bool addSiblings ); ///< workhorse for addWindow()
  104. HTREEITEM findItemEntry( HTREEITEM node, GameWindow *window ); ///< workhorse for findTreeEntry
  105. HTREEITEM findTreeEntry( GameWindow *window ); ///< return entry if in tree
  106. HWND m_dialog; ///< window handle for our control dialog
  107. HWND m_tree; ///< window handle for the tree control
  108. GameWindow *m_dragWindow; ///< for drag drop operations
  109. GameWindow *m_dragTarget; ///< target for drag and drop operations while mouse is moving
  110. GameWindow *m_popupTarget; ///< the target for right mouse popup menus
  111. }; // end HierarchyView
  112. ///////////////////////////////////////////////////////////////////////////////
  113. // INLINING ///////////////////////////////////////////////////////////////////
  114. ///////////////////////////////////////////////////////////////////////////////
  115. inline HWND HierarchyView::getTreeHandle( void ) { return m_tree; }
  116. inline HWND HierarchyView::getHierarchyHandle( void ) { return m_dialog; }
  117. inline void HierarchyView::setDragWindow( GameWindow *window ) { m_dragWindow = window; }
  118. inline void HierarchyView::setDragTarget( GameWindow *window ) { m_dragTarget = window; }
  119. inline GameWindow *HierarchyView::getDragWindow( void ) { return m_dragWindow; }
  120. inline GameWindow *HierarchyView::getDragTarget( void ) { return m_dragTarget; }
  121. inline void HierarchyView::setPopupTarget( GameWindow *window ) { m_popupTarget = window; }
  122. inline GameWindow *HierarchyView::getPopupTarget( void ) { return m_popupTarget; }
  123. // EXTERNALS //////////////////////////////////////////////////////////////////
  124. extern HierarchyView *TheHierarchyView; ///< singleton for our view
  125. #endif // __CONTROLPALETTE_H_