1 
2 
3 #pragma once
4 
5 #include <afxcview.h>
6 
7 #define PROJECT_VIEW_SEARCH_DEPTH 65535
8 
9 class copy_paste_info;
10 
11 class project_view : public CTreeView
12 {
13     protected:
14         DECLARE_DYNCREATE(project_view)
15 
16     public:
17         project_view();
18         ~project_view();
19         virtual BOOL PreCreateWindow(CREATESTRUCT& cs);
20         virtual void OnInitialUpdate();
21         void NewProject(CWnd *parent = NULL);
22         void ProjectRenamed();
23         void TerminateAppExecutions();
24         void CloseProject(BOOL DisplayRecent = FALSE, BOOL CheckSaveChanges = TRUE);
25         void OpenProject();
26         BOOL OpenProject(CString &path, CString &name);
27         void MergeProject();
28         void MergeProject(CString &path, CString &name);
29         void OpenHistoryProject(int Index);
30         void DeSelect();
31         void OnProjectReset();
32         void NotifyNameChange(widget_info *info);
33         void SelectFirstScreen();
34         void SelectDisplay(int display);
35 
36         void RunApplication(CWnd *parent = NULL);
37 
GetActiveDisplay()38         int GetActiveDisplay() {return m_active_display;}
39         template <class T>
40         BOOL check_set_active_display(T *info);
41         folder_info *GetRootFolder();
42         BOOL IsDisplaySelected();
43         BOOL IsFolderSelected();
44         INT GetSelectedNodeLevel();
45         folder_info *GetSelectedFolder();
46 
47         // Insert a top-level widget
48         void InsertTopLevelWidget(widget_info *info);    // for top level widget
49         void InsertFolder(folder_info *info);
50 
51         void DeleteWidget(widget_info *info);
52         void DeleteFolder(folder_info *info);
53 
54 
55         // this version is used to add a child widget to a specified node
56         widget_info *InsertTreeChild(HTREEITEM hParent, widget_info *info, BOOL do_siblings = TRUE);
57 
58         // this version is used to add a child widget to selected node
59         widget_info *InsertTreeChild(widget_info *parent, widget_info *info, BOOL do_siblings = TRUE);
60         folder_info *InsertTreeChild(folder_info *folder, widget_info *info, BOOL do_sibling = TRUE);
61 
62 
63         // this function is called by project view or target screen to see
64         // if we need to do anything special after modifying a widget.
65         static void CheckParentRefresh(GX_WIDGET *parent);
66         static void CheckParentRefresh(widget_info *parent_info);
67         static void UpdateChildPositions(widget_info *parent);
68 
69         void WidgetSelected(widget_info *widget);
70         void FolderSelected(INT display_index,  CString folder_name);
71         void FolderSelected(folder_info * folder);
72 
73         afx_msg void OnDeleteWidget();
74         afx_msg void OnInsertFolder();
75         afx_msg void OnEditFolderProperties();
76         afx_msg void OnCutWidget();
77         afx_msg void OnCopyWidget();
78         afx_msg void OnPasteWidget();
79         afx_msg void OnConfigureDisplays();
80         afx_msg void OnConfigureThemes();
81         afx_msg void OnGenerateAll();
82         afx_msg BOOL OnGenResources(GX_BOOL show_notify = TRUE);
83         afx_msg void OnGenApplication(GX_BOOL show_notify = TRUE);
84         afx_msg BOOL OnGenBinary(GX_BOOL show_notify = TRUE);
85 
86         BOOL CheckRemoveDuplicateTemplates(folder_info *start, folder_info *search_start = NULL, BOOL notify_duplicates = FALSE);
87         void AddWidgetsToFolder(folder_info *target_folder, folder_info *src_folder);
88         folder_info *CombineCopyPasteWidgets(copy_paste_info *pasted_info);
89         void PasteFolder(copy_paste_info *pasted_info);
90         void PasteWidgets(folder_info *parent_folder, copy_paste_info *pasted_info);
91         void PasteWidgets(widget_info *parent_widget_info, copy_paste_info *pasted_info);
92 
93         void MoveSelectedToFront();
94         void MoveSelectedToBack();
95 
96         /* Retrieve project tree status, used for macro record and playback.  */
97         void GetTreeState(CArray<int> *state_array);
98         void GetTreeState(HTREEITEM hParent, CArray<int> *state_array);
99 
100         /* Set project tree status, used for macro record and playback.  */
101         void SetTreeState(CArray<int> *state_array);
102         void SetTreeState(HTREEITEM hParent, CArray<int> *state_array);
103 
104         widget_info *GetTemplateInfo(int menu_index);
105         void UpdateBaseMenu(CMenu *parent);
106         BOOL CreateBaseMenu(CMenu *pBaseMenu);
107         GX_BOOL IsTopLevelWidget(widget_info *widget_info);//check if a widget is in top level
108         void GetTopLevelWidgetList(int display_index, CArray<widget_info *> *list);
109         widget_info *FindTopLevelWidget(widget_info *child);
110         GX_BOOL IsFolderNameExist(CString name);
111         GX_BOOL IsFolderNameExist(folder_info *folder, CString name);
112         void CreateUniqeFolderName(folder_info *info);
113         BOOL FindWidgetIdName(widget_info *start, widget_info *except, CString id_name);
114         BOOL CheckTriggerReference(screen_flow *flow, flow_item *item, widget_info *screen_info, widget_info *info, widget_info *search);
115         VOID RemoveWidgetIdFromDictionary(studiox_project *project, int display, widget_info *info);
116         BOOL CheckRemoveWidget(studiox_project *project, int display, widget_info *info);
117         VOID OnLockUlockWidgetPositions();
118 
119     // Generated message map functions
120     protected:
121 
122         afx_msg void OnPaint();
123         afx_msg BOOL OnEraseBkgnd(CDC *pDC);
124         afx_msg void OnRClick(NMHDR *pNMHDR, LRESULT *pResult);
125         afx_msg void OnContextMenu(CWnd *pWnd, CPoint pos);
126         afx_msg LRESULT OnTestMessage(WPARAM, LPARAM);
127 
128         afx_msg void OnNodeSelect(NMHDR *, LRESULT *);
129         afx_msg void OnItemExpanded(NMHDR *ph, LRESULT *pr);
130         virtual BOOL PreTranslateMessage(MSG* pMsg);
131 
132         DECLARE_MESSAGE_MAP()
133 
134     private:
135         HTREEITEM AddTreeRoot(CString &rootname);
136         void PopulateProjectTree(studiox_project *pProj);
137         void SetFrameTitle(CString &title);
138         void AssignTreeImage(HTREEITEM item, widget_info *info);
139         void AssignTreeImage(HTREEITEM item, folder_info *info, BOOL open = FALSE);
140 
141         void AddTreeWidgets(HTREEITEM hParent, widget_info *start);
142         void AddTreeFolders(HTREEITEM hParent, folder_info *start);
143         int GetTreeNodeLevel(HTREEITEM item);
144         HTREEITEM FindWidget(widget_info *widget);
145         HTREEITEM FindWidget(HTREEITEM start, widget_info *widget);
146         HTREEITEM FindProjectTreeNode(HTREEITEM start, CString name, int search_depth = PROJECT_VIEW_SEARCH_DEPTH);
147         HTREEITEM FindProjectTreeNode(CString name, CString display_name = _T(""), CString screen_name = _T(""));
148         void DisplaySelected();
149 
150         int        m_active_display;
151         CTreeCtrl *mpTree;
152         widget_info *m_widget_copy;
153         CImageList *mpImageList;
154 };
155 
156