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
# 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.
# Generated by GNU Autoconf 2.61 for wxWidgets 2.9.0.
#
@@ -33755,12 +33755,6 @@ done
fi
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 $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
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)
WX_PATH_FIND_INCLUDES($SEARCH_INCLUDE, Xm/Xm.h)
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 */
#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
# undef wxUSE_TAB_DIALOG
# define wxUSE_TAB_DIALOG 1

View File

@@ -128,8 +128,11 @@ extern XColor itemColors[5] ;
// ----------------------------------------------------------------------------
wxString wxXmStringToString( const XmString& xmString );
XmString wxStringToXmString( const wxString& 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
// cleaning up automatically)
@@ -146,6 +149,11 @@ public:
Init(str);
}
wxXmString(const wchar_t* str)
{
Init(wxConvLibc.cWC2MB(str));
}
wxXmString(const wxString& str)
{
Init(str.mb_str());

View File

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

View File

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

View File

@@ -260,6 +260,60 @@ bool wxApp::OnInitGui()
if ( clsname.empty() )
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,
(String)NULL,
appname.c_str(),
@@ -272,6 +326,8 @@ bool wxApp::OnInitGui()
# endif
argv);
#endif // Unicode/ANSI
if (!dpy) {
// if you don't log to stderr, nothing will be shown...
delete wxLog::SetActiveTarget(new wxLogStderr);

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@@ -550,7 +550,7 @@ wxXFont* wxFont::GetInternalFont(double scale, WXDisplay* display) const
int count = 0;
#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], XmNfontType, XmFONT_IS_FONTSET ); ++count;
#else

View File

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

View File

@@ -122,7 +122,7 @@ bool wxListBox::Create(wxWindow *parent, wxWindowID id,
Widget listWidget =
XmCreateScrolledList(parentWidget,
wxConstCast(name.mb_str(), char), args, count);
name.char_str(), args, count);
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]));
m_radioButtonLabels.push_back(str);
Widget radioItem = XtVaCreateManagedWidget (
wxConstCast(str.mb_str(), char),
str.mb_str(),
#if wxUSE_GADGETS
xmToggleButtonGadgetClass, radioBoxWidget,
#else

View File

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

View File

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

View File

@@ -629,7 +629,8 @@ void wxWindow::Lower()
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