root/trunk/SettingsDlg.cpp

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

Initial ( and last :( ) commit

Line 
1 // SettingsDlg.cpp : implementation file
2 //
3
4 #include "stdafx.h"
5 #include "Elephant.h"
6 #include "SettingsDlg.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 // CSettingsDlg dialog
16
17
18 CSettingsDlg::CSettingsDlg(CWnd* parent, bool selProject)
19     : CDialog(CSettingsDlg::IDD, parent), selectProject(selProject)
20 {
21     //{{AFX_DATA_INIT(CSettingsDlg)
22         // NOTE: the ClassWizard will add member initialization here
23     //}}AFX_DATA_INIT
24 }
25
26
27 void CSettingsDlg::DoDataExchange(CDataExchange* pDX)
28 {
29     CDialog::DoDataExchange(pDX);
30     //{{AFX_DATA_MAP(CSettingsDlg)
31     DDX_Control(pDX, IDC_BUTTON2, m_close);
32     DDX_Control(pDX, IDC_BUTTON1, m_save);
33     DDX_Control(pDX, IDC_TREE1, m_options);
34     //}}AFX_DATA_MAP
35 }
36
37
38 BEGIN_MESSAGE_MAP(CSettingsDlg, CDialog)
39     //{{AFX_MSG_MAP(CSettingsDlg)
40     ON_NOTIFY(TVN_SELCHANGED, IDC_TREE1, OnSelchangedTree1)
41     ON_NOTIFY(NM_CLICK, IDC_TREE1, OnClickTree1)
42     ON_BN_CLICKED(IDC_BUTTON2, OnClose)
43     ON_BN_CLICKED(IDC_BUTTON1, OnSave)
44     //}}AFX_MSG_MAP
45 END_MESSAGE_MAP()
46
47 /////////////////////////////////////////////////////////////////////////////
48 // CSettingsDlg message handlers
49
50 BOOL CSettingsDlg::OnInitDialog()
51 {
52     CDialog::OnInitDialog();
53
54     SetupButton(&m_close);
55     SetupButton(&m_save);
56
57     InitTree();
58
59     //m_debugPage.CRHCreateGenericChildDialog(this,IDC_PLACEHOLDER,IDD);
60     //m_releasePage.CRHCreateGenericChildDialog(this,IDC_PLACEHOLDER,IDD);
61     //m_linkerPage.CRHCreateGenericChildDialog(this,IDC_PLACEHOLDER,IDD);
62     //m_fileFormationPage.CRHCreateGenericChildDialog(this,IDC_PLACEHOLDER,IDD);
63     m_scriptsPage.CRHCreateGenericChildDialog(this,IDC_PLACEHOLDER,IDD);
64     m_importPage.CRHCreateGenericChildDialog(this,IDC_PLACEHOLDER,IDD);
65     m_tagsPage.CRHCreateGenericChildDialog(this,IDC_PLACEHOLDER,IDD);
66     m_abbsPage.CRHCreateGenericChildDialog(this,IDC_PLACEHOLDER,IDD);
67     m_compilerPage.CRHCreateGenericChildDialog(this,IDC_PLACEHOLDER,IDD);
68     m_behaviorPage.CRHCreateGenericChildDialog(this,IDC_PLACEHOLDER,IDD);
69     m_fileExtPage.CRHCreateGenericChildDialog(this,IDC_PLACEHOLDER,IDD);
70     m_editorPage.CRHCreateGenericChildDialog(this,IDC_PLACEHOLDER,IDD);
71     m_keywordColorPage.CRHCreateGenericChildDialog(this,IDC_PLACEHOLDER,IDD);
72     m_formatPage.CRHCreateGenericChildDialog(this,IDC_PLACEHOLDER,IDD);
73     m_angelPage  .CRHCreateGenericChildDialog(this,IDC_PLACEHOLDER,IDD);
74     m_eventsPage.CRHCreateGenericChildDialog(this,IDC_PLACEHOLDER,IDD);
75     m_appearancePage.CRHCreateGenericChildDialog(this,IDC_PLACEHOLDER,IDD);
76
77    
78     m_constantsDlg.CRHCreateGenericChildDialog(this,IDC_PLACEHOLDER,IDD);
79     //m_accelsPage.CRHCreateGenericChildDialog(this,IDC_PLACEHOLDER,IDD);
80    
81     m_makefileDlg.CRHCreateGenericChildDialog(this,IDC_PLACEHOLDER,IDD);
82     m_buildOptions.CRHCreateGenericChildDialog(this,IDC_PLACEHOLDER,IDD);   
83     m_configDlg.CRHCreateGenericChildDialog(this,IDC_PLACEHOLDER,IDD);
84     m_defsPage.CRHCreateGenericChildDialog(this,IDC_PLACEHOLDER,IDD);
85     m_previewPage.CRHCreateGenericChildDialog(this,IDC_PLACEHOLDER,IDD);
86     m_fileBuildPage.CRHCreateGenericChildDialog(this,IDC_PLACEHOLDER,IDD);
87     m_fileDMDPage.CRHCreateGenericChildDialog(this,IDC_PLACEHOLDER,IDD);
88     //m_libsPage.CRHCreateGenericChildDialog(this,IDC_PLACEHOLDER,IDD);
89     //  m_themesPage.CRHCreateGenericChildDialog(this,IDC_PLACEHOLDER,IDD);
90
91     if ( !m_imageList.Create( 16, 16, ILC_COLOR24 | ILC_MASK, 16, 16 ) )
92     {
93         TRACE("Failed to create image list.\n");
94         return -1;
95     }
96     else TRACE("Succeeded creating image list");
97    
98    
99    
100     m_bitmap.LoadBitmap( IDB_BITMAP3 );
101     m_imageList.Add( &m_bitmap, RGB( 0x00,0xff,0x00 ) );
102
103     m_options.SetImageList(&m_imageList, TVSIL_NORMAL );
104
105     HideAll();
106     selectProject ? m_configDlg.ShowWindow(SW_SHOW) : m_importPage.ShowWindow(SW_SHOW);
107
108
109     SetIcon(AfxGetApp()->LoadIcon(IDR_ELEPHANT) ,true);
110    
111     return TRUE;  // return TRUE unless you set the focus to a control
112                   // EXCEPTION: OCX Property Pages should return FALSE
113 }
114
115 void CSettingsDlg::OnSelchangedTree1(NMHDR* pNMHDR, LRESULT* pResult)
116 {
117     NM_TREEVIEW* pNMTreeView = (NM_TREEVIEW*)pNMHDR;
118     CString sel = m_options.GetItemText(pNMTreeView->itemNew.hItem);
119    
120    
121
122     if ( sel == "debug") HideAndShow(&m_debugPage);
123     else if ( sel == "release" ) HideAndShow(&m_releasePage);
124     else if ( sel == "linker" ) HideAndShow(&m_linkerPage);
125     else if ( sel == "scripts" ) HideAndShow(&m_scriptsPage);
126     else if ( sel == "import paths" ) HideAndShow(&m_importPage);
127     else if ( sel == "tag sets" ) HideAndShow(&m_tagsPage);
128     else if ( sel == "abbreviations" ) HideAndShow(&m_abbsPage);
129     else if ( sel == "compiler settings" ) HideAndShow(&m_compilerPage);
130     else if ( sel == "appearance" ) HideAndShow(&m_appearancePage);
131     else if ( sel == "behavior" ) HideAndShow(&m_behaviorPage);
132     //else if ( sel == "file extensions" ) HideAndShow(&m_fileExtPage);
133     else if ( sel == "editor" ) HideAndShow(&m_editorPage);
134     else if ( sel == "keywords & colors" ) HideAndShow(&m_keywordColorPage);
135     else if ( sel == "format settings" ) HideAndShow(&m_formatPage);
136     else if ( sel == "angel script" ) HideAndShow(&m_angelPage);
137     else if ( sel == "elephant events" ) HideAndShow(&m_eventsPage);
138     else if ( sel == "file formation" ) HideAndShow(&m_fileFormationPage);
139     else if ( sel == "constants" ) HideAndShow(&m_constantsDlg);
140     else if ( sel == "build scripts" ) HideAndShow(&m_makefileDlg);
141     else if ( sel == "build options" ) HideAndShow(&m_buildOptions);
142     else if ( sel == "configurations" ) HideAndShow(&m_configDlg);
143     else if ( sel == "definitions" ) HideAndShow(&m_defsPage);
144     else if ( sel == "preview" ) HideAndShow(&m_previewPage);
145     else if ( sel == "build file settings" ) HideAndShow(&m_fileBuildPage);
146     else if ( sel == "dmd file settings" ) HideAndShow(&m_fileDMDPage);
147     //  else if ( sel == "visual templates" ) HideAndShow(&m_themesPage);
148     //else if ( sel == "libraries" ) HideAndShow(&m_libsPage);
149     //else if ( sel == "accelerators" ) HideAndShow(&m_accelsPage);
150
151        
152     *pResult = 0;
153 }
154
155 void CSettingsDlg::OnClickTree1(NMHDR* pNMHDR, LRESULT* pResult)
156 {
157     // TODO: Add your control notification handler code here
158        
159     *pResult = 0;
160 }
161
162 void CSettingsDlg::OnClose()
163 {
164    
165 EndDialog(0);   // TODO: Add your control notification handler code here
166    
167 }
168
169 void CSettingsDlg::OnSave()
170 {
171
172 //  m_debugPage.Save();
173 //  m_releasePage.Save();
174 //  m_linkerPage.Save();
175    
176
177     m_scriptsPage.Save();
178     m_importPage.Save();
179     m_tagsPage.Save();
180     m_abbsPage.Save();
181     m_compilerPage.Save();
182     m_behaviorPage.Save();
183     //m_fileExtPage.Save();
184     m_editorPage.Save();
185     m_keywordColorPage.Save();
186     m_formatPage.Save();
187     m_angelPage.Save();
188     m_eventsPage.Save();
189     m_appearancePage.Save();
190     m_fileBuildPage.Save();
191     m_fileDMDPage.Save();
192     //  m_themesPage.Save();
193    
194    
195    
196     if ( Globals::currentProject )
197     {
198    
199       CString str;
200       m_configDlg.m_cbConfigs.GetLBText(m_configDlg.m_cbConfigs.GetCurSel(),str);
201       //AfxMessageBox(str);
202       SaveProjectPages();
203       Globals::currentProject->SetCache("CurrentConfiguration",str.GetBuffer(0));       
204    
205     }
206
207     Globals::settings->SaveAll();
208
209    
210     Globals::theApp.LogEvent(ELEPHANT_START,"Saving Settings" , Globals::installPath );
211     AfxMessageBox(Globals::settings->baseSettings->GetCache("installPath").c_str() );
212     AfxMessageBox(Globals::settings->baseSettings->GetCache("dmdPath").c_str() );
213
214     EndDialog(1);
215
216 }
217
218 void CSettingsDlg::UpdateProjectPages()
219 {
220     m_configDlg.UpdatePage();
221     m_libsPage.UpdatePage();
222     m_defsPage.UpdatePage();
223     m_buildOptions.UpdatePage();
224     // m_makefileDlg.UpdatePage();
225 }
226
227 void CSettingsDlg::SaveProjectPages()
228 {
229     m_configDlg.Save();
230     //  m_libsPage.Save();
231     m_defsPage.Save();
232     m_buildOptions.Save();
233     m_makefileDlg.Save();
234
235
236     CMainFrame* m = static_cast<CMainFrame*>(Globals::theApp.m_pMainWnd);
237     m->UpdateConfigCombo();
238 }
Note: See TracBrowser for help on using the browser.