///////////////////////////////////////////////////////////////////////////////
-// Name: common/rendcmn.cpp
+// Name: src/common/rendcmn.cpp
// Purpose: wxRendererNative common functions
// Author: Vadim Zeitlin
// Modified by:
#ifndef WX_PRECOMP
#include "wx/app.h"
+ #include "wx/log.h"
+ #include "wx/intl.h"
#endif //WX_PRECOMP
#include "wx/apptrait.h"
// wxRendererPtr: auto pointer holding the global renderer
// ----------------------------------------------------------------------------
-wxDECLARE_SCOPED_PTR(wxRendererNative, wxRendererPtrBase);
-wxDEFINE_SCOPED_PTR(wxRendererNative, wxRendererPtrBase);
+typedef wxScopedPtr<wxRendererNative> wxRendererPtrBase;
class wxRendererPtr : public wxRendererPtrBase
{
}
// return the global and unique wxRendererPtr
- static wxRendererPtr& Get()
- {
- static wxRendererPtr s_renderer;
-
- return s_renderer;
- }
+ static wxRendererPtr& Get();
private:
wxRendererPtr() : wxRendererPtrBase(NULL) { m_initialized = false; }
bool m_initialized;
+ // just to suppress a gcc warning
+ friend class wxRendererPtrDummyFriend;
+
DECLARE_NO_COPY_CLASS(wxRendererPtr)
};
+// return the global and unique wxRendererPtr
+/*static*/ wxRendererPtr& wxRendererPtr::Get()
+{
+ static wxRendererPtr s_renderer;
+
+ return s_renderer;
+}
+
#if wxUSE_DYNLIB_CLASS
// ----------------------------------------------------------------------------
// wxRendererNative implementation
// ============================================================================
+wxRendererNative::~wxRendererNative()
+{
+ // empty but necessary
+}
+
// ----------------------------------------------------------------------------
// Managing the global renderer
// ----------------------------------------------------------------------------
if ( !pfnwxCreateRenderer )
return NULL;
+ // create a renderer object
wxRendererNative *renderer = (*pfnwxCreateRenderer)();
if ( !renderer )
return NULL;
+ // check that its version is compatible with ours
+ wxRendererVersion ver = renderer->GetVersion();
+ if ( !wxRendererVersion::IsCompatible(ver) )
+ {
+ wxLogError(_("Renderer \"%s\" has incompatible version %d.%d and couldn't be loaded."),
+ name.c_str(), ver.version, ver.age);
+ delete renderer;
+
+ return NULL;
+ }
+
+ // finally wrap the renderer in an object which will delete it and unload
+ // the library when it is deleted and return it to the caller
return new wxRendererFromDynLib(dll, renderer);
}
#endif // wxUSE_DYNLIB_CLASS
-