From 8ab075f0137a7795ef5803e7ad54ecdc18c2fd2c Mon Sep 17 00:00:00 2001 From: Steve Brokenshire Date: Mon, 28 Aug 2017 19:57:53 +0100 Subject: [PATCH] frmContactEditorOrganisations: Implemented priority control --- source/AppXestiaAddrBk.cpp | 69 +++---------------- source/AppXestiaAddrBk.h | 6 +- .../frmContactEditorOrganisations.cpp | 37 ++++------ .../frmContactEditorOrganisations.h | 5 +- 4 files changed, 27 insertions(+), 90 deletions(-) diff --git a/source/AppXestiaAddrBk.cpp b/source/AppXestiaAddrBk.cpp index b15bd9a..7a61397 100644 --- a/source/AppXestiaAddrBk.cpp +++ b/source/AppXestiaAddrBk.cpp @@ -4460,78 +4460,33 @@ frmContactEditorOrganisationsADT::frmContactEditorOrganisationsADT( wxWindow* pa nbkOrganisation = new wxNotebook( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, 0 ); tabGeneral = new wxPanel( nbkOrganisation, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL ); - wxFlexGridSizer* fgSizer6; - fgSizer6 = new wxFlexGridSizer( 0, 2, 0, 0 ); - fgSizer6->AddGrowableCol( 1 ); - fgSizer6->SetFlexibleDirection( wxBOTH ); - fgSizer6->SetNonFlexibleGrowMode( wxFLEX_GROWMODE_SPECIFIED ); + szrGeneral = new wxFlexGridSizer( 3, 2, 0, 0 ); + szrGeneral->AddGrowableCol( 1 ); + szrGeneral->SetFlexibleDirection( wxBOTH ); + szrGeneral->SetNonFlexibleGrowMode( wxFLEX_GROWMODE_SPECIFIED ); lblOrganisation = new wxStaticText( tabGeneral, wxID_ANY, wxT("Organisation:"), wxDefaultPosition, wxDefaultSize, 0 ); lblOrganisation->Wrap( -1 ); - fgSizer6->Add( lblOrganisation, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5 ); + szrGeneral->Add( lblOrganisation, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5 ); txtOrganisation = new wxTextCtrl( tabGeneral, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 ); - fgSizer6->Add( txtOrganisation, 0, wxALL|wxEXPAND, 5 ); + szrGeneral->Add( txtOrganisation, 0, wxALL|wxEXPAND, 5 ); lblSortAs = new wxStaticText( tabGeneral, wxID_ANY, wxT("Sort As:"), wxDefaultPosition, wxDefaultSize, 0 ); lblSortAs->Wrap( -1 ); - fgSizer6->Add( lblSortAs, 0, wxALL, 5 ); + szrGeneral->Add( lblSortAs, 0, wxALL, 5 ); cmbSortAs = new wxComboBox( tabGeneral, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0, NULL, 0 ); - fgSizer6->Add( cmbSortAs, 1, wxALL, 5 ); + szrGeneral->Add( cmbSortAs, 1, wxALL, 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 ); nbkOrganisation->AddPage( tabGeneral, wxT("General"), false ); bSizer251->Add( nbkOrganisation, 1, wxEXPAND | wxALL, 5 ); @@ -4556,7 +4511,6 @@ frmContactEditorOrganisationsADT::frmContactEditorOrganisationsADT( wxWindow* pa // Connect Events txtOrganisation->Connect( wxEVT_COMMAND_TEXT_UPDATED, wxCommandEventHandler( frmContactEditorOrganisationsADT::UpdateSortAs ), NULL, this ); - chkUsePref->Connect( wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler( frmContactEditorOrganisationsADT::EnablePriority ), NULL, this ); btnAction->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( frmContactEditorOrganisationsADT::ProcessAction ), NULL, this ); btnClose->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( frmContactEditorOrganisationsADT::CloseWindow ), NULL, this ); } @@ -4565,7 +4519,6 @@ frmContactEditorOrganisationsADT::~frmContactEditorOrganisationsADT() { // Disconnect Events txtOrganisation->Disconnect( wxEVT_COMMAND_TEXT_UPDATED, wxCommandEventHandler( frmContactEditorOrganisationsADT::UpdateSortAs ), NULL, this ); - chkUsePref->Disconnect( wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler( frmContactEditorOrganisationsADT::EnablePriority ), NULL, this ); btnAction->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( frmContactEditorOrganisationsADT::ProcessAction ), NULL, this ); btnClose->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( frmContactEditorOrganisationsADT::CloseWindow ), NULL, this ); diff --git a/source/AppXestiaAddrBk.h b/source/AppXestiaAddrBk.h index 6084305..a901d85 100644 --- a/source/AppXestiaAddrBk.h +++ b/source/AppXestiaAddrBk.h @@ -1117,21 +1117,17 @@ class frmContactEditorOrganisationsADT : public wxDialog protected: wxNotebook* nbkOrganisation; wxPanel* tabGeneral; + wxFlexGridSizer* szrGeneral; wxStaticText* lblOrganisation; wxTextCtrl* txtOrganisation; wxStaticText* lblSortAs; wxComboBox* cmbSortAs; 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 UpdateSortAs( wxCommandEvent& event ) { event.Skip(); } - 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/frmContactEditorOrganisations.cpp b/source/contacteditor/frmContactEditorOrganisations.cpp index fa0ca45..e8aeb69 100644 --- a/source/contacteditor/frmContactEditorOrganisations.cpp +++ b/source/contacteditor/frmContactEditorOrganisations.cpp @@ -28,7 +28,8 @@ frmContactEditorOrganisationsADT( parent ) // Setup the window. EditorMode = FALSE; - sliPriority->Disable(); + priorityCtrl = new XABPriorityCtrl(tabGeneral); + szrGeneral->Add(priorityCtrl, 1, wxEXPAND, 5); } @@ -73,19 +74,6 @@ void frmContactEditorOrganisations::UpdateSortAs( wxCommandEvent& event ) } -void frmContactEditorOrganisations::EnablePriority( wxCommandEvent& event ) -{ - - // Enable/disable the priority setting. - - if (chkUsePref->IsChecked()){ - sliPriority->Enable(); - } else { - sliPriority->Disable(); - } - -} - void frmContactEditorOrganisations::ProcessAction( wxCommandEvent& event ) { @@ -124,9 +112,9 @@ void frmContactEditorOrganisations::ProcessAction( wxCommandEvent& event ) // Setup Organisation Priority. - if (chkUsePref->IsChecked()){ + if (priorityCtrl->IsPriorityChecked()){ - OrganisationListPrefPtr->insert(std::make_pair(OrganisationListIndex, sliPriority->GetValue())); + OrganisationListPrefPtr->insert(std::make_pair(OrganisationListIndex, priorityCtrl->GetValue())); } else { @@ -143,9 +131,9 @@ void frmContactEditorOrganisations::ProcessAction( wxCommandEvent& event ) coldata.SetText(txtOrganisation->GetValue()); ListCtrlIndex = OrganisationListCtrlPtr->InsertItem(coldata); - if (chkUsePref->IsChecked()){ + if (priorityCtrl->IsPriorityChecked()){ - OrganisationListCtrlPtr->SetItem(ListCtrlIndex, 1, wxString::Format(wxT("%i"), sliPriority->GetValue())); + OrganisationListCtrlPtr->SetItem(ListCtrlIndex, 1, wxString::Format(wxT("%i"), priorityCtrl->GetValue())); } @@ -171,9 +159,9 @@ void frmContactEditorOrganisations::ProcessAction( wxCommandEvent& event ) OrganisationListPrefPtr->erase(OrganisationListIndex); - if (chkUsePref->IsChecked()){ + if (priorityCtrl->IsPriorityChecked()){ - OrganisationListPrefPtr->insert(std::make_pair(OrganisationListIndex, sliPriority->GetValue())); + OrganisationListPrefPtr->insert(std::make_pair(OrganisationListIndex, priorityCtrl->GetValue())); } else { @@ -193,9 +181,9 @@ void frmContactEditorOrganisations::ProcessAction( wxCommandEvent& event ) OrganisationListCtrlPtr->SetItem(longSelected, 0, txtOrganisation->GetValue()); - if (chkUsePref->IsChecked()){ + if (priorityCtrl->IsPriorityChecked()){ - OrganisationListCtrlPtr->SetItem(longSelected, 1, wxString::Format(wxT("%i"), sliPriority->GetValue())); + OrganisationListCtrlPtr->SetItem(longSelected, 1, wxString::Format(wxT("%i"), priorityCtrl->GetValue())); } else { @@ -270,9 +258,8 @@ void frmContactEditorOrganisations::SetEditorMode(bool EditMode, SectionType Sec if (intiter->first == OrganisationListIndex && intiter->second > 0 && intiter != OrganisationListPrefPtr->end()){ - sliPriority->SetValue(intiter->second); - sliPriority->Enable(); - chkUsePref->SetValue(TRUE); + priorityCtrl->SetValue(intiter->second); + priorityCtrl->EnablePriority(true); } diff --git a/source/contacteditor/frmContactEditorOrganisations.h b/source/contacteditor/frmContactEditorOrganisations.h index 47926b9..9fb4f05 100644 --- a/source/contacteditor/frmContactEditorOrganisations.h +++ b/source/contacteditor/frmContactEditorOrganisations.h @@ -27,6 +27,7 @@ Subclass of frmContactEditorOrganisationsADT, which is generated by wxFormBuilde #include #include "../AppXestiaAddrBk.h" #include "../enums.h" +#include "../widgets/XABPriorityCtrl.h" //// end generated include @@ -36,7 +37,6 @@ class frmContactEditorOrganisations : public frmContactEditorOrganisationsADT protected: // Handlers for frmContactEditorOrganisationsADT events. void UpdateSortAs( wxCommandEvent& event ); - void EnablePriority( wxCommandEvent& event ); void ProcessAction( wxCommandEvent& event ); void CloseWindow( wxCommandEvent& event ); public: @@ -69,7 +69,8 @@ class frmContactEditorOrganisations : public frmContactEditorOrganisationsADT wxListCtrl *OrganisationListCtrlPtr; int OrganisationListIndex; SectionType EditSectionType; - + XABPriorityCtrl *priorityCtrl = nullptr; + }; #endif // __frmContactEditorOrganisations__ -- 2.39.2