Added classes to manage simple tabular data of known structure using a
popup containing a wxGrid object.
BasePicker : Abstract class adding a popup to wxPickerBase styled with
a wxTextCtrl.
BaseGridPicker : Abstract class adding a wxGrid in the popup.
JsonGridPickerCtrl : UI control storing the tabular data in a JSON
array.
LBoundJsonGridPicker : connect JsonGridPicker to database.
LGridJsonCellEditor : use LBoundJsonGridPicker in other wxGrid objects.
LGridJsonCellRenderer : render cell JSON data.
XmlGridPickerCtrl : UI control storing the tabular data in as XML
document.
LBoundXmlGridPicker : connect XmlGridPicker to database.
LGridXmlCellEditor : grid editor for LBoundXmlGridPicker.
LGridXmlCellRenderer : grid renderer for LBoundXmlGridPicker.
JsonHelper and XmlHelper : for applications to quickly get intent value
from database data..
The structure of managed tabular data :
Column 1 : Intent - this is what we want to store/edit. This can be
telephone numbers, email addresses, instant messaging addresses...
any single line piece of information that can exist many times for one
entity (person, company...).
Column 2 : Type - A short description of the intent : 'Home, Work,
Mobile, Fax, Other...'. It is displayed in a non editable wxComboBox.
Column 3 : Preferred - One line of data can be selected as the preferred
one. It is not mandatory, but it must be a single choice.
Column 4 : Notes - single line notes.
Adjust sql scripts and L7.dox.
Applied ANSI formatting style to all files.
Other changes :
Work around a nasty misbehavior.
Grid columns edited by a translated combobox expect full string
data as cell values. LResultSet::BEData() will report these mapped strings,
instead of database real data. LBoundComboBox::IsDirty() will always be
true even if the editor is unchanged once created.
Simplest workaround : disconnect m_BoundComboBox if unchanged.
LGridTextEditor::ProvideFormEditor() : set the form editor's value
explicitely.; wxTextCtrl does not interpret data it receives
LBoundControl::SetNull must be void.
LBoundGrid : Unbind:: instructions should limit to the widget's id, like Bind::
LConnection::GetReturnedKeys should return NULL.
LConnection::SetData should return void.
Notes : wxJSON must be configured with the same prefix as wxWidgets,
here /usr/local/{wxWidgets,wxWidgets-Release}.
This commit is contained in:
@@ -13,12 +13,15 @@
|
||||
LGridCheckEditor::LGridCheckEditor(const wxString& newColName, bool isDualstate, const wxString& newNullLabel)
|
||||
{
|
||||
m_triState = !isDualstate;
|
||||
m_style = wxCHK_3STATE|wxCHK_ALLOW_3RD_STATE_FOR_USER;
|
||||
m_style = wxCHK_3STATE | wxCHK_ALLOW_3RD_STATE_FOR_USER;
|
||||
if (!m_triState) m_style = wxCHK_2STATE;
|
||||
m_colName = newColName;
|
||||
if (newNullLabel.IsEmpty()) {
|
||||
if (newNullLabel.IsEmpty())
|
||||
{
|
||||
m_nullLabel = _T("?");
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
m_nullLabel = newNullLabel;
|
||||
}
|
||||
m_type = LGridColEditor::CHECK;
|
||||
@@ -32,7 +35,8 @@ LGridCheckEditor::~LGridCheckEditor()
|
||||
wxDELETE(m_control);
|
||||
}
|
||||
|
||||
void LGridCheckEditor::Create (wxWindow *parent, wxWindowID id, wxEvtHandler *evtHandler) {
|
||||
void LGridCheckEditor::Create(wxWindow *parent, wxWindowID id, wxEvtHandler *evtHandler)
|
||||
{
|
||||
m_control = new LBoundCheckBox(parent, id, m_style);
|
||||
m_BoundCheckBox = static_cast<LBoundCheckBox*> (m_control);
|
||||
m_BoundCheckBox->SetColumnName(m_colName);
|
||||
@@ -41,59 +45,86 @@ void LGridCheckEditor::Create (wxWindow *parent, wxWindowID id, wxEvtHandler *ev
|
||||
m_control->Show(false);
|
||||
}
|
||||
|
||||
void LGridCheckEditor::BeginEdit (int row, int col, wxGrid *grid) {
|
||||
if (m_control == NULL) {
|
||||
void LGridCheckEditor::BeginEdit(int row, int col, wxGrid *grid)
|
||||
{
|
||||
if (m_control == NULL)
|
||||
{
|
||||
Create(grid->GetGridWindow(), wxID_ANY, NULL);
|
||||
}
|
||||
m_BoundCheckBox->SetResultSet(((LBoundGrid *) grid)->GetResultSet());
|
||||
const wxAny val = grid->GetTable()->GetValue(row, col);
|
||||
if (m_triState && val.As<wxString>() == m_nullLabel) {
|
||||
if (m_triState && val.As<wxString>() == m_nullLabel)
|
||||
{
|
||||
m_BoundCheckBox->SetNull();
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
m_BoundCheckBox->SetData(val);
|
||||
}
|
||||
m_control->Show(true);
|
||||
}
|
||||
wxGridCellEditor* LGridCheckEditor::Clone () const {
|
||||
|
||||
wxGridCellEditor* LGridCheckEditor::Clone() const
|
||||
{
|
||||
return new LGridCheckEditor(m_colName, !m_triState, m_nullLabel);
|
||||
}
|
||||
bool LGridCheckEditor::EndEdit (int row, int col, const wxGrid *grid, const wxString &oldval, wxString *newval) {
|
||||
|
||||
bool LGridCheckEditor::EndEdit(int row, int col, const wxGrid *grid, const wxString &oldval, wxString *newval)
|
||||
{
|
||||
// What do we do here ?
|
||||
return true;
|
||||
}
|
||||
void LGridCheckEditor::ApplyEdit (int row, int col, wxGrid *grid) {
|
||||
|
||||
void LGridCheckEditor::ApplyEdit(int row, int col, wxGrid *grid)
|
||||
{
|
||||
const wxAny val = m_BoundCheckBox->GetData();
|
||||
if (m_triState && val.As<wxString>() == L_SQLNULL) {
|
||||
if (m_triState && val.As<wxString>() == L_SQLNULL)
|
||||
{
|
||||
grid->GetTable()->SetValue(row, col, m_nullLabel);
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
grid->GetTable()->SetValue(row, col, val.As<wxString>());
|
||||
}
|
||||
}
|
||||
void LGridCheckEditor::Reset () {
|
||||
|
||||
void LGridCheckEditor::Reset()
|
||||
{
|
||||
wxDELETE(m_control);
|
||||
m_BoundControl = NULL;
|
||||
m_BoundCheckBox = NULL;
|
||||
}
|
||||
|
||||
wxString LGridCheckEditor::GetValue() const {
|
||||
wxString LGridCheckEditor::GetValue() const
|
||||
{
|
||||
return m_control == NULL ? wxString(wxEmptyString) : m_BoundControl->GetData().As<wxString>();
|
||||
}
|
||||
wxControl* LGridCheckEditor::ProvideFormEditor(wxWindow * parent) {
|
||||
|
||||
wxControl* LGridCheckEditor::ProvideFormEditor(wxWindow * parent)
|
||||
{
|
||||
if (!m_formEditor) m_formEditor = new wxCheckBox(parent, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, m_style);
|
||||
if (m_triState) {
|
||||
if (m_triState)
|
||||
{
|
||||
m_formEditor->Set3StateValue(m_BoundCheckBox->Get3StateValue());
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
m_formEditor->SetValue(m_BoundCheckBox->GetValue());
|
||||
}
|
||||
m_formEditor->SetName(m_BoundCheckBox->GetName());
|
||||
if (m_BoundCheckBox->GetValidator()) m_formEditor->SetValidator(*(m_BoundCheckBox->GetValidator()));
|
||||
return m_formEditor;
|
||||
}
|
||||
void LGridCheckEditor::SyncBack(const int row, const int col, wxGrid * grid) {
|
||||
|
||||
void LGridCheckEditor::SyncBack(const int row, const int col, wxGrid * grid)
|
||||
{
|
||||
if (!m_formEditor) return;
|
||||
if (m_triState) {
|
||||
if (m_triState)
|
||||
{
|
||||
m_BoundCheckBox->Set3StateValue(m_formEditor->Get3StateValue());
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
m_BoundCheckBox->SetValue(m_formEditor->GetValue());
|
||||
}
|
||||
ApplyEdit(row, col, grid);
|
||||
|
||||
Reference in New Issue
Block a user