From b63495690152d16a9649eb93558685f2382e1f08 Mon Sep 17 00:00:00 2001 From: Simon Rozman Date: Tue, 21 Jun 2016 09:18:17 +0200 Subject: [PATCH] Credentials dialog banner title now dynamic --- lib/EAPBase_UI/include/EAP_UI.h | 40 ++++++++++++++++++++++++++++----- lib/EAPBase_UI/res/wxEAP_UI.fbp | 2 +- lib/EAPBase_UI/res/wxEAP_UI.h | 2 +- lib/EAPBase_UI/src/EAP_UI.cpp | 33 --------------------------- 4 files changed, 36 insertions(+), 41 deletions(-) diff --git a/lib/EAPBase_UI/include/EAP_UI.h b/lib/EAPBase_UI/include/EAP_UI.h index f25304a..4a6ebb3 100644 --- a/lib/EAPBase_UI/include/EAP_UI.h +++ b/lib/EAPBase_UI/include/EAP_UI.h @@ -31,7 +31,7 @@ template class wxEAPConfigDialog; /// /// EAP credentials dialog /// -class wxEAPCredentialsDialog; +template class wxEAPCredentialsDialog; /// /// EAP dialog banner @@ -153,22 +153,50 @@ protected: }; +template class wxEAPCredentialsDialog : public wxEAPCredentialsDialogBase { public: /// /// Constructs a credential dialog /// - wxEAPCredentialsDialog(wxWindow* parent); + wxEAPCredentialsDialog(_Tprov &prov, wxWindow* parent) : wxEAPCredentialsDialogBase(parent) + { + // Set extra style here, as wxFormBuilder overrides all default flags. + this->SetExtraStyle(this->GetExtraStyle() | wxWS_EX_VALIDATE_RECURSIVELY); + + // Set banner title. + m_banner->m_title->SetLabel(wxString::Format(_("%s Credentials"), prov.m_id.c_str())); + + m_buttonsOK->SetDefault(); + } + /// /// Adds panels to the dialog /// - void AddContents(wxPanel **contents, size_t content_count); + void AddContents(wxPanel **contents, size_t content_count) + { + if (content_count) { + for (size_t i = 0; i < content_count; i++) + m_panels->Add(contents[i], 0, wxALL|wxEXPAND, 5); + + this->Layout(); + this->GetSizer()->Fit(this); + contents[0]->SetFocusFromKbd(); + } + } + protected: /// \cond internal - virtual void OnInitDialog(wxInitDialogEvent& event); + + virtual void OnInitDialog(wxInitDialogEvent& event) + { + for (wxSizerItemList::compatibility_iterator panel = m_panels->GetChildren().GetFirst(); panel; panel = panel->GetNext()) + panel->GetData()->GetWindow()->GetEventHandler()->ProcessEvent(event); + } + /// \endcond }; @@ -341,7 +369,7 @@ protected: { UNREFERENCED_PARAMETER(event); - wxEAPCredentialsDialog dlg(this); + wxEAPCredentialsDialog<_Tprov> dlg(m_prov, this); _wxT *panel = new _wxT(m_prov, m_cred, m_target.c_str(), &dlg, true); @@ -363,7 +391,7 @@ protected: { UNREFERENCED_PARAMETER(event); - wxEAPCredentialsDialog dlg(this); + wxEAPCredentialsDialog<_Tprov> dlg(m_prov, this); _wxT *panel = new _wxT(m_prov, m_cred, _T(""), &dlg, true); diff --git a/lib/EAPBase_UI/res/wxEAP_UI.fbp b/lib/EAPBase_UI/res/wxEAP_UI.fbp index 96311ed..9498482 100644 --- a/lib/EAPBase_UI/res/wxEAP_UI.fbp +++ b/lib/EAPBase_UI/res/wxEAP_UI.fbp @@ -582,7 +582,7 @@ 1 - protected + public 1 Resizable diff --git a/lib/EAPBase_UI/res/wxEAP_UI.h b/lib/EAPBase_UI/res/wxEAP_UI.h index 8513c0c..075ccaf 100644 --- a/lib/EAPBase_UI/res/wxEAP_UI.h +++ b/lib/EAPBase_UI/res/wxEAP_UI.h @@ -92,9 +92,9 @@ class wxEAPBannerPanelBase : public wxPanel private: protected: - wxStaticText* m_title; public: + wxStaticText* m_title; wxEAPBannerPanelBase( wxWindow* parent, wxWindowID id = wxID_ANY, const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxSize( -1,-1 ), long style = 0 ); ~wxEAPBannerPanelBase(); diff --git a/lib/EAPBase_UI/src/EAP_UI.cpp b/lib/EAPBase_UI/src/EAP_UI.cpp index 2b6ff26..45b0e6a 100644 --- a/lib/EAPBase_UI/src/EAP_UI.cpp +++ b/lib/EAPBase_UI/src/EAP_UI.cpp @@ -21,39 +21,6 @@ #include "StdAfx.h" -////////////////////////////////////////////////////////////////////// -// wxEAPCredentialsDialog -////////////////////////////////////////////////////////////////////// - -wxEAPCredentialsDialog::wxEAPCredentialsDialog(wxWindow* parent) : wxEAPCredentialsDialogBase(parent) -{ - // Set extra style here, as wxFormBuilder overrides all default flags. - this->SetExtraStyle(this->GetExtraStyle() | wxWS_EX_VALIDATE_RECURSIVELY); - - m_buttonsOK->SetDefault(); -} - - -void wxEAPCredentialsDialog::AddContents(wxPanel **contents, size_t content_count) -{ - if (content_count) { - for (size_t i = 0; i < content_count; i++) - m_panels->Add(contents[i], 0, wxALL|wxEXPAND, 5); - - this->Layout(); - this->GetSizer()->Fit(this); - contents[0]->SetFocusFromKbd(); - } -} - - -void wxEAPCredentialsDialog::OnInitDialog(wxInitDialogEvent& event) -{ - for (wxSizerItemList::compatibility_iterator panel = m_panels->GetChildren().GetFirst(); panel; panel = panel->GetNext()) - panel->GetData()->GetWindow()->GetEventHandler()->ProcessEvent(event); -} - - ////////////////////////////////////////////////////////////////////// // wxEAPBannerPanel //////////////////////////////////////////////////////////////////////