root/trunk/NewProjectDlg.h

Revision 5, 4.3 kB (checked in by qbert, 6 years ago)

Initial ( and last :( ) commit

Line 
1 #if !defined(AFX_NEWPROJECTDLG_H__09250A6E_737D_4DBE_AC1A_65D2FD57F5AC__INCLUDED_)
2 #define AFX_NEWPROJECTDLG_H__09250A6E_737D_4DBE_AC1A_65D2FD57F5AC__INCLUDED_
3
4 #if _MSC_VER > 1000
5 #pragma once
6 #endif // _MSC_VER > 1000
7 // NewProjectDlg.h : header file
8 //
9
10 /////////////////////////////////////////////////////////////////////////////
11 // CNewProjectDlg dialog
12 #include "resource.h"
13 class CNewProjectDlg : public CXTResizeDialog
14 {
15 // Construction
16 public:
17     CNewProjectDlg(CWnd* pParent = NULL);   // standard constructor
18
19 // Dialog Data
20     //{{AFX_DATA(CNewProjectDlg)
21     enum { IDD = IDD_NEWPROJECT_DLG };
22     CStatic m_criteriaTitle;
23     CStatic m_properties;
24     CStatic m_static6;
25     CEdit   m_filesEdit;   
26     CStatic m_st2;
27     CStatic m_s2;
28     CStatic m_s1;
29     CTreeCtrl   m_options;
30     CXTButton   m_ok;
31     CXTButton   m_cancel;
32     CXTButton   m_browse;
33     CElephantEdit   m_projectDescription;
34     CEdit   m_projectLocation;
35     CElephantEdit   m_projectName;
36     CString m_csLocation;
37     CString m_csProjectDescription;
38     CString m_csProjectName;
39     CString m_st6;
40     CString m_csFiles;
41     BOOL    m_createProjectFolder;
42     CString m_strProjectDir;
43     CString m_projectTypeCriteria;
44     CString m_projectLocationCriteria;
45     CString m_projectNameCriteria;
46     CString m_criteriaStr;
47     //}}AFX_DATA
48     vector<ProjectSpecs> pspecs;
49     map<string,HTREEITEM> projectMap;
50     HTREEITEM rootItem;
51     CImageList m_imageList;
52     CBitmap m_bitmap;
53
54     string DescriptionForProject(const string& pname )
55     {
56         for ( int i = 0 ; i <  pspecs.size(); i++ )
57         {
58             if ( pspecs[i].projectName == pname ) return pspecs[i].description;
59
60         }
61         return "Project Description";
62
63     }
64
65     string FilesForProject(const string& pname )
66     {
67
68         string ret = "";
69         for ( int i = 0 ; i <  pspecs.size(); i++ )
70         {
71            
72             if ( pspecs[i].projectName == pname )
73             {
74                 for ( int j = 0 ; j < pspecs[i].files.size();j++ )
75                 {
76                     ret += StripFileName(pspecs[i].files[j]) + ",";
77                 }
78
79                 ret = ret.substr(0,ret.length() - 1);
80                 return ret;
81             }
82            
83         }
84         return "Project Files";
85        
86     }
87    
88     string ImagePathForProject(const string& pname)
89     {
90         for ( int i = 0 ; i <  pspecs.size(); i++ )
91         {
92             if ( pspecs[i].projectName == pname ) return pspecs[i].pathToImage;
93            
94         }
95         return "empty";
96
97     }
98
99
100     void InitTree()
101     {
102
103         rootItem = m_options.InsertItem("Projects",1,1);
104         projectMap["Projects"] = rootItem;
105
106         pspecs = Globals::settings->pspecSettings->projects;
107         for ( int i = 0;i < pspecs.size(); i++ )
108         {
109             CreateTreeItem(pspecs[i].rootFolder,pspecs[i].projectName );
110        
111         }
112
113         m_options.Expand(rootItem,TVE_EXPAND);
114     }
115
116     void CreateTreeItem(const string& path, const string& projectName)
117     {
118         vector<string> pathList;
119         Split(path,"//",pathList);
120         HTREEITEM lastItem = rootItem;
121
122         for ( int i = 0; i < pathList.size(); i++)
123         {
124             string temp = pathList[i];
125            
126             HTREEITEM item = NULL;
127
128            
129             if ( projectMap.find(temp ) != NULL ) item = projectMap[temp];
130            
131             if ( item)
132             {
133                 if ( i + 1 == pathList.size() )
134                 {
135                     m_options.InsertItem(projectName.c_str(),100,2,item );
136                 }
137             }
138             else
139             {
140                 item = m_options.InsertItem(temp.c_str(),3,3,lastItem);
141
142                 if ( i + 1 == pathList.size() )
143                 {
144                     m_options.InsertItem(projectName.c_str(),100,2,item );
145                 }
146                 projectMap[temp] = item;
147             }
148             lastItem = item;
149         }
150
151
152            
153    
154     }
155
156     ProjectSpecs GetProjectSpecs()
157     {
158         string sel = GetSelTreeCtrlItem(&m_options);
159         for ( int i = 0 ; i <  pspecs.size(); i++ )
160         {
161             if ( pspecs[i].projectName == sel ) return pspecs[i];
162            
163         }               
164
165        
166         throw new exception;
167
168     }
169
170 // Overrides
171     // ClassWizard generated virtual function overrides
172     //{{AFX_VIRTUAL(CNewProjectDlg)
173     protected:
174     virtual void DoDataExchange(CDataExchange* pDX);    // DDX/DDV support
175     //}}AFX_VIRTUAL
176
177 // Implementation
178 protected:
179
180     // Generated message map functions
181     //{{AFX_MSG(CNewProjectDlg)
182     virtual BOOL OnInitDialog();
183     afx_msg void OnBrowse();
184     afx_msg void OnDestroy();
185     afx_msg void OnProjectTreeChange(NMHDR* pNMHDR, LRESULT* pResult);
186     afx_msg void OnCancel();
187     afx_msg void OnOk();
188     afx_msg void OnProjectNameChange();
189     //}}AFX_MSG
190     DECLARE_MESSAGE_MAP()
191 };
192
193 //{{AFX_INSERT_LOCATION}}
194 // Microsoft Visual C++ will insert additional declarations immediately before the previous line.
195
196 #endif // !defined(AFX_NEWPROJECTDLG_H__09250A6E_737D_4DBE_AC1A_65D2FD57F5AC__INCLUDED_)
Note: See TracBrowser for help on using the browser.