Panel icon loading simplified
This commit is contained in:
parent
9daa5b52a4
commit
6e58183d16
@ -20,10 +20,7 @@
|
|||||||
|
|
||||||
#include <wx/hyperlink.h>
|
#include <wx/hyperlink.h>
|
||||||
#include <wx/icon.h>
|
#include <wx/icon.h>
|
||||||
#include <wx/menuitem.h>
|
|
||||||
#include <wx/scrolwin.h>
|
#include <wx/scrolwin.h>
|
||||||
#include <wx/statbmp.h>
|
|
||||||
#include <wx/aui/auibar.h>
|
|
||||||
#include <Windows.h>
|
#include <Windows.h>
|
||||||
|
|
||||||
|
|
||||||
@ -95,28 +92,13 @@ template <class _Tcred, class _Tbase> class wxPasswordCredentialsPanel;
|
|||||||
///
|
///
|
||||||
/// Loads icon from resource
|
/// Loads icon from resource
|
||||||
///
|
///
|
||||||
inline wxIcon wxLoadIconFromResource(HINSTANCE hinst, PCWSTR pszName, int cx, int cy);
|
inline wxIcon wxLoadIconFromResource(HINSTANCE hinst, PCWSTR pszName, int cx = GetSystemMetrics(SM_CXICON), int cy = GetSystemMetrics(SM_CYICON));
|
||||||
|
|
||||||
///
|
///
|
||||||
/// Loads icon from resource
|
/// Loads icon from resource
|
||||||
///
|
///
|
||||||
inline wxIcon wxLoadIconFromResource(HINSTANCE hinst, PCWSTR pszName, const wxSize &size);
|
inline wxIcon wxLoadIconFromResource(HINSTANCE hinst, PCWSTR pszName, const wxSize &size);
|
||||||
|
|
||||||
///
|
|
||||||
/// Sets icon from resource
|
|
||||||
///
|
|
||||||
inline bool wxSetIconFromResource(wxStaticBitmap *bmp, wxIcon &icon, HINSTANCE hinst, PCWSTR pszName);
|
|
||||||
|
|
||||||
///
|
|
||||||
/// Sets icon from resource
|
|
||||||
///
|
|
||||||
inline bool wxSetIconFromResource(wxAuiToolBarItem *bmp, wxIcon &icon, HINSTANCE hinst, PCWSTR pszName, const wxSize &size);
|
|
||||||
|
|
||||||
///
|
|
||||||
/// Sets icon from resource
|
|
||||||
///
|
|
||||||
inline bool wxSetIconFromResource(wxMenuItem *item, wxIcon &icon, HINSTANCE hinst, PCWSTR pszName);
|
|
||||||
|
|
||||||
///
|
///
|
||||||
/// Returns GUI displayable provider name
|
/// Returns GUI displayable provider name
|
||||||
///
|
///
|
||||||
@ -342,10 +324,6 @@ public:
|
|||||||
/// Constructs a notice pannel and set the title text
|
/// Constructs a notice pannel and set the title text
|
||||||
///
|
///
|
||||||
wxEAPProviderLockedPanel(const eap::config_provider &prov, wxWindow* parent);
|
wxEAPProviderLockedPanel(const eap::config_provider &prov, wxWindow* parent);
|
||||||
|
|
||||||
protected:
|
|
||||||
winstd::library m_shell32; ///< shell32.dll resource library reference
|
|
||||||
wxIcon m_icon; ///< Panel icon
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
@ -356,10 +334,6 @@ public:
|
|||||||
/// Constructs a notice pannel and set the title text
|
/// Constructs a notice pannel and set the title text
|
||||||
///
|
///
|
||||||
wxEAPCredentialWarningPanel(const eap::config_provider &prov, wxWindow* parent);
|
wxEAPCredentialWarningPanel(const eap::config_provider &prov, wxWindow* parent);
|
||||||
|
|
||||||
protected:
|
|
||||||
winstd::library m_shell32; ///< shell32.dll resource library reference
|
|
||||||
wxIcon m_icon; ///< Panel icon
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
@ -413,8 +387,6 @@ protected:
|
|||||||
|
|
||||||
protected:
|
protected:
|
||||||
eap::config_provider &m_prov; ///< EAP method configuration
|
eap::config_provider &m_prov; ///< EAP method configuration
|
||||||
winstd::library m_shell32; ///< shell32.dll resource library reference
|
|
||||||
wxIcon m_icon; ///< Panel icon
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
@ -437,8 +409,6 @@ protected:
|
|||||||
|
|
||||||
protected:
|
protected:
|
||||||
eap::config_provider &m_prov; ///< EAP method configuration
|
eap::config_provider &m_prov; ///< EAP method configuration
|
||||||
winstd::library m_shell32; ///< shell32.dll resource library reference
|
|
||||||
wxIcon m_icon; ///< Panel icon
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
@ -480,8 +450,9 @@ public:
|
|||||||
wxEAPCredentialsConfigPanelBase(parent)
|
wxEAPCredentialsConfigPanelBase(parent)
|
||||||
{
|
{
|
||||||
// Load and set icon.
|
// Load and set icon.
|
||||||
if (m_shell32.load(_T("shell32.dll"), NULL, LOAD_LIBRARY_AS_DATAFILE | LOAD_LIBRARY_AS_IMAGE_RESOURCE))
|
winstd::library lib_shell32;
|
||||||
wxSetIconFromResource(m_credentials_icon, m_icon, m_shell32, MAKEINTRESOURCE(/*16770*/269));
|
if (lib_shell32.load(_T("shell32.dll"), NULL, LOAD_LIBRARY_AS_DATAFILE | LOAD_LIBRARY_AS_IMAGE_RESOURCE))
|
||||||
|
m_credentials_icon->SetIcon(wxLoadIconFromResource(lib_shell32, MAKEINTRESOURCE(/*16770*/269)));
|
||||||
}
|
}
|
||||||
|
|
||||||
///
|
///
|
||||||
@ -645,8 +616,6 @@ protected:
|
|||||||
protected:
|
protected:
|
||||||
const eap::config_provider &m_prov; ///< EAP provider
|
const eap::config_provider &m_prov; ///< EAP provider
|
||||||
eap::config_method_with_cred &m_cfg; ///< EAP method configuration
|
eap::config_method_with_cred &m_cfg; ///< EAP method configuration
|
||||||
winstd::library m_shell32; ///< shell32.dll resource library reference
|
|
||||||
wxIcon m_icon; ///< Panel icon
|
|
||||||
winstd::tstring m_target; ///< Credential Manager target
|
winstd::tstring m_target; ///< Credential Manager target
|
||||||
|
|
||||||
private:
|
private:
|
||||||
@ -751,8 +720,9 @@ public:
|
|||||||
wxEAPCredentialsPanelBase<_Tcred, _Tbase>(prov, cfg, cred, pszCredTarget, parent, is_config)
|
wxEAPCredentialsPanelBase<_Tcred, _Tbase>(prov, cfg, cred, pszCredTarget, parent, is_config)
|
||||||
{
|
{
|
||||||
// Load and set icon.
|
// Load and set icon.
|
||||||
if (m_shell32.load(_T("shell32.dll"), NULL, LOAD_LIBRARY_AS_DATAFILE | LOAD_LIBRARY_AS_IMAGE_RESOURCE))
|
winstd::library lib_shell32;
|
||||||
wxSetIconFromResource(m_credentials_icon, m_icon, m_shell32, MAKEINTRESOURCE(269));
|
if (lib_shell32.load(_T("shell32.dll"), NULL, LOAD_LIBRARY_AS_DATAFILE | LOAD_LIBRARY_AS_IMAGE_RESOURCE))
|
||||||
|
m_credentials_icon->SetIcon(wxLoadIconFromResource(lib_shell32, MAKEINTRESOURCE(269)));
|
||||||
|
|
||||||
bool layout = false;
|
bool layout = false;
|
||||||
if (!m_prov.m_lbl_alt_credential.empty()) {
|
if (!m_prov.m_lbl_alt_credential.empty()) {
|
||||||
@ -817,10 +787,6 @@ protected:
|
|||||||
|
|
||||||
/// \endcond
|
/// \endcond
|
||||||
|
|
||||||
protected:
|
|
||||||
winstd::library m_shell32; ///< shell32.dll resource library reference
|
|
||||||
wxIcon m_icon; ///< Panel icon
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
static const wxStringCharType *s_dummy_password;
|
static const wxStringCharType *s_dummy_password;
|
||||||
};
|
};
|
||||||
@ -853,46 +819,6 @@ inline wxIcon wxLoadIconFromResource(HINSTANCE hinst, PCWSTR pszName, const wxSi
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
inline bool wxSetIconFromResource(wxStaticBitmap *bmp, wxIcon &icon, HINSTANCE hinst, PCWSTR pszName)
|
|
||||||
{
|
|
||||||
wxASSERT(bmp);
|
|
||||||
|
|
||||||
icon = wxLoadIconFromResource(hinst, pszName, GetSystemMetrics(SM_CXICON), GetSystemMetrics(SM_CYICON));
|
|
||||||
if (icon.IsOk()) {
|
|
||||||
bmp->SetIcon(icon);
|
|
||||||
return true;
|
|
||||||
} else
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
inline bool wxSetIconFromResource(wxAuiToolBarItem *item, wxIcon &icon, HINSTANCE hinst, PCWSTR pszName, const wxSize &size)
|
|
||||||
{
|
|
||||||
wxASSERT(item);
|
|
||||||
|
|
||||||
icon = wxLoadIconFromResource(hinst, pszName, size.GetWidth(), size.GetHeight());
|
|
||||||
if (icon.IsOk()) {
|
|
||||||
item->SetBitmap(icon);
|
|
||||||
item->SetDisabledBitmap(wxBitmap(icon).ConvertToDisabled());
|
|
||||||
return true;
|
|
||||||
} else
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
inline bool wxSetIconFromResource(wxMenuItem *item, wxIcon &icon, HINSTANCE hinst, PCWSTR pszName)
|
|
||||||
{
|
|
||||||
wxASSERT(item);
|
|
||||||
|
|
||||||
icon = wxLoadIconFromResource(hinst, pszName, GetSystemMetrics(SM_CXSMICON), GetSystemMetrics(SM_CYSMICON));
|
|
||||||
if (icon.IsOk()) {
|
|
||||||
item->SetBitmaps(icon);
|
|
||||||
return true;
|
|
||||||
} else
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
inline wxString wxEAPGetProviderName(const std::wstring &id)
|
inline wxString wxEAPGetProviderName(const std::wstring &id)
|
||||||
{
|
{
|
||||||
return
|
return
|
||||||
|
@ -184,8 +184,9 @@ void wxEAPNotePanel::CreateContactFields(const eap::config_provider &prov)
|
|||||||
wxEAPProviderLockedPanel::wxEAPProviderLockedPanel(const eap::config_provider &prov, wxWindow* parent) : wxEAPNotePanel(parent)
|
wxEAPProviderLockedPanel::wxEAPProviderLockedPanel(const eap::config_provider &prov, wxWindow* parent) : wxEAPNotePanel(parent)
|
||||||
{
|
{
|
||||||
// Load and set icon.
|
// Load and set icon.
|
||||||
if (m_shell32.load(_T("shell32.dll"), NULL, LOAD_LIBRARY_AS_DATAFILE | LOAD_LIBRARY_AS_IMAGE_RESOURCE))
|
winstd::library lib_shell32;
|
||||||
wxSetIconFromResource(m_note_icon, m_icon, m_shell32, MAKEINTRESOURCE(48));
|
if (lib_shell32.load(_T("shell32.dll"), NULL, LOAD_LIBRARY_AS_DATAFILE | LOAD_LIBRARY_AS_IMAGE_RESOURCE))
|
||||||
|
m_note_icon->SetIcon(wxLoadIconFromResource(lib_shell32, MAKEINTRESOURCE(48)));
|
||||||
|
|
||||||
m_note_label->SetLabel(wxString::Format(_("%s has pre-set parts of this configuration. Those parts are locked to prevent accidental modification."),
|
m_note_label->SetLabel(wxString::Format(_("%s has pre-set parts of this configuration. Those parts are locked to prevent accidental modification."),
|
||||||
!prov.m_name.empty() ? prov.m_name.c_str() :
|
!prov.m_name.empty() ? prov.m_name.c_str() :
|
||||||
@ -205,8 +206,9 @@ wxEAPProviderLockedPanel::wxEAPProviderLockedPanel(const eap::config_provider &p
|
|||||||
wxEAPCredentialWarningPanel::wxEAPCredentialWarningPanel(const eap::config_provider &prov, wxWindow* parent) : wxEAPNotePanel(parent)
|
wxEAPCredentialWarningPanel::wxEAPCredentialWarningPanel(const eap::config_provider &prov, wxWindow* parent) : wxEAPNotePanel(parent)
|
||||||
{
|
{
|
||||||
// Load and set icon.
|
// Load and set icon.
|
||||||
if (m_shell32.load(_T("shell32.dll"), NULL, LOAD_LIBRARY_AS_DATAFILE | LOAD_LIBRARY_AS_IMAGE_RESOURCE))
|
winstd::library lib_shell32;
|
||||||
wxSetIconFromResource(m_note_icon, m_icon, m_shell32, MAKEINTRESOURCE(161));
|
if (lib_shell32.load(_T("shell32.dll"), NULL, LOAD_LIBRARY_AS_DATAFILE | LOAD_LIBRARY_AS_IMAGE_RESOURCE))
|
||||||
|
m_note_icon->SetIcon(wxLoadIconFromResource(lib_shell32, MAKEINTRESOURCE(161)));
|
||||||
|
|
||||||
m_note_label->SetLabel(_("Previous attempt to connect failed. Please, make sure your credentials are correct, or try again later."));
|
m_note_label->SetLabel(_("Previous attempt to connect failed. Please, make sure your credentials are correct, or try again later."));
|
||||||
m_note_label->Wrap(449);
|
m_note_label->Wrap(449);
|
||||||
@ -275,8 +277,9 @@ wxEAPProviderIdentityPanel::wxEAPProviderIdentityPanel(eap::config_provider &pro
|
|||||||
wxEAPProviderIdentityPanelBase(parent)
|
wxEAPProviderIdentityPanelBase(parent)
|
||||||
{
|
{
|
||||||
// Load and set icon.
|
// Load and set icon.
|
||||||
if (m_shell32.load(_T("shell32.dll"), NULL, LOAD_LIBRARY_AS_DATAFILE | LOAD_LIBRARY_AS_IMAGE_RESOURCE))
|
winstd::library lib_shell32;
|
||||||
wxSetIconFromResource(m_provider_id_icon, m_icon, m_shell32, MAKEINTRESOURCE(259));
|
if (lib_shell32.load(_T("shell32.dll"), NULL, LOAD_LIBRARY_AS_DATAFILE | LOAD_LIBRARY_AS_IMAGE_RESOURCE))
|
||||||
|
m_provider_id_icon->SetIcon(wxLoadIconFromResource(lib_shell32, MAKEINTRESOURCE(259)));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -313,8 +316,9 @@ wxEAPProviderLockPanel::wxEAPProviderLockPanel(eap::config_provider &prov, wxWin
|
|||||||
wxEAPProviderLockPanelBase(parent)
|
wxEAPProviderLockPanelBase(parent)
|
||||||
{
|
{
|
||||||
// Load and set icon.
|
// Load and set icon.
|
||||||
if (m_shell32.load(_T("shell32.dll"), NULL, LOAD_LIBRARY_AS_DATAFILE | LOAD_LIBRARY_AS_IMAGE_RESOURCE))
|
winstd::library lib_shell32;
|
||||||
wxSetIconFromResource(m_provider_lock_icon, m_icon, m_shell32, MAKEINTRESOURCE(1003));
|
if (lib_shell32.load(_T("shell32.dll"), NULL, LOAD_LIBRARY_AS_DATAFILE | LOAD_LIBRARY_AS_IMAGE_RESOURCE))
|
||||||
|
m_provider_lock_icon->SetIcon(wxLoadIconFromResource(lib_shell32, MAKEINTRESOURCE(1003)));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -269,10 +269,6 @@ protected:
|
|||||||
virtual bool TransferDataFromWindow();
|
virtual bool TransferDataFromWindow();
|
||||||
virtual void OnUpdateUI(wxUpdateUIEvent& event);
|
virtual void OnUpdateUI(wxUpdateUIEvent& event);
|
||||||
/// \endcond
|
/// \endcond
|
||||||
|
|
||||||
protected:
|
|
||||||
winstd::library m_shell32; ///< shell32.dll resource library reference
|
|
||||||
wxIcon m_icon; ///< Panel icon
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
@ -309,8 +305,6 @@ protected:
|
|||||||
protected:
|
protected:
|
||||||
const eap::config_provider &m_prov; ///< EAP provider
|
const eap::config_provider &m_prov; ///< EAP provider
|
||||||
eap::config_method_tls &m_cfg; ///< TLS configuration
|
eap::config_method_tls &m_cfg; ///< TLS configuration
|
||||||
winstd::library m_certmgr; ///< certmgr.dll resource library reference
|
|
||||||
wxIcon m_icon; ///< Panel icon
|
|
||||||
std::list<std::wstring> m_server_names_val; ///< Acceptable authenticating server names
|
std::list<std::wstring> m_server_names_val; ///< Acceptable authenticating server names
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -315,8 +315,9 @@ wxTLSCredentialsPanel::wxTLSCredentialsPanel(const eap::config_provider &prov, c
|
|||||||
wxEAPCredentialsPanelBase<eap::credentials_tls, wxTLSCredentialsPanelBase>(prov, cfg, cred, pszCredTarget, parent, is_config)
|
wxEAPCredentialsPanelBase<eap::credentials_tls, wxTLSCredentialsPanelBase>(prov, cfg, cred, pszCredTarget, parent, is_config)
|
||||||
{
|
{
|
||||||
// Load and set icon.
|
// Load and set icon.
|
||||||
if (m_shell32.load(_T("shell32.dll"), NULL, LOAD_LIBRARY_AS_DATAFILE | LOAD_LIBRARY_AS_IMAGE_RESOURCE))
|
winstd::library lib_shell32;
|
||||||
wxSetIconFromResource(m_credentials_icon, m_icon, m_shell32, MAKEINTRESOURCE(269));
|
if (lib_shell32.load(_T("shell32.dll"), NULL, LOAD_LIBRARY_AS_DATAFILE | LOAD_LIBRARY_AS_IMAGE_RESOURCE))
|
||||||
|
m_credentials_icon->SetIcon(wxLoadIconFromResource(lib_shell32, MAKEINTRESOURCE(269)));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -418,8 +419,9 @@ wxTLSServerTrustPanel::wxTLSServerTrustPanel(const eap::config_provider &prov, e
|
|||||||
wxEAPTLSServerTrustConfigPanelBase(parent)
|
wxEAPTLSServerTrustConfigPanelBase(parent)
|
||||||
{
|
{
|
||||||
// Load and set icon.
|
// Load and set icon.
|
||||||
if (m_certmgr.load(_T("certmgr.dll"), NULL, LOAD_LIBRARY_AS_DATAFILE | LOAD_LIBRARY_AS_IMAGE_RESOURCE))
|
winstd::library lib_certmgr;
|
||||||
wxSetIconFromResource(m_server_trust_icon, m_icon, m_certmgr, MAKEINTRESOURCE(218));
|
if (lib_certmgr.load(_T("certmgr.dll"), NULL, LOAD_LIBRARY_AS_DATAFILE | LOAD_LIBRARY_AS_IMAGE_RESOURCE))
|
||||||
|
m_server_trust_icon->SetIcon(wxLoadIconFromResource(lib_certmgr, MAKEINTRESOURCE(218)));
|
||||||
|
|
||||||
// Do not use cfg.m_server_names directly, so we can decide not to store the value in case of provider-locked configuration.
|
// Do not use cfg.m_server_names directly, so we can decide not to store the value in case of provider-locked configuration.
|
||||||
// Never rely on control disabled state alone, as they can be enabled using external tool like Spy++.
|
// Never rely on control disabled state alone, as they can be enabled using external tool like Spy++.
|
||||||
|
@ -68,8 +68,6 @@ protected:
|
|||||||
protected:
|
protected:
|
||||||
const eap::config_provider &m_prov; ///< EAP provider
|
const eap::config_provider &m_prov; ///< EAP provider
|
||||||
eap::config_method_ttls &m_cfg; ///< TTLS configuration
|
eap::config_method_ttls &m_cfg; ///< TTLS configuration
|
||||||
winstd::library m_shell32; ///< shell32.dll resource library reference
|
|
||||||
wxIcon m_icon; ///< Panel icon
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
@ -31,8 +31,9 @@ wxTTLSConfigPanel::wxTTLSConfigPanel(const eap::config_provider &prov, eap::conf
|
|||||||
wxTTLSConfigPanelBase(parent)
|
wxTTLSConfigPanelBase(parent)
|
||||||
{
|
{
|
||||||
// Load and set icon.
|
// Load and set icon.
|
||||||
if (m_shell32.load(_T("shell32.dll"), NULL, LOAD_LIBRARY_AS_DATAFILE | LOAD_LIBRARY_AS_IMAGE_RESOURCE))
|
winstd::library lib_shell32;
|
||||||
wxSetIconFromResource(m_outer_identity_icon, m_icon, m_shell32, MAKEINTRESOURCE(265));
|
if (lib_shell32.load(_T("shell32.dll"), NULL, LOAD_LIBRARY_AS_DATAFILE | LOAD_LIBRARY_AS_IMAGE_RESOURCE))
|
||||||
|
m_outer_identity_icon->SetIcon(wxLoadIconFromResource(lib_shell32, MAKEINTRESOURCE(265)));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user