wxPlatformInfo::IsUsingUniversalWidgets() was broken by design, it couldn't work in wxBase shared by 2+ wxCores; fixed by making it non-static and moving its implementation back to wxAppTraits (where its equivalent used to be) and making small API changes implied by that

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@40630 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Václav Slavík 2006-08-16 17:18:34 +00:00
parent e74f9041c4
commit b98bd6af23
5 changed files with 101 additions and 78 deletions

View File

@ -36,6 +36,46 @@ None
\latexignore{\rtfignore{\wxheading{Members}}}
\membersection{wxAppTraits::CreateFontMapper}\label{wxapptraitscreatefontmapper}
\func{virtual wxFontMapper *}{CreateFontMapper}{\void}
Creates the global font mapper object used for encodings/charset mapping.
\membersection{wxAppTraits::CreateLogTarget}\label{wxapptraitscreatelogtarget}
\func{virtual wxLog *}{CreateLogTarget}{\void}
Creates the default log target for the application.
\membersection{wxAppTraits::CreateMessageOutput}\label{wxapptraitscreatemessageoutput}
\func{virtual wxMessageOutput *}{CreateMessageOutput}{\void}
Creates the global object used for printing out messages.
\membersection{wxAppTraits::CreateRenderer}\label{wxapptraitscreaterenderer}
\func{virtual wxRendererNative *}{CreateRenderer}{\void}
Returns the renderer to use for drawing the generic controls (return value may be \NULL
in which case the default renderer for the current platform is used);
this is used in GUI mode only and always returns \NULL in console.
NOTE: returned pointer will be deleted by the caller.
\membersection{wxAppTraits::GetStandardPaths}\label{wxapptraitsgetstandardpaths}
\func{virtual wxStandardPaths \&}{GetStandardPaths}{\void}
Returns the wxStandardPaths object for the application.
It's normally the same for wxBase and wxGUI except in the case of wxMac and wxCocoa.
\membersection{wxAppTraits::GetToolkitVersion}\label{wxapptraitsgettoolkitversion}
\func{virtual wxPortId}{GetToolkitVersion}{\param{int *}{major = NULL}, \param{int *}{minor = NULL}}
@ -50,7 +90,6 @@ put in given pointers the versions of the GTK library in use.
See \helpref{wxPlatformInfo}{wxplatforminfo} for more details.
\membersection{wxAppTraits::HasStderr}\label{wxapptraitshasstderr}
\func{virtual bool}{HasStderr}{\void}
@ -58,6 +97,13 @@ See \helpref{wxPlatformInfo}{wxplatforminfo} for more details.
Returns \true if {\tt fprintf(stderr)} goes somewhere, \false otherwise.
\membersection{wxAppTraits::IsUsingUniversalWidgets}\label{wxapptraitsisusinguniversalwidgets}
\constfunc{bool}{IsUsingUniversalWidgets}{\void}
Returns \true if the library was built as wxUniversal. Always returns
\false for wxBase-only apps.
\membersection{wxAppTraits::ShowAssertDialog}\label{wxapptraitsshowassertdialog}
@ -67,50 +113,3 @@ Shows the assert dialog with the specified message in GUI mode or just prints
the string to stderr in console mode.
Returns \true to suppress subsequent asserts, \false to continue as before.
\membersection{wxAppTraits::GetStandardPaths}\label{wxapptraitsgetstandardpaths}
\func{virtual wxStandardPaths \&}{GetStandardPaths}{\void}
Returns the wxStandardPaths object for the application.
It's normally the same for wxBase and wxGUI except in the case of wxMac and wxCocoa.
\membersection{wxAppTraits::CreateRenderer}\label{wxapptraitscreaterenderer}
\func{virtual wxRendererNative *}{CreateRenderer}{\void}
Returns the renderer to use for drawing the generic controls (return value may be \NULL
in which case the default renderer for the current platform is used);
this is used in GUI mode only and always returns \NULL in console.
NOTE: returned pointer will be deleted by the caller.
\membersection{wxAppTraits::CreateLogTarget}\label{wxapptraitscreatelogtarget}
\func{virtual wxLog *}{CreateLogTarget}{\void}
Creates the default log target for the application.
\membersection{wxAppTraits::CreateMessageOutput}\label{wxapptraitscreatemessageoutput}
\func{virtual wxMessageOutput *}{CreateMessageOutput}{\void}
Creates the global object used for printing out messages.
\membersection{wxAppTraits::CreateFontMapper}\label{wxapptraitscreatefontmapper}
\func{virtual wxFontMapper *}{CreateFontMapper}{\void}
Creates the global font mapper object used for encodings/charset mapping.

View File

