root/trunk/AddNewProjectWizard.cpp

Revision 5, 5.8 kB (checked in by qbert, 3 years ago)

Initial ( and last :( ) commit

Line 
1 // AddNewProjectWizard.cpp : implementation file
2 //
3
4 #include "stdafx.h"
5 #include "Elephant.h"
6 #include "AddNewProjectWizard.h"
7
8 #ifdef _DEBUG
9 #define new DEBUG_NEW
10 #undef THIS_FILE
11 static char THIS_FILE[] = __FILE__;
12 #endif
13
14 /////////////////////////////////////////////////////////////////////////////
15 // CAddNewProjectWizard dialog
16
17
18 CAddNewProjectWizard::CAddNewProjectWizard(CWnd* pParent /*=NULL*/)
19 : CDialog(CAddNewProjectWizard::IDD, pParent)
20 {
21     //{{AFX_DATA_INIT(CAddNewProjectWizard)
22     //}}AFX_DATA_INIT
23 }
24
25
26 void CAddNewProjectWizard::DoDataExchange(CDataExchange* pDX)
27 {
28     CDialog::DoDataExchange(pDX);
29     //{{AFX_DATA_MAP(CAddNewProjectWizard)
30     DDX_Control(pDX, IDC_BUTTON3, m_ok);
31     DDX_Control(pDX, IDC_TREE1, m_options);
32     DDX_Control(pDX, IDC_BUTTON2, m_cancel);
33     //}}AFX_DATA_MAP
34 }
35
36
37 BEGIN_MESSAGE_MAP(CAddNewProjectWizard, CDialog)
38 //{{AFX_MSG_MAP(CAddNewProjectWizard)
39 ON_NOTIFY(TVN_SELCHANGED, IDC_TREE1, OnSelchangedTree1)
40 ON_BN_CLICKED(IDC_BUTTON2, OnCancel)
41 ON_BN_CLICKED(IDC_BUTTON3, OnOk)
42 //}}AFX_MSG_MAP
43 END_MESSAGE_MAP()
44
45 /////////////////////////////////////////////////////////////////////////////
46 // CAddNewProjectWizard message handlers
47
48 BOOL CAddNewProjectWizard::OnInitDialog()
49 {
50     CDialog::OnInitDialog();
51    
52    
53     SetupButton(&m_cancel);
54     SetupButton(&m_ok);
55    
56     if ( !m_imageList.Create( 16, 16, ILC_COLOR24 | ILC_MASK, 16, 16 ) )
57     {
58         TRACE("Failed to create image list.\n");
59         return -1;
60     }
61     else TRACE("Succeeded creating image list");
62    
63     m_bitmap.LoadBitmap( IDB_BITMAP3 );
64     m_imageList.Add( &m_bitmap, RGB( 0x00,0xff,0x00 ) );
65    
66     m_options.SetImageList(&m_imageList, TVSIL_NORMAL );
67
68     InitTree();
69    
70     m_detailsPage.CRHCreateGenericChildDialog(this,IDC_PLACEHOLDER,IDD);
71     m_filesPage.CRHCreateGenericChildDialog(this,IDC_PLACEHOLDER,IDD);
72     m_compilerPage.CRHCreateGenericChildDialog(this,IDC_PLACEHOLDER,IDD);
73     //m_finishPage.CRHCreateGenericChildDialog(this,IDC_PLACEHOLDER,IDD);
74     m_buildPage.CRHCreateGenericChildDialog(this,IDC_PLACEHOLDER,IDD);
75     m_libPage.CRHCreateGenericChildDialog(this,IDC_PLACEHOLDER,IDD);
76    
77     HideAll();
78     m_detailsPage.ShowWindow(SW_SHOW);
79    
80     SetIcon(AfxGetApp()->LoadIcon(IDR_ELEPHANT) ,true);
81    
82    
83    
84     return TRUE;  // return TRUE unless you set the focus to a control
85     // EXCEPTION: OCX Property Pages should return FALSE
86 }
87
88 void CAddNewProjectWizard::OnSelchangedTree1(NMHDR* pNMHDR, LRESULT* pResult)
89 {
90     NM_TREEVIEW* pNMTreeView = (NM_TREEVIEW*)pNMHDR;
91     // TODO: Add your control notification handler code here
92     CString sel = m_options.GetItemText(pNMTreeView->itemNew.hItem);
93    
94    
95    
96     if ( sel == "project details") HideAndShow(&m_detailsPage);
97     else if ( sel == "compiler options" ) HideAndShow(&m_compilerPage);
98     else if ( sel == "build options" ) HideAndShow(&m_buildPage);
99     else if ( sel == "files" ) HideAndShow(&m_filesPage);
100     else if ( sel == "libraries" ) HideAndShow(&m_libPage);
101    
102     *pResult = 0;
103 }
104
105 void CAddNewProjectWizard::OnCancel()
106 {
107     EndDialog(0);
108    
109 }
110
111 void CAddNewProjectWizard::OnOk()
112 {
113     CreateProject();
114    
115 }
116 void CAddNewProjectWizard::CreateProject()
117 {
118     m_detailsPage.UpdateData();
119     m_filesPage.UpdateData();
120     m_compilerPage.UpdateData();
121     m_buildPage.UpdateData();
122     m_libPage.UpdateData();
123    
124             ProjectSpecs p;
125             p.authorName = m_detailsPage.m_csAuthor.GetBuffer(0);
126             p.companyName = m_detailsPage.m_csCompany.GetBuffer(0);     
127             p.description = m_detailsPage.m_csDescription.GetBuffer(0);         
128             p.M = m_buildPage.m_M.GetBuffer(0);
129             p.X = m_buildPage.m_X.GetBuffer(0);
130             p.projectName = m_detailsPage.m_csProjectName.GetBuffer(0);
131             p.rootFolder = m_detailsPage.m_csRootFolder.GetBuffer(0);
132
133             p.allobj = m_buildPage.m_allobj;
134             p.allowDeprecated = m_compilerPage.m_allowDeprecated;
135             p.clean = m_buildPage.m_clean;
136             p.debug = m_compilerPage.m_debug;
137             p.debugIdentifiers = m_compilerPage.m_csDebug;
138             p.dll = m_buildPage.m_dll;
139             p.full = m_buildPage.m_full;
140             p.gui = m_buildPage.m_gui;
141             p.inlin = m_compilerPage.m_inline;
142             p.lib = m_buildPage.m_lib;
143             p.link = m_buildPage.m_link;
144             p.names = m_buildPage.m_names;
145             p.nolib = m_buildPage.m_nolib;
146             p.nolink = m_buildPage.m_nolink;
147             p.obj = m_buildPage.m_obj;
148             p.optimize = m_compilerPage.m_optimize;
149             p.pHooks = m_compilerPage.m_pHooks;
150            
151            
152             p.release = m_compilerPage.m_release;
153             p.silent = m_buildPage.m_silent;
154             p.test = m_buildPage.m_test;
155             p.unittest = m_compilerPage.m_unittest;
156             p.v = m_buildPage.m_v;
157             p.verbose = m_compilerPage.m_verbose;
158             //p.versionIdentifiers = m_detailsPage.m
159            
160            
161            
162     //     
163             GetAllListCtrlItems(&m_filesPage.m_files,&p.files);
164             vector<string> libs;
165             GetAllListCtrlItems(&m_libPage.m_libraries,&libs);
166             p.libraries = Join(libs,",");
167     //
168     //      p.libraries = m_compilerPage.m_csLibs.GetBuffer(0);
169     //      p.linkerFlags = m_compilerPage.m_csLinker.GetBuffer(0);
170     ////        p.pathToImage = m_detailsPage.m_csImagePath.GetBuffer(0);
171
172     ////        p.treeImagePath = m_detailsPage.m_csImagePath.GetBuffer(0);
173     //      p.debugIdentifiers = m_compilerPage.m_csDebug == m_compilerPage.m_debug.GetText().c_str() ? "" : m_compilerPage.m_csDebug.GetBuffer(0);
174     //      p.versionIdentifiers = m_compilerPage.m_csVersion == m_compilerPage.m_version.GetText().c_str() ? "" : m_compilerPage.m_csVersion.GetBuffer(0);
175     //      p.staticLib = m_compilerPage.m_staticLib;
176     //      p.sharedLib = m_compilerPage.m_sharedLib;
177     //
178             bool err = false;
179     //
180             if ( p.projectName == "" || p.projectName == m_detailsPage.m_projectName.GetText() )
181             {
182                 ElephantMessageBox("You must enter a name for the project.");
183                 err = true;
184             }
185             if (p.rootFolder == "" || p.rootFolder == m_detailsPage.m_rootFolder.GetText() )
186             {
187                 p.rootFolder = "Projects";         
188             }
189    
190             if (!err) {
191            
192                 Globals::settings->pspecSettings->CreateNewProjectType(p);
193                 EndDialog(0);
194             }
195    
196    
197    
198 }
Note: See TracBrowser for help on using the browser.