Lots of Unix/Unicode compile fixes, some of which

are just #ifdef 0 such as the wxExecute calls
    in gdcps.cpp.


git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@16375 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Robert Roebling
2002-08-05 18:04:08 +00:00
parent d7a7bd6d27
commit 401eb3dec2
28 changed files with 121 additions and 48 deletions

View File

@@ -48,6 +48,10 @@ public:
// Implicit conversion from the colour name
wxColour( const wxString &colourName ) { InitFromName(colourName); }
wxColour( const char *colourName ) { InitFromName(colourName); }
#if wxUSE_UNICODE
wxColour( const wxChar *colourName ) { InitFromName( wxString(colourName) ); }
#endif
wxColour( const wxColour& col )
: wxGDIObject()

View File

@@ -33,7 +33,7 @@ class wxComboBox;
// global data
//-----------------------------------------------------------------------------
extern const char* wxComboBoxNameStr;
extern const wxChar* wxComboBoxNameStr;
extern const wxChar* wxEmptyString;
//-----------------------------------------------------------------------------

View File

@@ -33,7 +33,7 @@ class wxGauge;
// global data
//-----------------------------------------------------------------------------
extern const char* wxGaugeNameStr;
extern const wxChar* wxGaugeNameStr;
//-----------------------------------------------------------------------------
// wxGaugeBox

View File

@@ -39,14 +39,14 @@ public:
const wxPoint& pos = wxDefaultPosition,
const wxSize& size = wxDefaultSize,
long style = 0,
const wxString& name = "notebook");
const wxString& name = wxT("notebook"));
// Create() function
bool Create(wxWindow *parent,
wxWindowID id,
const wxPoint& pos = wxDefaultPosition,
const wxSize& size = wxDefaultSize,
long style = 0,
const wxString& name = "notebook");
const wxString& name = wxT("notebook"));
// dtor
virtual ~wxNotebook();

View File

@@ -59,8 +59,6 @@ public:
virtual int GetMax() const;
// implementation
// --------------
void OnChar( wxKeyEvent &event );
bool IsOwnGtkWindow( GdkWindow *window );

View File

@@ -48,6 +48,10 @@ public:
// Implicit conversion from the colour name
wxColour( const wxString &colourName ) { InitFromName(colourName); }
wxColour( const char *colourName ) { InitFromName(colourName); }
#if wxUSE_UNICODE
wxColour( const wxChar *colourName ) { InitFromName( wxString(colourName) ); }
#endif
wxColour( const wxColour& col )
: wxGDIObject()

View File

@@ -33,7 +33,7 @@ class wxComboBox;
// global data
//-----------------------------------------------------------------------------
extern const char* wxComboBoxNameStr;
extern const wxChar* wxComboBoxNameStr;
extern const wxChar* wxEmptyString;
//-----------------------------------------------------------------------------

View File

@@ -33,7 +33,7 @@ class wxGauge;
// global data
//-----------------------------------------------------------------------------
extern const char* wxGaugeNameStr;
extern const wxChar* wxGaugeNameStr;
//-----------------------------------------------------------------------------
// wxGaugeBox

View File

@@ -39,14 +39,14 @@ public:
const wxPoint& pos = wxDefaultPosition,
const wxSize& size = wxDefaultSize,
long style = 0,
const wxString& name = "notebook");
const wxString& name = wxT("notebook"));
// Create() function
bool Create(wxWindow *parent,
wxWindowID id,
const wxPoint& pos = wxDefaultPosition,
const wxSize& size = wxDefaultSize,
long style = 0,
const wxString& name = "notebook");
const wxString& name = wxT("notebook"));
// dtor
virtual ~wxNotebook();

View File

@@ -59,8 +59,6 @@ public:
virtual int GetMax() const;
// implementation
// --------------
void OnChar( wxKeyEvent &event );
bool IsOwnGtkWindow( GdkWindow *window );

View File

@@ -70,6 +70,7 @@ public:
// Implementation
void DoSetBitmap();
virtual void ChangeBackgroundColour();
virtual wxSize DoGetBestSize() const;
protected:
wxBitmap m_buttonBitmapFocus;

View File

