From 8089428e86139e335db5f5104382ffc37dce1c42 Mon Sep 17 00:00:00 2001 From: Steve Brokenshire Date: Sat, 2 Sep 2017 11:41:44 +0100 Subject: [PATCH] frmContactEditorCalAdr: Implemented priority control --- source/AppXestiaAddrBk.cpp | 69 +++---------------- source/AppXestiaAddrBk.h | 6 +- .../contacteditor/frmContactEditorCalAdr.cpp | 37 ++++------ source/contacteditor/frmContactEditorCalAdr.h | 4 +- 4 files changed, 26 insertions(+), 90 deletions(-) diff --git a/source/AppXestiaAddrBk.cpp b/source/AppXestiaAddrBk.cpp index 50dffff..f61a34e 100644 --- a/source/AppXestiaAddrBk.cpp +++ b/source/AppXestiaAddrBk.cpp @@ -5025,80 +5025,35 @@ frmContactEditorCalAdrADT::frmContactEditorCalAdrADT( wxWindow* parent, wxWindow 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( 3, 2, 0, 0 ); + szrGeneral->AddGrowableCol( 1 ); + szrGeneral->SetFlexibleDirection( wxBOTH ); + szrGeneral->SetNonFlexibleGrowMode( wxFLEX_GROWMODE_SPECIFIED ); lblAddress = new wxStaticText( tabGeneral, wxID_ANY, wxT("Address:"), wxDefaultPosition, wxDefaultSize, 0 ); lblAddress->Wrap( -1 ); - fgSizer6->Add( lblAddress, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5 ); + szrGeneral->Add( lblAddress, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5 ); txtAddress = new wxTextCtrl( tabGeneral, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 ); - fgSizer6->Add( txtAddress, 0, wxALL|wxEXPAND, 5 ); + szrGeneral->Add( txtAddress, 0, wxALL|wxEXPAND, 5 ); lblType = new wxStaticText( tabGeneral, wxID_ANY, wxT("Type:"), wxDefaultPosition, wxDefaultSize, 0 ); lblType->Wrap( -1 ); - fgSizer6->Add( lblType, 0, wxALL, 5 ); + szrGeneral->Add( lblType, 0, wxALL, 5 ); wxArrayString cmbTypeChoices; cmbType = new wxChoice( tabGeneral, wxID_ANY, wxDefaultPosition, wxDefaultSize, cmbTypeChoices, 0 ); cmbType->SetSelection( 0 ); - fgSizer6->Add( cmbType, 0, wxALL, 5 ); + szrGeneral->Add( cmbType, 0, 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 ); nbkWebsite->AddPage( tabGeneral, wxT("General"), false ); bSizer251->Add( nbkWebsite, 1, wxEXPAND | wxALL, 5 ); @@ -5122,7 +5077,6 @@ frmContactEditorCalAdrADT::frmContactEditorCalAdrADT( wxWindow* parent, wxWindow this->Centre( wxBOTH ); // Connect Events - chkUsePref->Connect( wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler( frmContactEditorCalAdrADT::EnablePriority ), NULL, this ); btnAction->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( frmContactEditorCalAdrADT::ProcessAction ), NULL, this ); btnClose->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( frmContactEditorCalAdrADT::CloseWindow ), NULL, this ); } @@ -5130,7 +5084,6 @@ frmContactEditorCalAdrADT::frmContactEditorCalAdrADT( wxWindow* parent, wxWindow frmContactEditorCalAdrADT::~frmContactEditorCalAdrADT() { // Disconnect Events - chkUsePref->Disconnect( wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler( frmContactEditorCalAdrADT::EnablePriority ), NULL, this ); btnAction->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( frmContactEditorCalAdrADT::ProcessAction ), NULL, this ); btnClose->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( frmContactEditorCalAdrADT::CloseWindow ), NULL, this ); diff --git a/source/AppXestiaAddrBk.h b/source/AppXestiaAddrBk.h index be9219e..939c34b 100644 --- a/source/AppXestiaAddrBk.h +++ b/source/AppXestiaAddrBk.h @@ -1360,20 +1360,16 @@ class frmContactEditorCalAdrADT : public wxDialog protected: wxNotebook* nbkWebsite; wxPanel* tabGeneral; + wxFlexGridSizer* szrGeneral; wxStaticText* lblAddress; wxTextCtrl* txtAddress; wxStaticText* lblType; wxChoice* cmbType; 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/frmContactEditorCalAdr.cpp b/source/contacteditor/frmContactEditorCalAdr.cpp index ac26f5a..176bb00 100644 --- a/source/contacteditor/frmContactEditorCalAdr.cpp +++ b/source/contacteditor/frmContactEditorCalAdr.cpp @@ -28,7 +28,8 @@ frmContactEditorCalAdrADT( parent ) // Setup the window. EditorMode = FALSE; - sliPriority->Disable(); + priorityCtrl = new XABPriorityCtrl(tabGeneral); + szrGeneral->Add(priorityCtrl, 1, wxEXPAND, 5); cmbType->Append(wxT("")); cmbType->Append(_("Home")); @@ -36,19 +37,6 @@ frmContactEditorCalAdrADT( parent ) } -void frmContactEditorCalAdr::EnablePriority( wxCommandEvent& event ) -{ - - // Enable/disable the priority setting. - - if (chkUsePref->IsChecked()){ - sliPriority->Enable(); - } else { - sliPriority->Disable(); - } - -} - void frmContactEditorCalAdr::ProcessAction( wxCommandEvent& event ) { @@ -86,9 +74,9 @@ void frmContactEditorCalAdr::ProcessAction( wxCommandEvent& event ) // Setup Calendar Priority. - if (chkUsePref->IsChecked()){ + if (priorityCtrl->IsPriorityChecked()){ - CalAdrListPrefPtr->insert(std::make_pair(CalAdrListIndex, sliPriority->GetValue())); + CalAdrListPrefPtr->insert(std::make_pair(CalAdrListIndex, priorityCtrl->GetValue())); } else { @@ -107,9 +95,9 @@ void frmContactEditorCalAdr::ProcessAction( wxCommandEvent& event ) CalAdrListCtrlPtr->SetItem(ListCtrlIndex, 1, strValue); - if (chkUsePref->IsChecked()){ + if (priorityCtrl->IsPriorityChecked()){ - CalAdrListCtrlPtr->SetItem(ListCtrlIndex, 2, wxString::Format(wxT("%i"), sliPriority->GetValue())); + CalAdrListCtrlPtr->SetItem(ListCtrlIndex, 2, wxString::Format(wxT("%i"), priorityCtrl->GetValue())); } @@ -146,9 +134,9 @@ void frmContactEditorCalAdr::ProcessAction( wxCommandEvent& event ) CalAdrListPrefPtr->erase(CalAdrListIndex); - if (chkUsePref->IsChecked()){ + if (priorityCtrl->IsPriorityChecked()){ - CalAdrListPrefPtr->insert(std::make_pair(CalAdrListIndex, sliPriority->GetValue())); + CalAdrListPrefPtr->insert(std::make_pair(CalAdrListIndex, priorityCtrl->GetValue())); } else { @@ -169,9 +157,9 @@ void frmContactEditorCalAdr::ProcessAction( wxCommandEvent& event ) CalAdrListCtrlPtr->SetItem(longSelected, 0, txtAddress->GetValue()); CalAdrListCtrlPtr->SetItem(longSelected, 1, strValue); - if (chkUsePref->IsChecked()){ + if (priorityCtrl->IsPriorityChecked()){ - CalAdrListCtrlPtr->SetItem(longSelected, 2, wxString::Format(wxT("%i"), sliPriority->GetValue())); + CalAdrListCtrlPtr->SetItem(longSelected, 2, wxString::Format(wxT("%i"), priorityCtrl->GetValue())); } else { @@ -256,9 +244,8 @@ void frmContactEditorCalAdr::SetEditorMode(bool EditMode) if (intiter->first == CalAdrListIndex && intiter->second > 0 && intiter != CalAdrListPrefPtr->end()){ - sliPriority->SetValue(intiter->second); - sliPriority->Enable(); - chkUsePref->SetValue(TRUE); + priorityCtrl->SetValue(intiter->second); + priorityCtrl->EnablePriority(true); } diff --git a/source/contacteditor/frmContactEditorCalAdr.h b/source/contacteditor/frmContactEditorCalAdr.h index d7f615f..1a51bed 100644 --- a/source/contacteditor/frmContactEditorCalAdr.h +++ b/source/contacteditor/frmContactEditorCalAdr.h @@ -27,6 +27,7 @@ Subclass of frmContactEditorCalAdrADT, which is generated by wxFormBuilder. #include #include "../AppXestiaAddrBk.h" #include "../enums.h" +#include "../widgets/XABPriorityCtrl.h" //// end generated include @@ -35,7 +36,6 @@ class frmContactEditorCalAdr : public frmContactEditorCalAdrADT { protected: // Handlers for frmContactEditorCalAdrADT events. - void EnablePriority( wxCommandEvent& event ); void ProcessAction( wxCommandEvent& event ); void CloseWindow( wxCommandEvent& event ); public: @@ -62,7 +62,7 @@ class frmContactEditorCalAdr : public frmContactEditorCalAdrADT wxListCtrl *CalAdrListCtrlPtr; int CalAdrListIndex; SectionType EditSectionType; - + XABPriorityCtrl *priorityCtrl = nullptr; }; #endif // __frmContactEditorCalAdr__ -- 2.39.2