Home | News | Projects | Releases
Bugs | RFE | Repositories | Help
frmContactEditorRoles: Implemented priority control
authorSteve Brokenshire <sbrokenshire@xestia.co.uk>
Mon, 28 Aug 2017 18:44:24 +0000 (19:44 +0100)
committerSteve Brokenshire <sbrokenshire@xestia.co.uk>
Mon, 28 Aug 2017 18:44:24 +0000 (19:44 +0100)
source/AppXestiaAddrBk.cpp
source/AppXestiaAddrBk.h
source/contacteditor/frmContactEditorRoles.cpp
source/contacteditor/frmContactEditorRoles.h

index 47e88df..b15bd9a 100644 (file)
@@ -4396,71 +4396,26 @@ frmContactEditorRolesADT::frmContactEditorRolesADT( wxWindow* parent, wxWindowID
        
        nbkRole = new wxNotebook( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, 0 );
        tabGeneral = new wxPanel( nbkRole, 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 );
        
        lblRole = new wxStaticText( tabGeneral, wxID_ANY, wxT("Role Name:"), wxDefaultPosition, wxDefaultSize, 0 );
        lblRole->Wrap( -1 );
-       fgSizer6->Add( lblRole, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5 );
+       szrGeneral->Add( lblRole, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5 );
        
        txtRole = new wxTextCtrl( tabGeneral, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 );
-       fgSizer6->Add( txtRole, 0, wxALL|wxEXPAND, 5 );
+       szrGeneral->Add( txtRole, 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 );
        nbkRole->AddPage( tabGeneral, wxT("General"), false );
        
        bSizer251->Add( nbkRole, 1, wxEXPAND | wxALL, 5 );
@@ -4484,7 +4439,6 @@ frmContactEditorRolesADT::frmContactEditorRolesADT( wxWindow* parent, wxWindowID
        this->Centre( wxBOTH );
        
        // Connect Events
-       chkUsePref->Connect( wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler( frmContactEditorRolesADT::EnablePriority ), NULL, this );
        btnAction->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( frmContactEditorRolesADT::ProcessAction ), NULL, this );
        btnClose->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( frmContactEditorRolesADT::CloseWindow ), NULL, this );
 }
@@ -4492,7 +4446,6 @@ frmContactEditorRolesADT::frmContactEditorRolesADT( wxWindow* parent, wxWindowID
 frmContactEditorRolesADT::~frmContactEditorRolesADT()
 {
        // Disconnect Events
-       chkUsePref->Disconnect( wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler( frmContactEditorRolesADT::EnablePriority ), NULL, this );
        btnAction->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( frmContactEditorRolesADT::ProcessAction ), NULL, this );
        btnClose->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( frmContactEditorRolesADT::CloseWindow ), NULL, this );
        
index c20329d..6084305 100644 (file)
@@ -1088,25 +1088,21 @@ class frmContactEditorRolesADT : public wxDialog
        protected:
                wxNotebook* nbkRole;
                wxPanel* tabGeneral;
+               wxFlexGridSizer* szrGeneral;
                wxStaticText* lblRole;
                wxTextCtrl* txtRole;
                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(); }
                
        
        public:
                
-               frmContactEditorRolesADT( wxWindow* parent, wxWindowID id = wxID_ANY, const wxString& title = wxT("Role Editor"), const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxSize( 350,210 ), long style = wxDEFAULT_DIALOG_STYLE ); 
+               frmContactEditorRolesADT( wxWindow* parent, wxWindowID id = wxID_ANY, const wxString& title = wxT("Role Editor"), const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxSize( 386,231 ), long style = wxDEFAULT_DIALOG_STYLE ); 
                ~frmContactEditorRolesADT();
        
 };
index 30a20b4..43f6b9e 100644 (file)
@@ -30,19 +30,9 @@ frmContactEditorRolesADT( parent )
        // Setup the window.
        
        EditorMode = FALSE;
-       sliPriority->Disable();
-}
-
-void frmContactEditorRoles::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);
        
 }
 
@@ -83,9 +73,9 @@ void frmContactEditorRoles::ProcessAction( wxCommandEvent& event )
                
                // Add the website priority.
                
