wxInitializerPeer: Move upstream and make reusable
Signed-off-by: Simon Rozman <simon@rozman.si>
This commit is contained in:
@@ -91,7 +91,7 @@
|
||||
<PropertyGroup />
|
||||
<ItemDefinitionGroup>
|
||||
<ClCompile>
|
||||
<AdditionalIncludeDirectories>..\..\Events\build\temp\Events.$(Platform).$(Configuration).$(PlatformToolset);..\..\WinStd\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
<AdditionalIncludeDirectories>..\..\Events\build\temp\Events.$(Platform).$(Configuration).$(PlatformToolset);..\..\WinStd\include;..\..\wxExtend\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
</ClCompile>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" />
|
||||
|
@@ -46,6 +46,7 @@ template <class _Tcred, class _Tbase> class wxEAPCredentialsPanel;
|
||||
template <class _Tcred, class _Tbase> class wxIdentityCredentialsPanel;
|
||||
template <class _Tcred, class _Tbase> class wxPasswordCredentialsPanel;
|
||||
class wxEAPProviderSelectDialog;
|
||||
class wxInitializerPeer;
|
||||
|
||||
///
|
||||
/// \defgroup EAPBaseGUI GUI
|
||||
@@ -121,7 +122,9 @@ inline void wxInitializeConfig();
|
||||
#include <WinStd/Win.h>
|
||||
|
||||
#include <wx/config.h>
|
||||
#include <wx/intl.h>
|
||||
#include <wx/log.h>
|
||||
#include <wx/thread.h>
|
||||
|
||||
#include <CommCtrl.h>
|
||||
|
||||
@@ -409,6 +412,32 @@ protected:
|
||||
};
|
||||
|
||||
|
||||
///
|
||||
/// Peer initializer
|
||||
///
|
||||
class wxInitializerPeer
|
||||
{
|
||||
public:
|
||||
///
|
||||
/// Initialize peer
|
||||
///
|
||||
wxInitializerPeer(_In_ HINSTANCE instance, _In_ const wxString &domain, _In_opt_ HWND hwndParent);
|
||||
|
||||
///
|
||||
/// Uninitialize peer
|
||||
///
|
||||
virtual ~wxInitializerPeer();
|
||||
|
||||
public:
|
||||
wxWindow* m_parent; ///< Parent window
|
||||
|
||||
protected:
|
||||
static wxCriticalSection s_lock; ///< Initialization lock
|
||||
static unsigned long s_init_ref_count; ///< Initialization reference counter
|
||||
static wxLocale *s_locale; ///< Locale
|
||||
};
|
||||
|
||||
|
||||
///
|
||||
/// EAP general note
|
||||
///
|
||||
@@ -1028,8 +1057,6 @@ protected:
|
||||
/// \endcond
|
||||
};
|
||||
|
||||
/// @}
|
||||
|
||||
|
||||
///
|
||||
/// Generic password credential entry panel
|
||||
|
@@ -467,3 +467,62 @@ void wxEAPProviderSelectDialog::OnProvSelect(wxCommandEvent& event)
|
||||
event.Skip();
|
||||
}
|
||||
/// \endcond
|
||||
|
||||
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
// wxInitializerPeer
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
|
||||
wxInitializerPeer::wxInitializerPeer(_In_ HINSTANCE instance, _In_ const wxString &domain, _In_opt_ HWND hwndParent)
|
||||
{
|
||||
wxCriticalSectionLocker locker(s_lock);
|
||||
|
||||
if (s_init_ref_count++ == 0) {
|
||||
// Initialize application.
|
||||
new wxApp();
|
||||
wxEntryStart(instance);
|
||||
|
||||
// Do our wxWidgets configuration and localization initialization.
|
||||
wxInitializeConfig();
|
||||
s_locale = new wxLocale;
|
||||
if (wxInitializeLocale(*s_locale)) {
|
||||
s_locale->AddCatalog(wxT("wxExtend") wxT(wxExtendVersion));
|
||||
if (!domain.IsEmpty())
|
||||
s_locale->AddCatalog(domain);
|
||||
}
|
||||
}
|
||||
|
||||
if (hwndParent) {
|
||||
// Create wxWidget-approved parent window.
|
||||
m_parent = new wxWindow;
|
||||
m_parent->SetHWND((WXHWND)hwndParent);
|
||||
m_parent->AdoptAttributesFromHWND();
|
||||
wxTopLevelWindows.Append(m_parent);
|
||||
} else
|
||||
m_parent = NULL;
|
||||
}
|
||||
|
||||
|
||||
wxInitializerPeer::~wxInitializerPeer()
|
||||
{
|
||||
wxCriticalSectionLocker locker(s_lock);
|
||||
|
||||
if (m_parent) {
|
||||
wxTopLevelWindows.DeleteObject(m_parent);
|
||||
m_parent->SetHWND((WXHWND)NULL);
|
||||
}
|
||||
|
||||
if (--s_init_ref_count == 0) {
|
||||
wxEntryCleanup();
|
||||
|
||||
if (s_locale) {
|
||||
delete s_locale;
|
||||
s_locale = NULL;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
wxCriticalSection wxInitializerPeer::s_lock;
|
||||
unsigned long wxInitializerPeer::s_init_ref_count = 0;
|
||||
wxLocale *wxInitializerPeer::s_locale = NULL;
|
||||
|
@@ -23,4 +23,7 @@
|
||||
#include "../include/EAP_UI.h"
|
||||
#include "../include/Module.h"
|
||||
|
||||
#include <wxex/common.h>
|
||||
|
||||
#include <wx/app.h>
|
||||
#include <wx/commandlinkbutton.h>
|
||||
|
Reference in New Issue
Block a user