]> git.saurik.com Git - wxWidgets.git/blobdiff - src/motif/utils.cpp
Applied patch [ 705663 ] Fix capture mouse bug in wxGrid
[wxWidgets.git] / src / motif / utils.cpp
index 179a3a43d630eed436a7752b6f847014070af82c..fcb590abbae9f7c64614654a2f02a7374786fb89 100644 (file)
@@ -81,7 +81,9 @@
     #define DEFAULT_XRESOURCE_DIR "/usr/lib/X11/app-defaults"
 #endif
 
+#if wxUSE_RESOURCES
 static char *GetIniFile (char *dest, const char *filename);
+#endif
 
 // ============================================================================
 // implementation
@@ -226,6 +228,8 @@ int wxGetOsVersion(int *majorVsn, int *minorVsn)
 // Reading and writing resources (eg WIN.INI, .Xdefaults)
 // ----------------------------------------------------------------------------
 
+#if wxUSE_RESOURCES
+
 // 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.
@@ -256,8 +260,6 @@ static char * GetIniFile (char *dest, const char *filename)
     return dest;
 }
 
-#if wxUSE_RESOURCES
-
 static char *GetResourcePath(char *buf, const char *name, bool create = FALSE)
 {
     if (create && wxFileExists (name) ) {
@@ -271,7 +273,7 @@ static char *GetResourcePath(char *buf, const char *name, bool create = FALSE)
         // Put in standard place for resource files if not absolute
         strcpy (buf, DEFAULT_XRESOURCE_DIR);
         strcat (buf, "/");
-        strcat (buf, (const char*) wxFileNameFromPath (name));
+        strcat (buf, wxFileNameFromPath (name).c_str());
     }
 
     if (create) {
@@ -333,9 +335,9 @@ bool wxWriteResource(const wxString& section, const wxString& entry, const wxStr
     }
 
     char resName[300];
-    strcpy (resName, (const char*) section);
+    strcpy (resName, section.c_str());
     strcat (resName, ".");
-    strcat (resName, (const char*) entry);
+    strcat (resName, entry.c_str());
 
     XrmPutStringResource (&database, resName, value);
     return TRUE;
@@ -479,7 +481,7 @@ void wxXMergeDatabases (wxApp * theApp, Display * display)
     wxString classname = theApp->GetClassName();
     char name[256];
     (void) strcpy (name, "/usr/lib/X11/app-defaults/");
-    (void) strcat (name, (const char*) classname);
+    (void) strcat (name, classname.c_str());
 
     /* Get application defaults file, if any */
     applicationDB = XrmGetFileDatabase (name);
@@ -672,9 +674,9 @@ bool wxSetDisplay(const wxString& display_name)
         Cardinal argc = 0;
 
         Display *display = XtOpenDisplay((XtAppContext) wxTheApp->GetAppContext(),
-            (const char*) display_name,
-            (const char*) wxTheApp->GetAppName(),
-            (const char*) wxTheApp->GetClassName(),
+            display_name.c_str(),
+            wxTheApp->GetAppName().c_str(),
+            wxTheApp->GetClassName().c_str(),
             NULL,
 #if XtSpecificationRelease < 5
             0, &argc,
@@ -1245,6 +1247,18 @@ void wxDoChangeBackgroundColour(WXWidget widget, wxColour& backgroundColour, boo
         NULL);
 }
 
+extern void wxDoChangeFont(WXWidget widget, wxFont& font)
+{
+    // Lesstif 0.87 hangs here, but 0.93 does not
+#if !wxCHECK_LESSTIF() || wxCHECK_LESSTIF_VERSION( 0, 93 )
+    Widget w = (Widget)widget;
+    XtVaSetValues( w,
+                   wxFont::GetFontTag(), font.GetFontType( XtDisplay(w) ),
+                   NULL );
+#endif
+
+}
+
 #endif
     // __WXMOTIF__
 
@@ -1255,3 +1269,26 @@ bool wxWindowIsVisible(Window win)
 
     return (wa.map_state == IsViewable);
 }
+
+wxString wxXmStringToString( const XmString& xmString )
+{
+    char *txt;
+    if( XmStringGetLtoR( xmString, XmSTRING_DEFAULT_CHARSET, &txt ) )
+    {
+        wxString str(txt);
+        XtFree (txt);
+        return str;
+    }
+
+    return wxEmptyString;
+}
+
+XmString wxStringToXmString( const wxString& str )
+{
+    return XmStringCreateLtoR((char *)str.c_str(), XmSTRING_DEFAULT_CHARSET);
+}
+
+XmString wxStringToXmString( const char* str )
+{
+    return XmStringCreateLtoR((char *)str, XmSTRING_DEFAULT_CHARSET);
+}