@ -271,10 +271,13 @@ Returns the wxWidgets port ID associated with this wxPlatformInfo instance.
\membersection{wxPlatformInfo::GetPortIdName}\label{wxplatforminfogetportidname}
\func{static wxString}{GetPortIdName}{\param{wxPortId }{port}}
\func{static wxString}{GetPortIdName}{\param{wxPortId }{port}, \param{bool }{usingUniversal}}
Returns the name of the given wxWidgets port ID value. The returned string always starts with
the "wx" prefix and is a mixed-case string.
Returns the name of the given wxWidgets port ID value. The \arg{usingUniversal}
argument specifies whether the port is in its native or wxUniversal variant.
The returned string always starts with the "wx" prefix and is a mixed-case
string.
\constfunc{wxString}{GetPortIdName}{\void}
@ -285,10 +288,14 @@ Returns the name of the wxWidgets port ID associated with this wxPlatformInfo in
\membersection{wxPlatformInfo::GetPortIdShortName}\label{wxplatforminfogetportidshortname}
\func{static wxString}{GetPortIdShortName}{\param{wxPortId }{port}}
\func{static wxString}{GetPortIdShortName}{\param{wxPortId }{port}, \param{bool }{usingUniversal}}
Returns the short name of the given wxWidgets port ID value. The returned string does not start with
the "wx" prefix and is always lower case.
Returns the short name of the given wxWidgets port ID value. The
\arg{usingUniversal} argument specifies whether the port is in its native or
wxUniversal variant.
The returned string does not start with the "wx" prefix and is always lower
case.
\constfunc{wxString}{GetPortIdShortName}{\void}
@ -324,10 +331,9 @@ Returns \true if this instance is fully initialized with valid values.
\membersection{wxPlatformInfo::IsUsingUniversalWidgets}\label{wxplatforminfoisusinguniversalwidgets}
\func{bool}{IsUsingUniversalWidgets}{\void}
\constfunc{bool}{IsUsingUniversalWidgets}{\void}
Returns \true if \_\_WXUNIVERSAL\_\_ symbol is defined. Note that this function always
returns a constant value defined at compile-time and exists just for completeness.
Returns \true if this wxPlatformInfo describes wxUniversal build.
\membersection{wxPlatformInfo::SetArchitecture}\label{wxplatforminfosetarchitecture}

View File

@ -114,6 +114,9 @@ public:
// returns wxPORT_BASE for console applications and one of the remaining
// wxPORT_* values for GUI applications.
virtual wxPortId GetToolkitVersion(int *majVer, int *minVer) const = 0;
// return true if the port is using wxUniversal for the GUI, false if not
virtual bool IsUsingUniversalWidgets() const = 0;
};
// ----------------------------------------------------------------------------
@ -172,7 +175,7 @@ public:
virtual void RemoveFromPendingDelete(wxObject *object);
// the GetToolkitVersion for console application is always the same
wxPortId GetToolkitVersion(int *verMaj, int *verMin) const
virtual wxPortId GetToolkitVersion(int *verMaj, int *verMin) const
{
// no toolkits (wxBase is for console applications without GUI support)
// NB: zero means "no toolkit", -1 means "not initialized yet"
@ -181,6 +184,8 @@ public:
if (verMin) *verMin = 0;
return wxPORT_BASE;
}
virtual bool IsUsingUniversalWidgets() const { return false; }
};
// ----------------------------------------------------------------------------
@ -211,6 +216,15 @@ public:
virtual void ScheduleForDestroy(wxObject *object);
virtual void RemoveFromPendingDelete(wxObject *object);
virtual bool IsUsingUniversalWidgets() const
{
#ifdef __WXUNIVERSAL__
return true;
#else
return false;
#endif
}
};
#endif // wxUSE_GUI

View File

