From 3e2d47e1a96977aa31c8af18f96e9363000f3ca5 Mon Sep 17 00:00:00 2001 From: Mattia Barbon Date: Mon, 10 Mar 2003 21:40:53 +0000 Subject: [PATCH] Added helper functions for string -> XmString conversion. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@19539 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- include/wx/motif/private.h | 6 ++++-- src/motif/utils.cpp | 23 ++++++++++++++++------- 2 files changed, 20 insertions(+), 9 deletions(-) diff --git a/include/wx/motif/private.h b/include/wx/motif/private.h index f070db4763..f93dc7b81e 100644 --- a/include/wx/motif/private.h +++ b/include/wx/motif/private.h @@ -94,6 +94,10 @@ extern XColor itemColors[5] ; // utility classes // ---------------------------------------------------------------------------- +wxString wxXmStringToString( const XmString& xmString ); +XmString wxStringToXmString( const wxString& string ); +XmString wxStringToXmString( const char* string ); + // XmString made easy to use in wxWindows (and has an added benefit of // cleaning up automatically) class wxXmString @@ -123,8 +127,6 @@ private: XmString m_string; }; -wxString wxXmStringToString( const XmString& xmString ); - // ---------------------------------------------------------------------------- // Routines used in both wxTextCtrl/wxListBox and nativa wxComboBox // (defined in src/motif/listbox.cpp or src/motif/textctrl.cpp diff --git a/src/motif/utils.cpp b/src/motif/utils.cpp index 4048d5a723..fcb590abba 100644 --- a/src/motif/utils.cpp +++ b/src/motif/utils.cpp @@ -273,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) { @@ -335,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; @@ -481,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); @@ -674,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, @@ -1283,3 +1283,12 @@ wxString wxXmStringToString( const XmString& xmString ) 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); +} -- 2.45.2