Bunch of compile fixes for wxX11 in Unicode.
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/branches/WX_2_4_BRANCH@17679 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -48,7 +48,10 @@ public:
|
||||
|
||||
// Implicit conversion from the colour name
|
||||
wxColour( const wxString &colourName ) { InitFromName(colourName); }
|
||||
wxColour( const char *colourName ) { InitFromName(colourName); }
|
||||
wxColour( const char *colourName ) { InitFromName( wxString::FromAscii(colourName) ); }
|
||||
#if wxUSE_UNICODE
|
||||
wxColour( const wxChar *colourName ) { InitFromName( wxString(colourName) ); }
|
||||
#endif
|
||||
|
||||
wxColour( const wxColour& col ) { Ref(col); }
|
||||
wxColour& operator = ( const wxColour& col ) { Ref(col); return *this; }
|
||||
|
@@ -26,6 +26,7 @@
|
||||
#include "wx/intl.h"
|
||||
#include "wx/evtloop.h"
|
||||
#include "wx/timer.h"
|
||||
#include "wx/filename.h"
|
||||
|
||||
#include "wx/univ/theme.h"
|
||||
#include "wx/univ/renderer.h"
|
||||
@@ -57,8 +58,6 @@ wxApp *wxTheApp = NULL;
|
||||
|
||||
// This is set within wxEntryStart -- too early on
|
||||
// to put these in wxTheApp
|
||||
static int g_newArgc = 0;
|
||||
static wxChar** g_newArgv = NULL;
|
||||
static bool g_showIconic = FALSE;
|
||||
static wxSize g_initialSize = wxDefaultSize;
|
||||
|
||||
@@ -136,10 +135,6 @@ bool wxApp::Initialize()
|
||||
|
||||
void wxApp::CleanUp()
|
||||
{
|
||||
if (g_newArgv)
|
||||
delete[] g_newArgv;
|
||||
g_newArgv = NULL;
|
||||
|
||||
delete wxWidgetHashTable;
|
||||
wxWidgetHashTable = NULL;
|
||||
delete wxClientWidgetHashTable;
|
||||
@@ -197,20 +192,13 @@ int wxEntryStart( int& argc, char *argv[] )
|
||||
#endif
|
||||
#endif // __WXDEBUG__
|
||||
|
||||
wxString displayName;
|
||||
char *displayName = NULL;
|
||||
bool syncDisplay = FALSE;
|
||||
|
||||
// Parse the arguments.
|
||||
// We can't use wxCmdLineParser or OnInitCmdLine and friends because
|
||||
// we have to create the Display earlier. If we can find a way to
|
||||
// use the wxAppBase API then I'll be quite happy to change it.
|
||||
g_newArgv = new wxChar*[argc + 1];
|
||||
g_newArgc = 0;
|
||||
int i;
|
||||
for (i = 0; i < argc; i++)
|
||||
{
|
||||
wxString arg(argv[i]);
|
||||
if (arg == wxT("-display"))
|
||||
if (strcmp( argv[i], "-display") == 0)
|
||||
{
|
||||
if (i < (argc - 1))
|
||||
{
|
||||
@@ -219,16 +207,15 @@ int wxEntryStart( int& argc, char *argv[] )
|
||||
continue;
|
||||
}
|
||||
}
|
||||
else if (arg == wxT("-geometry"))
|
||||
else if (strcmp( argv[i], "-geometry") == 0)
|
||||
{
|
||||
if (i < (argc - 1))
|
||||
{
|
||||
i ++;
|
||||
wxString windowGeometry = argv[i];
|
||||
int w, h;
|
||||
if (wxSscanf(windowGeometry.c_str(), _T("%dx%d"), &w, &h) != 2)
|
||||
if (sscanf(argv[i], "%dx%d", &w, &h) != 2)
|
||||
{
|
||||
wxLogError(_("Invalid geometry specification '%s'"), windowGeometry.c_str());
|
||||
wxLogError( _("Invalid geometry specification '%s'"), wxString::FromAscii(argv[i]).c_str() );
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -237,30 +224,23 @@ int wxEntryStart( int& argc, char *argv[] )
|
||||
continue;
|
||||
}
|
||||
}
|
||||
else if (arg == wxT("-sync"))
|
||||
else if (strcmp( argv[i], "-sync") == 0)
|
||||
{
|
||||
syncDisplay = TRUE;
|
||||
continue;
|
||||
}
|
||||
else if (arg == wxT("-iconic"))
|
||||
else if (strcmp( argv[i], "-iconic") == 0)
|
||||
{
|
||||
g_showIconic = TRUE;
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
// Not eaten by wxWindows, so pass through
|
||||
g_newArgv[g_newArgc] = argv[i];
|
||||
g_newArgc ++;
|
||||
}
|
||||
g_newArgv[g_newArgc] = NULL;
|
||||
|
||||
Display* xdisplay = NULL;
|
||||
if (displayName.IsEmpty())
|
||||
xdisplay = XOpenDisplay(NULL);
|
||||
else
|
||||
xdisplay = XOpenDisplay((char*) displayName.c_str());
|
||||
|
||||
|
||||
// X11 display stuff
|
||||
Display* xdisplay = XOpenDisplay( displayName );
|
||||
if (!xdisplay)
|
||||
{
|
||||
wxLogError( _("wxWindows could not open display. Exiting.") );
|
||||
@@ -268,14 +248,36 @@ int wxEntryStart( int& argc, char *argv[] )
|
||||
}
|
||||
|
||||
if (syncDisplay)
|
||||
{
|
||||
XSynchronize(xdisplay, True);
|
||||
}
|
||||
|
||||
wxApp::ms_display = (WXDisplay*) xdisplay;
|
||||
|
||||
|
||||
XSelectInput( xdisplay, XDefaultRootWindow(xdisplay), PropertyChangeMask);
|
||||
|
||||
|
||||
// Command line argument stuff
|
||||
wxTheApp->argc = argc;
|
||||
#if wxUSE_UNICODE
|
||||
wxTheApp->argv = new wxChar*[argc+1];
|
||||
int mb_argc = 0;
|
||||
while (mb_argc < argc)
|
||||
{
|
||||
wxString tmp = wxString::FromAscii( argv[mb_argc] );
|
||||
wxTheApp->argv[mb_argc] = wxStrdup( tmp.c_str() );
|
||||
mb_argc++;
|
||||
}
|
||||
wxTheApp->argv[mb_argc] = (wxChar *)NULL;
|
||||
#else
|
||||
wxTheApp->argv = argv;
|
||||
#endif
|
||||
|
||||
if (wxTheApp->argc > 0)
|
||||
{
|
||||
wxFileName fname( wxTheApp->argv[0] );
|
||||
wxTheApp->SetAppName( fname.GetName() );
|
||||
}
|
||||
|
||||
// Misc.
|
||||
wxSetDetectableAutoRepeat( TRUE );
|
||||
|
||||
if (!wxApp::Initialize())
|
||||
@@ -316,32 +318,17 @@ int wxEntry( int argc, char *argv[] )
|
||||
{
|
||||
printf( "wxWindows error: No initializer - use IMPLEMENT_APP macro.\n" );
|
||||
return 0;
|
||||
};
|
||||
}
|
||||
|
||||
wxTheApp = (wxApp*) (* wxApp::GetInitializerFunction()) ();
|
||||
};
|
||||
}
|
||||
|
||||
if (!wxTheApp)
|
||||
{
|
||||
printf( "wxWindows error: wxTheApp == NULL\n" );
|
||||
return 0;
|
||||
};
|
||||
|
||||
wxTheApp->SetClassName(wxFileNameFromPath(argv[0]));
|
||||
wxTheApp->SetAppName(wxFileNameFromPath(argv[0]));
|
||||
|
||||
// The command line may have been changed
|
||||
// by stripping out -display etc.
|
||||
if (g_newArgc > 0)
|
||||
{
|
||||
wxTheApp->argc = g_newArgc;
|
||||
wxTheApp->argv = g_newArgv;
|
||||
}
|
||||
else
|
||||
{
|
||||
wxTheApp->argc = argc;
|
||||
wxTheApp->argv = argv;
|
||||
}
|
||||
|
||||
wxTheApp->m_showIconic = g_showIconic;
|
||||
wxTheApp->m_initialSize = g_initialSize;
|
||||
|
||||
|
@@ -85,46 +85,46 @@ wxPalette wxNullPalette;
|
||||
wxFont wxNullFont;
|
||||
wxColour wxNullColour;
|
||||
|
||||
// Default window names
|
||||
const char *wxControlNameStr = "control";
|
||||
const char *wxButtonNameStr = "button";
|
||||
const char *wxCanvasNameStr = "canvas";
|
||||
const char *wxCheckBoxNameStr = "check";
|
||||
const char *wxChoiceNameStr = "choice";
|
||||
const char *wxComboBoxNameStr = "comboBox";
|
||||
const char *wxDialogNameStr = "dialog";
|
||||
const char *wxFrameNameStr = "frame";
|
||||
const char *wxGaugeNameStr = "gauge";
|
||||
const char *wxStaticBoxNameStr = "groupBox";
|
||||
const char *wxListBoxNameStr = "listBox";
|
||||
const char *wxStaticTextNameStr = "message";
|
||||
const char *wxStaticBitmapNameStr = "message";
|
||||
const char *wxMultiTextNameStr = "multitext";
|
||||
const char *wxPanelNameStr = "panel";
|
||||
const char *wxRadioBoxNameStr = "radioBox";
|
||||
const char *wxRadioButtonNameStr = "radioButton";
|
||||
const char *wxBitmapRadioButtonNameStr = "radioButton";
|
||||
const char *wxScrollBarNameStr = "scrollBar";
|
||||
const char *wxSliderNameStr = "slider";
|
||||
const char *wxStaticNameStr = "static";
|
||||
const char *wxTextCtrlWindowNameStr = "textWindow";
|
||||
const char *wxTextCtrlNameStr = "text";
|
||||
const char *wxVirtListBoxNameStr = "virtListBox";
|
||||
const char *wxButtonBarNameStr = "buttonbar";
|
||||
const char *wxEnhDialogNameStr = "Shell";
|
||||
const char *wxToolBarNameStr = "toolbar";
|
||||
const char *wxStatusLineNameStr = "status_line";
|
||||
const char *wxGetTextFromUserPromptStr = "Input Text";
|
||||
const char *wxMessageBoxCaptionStr = "Message";
|
||||
const char *wxFileSelectorPromptStr = "Select a file";
|
||||
const char *wxFileSelectorDefaultWildcardStr = "*.*";
|
||||
const char *wxDirDialogNameStr = "wxDirCtrl";
|
||||
const char *wxDirDialogDefaultFolderStr = "/";
|
||||
/* Default window names */
|
||||
const wxChar *wxControlNameStr = wxT("control");
|
||||
const wxChar *wxButtonNameStr = wxT("button");
|
||||
const wxChar *wxCanvasNameStr = wxT("canvas");
|
||||
const wxChar *wxCheckBoxNameStr = wxT("check");
|
||||
const wxChar *wxChoiceNameStr = wxT("choice");
|
||||
const wxChar *wxComboBoxNameStr = wxT("comboBox");
|
||||
const wxChar *wxDialogNameStr = wxT("dialog");
|
||||
const wxChar *wxFrameNameStr = wxT("frame");
|
||||
const wxChar *wxGaugeNameStr = wxT("gauge");
|
||||
const wxChar *wxStaticBoxNameStr = wxT("groupBox");
|
||||
const wxChar *wxListBoxNameStr = wxT("listBox");
|
||||
const wxChar *wxStaticTextNameStr = wxT("message");
|
||||
const wxChar *wxStaticBitmapNameStr = wxT("message");
|
||||
const wxChar *wxMultiTextNameStr = wxT("multitext");
|
||||
const wxChar *wxPanelNameStr = wxT("panel");
|
||||
const wxChar *wxRadioBoxNameStr = wxT("radioBox");
|
||||
const wxChar *wxRadioButtonNameStr = wxT("radioButton");
|
||||
const wxChar *wxBitmapRadioButtonNameStr = wxT("radioButton");
|
||||
const wxChar *wxScrollBarNameStr = wxT("scrollBar");
|
||||
const wxChar *wxSliderNameStr = wxT("slider");
|
||||
const wxChar *wxStaticNameStr = wxT("static");
|
||||
const wxChar *wxTextCtrlWindowNameStr = wxT("textWindow");
|
||||
const wxChar *wxTextCtrlNameStr = wxT("text");
|
||||
const wxChar *wxVirtListBoxNameStr = wxT("virtListBox");
|
||||
const wxChar *wxButtonBarNameStr = wxT("buttonbar");
|
||||
const wxChar *wxEnhDialogNameStr = wxT("Shell");
|
||||
const wxChar *wxToolBarNameStr = wxT("toolbar");
|
||||
const wxChar *wxStatusLineNameStr = wxT("status_line");
|
||||
const wxChar *wxGetTextFromUserPromptStr = wxT("Input Text");
|
||||
const wxChar *wxMessageBoxCaptionStr = wxT("Message");
|
||||
const wxChar *wxFileSelectorPromptStr = wxT("Select a file");
|
||||
const wxChar *wxFileSelectorDefaultWildcardStr = wxT("*");
|
||||
const wxChar *wxDirDialogNameStr = wxT("wxDirCtrl");
|
||||
const wxChar *wxDirDialogDefaultFolderStr = wxT("/");
|
||||
const wxChar *wxTreeCtrlNameStr = wxT("wxTreeCtrl");
|
||||
|
||||
// See wx/utils.h
|
||||
const char *wxFloatToStringStr = "%.2f";
|
||||
const char *wxDoubleToStringStr = "%.2f";
|
||||
/* See wx/utils.h */
|
||||
const wxChar *wxFloatToStringStr = wxT("%.2f");
|
||||
const wxChar *wxDoubleToStringStr = wxT("%.2f");
|
||||
|
||||
|
||||
const wxSize wxDefaultSize(-1, -1);
|
||||
|
@@ -102,7 +102,7 @@ wxString wxDataFormat::GetId() const
|
||||
return wxEmptyString;
|
||||
#else
|
||||
char *t = XGetAtomName ((Display*) wxGetDisplay(), m_format);
|
||||
wxString ret( t ); // this will convert from ascii to Unicode
|
||||
wxString ret = wxString::FromAscii( t );
|
||||
if (t)
|
||||
XFree( t );
|
||||
return ret;
|
||||
@@ -132,7 +132,7 @@ void wxDataFormat::SetId( const wxChar *id )
|
||||
PrepareFormats();
|
||||
m_type = wxDF_PRIVATE;
|
||||
wxString tmp( id );
|
||||
m_format = XInternAtom( (Display*) wxGetDisplay(), wxMBSTRINGCAST tmp.mbc_str(), FALSE ); // what is the string cast for?
|
||||
m_format = XInternAtom( (Display*) wxGetDisplay(), tmp.ToAscii(), FALSE );
|
||||
#endif
|
||||
}
|
||||
|
||||
|
@@ -1368,7 +1368,12 @@ void wxWindowDC::DoDrawText( const wxString &text, wxCoord x, wxCoord y )
|
||||
wxCHECK_RET( Ok(), wxT("invalid window dc") );
|
||||
|
||||
if (!m_window) return;
|
||||
|
||||
#if wxUSE_UNICODE
|
||||
|
||||
// later
|
||||
|
||||
#else
|
||||
XFontStruct *xfont = (XFontStruct*) m_font.GetFontStruct( m_scaleY, m_display );
|
||||
|
||||
wxCHECK_RET( xfont, wxT("invalid font") );
|
||||
@@ -1426,6 +1431,7 @@ void wxWindowDC::DoDrawText( const wxString &text, wxCoord x, wxCoord y )
|
||||
CalcBoundingBox (x + width, y + height);
|
||||
CalcBoundingBox (x, y);
|
||||
#endif
|
||||
#endif
|
||||
}
|
||||
|
||||
void wxWindowDC::DoDrawRotatedText( const wxString &text, wxCoord x, wxCoord y, double angle )
|
||||
|
@@ -34,7 +34,7 @@ IMPLEMENT_DYNAMIC_CLASS(wxPopupWindow, wxWindow)
|
||||
|
||||
bool wxPopupWindow::Create( wxWindow *parent, int style )
|
||||
{
|
||||
if (!CreateBase( parent, -1, wxDefaultPosition, wxDefaultSize, style, wxDefaultValidator, "popup" ))
|
||||
if (!CreateBase( parent, -1, wxDefaultPosition, wxDefaultSize, style, wxDefaultValidator, wxT("popup") ))
|
||||
{
|
||||
wxFAIL_MSG( wxT("wxPopupWindow creation failed") );
|
||||
return FALSE;
|
||||
|
@@ -296,13 +296,13 @@ WXWindow wxReparenter::FindAClientWindow(WXWindow window, const wxString& name)
|
||||
XFetchName((Display*) wxGetDisplay(), (Window) window, &clientName);
|
||||
|
||||
wxString str1(name);
|
||||
wxString str2(clientName);
|
||||
wxString str2 = wxString::FromAscii(clientName);
|
||||
str1.Lower();
|
||||
str2.Lower();
|
||||
|
||||
bool matches;
|
||||
if (sm_exactMatch)
|
||||
matches = (name == clientName);
|
||||
matches = (name == wxString::FromAscii(clientName));
|
||||
else
|
||||
matches = (str1.Contains(str2) || str2.Contains(str1));
|
||||
|
||||
@@ -316,7 +316,8 @@ WXWindow wxReparenter::FindAClientWindow(WXWindow window, const wxString& name)
|
||||
|
||||
old = XSetErrorHandler(ErrorHandler);
|
||||
if (!XQueryTree((Display*) wxGetDisplay(), (Window) window, &returnroot, &returnparent,
|
||||
&children, &numchildren) || Xerror) {
|
||||
&children, &numchildren) || Xerror)
|
||||
{
|
||||
XSetErrorHandler(old);
|
||||
return NULL;
|
||||
}
|
||||
|
@@ -410,10 +410,18 @@ void wxTopLevelWindowX11::SetTitle(const wxString& title)
|
||||
|
||||
if (GetMainWindow())
|
||||
{
|
||||
#if wxUSE_UNICODE
|
||||
// I wonder of e.g. Metacity takes UTF-8 here
|
||||
XStoreName(wxGlobalDisplay(), (Window) GetMainWindow(),
|
||||
(const char*) title.ToAscii() );
|
||||
XSetIconName(wxGlobalDisplay(), (Window) GetMainWindow(),
|
||||
(const char*) title.ToAscii() );
|
||||
#else
|
||||
XStoreName(wxGlobalDisplay(), (Window) GetMainWindow(),
|
||||
(const char*) title);
|
||||
XSetIconName(wxGlobalDisplay(), (Window) GetMainWindow(),
|
||||
(const char*) title);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user