fixed wxMotif to compile in Unicode mode (this is not full Unicode support, all strings must be representable in current locale's charset, similarly to MSLU)

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@47623 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Václav Slavík
2007-07-21 16:43:31 +00:00
parent 3c1a167904
commit 6991087b08
21 changed files with 100 additions and 59 deletions

8
configure vendored
View File

@@ -1,5 +1,5 @@
#! /bin/sh #! /bin/sh
# From configure.in Id: configure.in 47617 2007-07-21 13:01:28Z VZ . # From configure.in Id: configure.in 47621 2007-07-21 13:09:57Z VZ .
# Guess values for system-dependent variables and create Makefiles. # Guess values for system-dependent variables and create Makefiles.
# Generated by GNU Autoconf 2.61 for wxWidgets 2.9.0. # Generated by GNU Autoconf 2.61 for wxWidgets 2.9.0.
# #
@@ -33755,12 +33755,6 @@ done
fi fi
if test "$wxUSE_MOTIF" = 1; then if test "$wxUSE_MOTIF" = 1; then
if test "$wxUSE_UNICODE" = "yes"; then
{ { echo "$as_me:$LINENO: error: Unicode configuration not supported with Motif" >&5
echo "$as_me: error: Unicode configuration not supported with Motif" >&2;}
{ (exit 1); exit 1; }; }
fi
{ echo "$as_me:$LINENO: checking for Motif/Lesstif headers" >&5 { echo "$as_me:$LINENO: checking for Motif/Lesstif headers" >&5
echo $ECHO_N "checking for Motif/Lesstif headers... $ECHO_C" >&6; } echo $ECHO_N "checking for Motif/Lesstif headers... $ECHO_C" >&6; }

View File

@@ -3077,10 +3077,6 @@ libraries returned by 'pkg-config gtk+-2.0 --libs' or 'gtk-config
fi fi
if test "$wxUSE_MOTIF" = 1; then if test "$wxUSE_MOTIF" = 1; then
if test "$wxUSE_UNICODE" = "yes"; then
AC_MSG_ERROR([Unicode configuration not supported with Motif])
fi
AC_MSG_CHECKING(for Motif/Lesstif headers) AC_MSG_CHECKING(for Motif/Lesstif headers)
WX_PATH_FIND_INCLUDES($SEARCH_INCLUDE, Xm/Xm.h) WX_PATH_FIND_INCLUDES($SEARCH_INCLUDE, Xm/Xm.h)
if test "$ac_find_includes" != "" ; then if test "$ac_find_includes" != "" ; then

View File

@@ -11,14 +11,6 @@
/* THIS IS A C FILE, DON'T USE C++ FEATURES (IN PARTICULAR COMMENTS) IN IT */ /* THIS IS A C FILE, DON'T USE C++ FEATURES (IN PARTICULAR COMMENTS) IN IT */
#if wxUSE_UNICODE
# ifdef wxABORT_ON_CONFIG_ERROR
# error "wxUSE_UNICODE is not supported with wxMotif"
# else
# define wxUSE_UNICODE 0
# endif
#endif
#if wxUSE_NOTEBOOK && !wxUSE_TAB_DIALOG #if wxUSE_NOTEBOOK && !wxUSE_TAB_DIALOG
# undef wxUSE_TAB_DIALOG # undef wxUSE_TAB_DIALOG
# define wxUSE_TAB_DIALOG 1 # define wxUSE_TAB_DIALOG 1

View File

@@ -128,8 +128,11 @@ extern XColor itemColors[5] ;
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
wxString wxXmStringToString( const XmString& xmString ); wxString wxXmStringToString( const XmString& xmString );
XmString wxStringToXmString( const wxString& string );
XmString wxStringToXmString( const char* string ); XmString wxStringToXmString( const char* string );
inline XmString wxStringToXmString( const wxCharBuffer& string )
{ return wxStringToXmString(string.data()); }
inline XmString wxStringToXmString( const wxString& string )
{ return wxStringToXmString((const char*)string.mb_str()); }
// XmString made easy to use in wxWidgets (and has an added benefit of // XmString made easy to use in wxWidgets (and has an added benefit of
// cleaning up automatically) // cleaning up automatically)
@@ -146,6 +149,11 @@ public:
Init(str); Init(str);
} }
wxXmString(const wchar_t* str)
{
Init(wxConvLibc.cWC2MB(str));
}
wxXmString(const wxString& str) wxXmString(const wxString& str)
{ {
Init(str.mb_str()); Init(str.mb_str());

View File

@@ -28,8 +28,8 @@
// Include common declarations // Include common declarations
#include "wx/x11/privx.h" #include "wx/x11/privx.h"
#if wxUSE_UNICODE #if wxUSE_PANGO
#include "pango/pango.h" #include <pango/pango.h>
#endif #endif
class WXDLLIMPEXP_FWD_CORE wxMouseEvent; class WXDLLIMPEXP_FWD_CORE wxMouseEvent;

View File

@@ -25,7 +25,7 @@ IMPLEMENT_DYNAMIC_CLASS(wxAcceleratorTable, wxObject)
class WXDLLEXPORT wxAcceleratorRefData: public wxObjectRefData class WXDLLEXPORT wxAcceleratorRefData: public wxObjectRefData
{ {
friend class WXDLLEXPORT wxAcceleratorTable; friend class wxAcceleratorTable;
public: public:
wxAcceleratorRefData(); wxAcceleratorRefData();
virtual ~wxAcceleratorRefData(); virtual ~wxAcceleratorRefData();

View File

@@ -260,6 +260,60 @@ bool wxApp::OnInitGui()
if ( clsname.empty() ) if ( clsname.empty() )
clsname = _T("wx"); clsname = _T("wx");
// FIXME-UTF8: This code is taken from wxGTK and duplicated here. This
// is just a temporary fix to make wxX11 compile in Unicode
// build, the real fix is to change Initialize()'s signature
// to use char* on Unix.
#if wxUSE_UNICODE
// XtOpenDisplay() wants char*, not wchar_t*, so convert
int i;
char **argvX11 = new char *[argc + 1];
for ( i = 0; i < argc; i++ )
{
argvX11[i] = strdup(wxConvLibc.cWX2MB(argv[i]));
}
argvX11[argc] = NULL;
int argcX11 = argc;
Display *dpy = XtOpenDisplay((XtAppContext) wxTheApp->m_appContext,
(String)NULL,
appname.c_str(),
clsname.c_str(),
NULL, 0, // no options
# if XtSpecificationRelease < 5
(Cardinal*) &argcX11,
# else
&argcX11,
# endif
argvX11);
if ( argcX11 != argc )
{
// we have to drop the parameters which were consumed by X11+
for ( i = 0; i < argcX11; i++ )
{
while ( strcmp(wxConvLibc.cWX2MB(argv[i]), argvX11[i]) != 0 )
{
memmove(argv + i, argv + i + 1, (argc - i)*sizeof(*argv));
}
}
argc = argcX11;
}
//else: XtOpenDisplay() didn't modify our parameters
// free our copy
for ( i = 0; i < argcX11; i++ )
{
free(argvX11[i]);
}
delete [] argvX11;
#else // ANSI
Display *dpy = XtOpenDisplay((XtAppContext) wxTheApp->m_appContext, Display *dpy = XtOpenDisplay((XtAppContext) wxTheApp->m_appContext,
(String)NULL, (String)NULL,
appname.c_str(), appname.c_str(),
@@ -272,6 +326,8 @@ bool wxApp::OnInitGui()
# endif # endif
argv); argv);
#endif // Unicode/ANSI
if (!dpy) { if (!dpy) {
// if you don't log to stderr, nothing will be shown... // if you don't log to stderr, nothing will be shown...
delete wxLog::SetActiveTarget(new wxLogStderr); delete wxLog::SetActiveTarget(new wxLogStderr);

View File

@@ -312,7 +312,7 @@ bool wxClipboard::AddData( wxDataObject *data )
wxString id = dfarr[i].GetId(); wxString id = dfarr[i].GetId();
while( ( retval = XmClipboardCopy( xdisplay, xwindow, itemId, while( ( retval = XmClipboardCopy( xdisplay, xwindow, itemId,
wxConstCast(id.mb_str(), char), id.char_str(),
NULL, size, i, &data_id ) ) NULL, size, i, &data_id ) )
== XmClipboardLocked ); == XmClipboardLocked );
@@ -461,7 +461,7 @@ bool wxClipboard::GetData( wxDataObject& data )
wxString id = chosenFormat.GetId(); wxString id = chosenFormat.GetId();
while( ( retval = XmClipboardInquireLength( xdisplay, xwindow, while( ( retval = XmClipboardInquireLength( xdisplay, xwindow,
wxConstCast(id.mb_str(), char), id.char_str(),
&length ) ) &length ) )
== XmClipboardLocked ); == XmClipboardLocked );
if( retval != XmClipboardSuccess ) if( retval != XmClipboardSuccess )
@@ -470,7 +470,7 @@ bool wxClipboard::GetData( wxDataObject& data )
wxCharBuffer buf(length); wxCharBuffer buf(length);
while( ( retval = XmClipboardRetrieve( xdisplay, xwindow, while( ( retval = XmClipboardRetrieve( xdisplay, xwindow,
wxConstCast(id.mb_str(), char), id.char_str(),
(XtPointer)buf.data(), (XtPointer)buf.data(),
length, &dummy1, &dummy2 ) ) length, &dummy1, &dummy2 ) )
== XmClipboardLocked ); == XmClipboardLocked );

View File

@@ -196,7 +196,7 @@ void wxComboBox::SetValue(const wxString& value)
m_inSetValue = true; m_inSetValue = true;
XtVaSetValues( GetXmText(this), XtVaSetValues( GetXmText(this),
XmNvalue, value.mb_str(), XmNvalue, (const char*)value.mb_str(),
NULL); NULL);
m_inSetValue = false; m_inSetValue = false;
@@ -341,7 +341,7 @@ wxTextPos wxComboBox::GetLastPosition() const
void wxComboBox::Replace(long from, long to, const wxString& value) void wxComboBox::Replace(long from, long to, const wxString& value)
{ {
XmTextReplace( GetXmText(this), (XmTextPosition)from, (XmTextPosition)to, XmTextReplace( GetXmText(this), (XmTextPosition)from, (XmTextPosition)to,
wxConstCast(value.mb_str(), char) ); value.char_str() );
} }
void wxComboBox::Remove(long from, long to) void wxComboBox::Remove(long from, long to)

View File

@@ -51,7 +51,7 @@ WX_DEFINE_LIST(wxXCursorList)
class WXDLLEXPORT wxCursorRefData: public wxObjectRefData class WXDLLEXPORT wxCursorRefData: public wxObjectRefData
{ {
friend class WXDLLEXPORT wxCursor; friend class wxCursor;
public: public:
wxCursorRefData(); wxCursorRefData();
virtual ~wxCursorRefData(); virtual ~wxCursorRefData();
@@ -259,7 +259,7 @@ wxCursor::wxCursor(const wxString& name, long flags, int hotSpotX, int hotSpotY)
int screen_num = DefaultScreen (dpy); int screen_num = DefaultScreen (dpy);
int value = XReadBitmapFile (dpy, RootWindow (dpy, screen_num), int value = XReadBitmapFile (dpy, RootWindow (dpy, screen_num),
wxConstCast(name.mb_str(), char), name.mb_str(),
&w, &h, &pixmap, &hotX, &hotY); &w, &h, &pixmap, &hotX, &hotY);
if (value == BitmapSuccess) if (value == BitmapSuccess)

View File

@@ -1134,11 +1134,11 @@ void wxWindowDC::DoDrawText( const wxString &text, wxCoord x, wxCoord y )
#if wxMOTIF_NEW_FONT_HANDLING #if wxMOTIF_NEW_FONT_HANDLING
XmbDrawString((Display*) m_display, (Pixmap) m_window->GetBackingPixmap(), fset, (GC) m_gcBacking, XmbDrawString((Display*) m_display, (Pixmap) m_window->GetBackingPixmap(), fset, (GC) m_gcBacking,
XLOG2DEV_2 (x), YLOG2DEV_2 (y) + ascent, XLOG2DEV_2 (x), YLOG2DEV_2 (y) + ascent,
wxConstCast(text.mb_str(), char), slen); text.mb_str(), slen);
#else #else
XDrawString((Display*) m_display, (Pixmap) m_window->GetBackingPixmap(), (GC) m_gcBacking, XDrawString((Display*) m_display, (Pixmap) m_window->GetBackingPixmap(), (GC) m_gcBacking,
XLOG2DEV_2 (x), YLOG2DEV_2 (y) + ascent, XLOG2DEV_2 (x), YLOG2DEV_2 (y) + ascent,
wxConstCast(text.mb_str(), char), slen); text.mb_str(), slen);
#endif #endif
} }

View File

@@ -155,7 +155,7 @@ bool wxDialog::XmDoCreateTLW(wxWindow* parent,
XtSetArg (args[1], XmNautoUnmanage, False); XtSetArg (args[1], XmNautoUnmanage, False);
Widget dialogShell = Widget dialogShell =
XmCreateBulletinBoardDialog( parentWidget, XmCreateBulletinBoardDialog( parentWidget,
wxConstCast(name.mb_str(), char), name.char_str(),
args, 2); args, 2);
m_mainWidget = (WXWidget) dialogShell; m_mainWidget = (WXWidget) dialogShell;
@@ -236,9 +236,9 @@ void wxDialog::SetTitle(const wxString& title)
{ {
wxXmString str( title ); wxXmString str( title );
XtVaSetValues( (Widget)m_mainWidget, XtVaSetValues( (Widget)m_mainWidget,
XmNtitle, title.mb_str(), XmNtitle, (const char*)title.mb_str(),
XmNdialogTitle, str(), XmNdialogTitle, str(),
XmNiconName, title.mb_str(), XmNiconName, (const char*)title.mb_str(),
NULL ); NULL );
} }
} }

View File

@@ -237,7 +237,7 @@ int wxFileDialog::ShowModal()
if (!m_message.IsNull()) if (!m_message.IsNull())
XtVaSetValues(shell, XtVaSetValues(shell,
XmNtitle, wxConstCast(m_message.mb_str(), char), XmNtitle, (const char*)m_message.mb_str(),
NULL); NULL);
if (!m_wildCard.empty()) if (!m_wildCard.empty())
@@ -250,7 +250,7 @@ int wxFileDialog::ShowModal()
else else
filter = wildCard; filter = wildCard;
XmTextSetString(filterWidget, wxConstCast(filter.mb_str(), char)); XmTextSetString(filterWidget, filter.char_str());
XmFileSelectionDoSearch(fileSel, NULL); XmFileSelectionDoSearch(fileSel, NULL);
} }
@@ -278,8 +278,7 @@ int wxFileDialog::ShowModal()
if (!entirePath.empty()) if (!entirePath.empty())
{ {
XmTextSetString(selectionWidget, XmTextSetString(selectionWidget, entirePath.char_str());
wxConstCast(entirePath.mb_str(), char));
} }
XtAddCallback(fileSel, XmNcancelCallback, XtAddCallback(fileSel, XmNcancelCallback,

View File

@@ -550,7 +550,7 @@ wxXFont* wxFont::GetInternalFont(double scale, WXDisplay* display) const
int count = 0; int count = 0;
#if wxMOTIF_NEW_FONT_HANDLING #if wxMOTIF_NEW_FONT_HANDLING
wxChar* fontSpec = wxStrdup( xFontSpec.mb_str() ); char* fontSpec = wxStrdup(xFontSpec.mb_str());
XtSetArg( args[count], XmNfontName, fontSpec ); ++count; XtSetArg( args[count], XmNfontName, fontSpec ); ++count;
XtSetArg( args[count], XmNfontType, XmFONT_IS_FONTSET ); ++count; XtSetArg( args[count], XmNfontType, XmFONT_IS_FONTSET ); ++count;
#else #else

View File

@@ -452,8 +452,8 @@ void wxFrame::SetTitle(const wxString& title)
if( !title.empty() ) if( !title.empty() )
XtVaSetValues( (Widget)m_frameShell, XtVaSetValues( (Widget)m_frameShell,
XmNtitle, title.mb_str(), XmNtitle, (const char*)title.mb_str(),
XmNiconName, title.mb_str(), XmNiconName, (const char*)title.mb_str(),
NULL ); NULL );
} }

View File

@@ -122,7 +122,7 @@ bool wxListBox::Create(wxWindow *parent, wxWindowID id,
Widget listWidget = Widget listWidget =
XmCreateScrolledList(parentWidget, XmCreateScrolledList(parentWidget,
wxConstCast(name.mb_str(), char), args, count); name.char_str(), args, count);
m_mainWidget = (WXWidget) listWidget; m_mainWidget = (WXWidget) listWidget;

View File

@@ -125,7 +125,7 @@ bool wxRadioBox::Create(wxWindow *parent, wxWindowID id, const wxString& title,
wxString str(GetLabelText(choices[i])); wxString str(GetLabelText(choices[i]));
m_radioButtonLabels.push_back(str); m_radioButtonLabels.push_back(str);
Widget radioItem = XtVaCreateManagedWidget ( Widget radioItem = XtVaCreateManagedWidget (
wxConstCast(str.mb_str(), char), str.mb_str(),
#if wxUSE_GADGETS #if wxUSE_GADGETS
xmToggleButtonGadgetClass, radioBoxWidget, xmToggleButtonGadgetClass, radioBoxWidget,
#else #else

View File

@@ -51,7 +51,7 @@ bool wxStaticText::Create(wxWindow *parent, wxWindowID id,
(Widget) wxCreateBorderWidget( (WXWidget)parentWidget, style ); (Widget) wxCreateBorderWidget( (WXWidget)parentWidget, style );
m_labelWidget = m_labelWidget =
XtVaCreateManagedWidget (wxConstCast(name.mb_str(), char), XtVaCreateManagedWidget (name.mb_str(),
xmLabelWidgetClass, xmLabelWidgetClass,
borderWidget ? borderWidget : parentWidget, borderWidget ? borderWidget : parentWidget,
wxFont::GetFontTag(), m_font.GetFontTypeC(XtDisplay(parentWidget)), wxFont::GetFontTag(), m_font.GetFontTypeC(XtDisplay(parentWidget)),

View File

@@ -138,14 +138,14 @@ bool wxTextCtrl::Create(wxWindow *parent,
XtSetArg (args[count], (String) wxFont::GetFontTag(), XtSetArg (args[count], (String) wxFont::GetFontTag(),
m_font.GetFontType( XtDisplay(parentWidget) ) ); ++count; m_font.GetFontType( XtDisplay(parentWidget) ) ); ++count;
XtSetArg (args[count], XmNwordWrap, wantWordWrap); ++count; XtSetArg (args[count], XmNwordWrap, wantWordWrap); ++count;
XtSetArg (args[count], XmNvalue, value.mb_str()); ++count; XtSetArg (args[count], XmNvalue, (const char*)value.mb_str()); ++count;
XtSetArg (args[count], XmNeditable, XtSetArg (args[count], XmNeditable,
style & wxTE_READONLY ? False : True); ++count; style & wxTE_READONLY ? False : True); ++count;
XtSetArg (args[count], XmNeditMode, XmMULTI_LINE_EDIT ); ++count; XtSetArg (args[count], XmNeditMode, XmMULTI_LINE_EDIT ); ++count;
m_mainWidget = m_mainWidget =
(WXWidget) XmCreateScrolledText(parentWidget, (WXWidget) XmCreateScrolledText(parentWidget,
wxConstCast(name.mb_str(), char), name.char_str(),
args, count); args, count);
XtManageChild ((Widget) m_mainWidget); XtManageChild ((Widget) m_mainWidget);
@@ -154,11 +154,11 @@ bool wxTextCtrl::Create(wxWindow *parent,
{ {
m_mainWidget = (WXWidget)XtVaCreateManagedWidget m_mainWidget = (WXWidget)XtVaCreateManagedWidget
( (
wxConstCast(name.mb_str(), char), name.mb_str(),
xmTextWidgetClass, xmTextWidgetClass,
parentWidget, parentWidget,
wxFont::GetFontTag(), m_font.GetFontType( XtDisplay(parentWidget) ), wxFont::GetFontTag(), m_font.GetFontType( XtDisplay(parentWidget) ),
XmNvalue, value.mb_str(), XmNvalue, (const char*)value.mb_str(),
XmNeditable, (style & wxTE_READONLY) ? XmNeditable, (style & wxTE_READONLY) ?
False : True, False : True,
NULL NULL
@@ -243,7 +243,7 @@ void wxTextCtrl::DoSetValue(const wxString& text, int flags)
{ {
m_inSetValue = true; m_inSetValue = true;
XmTextSetString ((Widget) m_mainWidget, wxConstCast(text.mb_str(), char)); XmTextSetString ((Widget) m_mainWidget, text.char_str());
XtVaSetValues ((Widget) m_mainWidget, XtVaSetValues ((Widget) m_mainWidget,
XmNcursorPosition, text.length(), XmNcursorPosition, text.length(),
NULL); NULL);
@@ -364,7 +364,7 @@ wxTextPos wxTextCtrl::GetLastPosition() const
void wxTextCtrl::Replace(long from, long to, const wxString& value) void wxTextCtrl::Replace(long from, long to, const wxString& value)
{ {
XmTextReplace ((Widget) m_mainWidget, (XmTextPosition) from, (XmTextPosition) to, XmTextReplace ((Widget) m_mainWidget, (XmTextPosition) from, (XmTextPosition) to,
wxConstCast(value.mb_str(), char)); value.char_str());
} }
void wxTextCtrl::Remove(long from, long to) void wxTextCtrl::Remove(long from, long to)
@@ -387,7 +387,7 @@ void wxTextCtrl::WriteText(const wxString& text)
{ {
long textPosition = GetInsertionPoint() + text.length(); long textPosition = GetInsertionPoint() + text.length();
XmTextInsert ((Widget) m_mainWidget, GetInsertionPoint(), XmTextInsert ((Widget) m_mainWidget, GetInsertionPoint(),
wxConstCast(text.mb_str(), char)); text.char_str());
XtVaSetValues ((Widget) m_mainWidget, XmNcursorPosition, textPosition, NULL); XtVaSetValues ((Widget) m_mainWidget, XmNcursorPosition, textPosition, NULL);
SetInsertionPoint(textPosition); SetInsertionPoint(textPosition);
XmTextShowPosition ((Widget) m_mainWidget, textPosition); XmTextShowPosition ((Widget) m_mainWidget, textPosition);
@@ -398,7 +398,7 @@ void wxTextCtrl::AppendText(const wxString& text)
{ {
wxTextPos textPosition = GetLastPosition() + text.length(); wxTextPos textPosition = GetLastPosition() + text.length();
XmTextInsert ((Widget) m_mainWidget, GetLastPosition(), XmTextInsert ((Widget) m_mainWidget, GetLastPosition(),
wxConstCast(text.mb_str(), char)); text.char_str());
XtVaSetValues ((Widget) m_mainWidget, XmNcursorPosition, textPosition, NULL); XtVaSetValues ((Widget) m_mainWidget, XmNcursorPosition, textPosition, NULL);
SetInsertionPoint(textPosition); SetInsertionPoint(textPosition);
XmTextShowPosition ((Widget) m_mainWidget, textPosition); XmTextShowPosition ((Widget) m_mainWidget, textPosition);

View File

@@ -601,11 +601,6 @@ wxString wxXmStringToString( const XmString& xmString )
return wxEmptyString; return wxEmptyString;
} }
XmString wxStringToXmString( const wxString& str )
{
return wxStringToXmString(str.mb_str());
}
XmString wxStringToXmString( const char* str ) XmString wxStringToXmString( const char* str )
{ {
return XmStringCreateLtoR((char *)str, XmSTRING_DEFAULT_CHARSET); return XmStringCreateLtoR((char *)str, XmSTRING_DEFAULT_CHARSET);

View File

@@ -629,7 +629,8 @@ void wxWindow::Lower()
void wxWindow::SetLabel(const wxString& label) void wxWindow::SetLabel(const wxString& label)
{ {
XtVaSetValues((Widget)GetMainWidget(), XmNtitle, label.mb_str(), NULL); XtVaSetValues((Widget)GetMainWidget(), XmNtitle,
(const char*)label.mb_str(), NULL);
} }
wxString wxWindow::GetLabel() const wxString wxWindow::GetLabel() const