From bfe817b5bfae33a1eb666c463643ec119cd1d66d Mon Sep 17 00:00:00 2001 From: Steve Brokenshire Date: Sat, 2 Sep 2017 20:21:57 +0100 Subject: [PATCH] frmContactEditorKey: Implemented priority control --- source/AppXestiaAddrBk.cpp | 73 ++++---------------- source/AppXestiaAddrBk.h | 6 +- source/contacteditor/frmContactEditorKey.cpp | 37 +++------- source/contacteditor/frmContactEditorKey.h | 4 +- 4 files changed, 26 insertions(+), 94 deletions(-) diff --git a/source/AppXestiaAddrBk.cpp b/source/AppXestiaAddrBk.cpp index c441001..2203e39 100644 --- a/source/AppXestiaAddrBk.cpp +++ b/source/AppXestiaAddrBk.cpp @@ -5241,83 +5241,38 @@ frmContactEditorKeyADT::frmContactEditorKeyADT( wxWindow* parent, wxWindowID id, 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 ); lblKeyType = new wxStaticText( tabGeneral, wxID_ANY, wxT("Key Type:"), wxDefaultPosition, wxDefaultSize, 0 ); lblKeyType->Wrap( -1 ); - fgSizer6->Add( lblKeyType, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5 ); + szrGeneral->Add( lblKeyType, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5 ); wxArrayString cmbKeyMainTypeChoices; cmbKeyMainType = new wxChoice( tabGeneral, wxID_ANY, wxDefaultPosition, wxDefaultSize, cmbKeyMainTypeChoices, 0 ); cmbKeyMainType->SetSelection( 0 ); - fgSizer6->Add( cmbKeyMainType, 0, wxALL, 5 ); + szrGeneral->Add( cmbKeyMainType, 0, wxALL, 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 ); - nbkWebsite->AddPage( tabGeneral, wxT("General"), false ); + szrGeneral->Fit( tabGeneral ); + nbkWebsite->AddPage( tabGeneral, wxT("General"), true ); tabURL = new wxPanel( nbkWebsite, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL ); wxFlexGridSizer* fgSizer61; fgSizer61 = new wxFlexGridSizer( 0, 2, 0, 0 ); @@ -5373,7 +5328,7 @@ frmContactEditorKeyADT::frmContactEditorKeyADT( wxWindow* parent, wxWindowID id, tabKey->SetSizer( fgSizer62 ); tabKey->Layout(); fgSizer62->Fit( tabKey ); - nbkWebsite->AddPage( tabKey, wxT("Key"), true ); + nbkWebsite->AddPage( tabKey, wxT("Key"), false ); bSizer251->Add( nbkWebsite, 1, wxEXPAND | wxALL, 5 ); @@ -5397,7 +5352,6 @@ frmContactEditorKeyADT::frmContactEditorKeyADT( wxWindow* parent, wxWindowID id, // Connect Events cmbKeyMainType->Connect( wxEVT_COMMAND_CHOICE_SELECTED, wxCommandEventHandler( frmContactEditorKeyADT::ProcessKeyType ), NULL, this ); - chkUsePref->Connect( wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler( frmContactEditorKeyADT::EnablePriority ), NULL, this ); cmbURL->Connect( wxEVT_COMMAND_COMBOBOX_SELECTED, wxCommandEventHandler( frmContactEditorKeyADT::ConvertURLType ), NULL, this ); cmbKeyType->Connect( wxEVT_COMMAND_COMBOBOX_SELECTED, wxCommandEventHandler( frmContactEditorKeyADT::ConvertKeyType ), NULL, this ); btnAction->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( frmContactEditorKeyADT::ProcessAction ), NULL, this ); @@ -5408,7 +5362,6 @@ frmContactEditorKeyADT::~frmContactEditorKeyADT() { // Disconnect Events cmbKeyMainType->Disconnect( wxEVT_COMMAND_CHOICE_SELECTED, wxCommandEventHandler( frmContactEditorKeyADT::ProcessKeyType ), NULL, this ); - chkUsePref->Disconnect( wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler( frmContactEditorKeyADT::EnablePriority ), NULL, this ); cmbURL->Disconnect( wxEVT_COMMAND_COMBOBOX_SELECTED, wxCommandEventHandler( frmContactEditorKeyADT::ConvertURLType ), NULL, this ); cmbKeyType->Disconnect( wxEVT_COMMAND_COMBOBOX_SELECTED, wxCommandEventHandler( frmContactEditorKeyADT::ConvertKeyType ), NULL, this ); btnAction->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( frmContactEditorKeyADT::ProcessAction ), NULL, this ); diff --git a/source/AppXestiaAddrBk.h b/source/AppXestiaAddrBk.h index 939c34b..8ee17be 100644 --- a/source/AppXestiaAddrBk.h +++ b/source/AppXestiaAddrBk.h @@ -1451,15 +1451,12 @@ class frmContactEditorKeyADT : public wxDialog protected: wxNotebook* nbkWebsite; wxPanel* tabGeneral; + wxFlexGridSizer* szrGeneral; wxStaticText* lblKeyType; wxChoice* cmbKeyMainType; wxStaticText* lblType; wxChoice* cmbType; wxStaticText* lblPriority; - wxCheckBox* chkUsePref; - wxSlider* sliPriority; - wxStaticText* lblHigh; - wxStaticText* lblLow; wxPanel* tabURL; wxStaticText* lblKeyFormat; wxComboBox* cmbURL; @@ -1475,7 +1472,6 @@ class frmContactEditorKeyADT : public wxDialog // Virtual event handlers, overide them in your derived class virtual void ProcessKeyType( wxCommandEvent& event ) { event.Skip(); } - virtual void EnablePriority( wxCommandEvent& event ) { event.Skip(); } virtual void ConvertURLType( wxCommandEvent& event ) { event.Skip(); } virtual void ConvertKeyType( wxCommandEvent& event ) { event.Skip(); } virtual void ProcessAction( wxCommandEvent& event ) { event.Skip(); } diff --git a/source/contacteditor/frmContactEditorKey.cpp b/source/contacteditor/frmContactEditorKey.cpp index fb6319b..78ee77a 100644 --- a/source/contacteditor/frmContactEditorKey.cpp +++ b/source/contacteditor/frmContactEditorKey.cpp @@ -29,7 +29,8 @@ frmContactEditorKeyADT( parent ) // Setup the window. EditorMode = FALSE; - sliPriority->Disable(); + priorityCtrl = new XABPriorityCtrl(tabGeneral); + szrGeneral->Add(priorityCtrl, 1, wxEXPAND, 5); // Setup the control boxes and hide tabs unless they are // needed. @@ -52,19 +53,6 @@ frmContactEditorKeyADT( parent ) } -void frmContactEditorKey::EnablePriority( wxCommandEvent& event ) -{ - - // Enable/disable the priority setting. - - if (chkUsePref->IsChecked()){ - sliPriority->Enable(); - } else { - sliPriority->Disable(); - } - -} - void frmContactEditorKey::SetEditorMode(bool EditMode) { @@ -208,9 +196,8 @@ void frmContactEditorKey::SetEditorMode(bool EditMode) if (intiter->first == KeyListIndex && intiter->second > 0 && intiter != KeyListPrefPtr->end()){ - sliPriority->SetValue(intiter->second); - sliPriority->Enable(); - chkUsePref->SetValue(TRUE); + priorityCtrl->SetValue(intiter->second); + priorityCtrl->EnablePriority(true); } @@ -296,10 +283,10 @@ void frmContactEditorKey::ProcessAction( wxCommandEvent& event ) // Get Key priority. - if (chkUsePref->IsChecked()){ + if (priorityCtrl->IsPriorityChecked()){ - KeyListPrefPtr->insert(std::make_pair(KeyListIndex, sliPriority->GetValue())); - KeyListCtrlPtr->SetItem(ListCtrlIndex, 2, wxString::Format(wxT("%i"), sliPriority->GetValue())); + KeyListPrefPtr->insert(std::make_pair(KeyListIndex, priorityCtrl->GetValue())); + KeyListCtrlPtr->SetItem(ListCtrlIndex, 2, wxString::Format(wxT("%i"), priorityCtrl->GetValue())); } else { @@ -307,10 +294,6 @@ void frmContactEditorKey::ProcessAction( wxCommandEvent& event ) } - if (chkUsePref->IsChecked()){ - - } - this->Close(); } else if (EditorMode == TRUE){ @@ -388,10 +371,10 @@ void frmContactEditorKey::ProcessAction( wxCommandEvent& event ) KeyListPrefPtr->erase(KeyListIndex); - if (chkUsePref->IsChecked()){ + if (priorityCtrl->IsPriorityChecked()){ - KeyListPrefPtr->insert(std::make_pair(KeyListIndex, sliPriority->GetValue())); - KeyListCtrlPtr->SetItem(longSelected, 2, wxString::Format(wxT("%i"), sliPriority->GetValue())); + KeyListPrefPtr->insert(std::make_pair(KeyListIndex, priorityCtrl->GetValue())); + KeyListCtrlPtr->SetItem(longSelected, 2, wxString::Format(wxT("%i"), priorityCtrl->GetValue())); } else { diff --git a/source/contacteditor/frmContactEditorKey.h b/source/contacteditor/frmContactEditorKey.h index 6e27dd3..b67ad48 100644 --- a/source/contacteditor/frmContactEditorKey.h +++ b/source/contacteditor/frmContactEditorKey.h @@ -27,6 +27,7 @@ Subclass of frmContactEditorKeyADT, which is generated by wxFormBuilder. #include #include "../AppXestiaAddrBk.h" #include "../enums.h" +#include "../widgets/XABPriorityCtrl.h" //// end generated include @@ -35,7 +36,6 @@ class frmContactEditorKey : public frmContactEditorKeyADT { protected: // Handlers for frmContactEditorKeyADT events. - void EnablePriority( wxCommandEvent& event ); void ProcessAction( wxCommandEvent& event ); void CloseWindow( wxCommandEvent& event ); void ProcessKeyType( wxCommandEvent& event ); @@ -70,7 +70,7 @@ class frmContactEditorKey : public frmContactEditorKeyADT wxListCtrl *KeyListCtrlPtr; int KeyListIndex; SectionType EditSectionType; - + XABPriorityCtrl *priorityCtrl = nullptr; }; #endif // __frmContactEditorKey__ -- 2.39.5