StringsCategoryViewDialog.h 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203
  1. /*
  2. ** Command & Conquer Renegade(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. #if !defined(AFX_STRINGSCATEGORYVIEWDIALOG_H__E1BB750E_63DF_4D8D_8B0C_77D90F6D2CB9__INCLUDED_)
  19. #define AFX_STRINGSCATEGORYVIEWDIALOG_H__E1BB750E_63DF_4D8D_8B0C_77D90F6D2CB9__INCLUDED_
  20. #if _MSC_VER > 1000
  21. #pragma once
  22. #endif // _MSC_VER > 1000
  23. #include "resource.h"
  24. #include "vector.h"
  25. /////////////////////////////////////////////////////////////////////////////
  26. // Forward declarations
  27. /////////////////////////////////////////////////////////////////////////////
  28. class TDBObjClass;
  29. class StringLibraryDialogClass;
  30. class StringsCategoryViewCallbackClass;
  31. /////////////////////////////////////////////////////////////////////////////
  32. //
  33. // StringsCategoryViewDialogClass
  34. //
  35. /////////////////////////////////////////////////////////////////////////////
  36. class StringsCategoryViewDialogClass : public CDialog
  37. {
  38. // Construction
  39. public:
  40. StringsCategoryViewDialogClass(CWnd* pParent = NULL); // standard constructor
  41. // Dialog Data
  42. //{{AFX_DATA(StringsCategoryViewDialogClass)
  43. enum { IDD = IDD_STRINGS_CATEGORY_VIEW };
  44. CListCtrl m_ListCtrl;
  45. //}}AFX_DATA
  46. // Overrides
  47. // ClassWizard generated virtual function overrides
  48. //{{AFX_VIRTUAL(StringsCategoryViewDialogClass)
  49. public:
  50. protected:
  51. virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
  52. //}}AFX_VIRTUAL
  53. // Implementation
  54. protected:
  55. // Generated message map functions
  56. //{{AFX_MSG(StringsCategoryViewDialogClass)
  57. virtual BOOL OnInitDialog();
  58. afx_msg void OnColumnclickStringList(NMHDR* pNMHDR, LRESULT* pResult);
  59. afx_msg void OnDblclkStringList(NMHDR* pNMHDR, LRESULT* pResult);
  60. afx_msg void OnDeleteitemStringList(NMHDR* pNMHDR, LRESULT* pResult);
  61. afx_msg void OnKeydownStringList(NMHDR* pNMHDR, LRESULT* pResult);
  62. afx_msg void OnSize(UINT nType, int cx, int cy);
  63. afx_msg void OnItemchangedStringList(NMHDR* pNMHDR, LRESULT* pResult);
  64. //}}AFX_MSG
  65. DECLARE_MESSAGE_MAP()
  66. public:
  67. /////////////////////////////////////////////////////////////////////////////
  68. // Constants
  69. /////////////////////////////////////////////////////////////////////////////
  70. static const enum
  71. {
  72. COL_ID = 0,
  73. COL_TEXT,
  74. COL_MAX
  75. };
  76. typedef enum
  77. {
  78. EDIT_MODE_NONE = 0,
  79. EDIT_MODE_STRING,
  80. EDIT_MODE_TWIDDLER
  81. } EDIT_MODE;
  82. /////////////////////////////////////////////////////////////////////////////
  83. // Public methods
  84. /////////////////////////////////////////////////////////////////////////////
  85. //
  86. // Creation
  87. //
  88. void Create (CWnd *parent_wnd);
  89. void Apply_Changes (void);
  90. void Update_Controls (void);
  91. //
  92. // Modification
  93. //
  94. void Cut (DynamicVectorClass <TDBObjClass *> &entry_list, bool sel_only = true);
  95. void Paste (DynamicVectorClass <TDBObjClass *> &entry_list);
  96. //
  97. // Accessors
  98. //
  99. int Get_Category_ID (void) const { return CategoryID; }
  100. void Set_Category_ID (int id) { CategoryID = id; }
  101. bool Is_Version_Number_Dirty (void) const { return ShouldUpdateVersionNumber; }
  102. void Set_Edit_Mode (EDIT_MODE mode) { EditMode = mode; }
  103. //
  104. // Callback support
  105. //
  106. void Set_Callback (StringsCategoryViewCallbackClass *callback) { CallbackObject = callback; }
  107. //
  108. // Column control
  109. //
  110. void Remove_Column (int col_id);
  111. void Set_Column_Width (int col_id, float width);
  112. //
  113. // Selection access
  114. //
  115. void Set_Selection (int object_id) { SelectedObjectID = object_id; }
  116. int Get_Selection (void);
  117. private:
  118. /////////////////////////////////////////////////////////////////////////////
  119. // Private data types
  120. /////////////////////////////////////////////////////////////////////////////
  121. typedef struct _COL_INFO
  122. {
  123. int id;
  124. const char * name;
  125. float width;
  126. } COL_INFO;
  127. /////////////////////////////////////////////////////////////////////////////
  128. // Private methods
  129. /////////////////////////////////////////////////////////////////////////////
  130. void Resize_Controls (void);
  131. void Insert_New_Entry (TDBObjClass *object);
  132. void Upate_Entry (int index);
  133. int Find_Entry (TDBObjClass *object);
  134. /////////////////////////////////////////////////////////////////////////////
  135. // Private member data
  136. /////////////////////////////////////////////////////////////////////////////
  137. int SelectedObjectID;
  138. int CategoryID;
  139. bool IsInitialized;
  140. bool ShouldUpdateVersionNumber;
  141. int CurrentColSort;
  142. bool AscendingSort;
  143. StringsCategoryViewCallbackClass * CallbackObject;
  144. CRect CurrListRect;
  145. EDIT_MODE EditMode;
  146. DynamicVectorClass<int> Columns;
  147. COL_INFO ColumnSettings[COL_MAX];
  148. };
  149. /////////////////////////////////////////////////////////////////////////////
  150. //
  151. // StringsCategoryViewCallbackClass
  152. //
  153. /////////////////////////////////////////////////////////////////////////////
  154. class StringsCategoryViewCallbackClass
  155. {
  156. public:
  157. StringsCategoryViewCallbackClass (void) {}
  158. virtual ~StringsCategoryViewCallbackClass (void) {}
  159. /////////////////////////////////////////////////////////////////////////////
  160. // Public methods
  161. /////////////////////////////////////////////////////////////////////////////
  162. virtual void On_Selection_Changed (int sel_object_id) {}
  163. virtual void On_Cut (void) {}
  164. virtual void On_Paste (void) {}
  165. };
  166. //{{AFX_INSERT_LOCATION}}
  167. // Microsoft Visual C++ will insert additional declarations immediately before the previous line.
  168. #endif // !defined(AFX_STRINGSCATEGORYVIEWDIALOG_H__E1BB750E_63DF_4D8D_8B0C_77D90F6D2CB9__INCLUDED_)