From 1c193821a999730fbf6a9bea83763f37daae68f1 Mon Sep 17 00:00:00 2001 From: Julian Smart Date: Fri, 11 Jul 2003 11:21:47 +0000 Subject: [PATCH] More WinCE mods. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@21890 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- include/wx/msw/wince/setup.h | 54 ++++++----- include/wx/msw/wince/time.h | 38 ++++++++ src/common/appbase.cpp | 7 +- src/common/appcmn.cpp | 14 +-- src/common/cmndata.cpp | 11 ++- src/common/config.cpp | 4 + src/common/datetime.cpp | 2 +- src/common/dynlib.cpp | 10 +- src/common/encconv.cpp | 11 ++- src/common/file.cpp | 178 +++++++++++++++++++++++++++++++++-- src/common/fileconf.cpp | 2 +- src/common/filefn.cpp | 135 +++++++++++++++++++------- src/common/filename.cpp | 22 ++++- src/common/fmapbase.cpp | 5 + src/common/fontcmn.cpp | 6 ++ src/common/fontmap.cpp | 10 +- src/common/gdicmn.cpp | 11 ++- src/common/init.cpp | 9 ++ src/common/intl.cpp | 54 +++++++++-- src/common/list.cpp | 11 ++- src/common/log.cpp | 16 ++++ src/common/menucmn.cpp | 4 +- src/common/quantize.cpp | 1 + src/common/regex.cpp | 2 + src/common/stopwatch.cpp | 15 ++- src/common/strconv.cpp | 3 + src/common/string.cpp | 2 +- src/common/utilscmn.cpp | 4 + src/common/valtext.cpp | 4 +- src/common/wxchar.cpp | 7 +- src/common/xpmdecod.cpp | 4 +- src/generic/dirctrlg.cpp | 2 + src/generic/grid.cpp | 2 +- src/msw/wince/time.cpp | 132 ++++++++++++++++++++++++++ 34 files changed, 682 insertions(+), 110 deletions(-) create mode 100644 include/wx/msw/wince/time.h create mode 100644 src/msw/wince/time.cpp diff --git a/include/wx/msw/wince/setup.h b/include/wx/msw/wince/setup.h index 8f6f478237..a06174ec17 100644 --- a/include/wx/msw/wince/setup.h +++ b/include/wx/msw/wince/setup.h @@ -350,6 +350,10 @@ // Recommended setting: 1 #define wxUSE_CONFIG_NATIVE 1 +// Use wxFileConfig. +// Recommended setting: 1 +#define wxUSE_FILECONFIG 0 + // If wxUSE_DIALUP_MANAGER is 1, compile in wxDialUpManager class which allows // to connect/disconnect from the network and be notified whenever the dial-up // network connection is established/terminated. Requires wxUSE_DYNAMIC_LOADER. @@ -357,7 +361,7 @@ // Default is 1. // // Recommended setting: 1 -#define wxUSE_DIALUP_MANAGER 1 +#define wxUSE_DIALUP_MANAGER 0 // Compile in classes for run-time DLL loading and function calling. // Required by wxUSE_DIALUP_MANAGER. @@ -370,22 +374,22 @@ #define wxUSE_DYNLIB_CLASS 1 // experimental, don't use for now -#define wxUSE_DYNAMIC_LOADER 1 +#define wxUSE_DYNAMIC_LOADER 0 // Set to 1 to use socket classes -#define wxUSE_SOCKETS 1 +#define wxUSE_SOCKETS 0 // Set to 1 to enable virtual file systems (required by wxHTML) -#define wxUSE_FILESYSTEM 1 +#define wxUSE_FILESYSTEM 0 // Set to 1 to enable virtual ZIP filesystem (requires wxUSE_FILESYSTEM) -#define wxUSE_FS_ZIP 1 +#define wxUSE_FS_ZIP 0 // Set to 1 to enable virtual Internet filesystem (requires wxUSE_FILESYSTEM) -#define wxUSE_FS_INET 1 +#define wxUSE_FS_INET 0 // Set to 1 to compile wxZipInput/OutputStream classes. -#define wxUSE_ZIPSTREAM 1 +#define wxUSE_ZIPSTREAM 0 // Set to 1 to compile wxZlibInput/OutputStream classes. Also required by // wxUSE_LIBPNG. @@ -415,7 +419,7 @@ // Default is 1. // // Recommended setting: 1 -#define wxUSE_PROTOCOL 1 +#define wxUSE_PROTOCOL 0 // The settings for the individual URL schemes #define wxUSE_PROTOCOL_FILE 1 @@ -423,7 +427,7 @@ #define wxUSE_PROTOCOL_HTTP 1 // Define this to use wxURL class. -#define wxUSE_URL 1 +#define wxUSE_URL 0 // Support for regular expression matching via wxRegEx class: enable this to // use POSIX regular expressions in your code. You need to compile regex @@ -433,7 +437,7 @@ // // Recommended setting: 1 if your compiler supports it, if it doesn't please // contribute us a makefile for src/regex for it -#define wxUSE_REGEX 1 +#define wxUSE_REGEX 0 // wxSystemOptions class #define wxUSE_SYSTEM_OPTIONS 1 @@ -658,7 +662,7 @@ // Default is 1 // // Recommended setting: 1 (unless it really doesn't work) -#define wxUSE_COMMON_DIALOGS 1 +#define wxUSE_COMMON_DIALOGS 0 // wxBusyInfo displays window with message when app is busy. Works in same way // as wxBusyCursor @@ -761,7 +765,7 @@ #define wxUSE_MDI_ARCHITECTURE 1 // Set to 0 to disable print/preview architecture code -#define wxUSE_PRINTING_ARCHITECTURE 1 +#define wxUSE_PRINTING_ARCHITECTURE 0 // wxHTML sublibrary allows to display HTML in wxWindow programs and much, // much more. @@ -770,7 +774,7 @@ // // Recommended setting: 1 (wxHTML is great!), set to 0 if you want compile a // smaller library. -#define wxUSE_HTML 1 +#define wxUSE_HTML 0 // Setting wxUSE_GLCANVAS to 1 enables OpenGL support. You need to have OpenGL // headers and libraries to be able to compile the library with wxUSE_GLCANVAS @@ -838,13 +842,13 @@ // 0 for no interprocess comms #define wxUSE_HELP 0 // 0 for no help facility -#define wxUSE_MS_HTML_HELP 1 +#define wxUSE_MS_HTML_HELP 0 // 0 for no MS HTML Help // Use wxHTML-based help controller? #define wxUSE_WXHTML_HELP 0 -#define wxUSE_RESOURCES 1 +#define wxUSE_RESOURCES 0 // 0 for no wxGetResource/wxWriteResource #define wxUSE_CONSTRAINTS 1 // 0 for no window layout constraint system @@ -867,7 +871,7 @@ // Set to 0 to disable PostScript print/preview architecture code under Windows // (just use Windows printing). -#define wxUSE_POSTSCRIPT_ARCHITECTURE_IN_MSW 1 +#define wxUSE_POSTSCRIPT_ARCHITECTURE_IN_MSW 0 // ---------------------------------------------------------------------------- // database classes @@ -930,22 +934,22 @@ #define wxUSE_IMAGE 1 // Set to 1 for PNG format support (requires libpng). Also requires wxUSE_ZLIB. -#define wxUSE_LIBPNG 1 +#define wxUSE_LIBPNG 0 // Set to 1 for JPEG format support (requires libjpeg) -#define wxUSE_LIBJPEG 1 +#define wxUSE_LIBJPEG 0 // Set to 1 for TIFF format support (requires libtiff) -#define wxUSE_LIBTIFF 1 +#define wxUSE_LIBTIFF 0 // Set to 1 for GIF format support -#define wxUSE_GIF 1 +#define wxUSE_GIF 0 // Set to 1 for PNM format support -#define wxUSE_PNM 1 +#define wxUSE_PNM 0 // Set to 1 for PCX format support -#define wxUSE_PCX 1 +#define wxUSE_PCX 0 // Set to 1 for IFF format support (Amiga format) #define wxUSE_IFF 0 @@ -954,7 +958,7 @@ #define wxUSE_XPM 1 // Set to 1 for MS Icons and Cursors format support -#define wxUSE_ICO_CUR 1 +#define wxUSE_ICO_CUR 0 // Set to 1 to compile in wxPalette class #define wxUSE_PALETTE 1 @@ -1034,11 +1038,11 @@ #define wxUSE_OWNER_DRAWN 1 // Set to 1 to compile MS Windows XP theme engine support -#define wxUSE_UXTHEME 1 +#define wxUSE_UXTHEME 0 // Set to 1 to auto-adapt to MS Windows XP themes where possible // (notably, wxNotebook pages) -#define wxUSE_UXTHEME_AUTO 1 +#define wxUSE_UXTHEME_AUTO 0 // ---------------------------------------------------------------------------- // obsolete settings diff --git a/include/wx/msw/wince/time.h b/include/wx/msw/wince/time.h new file mode 100644 index 0000000000..f56f31bee8 --- /dev/null +++ b/include/wx/msw/wince/time.h @@ -0,0 +1,38 @@ + +/* + * time.h + * Missing time functions and structures for use under WinCE + */ + +#ifndef __WINCE_TIME_ +#define __WINCE_TIME_ + +struct tm { + int tm_sec; /* seconds after the minute - [0,59] */ + int tm_min; /* minutes after the hour - [0,59] */ + int tm_hour; /* hours since midnight - [0,23] */ + int tm_mday; /* day of the month - [1,31] */ + int tm_mon; /* months since January - [0,11] */ + int tm_year; /* years since 1900 */ + int tm_wday; /* days since Sunday - [0,6] */ + int tm_yday; /* days since January 1 - [0,365] */ + int tm_isdst; /* daylight savings time flag */ + }; + +struct tm * __cdecl localtime(const time_t *); + +time_t __cdecl time(time_t *); + +time_t __cdecl mktime(struct tm *); + +struct tm * __cdecl gmtime(const time_t *); + +#define _tcsftime wcsftime + +size_t __cdecl wcsftime(wchar_t *, size_t, const wchar_t *, + const struct tm *); + +extern long timezone; + +#endif + diff --git a/src/common/appbase.cpp b/src/common/appbase.cpp index 04304f3672..216d9b8647 100644 --- a/src/common/appbase.cpp +++ b/src/common/appbase.cpp @@ -40,9 +40,6 @@ #if wxUSE_FILENAME #include "wx/filename.h" #endif // wxUSE_FILENAME -#if wxUSE_FONTMAP - #include "wx/fontmap.h" -#endif // wxUSE_FONTMAP #include "wx/msgout.h" #include "wx/tokenzr.h" @@ -54,6 +51,10 @@ #include "wx/msw/private.h" // includes windows.h for MessageBox() #endif +#if wxUSE_FONTMAP + #include "wx/fontmap.h" +#endif // wxUSE_FONTMAP + #if defined(__WXMAC__) // VZ: MacTypes.h is enough under Mac OS X (where I could test it) but // I don't know which headers are needed under earlier systems so diff --git a/src/common/appcmn.cpp b/src/common/appcmn.cpp index 97c2f5eb2d..abc9545e04 100644 --- a/src/common/appcmn.cpp +++ b/src/common/appcmn.cpp @@ -40,13 +40,18 @@ #endif #include "wx/apptrait.h" -#if wxUSE_FONTMAP - #include "wx/fontmap.h" -#endif // wxUSE_FONTMAP #include "wx/msgout.h" #include "wx/thread.h" #include "wx/utils.h" +#if defined(__WXMSW__) + #include "wx/msw/private.h" // includes windows.h for LOGFONT +#endif + +#if wxUSE_FONTMAP + #include "wx/fontmap.h" +#endif // wxUSE_FONTMAP + // ============================================================================ // wxAppBase implementation // ============================================================================ @@ -85,9 +90,6 @@ bool wxAppBase::Initialize(int& argc, wxChar **argv) wxPendingEventsLocker = new wxCriticalSection; #endif - wxTheColourDatabase = new wxColourDatabase; - wxTheColourDatabase->Initialize(); - wxInitializeStockLists(); wxInitializeStockObjects(); diff --git a/src/common/cmndata.cpp b/src/common/cmndata.cpp index 08e3e0cf09..6e09c357b5 100644 --- a/src/common/cmndata.cpp +++ b/src/common/cmndata.cpp @@ -48,13 +48,12 @@ #endif // wxUSE_PRINTING_ARCHITECTURE #ifdef __WXMSW__ - #include + #include #include "wx/msw/private.h" - #if !defined(__WIN32__) - #include + #ifdef __WXWINCE__ #include - #endif // Win16 + #endif #if defined(__WATCOMC__) || defined(__SYMANTEC__) || defined(__SALFORDC__) #include @@ -327,7 +326,11 @@ void wxPrintData::ConvertToNative() pd.lStructSize = 66; #else memset(&pd, 0, sizeof(PRINTDLG)); +#ifdef __WXWINCE__ + pd.cbStruct = sizeof(PRINTDLG); +#else pd.lStructSize = sizeof(PRINTDLG); +#endif #endif pd.hwndOwner = (HWND)NULL; diff --git a/src/common/config.cpp b/src/common/config.cpp index 24c66d9e90..f9e071fee3 100644 --- a/src/common/config.cpp +++ b/src/common/config.cpp @@ -335,7 +335,11 @@ wxString wxExpandEnvVars(const wxString& str) wxString strVarName(str.c_str() + n + 1, m - n - 1); +#ifdef __WXWINCE__ + const wxChar *pszValue = NULL; +#else const wxChar *pszValue = wxGetenv(strVarName); +#endif if ( pszValue != NULL ) { strResult += pszValue; } diff --git a/src/common/datetime.cpp b/src/common/datetime.cpp index 6c87ccc236..ac737d6322 100644 --- a/src/common/datetime.cpp +++ b/src/common/datetime.cpp @@ -2668,7 +2668,7 @@ const wxChar *wxDateTime::ParseFormat(const wxChar *date, // parse the optional width size_t width = 0; - while ( isdigit(*++fmt) ) + while ( wxIsdigit(*++fmt) ) { width *= 10; width += *fmt - _T('0'); diff --git a/src/common/dynlib.cpp b/src/common/dynlib.cpp index 90945e8cae..a452cb2c82 100644 --- a/src/common/dynlib.cpp +++ b/src/common/dynlib.cpp @@ -99,7 +99,11 @@ const char *dlerror(void); // using LoadLibraryEx under Win32 to avoid name clash with LoadLibrary # ifdef __WIN32__ #ifdef _UNICODE +#ifdef __WXWINCE__ +# define wxDllOpen(lib) ::LoadLibrary(lib) +#else # define wxDllOpen(lib) ::LoadLibraryExW(lib, 0, 0) +#endif #else # define wxDllOpen(lib) ::LoadLibraryExA(lib, 0, 0) #endif @@ -323,7 +327,11 @@ void *wxDllLoader::GetSymbol(wxDllType dllHandle, const wxString &name, bool *su // mb_str() is necessary in Unicode build // // "void *" cast is needed by gcc 3.1 + w32api 1.4, don't ask me why - symbol = (void *)wxDllGetSymbol(dllHandle, name.mb_str()); +#ifdef __WXWINCE__ + symbol = (void *) wxDllGetSymbol(dllHandle, name.c_str()); +#else + symbol = (void *) wxDllGetSymbol(dllHandle, name.mb_str()); +#endif #endif // OS diff --git a/src/common/encconv.cpp b/src/common/encconv.cpp index 759dd58fa5..5ad6186464 100644 --- a/src/common/encconv.cpp +++ b/src/common/encconv.cpp @@ -37,6 +37,11 @@ typedef wchar_t tchar; typedef char tchar; #endif +#ifdef __WXWINCE__ +#undef LINKAGEMODE +#define LINKAGEMODE __cdecl +#endif + static wxUint16* LINKAGEMODE GetEncTable(wxFontEncoding enc) { for (int i = 0; encodings_list[i].table != NULL; i++) @@ -52,8 +57,6 @@ typedef struct { wxUint8 c; } CharsetItem; - - extern "C" int LINKAGEMODE CompareCharsetItems(const void *i1, const void *i2) { return ( ((CharsetItem*)i1) -> u - ((CharsetItem*)i2) -> u ); @@ -137,6 +140,8 @@ bool wxEncodingConverter::Init(wxFontEncoding input_enc, wxFontEncoding output_e for (i = 0; i < 128; i++) m_Table[128 + i] = (tchar)in_tbl[i]; return TRUE; } + // FIXME: write a substitute for bsearch +#ifndef __WXWINCE__ else { CharsetItem *rev = BuildReverseTable(out_tbl); @@ -163,6 +168,8 @@ bool wxEncodingConverter::Init(wxFontEncoding input_enc, wxFontEncoding output_e delete[] rev; return TRUE; } +#endif + return TRUE; } } diff --git a/src/common/file.cpp b/src/common/file.cpp index 04fd887a93..aca1dc4d26 100644 --- a/src/common/file.cpp +++ b/src/common/file.cpp @@ -28,7 +28,7 @@ #if wxUSE_FILE // standard -#if defined(__WXMSW__) && !defined(__GNUWIN32__) && !defined(__WXMICROWIN__) +#if defined(__WXMSW__) && !defined(__GNUWIN32__) && !defined(__WXMICROWIN__) && !defined(__WXWINCE__) #include #ifndef __SALFORDC__ @@ -54,6 +54,8 @@ #define NOMCX #endif +#elif defined(__WXMSW__) && defined(__WXWINCE__) + // TODO: what to include? #elif (defined(__UNIX__) || defined(__GNUWIN32__)) #include #include @@ -89,9 +91,14 @@ #endif //Win/UNIX #include // SEEK_xxx constants + +#ifndef __WXWINCE__ #include // O_RDONLY &c +#endif -#ifndef __MWERKS__ +#ifdef __WXWINCE__ +// Nothing +#elif !defined(__MWERKS__) #include // needed for stat #include // stat #elif defined(__MWERKS__) && ( defined(__WXMSW__) || defined(__MACH__) ) @@ -147,6 +154,10 @@ #include "wx/msw/mslu.h" #endif +#ifdef __WXWINCE__ + #include "wx/msw/private.h" +#endif + // ============================================================================ // implementation of wxFile // ============================================================================ @@ -183,7 +194,12 @@ bool wxFile::Access(const wxChar *name, OpenMode mode) break; } +#ifdef __WXWINCE__ + // FIXME: use CreateFile with 0 access to query the file + return TRUE; +#else return wxAccess(name, how) == 0; +#endif } // ---------------------------------------------------------------------------- @@ -208,11 +224,22 @@ bool wxFile::Create(const wxChar *szFileName, bool bOverwrite, int accessMode) // Dominic Mazzoni [dmazzoni+@cs.cmu.edu] reports that open is still broken on the mac, so we replace // int fd = open(wxUnix2MacFilename( szFileName ), O_CREAT | (bOverwrite ? O_TRUNC : O_EXCL), access); int fd = creat( szFileName , accessMode); +#else +#ifdef __WXWINCE__ + HANDLE fileHandle = ::CreateFile(szFileName, GENERIC_WRITE, 0, NULL, + bOverwrite ? CREATE_ALWAYS : CREATE_NEW, FILE_ATTRIBUTE_NORMAL, + 0); + int fd = 0; + if (fileHandle == INVALID_HANDLE_VALUE) + fd = (int) fileHandle; + else + fd = -1; #else int fd = wxOpen( szFileName, O_BINARY | O_WRONLY | O_CREAT | (bOverwrite ? O_TRUNC : O_EXCL) ACCESS(accessMode) ); +#endif #endif if ( fd == -1 ) { @@ -229,6 +256,59 @@ bool wxFile::Create(const wxChar *szFileName, bool bOverwrite, int accessMode) // open the file bool wxFile::Open(const wxChar *szFileName, OpenMode mode, int accessMode) { +#ifdef __WXWINCE__ + DWORD access = 0; + DWORD shareMode = 0; + DWORD disposition = 0; + + int flags = O_BINARY; + + switch ( mode ) + { + case read: + access = GENERIC_READ; + shareMode = FILE_SHARE_READ|FILE_SHARE_WRITE; + disposition = OPEN_EXISTING; + break; + + case write_append: + if ( wxFile::Exists(szFileName) ) + { + access = GENERIC_READ|GENERIC_WRITE; + shareMode = FILE_SHARE_READ; + disposition = 0; + break; + } + //else: fall through as write_append is the same as write if the + // file doesn't exist + + case write: + access = GENERIC_WRITE; + shareMode = 0; + disposition = TRUNCATE_EXISTING; + break; + + case write_excl: + access = GENERIC_WRITE; + shareMode = 0; + disposition = TRUNCATE_EXISTING; + break; + + case read_write: + access = GENERIC_READ|GENERIC_WRITE; + shareMode = 0; + disposition = 0; + break; + } + + int fd = 0; + HANDLE fileHandle = ::CreateFile(szFileName, access, shareMode, NULL, + disposition, FILE_ATTRIBUTE_NORMAL, 0); + if (fileHandle == INVALID_HANDLE_VALUE) + fd = -1; + else + fd = (int) fileHandle; +#else int flags = O_BINARY; switch ( mode ) @@ -260,6 +340,7 @@ bool wxFile::Open(const wxChar *szFileName, OpenMode mode, int accessMode) } int fd = wxOpen( szFileName, flags ACCESS(accessMode)); +#endif if ( fd == -1 ) { wxLogSysError(_("can't open file '%s'"), szFileName); @@ -275,7 +356,12 @@ bool wxFile::Open(const wxChar *szFileName, OpenMode mode, int accessMode) bool wxFile::Close() { if ( IsOpened() ) { - if ( close(m_fd) == -1 ) { +#ifdef __WXWINCE__ + if (!CloseHandle((HANDLE) m_fd)) +#else + if ( close(m_fd) == -1 ) +#endif + { wxLogSysError(_("can't close file descriptor %d"), m_fd); m_fd = fd_invalid; return FALSE; @@ -296,7 +382,14 @@ off_t wxFile::Read(void *pBuf, off_t nCount) { wxCHECK( (pBuf != NULL) && IsOpened(), 0 ); -#ifdef __MWERKS__ +#ifdef __WXWINCE__ + DWORD bytesRead = 0; + int iRc = 0; + if (ReadFile((HANDLE) m_fd, pBuf, (DWORD) nCount, & bytesRead, NULL)) + iRc = bytesRead; + else + iRc = -1; +#elif defined(__MWERKS__) int iRc = ::read(m_fd, (char*) pBuf, nCount); #else int iRc = ::read(m_fd, pBuf, nCount); @@ -314,7 +407,14 @@ size_t wxFile::Write(const void *pBuf, size_t nCount) { wxCHECK( (pBuf != NULL) && IsOpened(), 0 ); -#ifdef __MWERKS__ +#ifdef __WXWINCE__ + DWORD bytesRead = 0; + int iRc = 0; + if (WriteFile((HANDLE) m_fd, pBuf, (DWORD) nCount, & bytesRead, NULL)) + iRc = bytesRead; + else + iRc = -1; +#elif defined(__MWERKS__) #if __MSL__ >= 0x6000 int iRc = ::write(m_fd, (void*) pBuf, nCount); #else @@ -336,7 +436,9 @@ size_t wxFile::Write(const void *pBuf, size_t nCount) bool wxFile::Flush() { if ( IsOpened() ) { -#if defined(__VISUALC__) || wxHAVE_FSYNC +#ifdef __WXWINCE__ + // Do nothing +#elif defined(__VISUALC__) || wxHAVE_FSYNC if ( wxFsync(m_fd) == -1 ) { wxLogSysError(_("can't flush file descriptor %d"), m_fd); @@ -359,6 +461,34 @@ off_t wxFile::Seek(off_t ofs, wxSeekMode mode) { wxASSERT( IsOpened() ); +#ifdef __WXWINCE__ + int origin; + switch ( mode ) { + default: + wxFAIL_MSG(_("unknown seek origin")); + + case wxFromStart: + origin = FILE_BEGIN; + break; + + case wxFromCurrent: + origin = FILE_CURRENT; + break; + + case wxFromEnd: + origin = FILE_END; + break; + } + + DWORD res = SetFilePointer((HANDLE) m_fd, ofs, 0, origin) ; + if (res == 0xFFFFFFFF && GetLastError() != NO_ERROR) + { + wxLogSysError(_("can't seek on file descriptor %d"), m_fd); + return wxInvalidOffset; + } + else + return (off_t)res; +#else int origin; switch ( mode ) { default: @@ -384,6 +514,7 @@ off_t wxFile::Seek(off_t ofs, wxSeekMode mode) } else return (off_t)iRc; +#endif } // get current off_t @@ -391,6 +522,16 @@ off_t wxFile::Tell() const { wxASSERT( IsOpened() ); +#ifdef __WXWINCE__ + DWORD res = SetFilePointer((HANDLE) m_fd, 0, 0, FILE_CURRENT) ; + if (res == 0xFFFFFFFF && GetLastError() != NO_ERROR) + { + wxLogSysError(_("can't get seek position on file descriptor %d"), m_fd); + return wxInvalidOffset; + } + else + return (off_t)res; +#else int iRc = wxTell(m_fd); if ( iRc == -1 ) { wxLogSysError(_("can't get seek position on file descriptor %d"), m_fd); @@ -398,6 +539,7 @@ off_t wxFile::Tell() const } else return (off_t)iRc; +#endif } // get current file length @@ -405,6 +547,15 @@ off_t wxFile::Length() const { wxASSERT( IsOpened() ); +#ifdef __WXWINCE__ + DWORD off0 = SetFilePointer((HANDLE) m_fd, 0, 0, FILE_CURRENT); + DWORD off1 = SetFilePointer((HANDLE) m_fd, 0, 0, FILE_END); + off_t len = off1; + + // Restore position + SetFilePointer((HANDLE) m_fd, off0, 0, FILE_BEGIN); + return len; +#else #ifdef __VISUALC__ int iRc = _filelength(m_fd); #else // !VC++ @@ -430,6 +581,7 @@ off_t wxFile::Length() const } else return (off_t)iRc; +#endif } // is end of file reached? @@ -437,6 +589,17 @@ bool wxFile::Eof() const { wxASSERT( IsOpened() ); +#ifdef __WXWINCE__ + DWORD off0 = SetFilePointer((HANDLE) m_fd, 0, 0, FILE_CURRENT); + DWORD off1 = SetFilePointer((HANDLE) m_fd, 0, 0, FILE_END); + if (off0 == off1) + return TRUE; + else + { + SetFilePointer((HANDLE) m_fd, off0, 0, FILE_BEGIN); + return FALSE; + } +#else int iRc; #if defined(__DOS__) || defined(__UNIX__) || defined(__GNUWIN32__) || defined( __MWERKS__ ) || defined(__SALFORDC__) @@ -467,6 +630,7 @@ bool wxFile::Eof() const } return TRUE; +#endif } // ============================================================================ @@ -553,7 +717,7 @@ bool wxTempFile::Commit() return FALSE; } - if ( wxRename(m_strTemp, m_strName) != 0 ) { + if ( wxRenameFile(m_strTemp, m_strName) != 0 ) { wxLogSysError(_("can't commit changes to file '%s'"), m_strName.c_str()); return FALSE; } diff --git a/src/common/fileconf.cpp b/src/common/fileconf.cpp index 3e39151ade..6babd6ea78 100644 --- a/src/common/fileconf.cpp +++ b/src/common/fileconf.cpp @@ -24,7 +24,7 @@ #pragma hdrstop #endif //__BORLANDC__ -#if wxUSE_CONFIG +#if wxUSE_CONFIG && wxUSE_FILECONFIG #ifndef WX_PRECOMP #include "wx/string.h" diff --git a/src/common/filefn.cpp b/src/common/filefn.cpp index 40af10e79a..3ccac13183 100644 --- a/src/common/filefn.cpp +++ b/src/common/filefn.cpp @@ -54,9 +54,16 @@ #include "wx/mac/private.h" // includes mac headers #endif +#ifdef __WXWINCE__ +#include "wx/msw/wince/time.h" +#include "wx/msw/private.h" +#else #include +#endif -#ifndef __MWERKS__ +#ifdef __WXWINCE__ +// Nothing +#elif !defined(__MWERKS__) #include #include #else @@ -84,7 +91,7 @@ #include "wx/os2/private.h" #endif #if defined(__WINDOWS__) && !defined(__WXMICROWIN__) -#if !defined( __GNUWIN32__ ) && !defined( __MWERKS__ ) && !defined(__SALFORDC__) +#if !defined( __GNUWIN32__ ) && !defined( __MWERKS__ ) && !defined(__SALFORDC__) && !defined(__WXWINCE__) #include #include #include @@ -254,6 +261,8 @@ void wxPathList::Add (const wxString& path) // Add paths e.g. from the PATH environment variable void wxPathList::AddEnvList (const wxString& envVariable) { + // No environment variables on WinCE +#ifndef __WXWINCE__ static const wxChar PATH_TOKS[] = #ifdef __WINDOWS__ /* @@ -292,6 +301,7 @@ void wxPathList::AddEnvList (const wxString& envVariable) delete [] s; } +#endif } // Given a full filename (with path), ensure that that file can @@ -632,6 +642,8 @@ wxChar *wxExpandPath(wxChar *buf, const wxChar *name) } else # endif #endif + // No env variables on WinCE +#ifndef __WXWINCE__ #ifdef __WXMSW__ if (*s++ == wxT('$') && (*s == wxT('{') || *s == wxT(')'))) #else @@ -659,6 +671,8 @@ wxChar *wxExpandPath(wxChar *buf, const wxChar *name) s++; } } +#endif + // __WXWINCE__ } /* Expand ~ and ~user */ @@ -738,6 +752,7 @@ wxContractPath (const wxString& filename, const wxString& envname, const wxStrin // Handle environment const wxChar *val = (const wxChar *) NULL; +#ifndef __WXWINCE__ wxChar *tcp = (wxChar *) NULL; if (envname != WXSTRINGCAST NULL && (val = wxGetenv (WXSTRINGCAST envname)) != NULL && (tcp = wxStrstr (dest, val)) != NULL) @@ -749,6 +764,7 @@ wxContractPath (const wxString& filename, const wxString& envname, const wxStrin wxStrcat (tcp, wxT("}")); wxStrcat (tcp, wxFileFunctionsBuffer); } +#endif // Handle User's home (ignore root homes!) size_t len = 0; @@ -1283,9 +1299,11 @@ wxCopyFile (const wxString& file1, const wxString& file2, bool overwrite) bool wxRenameFile (const wxString& file1, const wxString& file2) { - // Normal system call +#ifndef __WXWINCE__ + // Normal system call if ( wxRename (file1, file2) == 0 ) return TRUE; +#endif // Try to copy if (wxCopyFile(file1, file2)) { @@ -1340,7 +1358,11 @@ bool wxMkdir(const wxString& dir, int perm) #endif #else // !MSW, !DOS and !OS/2 VAC++ (void)perm; +#ifdef __WXWINCE__ + if ( !CreateDirectory(dirname, NULL) ) +#else if ( wxMkDir(wxFNSTRINGCAST wxFNCONV(dirname)) != 0 ) +#endif #endif // !MSW/MSW { wxLogSysError(_("Directory '%s' couldn't be created"), dirname); @@ -1355,15 +1377,15 @@ bool wxMkdir(const wxString& dir, int perm) bool wxRmdir(const wxString& dir, int WXUNUSED(flags)) { #ifdef __VMS__ - return FALSE; //to be changed since rmdir exists in VMS7.x + return FALSE; //to be changed since rmdir exists in VMS7.x #elif defined(__WXPM__) - return (::DosDeleteDir((PSZ)dir.c_str()) == 0); + return (::DosDeleteDir((PSZ)dir.c_str()) == 0); #else -#ifdef __SALFORDC__ - return FALSE; // What to do? +#ifdef __WXWINCE__ + return (CreateDirectory(dir, NULL) != 0); #else - return (wxRmDir(OS_FILENAME(dir)) == 0); + return (wxRmDir(OS_FILENAME(dir)) == 0); #endif #endif @@ -1492,6 +1514,9 @@ wxString wxFindNextFile() // copies into buf. wxChar *wxGetWorkingDirectory(wxChar *buf, int sz) { +#ifdef __WXWINCE__ + return NULL; +#else if ( !buf ) { buf = new wxChar[sz + 1]; @@ -1607,6 +1632,9 @@ wxChar *wxGetWorkingDirectory(wxChar *buf, int sz) #if !wxUSE_UNICODE #undef cbuf #endif + +#endif + // __WXWINCE__ } wxString wxGetCwd() @@ -1622,37 +1650,42 @@ wxString wxGetCwd() bool wxSetWorkingDirectory(const wxString& d) { #if defined(__UNIX__) || defined(__WXMAC__) || defined(__DOS__) - return (chdir(wxFNSTRINGCAST d.fn_str()) == 0); + return (chdir(wxFNSTRINGCAST d.fn_str()) == 0); #elif defined(__WXPM__) - return (::DosSetCurrentDir((PSZ)d.c_str()) == 0); + return (::DosSetCurrentDir((PSZ)d.c_str()) == 0); #elif defined(__WINDOWS__) - + #ifdef __WIN32__ - return (bool)(SetCurrentDirectory(d) != 0); +#ifdef __WXWINCE__ + // No equivalent in WinCE + return FALSE; #else - // Must change drive, too. - bool isDriveSpec = ((strlen(d) > 1) && (d[1] == ':')); - if (isDriveSpec) - { - wxChar firstChar = d[0]; - - // To upper case - if (firstChar > 90) - firstChar = firstChar - 32; - - // To a drive number - unsigned int driveNo = firstChar - 64; - if (driveNo > 0) + return (bool)(SetCurrentDirectory(d) != 0); +#endif +#else + // Must change drive, too. + bool isDriveSpec = ((strlen(d) > 1) && (d[1] == ':')); + if (isDriveSpec) { - unsigned int noDrives; - _dos_setdrive(driveNo, &noDrives); + wxChar firstChar = d[0]; + + // To upper case + if (firstChar > 90) + firstChar = firstChar - 32; + + // To a drive number + unsigned int driveNo = firstChar - 64; + if (driveNo > 0) + { + unsigned int noDrives; + _dos_setdrive(driveNo, &noDrives); + } } - } - bool success = (chdir(WXSTRINGCAST d) == 0); - - return success; + bool success = (chdir(WXSTRINGCAST d) == 0); + + return success; #endif - + #endif } @@ -1660,7 +1693,9 @@ bool wxSetWorkingDirectory(const wxString& d) // On non-Windows platform, probably just return the empty string. wxString wxGetOSDirectory() { -#if defined(__WINDOWS__) && !defined(__WXMICROWIN__) +#ifdef __WXWINCE__ + return wxString(wxT("\\Windows")); +#elif defined(__WINDOWS__) && !defined(__WXMICROWIN__) wxChar buf[256]; GetWindowsDirectory(buf, 256); return wxString(buf); @@ -1733,10 +1768,44 @@ void WXDLLEXPORT wxSplitPath(const wxChar *pszFileName, time_t WXDLLEXPORT wxFileModificationTime(const wxString& filename) { +#ifdef __WXWINCE__ + FILETIME creationTime, lastAccessTime, lastWriteTime; + HANDLE fileHandle = ::CreateFile(filename, GENERIC_READ, FILE_SHARE_READ, NULL, + 0, FILE_ATTRIBUTE_NORMAL, 0); + if (fileHandle == INVALID_HANDLE_VALUE) + return 0; + else + { + if (GetFileTime(fileHandle, & creationTime, & lastAccessTime, & lastWriteTime)) + { + CloseHandle(fileHandle); + + wxDateTime dateTime; + FILETIME ftLocal; + if ( !::FileTimeToLocalFileTime(&lastWriteTime, &ftLocal) ) + { + wxLogLastError(_T("FileTimeToLocalFileTime")); + } + + SYSTEMTIME st; + if ( !::FileTimeToSystemTime(&ftLocal, &st) ) + { + wxLogLastError(_T("FileTimeToSystemTime")); + } + + dateTime.Set(st.wDay, wxDateTime::Month(st.wMonth - 1), st.wYear, + st.wHour, st.wMinute, st.wSecond, st.wMilliseconds); + return dateTime.GetTicks(); + } + else + return 0; + } +#else wxStructStat buf; wxStat( filename, &buf); return buf.st_mtime; +#endif } diff --git a/src/common/filename.cpp b/src/common/filename.cpp index e53a24eafe..181b06705e 100644 --- a/src/common/filename.cpp +++ b/src/common/filename.cpp @@ -90,6 +90,10 @@ #include "wx/msw/winundef.h" #endif +#ifdef __WXWINCE__ +#include "wx/msw/private.h" +#endif + #if defined(__WXMAC__) #include "wx/mac/private.h" // includes mac headers #endif @@ -564,8 +568,22 @@ wxFileName::CreateTempFileName(const wxString& prefix, wxFile *fileTemp) // use the directory specified by the prefix SplitPath(prefix, &dir, &name, NULL /* extension */); -#if defined(__WINDOWS__) && !defined(__WXMICROWIN__) +#if defined(__WXWINCE__) + if (dir.empty()) + { + // FIXME. Create \temp dir? + dir = wxT("\\"); + } + path = dir + wxT("\\") + prefix; + int i = 1; + while (wxFileExists(path)) + { + path = dir + wxT("\\") + prefix ; + path << i; + i ++; + } +#elif defined(__WINDOWS__) && !defined(__WXMICROWIN__) #ifdef __WIN32__ if ( dir.empty() ) { @@ -1284,7 +1302,7 @@ wxString wxFileName::GetFullPath( wxPathFormat format ) const // Return the short form of the path (returns identity on non-Windows platforms) wxString wxFileName::GetShortPath() const { -#if defined(__WXMSW__) && defined(__WIN32__) && !defined(__WXMICROWIN__) +#if defined(__WXMSW__) && defined(__WIN32__) && !defined(__WXMICROWIN__) && !defined(__WXWINCE__) wxString path(GetFullPath()); wxString pathOut; DWORD sz = ::GetShortPathName(path, NULL, 0); diff --git a/src/common/fmapbase.cpp b/src/common/fmapbase.cpp index 7d6cb2f11e..fa6dcd0d65 100644 --- a/src/common/fmapbase.cpp +++ b/src/common/fmapbase.cpp @@ -32,6 +32,11 @@ #include "wx/intl.h" #endif //WX_PRECOMP +#if defined(__WXMSW__) + #include "wx/msw/private.h" // includes windows.h for LOGFONT + #include "wx/msw/winundef.h" +#endif + #include "wx/fontmap.h" #include "wx/fmappriv.h" diff --git a/src/common/fontcmn.cpp b/src/common/fontcmn.cpp index d448cd6238..764a4ed47e 100644 --- a/src/common/fontcmn.cpp +++ b/src/common/fontcmn.cpp @@ -34,6 +34,12 @@ #endif // WX_PRECOMP #include "wx/gdicmn.h" + +#if defined(__WXMSW__) + #include "wx/msw/private.h" // includes windows.h for LOGFONT + #include "wx/msw/winundef.h" +#endif + #include "wx/fontutil.h" // for wxNativeFontInfo #include "wx/fontmap.h" diff --git a/src/common/fontmap.cpp b/src/common/fontmap.cpp index d858e43dd0..171639e6e3 100644 --- a/src/common/fontmap.cpp +++ b/src/common/fontmap.cpp @@ -36,13 +36,17 @@ #include "wx/intl.h" #endif // PCH -#include "wx/fontmap.h" -#include "wx/fmappriv.h" - #if wxUSE_CONFIG #include "wx/config.h" #endif // wxUSE_CONFIG +#if defined(__WXMSW__) + #include "wx/msw/private.h" // includes windows.h for LOGFONT + #include "wx/msw/winundef.h" +#endif + +#include "wx/fontmap.h" +#include "wx/fmappriv.h" #include "wx/fontutil.h" #include "wx/msgdlg.h" #include "wx/fontdlg.h" diff --git a/src/common/gdicmn.cpp b/src/common/gdicmn.cpp index 7bf932f207..445f18f4c5 100644 --- a/src/common/gdicmn.cpp +++ b/src/common/gdicmn.cpp @@ -436,10 +436,13 @@ wxString wxColourDatabase::FindName (const wxColour& colour) const void wxInitializeStockLists() { - wxTheBrushList = new wxBrushList; - wxThePenList = new wxPenList; - wxTheFontList = new wxFontList; - wxTheBitmapList = new wxBitmapList; + wxTheColourDatabase = new wxColourDatabase; + wxTheColourDatabase->Initialize(); + + wxTheBrushList = new wxBrushList; + wxThePenList = new wxPenList; + wxTheFontList = new wxFontList; + wxTheBitmapList = new wxBitmapList; } void wxInitializeStockObjects () diff --git a/src/common/init.cpp b/src/common/init.cpp index c25c12cd86..fe406b7be9 100644 --- a/src/common/init.cpp +++ b/src/common/init.cpp @@ -426,6 +426,11 @@ int wxEntryReal(int& argc, wxChar **argv) // OnFatalException() if necessary #if defined(__WXMSW__) && wxUSE_ON_FATAL_EXCEPTION +#ifdef __WXWINCE__ +// For ExitThread +#include "wx/msw/private.h" +#endif + extern unsigned long wxGlobalSEHandler(); int wxEntry(int& argc, wxChar **argv) @@ -436,7 +441,11 @@ int wxEntry(int& argc, wxChar **argv) } __except ( wxGlobalSEHandler() ) { +#ifdef __WXWINCE__ + ::ExitThread(3); // the same exit code as abort() +#else ::ExitProcess(3); // the same exit code as abort() +#endif #if !defined(_MSC_VER) || _MSC_VER < 1300 // this code is unreachable but put it here to suppress warnings diff --git a/src/common/intl.cpp b/src/common/intl.cpp index b8d28fdb0d..aef903c92b 100644 --- a/src/common/intl.cpp +++ b/src/common/intl.cpp @@ -31,7 +31,11 @@ #if wxUSE_INTL // standard headers + +#ifndef __WXWINCE__ #include +#endif + #include #include #ifdef HAVE_LANGINFO_H @@ -48,6 +52,12 @@ #include "wx/dynarray.h" #endif // WX_PRECOMP +#ifdef __WIN32__ + #include "wx/msw/private.h" +#elif defined(__UNIX_LIKE__) + #include "wx/fontmap.h" // for CharsetToEncoding() +#endif + #include "wx/file.h" #include "wx/tokenzr.h" #include "wx/module.h" @@ -55,12 +65,6 @@ #include "wx/encconv.h" #include "wx/hashmap.h" -#ifdef __WIN32__ - #include "wx/msw/private.h" -#elif defined(__UNIX_LIKE__) - #include "wx/fontmap.h" // for CharsetToEncoding() -#endif - #if defined(__WXMAC__) #include "wx/mac/private.h" // includes mac headers #endif @@ -308,9 +312,11 @@ static wxString GetFullSearchPath(const wxChar *lang) // LC_PATH is a standard env var containing the search path for the .mo // files +#ifndef __WXWINCE__ const wxChar *pszLcPath = wxGetenv(wxT("LC_PATH")); if ( pszLcPath != NULL ) searchPath << GetAllMsgCatalogSubdirs(pszLcPath, lang); +#endif #ifdef __UNIX__ // add some standard ones and the one in the tree where wxWin was installed: @@ -626,7 +632,24 @@ bool wxLocale::Init(const wxChar *szName, wxCHECK_MSG( szLocale, FALSE, _T("no locale to set in wxLocale::Init()") ); } +#ifdef __WXWINCE__ + // FIXME: I'm guessing here + wxChar localeName[256]; + int ret = GetLocaleInfo(LOCALE_USER_DEFAULT, LOCALE_SLANGUAGE, localeName, + 256); + if (ret != 0) + { + m_pszOldLocale = wxStrdup(localeName); + } + else + m_pszOldLocale = NULL; + + // TODO: how to find languageId + // SetLocaleInfo(languageId, SORT_DEFAULT, localeName); +#else m_pszOldLocale = wxStrdup(wxSetlocale(LC_ALL, szLocale)); +#endif + if ( m_pszOldLocale == NULL ) wxLogError(_("locale '%s' can not be set."), szLocale); @@ -768,7 +791,10 @@ bool wxLocale::Init(int language, int flags) int codepage = -1; wxUint32 lcid = MAKELCID(MAKELANGID(info->WinLang, info->WinSublang), SORT_DEFAULT); + // FIXME +#ifndef __WXWINCE__ SetThreadLocale(lcid); +#endif // NB: we must translate LCID to CRT's setlocale string ourselves, // because SetThreadLocale does not modify change the // interpretation of setlocale(LC_ALL, "") call: @@ -792,7 +818,10 @@ bool wxLocale::Init(int language, int flags) } else { + // FIXME +#ifndef __WXWINCE__ retloc = wxSetlocale(LC_ALL, locale); +#endif #ifdef SETLOCALE_FAILS_ON_UNICODE_LANGS if (codepage == 0 && (const wxChar*)retloc == NULL) { @@ -804,7 +833,12 @@ bool wxLocale::Init(int language, int flags) } else { + // FIXME +#ifndef __WXWINCE__ retloc = wxSetlocale(LC_ALL, wxEmptyString); +#else + retloc = NULL; +#endif #ifdef SETLOCALE_FAILS_ON_UNICODE_LANGS if ((const wxChar*)retloc == NULL) { @@ -1524,7 +1558,12 @@ const wxLanguageInfo *wxLocale::FindLanguageInfo(const wxString& locale) wxString wxLocale::GetSysName() const { + // FIXME +#ifndef __WXWINCE__ return wxSetlocale(LC_ALL, NULL); +#else + return wxEmptyString; +#endif } // clean up @@ -1540,7 +1579,10 @@ wxLocale::~wxLocale() // restore old locale wxSetLocale(m_pOldLocale); + // FIXME +#ifndef __WXWINCE__ wxSetlocale(LC_ALL, m_pszOldLocale); +#endif free((wxChar *)m_pszOldLocale); // const_cast } diff --git a/src/common/list.cpp b/src/common/list.cpp index 62200c7e5e..8c6d14fdba 100644 --- a/src/common/list.cpp +++ b/src/common/list.cpp @@ -519,7 +519,11 @@ void wxListBase::Sort(const wxSortCompareFunction compfunc) } // sort the array - qsort((void *)objArray,num,sizeof(wxObject *),compfunc); + qsort((void *)objArray,num,sizeof(wxObject *), +#ifdef __WXWINCE__ + (int (__cdecl *)(const void *,const void *)) +#endif + compfunc); // put the sorted pointers back into the list objPtr = objArray; @@ -722,7 +726,12 @@ bool wxStringList::Member(const wxChar *s) const return FALSE; } +#ifdef __WXWINCE__ +extern "C" int __cdecl +#else extern "C" int LINKAGEMODE +#endif + wx_comparestrings(const void *arg1, const void *arg2) { wxChar **s1 = (wxChar **) arg1; diff --git a/src/common/log.cpp b/src/common/log.cpp index 897ee542a5..0b2c63a205 100644 --- a/src/common/log.cpp +++ b/src/common/log.cpp @@ -48,9 +48,17 @@ #include "wx/wxchar.h" // other standard headers +#ifndef __WXWINCE__ #include +#endif + #include + +#ifndef __WXWINCE__ #include +#else +#include "wx/msw/wince/time.h" +#endif #if defined(__WINDOWS__) #include "wx/msw/private.h" // includes windows.h @@ -179,7 +187,11 @@ void wxVLogFatalError(const wxChar *szFormat, va_list argptr) wxSafeShowMessage(_T("Fatal Error"), s_szBuf); +#ifdef __WXWINCE__ + ExitThread(3); +#else abort(); +#endif } void wxLogFatalError(const wxChar *szFormat, ...) @@ -455,7 +467,11 @@ void wxLog::DoLog(wxLogLevel level, const wxChar *szString, time_t t) DoLogString(wxString(_("Fatal error: ")) + szString, t); DoLogString(_("Program aborted."), t); Flush(); +#ifdef __WXWINCE__ + ExitThread(3); +#else abort(); +#endif break; case wxLOG_Error: diff --git a/src/common/menucmn.cpp b/src/common/menucmn.cpp index 221de1a5b2..0a00187d3b 100644 --- a/src/common/menucmn.cpp +++ b/src/common/menucmn.cpp @@ -151,9 +151,9 @@ wxAcceleratorEntry *wxGetAccelFromString(const wxString& label) } else { // is it a function key? - if ( current[0U] == 'f' && isdigit(current[1U]) && + if ( current[0U] == 'f' && wxIsdigit(current[1U]) && (current.Len() == 2 || - (current.Len() == 3 && isdigit(current[2U]))) ) { + (current.Len() == 3 && wxIsdigit(current[2U]))) ) { int n; wxSscanf(current.c_str() + 1, wxT("%d"), &n); diff --git a/src/common/quantize.cpp b/src/common/quantize.cpp index d3d894f41a..3b2f3dc9a1 100644 --- a/src/common/quantize.cpp +++ b/src/common/quantize.cpp @@ -50,6 +50,7 @@ #ifdef __WXMSW__ #include +#include "wx/msw/private.h" #endif #include diff --git a/src/common/regex.cpp b/src/common/regex.cpp index e96257c8b6..62ffa7c781 100644 --- a/src/common/regex.cpp +++ b/src/common/regex.cpp @@ -43,7 +43,9 @@ #include #endif +#ifndef __WXWINCE__ #include +#endif #include "wx/regex.h" diff --git a/src/common/stopwatch.cpp b/src/common/stopwatch.cpp index 21cd161679..f114953332 100644 --- a/src/common/stopwatch.cpp +++ b/src/common/stopwatch.cpp @@ -44,7 +44,7 @@ #include #endif -#if defined(__WIN32__) && !defined(HAVE_FTIME) && !defined(__MWERKS__) +#if defined(__WIN32__) && !defined(HAVE_FTIME) && !defined(__MWERKS__) && !defined(__WXWINCE__) #define HAVE_FTIME #endif @@ -60,8 +60,14 @@ # undef HAVE_GETTIMEOFDAY #endif +#ifndef __WXWINCE__ #include -#ifndef __WXMAC__ +#else +#include "wx/msw/private.h" +#include "wx/msw/wince/time.h" +#endif + +#if !defined(__WXMAC__) && !defined(__WXWINCE__) #include // for time_t #endif @@ -313,11 +319,16 @@ wxLongLong wxGetLocalTimeMillis() val *= wxGetLocalTime(); // GRG: This will go soon as all WIN32 seem to have ftime +// JACS: unfortunately not. WinCE doesn't have it. #if defined (__WIN32__) // If your platform/compiler needs to use two different functions // to get ms resolution, please do NOT just shut off these warnings, // drop me a line instead at + + // FIXME +#ifndef __WXWINCE__ #warning "Possible clock skew bug in wxGetLocalTimeMillis()!" +#endif SYSTEMTIME st; ::GetLocalTime(&st); diff --git a/src/common/strconv.cpp b/src/common/strconv.cpp index 7e7b6efff5..68c41c7148 100644 --- a/src/common/strconv.cpp +++ b/src/common/strconv.cpp @@ -37,7 +37,10 @@ #include "wx/msw/private.h" #endif +#ifndef __WXWINCE__ #include +#endif + #include #include #include diff --git a/src/common/string.cpp b/src/common/string.cpp index 29d51e71b8..7ac3f254a2 100644 --- a/src/common/string.cpp +++ b/src/common/string.cpp @@ -1017,7 +1017,7 @@ bool wxString::IsAscii() const { const wxChar *s = (const wxChar*) *this; while(*s){ - if(!isascii(*s)) return(FALSE); + if(!wxIsascii(*s)) return(FALSE); s++; } return(TRUE); diff --git a/src/common/utilscmn.cpp b/src/common/utilscmn.cpp index eefe29c5c9..3a131a372f 100644 --- a/src/common/utilscmn.cpp +++ b/src/common/utilscmn.cpp @@ -73,7 +73,11 @@ #include "wx/statusbr.h" #endif // wxUSE_GUI +#ifndef __WXWINCE__ #include +#else +#include "wx/msw/wince/time.h" +#endif #ifndef __MWERKS__ #include diff --git a/src/common/valtext.cpp b/src/common/valtext.cpp index 35b6613421..7ca1758c3d 100644 --- a/src/common/valtext.cpp +++ b/src/common/valtext.cpp @@ -246,7 +246,7 @@ void wxTextValidator::OnChar(wxKeyEvent& event) ( ((m_validatorStyle & wxFILTER_INCLUDE_CHAR_LIST) && !IsInCharIncludeList(wxString((char) keyCode, 1))) || ((m_validatorStyle & wxFILTER_EXCLUDE_CHAR_LIST) && !IsNotInCharExcludeList(wxString((char) keyCode, 1))) || - ((m_validatorStyle & wxFILTER_ASCII) && !isascii(keyCode)) || + ((m_validatorStyle & wxFILTER_ASCII) && !wxIsascii(keyCode)) || ((m_validatorStyle & wxFILTER_ALPHA) && !wxIsalpha(keyCode)) || ((m_validatorStyle & wxFILTER_ALPHANUMERIC) && !wxIsalnum(keyCode)) || ((m_validatorStyle & wxFILTER_NUMERIC) && !wxIsdigit(keyCode) @@ -272,7 +272,7 @@ static bool wxIsNumeric(const wxString& val) { // Allow for "," (French) as well as "." -- in future we should // use wxSystemSettings or other to do better localisation - if ((!isdigit(val[i])) && (val[i] != '.') && (val[i] != ',') && (val[i] != wxT('e')) && (val[i] != wxT('E')) && (val[i] != wxT('+')) && (val[i] != wxT('-'))) + if ((!wxIsdigit(val[i])) && (val[i] != '.') && (val[i] != ',') && (val[i] != wxT('e')) && (val[i] != wxT('E')) && (val[i] != wxT('+')) && (val[i] != wxT('-'))) return FALSE; } return TRUE; diff --git a/src/common/wxchar.cpp b/src/common/wxchar.cpp index 6b2a005483..571d165d3d 100644 --- a/src/common/wxchar.cpp +++ b/src/common/wxchar.cpp @@ -30,8 +30,13 @@ #include #include #include -#include + +#ifndef __WXWINCE__ #include +#include +#else +#include "wx/msw/wince/time.h" +#endif #ifndef WX_PRECOMP #include "wx/defs.h" diff --git a/src/common/xpmdecod.cpp b/src/common/xpmdecod.cpp index 4b4e47e045..f3cd26aa0b 100644 --- a/src/common/xpmdecod.cpp +++ b/src/common/xpmdecod.cpp @@ -551,7 +551,7 @@ static bool GetRGBFromName(const char *inname, bool *isNone, return TRUE; } - name = strdup(inname); + name = wxStrdup(inname); // theRGBRecords[] has no names with spaces, and no grey, but a // lot of gray... @@ -638,7 +638,7 @@ static const char *ParseColor(const char *data) { if ( *r != *q ) continue; - if ( !isspace((int) (*(r - 1))) ) + if ( !wxIsspace((int) (*(r - 1))) ) continue; p = r; for (;;) diff --git a/src/generic/dirctrlg.cpp b/src/generic/dirctrlg.cpp index 045fa1b2b9..08e424f7d7 100644 --- a/src/generic/dirctrlg.cpp +++ b/src/generic/dirctrlg.cpp @@ -63,7 +63,9 @@ // older releases don't, but it should be verified and the checks modified // accordingly. #if !defined(__GNUWIN32__) || (defined(__MINGW32_MAJOR_VERSION) && __MINGW32_MAJOR_VERSION >= 1) +#if !defined(__WXWINCE__) #include +#endif #include #include #endif diff --git a/src/generic/grid.cpp b/src/generic/grid.cpp index 068d735b61..4b9fbf9958 100644 --- a/src/generic/grid.cpp +++ b/src/generic/grid.cpp @@ -717,7 +717,7 @@ bool wxGridCellTextEditor::IsAcceptedKey(wxKeyEvent& event) default: // accept 8 bit chars too if isprint() agrees - if ( (keycode < 255) && (isprint(keycode)) ) + if ( (keycode < 255) && (wxIsprint(keycode)) ) return TRUE; } } diff --git a/src/msw/wince/time.cpp b/src/msw/wince/time.cpp new file mode 100644 index 0000000000..afd4aa4b93 --- /dev/null +++ b/src/msw/wince/time.cpp @@ -0,0 +1,132 @@ +///////////////////////////////////////////////////////////////////////////// +// Name: src/msw/wince/time.cpp +// Purpose: Implements missing time functionality for WinCE +// Author: +// Modified by: +// Created: 2003-07-10 +// RCS-ID: $Id$ +// Copyright: +// Licence: wxWindows licence +///////////////////////////////////////////////////////////////////////////// + +// =========================================================================== +// declarations +// =========================================================================== + +// --------------------------------------------------------------------------- +// headers +// --------------------------------------------------------------------------- + +#ifdef __GNUG__ + #pragma implementation "window.h" +#endif + +// For compilers that support precompilation, includes "wx.h". +#include "wx/wxprec.h" + +#ifdef __BORLANDC__ + #pragma hdrstop +#endif + +#ifndef WX_PRECOMP + #include + #include "wx/msw/winundef.h" +#endif + +#include "wx/msw/wince/time.h" + +long timezone = 0; + +// Hint: use GetSystemTime() + +struct tm * localtime(const time_t *) +{ + // TODO + return NULL; + + // Possible implementation +#if 0 + // Localtime for WinCE + // By martin brown (mpatalberta@yahoo.com) + // This is really stupid, converting FILETIME to timeval back and + // forth. It assumes FILETIME and DWORDLONG are the same structure + // internally. + + TIME_ZONE_INFORMATION pTz; + + const unsigned short int __mon_yday[2][13] = + { + /* Normal years. */ + { 0, 31, 59, 90, 120, 151, 181, 212, 243, 273, 304, 334, 365 }, + /* Leap years. */ + { 0, 31, 60, 91, 121, 152, 182, 213, 244, 274, 305, 335, 366 } + }; + + + ULARGE_INTEGER _100ns; + ::GetTimeZoneInformation(&pTz); + + // FIXME + _100ns.QuadPart = (DWORDLONG) *t * 10000 * 1000 /* + ACE_Time_Value::FILETIME_to_timval_skew */; + FILETIME file_time; + file_time.dwLowDateTime = _100ns.LowPart; + file_time.dwHighDateTime = _100ns.HighPart; + + FILETIME localtime; + SYSTEMTIME systime; + FileTimeToLocalFileTime (&file_time, &localtime); + FileTimeToSystemTime (&localtime, &systime); + + res->tm_hour = systime.wHour; + + if(pTz.DaylightBias!=0) + { + res->tm_isdst = 1; + } + else + { + res->tm_isdst = 1; + } + + int iLeap; + iLeap = (res->tm_year % 4 == 0 && (res->tm_year% 100 != 0 || res->tm_year % 400 == 0)); + // based on leap select which group to use + + res->tm_mday = systime.wDay; + res->tm_min = systime.wMinute; + res->tm_mon = systime.wMonth; + res->tm_sec = systime.wSecond; + res->tm_wday = systime.wDayOfWeek; + res->tm_yday = __mon_yday[iLeap][systime.wMonth] + systime.wDay; + res->tm_year = systime.wYear;// this the correct year but bias the value to start at the 1900 + res->tm_year = res->tm_year - 1900; + + return res; +#endif +} + +time_t time(time_t *) +{ + // TODO + return 0; +} + +size_t wcsftime(wchar_t *, size_t, const wchar_t *, + const struct tm *) +{ + // TODO + return 0; +} + +time_t mktime(struct tm *) +{ + // TODO + return 0; +} + +struct tm * gmtime(const time_t *) +{ + // TODO + return NULL; +} + -- 2.45.2