mirror of
https://github.com/cookiengineer/audacity
synced 2025-07-31 16:09:28 +02:00
Merge branch 'wx3.0-compat-initial'
Reference-to: https://github.com/tenacityteam/tenacity/pull/514 Signed-off-by: Mart Raudsepp <leio@gentoo.org>
This commit is contained in:
commit
807b710c74
@ -28,7 +28,14 @@ std::string ToUTF8 (const wchar_t* wstr)
|
||||
|
||||
std::string ToUTF8 (const wxString& wstr)
|
||||
{
|
||||
#if wxCHECK_VERSION(3, 1, 1)
|
||||
return wstr.ToStdString (wxGet_wxConvUTF8 ());
|
||||
#elif !wxUSE_UNICODE
|
||||
return std::string (wstr.c_str (), wstr.length ());
|
||||
#else
|
||||
wxScopedCharBuffer buf (wstr.mb_str (wxGet_wxConvUTF8 ()));
|
||||
return std::string (buf.data (), buf.length ());
|
||||
#endif
|
||||
}
|
||||
|
||||
std::wstring ToWString (const std::string& str)
|
||||
@ -48,7 +55,11 @@ std::wstring ToWString (const wxString& str)
|
||||
|
||||
wxString ToWXString (const std::string& str)
|
||||
{
|
||||
#if wxCHECK_VERSION(3, 1, 1)
|
||||
return wxString::FromUTF8 (str);
|
||||
#else
|
||||
return wxString::FromUTF8 (str.c_str());
|
||||
#endif
|
||||
}
|
||||
|
||||
wxString ToWXString (const std::wstring& str)
|
||||
|
@ -90,6 +90,20 @@ inline bool operator <= ( const Identifier &x, const Identifier &y )
|
||||
inline bool operator >= ( const Identifier &x, const Identifier &y )
|
||||
{ return !(x < y); }
|
||||
|
||||
#if !wxCHECK_VERSION(3, 1, 0)
|
||||
namespace std
|
||||
{
|
||||
template<> struct hash< wxString > {
|
||||
size_t operator () (const wxString &str) const // noexcept
|
||||
{
|
||||
auto stdstr = str.ToStdWstring(); // no allocations, a cheap fetch
|
||||
using Hasher = hash< decltype(stdstr) >;
|
||||
return Hasher{}( stdstr );
|
||||
}
|
||||
};
|
||||
}
|
||||
#endif
|
||||
|
||||
namespace std
|
||||
{
|
||||
template<> struct hash< Identifier > {
|
||||
|
@ -18,6 +18,7 @@
|
||||
class Identifier;
|
||||
|
||||
#include <vector>
|
||||
#include "Identifier.h"
|
||||
|
||||
//! Holds a msgid for the translation catalog; may also bind format arguments
|
||||
/*!
|
||||
|
@ -52,12 +52,12 @@ public:
|
||||
mMessage = message;
|
||||
}
|
||||
|
||||
virtual wxObject* Clone() const wxOVERRIDE
|
||||
virtual wxObject* Clone() const override
|
||||
{
|
||||
return safenew FilesystemValidator(mMessage);
|
||||
}
|
||||
|
||||
virtual bool Validate(wxWindow* WXUNUSED(parent)) wxOVERRIDE
|
||||
virtual bool Validate(wxWindow* WXUNUSED(parent)) override
|
||||
{
|
||||
wxTextCtrl* tc = wxDynamicCast(GetWindow(), wxTextCtrl);
|
||||
if (!tc) {
|
||||
@ -71,12 +71,12 @@ public:
|
||||
return true;
|
||||
}
|
||||
|
||||
virtual bool TransferToWindow() wxOVERRIDE
|
||||
virtual bool TransferToWindow() override
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
virtual bool TransferFromWindow() wxOVERRIDE
|
||||
virtual bool TransferFromWindow() override
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
@ -63,7 +63,10 @@ void FileConfig::Init()
|
||||
// because we don't use the wxFileConfig::Flush() method and so the wxFileConfig dirty
|
||||
// flag never gets reset. During deletion, the dirty flag is checked and a Flush()
|
||||
// performed. This can (and probably will) create bogus temporary files.
|
||||
// TODO: Fix the problem for wx3.0
|
||||
#if wxCHECK_VERSION(3, 1, 3)
|
||||
mConfig->DisableAutoSave();
|
||||
#endif
|
||||
|
||||
bool canRead = false;
|
||||
bool canWrite = false;
|
||||
|
@ -30,22 +30,22 @@ public:
|
||||
void Init();
|
||||
virtual ~FileConfig();
|
||||
|
||||
virtual void SetPath(const wxString& strPath) wxOVERRIDE;
|
||||
virtual const wxString& GetPath() const wxOVERRIDE;
|
||||
virtual bool GetFirstGroup(wxString& str, long& lIndex) const wxOVERRIDE;
|
||||
virtual bool GetNextGroup(wxString& str, long& lIndex) const wxOVERRIDE;
|
||||
virtual bool GetFirstEntry(wxString& str, long& lIndex) const wxOVERRIDE;
|
||||
virtual bool GetNextEntry(wxString& str, long& lIndex) const wxOVERRIDE;
|
||||
virtual size_t GetNumberOfEntries(bool bRecursive = false) const wxOVERRIDE;
|
||||
virtual size_t GetNumberOfGroups(bool bRecursive = false) const wxOVERRIDE;
|
||||
virtual bool HasGroup(const wxString& strName) const wxOVERRIDE;
|
||||
virtual bool HasEntry(const wxString& strName) const wxOVERRIDE;
|
||||
virtual bool Flush(bool bCurrentOnly = false) wxOVERRIDE;
|
||||
virtual bool RenameEntry(const wxString& oldName, const wxString& newName) wxOVERRIDE;
|
||||
virtual bool RenameGroup(const wxString& oldName, const wxString& newName) wxOVERRIDE;
|
||||
virtual bool DeleteEntry(const wxString& key, bool bDeleteGroupIfEmpty = true) wxOVERRIDE;
|
||||
virtual bool DeleteGroup(const wxString& key) wxOVERRIDE;
|
||||
virtual bool DeleteAll() wxOVERRIDE;
|
||||
virtual void SetPath(const wxString& strPath) override;
|
||||
virtual const wxString& GetPath() const override;
|
||||
virtual bool GetFirstGroup(wxString& str, long& lIndex) const override;
|
||||
virtual bool GetNextGroup(wxString& str, long& lIndex) const override;
|
||||
virtual bool GetFirstEntry(wxString& str, long& lIndex) const override;
|
||||
virtual bool GetNextEntry(wxString& str, long& lIndex) const override;
|
||||
virtual size_t GetNumberOfEntries(bool bRecursive = false) const override;
|
||||
virtual size_t GetNumberOfGroups(bool bRecursive = false) const override;
|
||||
virtual bool HasGroup(const wxString& strName) const override;
|
||||
virtual bool HasEntry(const wxString& strName) const override;
|
||||
virtual bool Flush(bool bCurrentOnly = false) override;
|
||||
virtual bool RenameEntry(const wxString& oldName, const wxString& newName) override;
|
||||
virtual bool RenameGroup(const wxString& oldName, const wxString& newName) override;
|
||||
virtual bool DeleteEntry(const wxString& key, bool bDeleteGroupIfEmpty = true) override;
|
||||
virtual bool DeleteGroup(const wxString& key) override;
|
||||
virtual bool DeleteAll() override;
|
||||
|
||||
// Set and Get values of the version major/minor/micro keys in tenacity.cfg when Tenacity first opens
|
||||
void SetVersionKeysInit( int major, int minor, int micro)
|
||||
@ -62,16 +62,16 @@ public:
|
||||
}
|
||||
|
||||
protected:
|
||||
virtual bool DoReadString(const wxString& key, wxString *pStr) const wxOVERRIDE;
|
||||
virtual bool DoReadLong(const wxString& key, long *pl) const wxOVERRIDE;
|
||||
virtual bool DoReadString(const wxString& key, wxString *pStr) const override;
|
||||
virtual bool DoReadLong(const wxString& key, long *pl) const override;
|
||||
#if wxUSE_BASE64
|
||||
virtual bool DoReadBinary(const wxString& key, wxMemoryBuffer* buf) const wxOVERRIDE;
|
||||
virtual bool DoReadBinary(const wxString& key, wxMemoryBuffer* buf) const override;
|
||||
#endif // wxUSE_BASE64
|
||||
|
||||
virtual bool DoWriteString(const wxString& key, const wxString& szValue) wxOVERRIDE;
|
||||
virtual bool DoWriteLong(const wxString& key, long lValue) wxOVERRIDE;
|
||||
virtual bool DoWriteString(const wxString& key, const wxString& szValue) override;
|
||||
virtual bool DoWriteLong(const wxString& key, long lValue) override;
|
||||
#if wxUSE_BASE64
|
||||
virtual bool DoWriteBinary(const wxString& key, const wxMemoryBuffer& buf) wxOVERRIDE;
|
||||
virtual bool DoWriteBinary(const wxString& key, const wxMemoryBuffer& buf) override;
|
||||
#endif // wxUSE_BASE64
|
||||
|
||||
protected:
|
||||
|
@ -471,6 +471,16 @@ void MeterPanel::OnErase(wxEraseEvent & WXUNUSED(event))
|
||||
// Ignore it to prevent flashing
|
||||
}
|
||||
|
||||
static double GetColourLuminance(wxColour color)
|
||||
{
|
||||
#if wxCHECK_VERSION(3, 1, 0)
|
||||
return color.GetLuminance();
|
||||
#else
|
||||
// Standard RGB to YIQ conversion for the luma (Y) part, used also by wx3.1
|
||||
return (0.299*color.Red() + 0.587*color.Green() + 0.114*color.Blue()) / 255.0;
|
||||
#endif
|
||||
}
|
||||
|
||||
void MeterPanel::OnPaint(wxPaintEvent & WXUNUSED(event))
|
||||
{
|
||||
#if defined(__WXMAC__)
|
||||
@ -533,13 +543,13 @@ void MeterPanel::OnPaint(wxPaintEvent & WXUNUSED(event))
|
||||
// Bug #2473 - (Sort of) Hack to make text on meters more
|
||||
// visible with darker backgrounds. It would be better to have
|
||||
// different colors entirely and as part of the theme.
|
||||
if (GetBackgroundColour().GetLuminance() < 0.25)
|
||||
if (GetColourLuminance(GetBackgroundColour()) < 0.25)
|
||||
{
|
||||
green = wxColor(117-100, 215-100, 112-100);
|
||||
yellow = wxColor(255-100, 255-100, 0);
|
||||
red = wxColor(255-100, 0, 0);
|
||||
}
|
||||
else if (GetBackgroundColour().GetLuminance() < 0.50)
|
||||
else if (GetColourLuminance(GetBackgroundColour()) < 0.50)
|
||||
{
|
||||
green = wxColor(117-50, 215-50, 112-50);
|
||||
yellow = wxColor(255-50, 255-50, 0);
|
||||
|
Loading…
x
Reference in New Issue
Block a user