-               if (chkUsePref->IsChecked()){
+               if (priorityCtrl->IsPriorityChecked()){
                
-                       RolesListPrefPtr->insert(std::make_pair(RolesListIndex, sliPriority->GetValue()));
+                       RolesListPrefPtr->insert(std::make_pair(RolesListIndex, priorityCtrl->GetValue()));
                
                } else {
                
@@ -102,11 +92,11 @@ void frmContactEditorRoles::ProcessAction( wxCommandEvent& event )
                coldata.SetText(txtRole->GetValue());
                ListCtrlIndex = RolesListCtrlPtr->InsertItem(coldata);
                
-               if (chkUsePref->IsChecked()){
+               if (priorityCtrl->IsPriorityChecked()){
                
-                       RolesListCtrlPtr->SetItem(ListCtrlIndex, 1, wxString::Format(wxT("%i"), sliPriority->GetValue()));
+                       RolesListCtrlPtr->SetItem(ListCtrlIndex, 1, wxString::Format(wxT("%i"), priorityCtrl->GetValue()));
                
-               }               
+               }
        
                this->Close();          
        
@@ -122,15 +112,15 @@ void frmContactEditorRoles::ProcessAction( wxCommandEvent& event )
                
                RolesListPrefPtr->erase(RolesListIndex);
                
-               if (chkUsePref->IsChecked()){
+               if (priorityCtrl->IsPriorityChecked()){
                
-                       RolesListPrefPtr->insert(std::make_pair(RolesListIndex, sliPriority->GetValue()));
+                       RolesListPrefPtr->insert(std::make_pair(RolesListIndex, priorityCtrl->GetValue()));
                
                } else {
                
                        RolesListPrefPtr->insert(std::make_pair(RolesListIndex, 0));
                
-               }               
+               }       
                
                // Update the form.
                
@@ -144,15 +134,15 @@ void frmContactEditorRoles::ProcessAction( wxCommandEvent& event )
                
                RolesListCtrlPtr->SetItem(longSelected, 0, txtRole->GetValue());
                
-               if (chkUsePref->IsChecked()){
+               if (priorityCtrl->IsPriorityChecked()){
                
-                       RolesListCtrlPtr->SetItem(longSelected, 1, wxString::Format(wxT("%i"), sliPriority->GetValue()));
+                       RolesListCtrlPtr->SetItem(longSelected, 1, wxString::Format(wxT("%i"), priorityCtrl->GetValue()));
                
                } else {
                
                        RolesListCtrlPtr->SetItem(longSelected, 1, wxT(""));
                
-               }               
+               }       
        
                this->Close();
        
@@ -205,9 +195,8 @@ void frmContactEditorRoles::SetEditorMode(bool EditMode, SectionType SectType)
                if (intiter->first == RolesListIndex && intiter->second > 0 &&
                        intiter != RolesListPrefPtr->end()){
                
-                       sliPriority->SetValue(intiter->second);
-                       sliPriority->Enable();
-                       chkUsePref->SetValue(TRUE);
+                       priorityCtrl->SetValue(intiter->second);
+                       priorityCtrl->EnablePriority(true);
                
                }       
                
index 5d18bbd..64dede0 100644 (file)
@@ -27,6 +27,7 @@ Subclass of frmContactEditorRolesADT, which is generated by wxFormBuilder.
 #include <map>
 #include "../AppXestiaAddrBk.h"
 #include "../enums.h"
+#include "../widgets/XABPriorityCtrl.h"
 
 //// end generated include
 
@@ -35,7 +36,6 @@ class frmContactEditorRoles : public frmContactEditorRolesADT
 {
        protected:
                // Handlers for frmContactEditorRolesADT events.
-               void EnablePriority( wxCommandEvent& event );
                void ProcessAction( wxCommandEvent& event );
                void CloseWindow( wxCommandEvent& event );
        public:
@@ -66,6 +66,7 @@ class frmContactEditorRoles : public frmContactEditorRolesADT
                wxListCtrl *RolesListCtrlPtr;
                int RolesListIndex;
                SectionType EditSectionType;
+               XABPriorityCtrl *priorityCtrl = nullptr;
 };
 
 #endif // __frmContactEditorRoles__
Xestia Software Development
Yn Maystri
© 2006 - 2019 Xestia Software Development
Software

Xestia Address Book
Xestia Calendar
Development

Xestia Gelforn
Everything else

About
News
Privacy Policy