-#ifdef __WXMOTIF__
- // FIXME TODO
- // This code is WRONG!! Does NOT return the
- // Motif version of the libs but the X protocol
- // version!
- Display *display = XtDisplay ((Widget) wxTheApp->GetTopLevelWidget());
- if (majorVsn)
- *majorVsn = ProtocolVersion (display);
- if (minorVsn)
- *minorVsn = ProtocolRevision (display);
-
- return wxMOTIF_X;
-#endif
-#ifdef __WXX11__
- if (majorVsn)
- *majorVsn = 0;
- if (minorVsn)
- *minorVsn = 0;
- return wxX11;
-#endif
-}
-
-// ----------------------------------------------------------------------------
-// Reading and writing resources (eg WIN.INI, .Xdefaults)
-// ----------------------------------------------------------------------------
-
-// Read $HOME for what it says is home, if not
-// read $USER or $LOGNAME for user name else determine
-// the Real User, then determine the Real home dir.
-static char * GetIniFile (char *dest, const char *filename)
-{
- char *home = NULL;
- if (filename && wxIsAbsolutePath(filename))
- {
- strcpy(dest, filename);
- }
- else if ((home = wxGetUserHome("")) != NULL)
- {
- strcpy(dest, home);
- if (dest[strlen(dest) - 1] != '/')
- strcat (dest, "/");
- if (filename == NULL)
- {
- if ((filename = getenv ("XENVIRONMENT")) == NULL)
- filename = ".Xdefaults";
- }
- else if (*filename != '.')
- strcat (dest, ".");
- strcat (dest, filename);
- } else
- {
- dest[0] = '\0';
- }
- return dest;
-}
-
-#if wxUSE_RESOURCES
-
-static char *GetResourcePath(char *buf, const char *name, bool create = FALSE)
-{
- if (create && wxFileExists (name) ) {
- strcpy(buf, name);
- return buf; // Exists so ...
- }
-
- if (*name == '/')
- strcpy(buf, name);
- else {
- // Put in standard place for resource files if not absolute
- strcpy (buf, DEFAULT_XRESOURCE_DIR);
- strcat (buf, "/");
- strcat (buf, (const char*) wxFileNameFromPath (name));
- }
-
- if (create) {
- // Touch the file to create it
- FILE *fd = fopen (buf, "w");
- if (fd) fclose (fd);
- }
- return buf;
-}
-
-/*
-* We have a cache for writing different resource files,
-* which will only get flushed when we call wxFlushResources().
-* Build up a list of resource databases waiting to be written.
-*
-*/
-
-wxList wxResourceCache (wxKEY_STRING);
-
-void
-wxFlushResources (void)
-{
- char nameBuffer[512];
-
- wxNode *node = wxResourceCache.First ();
- while (node)
- {
- const char *file = node->GetKeyString();
- // If file doesn't exist, create it first.
- (void)GetResourcePath(nameBuffer, file, TRUE);
-
- XrmDatabase database = (XrmDatabase) node->Data ();
- XrmPutFileDatabase (database, nameBuffer);
- XrmDestroyDatabase (database);
- wxNode *next = node->Next ();
- delete node;
- node = next;
- }
-}
-
-static XrmDatabase wxResourceDatabase = 0;
-
-void wxXMergeDatabases (wxApp * theApp, Display * display);
-
-bool wxWriteResource(const wxString& section, const wxString& entry, const wxString& value, const wxString& file)
-{
- char buffer[500];
-
- (void) GetIniFile (buffer, file);
-
- XrmDatabase database;
- wxNode *node = wxResourceCache.Find (buffer);
- if (node)
- database = (XrmDatabase) node->Data ();
- else
- {
- database = XrmGetFileDatabase (buffer);
- wxResourceCache.Append (buffer, (wxObject *) database);
- }
-
- char resName[300];
- strcpy (resName, (const char*) section);
- strcat (resName, ".");
- strcat (resName, (const char*) entry);
-
- XrmPutStringResource (&database, resName, value);
- return TRUE;
-}
-
-bool wxWriteResource(const wxString& section, const wxString& entry, float value, const wxString& file)
-{
- char buf[50];
- sprintf(buf, "%.4f", value);
- return wxWriteResource(section, entry, buf, file);
-}
-
-bool wxWriteResource(const wxString& section, const wxString& entry, long value, const wxString& file)
-{
- char buf[50];
- sprintf(buf, "%ld", value);
- return wxWriteResource(section, entry, buf, file);
-}
-
-bool wxWriteResource(const wxString& section, const wxString& entry, int value, const wxString& file)
-{
- char buf[50];
- sprintf(buf, "%d", value);
- return wxWriteResource(section, entry, buf, file);
-}
-
-bool wxGetResource(const wxString& section, const wxString& entry, char **value, const wxString& file)
-{
- if (!wxResourceDatabase)
- {
- Display *display = (Display*) wxGetDisplay();
- wxXMergeDatabases (wxTheApp, display);