#endif // O_RDONLY
#else
// functions
- #define wxOpen open
#define wxClose close
#define wxRead read
#define wxWrite write
#define wxLseek lseek
#define wxFsync commit
- #define wxAccess access
#define wxEof eof
#define wxMkDir mkdir
#define wxTell(fd) lseek(fd, 0, SEEK_CUR)
- #define wxStat stat
-
- // types
#define wxStructStat struct stat
+
+#if wxUSE_UNICODE
+# define wxNEED_WX_UNISTD_H
+WXDLLEXPORT int wxStat( const wxChar *file_name, wxStructStat *buf );
+WXDLLEXPORT int wxAccess( const wxChar *pathname, int mode );
+WXDLLEXPORT int wxOpen( const wxChar *pathname, int flags, mode_t mode );
+#else
+ #define wxOpen open
+ #define wxStat stat
+ #define wxAccess access
+#endif
#endif // VC++
g_printData = new wxPrintData;
g_pageSetupData = new wxPageSetupDialogData;
+
+ // wxGetenv( wxT("HOME") );
// Compatibility with old system. In fact, we might keep wxThePrintSetupData
// just for useful default values which we can optionally assign to our
dc.SetPen(* wxRED_PEN);
dc.DrawRectangle(0, 30, 200, 100);
- dc.DrawText("Rectangle 200 by 100", 40, 40);
+
+ dc.DrawText( wxT("Rectangle 200 by 100"), 40, 40);
dc.DrawEllipse(50, 140, 100, 50);
- dc.DrawText("Test message: this is in 10 point text", 10, 180);
+ dc.DrawText( wxT("Test message: this is in 10 point text"), 10, 180);
+
+#if wxUSE_UNICODE
+ char *test = "Greek (Ελληνικά) Γειά σας -- Hebrew שלום -- Japanese (日本語)";
+ wxString tmp = wxConvUTF8.cMB2WC( test );
+ dc.DrawText( tmp, 10, 200 );
+#endif
dc.SetPen(* wxBLACK_PEN);
dc.DrawLine(0, 0, 200, 200);
dc->SetDeviceOrigin(0, 0);
dc->SetUserScale(1.0, 1.0);
- char buf[200];
- sprintf(buf, "PAGE %d", page);
+ wxChar buf[200];
+ wxSprintf(buf, wxT("PAGE %d"), page);
dc->DrawText(buf, 10, 10);
return TRUE;
dc->DrawLine(50, 250, (long)(50.0 + logUnits), 250);
dc->DrawLine(50, 250, 50, (long)(250.0 + logUnits));
+ return;
+
dc->SetFont(* wxGetApp().m_testFont);
dc->SetBackgroundMode(wxTRANSPARENT);
- dc->DrawText("Some test text", 200, 200 );
{ // GetTextExtent demo:
wxString words[7] = {"This ", "is ", "GetTextExtent ", "testing ", "string. ", "Enjoy ", "it!"};
dc->SetFont(* wxGetApp().m_testFont);
}
+ dc->DrawText("Some test text", 200, 300 );
+
// TESTING
int leftMargin = 20;
bool wxFile::Exists(const wxChar *name)
{
wxStructStat st;
-#if wxUSE_UNICODE && wxMBFILES
- wxCharBuffer fname = wxConvFile.cWC2MB(name);
-
- return !wxAccess(fname, 0) &&
- !wxStat(wxMBSTRINGCAST fname, &st) &&
- (st.st_mode & S_IFREG);
-
-#else
return !wxAccess(name, 0) &&
!wxStat(name, &st) &&
(st.st_mode & S_IFREG);
-#endif
}
bool wxFile::Access(const wxChar *name, OpenMode mode)
wxFAIL_MSG(wxT("bad wxFile::Access mode parameter."));
}
- return wxAccess(wxFNCONV(name), how) == 0;
+ return wxAccess( name, how) == 0;
}
// ----------------------------------------------------------------------------
// if bOverwrite we create a new file or truncate the existing one,
// otherwise we only create the new file and fail if it already exists
#if defined(__WXMAC__) && !defined(__UNIX__)
- // 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);
+ // 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
- int fd = wxOpen(wxFNCONV(szFileName),
- O_BINARY | O_WRONLY | O_CREAT |
- (bOverwrite ? O_TRUNC : O_EXCL)
- ACCESS(accessMode));
+ int fd = wxOpen( szFileName,
+ O_BINARY | O_WRONLY | O_CREAT |
+ (bOverwrite ? O_TRUNC : O_EXCL)
+ ACCESS(accessMode) );
#endif
- if ( fd == -1 ) {
+ if ( fd == -1 )
+ {
wxLogSysError(_("can't create file '%s'"), szFileName);
return FALSE;
}
- else {
+ else
+ {
Attach(fd);
return TRUE;
}
{
int flags = O_BINARY;
- switch ( mode ) {
+ switch ( mode )
+ {
case read:
flags |= O_RDONLY;
break;
break;
}
- int fd = wxOpen(wxFNCONV(szFileName), flags ACCESS(accessMode));
- if ( fd == -1 ) {
+ int fd = wxOpen( szFileName, flags ACCESS(accessMode));
+ if ( fd == -1 )
+ {
wxLogSysError(_("can't open file '%s'"), szFileName);
return FALSE;
}
#ifdef __UNIX__
#include <unistd.h>
#include <dirent.h>
+ #include <fcntl.h>
#endif
#ifdef __WXPM__
# include "FSpCompat.h"
#endif
-IMPLEMENT_DYNAMIC_CLASS(wxPathList, wxStringList)
-
// ----------------------------------------------------------------------------
// private globals
// ----------------------------------------------------------------------------
// implementation
// ============================================================================
+#ifdef wxNEED_WX_UNISTD_H
+
+WXDLLEXPORT int wxStat( const wxChar *file_name, wxStructStat *buf )
+{
+ return stat( wxConvFile.cWX2MB( file_name ), buf );
+}
+
+WXDLLEXPORT int wxAccess( const wxChar *pathname, int mode )
+{
+ return access( wxConvFile.cWX2MB( pathname ), mode );
+}
+
+WXDLLEXPORT int wxOpen( const wxChar *pathname, int flags, mode_t mode )
+{
+ return open( wxConvFile.cWX2MB( pathname ), flags, mode );
+}
+
+#endif
+ // wxNEED_WX_UNISTD_H
+
+// ----------------------------------------------------------------------------
+// wxPathList
+// ----------------------------------------------------------------------------
+
+IMPLEMENT_DYNAMIC_CLASS(wxPathList, wxStringList)
+
void wxPathList::Add (const wxString& path)
{
wxStringList::Add (WXSTRINGCAST path);
return (ret != (DWORD)-1) && !(ret & FILE_ATTRIBUTE_DIRECTORY);
#else
wxStructStat stbuf;
- if ( !filename.empty() && wxStat (OS_FILENAME(filename), &stbuf) == 0 )
+ if ( !filename.empty() && wxStat( filename, &stbuf) == 0 )
return TRUE;
return FALSE;
wxStructStat fbuf;
// get permissions of file1
- if ( wxStat(OS_FILENAME(file1), &fbuf) != 0 )
+ if ( wxStat( file1, &fbuf) != 0 )
{
// the file probably doesn't exist or we haven't the rights to read
// from it anyhow
wxStructStat st;
#ifndef __VISAGECPP__
- return wxStat(wxFNSTRINGCAST strPath.fn_str(), &st) == 0 &&
- ((st.st_mode & S_IFMT) == S_IFDIR);
+ return wxStat(pszPathName, &st) == 0 && ((st.st_mode & S_IFMT) == S_IFDIR);
#else
// S_IFMT not supported in VA compilers.. st_mode is a 2byte value only
- return wxStat(wxFNSTRINGCAST strPath.fn_str(), &st) == 0 &&
- (st.st_mode == S_IFDIR);
+ return wxStat(pszPathName, &st) == 0 && (st.st_mode == S_IFDIR);
#endif
#endif // __WIN32__/!__WIN32__
time_t WXDLLEXPORT wxFileModificationTime(const wxString& filename)
{
wxStructStat buf;
-
- wxStat(filename.fn_str(), &buf);
+ wxStat( filename, &buf);
+
return buf.st_mtime;
}
{
#if defined(__UNIX_LIKE__) || defined(__WXMAC__) || (defined(__DOS__) && defined(__WATCOMC__))
wxStructStat stBuf;
- if ( wxStat(GetFullPath().fn_str(), &stBuf) == 0 )
+ if ( wxStat( GetFullPath().c_str(), &stBuf) == 0 )
{
if ( dtAccess )
dtAccess->Set(stBuf.st_atime);
#include "wx/hash.h"
#endif
+#include "wx/msgdlg.h"
+
#if defined(__WIN32__) && defined(wxNEED_WX_CTYPE_H)
#include <windef.h>
#include <winbase.h>
#ifdef wxNEED_WX_STDIO_H
WXDLLEXPORT FILE * wxFopen(const wxChar *path, const wxChar *mode)
{
- return fopen(wxConvFile.cWX2MB(path), wxConvLibc.cWX2MB(mode));
+ return fopen( wxConvFile.cWX2MB(path), wxConvLibc.cWX2MB(mode) );
}
WXDLLEXPORT FILE * wxFreopen(const wxChar *path, const wxChar *mode, FILE *stream)
{
- return freopen(wxConvFile.cWX2MB(path), wxConvLibc.cWX2MB(mode), stream);
+ return freopen( wxConvFile.cWX2MB(path), wxConvLibc.cWX2MB(mode), stream );
}
WXDLLEXPORT int wxRemove(const wxChar *path)
{
- return remove(wxConvFile.cWX2MB(path));
+ return remove( wxConvFile.cWX2MB(path) );
}
WXDLLEXPORT int wxRename(const wxChar *oldpath, const wxChar *newpath)
{
- return rename(wxConvFile.cWX2MB(oldpath), wxConvFile.cWX2MB(newpath));
+ return rename( wxConvFile.cWX2MB(oldpath), wxConvFile.cWX2MB(newpath) );
}
int WXDLLEXPORT wxPrintf(const wxChar *fmt, ...)
wxChar * WXDLLEXPORT wxGetenv(const wxChar *name)
{
static wxHashTable env;
+
// check if we already have stored the converted env var
wxObject *data = env.Get(name);
- if (!data) {
+ if (!data)
+ {
// nope, retrieve it,
- const char *val = getenv(wxConvLibc.cWX2MB(name));
+#if wxUSE_UNICODE
+ wxCharBuffer buffer = wxConvLibc.cWX2MB(name);
+ // printf( "buffer %s\n", (const char*) buffer );
+ const char *val = getenv( (const char *)buffer );
+#else
+ const char *val = getenv( name );
+#endif
+
if (!val) return (wxChar *)NULL;
+ // printf( "home %s\n", val );
+
// convert it,
+#ifdef wxUSE_UNICODE
+ data = (wxObject *)new wxString(val, wxConvLibc);
+#else
data = (wxObject *)new wxString(val);
+#endif
+
// and store it
env.Put(name, data);
}
wxChar *header_file = wxGetTempFileName("ps");
- m_pstream = fopen( wxConvFile.cWX2MB(header_file) , "w+" );
+ m_pstream = wxFopen( header_file, wxT("w+") );
fprintf( m_pstream, "%%!PS-Adobe-2.0\n" ); // PostScript magic strings
fprintf( m_pstream, "%%%%Title: %s\n", (const char *)m_title.mb_str() );
- fprintf( m_pstream, "%%%%Creator: %s\n", (const char*)wxConvCurrent->cWX2MB(wxTheApp->argv[0]) );
+ fprintf( m_pstream, "%%%%Creator: wxWindows PostScript renderer\n" );
fprintf( m_pstream, "%%%%CreationDate: %s\n", (const char *)wxNow().mb_str() );
- wxChar userID[256];
- if ( wxGetEmailAddress(userID, sizeof(userID)) )
- {
- fprintf( m_pstream, "%%%%For: %s ", wxMBSTRINGCAST wxConvCurrent->cWX2MB(userID) );
- wxChar userName[245];
- if (wxGetUserName(userName, sizeof(userName)))
- fprintf( m_pstream, " (%s)", wxMBSTRINGCAST wxConvCurrent->cWX2MB(userName) );
- fprintf( m_pstream, "\n" );
- }
- else if ( wxGetUserName(userID, sizeof(userID)) )
- {
- fprintf( m_pstream, "%%%%For: %s\n", wxMBSTRINGCAST wxConvCurrent->cWX2MB(userID) );;
- }
// THE FOLLOWING HAS BEEN CONTRIBUTED BY Andy Fyfe <andy@hyperparallel.com>
bool wxGenericPrintDialog::TransferDataFromWindow()
{
+ long res = 0;
if(m_printDialogData.GetFromPage() != -1)
{
if (m_printDialogData.GetEnablePageNumbers())
{
- if(m_fromText) m_printDialogData.SetFromPage(wxAtoi(m_fromText->GetValue()));
- if(m_toText) m_printDialogData.SetToPage(wxAtoi(m_toText->GetValue()));
+ if(m_fromText)
+ {
+ wxString value = m_fromText->GetValue();
+ if (value.ToLong( &res ))
+ m_printDialogData.SetFromPage( res );
+ }
+ if(m_toText)
+ {
+ wxString value = m_toText->GetValue();
+ if (value.ToLong( &res ))
+ m_printDialogData.SetToPage( res );
+ }
}
if(m_rangeRadioBox)
{
m_printDialogData.SetFromPage(1);
m_printDialogData.SetToPage(32000);
}
- m_printDialogData.SetNoCopies(wxAtoi(m_noCopiesText->GetValue()));
+
+ wxString value = m_noCopiesText->GetValue();
+ if (value.ToLong( &res ))
+ m_printDialogData.SetNoCopies( res );
+
m_printDialogData.SetPrintToFile(m_printToFileCheckBox->GetValue());
return TRUE;
// caller will learn it soon enough when it calls GetFirst(wxDIR)
// anyhow
wxStructStat stBuf;
- if ( wxStat(M_DIR->GetName().fn_str(), &stBuf) == 0 )
+ if ( wxStat(M_DIR->GetName().c_str(), &stBuf) == 0 )
{
switch ( stBuf.st_nlink )
{