Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Extract Environment Variables grid to separate control; (data get/set…

… not hooked up yet.)
  • Loading branch information...
commit f66a5ebfa0460ee7ac8be6fecd69eb01553424cf 1 parent d1d926d
@adamv adamv authored
View
73 src/EnvVarsPanel.cpp
@@ -0,0 +1,73 @@
+#include "EnvVarsPanel.h"
+#include <wx/grid.h>
+
+enum {
+ ID_BUTTON_ADD,
+ ID_BUTTON_DEL,
+ ID_ENVLIST
+};
+
+BEGIN_EVENT_TABLE(EnvVarsPanel, wxPanel)
+ EVT_BUTTON(ID_BUTTON_ADD, EnvVarsPanel::OnButtonAddEnv)
+ EVT_BUTTON(ID_BUTTON_DEL, EnvVarsPanel::OnButtonDelEnv)
+ EVT_GRID_CMD_CELL_CHANGE(ID_ENVLIST, EnvVarsPanel::OnGridChange)
+END_EVENT_TABLE()
+
+
+EnvVarsPanel::EnvVarsPanel(wxWindow*parent, wxWindowID id):
+ wxPanel(parent, id),
+ m_varsChanged(false)
+{
+ m_envList = new wxGrid(this, ID_ENVLIST, wxDefaultPosition, wxDefaultSize, wxWANTS_CHARS|wxSUNKEN_BORDER);
+ wxButton* addButton = new wxButton(this, ID_BUTTON_ADD, wxT("+"), wxDefaultPosition, wxSize(45, -1));
+ wxButton* delButton = new wxButton(this, ID_BUTTON_DEL, wxT("-"), wxDefaultPosition, wxSize(45, -1));
+
+ m_envList->CreateGrid(0, 2);
+ m_envList->SetColLabelValue(0, _("Key"));
+ m_envList->SetColLabelValue(1, _("Value"));
+ m_envList->SetMargins(0,0);
+ m_envList->SetRowLabelSize(0);
+ m_envList->SetColLabelSize(19);
+ m_envList->EnableEditing(true);
+ m_envList->EnableGridLines(true);
+ m_envList->EnableDragColSize(true);
+ m_envList->EnableDragRowSize(false);
+ m_envList->EnableDragGridSize(false);
+ m_envList->SetSelectionMode(wxGrid::wxGridSelectRows);
+
+ m_envList->SetColSize(0, 100);
+ m_envList->SetColSize(1, 230);
+
+ wxBoxSizer* pageSizer = new wxBoxSizer(wxVERTICAL);
+ pageSizer->Add(m_envList, 1, wxEXPAND|wxALL, 5);
+ wxBoxSizer* buttonSizer = new wxBoxSizer(wxHORIZONTAL);
+ buttonSizer->Add(addButton, 0, wxRIGHT, 5);
+ buttonSizer->Add(delButton, 0);
+ pageSizer->Add(buttonSizer, 0, wxLEFT|wxRIGHT|wxBOTTOM, 5);
+
+ this->SetSizer(pageSizer);
+}
+
+EnvVarsPanel::~EnvVarsPanel(void){}
+
+void EnvVarsPanel::OnButtonAddEnv(wxCommandEvent& WXUNUSED(event)) {
+ const unsigned int gridPos = m_envList->GetNumberRows();
+ m_envList->InsertRows(gridPos);
+ m_envList->SetGridCursor(gridPos, 0);
+ m_envList->MakeCellVisible(gridPos, 0);
+ m_envList->ForceRefresh();
+ m_envList->EnableCellEditControl();
+}
+
+void EnvVarsPanel::OnButtonDelEnv(wxCommandEvent& WXUNUSED(event)) {
+ const int rowId = m_envList->GetGridCursorRow();
+ if (rowId != -1) {
+ m_envList->DeleteRows(rowId);
+ m_envList->ForceRefresh();
+ m_varsChanged = true;
+ }
+}
+
+void EnvVarsPanel::OnGridChange(wxGridEvent& WXUNUSED(event)) {
+ m_varsChanged = true;
+}
View
30 src/EnvVarsPanel.h
@@ -0,0 +1,30 @@
+#ifndef __ENVVARSPANEL_H__
+#define __ENVVARSPANEL_H__
+
+#include "wx/wxprec.h"
+#ifndef WX_PRECOMP
+ #include <wx/dialog.h>
+#endif
+
+class wxGrid;
+class wxGridEvent;
+
+class EnvVarsPanel : public wxPanel
+{
+public:
+ EnvVarsPanel(wxWindow*parent, wxWindowID id = wxID_ANY);
+ virtual ~EnvVarsPanel(void);
+
+ bool VarsChanged(){return m_varsChanged;}
+
+private:
+ void OnButtonAddEnv(wxCommandEvent& event);
+ void OnButtonDelEnv(wxCommandEvent& event);
+ void OnGridChange(wxGridEvent& event);
+ DECLARE_EVENT_TABLE()
+
+ wxGrid* m_envList;
+ bool m_varsChanged;
+};
+
+#endif
View
113 src/ProjectSettings.cpp
@@ -12,25 +12,22 @@
******************************************************************************/
#include "ProjectSettings.h"
-#include "ProjectInfo.h"
+
#include <wx/notebook.h>
#include <wx/tokenzr.h>
#include <wx/grid.h>
+
+#include "EnvVarsPanel.h"
+#include "ProjectInfo.h"
#include "Strings.h"
// ctrl ids
enum {
ID_INHERIT,
- ID_BUTTON_ADD,
- ID_BUTTON_DEL,
- ID_ENVLIST
};
BEGIN_EVENT_TABLE(ProjectSettings, wxDialog)
EVT_CHECKBOX(ID_INHERIT, ProjectSettings::OnInheritCheck)
- EVT_BUTTON(ID_BUTTON_ADD, ProjectSettings::OnButtonAddEnv)
- EVT_BUTTON(ID_BUTTON_DEL, ProjectSettings::OnButtonDelEnv)
- EVT_GRID_CMD_CELL_CHANGE(ID_ENVLIST, ProjectSettings::OnGridChange)
END_EVENT_TABLE()
ProjectSettings::ProjectSettings(wxWindow* parent, const cxProjectInfo& project, const cxProjectInfo& parentProject)
@@ -75,40 +72,8 @@ ProjectSettings::ProjectSettings(wxWindow* parent, const cxProjectInfo& project,
}
if (project.IsRoot()) {
- // Create the environment variable page
- wxPanel* envPage = new wxPanel(notebook, wxID_ANY);
- {
- m_envList = new wxGrid(envPage, ID_ENVLIST, wxDefaultPosition, wxDefaultSize, wxWANTS_CHARS|wxSUNKEN_BORDER);
- wxButton* addButton = new wxButton(envPage, ID_BUTTON_ADD, wxT("+"), wxDefaultPosition, wxSize(45, -1));
- wxButton* delButton = new wxButton(envPage, ID_BUTTON_DEL, wxT("-"), wxDefaultPosition, wxSize(45, -1));
-
- m_envList->CreateGrid(0, 2);
- m_envList->SetColLabelValue(0, _("Key"));
- m_envList->SetColLabelValue(1, _("Value"));
- m_envList->SetMargins(0,0);
- m_envList->SetRowLabelSize(0);
- m_envList->SetColLabelSize(19);
- m_envList->EnableEditing(true);
- m_envList->EnableGridLines(true);
- m_envList->EnableDragColSize(true);
- m_envList->EnableDragRowSize(false);
- m_envList->EnableDragGridSize(false);
- m_envList->SetSelectionMode(wxGrid::wxGridSelectRows);
-
- m_envList->SetColSize(0, 100);
- m_envList->SetColSize(1, 230);
-
- // Layout
- wxBoxSizer* pageSizer = new wxBoxSizer(wxVERTICAL);
- pageSizer->Add(m_envList, 1, wxEXPAND|wxALL, 5);
- wxBoxSizer* buttonSizer = new wxBoxSizer(wxHORIZONTAL);
- buttonSizer->Add(addButton, 0, wxRIGHT, 5);
- buttonSizer->Add(delButton, 0);
- pageSizer->Add(buttonSizer, 0, wxLEFT|wxRIGHT|wxBOTTOM, 5);
-
- envPage->SetSizer(pageSizer);
- notebook->AddPage(envPage, _("Environment"), true);
- }
+ m_envPage = new EnvVarsPanel(notebook);
+ notebook->AddPage(m_envPage, _("Environment"), true);
}
mainSizer->Add(notebook, 1, wxEXPAND|wxALL, 5);
@@ -149,10 +114,10 @@ ProjectSettings::ProjectSettings(wxWindow* parent, const cxProjectInfo& project,
// Load env variables
if (project.IsRoot()) {
for (map<wxString,wxString>::const_iterator p = project.env.begin(); p != project.env.end(); ++p) {
- const unsigned int rowId = m_envList->GetNumberRows();
- m_envList->InsertRows(rowId);
- m_envList->SetCellValue(rowId, 0, p->first);
- m_envList->SetCellValue(rowId, 1, p->second);
+ //const unsigned int rowId = m_envList->GetNumberRows();
+ //m_envList->InsertRows(rowId);
+ //m_envList->SetCellValue(rowId, 0, p->first);
+ //m_envList->SetCellValue(rowId, 1, p->second);
}
}
@@ -170,7 +135,7 @@ bool ProjectSettings::IsModified() const {
if (m_includeFiles->IsModified()) return true;
if (m_excludeFiles->IsModified()) return true;
- if (m_projectInfo.IsRoot() && m_envModified) return true;
+ if (m_projectInfo.IsRoot() && m_envPage->VarsChanged()) return true;
return false;
}
@@ -189,9 +154,9 @@ void ProjectSettings::GetSettings(cxProjectInfo& project) const {
if (m_projectInfo.IsRoot()) {
project.env.clear();
- for (int i = 0; i < m_envList->GetNumberRows(); ++i) {
- project.env[m_envList->GetCellValue(i, 0)] = m_envList->GetCellValue(i, 1);
- }
+ //for (int i = 0; i < m_envList->GetNumberRows(); ++i) {
+ // project.env[m_envList->GetCellValue(i, 0)] = m_envList->GetCellValue(i, 1);
+ //}
}
}
@@ -202,23 +167,17 @@ void ProjectSettings::OnInheritCheck(wxCommandEvent& event) {
m_excludeDirs->Clear();
m_excludeFiles->Clear();
- unsigned int i = 0;
- for (i = 0; i < m_parentProject.includeDirs.GetCount(); ++i) {
- if (i) m_includeDirs->AppendText(wxT("\n"));
- m_includeDirs->AppendText(m_parentProject.includeDirs[i]);
- }
- for (i = 0; i < m_parentProject.includeFiles.GetCount(); ++i) {
- if (i) m_includeFiles->AppendText(wxT("\n"));
- m_includeFiles->AppendText(m_parentProject.includeFiles[i]);
- }
- for (i = 0; i < m_parentProject.excludeDirs.GetCount(); ++i) {
- if (i) m_excludeDirs->AppendText(wxT("\n"));
- m_excludeDirs->AppendText(m_parentProject.excludeDirs[i]);
- }
- for (i = 0; i < m_parentProject.excludeFiles.GetCount(); ++i) {
- if (i) m_excludeFiles->AppendText(wxT("\n"));
- m_excludeFiles->AppendText(m_parentProject.excludeFiles[i]);
- }
+ const wxString ind = wxJoin(m_parentProject.includeDirs, wxT('\n'), NULL);
+ m_includeDirs->SetValue(ind);
+
+ const wxString inf = wxJoin(m_parentProject.includeFiles, wxT('\n'), NULL);
+ m_includeFiles->SetValue(inf);
+
+ const wxString exd = wxJoin(m_parentProject.excludeDirs, wxT('\n'), NULL);
+ m_excludeDirs->SetValue(exd);
+
+ const wxString exf = wxJoin(m_parentProject.excludeFiles, wxT('\n'), NULL);
+ m_excludeFiles->SetValue(exf);
m_includeDirs->Disable();
m_excludeDirs->Disable();
@@ -232,25 +191,3 @@ void ProjectSettings::OnInheritCheck(wxCommandEvent& event) {
m_excludeFiles->Enable();
}
}
-
-void ProjectSettings::OnButtonAddEnv(wxCommandEvent& WXUNUSED(event)) {
- const unsigned int gridPos = m_envList->GetNumberRows();
- m_envList->InsertRows(gridPos);
- m_envList->SetGridCursor(gridPos, 0);
- m_envList->MakeCellVisible(gridPos, 0);
- m_envList->ForceRefresh();
- m_envList->EnableCellEditControl();
-}
-
-void ProjectSettings::OnButtonDelEnv(wxCommandEvent& WXUNUSED(event)) {
- const int rowId = m_envList->GetGridCursorRow();
- if (rowId != -1) {
- m_envList->DeleteRows(rowId);
- m_envList->ForceRefresh();
- m_envModified = true; // del does not send change event?
- }
-}
-
-void ProjectSettings::OnGridChange(wxGridEvent& WXUNUSED(event)) {
- m_envModified = true;
-}
View
14 src/ProjectSettings.h
@@ -14,18 +14,16 @@
#ifndef __PROJECTSETTINGS_H__
#define __PROJECTSETTINGS_H__
-#include "wx/wxprec.h" // For compilers that support precompilation, includes "wx/wx.h".
-
+#include "wx/wxprec.h"
#ifndef WX_PRECOMP
#include <wx/dialog.h>
#endif
class cxProjectInfo;
-class wxGrid;
-class wxGridEvent;
class wxCheckBox;
class wxTextCtrl;
class wxCommandEvent;
+class EnvVarsPanel;
class ProjectSettings : public wxDialog {
public:
@@ -35,11 +33,7 @@ class ProjectSettings : public wxDialog {
void GetSettings(cxProjectInfo& project) const;
private:
- // Event handlers
void OnInheritCheck(wxCommandEvent& event);
- void OnButtonAddEnv(wxCommandEvent& event);
- void OnButtonDelEnv(wxCommandEvent& event);
- void OnGridChange(wxGridEvent& event);
DECLARE_EVENT_TABLE()
// Member varibles
@@ -47,13 +41,13 @@ class ProjectSettings : public wxDialog {
const cxProjectInfo& m_parentProject;
bool m_envModified;
- // ctrls
+ // Controls
wxCheckBox* m_inheritCheck;
wxTextCtrl* m_includeDirs;
wxTextCtrl* m_includeFiles;
wxTextCtrl* m_excludeDirs;
wxTextCtrl* m_excludeFiles;
- wxGrid* m_envList;
+ EnvVarsPanel* m_envPage;
};
#endif // __PROJECTSETTINGS_H__
View
8 src/e.vcproj
@@ -2518,6 +2518,14 @@
>
</File>
<File
+ RelativePath=".\EnvVarsPanel.cpp"
+ >
+ </File>
+ <File
+ RelativePath=".\EnvVarsPanel.h"
+ >
+ </File>
+ <File
RelativePath=".\eSettings.cpp"
>
</File>
Please sign in to comment.
Something went wrong with that request. Please try again.