| 1 |
// ConfigurationsDlg.cpp : implementation file |
|---|
| 2 |
// |
|---|
| 3 |
|
|---|
| 4 |
#include "stdafx.h" |
|---|
| 5 |
#include "Elephant.h" |
|---|
| 6 |
#include "ConfigurationsDlg.h" |
|---|
| 7 |
#include "SettingsDlg.h" |
|---|
| 8 |
#ifdef _DEBUG |
|---|
| 9 |
#define new DEBUG_NEW |
|---|
| 10 |
#undef THIS_FILE |
|---|
| 11 |
static char THIS_FILE[] = __FILE__; |
|---|
| 12 |
#endif |
|---|
| 13 |
|
|---|
| 14 |
///////////////////////////////////////////////////////////////////////////// |
|---|
| 15 |
// CConfigurationsDlg dialog |
|---|
| 16 |
|
|---|
| 17 |
|
|---|
| 18 |
CConfigurationsDlg::CConfigurationsDlg(CWnd* pParent /*=NULL*/) |
|---|
| 19 |
|
|---|
| 20 |
{ |
|---|
| 21 |
|
|---|
| 22 |
//{{AFX_DATA_INIT(CConfigurationsDlg) |
|---|
| 23 |
//}}AFX_DATA_INIT |
|---|
| 24 |
} |
|---|
| 25 |
|
|---|
| 26 |
|
|---|
| 27 |
void CConfigurationsDlg::DoDataExchange(CDataExchange* pDX) |
|---|
| 28 |
{ |
|---|
| 29 |
CDialog::DoDataExchange(pDX); |
|---|
| 30 |
//{{AFX_DATA_MAP(CConfigurationsDlg) |
|---|
| 31 |
DDX_Control(pDX, IDC_COMBO1, m_cbConfigs); |
|---|
| 32 |
DDX_Control(pDX, IDC_BUTTON2, m_remove); |
|---|
| 33 |
DDX_Control(pDX, IDC_BUTTON1, m_add); |
|---|
| 34 |
DDX_CBIndex(pDX, IDC_COMBO1, m_configurations); |
|---|
| 35 |
DDX_Check(pDX, IDC_CHECK2, m_inline); |
|---|
| 36 |
DDX_Check(pDX, IDC_CHECK24, m_optimize); |
|---|
| 37 |
DDX_Check(pDX, IDC_CHECK21, m_allowDeprecated); |
|---|
| 38 |
DDX_Check(pDX, IDC_CHECK23, m_warnings); |
|---|
| 39 |
DDX_Check(pDX, IDC_CHECK4, m_verbose); |
|---|
| 40 |
DDX_Check(pDX, IDC_CHECK1, m_release); |
|---|
| 41 |
DDX_Check(pDX, IDC_CHECK3, m_debug); |
|---|
| 42 |
DDX_Check(pDX, IDC_CHECK18, m_pHooks); |
|---|
| 43 |
DDX_Check(pDX, IDC_CHECK22, m_unittest); |
|---|
| 44 |
//}}AFX_DATA_MAP |
|---|
| 45 |
} |
|---|
| 46 |
|
|---|
| 47 |
|
|---|
| 48 |
BEGIN_MESSAGE_MAP(CConfigurationsDlg, CRHGenericChildDialog) |
|---|
| 49 |
//{{AFX_MSG_MAP(CConfigurationsDlg) |
|---|
| 50 |
ON_BN_CLICKED(IDC_BUTTON1, OnAdd) |
|---|
| 51 |
ON_CBN_SELCHANGE(IDC_COMBO1, OnConfigChange) |
|---|
| 52 |
ON_BN_CLICKED(IDC_BUTTON2, OnRemove) |
|---|
| 53 |
//}}AFX_MSG_MAP |
|---|
| 54 |
END_MESSAGE_MAP() |
|---|
| 55 |
|
|---|
| 56 |
///////////////////////////////////////////////////////////////////////////// |
|---|
| 57 |
// CConfigurationsDlg message handlers |
|---|
| 58 |
|
|---|
| 59 |
BOOL CConfigurationsDlg::OnInitDialog() |
|---|
| 60 |
{ |
|---|
| 61 |
CRHGenericChildDialog::OnInitDialog(); |
|---|
| 62 |
|
|---|
| 63 |
SetupButton(&m_remove); |
|---|
| 64 |
SetupButton(&m_add); |
|---|
| 65 |
|
|---|
| 66 |
|
|---|
| 67 |
if (Globals::currentProject ) |
|---|
| 68 |
{ |
|---|
| 69 |
string cconfig = Globals::currentProject->GetCache("CurrentConfiguration"); |
|---|
| 70 |
m_cbConfigs.ResetContent(); |
|---|
| 71 |
int sel = 0; |
|---|
| 72 |
vector<string> configs; |
|---|
| 73 |
Split(Globals::currentProject->GetCache("Configurations") ,",",configs ); |
|---|
| 74 |
|
|---|
| 75 |
for ( int i = 0 ; i < configs.size(); i++ ) |
|---|
| 76 |
{ |
|---|
| 77 |
if ( cconfig == configs[i]) sel = i; |
|---|
| 78 |
m_cbConfigs.AddString(configs[i].c_str() ); |
|---|
| 79 |
} |
|---|
| 80 |
|
|---|
| 81 |
m_cbConfigs.SetCurSel(sel ); |
|---|
| 82 |
} |
|---|
| 83 |
|
|---|
| 84 |
|
|---|
| 85 |
|
|---|
| 86 |
UpdatePage(); |
|---|
| 87 |
|
|---|
| 88 |
return TRUE; // return TRUE unless you set the focus to a control |
|---|
| 89 |
// EXCEPTION: OCX Property Pages should return FALSE |
|---|
| 90 |
} |
|---|
| 91 |
|
|---|
| 92 |
void CConfigurationsDlg::OnAdd() |
|---|
| 93 |
{ |
|---|
| 94 |
|
|---|
| 95 |
if ( !Globals::currentProject ) |
|---|
| 96 |
{ |
|---|
| 97 |
return; |
|---|
| 98 |
|
|---|
| 99 |
} |
|---|
| 100 |
CGetInputDlg dlg("Enter the new configuration name."); |
|---|
| 101 |
|
|---|
| 102 |
if ( dlg.DoModal()) |
|---|
| 103 |
{ |
|---|
| 104 |
string config = dlg.m_csValue.GetBuffer(0); |
|---|
| 105 |
|
|---|
| 106 |
m_cbConfigs.AddString(config.c_str()); |
|---|
| 107 |
//m_cbConfigs.SetCurSel(m_cbConfigs.GetCount() - 1 ); |
|---|
| 108 |
|
|---|
| 109 |
|
|---|
| 110 |
} |
|---|
| 111 |
|
|---|
| 112 |
} |
|---|
| 113 |
|
|---|
| 114 |
void CConfigurationsDlg::OnConfigChange() |
|---|
| 115 |
{ |
|---|
| 116 |
UpdateData(); |
|---|
| 117 |
|
|---|
| 118 |
CSettingsDlg* parent = static_cast<CSettingsDlg*>(CRHpParent ); |
|---|
| 119 |
CString str; |
|---|
| 120 |
m_cbConfigs.GetLBText(m_cbConfigs.GetCurSel(),str); |
|---|
| 121 |
//AfxMessageBox(str); |
|---|
| 122 |
parent->SaveProjectPages(); |
|---|
| 123 |
Globals::currentProject->SetCache("CurrentConfiguration",str.GetBuffer(0)); |
|---|
| 124 |
|
|---|
| 125 |
parent->UpdateProjectPages(); |
|---|
| 126 |
|
|---|
| 127 |
} |
|---|
| 128 |
|
|---|
| 129 |
void CConfigurationsDlg::OnRemove() |
|---|
| 130 |
{ |
|---|
| 131 |
|
|---|
| 132 |
UpdateData(); |
|---|
| 133 |
|
|---|
| 134 |
if (!Globals::currentProject) return; |
|---|
| 135 |
|
|---|
| 136 |
if ( m_cbConfigs.GetCount() == 1) |
|---|
| 137 |
{ |
|---|
| 138 |
|
|---|
| 139 |
ElephantMessageBox("You must have at least one configuration."); |
|---|
| 140 |
return; |
|---|
| 141 |
} |
|---|
| 142 |
CString _str; |
|---|
| 143 |
m_cbConfigs.GetLBText(m_cbConfigs.GetCurSel(),_str); |
|---|
| 144 |
string str = _str.GetBuffer(0); |
|---|
| 145 |
|
|---|
| 146 |
vector<string> items,newItems; |
|---|
| 147 |
Split(Globals::currentProject->GetCache("Configurations" ),",",items ); |
|---|
| 148 |
|
|---|
| 149 |
for ( int i = 0 ; i < items.size(); i++ ) |
|---|
| 150 |
{ |
|---|
| 151 |
if ( items[i] == str ) continue; |
|---|
| 152 |
else newItems.push_back(items[i]); |
|---|
| 153 |
|
|---|
| 154 |
} |
|---|
| 155 |
|
|---|
| 156 |
Globals::currentProject->SetCache("Configurations",Join(newItems,",")); |
|---|
| 157 |
|
|---|
| 158 |
string lastConfig = ""; |
|---|
| 159 |
|
|---|
| 160 |
if (Globals::currentProject ) |
|---|
| 161 |
{ |
|---|
| 162 |
m_cbConfigs.ResetContent(); |
|---|
| 163 |
|
|---|
| 164 |
vector<string> configs; |
|---|
| 165 |
Split(Globals::currentProject->GetCache("Configurations") ,",",configs ); |
|---|
| 166 |
|
|---|
| 167 |
for ( int i = 0 ; i < configs.size(); i++ ) |
|---|
| 168 |
{ |
|---|
| 169 |
lastConfig = configs[i]; |
|---|
| 170 |
m_cbConfigs.AddString(lastConfig.c_str() ); |
|---|
| 171 |
} |
|---|
| 172 |
|
|---|
| 173 |
m_cbConfigs.SetCurSel(m_cbConfigs.GetCount()-1); |
|---|
| 174 |
|
|---|
| 175 |
Globals::currentProject->SetCache("CurrentConfiguration",lastConfig); |
|---|
| 176 |
|
|---|
| 177 |
} |
|---|
| 178 |
CSettingsDlg* parent = static_cast<CSettingsDlg*>(CRHpParent ); |
|---|
| 179 |
parent->UpdateProjectPages(); |
|---|
| 180 |
|
|---|
| 181 |
} |
|---|