From cbeea63f67490b46dfe5b2f59c3f54b5304835b6 Mon Sep 17 00:00:00 2001 From: Steve Brokenshire Date: Sat, 2 Sep 2017 11:09:09 +0100 Subject: [PATCH] frmContactEditorGeoposition: Implemented priority control --- source/AppXestiaAddrBk.cpp | 65 +++---------------- source/AppXestiaAddrBk.h | 6 +- .../frmContactEditorGeoposition.cpp | 36 ++++------ .../frmContactEditorGeoposition.h | 4 +- 4 files changed, 24 insertions(+), 87 deletions(-) diff --git a/source/AppXestiaAddrBk.cpp b/source/AppXestiaAddrBk.cpp index 7be4e48..50dffff 100644 --- a/source/AppXestiaAddrBk.cpp +++ b/source/AppXestiaAddrBk.cpp @@ -4961,71 +4961,26 @@ frmContactEditorGeopositionADT::frmContactEditorGeopositionADT( wxWindow* parent nbkWebsite = new wxNotebook( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, 0 ); tabGeneral = new wxPanel( nbkWebsite, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL ); - wxFlexGridSizer* fgSizer6; - fgSizer6 = new wxFlexGridSizer( 0, 2, 0, 0 ); - fgSizer6->AddGrowableCol( 1 ); - fgSizer6->SetFlexibleDirection( wxVERTICAL ); - fgSizer6->SetNonFlexibleGrowMode( wxFLEX_GROWMODE_SPECIFIED ); + szrGeneral = new wxFlexGridSizer( 2, 2, 0, 0 ); + szrGeneral->AddGrowableCol( 1 ); + szrGeneral->SetFlexibleDirection( wxBOTH ); + szrGeneral->SetNonFlexibleGrowMode( wxFLEX_GROWMODE_SPECIFIED ); lblGeoposition = new wxStaticText( tabGeneral, wxID_ANY, wxT("Geoposition:"), wxDefaultPosition, wxDefaultSize, 0 ); lblGeoposition->Wrap( -1 ); - fgSizer6->Add( lblGeoposition, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5 ); + szrGeneral->Add( lblGeoposition, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5 ); txtGeoposition = new wxTextCtrl( tabGeneral, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 ); - fgSizer6->Add( txtGeoposition, 0, wxALL|wxEXPAND, 5 ); + szrGeneral->Add( txtGeoposition, 0, wxALL|wxEXPAND, 5 ); lblPriority = new wxStaticText( tabGeneral, wxID_ANY, wxT("Priority:"), wxDefaultPosition, wxDefaultSize, 0 ); lblPriority->Wrap( -1 ); - fgSizer6->Add( lblPriority, 0, wxALL, 5 ); - - wxBoxSizer* bSizer260; - bSizer260 = new wxBoxSizer( wxHORIZONTAL ); - - chkUsePref = new wxCheckBox( tabGeneral, wxID_ANY, wxT("Use"), wxDefaultPosition, wxDefaultSize, 0 ); - bSizer260->Add( chkUsePref, 0, wxALL, 5 ); - - wxBoxSizer* bSizer254; - bSizer254 = new wxBoxSizer( wxVERTICAL ); - - wxBoxSizer* bSizer256; - bSizer256 = new wxBoxSizer( wxHORIZONTAL ); - - sliPriority = new wxSlider( tabGeneral, wxID_ANY, 0, 1, 100, wxDefaultPosition, wxDefaultSize, wxSL_HORIZONTAL|wxSL_LABELS ); - bSizer256->Add( sliPriority, 1, wxALL|wxEXPAND, 5 ); - - - bSizer254->Add( bSizer256, 1, wxEXPAND, 5 ); - - wxBoxSizer* bSizer255; - bSizer255 = new wxBoxSizer( wxHORIZONTAL ); - - lblHigh = new wxStaticText( tabGeneral, wxID_ANY, wxT("High"), wxDefaultPosition, wxDefaultSize, 0 ); - lblHigh->Wrap( -1 ); - bSizer255->Add( lblHigh, 0, wxALIGN_LEFT|wxALL, 5 ); - - - bSizer255->Add( 0, 0, 1, wxEXPAND, 5 ); - - lblLow = new wxStaticText( tabGeneral, wxID_ANY, wxT("Low"), wxDefaultPosition, wxDefaultSize, 0 ); - lblLow->Wrap( -1 ); - bSizer255->Add( lblLow, 0, wxALIGN_RIGHT|wxALL, 5 ); - - - bSizer254->Add( bSizer255, 1, wxEXPAND, 0 ); - - - bSizer260->Add( bSizer254, 1, wxEXPAND, 5 ); - - - fgSizer6->Add( bSizer260, 1, wxEXPAND, 5 ); - - - fgSizer6->Add( 0, 0, 1, wxEXPAND, 5 ); + szrGeneral->Add( lblPriority, 0, wxALL, 5 ); - tabGeneral->SetSizer( fgSizer6 ); + tabGeneral->SetSizer( szrGeneral ); tabGeneral->Layout(); - fgSizer6->Fit( tabGeneral ); + szrGeneral->Fit( tabGeneral ); nbkWebsite->AddPage( tabGeneral, wxT("General"), false ); bSizer251->Add( nbkWebsite, 1, wxEXPAND | wxALL, 5 ); @@ -5049,7 +5004,6 @@ frmContactEditorGeopositionADT::frmContactEditorGeopositionADT( wxWindow* parent this->Centre( wxBOTH ); // Connect Events - chkUsePref->Connect( wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler( frmContactEditorGeopositionADT::EnablePriority ), NULL, this ); btnAction->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( frmContactEditorGeopositionADT::ProcessAction ), NULL, this ); btnClose->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( frmContactEditorGeopositionADT::CloseWindow ), NULL, this ); } @@ -5057,7 +5011,6 @@ frmContactEditorGeopositionADT::frmContactEditorGeopositionADT( wxWindow* parent frmContactEditorGeopositionADT::~frmContactEditorGeopositionADT() { // Disconnect Events - chkUsePref->Disconnect( wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler( frmContactEditorGeopositionADT::EnablePriority ), NULL, this ); btnAction->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( frmContactEditorGeopositionADT::ProcessAction ), NULL, this ); btnClose->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( frmContactEditorGeopositionADT::CloseWindow ), NULL, this ); diff --git a/source/AppXestiaAddrBk.h b/source/AppXestiaAddrBk.h index 2029ade..be9219e 100644 --- a/source/AppXestiaAddrBk.h +++ b/source/AppXestiaAddrBk.h @@ -1331,18 +1331,14 @@ class frmContactEditorGeopositionADT : public wxDialog protected: wxNotebook* nbkWebsite; wxPanel* tabGeneral; + wxFlexGridSizer* szrGeneral; wxStaticText* lblGeoposition; wxTextCtrl* txtGeoposition; wxStaticText* lblPriority; - wxCheckBox* chkUsePref; - wxSlider* sliPriority; - wxStaticText* lblHigh; - wxStaticText* lblLow; wxButton* btnAction; wxButton* btnClose; // Virtual event handlers, overide them in your derived class - virtual void EnablePriority( wxCommandEvent& event ) { event.Skip(); } virtual void ProcessAction( wxCommandEvent& event ) { event.Skip(); } virtual void CloseWindow( wxCommandEvent& event ) { event.Skip(); } diff --git a/source/contacteditor/frmContactEditorGeoposition.cpp b/source/contacteditor/frmContactEditorGeoposition.cpp index 4f91605..e8c89eb 100644 --- a/source/contacteditor/frmContactEditorGeoposition.cpp +++ b/source/contacteditor/frmContactEditorGeoposition.cpp @@ -28,19 +28,8 @@ frmContactEditorGeopositionADT( parent ) // Setup the window. EditorMode = FALSE; - sliPriority->Disable(); -} - -void frmContactEditorGeoposition::EnablePriority( wxCommandEvent& event ) -{ - - // Enable/Disable the priority setting. - - if (chkUsePref->IsChecked()){ - sliPriority->Enable(); - } else { - sliPriority->Disable(); - } + priorityCtrl = new XABPriorityCtrl(tabGeneral); + szrGeneral->Add(priorityCtrl, 1, wxEXPAND, 5); } @@ -86,9 +75,8 @@ void frmContactEditorGeoposition::SetEditorMode(bool EditMode, SectionType SectT if (intiter->first == GeopositionListIndex && intiter->second > 0 && intiter != GeopositionListPrefPtr->end()){ - sliPriority->SetValue(intiter->second); - sliPriority->Enable(); - chkUsePref->SetValue(TRUE); + priorityCtrl->SetValue(intiter->second); + priorityCtrl->EnablePriority(true); } @@ -135,9 +123,9 @@ void frmContactEditorGeoposition::ProcessAction( wxCommandEvent& event ) // Add Language priority. - if (chkUsePref->IsChecked()){ + if (priorityCtrl->IsPriorityChecked()){ - GeopositionListPrefPtr->insert(std::make_pair(GeopositionListIndex, sliPriority->GetValue())); + GeopositionListPrefPtr->insert(std::make_pair(GeopositionListIndex, priorityCtrl->GetValue())); } else { @@ -154,9 +142,9 @@ void frmContactEditorGeoposition::ProcessAction( wxCommandEvent& event ) coldata.SetText(txtGeoposition->GetValue()); ListCtrlIndex = GeopositionListCtrlPtr->InsertItem(coldata); - if (chkUsePref->IsChecked()){ + if (priorityCtrl->IsPriorityChecked()){ - GeopositionListCtrlPtr->SetItem(ListCtrlIndex, 1, wxString::Format(wxT("%i"), sliPriority->GetValue())); + GeopositionListCtrlPtr->SetItem(ListCtrlIndex, 1, wxString::Format(wxT("%i"), priorityCtrl->GetValue())); } @@ -175,9 +163,9 @@ void frmContactEditorGeoposition::ProcessAction( wxCommandEvent& event ) GeopositionListPrefPtr->erase(GeopositionListIndex); - if (chkUsePref->IsChecked()){ + if (priorityCtrl->IsPriorityChecked()){ - GeopositionListPrefPtr->insert(std::make_pair(GeopositionListIndex, sliPriority->GetValue())); + GeopositionListPrefPtr->insert(std::make_pair(GeopositionListIndex, priorityCtrl->GetValue())); } else { @@ -195,9 +183,9 @@ void frmContactEditorGeoposition::ProcessAction( wxCommandEvent& event ) GeopositionListCtrlPtr->SetItem(longSelected, 0, txtGeoposition->GetValue()); - if (chkUsePref->IsChecked()){ + if (priorityCtrl->IsPriorityChecked()){ - GeopositionListCtrlPtr->SetItem(longSelected, 1, wxString::Format(wxT("%i"), sliPriority->GetValue())); + GeopositionListCtrlPtr->SetItem(longSelected, 1, wxString::Format(wxT("%i"), priorityCtrl->GetValue())); } else { diff --git a/source/contacteditor/frmContactEditorGeoposition.h b/source/contacteditor/frmContactEditorGeoposition.h index 063ebd1..0b43ab3 100644 --- a/source/contacteditor/frmContactEditorGeoposition.h +++ b/source/contacteditor/frmContactEditorGeoposition.h @@ -29,6 +29,7 @@ Subclass of frmContactEditorGeopositionADT, which is generated by wxFormBuilder. #include "../AppXestiaAddrBk.h" #include "../enums.h" +#include "../widgets/XABPriorityCtrl.h" //// end generated include @@ -37,7 +38,6 @@ class frmContactEditorGeoposition : public frmContactEditorGeopositionADT { protected: // Handlers for frmContactEditorGeopositionADT events. - void EnablePriority( wxCommandEvent& event ); void ProcessAction( wxCommandEvent& event ); void CloseWindow( wxCommandEvent& event ); public: @@ -68,7 +68,7 @@ class frmContactEditorGeoposition : public frmContactEditorGeopositionADT wxListCtrl *GeopositionListCtrlPtr; int GeopositionListIndex; SectionType EditSectionType; - + XABPriorityCtrl *priorityCtrl = nullptr; }; #endif // __frmContactEditorGeoposition__ -- 2.39.2