@@ -36,6 +36,7 @@
#endif
#include "wx/filename.h" // for SplitPath()
#include "wx/strconv.h"
#include "wx/dynload.h"
#include "wx/module.h"
@@ -167,7 +168,7 @@ bool wxDynamicLibrary::Load(wxString libname, int flags)
#endif
}
m_handle = dlopen(libname.c_str(), rtldFlags);
m_handle = dlopen(libname.fn_str(), rtldFlags);
#endif // __VMS || __DARWIN__ ?
#elif defined(HAVE_SHL_LOAD)
@@ -183,7 +184,7 @@ bool wxDynamicLibrary::Load(wxString libname, int flags)
{
shlFlags |= BIND_IMMEDIATE;
}
m_handle = shl_load(libname.c_str(), BIND_DEFERRED, 0);
m_handle = shl_load(libname.fn_str(), BIND_DEFERRED, 0);
#elif defined(__WINDOWS__)
m_handle = ::LoadLibrary(libname.c_str());
@@ -195,7 +196,14 @@ bool wxDynamicLibrary::Load(wxString libname, int flags)
{
wxString msg(_("Failed to load shared library '%s'"));
#if defined(HAVE_DLERROR) && !defined(__EMX__)
#if defined(__WXGTK__) && wxUSE_UNICODE
wxWCharBuffer buffer = wxConvLocal.cMB2WC( dlerror() );
const wxChar *err = buffer;
#else
const wxChar *err = dlerror();
#endif
if( err )
wxLogError( msg, err );
#else
@@ -252,10 +260,10 @@ void *wxDynamicLibrary::GetSymbol(const wxString &name, bool *success) const
DosQueryProcAddr( m_handle, 1L, name.c_str(), (PFN*)symbol );
#elif defined(HAVE_DLOPEN) || defined(__DARWIN__)
symbol = dlsym( m_handle, name.c_str() );
symbol = dlsym( m_handle, name.fn_str() );
#elif defined(HAVE_SHL_LOAD)
if( shl_findsym( &m_handle, name.c_str(), TYPE_UNDEFINED, &symbol ) != 0 )
if( shl_findsym( &m_handle, name.fn_str(), TYPE_UNDEFINED, &symbol ) != 0 )
symbol = 0;
#elif defined(__WINDOWS__)
@@ -269,7 +277,14 @@ void *wxDynamicLibrary::GetSymbol(const wxString &name, bool *success) const
{
wxString msg(_("wxDynamicLibrary failed to GetSymbol '%s'"));
#if defined(HAVE_DLERROR) && !defined(__EMX__)
#if defined(__WXGTK__) && wxUSE_UNICODE
wxWCharBuffer buffer = wxConvLocal.cMB2WC( dlerror() );
const wxChar *err = buffer;
#else
const wxChar *err = dlerror();
#endif
if( err )
{
failed = TRUE;

View File

@@ -1040,9 +1040,9 @@ wxConcatFiles (const wxString& file1, const wxString& file2, const wxString& fil
FILE *fp2 = (FILE *) NULL;
FILE *fp3 = (FILE *) NULL;
// Open the inputs and outputs
if ((fp1 = wxFopen (OS_FILENAME( file1 ), wxT("rb"))) == NULL ||
(fp2 = wxFopen (OS_FILENAME( file2 ), wxT("rb"))) == NULL ||
(fp3 = wxFopen (OS_FILENAME( outfile ), wxT("wb"))) == NULL)
if ((fp1 = wxFopen ( file1, wxT("rb"))) == NULL ||
(fp2 = wxFopen ( file2, wxT("rb"))) == NULL ||
(fp3 = wxFopen ( outfile, wxT("wb"))) == NULL)
{
if (fp1)
fclose (fp1);

View File

@@ -640,7 +640,7 @@ wxFileName::CreateTempFileName(const wxString& prefix, wxFile *fileTemp)
// can use the cast here because the length doesn't change and the string
// is not shared
int fdTemp = mkstemp((char *)path.mb_str());
int fdTemp = mkstemp((char*)(const char *)path.mb_str());
if ( fdTemp == -1 )
{
// this might be not necessary as mkstemp() on most systems should have
@@ -1601,7 +1601,7 @@ bool wxFileName::SetTimes(const wxDateTime *dtAccess,
utimbuf utm;
utm.actime = dtAccess ? dtAccess->GetTicks() : dtMod->GetTicks();
utm.modtime = dtMod ? dtMod->GetTicks() : dtAccess->GetTicks();
if ( utime(GetFullPath(), &utm) == 0 )
if ( utime(GetFullPath().fn_str(), &utm) == 0 )
{
return TRUE;
}
@@ -1639,7 +1639,7 @@ bool wxFileName::Touch()
{
#if defined(__UNIX_LIKE__)
// under Unix touching file is simple: just pass NULL to utime()
if ( utime(GetFullPath(), NULL) == 0 )
if ( utime(GetFullPath().fn_str(), NULL) == 0 )
{
return TRUE;
}
@@ -1660,7 +1660,7 @@ bool wxFileName::GetTimes(wxDateTime *dtAccess,
{
#if defined(__UNIX_LIKE__) || defined(__WXMAC__) || (defined(__DOS__) && defined(__WATCOMC__))
wxStructStat stBuf;
if ( wxStat(GetFullPath(), &stBuf) == 0 )
if ( wxStat(GetFullPath().fn_str(), &stBuf) == 0 )
{
if ( dtAccess )
dtAccess->Set(stBuf.st_atime);

View File

@@ -83,7 +83,7 @@ void wxMessageOutputStderr::Printf(const wxChar* format, ...)
out.PrintfV(format, args);
va_end(args);
fprintf(stderr, "%s", out.mb_str());
fprintf(stderr, "%s", (const char*) out.mb_str());
}
// ----------------------------------------------------------------------------
@@ -102,7 +102,7 @@ void wxMessageOutputMessageBox::Printf(const wxChar* format, ...)
va_end(args);
#ifndef __WXMSW__
out.Replace("\t"," ");
out.Replace(wxT("\t"),wxT(" "));
#endif
::wxMessageBox(out);
}

View File

@@ -260,7 +260,7 @@ bool wxTCPServer::Create(const wxString& serverName)
{
// ensure that the file doesn't exist as otherwise calling socket() would
// fail
int rc = remove(serverName);
int rc = remove(serverName.fn_str());
if ( rc < 0 && errno != ENOENT )
{
delete addr;
@@ -321,7 +321,7 @@ wxTCPServer::~wxTCPServer()
#ifdef __UNIX_LIKE__
if ( !m_filename.empty() )
{
if ( remove(m_filename) != 0 )
if ( remove(m_filename.fn_str()) != 0 )
{
wxLogDebug(_T("Stale AF_UNIX file '%s' left."), m_filename.c_str());
}

View File

@@ -328,12 +328,12 @@ bool wxTextCtrlBase::EmulateKeyPress(const wxKeyEvent& event)
break;
default:
if ( keycode < 256 && keycode >= 0 && isprint(keycode) )
if ( keycode < 256 && keycode >= 0 && wxIsprint(keycode) )
{
// FIXME this is not going to work for non letters...
if ( !event.ShiftDown() )
{
keycode = tolower(keycode);
keycode = wxTolower(keycode);
}
ch = (wxChar)keycode;

View File

@@ -115,9 +115,7 @@ license is as follows:
#include "wx/intl.h"
#include <string.h>
#ifdef __VISUALC__
#include <ctype.h>
#endif
#include "wx/xpmdecod.h"

View File

@@ -26,6 +26,8 @@
#if wxUSE_POSTSCRIPT
#include "wx/setup.h"
#include "wx/window.h"
#include "wx/dcmemory.h"
#include "wx/utils.h"
@@ -1577,7 +1579,7 @@ bool wxPostScriptDC::StartDoc( const wxString& message )
m_printData.SetFilename(filename);
}
m_pstream = wxFopen( m_printData.GetFilename().fn_str(), wxT("w+") );
m_pstream = wxFopen( m_printData.GetFilename().c_str(), wxT("w+") ); // FIXME: use fn_str() here under Unicode?
if (!m_pstream)
{
@@ -1748,7 +1750,10 @@ void wxPostScriptDC::EndDoc ()
argv[0] = WXSTRINGCAST previewCommand;
argv[1] = WXSTRINGCAST filename;
argv[2] = (wxChar*) NULL;
#if defined(__WXGTK20__) && wxUSE_UNICODE
#else
wxExecute( argv, TRUE );
#endif
wxRemoveFile( m_printData.GetFilename() );
}
break;
@@ -1766,7 +1771,10 @@ void wxPostScriptDC::EndDoc ()
argv[argc++] = WXSTRINGCAST filename;
argv[argc++] = (wxChar *) NULL;
#if defined(__WXGTK20__) && wxUSE_UNICODE
#else
wxExecute( argv, TRUE );
#endif
wxRemoveFile( filename );
}
break;

View File

@@ -29,6 +29,8 @@
#include "wx/log.h"
#endif
#include <ctype.h>
#include "wx/html/helpdata.h"
#include "wx/tokenzr.h"
#include "wx/wfstream.h"

View File

@@ -113,7 +113,19 @@ bool wxBitmapButton::Create(wxWindow *parent, wxWindowID id, const wxBitmap& bit
(XtPointer) this);
SetCanAddEventHandler(TRUE);
AttachWidget (parent, m_mainWidget, (WXWidget) NULL, pos.x, pos.y, size.x, size.y);
wxSize newSize = size;
if (m_buttonBitmap.Ok())
{
int border = (style & wxNO_BORDER) ? 4 : 10;
if (newSize.x == -1)
newSize.x = m_buttonBitmap.GetWidth()+border;
if (newSize.y == -1)
newSize.y = m_buttonBitmap.GetHeight()+border;
}
AttachWidget (parent, m_mainWidget, (WXWidget) NULL, pos.x, pos.y, newSize.x, newSize.y);
return TRUE;
}
@@ -262,3 +274,23 @@ void wxBitmapButton::ChangeBackgroundColour()
// Must reset the bitmaps since the colours have changed.
DoSetBitmap();
}
wxSize wxBitmapButton::DoGetBestSize() const
{
wxSize ret( 30,30 );
if (m_buttonBitmap.Ok())
{
int border = (GetWindowStyle() & wxNO_BORDER) ? 4 : 10;
ret.x = m_buttonBitmap.GetWidth()+border;
ret.y = m_buttonBitmap.GetHeight()+border;
}
if (!HasFlag(wxBU_EXACTFIT))
{
if (ret.x < 80) ret.x = 80;
}
return ret;
}

View File

@@ -719,10 +719,10 @@ wxDialUpManagerImpl::CheckIfconfig()
hasModem = strstr(output,"ipdptp") != (char *)NULL;
hasLAN = strstr(output, "hme") != (char *)NULL;
#elif defined(__LINUX__) || defined (__FREEBSD__)
hasModem = strstr(output,"ppp") // ppp
|| strstr(output,"sl") // slip
|| strstr(output,"pl"); // plip
hasLAN = strstr(output, "eth") != NULL;
hasModem = strstr(output.fn_str(),"ppp") // ppp
|| strstr(output.fn_str(),"sl") // slip
|| strstr(output.fn_str(),"pl"); // plip
hasLAN = strstr(output.fn_str(), "eth") != NULL;
#elif defined(__SGI__) // IRIX
hasModem = strstr(output, "ppp") != NULL; // PPP
#elif defined(__HPUX__)

View File

@@ -303,7 +303,7 @@ bool wxDir::HasSubDirs(const wxString& spec)
// caller will learn it soon enough when it calls GetFirst(wxDIR)
// anyhow
wxStructStat stBuf;
if ( wxStat(M_DIR->GetName(), &stBuf) == 0 )
if ( wxStat(M_DIR->GetName().fn_str(), &stBuf) == 0 )
{
switch ( stBuf.st_nlink )
{

View File

@@ -107,7 +107,12 @@ static bool ProcessFamiliesFromFontList(wxFontEnumerator *This,
{
char *font = fonts[n];
#if wxUSE_REGEX
#if wxUSE_UNICODE
wxString sfont( wxConvLocal.cMB2WC( font ) );
if ( !re.Matches(sfont) )
#else
if ( !re.Matches(font) )
#endif
#else // !wxUSE_REGEX
if ( !wxString(font).Matches(wxT("-*-*-*-*-*-*-*-*-*-*-*-*-*-*")) )
#endif // wxUSE_REGEX/!wxUSE_REGEX
@@ -120,7 +125,11 @@ static bool ProcessFamiliesFromFontList(wxFontEnumerator *This,
char *family = dash + 1;
dash = strchr(family, '-');
*dash = '\0'; // !NULL because Matches() above succeeded
#if wxUSE_UNICODE
wxString fam( wxConvLocal.cMB2WC( family ) );
#else
wxString fam(family);
#endif
if ( families.Index(fam) == wxNOT_FOUND )
{

View File

@@ -455,7 +455,7 @@ wxNativeFont wxLoadQueryNearestFont(int pointSize,
(void) tokenizer.NextToken();
newFontName += wxString::Format("%d-", pointSize);
newFontName += wxString::Format(wxT("%d-"), pointSize);
while(tokenizer.HasMoreTokens())
newFontName += tokenizer.GetNextToken();

View File

@@ -151,7 +151,7 @@ private:
LockResult wxSingleInstanceCheckerImpl::CreateLockFile()
{
// try to open the file
m_fdLock = open(m_nameLock,
m_fdLock = open(m_nameLock.fn_str(),
O_WRONLY | O_CREAT | O_EXCL,
S_IRUSR | S_IWUSR);
@@ -192,7 +192,7 @@ LockResult wxSingleInstanceCheckerImpl::CreateLockFile()
wxLogSysError(_("Failed to lock the lock file '%s'"),
m_nameLock.c_str());
unlink(m_nameLock);
unlink(m_nameLock.fn_str());
return LOCK_ERROR;
}
@@ -257,7 +257,7 @@ bool wxSingleInstanceCheckerImpl::Create(const wxString& name)
{
if ( kill(m_pidLocker, 0) != 0 )
{
if ( unlink(name) != 0 )
if ( unlink(name.fn_str()) != 0 )
{
wxLogError(_("Failed to remove stale lock file '%s'."),
name.c_str());
@@ -291,7 +291,7 @@ void wxSingleInstanceCheckerImpl::Unlock()
{
if ( m_fdLock != -1 )
{
if ( unlink(m_nameLock) != 0 )
if ( unlink(m_nameLock.fn_str()) != 0 )
{
wxLogSysError(_("Failed to remove lock file '%s'"),
m_nameLock.c_str());

View File

@@ -210,7 +210,7 @@ wxMutexInternal::wxMutexInternal(wxMutexType mutexType)
m_isOk = err == 0;
if ( !m_isOk )
{
wxLogApiError("pthread_mutex_init()", err);
wxLogApiError( wxT("pthread_mutex_init()"), err);
}
}
@@ -221,7 +221,7 @@ wxMutexInternal::~wxMutexInternal()
int err = pthread_mutex_destroy(&m_mutex);
if ( err != 0 )
{
wxLogApiError("pthread_mutex_destroy()", err);
wxLogApiError( wxT("pthread_mutex_destroy()"), err);
}
}
}

View File

@@ -253,7 +253,11 @@ long wxExecute( const wxString& command, int flags, wxProcess *process )
argv[argc] = NULL;
// do execute the command
#if wxUSE_UNICODE
long lRc = -1;
#else
long lRc = wxExecute(argv, flags, process);
#endif
// clean up
argc = 0;
@@ -1105,9 +1109,9 @@ bool wxGetDiskSpace(const wxString& path, wxLongLong *pTotal, wxLongLong *pFree)
#if defined(HAVE_STATFS) || defined(HAVE_STATVFS)
// the case to "char *" is needed for AIX 4.3
wxStatFs fs;
if ( statfs((char *)path.fn_str(), &fs) != 0 )
if ( statfs((char *)(const char*)path.fn_str(), &fs) != 0 )
{
wxLogSysError("Failed to get file system statistics");
wxLogSysError( wxT("Failed to get file system statistics") );
return FALSE;
}