From: Václav Slavík Date: Wed, 16 Aug 2006 17:18:34 +0000 (+0000) Subject: wxPlatformInfo::IsUsingUniversalWidgets() was broken by design, it couldn't work... X-Git-Url: https://git.saurik.com/wxWidgets.git/commitdiff_plain/b98bd6af23c1c73eb2cddf14da18455e5668de6d?hp=e74f9041c4a598156b761cd19ad1c4ddc8e9a513 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 --- diff --git a/docs/latex/wx/apptraits.tex b/docs/latex/wx/apptraits.tex index 9e97999a28..16f40d2250 100644 --- a/docs/latex/wx/apptraits.tex +++ b/docs/latex/wx/apptraits.tex @@ -36,38 +36,37 @@ None \latexignore{\rtfignore{\wxheading{Members}}} -\membersection{wxAppTraits::GetToolkitVersion}\label{wxapptraitsgettoolkitversion} +\membersection{wxAppTraits::CreateFontMapper}\label{wxapptraitscreatefontmapper} -\func{virtual wxPortId}{GetToolkitVersion}{\param{int *}{major = NULL}, \param{int *}{minor = NULL}} +\func{virtual wxFontMapper *}{CreateFontMapper}{\void} -Returns the wxWidgets port ID used by the running program and eventually -fills the given pointers with the values of the major and minor digits -of the native toolkit currently used. +Creates the global font mapper object used for encodings/charset mapping. -E.g. if your program is using wxGTK port this function will return wxPORT_GTK and -put in given pointers the versions of the GTK library in use. -See \helpref{wxPlatformInfo}{wxplatforminfo} for more details. +\membersection{wxAppTraits::CreateLogTarget}\label{wxapptraitscreatelogtarget} +\func{virtual wxLog *}{CreateLogTarget}{\void} -\membersection{wxAppTraits::HasStderr}\label{wxapptraitshasstderr} +Creates the default log target for the application. -\func{virtual bool}{HasStderr}{\void} -Returns \true if {\tt fprintf(stderr)} goes somewhere, \false otherwise. +\membersection{wxAppTraits::CreateMessageOutput}\label{wxapptraitscreatemessageoutput} +\func{virtual wxMessageOutput *}{CreateMessageOutput}{\void} +Creates the global object used for printing out messages. -\membersection{wxAppTraits::ShowAssertDialog}\label{wxapptraitsshowassertdialog} -\func{virtual bool}{ShowAssertDialog}{\param{const wxString \&}{ msg}} +\membersection{wxAppTraits::CreateRenderer}\label{wxapptraitscreaterenderer} -Shows the assert dialog with the specified message in GUI mode or just prints -the string to stderr in console mode. +\func{virtual wxRendererNative *}{CreateRenderer}{\void} -Returns \true to suppress subsequent asserts, \false to continue as before. +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} @@ -77,40 +76,40 @@ Returns \true to suppress subsequent asserts, \false to continue as before. 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}} -\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. - - +Returns the wxWidgets port ID used by the running program and eventually +fills the given pointers with the values of the major and minor digits +of the native toolkit currently used. -\membersection{wxAppTraits::CreateLogTarget}\label{wxapptraitscreatelogtarget} +E.g. if your program is using wxGTK port this function will return wxPORT_GTK and +put in given pointers the versions of the GTK library in use. -\func{virtual wxLog *}{CreateLogTarget}{\void} +See \helpref{wxPlatformInfo}{wxplatforminfo} for more details. -Creates the default log target for the application. +\membersection{wxAppTraits::HasStderr}\label{wxapptraitshasstderr} +\func{virtual bool}{HasStderr}{\void} -\membersection{wxAppTraits::CreateMessageOutput}\label{wxapptraitscreatemessageoutput} +Returns \true if {\tt fprintf(stderr)} goes somewhere, \false otherwise. -\func{virtual wxMessageOutput *}{CreateMessageOutput}{\void} -Creates the global object used for printing out messages. +\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::CreateFontMapper}\label{wxapptraitscreatefontmapper} -\func{virtual wxFontMapper *}{CreateFontMapper}{\void} +\membersection{wxAppTraits::ShowAssertDialog}\label{wxapptraitsshowassertdialog} -Creates the global font mapper object used for encodings/charset mapping. +\func{virtual bool}{ShowAssertDialog}{\param{const wxString \&}{ msg}} +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. diff --git a/docs/latex/wx/platinfo.tex b/docs/latex/wx/platinfo.tex index 60d5c2a69d..1d0e09a74d 100644 --- a/docs/latex/wx/platinfo.tex +++ b/docs/latex/wx/platinfo.tex @@ -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 +\arg{usingUniversal} argument specifies whether the port is in its native or +wxUniversal variant. -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. +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} diff --git a/include/wx/apptrait.h b/include/wx/apptrait.h index 12d9dba4ac..ec59d03414 100644 --- a/include/wx/apptrait.h +++ b/include/wx/apptrait.h @@ -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 diff --git a/include/wx/platinfo.h b/include/wx/platinfo.h index 913a08d182..c5f8a6cf81 100644 --- a/include/wx/platinfo.h +++ b/include/wx/platinfo.h @@ -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 // ----------------- diff --git a/src/common/platinfo.cpp b/src/common/platinfo.cpp index 0987ab0b12..b8ee8fcc1c 100644 --- a/src/common/platinfo.cpp +++ b/src/common/platinfo.cpp @@ -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; }