};
#endif // wxUSE_GUI
+
// ----------------------------------------------------------------------------
// wxAppConsole: wxApp for non-GUI applications
// ----------------------------------------------------------------------------
#ifndef _WX_APPTRAIT_H_
#define _WX_APPTRAIT_H_
-class WXDLLEXPORT wxObject;
+#include "wx/string.h"
+
+class WXDLLIMPEXP_BASE wxObject;
class WXDLLEXPORT wxAppTraits;
#if wxUSE_FONTMAP
class WXDLLEXPORT wxFontMapper;
#endif // wxUSE_FONTMAP
-class WXDLLEXPORT wxLog;
-class WXDLLEXPORT wxMessageOutput;
+class WXDLLIMPEXP_BASE wxLog;
+class WXDLLIMPEXP_BASE wxMessageOutput;
class WXDLLEXPORT wxRendererNative;
-class WXDLLEXPORT wxString;
+class WXDLLIMPEXP_BASE wxString;
+struct WXDLLIMPEXP_BASE wxToolkitInfo;
+
+// ----------------------------------------------------------------------------
+// toolkit information
+// ----------------------------------------------------------------------------
+
+// Information about the toolkit that the app is running under (e.g. wxMSW):
+struct WXDLLIMPEXP_BASE wxToolkitInfo
+{
+ // Short name of the toolkit (e.g. "msw" or "mswuniv"); empty for console:
+ wxString shortName;
+ // Descriptive name of the toolkit, human readable (e.g. "wxMSW" or
+ // "wxMSW/Universal"); "wxBase" for console apps:
+ wxString name;
+ // Version of the underlying toolkit or of the OS for console apps:
+ int versionMajor, versionMinor;
+ // OS mnenomics, e.g. wxGTK or wxMSW:
+ int os;
+};
+
// ----------------------------------------------------------------------------
// wxAppTraits: this class defines various configurable aspects of wxApp
virtual void RemoveFromPendingDelete(wxObject *object) = 0;
- // other miscellaneous helpers
- // ---------------------------
-
- // wxGetOsVersion() behaves differently in GUI and non-GUI builds under
- // Unix: in the former case it returns the information about the toolkit
- // and in the latter -- about the OS, so we need to virtualize it
- virtual int GetOSVersion(int *verMaj, int *verMin) = 0;
+ // return information about what toolkit is running; we need for two things
+ // that are both contained in wxBase:
+ // - wxGetOsVersion() behaves differently in GUI and non-GUI builds under
+ // Unix: in the former case it returns the information about the toolkit
+ // and in the latter -- about the OS, so we need to virtualize it
+ // - wxDynamicLibrary::CanonicalizePluginName() must embed toolkit
+ // signature in DLL name
+ virtual wxToolkitInfo *GetToolkitInfo() = 0;
};
// ----------------------------------------------------------------------------
// other miscellaneous helpers
// ---------------------------
- virtual int GetOSVersion(int *verMaj, int *verMin);
+ virtual wxToolkitInfo *GetToolkitInfo();
};
#if wxUSE_GUI
// other miscellaneous helpers
// ---------------------------
- virtual int GetOSVersion(int *verMaj, int *verMin);
+ virtual wxToolkitInfo *GetToolkitInfo();
};
#endif // wxUSE_GUI
// other miscellaneous helpers
// ---------------------------
- // under MSW this function does the same thing for console and GUI
- // applications so we can implement it directly in the base class
- virtual int GetOSVersion(int *verMaj, int *verMin);
+ // under MSW this function returns same version for both console and GUI
+ // applications so we can implement it directly in the base class and only
+ // override it wxGUIAppTraits to fill in toolkit information
+ virtual wxToolkitInfo *GetToolkitInfo();
};
#endif // _WX_MSW_APPTBASE_H_
virtual void AfterChildWaitLoop(void *data);
virtual bool DoMessageFromThreadWait();
+ virtual wxToolkitInfo *GetToolkitInfo();
};
#endif // wxUSE_GUI
virtual void DetachWriteFDOfEndProcessPipe(wxExecuteData& execData);
virtual int WaitForChild(wxExecuteData& execData);
- virtual int GetOSVersion(int *verMaj, int *verMin);
+ virtual wxToolkitInfo *GetToolkitInfo();
};
#if wxUSE_GUI
virtual void DetachWriteFDOfEndProcessPipe(wxExecuteData& execData);
virtual int WaitForChild(wxExecuteData& execData);
- virtual int GetOSVersion(int *verMaj, int *verMin);
+ virtual wxToolkitInfo *GetToolkitInfo();
};
#endif // wxUSE_GUI
#include "wx/log.h"
#include "wx/utils.h"
#include "wx/filename.h" // for SplitPath()
+#include "wx/app.h"
+#include "wx/apptrait.h"
#if defined(__WXMAC__)
#include "wx/mac/private.h"
wxString suffix;
if ( cat == wxDL_PLUGIN_GUI )
{
- suffix = wxString::FromAscii(
-#if defined(__WXMSW__)
- "msw"
-#elif defined(__WXGTK__)
- "gtk"
-#elif defined(__WXMGL__)
- "mgl"
-#elif defined(__WXMOTIF__)
- "motif"
-#elif defined(__WXOS2__)
- "pm"
-#elif defined(__WXX11__)
- "x11"
-#elif defined(__WXMAC__)
- "mac"
-#elif defined(__WXCOCOA__)
- "cocoa"
-#else // FIXME - wrong!
- ""
-#endif
- );
-
-#ifdef __WXUNIVERSAL__
- suffix << _T("univ");
-#endif
+ wxAppTraits *traits = wxAppConsole::GetInstance() ?
+ wxAppConsole::GetInstance()->GetTraits() : NULL;
+ wxASSERT_MSG( traits,
+ _("can't query for GUI plugins name in console applications") );
+ suffix = traits->GetToolkitInfo()->shortName;
}
#if wxUSE_UNICODE
suffix << _T('u');
if ( ! traits )
traits = &traitsConsole;
- return traits->GetOSVersion(verMaj, verMin);
+ wxToolkitInfo *info = traits->GetToolkitInfo();
+ if ( verMaj )
+ *verMaj = info->versionMajor;
+ if ( verMin )
+ *verMin = info->versionMinor;
+ return info->os;
}
// ----------------------------------------------------------------------------
return gdk_window_get_visual( wxGetRootWindow()->window )->depth;
}
-int wxGUIAppTraits::GetOSVersion(int *majorVsn, int *minorVsn)
+wxToolkitInfo *wxGUIAppTraits::GetToolkitInfo()
{
- if (majorVsn)
- *majorVsn = GTK_MAJOR_VERSION;
- if (minorVsn)
- *minorVsn = GTK_MINOR_VERSION;
-
- return wxGTK;
+ static wxToolkitInfo info;
+#ifdef __WXGTK20__
+ info.shortName = _T("gtk2");
+#else
+ info.shortName = _T("gtk");
+#endif
+ info.name = _T("wxGTK");
+#ifdef __WXUNIVERSAL__
+ info.shortName << _T("univ");
+ info.name << _T("/wxUniversal");
+#endif
+ info.versionMajor = GTK_MAJOR_VERSION;
+ info.versionMinor = GTK_MINOR_VERSION;
+ info.os = wxGTK;
+ return &info;
}
wxWindow* wxFindWindowAtPoint(const wxPoint& pt)
return gdk_window_get_visual( wxGetRootWindow()->window )->depth;
}
-int wxGUIAppTraits::GetOSVersion(int *majorVsn, int *minorVsn)
+wxToolkitInfo *wxGUIAppTraits::GetToolkitInfo()
{
- if (majorVsn)
- *majorVsn = GTK_MAJOR_VERSION;
- if (minorVsn)
- *minorVsn = GTK_MINOR_VERSION;
-
- return wxGTK;
+ static wxToolkitInfo info;
+#ifdef __WXGTK20__
+ info.shortName = _T("gtk2");
+#else
+ info.shortName = _T("gtk");
+#endif
+ info.name = _T("wxGTK");
+#ifdef __WXUNIVERSAL__
+ info.shortName << _T("univ");
+ info.name << _T("/wxUniversal");
+#endif
+ info.versionMajor = GTK_MAJOR_VERSION;
+ info.versionMinor = GTK_MINOR_VERSION;
+ info.os = wxGTK;
+ return &info;
}
wxWindow* wxFindWindowAtPoint(const wxPoint& pt)
#endif
}
-int wxConsoleAppTraits::GetOSVersion(int *majorVsn, int *minorVsn)
+wxToolkitInfo *wxConsoleAppTraits::GetToolkitInfo()
{
- return DoGetOSVersion(majorVsn, minorVsn);
+ static wxToolkitInfo info;
+ info.os = DoGetOSVersion(&info.majorVersion, &info.minorVersion);
+ info.name = _T("wxBase");
+ return &info;
}
#endif // wxUSE_BASE
#if wxUSE_GUI
-int wxGUIAppTraits::GetOSVersion(int *majorVsn, int *minorVsn)
+wxToolkitInfo *wxGUIAppTraits::GetToolkitInfo()
{
- return DoGetOSVersion(majorVsn, minorVsn);
+ static wxToolkitInfo info;
+ info.os = DoGetOSVersion(&info.majorVersion, &info.minorVersion);
+ info.shortName = _T("mac");
+ info.name = _T("wxMac");
+#ifdef __WXUNIVERSAL__
+ info.shortName << _T("univ");
+ info.name << _T("/wxUniversal");
+#endif
+ return &info;
}
// Reading and writing resources (eg WIN.INI, .Xdefaults)
#endif
}
-int wxConsoleAppTraits::GetOSVersion(int *majorVsn, int *minorVsn)
+wxToolkitInfo *wxConsoleAppTraits::GetToolkitInfo()
{
- return DoGetOSVersion(majorVsn, minorVsn);
+ static wxToolkitInfo info;
+ info.os = DoGetOSVersion(&info.majorVersion, &info.minorVersion);
+ info.name = _T("wxBase");
+ return &info;
}
#endif // wxUSE_BASE
#if wxUSE_GUI
-int wxGUIAppTraits::GetOSVersion(int *majorVsn, int *minorVsn)
+wxToolkitInfo *wxGUIAppTraits::GetToolkitInfo()
{
- return DoGetOSVersion(majorVsn, minorVsn);
+ static wxToolkitInfo info;
+ info.os = DoGetOSVersion(&info.majorVersion, &info.minorVersion);
+ info.shortName = _T("mac");
+ info.name = _T("wxMac");
+#ifdef __WXUNIVERSAL__
+ info.shortName << _T("univ");
+ info.name << _T("/wxUniversal");
+#endif
+ return &info;
}
// Reading and writing resources (eg WIN.INI, .Xdefaults)
XBell (wxGlobalDisplay(), 0);
}
-int wxGUIAppTraits::GetOSVersion(int *majorVsn, int *minorVsn)
+wxToolkitInfo *wxGUIAppTraits::GetToolkitInfo()
{
+ wxToolkitInfo info;
+ info.shortName = _T("motif");
+ info.name = _T("wxMotif");
+#ifdef __WXUNIVERSAL__
+ info.shortName << _T("univ");
+ info.name << _T("/wxUniversal");
+#endif
// FIXME TODO
// This code is WRONG!! Does NOT return the
// Motif version of the libs but the X protocol
// version!
Display *display = wxGlobalDisplay();
- if (majorVsn)
- *majorVsn = ProtocolVersion (display);
- if (minorVsn)
- *minorVsn = ProtocolRevision (display);
-
- return wxMOTIF_X;
+ info.versionMajor = ProtocolVersion (display);
+ info.versionMinor = ProtocolRevision (display);
+ info.os = wxMOTIF_X;
+ return &info;
}
// ----------------------------------------------------------------------------
return !wxTheApp || wxTheApp->DoMessage();
}
+wxToolkitInfo *wxGUIAppTraits::GetToolkitInfo()
+{
+ static wxToolkitInfo info;
+ wxToolkitInfo *baseInfo = wxAppTraits::GetToolkitInfo();
+ info.versionMajor = baseInfo->versionMajor;
+ info.versionMinor = baseInfo->versionMinor;
+ info.os = baseInfo->os;
+ info.shortName = _T("msw");
+ info.name = _T("wxMSW");
+#ifdef __WXUNIVERSAL__
+ info.shortName << _T("univ");
+ info.name << _T("/wxUniversal");
+#endif
+ return &info;
+}
+
// ===========================================================================
// wxApp implementation
// ===========================================================================
#endif // Win32/16
}
-int wxAppTraits::GetOSVersion(int *verMaj, int *verMin)
+wxToolkitInfo *wxAppTraits::GetToolkitInfo()
{
// cache the version info, it's not going to change
//
}
}
- if ( verMaj )
- *verMaj = s_major;
- if ( verMin )
- *verMin = s_minor;
-
- return s_ver;
+ static wxToolkitInfo info;
+ info.versionMajor = s_major;
+ info.versionMinor = s_minor;
+ info.os = s_ver;
+ info.name = _T("wxBase");
+ return &info;
}
// ----------------------------------------------------------------------------
// this is in mac/utils.cpp under Mac
#ifndef __WXMAC__
-int wxConsoleAppTraits::GetOSVersion(int *verMaj, int *verMin)
+wxToolkitInfo *wxConsoleAppTraits::GetToolkitInfo()
{
+ static wxToolkitInfo info;
int major, minor;
char name[256];
minor = -1;
}
- if ( verMaj )
- *verMaj = major;
- if ( verMin )
- *verMin = minor;
+ info.versionMajor = major;
+ info.versionMinor = minor;
+ info.name = _T("wxBase");
+ info.os = wxUNIX;
- return wxUNIX;
+ return &info;
}
#endif // __WXMAC__
#endif /* __GSOCKET_STANDALONE__ */
/* redefine some GUI-only functions to do nothing in console mode */
-#if defined(wxUSE_GUI) && !wxUSE_GUI
+#if 1 //defined(wxUSE_GUI) && !wxUSE_GUI
+ // FIXME -- temporary measure
# define _GSocket_GUI_Init(socket) (1)
# define _GSocket_GUI_Destroy(socket)
# define _GSocket_Enable_Events(socket)
XBell ((Display*) wxGetDisplay(), 0);
}
-int wxGUIAppTraits::GetOSVersion(int *majorVsn, int *minorVsn)
+wxToolkitInfo *wxGUIAppTraits::GetToolkitInfo()
{
- if (majorVsn)
- *majorVsn = 0;
-
- if (minorVsn)
- *minorVsn = 0;
-
- return wxX11;
+ static wxToolkitInfo info;
+ info.shortName = _T("x11univ");
+ info.name = _T("wxX11");
+ info.versionMajor = 0;
+ info.versionMinor = 0;
+ info.os = wxX11;
+ return &info;
}
// ----------------------------------------------------------------------------