@ -118,7 +118,8 @@ public:
wxOperatingSystemId id = wxOS_UNKNOWN,
int osMajor = -1, int osMinor = -1,
wxArchitecture arch = wxARCH_INVALID,
wxEndianness endian = wxENDIAN_INVALID);
wxEndianness endian = wxENDIAN_INVALID,
bool usingUniversal = false);
// default copy ctor, assignment operator and dtor are ok
@ -142,8 +143,8 @@ public:
static wxString GetOperatingSystemFamilyName(wxOperatingSystemId os);
static wxString GetOperatingSystemIdName(wxOperatingSystemId os);
static wxString GetPortIdName(wxPortId port);
static wxString GetPortIdShortName(wxPortId port);
static wxString GetPortIdName(wxPortId port, bool usingUniversal);
static wxString GetPortIdShortName(wxPortId port, bool usingUniversal);
static wxString GetArchName(wxArchitecture arch);
static wxString GetEndiannessName(wxEndianness end);
@ -161,6 +162,9 @@ public:
int GetToolkitMinorVersion() const
{ return m_tkVersionMinor; }
bool IsUsingUniversalWidgets() const
{ return m_usingUniversal; }
wxOperatingSystemId GetOperatingSystemId() const
{ return m_os; }
wxPortId GetPortId() const
@ -179,9 +183,9 @@ public:
wxString GetOperatingSystemIdName() const
{ return GetOperatingSystemIdName(m_os); }
wxString GetPortIdName() const
{ return GetPortIdName(m_port); }
{ return GetPortIdName(m_port, m_usingUniversal); }
wxString GetPortIdShortName() const
{ return GetPortIdShortName(m_port); }
{ return GetPortIdShortName(m_port, m_usingUniversal); }
wxString GetArchName() const
{ return GetArchName(m_arch); }
wxString GetEndiannessName() const
@ -216,15 +220,6 @@ public:
m_arch != wxARCH_INVALID && m_endian != wxENDIAN_INVALID;
}
static bool IsUsingUniversalWidgets()
{
#ifdef __WXUNIVERSAL__
return true;
#else
return false;
#endif
}
protected:
// OS stuff
@ -248,6 +243,9 @@ protected:
// name of the wxWidgets port
wxPortId m_port;
// is using wxUniversal widgets?
bool m_usingUniversal;
// others
// -----------------

View File

@ -123,12 +123,14 @@ wxPlatformInfo::wxPlatformInfo()
wxFAIL_MSG( _T("failed to initialize wxPlatformInfo") );
m_port = wxPORT_UNKNOWN;
m_usingUniversal = false;
m_tkVersionMajor =
m_tkVersionMinor = 0;
}
else
{
m_port = traits->GetToolkitVersion(&m_tkVersionMajor, &m_tkVersionMinor);
m_usingUniversal = traits->IsUsingUniversalWidgets();
}
m_os = wxGetOsVersion(&m_osVersionMajor, &m_osVersionMinor);
@ -139,11 +141,13 @@ wxPlatformInfo::wxPlatformInfo()
wxPlatformInfo::wxPlatformInfo(wxPortId pid, int tkMajor, int tkMinor,
wxOperatingSystemId id, int osMajor, int osMinor,
wxArchitecture arch,
wxEndianness endian)
wxEndianness endian,
bool usingUniversal)
{
m_tkVersionMajor = tkMajor;
m_tkVersionMinor = tkMinor;
m_port = pid;
m_usingUniversal = usingUniversal;
m_os = id;
m_osVersionMajor = osMajor;
@ -161,6 +165,7 @@ bool wxPlatformInfo::operator==(const wxPlatformInfo &t) const
m_osVersionMinor == t.m_osVersionMinor &&
m_os == t.m_os &&
m_port == t.m_port &&
m_usingUniversal == t.m_usingUniversal &&
m_arch == t.m_arch &&
m_endian == t.m_endian;
}
@ -195,7 +200,7 @@ wxString wxPlatformInfo::GetOperatingSystemIdName(wxOperatingSystemId os)
return wxOperatingSystemIdNames[idx];
}
wxString wxPlatformInfo::GetPortIdName(wxPortId port)
wxString wxPlatformInfo::GetPortIdName(wxPortId port, bool usingUniversal)
{
const unsigned idx = wxGetIndexFromEnumValue(port);
@ -204,13 +209,13 @@ wxString wxPlatformInfo::GetPortIdName(wxPortId port)
wxString ret = wxPortIdNames[idx];
if ( IsUsingUniversalWidgets() )
if ( usingUniversal )
ret += wxT("/wxUniversal");
return ret;
}
wxString wxPlatformInfo::GetPortIdShortName(wxPortId port)
wxString wxPlatformInfo::GetPortIdShortName(wxPortId port, bool usingUniversal)
{
const unsigned idx = wxGetIndexFromEnumValue(port);
@ -220,7 +225,7 @@ wxString wxPlatformInfo::GetPortIdShortName(wxPortId port)
wxString ret = wxPortIdNames[idx];
ret = ret.Mid(2).Lower(); // remove 'wx' prefix
if ( IsUsingUniversalWidgets() )
if ( usingUniversal )
ret += wxT("univ");
return ret;
@ -267,7 +272,8 @@ wxPortId wxPlatformInfo::GetPortId(const wxString &str)
if ( wxPortIdNames[i].CmpNoCase(str) == 0 )
return current;
if ( GetPortIdShortName(current).CmpNoCase(str) == 0 )
if ( GetPortIdShortName(current, true).CmpNoCase(str) == 0 ||
GetPortIdShortName(current, false).CmpNoCase(str) == 0 )
return current;
}