It now compiles all these files without warnings in Unicode mode.
(at least It Works For Me(tm)) I will respond to any complaints when I wake up for another workday (any complaints will prove whether Vadim was right in that it's bound to break things) git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@2114 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -1136,8 +1136,8 @@ void wxPageSetupDialogData::SetPaperSize(wxPaperSize id)
|
|||||||
void wxPageSetupDialogData::CalculateIdFromPaperSize()
|
void wxPageSetupDialogData::CalculateIdFromPaperSize()
|
||||||
{
|
{
|
||||||
wxASSERT_MSG( (wxThePrintPaperDatabase != (wxPrintPaperDatabase*) NULL),
|
wxASSERT_MSG( (wxThePrintPaperDatabase != (wxPrintPaperDatabase*) NULL),
|
||||||
"wxThePrintPaperDatabase should not be NULL. "
|
_T("wxThePrintPaperDatabase should not be NULL. "
|
||||||
"Do not create global print dialog data objects." );
|
"Do not create global print dialog data objects.") );
|
||||||
|
|
||||||
wxSize sz = GetPaperSize();
|
wxSize sz = GetPaperSize();
|
||||||
|
|
||||||
@@ -1152,8 +1152,8 @@ void wxPageSetupDialogData::CalculateIdFromPaperSize()
|
|||||||
void wxPageSetupDialogData::CalculatePaperSizeFromId()
|
void wxPageSetupDialogData::CalculatePaperSizeFromId()
|
||||||
{
|
{
|
||||||
wxASSERT_MSG( (wxThePrintPaperDatabase != (wxPrintPaperDatabase*) NULL),
|
wxASSERT_MSG( (wxThePrintPaperDatabase != (wxPrintPaperDatabase*) NULL),
|
||||||
"wxThePrintPaperDatabase should not be NULL. "
|
_T("wxThePrintPaperDatabase should not be NULL. "
|
||||||
"Do not create global print dialog data objects." );
|
"Do not create global print dialog data objects.") );
|
||||||
|
|
||||||
wxSize sz = wxThePrintPaperDatabase->GetSize(m_printData.GetPaperId());
|
wxSize sz = wxThePrintPaperDatabase->GetSize(m_printData.GetPaperId());
|
||||||
|
|
||||||
|
@@ -124,7 +124,7 @@ bool wxConfigBase::Read(const wxString& key, double* val) const
|
|||||||
wxString str;
|
wxString str;
|
||||||
if (Read(key, & str))
|
if (Read(key, & str))
|
||||||
{
|
{
|
||||||
*val = atof(str);
|
*val = wxAtof(str);
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@@ -187,7 +187,7 @@ bool wxConfigBase::Read(const wxString& key, int *pi, int defVal) const
|
|||||||
bool wxConfigBase::Write(const wxString& key, double val)
|
bool wxConfigBase::Write(const wxString& key, double val)
|
||||||
{
|
{
|
||||||
wxString str;
|
wxString str;
|
||||||
str.Printf("%f", val);
|
str.Printf(_T("%f"), val);
|
||||||
return Write(key, str);
|
return Write(key, str);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -314,7 +314,7 @@ wxString wxExpandEnvVars(const wxString& str)
|
|||||||
|
|
||||||
wxString strVarName(str.c_str() + n + 1, m - n - 1);
|
wxString strVarName(str.c_str() + n + 1, m - n - 1);
|
||||||
|
|
||||||
const char *pszValue = getenv(strVarName);
|
const wxChar *pszValue = wxGetenv(strVarName);
|
||||||
if ( pszValue != NULL ) {
|
if ( pszValue != NULL ) {
|
||||||
strResult += pszValue;
|
strResult += pszValue;
|
||||||
}
|
}
|
||||||
@@ -332,7 +332,7 @@ wxString wxExpandEnvVars(const wxString& str)
|
|||||||
if ( bracket != Bracket_None ) {
|
if ( bracket != Bracket_None ) {
|
||||||
if ( m == str.Len() || str[m] != (char)bracket ) {
|
if ( m == str.Len() || str[m] != (char)bracket ) {
|
||||||
wxLogWarning(_("Environment variables expansion failed: "
|
wxLogWarning(_("Environment variables expansion failed: "
|
||||||
"missing '%c' at position %d in '%s'."),
|
"missing '%c' at position %d in '%s'."),
|
||||||
(char)bracket, m + 1, str.c_str());
|
(char)bracket, m + 1, str.c_str());
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
@@ -48,13 +48,14 @@
|
|||||||
|
|
||||||
#define ABBR_LENGTH 3
|
#define ABBR_LENGTH 3
|
||||||
|
|
||||||
static const char *dayname[] = {
|
static const wxChar *dayname[] = {
|
||||||
"Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"
|
_T("Sunday"), _T("Monday"), _T("Tuesday"), _T("Wednesday"),
|
||||||
|
_T("Thursday"), _T("Friday"), _T("Saturday")
|
||||||
};
|
};
|
||||||
|
|
||||||
static const char *mname[] = {
|
static const wxChar *mname[] = {
|
||||||
"January", "February", "March", "April", "May", "June", "July", "August",
|
_T("January"), _T("February"), _T("March"), _T("April"), _T("May"), _T("June"),
|
||||||
"September", "October", "November", "December"
|
_T("July"), _T("August"), _T("September"), _T("October"), _T("November"), _T("December")
|
||||||
};
|
};
|
||||||
|
|
||||||
static int GauDays[] = { 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 };
|
static int GauDays[] = { 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 };
|
||||||
@@ -93,20 +94,20 @@ wxDate::wxDate (const wxString& dat)
|
|||||||
{
|
{
|
||||||
DisplayFormat=wxMDY;
|
DisplayFormat=wxMDY;
|
||||||
DisplayOptions='\0';
|
DisplayOptions='\0';
|
||||||
if (strcmp(dat, "TODAY") == 0 || strcmp(dat, "today") == 0)
|
if (wxStrcmp(dat, _T("TODAY")) == 0 || wxStrcmp(dat, _T("today")) == 0)
|
||||||
{
|
{
|
||||||
// Sets the current date
|
// Sets the current date
|
||||||
Set();
|
Set();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
char buf[100];
|
wxChar buf[100];
|
||||||
strcpy(buf, (char *) (const char *)dat);
|
wxStrcpy(buf, WXSTRINGCAST dat);
|
||||||
|
|
||||||
char *token = strtok(buf,"/-");
|
wxChar *save_ptr, *token = wxStrtok(buf,_T("/-"),&save_ptr);
|
||||||
month = atoi(token);
|
month = wxAtoi(token);
|
||||||
day = atoi(strtok((char *) NULL,"/-"));
|
day = wxAtoi(wxStrtok((wxChar *) NULL,_T("/-"),&save_ptr));
|
||||||
year = atoi(strtok((char *) NULL," "));
|
year = wxAtoi(wxStrtok((wxChar *) NULL,_T(" "),&save_ptr));
|
||||||
}
|
}
|
||||||
|
|
||||||
mdy_to_julian ();
|
mdy_to_julian ();
|
||||||
@@ -136,20 +137,20 @@ void wxDate::operator = (const wxString& dat)
|
|||||||
{
|
{
|
||||||
DisplayFormat=wxMDY;
|
DisplayFormat=wxMDY;
|
||||||
DisplayOptions='\0';
|
DisplayOptions='\0';
|
||||||
if (strcmp(dat, "TODAY") == 0 || strcmp(dat, "today") == 0)
|
if (wxStrcmp(dat, _T("TODAY")) == 0 || wxStrcmp(dat, _T("today")) == 0)
|
||||||
{
|
{
|
||||||
// Sets the current date
|
// Sets the current date
|
||||||
Set();
|
Set();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
char buf[100];
|
wxChar buf[100];
|
||||||
strcpy(buf, (char *)(const char *)dat);
|
wxStrcpy(buf, WXSTRINGCAST dat);
|
||||||
|
|
||||||
char *token = strtok(buf,"/-");
|
wxChar *save_ptr, *token = wxStrtok(buf,_T("/-"),&save_ptr);
|
||||||
month = atoi(token);
|
month = wxAtoi(token);
|
||||||
day = atoi(strtok((char *) NULL,"/-"));
|
day = wxAtoi(wxStrtok((wxChar *) NULL,_T("/-"),&save_ptr));
|
||||||
year = atoi(strtok((char *) NULL," "));
|
year = wxAtoi(wxStrtok((wxChar *) NULL,_T(" "),&save_ptr));
|
||||||
}
|
}
|
||||||
|
|
||||||
mdy_to_julian ();
|
mdy_to_julian ();
|
||||||
@@ -281,7 +282,7 @@ bool WXDLLEXPORT operator != (const wxDate &dt1, const wxDate &dt2)
|
|||||||
|
|
||||||
ostream WXDLLEXPORT & operator << (ostream &os, const wxDate &dt)
|
ostream WXDLLEXPORT & operator << (ostream &os, const wxDate &dt)
|
||||||
{
|
{
|
||||||
return os << (const char *) dt.FormatDate();
|
return os << (const wxChar *) dt.FormatDate();
|
||||||
}
|
}
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////
|
||||||
@@ -345,72 +346,72 @@ wxString wxDate::FormatDate (int type) const
|
|||||||
if (actualType == -1)
|
if (actualType == -1)
|
||||||
actualType = DisplayFormat;
|
actualType = DisplayFormat;
|
||||||
|
|
||||||
char buf[40];
|
wxChar buf[40];
|
||||||
|
|
||||||
memset( buf, '\0', sizeof(buf) );
|
memset( buf, '\0', sizeof(buf) );
|
||||||
switch ( actualType )
|
switch ( actualType )
|
||||||
{
|
{
|
||||||
case wxDAY:
|
case wxDAY:
|
||||||
if ( (day_of_week < 1) || (day_of_week > 7) )
|
if ( (day_of_week < 1) || (day_of_week > 7) )
|
||||||
strcpy(buf, _("invalid day"));
|
wxStrcpy(buf, _("invalid day"));
|
||||||
else
|
else
|
||||||
strncpy( buf, _(dayname[day_of_week-1]),
|
wxStrncpy( buf, wxGetTranslation(dayname[day_of_week-1]),
|
||||||
(DisplayOptions & wxDATE_ABBR) ? ABBR_LENGTH : 9);
|
(DisplayOptions & wxDATE_ABBR) ? ABBR_LENGTH : 9);
|
||||||
return wxString(buf);
|
return wxString(buf);
|
||||||
|
|
||||||
case wxMONTH:
|
case wxMONTH:
|
||||||
if ( (month < 1) || (month > 12) )
|
if ( (month < 1) || (month > 12) )
|
||||||
strcpy(buf, _("invalid month"));
|
wxStrcpy(buf, _("invalid month"));
|
||||||
else
|
else
|
||||||
strncpy( buf, _(mname[month-1]),
|
wxStrncpy( buf, wxGetTranslation(mname[month-1]),
|
||||||
(DisplayOptions & wxDATE_ABBR) ? ABBR_LENGTH : 9);
|
(DisplayOptions & wxDATE_ABBR) ? ABBR_LENGTH : 9);
|
||||||
return wxString(buf);
|
return wxString(buf);
|
||||||
|
|
||||||
case wxFULL:
|
case wxFULL:
|
||||||
if ( (month < 1) || (month > 12) || (day_of_week < 0) ||
|
if ( (month < 1) || (month > 12) || (day_of_week < 0) ||
|
||||||
(day_of_week > 7) )
|
(day_of_week > 7) )
|
||||||
{
|
{
|
||||||
strcpy(buf, _("invalid date"));
|
wxStrcpy(buf, _("invalid date"));
|
||||||
return wxString(buf);
|
return wxString(buf);
|
||||||
}
|
}
|
||||||
strncpy( buf, _(dayname[day_of_week-1]),
|
wxStrncpy( buf, wxGetTranslation(dayname[day_of_week-1]),
|
||||||
(DisplayOptions & wxDATE_ABBR) ? ABBR_LENGTH : 9);
|
(DisplayOptions & wxDATE_ABBR) ? ABBR_LENGTH : 9);
|
||||||
strcat( buf, ", ");
|
wxStrcat( buf, _T(", "));
|
||||||
strncat( buf, _(mname[month-1]),
|
wxStrncat( buf, wxGetTranslation(mname[month-1]),
|
||||||
(DisplayOptions & wxDATE_ABBR) ? ABBR_LENGTH : 9);
|
(DisplayOptions & wxDATE_ABBR) ? ABBR_LENGTH : 9);
|
||||||
strcat( buf, " ");
|
wxStrcat( buf, _T(" "));
|
||||||
sprintf( buf+strlen(buf), "%d, %d", day, abs(year) );
|
wxSprintf( buf+wxStrlen(buf), _T("%d, %d"), day, abs(year) );
|
||||||
if (year < 0)
|
if (year < 0)
|
||||||
strcat(buf,_(" B.C."));
|
wxStrcat(buf,_(" B.C."));
|
||||||
return wxString(buf);
|
return wxString(buf);
|
||||||
|
|
||||||
case wxEUROPEAN:
|
case wxEUROPEAN:
|
||||||
if ( (month < 1) || (month > 12) || (day_of_week < 0) ||
|
if ( (month < 1) || (month > 12) || (day_of_week < 0) ||
|
||||||
(day_of_week > 7) )
|
(day_of_week > 7) )
|
||||||
{
|
{
|
||||||
strcpy(buf, _("invalid date"));
|
wxStrcpy(buf, _("invalid date"));
|
||||||
return wxString(buf);
|
return wxString(buf);
|
||||||
}
|
}
|
||||||
sprintf(buf,"%d ", day);
|
wxSprintf(buf,_T("%d "), day);
|
||||||
strncat(buf, _(mname[month-1]),
|
wxStrncat(buf, wxGetTranslation(mname[month-1]),
|
||||||
(DisplayOptions & wxDATE_ABBR) ? ABBR_LENGTH : 9);
|
(DisplayOptions & wxDATE_ABBR) ? ABBR_LENGTH : 9);
|
||||||
sprintf( buf+strlen(buf), " %d", abs(year) );
|
wxSprintf( buf+wxStrlen(buf), _T(" %d"), abs(year) );
|
||||||
if (year < 0)
|
if (year < 0)
|
||||||
strcat(buf, _(" B.C."));
|
wxStrcat(buf, _(" B.C."));
|
||||||
return wxString(buf);
|
return wxString(buf);
|
||||||
|
|
||||||
case wxMDY:
|
case wxMDY:
|
||||||
default:
|
default:
|
||||||
if (day==0 || month==0 || year==0)
|
if (day==0 || month==0 || year==0)
|
||||||
strcpy(buf, _("invalid date"));
|
wxStrcpy(buf, _("invalid date"));
|
||||||
else
|
else
|
||||||
sprintf( buf+strlen(buf), "%1d/%1d/%02d", month, day,
|
wxSprintf( buf+wxStrlen(buf), _T("%1d/%1d/%02d"), month, day,
|
||||||
(DisplayOptions & wxNO_CENTURY) && (abs(year) > 1899)
|
(DisplayOptions & wxNO_CENTURY) && (abs(year) > 1899)
|
||||||
? (abs(year) - (abs(year) / 100 * 100))
|
? (abs(year) - (abs(year) / 100 * 100))
|
||||||
: (abs(year)) );
|
: (abs(year)) );
|
||||||
return wxString(buf);
|
return wxString(buf);
|
||||||
}
|
}
|
||||||
return wxString("");
|
return wxString(_T(""));
|
||||||
}
|
}
|
||||||
|
|
||||||
void wxDate::SetFormat( int format )
|
void wxDate::SetFormat( int format )
|
||||||
|
@@ -39,7 +39,7 @@
|
|||||||
#include "wx/utils.h"
|
#include "wx/utils.h"
|
||||||
#include "wx/app.h"
|
#include "wx/app.h"
|
||||||
#include "wx/dc.h"
|
#include "wx/dc.h"
|
||||||
#include "wx/dialog.h"
|
#include "wx/dialog.h"
|
||||||
#include "wx/menu.h"
|
#include "wx/menu.h"
|
||||||
#include "wx/list.h"
|
#include "wx/list.h"
|
||||||
#include "wx/filedlg.h"
|
#include "wx/filedlg.h"
|
||||||
@@ -92,7 +92,7 @@
|
|||||||
// function prototypes
|
// function prototypes
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
|
|
||||||
static inline wxString FindExtension(const char *path);
|
static inline wxString FindExtension(const wxChar *path);
|
||||||
|
|
||||||
// ============================================================================
|
// ============================================================================
|
||||||
// implementation
|
// implementation
|
||||||
@@ -102,7 +102,7 @@ static inline wxString FindExtension(const char *path);
|
|||||||
// local functions
|
// local functions
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
|
|
||||||
static wxString FindExtension(const char *path)
|
static wxString FindExtension(const wxChar *path)
|
||||||
{
|
{
|
||||||
wxString ext;
|
wxString ext;
|
||||||
wxSplitPath(path, NULL, NULL, &ext);
|
wxSplitPath(path, NULL, NULL, &ext);
|
||||||
@@ -279,7 +279,7 @@ bool wxDocument::OnSaveDocument(const wxString& file)
|
|||||||
else
|
else
|
||||||
msgTitle = wxString(_("File error"));
|
msgTitle = wxString(_("File error"));
|
||||||
|
|
||||||
ofstream store(file);
|
ofstream store(file.fn_str());
|
||||||
if (store.fail() || store.bad())
|
if (store.fail() || store.bad())
|
||||||
{
|
{
|
||||||
(void)wxMessageBox(_("Sorry, could not open this file for saving."), msgTitle, wxOK | wxICON_EXCLAMATION,
|
(void)wxMessageBox(_("Sorry, could not open this file for saving."), msgTitle, wxOK | wxICON_EXCLAMATION,
|
||||||
@@ -310,7 +310,7 @@ bool wxDocument::OnOpenDocument(const wxString& file)
|
|||||||
else
|
else
|
||||||
msgTitle = wxString(_("File error"));
|
msgTitle = wxString(_("File error"));
|
||||||
|
|
||||||
ifstream store(file);
|
ifstream store(file.fn_str());
|
||||||
if (store.fail() || store.bad())
|
if (store.fail() || store.bad())
|
||||||
{
|
{
|
||||||
(void)wxMessageBox(_("Sorry, could not open this file."), msgTitle, wxOK|wxICON_EXCLAMATION,
|
(void)wxMessageBox(_("Sorry, could not open this file."), msgTitle, wxOK|wxICON_EXCLAMATION,
|
||||||
@@ -402,7 +402,7 @@ bool wxDocument::OnSaveModified()
|
|||||||
|
|
||||||
wxString prompt;
|
wxString prompt;
|
||||||
prompt.Printf(_("Do you want to save changes to document %s?"),
|
prompt.Printf(_("Do you want to save changes to document %s?"),
|
||||||
(const char *)title);
|
(const wxChar *)title);
|
||||||
int res = wxMessageBox(prompt, msgTitle,
|
int res = wxMessageBox(prompt, msgTitle,
|
||||||
wxYES_NO|wxCANCEL|wxICON_QUESTION,
|
wxYES_NO|wxCANCEL|wxICON_QUESTION,
|
||||||
GetDocumentWindow());
|
GetDocumentWindow());
|
||||||
@@ -1139,7 +1139,7 @@ wxDocTemplate *wxDocManager::FindTemplateForPath(const wxString& path)
|
|||||||
for (i = 0; i < m_templates.Number(); i++)
|
for (i = 0; i < m_templates.Number(); i++)
|
||||||
{
|
{
|
||||||
wxDocTemplate *temp = (wxDocTemplate *)m_templates.Nth(i)->Data();
|
wxDocTemplate *temp = (wxDocTemplate *)m_templates.Nth(i)->Data();
|
||||||
if (strcmp(temp->GetDefaultExtension(), theExt) == 0)
|
if (wxStrcmp(temp->GetDefaultExtension(), theExt) == 0)
|
||||||
{
|
{
|
||||||
theTemplate = temp;
|
theTemplate = temp;
|
||||||
break;
|
break;
|
||||||
@@ -1170,18 +1170,18 @@ wxDocTemplate *wxDocManager::SelectDocumentPath(wxDocTemplate **templates,
|
|||||||
{
|
{
|
||||||
// add a '|' to separate this filter from the previous one
|
// add a '|' to separate this filter from the previous one
|
||||||
if ( !descrBuf.IsEmpty() )
|
if ( !descrBuf.IsEmpty() )
|
||||||
descrBuf << '|';
|
descrBuf << _T('|');
|
||||||
|
|
||||||
descrBuf << templates[i]->GetDescription()
|
descrBuf << templates[i]->GetDescription()
|
||||||
<< " (" << templates[i]->GetFileFilter() << ") |"
|
<< _T(" (") << templates[i]->GetFileFilter() << _T(") |")
|
||||||
<< templates[i]->GetFileFilter();
|
<< templates[i]->GetFileFilter();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
wxString descrBuf = "*.*";
|
wxString descrBuf = _T("*.*");
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
wxString pathTmp = wxFileSelector(_("Select a file"), "", "", "",
|
wxString pathTmp = wxFileSelector(_("Select a file"), _T(""), _T(""), _T(""),
|
||||||
descrBuf, 0, wxTheApp->GetTopWindow());
|
descrBuf, 0, wxTheApp->GetTopWindow());
|
||||||
|
|
||||||
if (!pathTmp.IsEmpty())
|
if (!pathTmp.IsEmpty())
|
||||||
@@ -1229,8 +1229,8 @@ wxDocTemplate *wxDocManager::SelectDocumentPath(wxDocTemplate **templates,
|
|||||||
wxDocTemplate *wxDocManager::SelectDocumentType(wxDocTemplate **templates,
|
wxDocTemplate *wxDocManager::SelectDocumentType(wxDocTemplate **templates,
|
||||||
int noTemplates)
|
int noTemplates)
|
||||||
{
|
{
|
||||||
char **strings = new char *[noTemplates];
|
wxChar **strings = new wxChar *[noTemplates];
|
||||||
char **data = new char *[noTemplates];
|
wxChar **data = new wxChar *[noTemplates];
|
||||||
int i;
|
int i;
|
||||||
int n = 0;
|
int n = 0;
|
||||||
for (i = 0; i < noTemplates; i++)
|
for (i = 0; i < noTemplates; i++)
|
||||||
@@ -1238,7 +1238,7 @@ wxDocTemplate *wxDocManager::SelectDocumentType(wxDocTemplate **templates,
|
|||||||
if (templates[i]->IsVisible())
|
if (templates[i]->IsVisible())
|
||||||
{
|
{
|
||||||
strings[n] = WXSTRINGCAST templates[i]->m_description;
|
strings[n] = WXSTRINGCAST templates[i]->m_description;
|
||||||
data[n] = (char *)templates[i];
|
data[n] = (wxChar *)templates[i];
|
||||||
n ++;
|
n ++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1266,8 +1266,8 @@ wxDocTemplate *wxDocManager::SelectDocumentType(wxDocTemplate **templates,
|
|||||||
wxDocTemplate *wxDocManager::SelectViewType(wxDocTemplate **templates,
|
wxDocTemplate *wxDocManager::SelectViewType(wxDocTemplate **templates,
|
||||||
int noTemplates)
|
int noTemplates)
|
||||||
{
|
{
|
||||||
char **strings = new char *[noTemplates];
|
wxChar **strings = new wxChar *[noTemplates];
|
||||||
char **data = new char *[noTemplates];
|
wxChar **data = new wxChar *[noTemplates];
|
||||||
int i;
|
int i;
|
||||||
int n = 0;
|
int n = 0;
|
||||||
for (i = 0; i < noTemplates; i++)
|
for (i = 0; i < noTemplates; i++)
|
||||||
@@ -1275,7 +1275,7 @@ wxDocTemplate *wxDocManager::SelectViewType(wxDocTemplate **templates,
|
|||||||
if (templates[i]->IsVisible() && (templates[i]->GetViewName() != ""))
|
if (templates[i]->IsVisible() && (templates[i]->GetViewName() != ""))
|
||||||
{
|
{
|
||||||
strings[n] = WXSTRINGCAST templates[i]->m_viewTypeName;
|
strings[n] = WXSTRINGCAST templates[i]->m_viewTypeName;
|
||||||
data[n] = (char *)templates[i];
|
data[n] = (wxChar *)templates[i];
|
||||||
n ++;
|
n ++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1763,7 +1763,7 @@ wxFileHistory::wxFileHistory(int maxFiles)
|
|||||||
{
|
{
|
||||||
m_fileMaxFiles = maxFiles;
|
m_fileMaxFiles = maxFiles;
|
||||||
m_fileHistoryN = 0;
|
m_fileHistoryN = 0;
|
||||||
m_fileHistory = new char *[m_fileMaxFiles];
|
m_fileHistory = new wxChar *[m_fileMaxFiles];
|
||||||
}
|
}
|
||||||
|
|
||||||
wxFileHistory::~wxFileHistory()
|
wxFileHistory::~wxFileHistory()
|
||||||
@@ -1792,7 +1792,7 @@ void wxFileHistory::AddFileToHistory(const wxString& file)
|
|||||||
if (m_fileHistoryN == m_fileMaxFiles)
|
if (m_fileHistoryN == m_fileMaxFiles)
|
||||||
{
|
{
|
||||||
delete[] m_fileHistory[m_fileMaxFiles-1];
|
delete[] m_fileHistory[m_fileMaxFiles-1];
|
||||||
m_fileHistory[m_fileMaxFiles-1] = (char *) NULL;
|
m_fileHistory[m_fileMaxFiles-1] = (wxChar *) NULL;
|
||||||
}
|
}
|
||||||
if (m_fileHistoryN < m_fileMaxFiles)
|
if (m_fileHistoryN < m_fileMaxFiles)
|
||||||
{
|
{
|
||||||
@@ -1818,7 +1818,7 @@ void wxFileHistory::AddFileToHistory(const wxString& file)
|
|||||||
if (m_fileHistory[i])
|
if (m_fileHistory[i])
|
||||||
{
|
{
|
||||||
wxString buf;
|
wxString buf;
|
||||||
buf.Printf("&%d %s", i+1, m_fileHistory[i]);
|
buf.Printf(_T("&%d %s"), i+1, m_fileHistory[i]);
|
||||||
wxNode* node = m_fileMenus.First();
|
wxNode* node = m_fileMenus.First();
|
||||||
while (node)
|
while (node)
|
||||||
{
|
{
|
||||||
@@ -1853,13 +1853,13 @@ void wxFileHistory::Load(wxConfigBase& config)
|
|||||||
{
|
{
|
||||||
m_fileHistoryN = 0;
|
m_fileHistoryN = 0;
|
||||||
wxString buf;
|
wxString buf;
|
||||||
buf.Printf("file%d", m_fileHistoryN+1);
|
buf.Printf(_T("file%d"), m_fileHistoryN+1);
|
||||||
wxString historyFile;
|
wxString historyFile;
|
||||||
while ((m_fileHistoryN <= m_fileMaxFiles) && config.Read(buf, &historyFile) && (historyFile != ""))
|
while ((m_fileHistoryN <= m_fileMaxFiles) && config.Read(buf, &historyFile) && (historyFile != ""))
|
||||||
{
|
{
|
||||||
m_fileHistory[m_fileHistoryN] = copystring((const char*) historyFile);
|
m_fileHistory[m_fileHistoryN] = copystring((const wxChar*) historyFile);
|
||||||
m_fileHistoryN ++;
|
m_fileHistoryN ++;
|
||||||
buf.Printf("file%d", m_fileHistoryN+1);
|
buf.Printf(_T("file%d"), m_fileHistoryN+1);
|
||||||
historyFile = "";
|
historyFile = "";
|
||||||
}
|
}
|
||||||
AddFilesToMenu();
|
AddFilesToMenu();
|
||||||
@@ -1871,7 +1871,7 @@ void wxFileHistory::Save(wxConfigBase& config)
|
|||||||
for (i = 0; i < m_fileHistoryN; i++)
|
for (i = 0; i < m_fileHistoryN; i++)
|
||||||
{
|
{
|
||||||
wxString buf;
|
wxString buf;
|
||||||
buf.Printf("file%d", i+1);
|
buf.Printf(_T("file%d"), i+1);
|
||||||
config.Write(buf, wxString(m_fileHistory[i]));
|
config.Write(buf, wxString(m_fileHistory[i]));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1892,7 +1892,7 @@ void wxFileHistory::AddFilesToMenu()
|
|||||||
if (m_fileHistory[i])
|
if (m_fileHistory[i])
|
||||||
{
|
{
|
||||||
wxString buf;
|
wxString buf;
|
||||||
buf.Printf("&%d %s", i+1, m_fileHistory[i]);
|
buf.Printf(_T("&%d %s"), i+1, m_fileHistory[i]);
|
||||||
menu->Append(wxID_FILE1+i, buf);
|
menu->Append(wxID_FILE1+i, buf);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1912,7 +1912,7 @@ void wxFileHistory::AddFilesToMenu(wxMenu* menu)
|
|||||||
if (m_fileHistory[i])
|
if (m_fileHistory[i])
|
||||||
{
|
{
|
||||||
wxString buf;
|
wxString buf;
|
||||||
buf.Printf("&%d %s", i+1, m_fileHistory[i]);
|
buf.Printf(_T("&%d %s"), i+1, m_fileHistory[i]);
|
||||||
menu->Append(wxID_FILE1+i, buf);
|
menu->Append(wxID_FILE1+i, buf);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1929,7 +1929,7 @@ bool wxTransferFileToStream(const wxString& filename, ostream& stream)
|
|||||||
FILE *fd1;
|
FILE *fd1;
|
||||||
int ch;
|
int ch;
|
||||||
|
|
||||||
if ((fd1 = fopen (WXSTRINGCAST filename, "rb")) == NULL)
|
if ((fd1 = fopen (filename.fn_str(), "rb")) == NULL)
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
|
||||||
while ((ch = getc (fd1)) != EOF)
|
while ((ch = getc (fd1)) != EOF)
|
||||||
@@ -1944,7 +1944,7 @@ bool wxTransferStreamToFile(istream& stream, const wxString& filename)
|
|||||||
FILE *fd1;
|
FILE *fd1;
|
||||||
int ch;
|
int ch;
|
||||||
|
|
||||||
if ((fd1 = fopen (WXSTRINGCAST filename, "wb")) == NULL)
|
if ((fd1 = fopen (filename.fn_str(), "wb")) == NULL)
|
||||||
{
|
{
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
@@ -250,7 +250,7 @@ void wxBaseArray::Add(long lItem, CMPFUNC fnCompare)
|
|||||||
// add item at the given position
|
// add item at the given position
|
||||||
void wxBaseArray::Insert(long lItem, size_t nIndex)
|
void wxBaseArray::Insert(long lItem, size_t nIndex)
|
||||||
{
|
{
|
||||||
wxCHECK_RET( nIndex <= m_nCount, "bad index in wxArray::Insert" );
|
wxCHECK_RET( nIndex <= m_nCount, _T("bad index in wxArray::Insert") );
|
||||||
|
|
||||||
Grow();
|
Grow();
|
||||||
|
|
||||||
@@ -263,7 +263,7 @@ void wxBaseArray::Insert(long lItem, size_t nIndex)
|
|||||||
// removes item from array (by index)
|
// removes item from array (by index)
|
||||||
void wxBaseArray::Remove(size_t nIndex)
|
void wxBaseArray::Remove(size_t nIndex)
|
||||||
{
|
{
|
||||||
wxCHECK_RET( nIndex <= m_nCount, "bad index in wxArray::Remove" );
|
wxCHECK_RET( nIndex <= m_nCount, _T("bad index in wxArray::Remove") );
|
||||||
|
|
||||||
memmove(&m_pItems[nIndex], &m_pItems[nIndex + 1],
|
memmove(&m_pItems[nIndex], &m_pItems[nIndex + 1],
|
||||||
(m_nCount - nIndex - 1)*sizeof(long));
|
(m_nCount - nIndex - 1)*sizeof(long));
|
||||||
@@ -276,7 +276,7 @@ void wxBaseArray::Remove(long lItem)
|
|||||||
int iIndex = Index(lItem);
|
int iIndex = Index(lItem);
|
||||||
|
|
||||||
wxCHECK_RET( iIndex != wxNOT_FOUND,
|
wxCHECK_RET( iIndex != wxNOT_FOUND,
|
||||||
"removing inexistent item in wxArray::Remove" );
|
_T("removing inexistent item in wxArray::Remove") );
|
||||||
|
|
||||||
Remove((size_t)iIndex);
|
Remove((size_t)iIndex);
|
||||||
}
|
}
|
||||||
|
@@ -40,17 +40,17 @@
|
|||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
|
|
||||||
#if defined(HAVE_DLOPEN)
|
#if defined(HAVE_DLOPEN)
|
||||||
#define wxDllOpen(lib) dlopen(lib, RTLD_LAZY)
|
#define wxDllOpen(lib) dlopen(lib.fn_str(), RTLD_LAZY)
|
||||||
#define wxDllGetSymbol(handle, name) dlsym(handle, (char *)name)
|
#define wxDllGetSymbol(handle, name) dlsym(handle, name.mb_str())
|
||||||
#define wxDllClose dlclose
|
#define wxDllClose dlclose
|
||||||
#elif defined(HAVE_SHL_LOAD)
|
#elif defined(HAVE_SHL_LOAD)
|
||||||
#define wxDllOpen(lib) shl_load(lib, BIND_DEFERRED, 0)
|
#define wxDllOpen(lib) shl_load(lib.fn_str(), BIND_DEFERRED, 0)
|
||||||
#define wxDllClose shl_unload
|
#define wxDllClose shl_unload
|
||||||
|
|
||||||
static inline void *wxDllGetSymbol(shl_t handle, const char *name)
|
static inline void *wxDllGetSymbol(shl_t handle, const wxString& name)
|
||||||
{
|
{
|
||||||
void *sym;
|
void *sym;
|
||||||
if ( shl_findsym(&handle, name, TYPE_UNDEFINED, &sym) == 0 )
|
if ( shl_findsym(&handle, name.mb_str(), TYPE_UNDEFINED, &sym) == 0 )
|
||||||
return sym;
|
return sym;
|
||||||
else
|
else
|
||||||
return (void *)0;
|
return (void *)0;
|
||||||
@@ -179,9 +179,7 @@ void *wxLibrary::GetSymbol(const wxString& symbname)
|
|||||||
symbol = (void *)symAddress ;
|
symbol = (void *)symAddress ;
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
// VZ: hmm... why is WXSTRINGCAST needed? if it's really modified, we
|
symbol = wxDllGetSymbol(m_handle, symbname);
|
||||||
// should make a copy of it
|
|
||||||
symbol = wxDllGetSymbol(m_handle, WXSTRINGCAST symbname);
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if ( !symbol )
|
if ( !symbol )
|
||||||
@@ -234,7 +232,7 @@ wxLibrary *wxLibraries::LoadLibrary(const wxString& name)
|
|||||||
const char *envLibPath = getenv("LD_LIBRARY_PATH");
|
const char *envLibPath = getenv("LD_LIBRARY_PATH");
|
||||||
if ( envLibPath )
|
if ( envLibPath )
|
||||||
libPath << ':' << envLibPath;
|
libPath << ':' << envLibPath;
|
||||||
wxStringTokenizer tokenizer(libPath, ':');
|
wxStringTokenizer tokenizer(libPath, _T(':'));
|
||||||
while ( tokenizer.HasMoreToken() )
|
while ( tokenizer.HasMoreToken() )
|
||||||
{
|
{
|
||||||
wxString fullname(tokenizer.NextToken());
|
wxString fullname(tokenizer.NextToken());
|
||||||
|
@@ -171,7 +171,7 @@ bool wxMouseEvent::ButtonDClick(int but) const
|
|||||||
case 3:
|
case 3:
|
||||||
return RightDClick();
|
return RightDClick();
|
||||||
default:
|
default:
|
||||||
wxFAIL_MSG("invalid parameter in wxMouseEvent::ButtonDClick");
|
wxFAIL_MSG(_T("invalid parameter in wxMouseEvent::ButtonDClick"));
|
||||||
}
|
}
|
||||||
|
|
||||||
return FALSE;
|
return FALSE;
|
||||||
@@ -192,7 +192,7 @@ bool wxMouseEvent::ButtonDown(int but) const
|
|||||||
case 3:
|
case 3:
|
||||||
return RightDown();
|
return RightDown();
|
||||||
default:
|
default:
|
||||||
wxFAIL_MSG("invalid parameter in wxMouseEvent::ButtonDown");
|
wxFAIL_MSG(_T("invalid parameter in wxMouseEvent::ButtonDown"));
|
||||||
}
|
}
|
||||||
|
|
||||||
return FALSE;
|
return FALSE;
|
||||||
@@ -212,7 +212,7 @@ bool wxMouseEvent::ButtonUp(int but) const
|
|||||||
case 3:
|
case 3:
|
||||||
return RightUp();
|
return RightUp();
|
||||||
default:
|
default:
|
||||||
wxFAIL_MSG("invalid parameter in wxMouseEvent::ButtonUp");
|
wxFAIL_MSG(_T("invalid parameter in wxMouseEvent::ButtonUp"));
|
||||||
}
|
}
|
||||||
|
|
||||||
return FALSE;
|
return FALSE;
|
||||||
@@ -231,7 +231,7 @@ bool wxMouseEvent::Button(int but) const
|
|||||||
case 3:
|
case 3:
|
||||||
return (RightDown() || RightUp() || RightDClick());
|
return (RightDown() || RightUp() || RightDClick());
|
||||||
default:
|
default:
|
||||||
wxFAIL_MSG("invalid parameter in wxMouseEvent::Button");
|
wxFAIL_MSG(_T("invalid parameter in wxMouseEvent::Button"));
|
||||||
}
|
}
|
||||||
|
|
||||||
return FALSE;
|
return FALSE;
|
||||||
@@ -249,7 +249,7 @@ bool wxMouseEvent::ButtonIsDown(int but) const
|
|||||||
case 3:
|
case 3:
|
||||||
return RightIsDown();
|
return RightIsDown();
|
||||||
default:
|
default:
|
||||||
wxFAIL_MSG("invalid parameter in wxMouseEvent::ButtonIsDown");
|
wxFAIL_MSG(_T("invalid parameter in wxMouseEvent::ButtonIsDown"));
|
||||||
}
|
}
|
||||||
|
|
||||||
return FALSE;
|
return FALSE;
|
||||||
@@ -511,7 +511,7 @@ void wxEvtHandler::Connect( int id, int lastId,
|
|||||||
bool wxEvtHandler::SearchDynamicEventTable( wxEvent& event )
|
bool wxEvtHandler::SearchDynamicEventTable( wxEvent& event )
|
||||||
{
|
{
|
||||||
wxCHECK_MSG( m_dynamicEvents, FALSE,
|
wxCHECK_MSG( m_dynamicEvents, FALSE,
|
||||||
"caller should check that we have dynamic events" );
|
_T("caller should check that we have dynamic events") );
|
||||||
|
|
||||||
int commandId = event.GetId();
|
int commandId = event.GetId();
|
||||||
|
|
||||||
|
@@ -156,16 +156,23 @@
|
|||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
// static functions
|
// static functions
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
bool wxFile::Exists(const char *name)
|
bool wxFile::Exists(const wxChar *name)
|
||||||
{
|
{
|
||||||
struct stat st;
|
struct stat st;
|
||||||
|
#if wxUSE_UNICODE && wxMBFILES
|
||||||
|
wxCharBuffer fname = wxConv_file.cWC2MB(name);
|
||||||
|
|
||||||
return !access(name, 0) &&
|
return !access(fname, 0) &&
|
||||||
!stat((char*) name, &st) &&
|
!stat(MBSTRINGCAST fname, &st) &&
|
||||||
(st.st_mode & S_IFREG);
|
(st.st_mode & S_IFREG);
|
||||||
|
#else
|
||||||
|
return !access(name, 0) &&
|
||||||
|
!stat((wxChar*) name, &st) &&
|
||||||
|
(st.st_mode & S_IFREG);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
bool wxFile::Access(const char *name, OpenMode mode)
|
bool wxFile::Access(const wxChar *name, OpenMode mode)
|
||||||
{
|
{
|
||||||
int how = 0;
|
int how = 0;
|
||||||
|
|
||||||
@@ -179,10 +186,10 @@ bool wxFile::Access(const char *name, OpenMode mode)
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
wxFAIL_MSG("bad wxFile::Access mode parameter.");
|
wxFAIL_MSG(_T("bad wxFile::Access mode parameter."));
|
||||||
}
|
}
|
||||||
|
|
||||||
return access(name, how) == 0;
|
return access(wxFNCONV(name), how) == 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
@@ -190,7 +197,7 @@ bool wxFile::Access(const char *name, OpenMode mode)
|
|||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
|
|
||||||
// ctors
|
// ctors
|
||||||
wxFile::wxFile(const char *szFileName, OpenMode mode)
|
wxFile::wxFile(const wxChar *szFileName, OpenMode mode)
|
||||||
{
|
{
|
||||||
m_fd = fd_invalid;
|
m_fd = fd_invalid;
|
||||||
m_error = FALSE;
|
m_error = FALSE;
|
||||||
@@ -205,11 +212,11 @@ wxFile::~wxFile()
|
|||||||
}
|
}
|
||||||
|
|
||||||
// create the file, fail if it already exists and bOverwrite
|
// create the file, fail if it already exists and bOverwrite
|
||||||
bool wxFile::Create(const char *szFileName, bool bOverwrite, int accessMode)
|
bool wxFile::Create(const wxChar *szFileName, bool bOverwrite, int accessMode)
|
||||||
{
|
{
|
||||||
// if bOverwrite we create a new file or truncate the existing one,
|
// 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
|
// otherwise we only create the new file and fail if it already exists
|
||||||
int fd = open(szFileName,
|
int fd = open(wxFNCONV(szFileName),
|
||||||
O_WRONLY | O_CREAT | (bOverwrite ? O_TRUNC : O_EXCL)
|
O_WRONLY | O_CREAT | (bOverwrite ? O_TRUNC : O_EXCL)
|
||||||
ACCESS(accessMode));
|
ACCESS(accessMode));
|
||||||
|
|
||||||
@@ -224,7 +231,7 @@ bool wxFile::Create(const char *szFileName, bool bOverwrite, int accessMode)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// open the file
|
// open the file
|
||||||
bool wxFile::Open(const char *szFileName, OpenMode mode, int accessMode)
|
bool wxFile::Open(const wxChar *szFileName, OpenMode mode, int accessMode)
|
||||||
{
|
{
|
||||||
int flags = O_BINARY;
|
int flags = O_BINARY;
|
||||||
|
|
||||||
@@ -246,7 +253,7 @@ bool wxFile::Open(const char *szFileName, OpenMode mode, int accessMode)
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
int fd = open(szFileName, flags ACCESS(accessMode));
|
int fd = open(wxFNCONV(szFileName), flags ACCESS(accessMode));
|
||||||
|
|
||||||
if ( fd == -1 ) {
|
if ( fd == -1 ) {
|
||||||
wxLogSysError(_("can't open file '%s'"), szFileName);
|
wxLogSysError(_("can't open file '%s'"), szFileName);
|
||||||
@@ -474,21 +481,21 @@ bool wxTempFile::Open(const wxString& strName)
|
|||||||
// different partitions for example). Unfortunately, the only standard
|
// different partitions for example). Unfortunately, the only standard
|
||||||
// (POSIX) temp file creation function tmpnam() can't do it.
|
// (POSIX) temp file creation function tmpnam() can't do it.
|
||||||
#if defined(__UNIX__) || defined(__WXSTUBS__)|| defined( __WXMAC__ )
|
#if defined(__UNIX__) || defined(__WXSTUBS__)|| defined( __WXMAC__ )
|
||||||
static const char *szMktempSuffix = "XXXXXX";
|
static const wxChar *szMktempSuffix = _T("XXXXXX");
|
||||||
m_strTemp << strName << szMktempSuffix;
|
m_strTemp << strName << szMktempSuffix;
|
||||||
mktemp((char *)m_strTemp.c_str()); // will do because length doesn't change
|
mktemp(MBSTRINGCAST m_strTemp.mb_str()); // will do because length doesn't change
|
||||||
#else // Windows
|
#else // Windows
|
||||||
wxString strPath;
|
wxString strPath;
|
||||||
wxSplitPath(strName, &strPath, NULL, NULL);
|
wxSplitPath(strName, &strPath, NULL, NULL);
|
||||||
if ( strPath.IsEmpty() )
|
if ( strPath.IsEmpty() )
|
||||||
strPath = '.'; // GetTempFileName will fail if we give it empty string
|
strPath = _T('.'); // GetTempFileName will fail if we give it empty string
|
||||||
#ifdef __WIN32__
|
#ifdef __WIN32__
|
||||||
if ( !GetTempFileName(strPath, "wx_",0, m_strTemp.GetWriteBuf(MAX_PATH)) )
|
if ( !GetTempFileName(strPath, _T("wx_"),0, m_strTemp.GetWriteBuf(MAX_PATH)) )
|
||||||
#else
|
#else
|
||||||
// Not sure why MSVC++ 1.5 header defines first param as BYTE - bug?
|
// Not sure why MSVC++ 1.5 header defines first param as BYTE - bug?
|
||||||
if ( !GetTempFileName((BYTE) (const char*) strPath, "wx_",0, m_strTemp.GetWriteBuf(MAX_PATH)) )
|
if ( !GetTempFileName((BYTE) (const wxChar*) strPath, _T("wx_"),0, m_strTemp.GetWriteBuf(MAX_PATH)) )
|
||||||
#endif
|
#endif
|
||||||
wxLogLastError("GetTempFileName");
|
wxLogLastError(_T("GetTempFileName"));
|
||||||
m_strTemp.UngetWriteBuf();
|
m_strTemp.UngetWriteBuf();
|
||||||
#endif // Windows/Unix
|
#endif // Windows/Unix
|
||||||
|
|
||||||
@@ -496,7 +503,7 @@ bool wxTempFile::Open(const wxString& strName)
|
|||||||
#ifdef __UNIX__
|
#ifdef __UNIX__
|
||||||
// create the file with the same mode as the original one under Unix
|
// create the file with the same mode as the original one under Unix
|
||||||
struct stat st;
|
struct stat st;
|
||||||
if ( stat(strName, &st) == 0 )
|
if ( stat(strName.fn_str(), &st) == 0 )
|
||||||
{
|
{
|
||||||
// this assumes that only lower bits of st_mode contain the access
|
// this assumes that only lower bits of st_mode contain the access
|
||||||
// rights, but it's true for at least all Unices which have S_IXXXX()
|
// rights, but it's true for at least all Unices which have S_IXXXX()
|
||||||
@@ -506,7 +513,7 @@ bool wxTempFile::Open(const wxString& strName)
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
wxLogLastError("stat");
|
wxLogLastError(_T("stat"));
|
||||||
}
|
}
|
||||||
|
|
||||||
// we want to create the file with exactly the same access rights as the
|
// we want to create the file with exactly the same access rights as the
|
||||||
@@ -538,12 +545,12 @@ bool wxTempFile::Commit()
|
|||||||
{
|
{
|
||||||
m_file.Close();
|
m_file.Close();
|
||||||
|
|
||||||
if ( wxFile::Exists(m_strName) && remove(m_strName) != 0 ) {
|
if ( wxFile::Exists(m_strName) && remove(m_strName.fn_str()) != 0 ) {
|
||||||
wxLogSysError(_("can't remove file '%s'"), m_strName.c_str());
|
wxLogSysError(_("can't remove file '%s'"), m_strName.c_str());
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( rename(m_strTemp, m_strName) != 0 ) {
|
if ( rename(m_strTemp.fn_str(), m_strName.fn_str()) != 0 ) {
|
||||||
wxLogSysError(_("can't commit changes to file '%s'"), m_strName.c_str());
|
wxLogSysError(_("can't commit changes to file '%s'"), m_strName.c_str());
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
@@ -554,6 +561,6 @@ bool wxTempFile::Commit()
|
|||||||
void wxTempFile::Discard()
|
void wxTempFile::Discard()
|
||||||
{
|
{
|
||||||
m_file.Close();
|
m_file.Close();
|
||||||
if ( remove(m_strTemp) != 0 )
|
if ( remove(m_strTemp.fn_str()) != 0 )
|
||||||
wxLogSysError(_("can't remove temporary file '%s'"), m_strTemp.c_str());
|
wxLogSysError(_("can't remove temporary file '%s'"), m_strTemp.c_str());
|
||||||
}
|
}
|
||||||
|
@@ -90,17 +90,17 @@ wxString wxFileConfig::GetGlobalDir()
|
|||||||
wxString strDir;
|
wxString strDir;
|
||||||
|
|
||||||
#ifdef __UNIX__
|
#ifdef __UNIX__
|
||||||
strDir = "/etc/";
|
strDir = _T("/etc/");
|
||||||
#elif defined(__WXSTUBS__)
|
#elif defined(__WXSTUBS__)
|
||||||
wxASSERT_MSG( FALSE, "TODO" ) ;
|
wxASSERT_MSG( FALSE, _T("TODO") ) ;
|
||||||
#elif defined(__WXMAC__)
|
#elif defined(__WXMAC__)
|
||||||
wxASSERT_MSG( FALSE, "TODO" ) ;
|
wxASSERT_MSG( FALSE, _T("TODO") ) ;
|
||||||
#else // Windows
|
#else // Windows
|
||||||
char szWinDir[MAX_PATH];
|
wxChar szWinDir[MAX_PATH];
|
||||||
::GetWindowsDirectory(szWinDir, MAX_PATH);
|
::GetWindowsDirectory(szWinDir, MAX_PATH);
|
||||||
|
|
||||||
strDir = szWinDir;
|
strDir = szWinDir;
|
||||||
strDir << '\\';
|
strDir << _T('\\');
|
||||||
#endif // Unix/Windows
|
#endif // Unix/Windows
|
||||||
|
|
||||||
return strDir;
|
return strDir;
|
||||||
@@ -113,42 +113,42 @@ wxString wxFileConfig::GetLocalDir()
|
|||||||
wxGetHomeDir(&strDir);
|
wxGetHomeDir(&strDir);
|
||||||
|
|
||||||
#ifdef __UNIX__
|
#ifdef __UNIX__
|
||||||
if (strDir.Last() != '/') strDir << '/';
|
if (strDir.Last() != _T('/')) strDir << _T('/');
|
||||||
#else
|
#else
|
||||||
if (strDir.Last() != '\\') strDir << '\\';
|
if (strDir.Last() != _T('\\')) strDir << _T('\\');
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
return strDir;
|
return strDir;
|
||||||
}
|
}
|
||||||
|
|
||||||
wxString wxFileConfig::GetGlobalFileName(const char *szFile)
|
wxString wxFileConfig::GetGlobalFileName(const wxChar *szFile)
|
||||||
{
|
{
|
||||||
wxString str = GetGlobalDir();
|
wxString str = GetGlobalDir();
|
||||||
str << szFile;
|
str << szFile;
|
||||||
|
|
||||||
if ( strchr(szFile, '.') == NULL )
|
if ( wxStrchr(szFile, _T('.')) == NULL )
|
||||||
#ifdef __UNIX__
|
#ifdef __UNIX__
|
||||||
str << ".conf";
|
str << _T(".conf");
|
||||||
#else // Windows
|
#else // Windows
|
||||||
str << ".ini";
|
str << _T(".ini");
|
||||||
#endif // UNIX/Win
|
#endif // UNIX/Win
|
||||||
|
|
||||||
return str;
|
return str;
|
||||||
}
|
}
|
||||||
|
|
||||||
wxString wxFileConfig::GetLocalFileName(const char *szFile)
|
wxString wxFileConfig::GetLocalFileName(const wxChar *szFile)
|
||||||
{
|
{
|
||||||
wxString str = GetLocalDir();
|
wxString str = GetLocalDir();
|
||||||
|
|
||||||
#ifdef __UNIX__
|
#ifdef __UNIX__
|
||||||
str << '.';
|
str << _T('.');
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
str << szFile;
|
str << szFile;
|
||||||
|
|
||||||
#ifdef __WXMSW__
|
#ifdef __WXMSW__
|
||||||
if ( strchr(szFile, '.') == NULL )
|
if ( wxStrchr(szFile, _T('.')) == NULL )
|
||||||
str << ".ini";
|
str << _T(".ini");
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
return str;
|
return str;
|
||||||
@@ -265,8 +265,8 @@ wxFileConfig::~wxFileConfig()
|
|||||||
|
|
||||||
void wxFileConfig::Parse(wxTextFile& file, bool bLocal)
|
void wxFileConfig::Parse(wxTextFile& file, bool bLocal)
|
||||||
{
|
{
|
||||||
const char *pStart;
|
const wxChar *pStart;
|
||||||
const char *pEnd;
|
const wxChar *pEnd;
|
||||||
wxString strLine;
|
wxString strLine;
|
||||||
|
|
||||||
size_t nLineCount = file.GetLineCount();
|
size_t nLineCount = file.GetLineCount();
|
||||||
@@ -278,22 +278,22 @@ void wxFileConfig::Parse(wxTextFile& file, bool bLocal)
|
|||||||
LineListAppend(strLine);
|
LineListAppend(strLine);
|
||||||
|
|
||||||
// skip leading spaces
|
// skip leading spaces
|
||||||
for ( pStart = strLine; isspace(*pStart); pStart++ )
|
for ( pStart = strLine; wxIsspace(*pStart); pStart++ )
|
||||||
;
|
;
|
||||||
|
|
||||||
// skip blank/comment lines
|
// skip blank/comment lines
|
||||||
if ( *pStart == '\0'|| *pStart == ';' || *pStart == '#' )
|
if ( *pStart == _T('\0')|| *pStart == _T(';') || *pStart == _T('#') )
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
if ( *pStart == '[' ) { // a new group
|
if ( *pStart == _T('[') ) { // a new group
|
||||||
pEnd = pStart;
|
pEnd = pStart;
|
||||||
|
|
||||||
while ( *++pEnd != ']' ) {
|
while ( *++pEnd != _T(']') ) {
|
||||||
if ( *pEnd == '\n' || *pEnd == '\0' )
|
if ( *pEnd == _T('\n') || *pEnd == _T('\0') )
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( *pEnd != ']' ) {
|
if ( *pEnd != _T(']') ) {
|
||||||
wxLogError(_("file '%s': unexpected character %c at line %d."),
|
wxLogError(_("file '%s': unexpected character %c at line %d."),
|
||||||
file.GetName(), *pEnd, n + 1);
|
file.GetName(), *pEnd, n + 1);
|
||||||
continue; // skip this line
|
continue; // skip this line
|
||||||
@@ -313,15 +313,15 @@ void wxFileConfig::Parse(wxTextFile& file, bool bLocal)
|
|||||||
|
|
||||||
// check that there is nothing except comments left on this line
|
// check that there is nothing except comments left on this line
|
||||||
bool bCont = TRUE;
|
bool bCont = TRUE;
|
||||||
while ( *++pEnd != '\0' && bCont ) {
|
while ( *++pEnd != _T('\0') && bCont ) {
|
||||||
switch ( *pEnd ) {
|
switch ( *pEnd ) {
|
||||||
case '#':
|
case _T('#'):
|
||||||
case ';':
|
case _T(';'):
|
||||||
bCont = FALSE;
|
bCont = FALSE;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case ' ':
|
case _T(' '):
|
||||||
case '\t':
|
case _T('\t'):
|
||||||
// ignore whitespace ('\n' impossible here)
|
// ignore whitespace ('\n' impossible here)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
@@ -334,9 +334,9 @@ void wxFileConfig::Parse(wxTextFile& file, bool bLocal)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
else { // a key
|
else { // a key
|
||||||
const char *pEnd = pStart;
|
const wxChar *pEnd = pStart;
|
||||||
while ( !isspace(*pEnd) ) {
|
while ( !wxIsspace(*pEnd) ) {
|
||||||
if ( *pEnd == '\\' ) {
|
if ( *pEnd == _T('\\') ) {
|
||||||
// next character may be space or not - still take it because it's
|
// next character may be space or not - still take it because it's
|
||||||
// quoted
|
// quoted
|
||||||
pEnd++;
|
pEnd++;
|
||||||
@@ -351,7 +351,7 @@ void wxFileConfig::Parse(wxTextFile& file, bool bLocal)
|
|||||||
while ( isspace(*pEnd) )
|
while ( isspace(*pEnd) )
|
||||||
pEnd++;
|
pEnd++;
|
||||||
|
|
||||||
if ( *pEnd++ != '=' ) {
|
if ( *pEnd++ != _T('=') ) {
|
||||||
wxLogError(_("file '%s', line %d: '=' expected."),
|
wxLogError(_("file '%s', line %d: '=' expected."),
|
||||||
file.GetName(), n + 1);
|
file.GetName(), n + 1);
|
||||||
}
|
}
|
||||||
@@ -389,7 +389,7 @@ void wxFileConfig::Parse(wxTextFile& file, bool bLocal)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// skip whitespace
|
// skip whitespace
|
||||||
while ( isspace(*pEnd) )
|
while ( wxIsspace(*pEnd) )
|
||||||
pEnd++;
|
pEnd++;
|
||||||
|
|
||||||
pEntry->SetValue(FilterInValue(pEnd), FALSE /* read from file */);
|
pEntry->SetValue(FilterInValue(pEnd), FALSE /* read from file */);
|
||||||
@@ -574,7 +574,7 @@ bool wxFileConfig::Read(const wxString& key, long *pl) const
|
|||||||
{
|
{
|
||||||
wxString str;
|
wxString str;
|
||||||
if ( Read(key, & str) ) {
|
if ( Read(key, & str) ) {
|
||||||
*pl = atol(str);
|
*pl = wxAtol(str);
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
@@ -589,7 +589,7 @@ bool wxFileConfig::Write(const wxString& key, const wxString& szValue)
|
|||||||
wxString strName = path.Name();
|
wxString strName = path.Name();
|
||||||
if ( strName.IsEmpty() ) {
|
if ( strName.IsEmpty() ) {
|
||||||
// setting the value of a group is an error
|
// setting the value of a group is an error
|
||||||
wxASSERT_MSG( IsEmpty(szValue), "can't set value of a group!" );
|
wxASSERT_MSG( wxIsEmpty(szValue), _T("can't set value of a group!") );
|
||||||
|
|
||||||
// ... except if it's empty in which case it's a way to force it's creation
|
// ... except if it's empty in which case it's a way to force it's creation
|
||||||
m_pCurrentGroup->SetDirty();
|
m_pCurrentGroup->SetDirty();
|
||||||
@@ -623,7 +623,7 @@ bool wxFileConfig::Write(const wxString& key, long lValue)
|
|||||||
{
|
{
|
||||||
// ltoa() is not ANSI :-(
|
// ltoa() is not ANSI :-(
|
||||||
wxString buf;
|
wxString buf;
|
||||||
buf.Printf("%ld", lValue);
|
buf.Printf(_T("%ld"), lValue);
|
||||||
return Write(key, buf);
|
return Write(key, buf);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -708,7 +708,7 @@ bool wxFileConfig::DeleteEntry(const wxString& key, bool bGroupIfEmptyAlso)
|
|||||||
if ( bGroupIfEmptyAlso && m_pCurrentGroup->IsEmpty() ) {
|
if ( bGroupIfEmptyAlso && m_pCurrentGroup->IsEmpty() ) {
|
||||||
if ( m_pCurrentGroup != m_pRootGroup ) {
|
if ( m_pCurrentGroup != m_pRootGroup ) {
|
||||||
ConfigGroup *pGroup = m_pCurrentGroup;
|
ConfigGroup *pGroup = m_pCurrentGroup;
|
||||||
SetPath(".."); // changes m_pCurrentGroup!
|
SetPath(_T("..")); // changes m_pCurrentGroup!
|
||||||
m_pCurrentGroup->DeleteSubgroupByName(pGroup->Name());
|
m_pCurrentGroup->DeleteSubgroupByName(pGroup->Name());
|
||||||
}
|
}
|
||||||
//else: never delete the root group
|
//else: never delete the root group
|
||||||
@@ -728,12 +728,10 @@ bool wxFileConfig::DeleteAll()
|
|||||||
{
|
{
|
||||||
CleanUp();
|
CleanUp();
|
||||||
|
|
||||||
const char *szFile = m_strLocalFile;
|
if ( remove(m_strLocalFile.fn_str()) == -1 )
|
||||||
|
wxLogSysError(_("can't delete user configuration file '%s'"), m_strLocalFile.c_str());
|
||||||
|
|
||||||
if ( remove(szFile) == -1 )
|
m_strLocalFile = m_strGlobalFile = _T("");
|
||||||
wxLogSysError(_("can't delete user configuration file '%s'"), szFile);
|
|
||||||
|
|
||||||
m_strLocalFile = m_strGlobalFile = "";
|
|
||||||
Init();
|
Init();
|
||||||
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
@@ -905,7 +903,7 @@ LineList *ConfigGroup::GetGroupLine()
|
|||||||
// this group wasn't present in local config file, add it now
|
// this group wasn't present in local config file, add it now
|
||||||
if ( pParent != NULL ) {
|
if ( pParent != NULL ) {
|
||||||
wxString strFullName;
|
wxString strFullName;
|
||||||
strFullName << "[" << (GetFullName().c_str() + 1) << "]"; // +1: no '/'
|
strFullName << _T("[") << (GetFullName().c_str() + 1) << _T("]"); // +1: no '/'
|
||||||
m_pLine = m_pConfig->LineListInsert(strFullName,
|
m_pLine = m_pConfig->LineListInsert(strFullName,
|
||||||
pParent->GetLastGroupLine());
|
pParent->GetLastGroupLine());
|
||||||
pParent->SetLastGroup(this); // we're surely after all the others
|
pParent->SetLastGroup(this); // we're surely after all the others
|
||||||
@@ -963,7 +961,7 @@ void ConfigGroup::Rename(const wxString& newName)
|
|||||||
|
|
||||||
LineList *line = GetGroupLine();
|
LineList *line = GetGroupLine();
|
||||||
wxString strFullName;
|
wxString strFullName;
|
||||||
strFullName << "[" << (GetFullName().c_str() + 1) << "]"; // +1: no '/'
|
strFullName << _T("[") << (GetFullName().c_str() + 1) << _T("]"); // +1: no '/'
|
||||||
line->SetText(strFullName);
|
line->SetText(strFullName);
|
||||||
|
|
||||||
SetDirty();
|
SetDirty();
|
||||||
@@ -974,7 +972,7 @@ wxString ConfigGroup::GetFullName() const
|
|||||||
if ( Parent() )
|
if ( Parent() )
|
||||||
return Parent()->GetFullName() + wxCONFIG_PATH_SEPARATOR + Name();
|
return Parent()->GetFullName() + wxCONFIG_PATH_SEPARATOR + Name();
|
||||||
else
|
else
|
||||||
return "";
|
return _T("");
|
||||||
}
|
}
|
||||||
|
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
@@ -983,7 +981,7 @@ wxString ConfigGroup::GetFullName() const
|
|||||||
|
|
||||||
// use binary search because the array is sorted
|
// use binary search because the array is sorted
|
||||||
ConfigEntry *
|
ConfigEntry *
|
||||||
ConfigGroup::FindEntry(const char *szName) const
|
ConfigGroup::FindEntry(const wxChar *szName) const
|
||||||
{
|
{
|
||||||
size_t i,
|
size_t i,
|
||||||
lo = 0,
|
lo = 0,
|
||||||
@@ -996,9 +994,9 @@ ConfigGroup::FindEntry(const char *szName) const
|
|||||||
pEntry = m_aEntries[i];
|
pEntry = m_aEntries[i];
|
||||||
|
|
||||||
#if wxCONFIG_CASE_SENSITIVE
|
#if wxCONFIG_CASE_SENSITIVE
|
||||||
res = strcmp(pEntry->Name(), szName);
|
res = wxStrcmp(pEntry->Name(), szName);
|
||||||
#else
|
#else
|
||||||
res = Stricmp(pEntry->Name(), szName);
|
res = wxStricmp(pEntry->Name(), szName);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if ( res > 0 )
|
if ( res > 0 )
|
||||||
@@ -1013,7 +1011,7 @@ ConfigGroup::FindEntry(const char *szName) const
|
|||||||
}
|
}
|
||||||
|
|
||||||
ConfigGroup *
|
ConfigGroup *
|
||||||
ConfigGroup::FindSubgroup(const char *szName) const
|
ConfigGroup::FindSubgroup(const wxChar *szName) const
|
||||||
{
|
{
|
||||||
size_t i,
|
size_t i,
|
||||||
lo = 0,
|
lo = 0,
|
||||||
@@ -1026,9 +1024,9 @@ ConfigGroup::FindSubgroup(const char *szName) const
|
|||||||
pGroup = m_aSubgroups[i];
|
pGroup = m_aSubgroups[i];
|
||||||
|
|
||||||
#if wxCONFIG_CASE_SENSITIVE
|
#if wxCONFIG_CASE_SENSITIVE
|
||||||
res = strcmp(pGroup->Name(), szName);
|
res = wxStrcmp(pGroup->Name(), szName);
|
||||||
#else
|
#else
|
||||||
res = Stricmp(pGroup->Name(), szName);
|
res = wxStricmp(pGroup->Name(), szName);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if ( res > 0 )
|
if ( res > 0 )
|
||||||
@@ -1081,7 +1079,7 @@ ConfigGroup::AddSubgroup(const wxString& strName)
|
|||||||
delete several of them.
|
delete several of them.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
bool ConfigGroup::DeleteSubgroupByName(const char *szName)
|
bool ConfigGroup::DeleteSubgroupByName(const wxChar *szName)
|
||||||
{
|
{
|
||||||
return DeleteSubgroup(FindSubgroup(szName));
|
return DeleteSubgroup(FindSubgroup(szName));
|
||||||
}
|
}
|
||||||
@@ -1153,7 +1151,7 @@ bool ConfigGroup::DeleteSubgroup(ConfigGroup *pGroup)
|
|||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ConfigGroup::DeleteEntry(const char *szName)
|
bool ConfigGroup::DeleteEntry(const wxChar *szName)
|
||||||
{
|
{
|
||||||
ConfigEntry *pEntry = FindEntry(szName);
|
ConfigEntry *pEntry = FindEntry(szName);
|
||||||
wxCHECK( pEntry != NULL, FALSE ); // deleting non existing item?
|
wxCHECK( pEntry != NULL, FALSE ); // deleting non existing item?
|
||||||
@@ -1272,7 +1270,7 @@ void ConfigEntry::SetValue(const wxString& strValue, bool bUser)
|
|||||||
if ( bUser ) {
|
if ( bUser ) {
|
||||||
wxString strVal = FilterOutValue(strValue);
|
wxString strVal = FilterOutValue(strValue);
|
||||||
wxString strLine;
|
wxString strLine;
|
||||||
strLine << m_strName << " = " << strVal;
|
strLine << m_strName << _T(" = ") << strVal;
|
||||||
|
|
||||||
if ( m_pLine != NULL ) {
|
if ( m_pLine != NULL ) {
|
||||||
// entry was read from the local config file, just modify the line
|
// entry was read from the local config file, just modify the line
|
||||||
@@ -1309,9 +1307,9 @@ int CompareEntries(ConfigEntry *p1,
|
|||||||
ConfigEntry *p2)
|
ConfigEntry *p2)
|
||||||
{
|
{
|
||||||
#if wxCONFIG_CASE_SENSITIVE
|
#if wxCONFIG_CASE_SENSITIVE
|
||||||
return strcmp(p1->Name(), p2->Name());
|
return wxStrcmp(p1->Name(), p2->Name());
|
||||||
#else
|
#else
|
||||||
return Stricmp(p1->Name(), p2->Name());
|
return wxStricmp(p1->Name(), p2->Name());
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1319,9 +1317,9 @@ int CompareGroups(ConfigGroup *p1,
|
|||||||
ConfigGroup *p2)
|
ConfigGroup *p2)
|
||||||
{
|
{
|
||||||
#if wxCONFIG_CASE_SENSITIVE
|
#if wxCONFIG_CASE_SENSITIVE
|
||||||
return strcmp(p1->Name(), p2->Name());
|
return wxStrcmp(p1->Name(), p2->Name());
|
||||||
#else
|
#else
|
||||||
return Stricmp(p1->Name(), p2->Name());
|
return wxStricmp(p1->Name(), p2->Name());
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1338,31 +1336,31 @@ static wxString FilterInValue(const wxString& str)
|
|||||||
bool bQuoted = !str.IsEmpty() && str[0] == '"';
|
bool bQuoted = !str.IsEmpty() && str[0] == '"';
|
||||||
|
|
||||||
for ( size_t n = bQuoted ? 1 : 0; n < str.Len(); n++ ) {
|
for ( size_t n = bQuoted ? 1 : 0; n < str.Len(); n++ ) {
|
||||||
if ( str[n] == '\\' ) {
|
if ( str[n] == _T('\\') ) {
|
||||||
switch ( str[++n] ) {
|
switch ( str[++n] ) {
|
||||||
case 'n':
|
case _T('n'):
|
||||||
strResult += '\n';
|
strResult += _T('\n');
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'r':
|
case _T('r'):
|
||||||
strResult += '\r';
|
strResult += _T('\r');
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 't':
|
case _T('t'):
|
||||||
strResult += '\t';
|
strResult += _T('\t');
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case '\\':
|
case _T('\\'):
|
||||||
strResult += '\\';
|
strResult += _T('\\');
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case '"':
|
case _T('"'):
|
||||||
strResult += '"';
|
strResult += _T('"');
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
if ( str[n] != '"' || !bQuoted )
|
if ( str[n] != _T('"') || !bQuoted )
|
||||||
strResult += str[n];
|
strResult += str[n];
|
||||||
else if ( n != str.Len() - 1 ) {
|
else if ( n != str.Len() - 1 ) {
|
||||||
wxLogWarning(_("unexpected \" at position %d in '%s'."),
|
wxLogWarning(_("unexpected \" at position %d in '%s'."),
|
||||||
@@ -1385,33 +1383,33 @@ static wxString FilterOutValue(const wxString& str)
|
|||||||
strResult.Alloc(str.Len());
|
strResult.Alloc(str.Len());
|
||||||
|
|
||||||
// quoting is necessary to preserve spaces in the beginning of the string
|
// quoting is necessary to preserve spaces in the beginning of the string
|
||||||
bool bQuote = isspace(str[0]) || str[0] == '"';
|
bool bQuote = wxIsspace(str[0]) || str[0] == _T('"');
|
||||||
|
|
||||||
if ( bQuote )
|
if ( bQuote )
|
||||||
strResult += '"';
|
strResult += _T('"');
|
||||||
|
|
||||||
char c;
|
wxChar c;
|
||||||
for ( size_t n = 0; n < str.Len(); n++ ) {
|
for ( size_t n = 0; n < str.Len(); n++ ) {
|
||||||
switch ( str[n] ) {
|
switch ( str[n] ) {
|
||||||
case '\n':
|
case _T('\n'):
|
||||||
c = 'n';
|
c = _T('n');
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case '\r':
|
case _T('\r'):
|
||||||
c = 'r';
|
c = _T('r');
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case '\t':
|
case _T('\t'):
|
||||||
c = 't';
|
c = _T('t');
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case '\\':
|
case _T('\\'):
|
||||||
c = '\\';
|
c = _T('\\');
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case '"':
|
case _T('"'):
|
||||||
if ( bQuote ) {
|
if ( bQuote ) {
|
||||||
c = '"';
|
c = _T('"');
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
//else: fall through
|
//else: fall through
|
||||||
@@ -1422,11 +1420,11 @@ static wxString FilterOutValue(const wxString& str)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// we get here only for special characters
|
// we get here only for special characters
|
||||||
strResult << '\\' << c;
|
strResult << _T('\\') << c;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( bQuote )
|
if ( bQuote )
|
||||||
strResult += '"';
|
strResult += _T('"');
|
||||||
|
|
||||||
return strResult;
|
return strResult;
|
||||||
}
|
}
|
||||||
@@ -1437,8 +1435,8 @@ static wxString FilterInEntryName(const wxString& str)
|
|||||||
wxString strResult;
|
wxString strResult;
|
||||||
strResult.Alloc(str.Len());
|
strResult.Alloc(str.Len());
|
||||||
|
|
||||||
for ( const char *pc = str.c_str(); *pc != '\0'; pc++ ) {
|
for ( const wxChar *pc = str.c_str(); *pc != '\0'; pc++ ) {
|
||||||
if ( *pc == '\\' )
|
if ( *pc == _T('\\') )
|
||||||
pc++;
|
pc++;
|
||||||
|
|
||||||
strResult += *pc;
|
strResult += *pc;
|
||||||
@@ -1453,15 +1451,15 @@ static wxString FilterOutEntryName(const wxString& str)
|
|||||||
wxString strResult;
|
wxString strResult;
|
||||||
strResult.Alloc(str.Len());
|
strResult.Alloc(str.Len());
|
||||||
|
|
||||||
for ( const char *pc = str.c_str(); *pc != '\0'; pc++ ) {
|
for ( const wxChar *pc = str.c_str(); *pc != _T('\0'); pc++ ) {
|
||||||
char c = *pc;
|
wxChar c = *pc;
|
||||||
|
|
||||||
// we explicitly allow some of "safe" chars and 8bit ASCII characters
|
// we explicitly allow some of "safe" chars and 8bit ASCII characters
|
||||||
// which will probably never have special meaning
|
// which will probably never have special meaning
|
||||||
// NB: note that wxCONFIG_IMMUTABLE_PREFIX and wxCONFIG_PATH_SEPARATOR
|
// NB: note that wxCONFIG_IMMUTABLE_PREFIX and wxCONFIG_PATH_SEPARATOR
|
||||||
// should *not* be quoted
|
// should *not* be quoted
|
||||||
if ( !isalnum(c) && !strchr("@_/-!.*%", c) && ((c & 0x80) == 0) )
|
if ( !wxIsalnum(c) && !wxStrchr(_T("@_/-!.*%"), c) && ((c & 0x80) == 0) )
|
||||||
strResult += '\\';
|
strResult += _T('\\');
|
||||||
|
|
||||||
strResult += c;
|
strResult += c;
|
||||||
}
|
}
|
||||||
|
File diff suppressed because it is too large
Load Diff
@@ -148,91 +148,91 @@ void wxColourDatabase::Initialize ()
|
|||||||
// Added: Not all
|
// Added: Not all
|
||||||
|
|
||||||
struct cdef {
|
struct cdef {
|
||||||
char *name;
|
wxChar *name;
|
||||||
int r,g,b;
|
int r,g,b;
|
||||||
};
|
};
|
||||||
cdef cc;
|
cdef cc;
|
||||||
static cdef table[]={
|
static cdef table[]={
|
||||||
|
|
||||||
// #ifdef __WXMSW__
|
// #ifdef __WXMSW__
|
||||||
{"AQUAMARINE",112, 219, 147},
|
{_T("AQUAMARINE"),112, 219, 147},
|
||||||
{"BLACK",0, 0, 0},
|
{_T("BLACK"),0, 0, 0},
|
||||||
{"BLUE", 0, 0, 255},
|
{_T("BLUE"), 0, 0, 255},
|
||||||
{"BLUE VIOLET", 159, 95, 159},
|
{_T("BLUE VIOLET"), 159, 95, 159},
|
||||||
{"BROWN", 165, 42, 42},
|
{_T("BROWN"), 165, 42, 42},
|
||||||
{"CADET BLUE", 95, 159, 159},
|
{_T("CADET BLUE"), 95, 159, 159},
|
||||||
{"CORAL", 255, 127, 0},
|
{_T("CORAL"), 255, 127, 0},
|
||||||
{"CORNFLOWER BLUE", 66, 66, 111},
|
{_T("CORNFLOWER BLUE"), 66, 66, 111},
|
||||||
{"CYAN", 0, 255, 255},
|
{_T("CYAN"), 0, 255, 255},
|
||||||
{"DARK GREY", 47, 47, 47}, // ?
|
{_T("DARK GREY"), 47, 47, 47}, // ?
|
||||||
|
|
||||||
{"DARK GREEN", 47, 79, 47},
|
{_T("DARK GREEN"), 47, 79, 47},
|
||||||
{"DARK OLIVE GREEN", 79, 79, 47},
|
{_T("DARK OLIVE GREEN"), 79, 79, 47},
|
||||||
{"DARK ORCHID", 153, 50, 204},
|
{_T("DARK ORCHID"), 153, 50, 204},
|
||||||
{"DARK SLATE BLUE", 107, 35, 142},
|
{_T("DARK SLATE BLUE"), 107, 35, 142},
|
||||||
{"DARK SLATE GREY", 47, 79, 79},
|
{_T("DARK SLATE GREY"), 47, 79, 79},
|
||||||
{"DARK TURQUOISE", 112, 147, 219},
|
{_T("DARK TURQUOISE"), 112, 147, 219},
|
||||||
{"DIM GREY", 84, 84, 84},
|
{_T("DIM GREY"), 84, 84, 84},
|
||||||
{"FIREBRICK", 142, 35, 35},
|
{_T("FIREBRICK"), 142, 35, 35},
|
||||||
{"FOREST GREEN", 35, 142, 35},
|
{_T("FOREST GREEN"), 35, 142, 35},
|
||||||
{"GOLD", 204, 127, 50},
|
{_T("GOLD"), 204, 127, 50},
|
||||||
{"GOLDENROD", 219, 219, 112},
|
{_T("GOLDENROD"), 219, 219, 112},
|
||||||
{"GREY", 128, 128, 128},
|
{_T("GREY"), 128, 128, 128},
|
||||||
{"GREEN", 0, 255, 0},
|
{_T("GREEN"), 0, 255, 0},
|
||||||
{"GREEN YELLOW", 147, 219, 112},
|
{_T("GREEN YELLOW"), 147, 219, 112},
|
||||||
{"INDIAN RED", 79, 47, 47},
|
{_T("INDIAN RED"), 79, 47, 47},
|
||||||
{"KHAKI", 159, 159, 95},
|
{_T("KHAKI"), 159, 159, 95},
|
||||||
{"LIGHT BLUE", 191, 216, 216},
|
{_T("LIGHT BLUE"), 191, 216, 216},
|
||||||
{"LIGHT GREY", 192, 192, 192},
|
{_T("LIGHT GREY"), 192, 192, 192},
|
||||||
{"LIGHT STEEL BLUE", 143, 143, 188},
|
{_T("LIGHT STEEL BLUE"), 143, 143, 188},
|
||||||
{"LIME GREEN", 50, 204, 50},
|
{_T("LIME GREEN"), 50, 204, 50},
|
||||||
{"LIGHT MAGENTA", 255, 0, 255},
|
{_T("LIGHT MAGENTA"), 255, 0, 255},
|
||||||
{"MAGENTA", 255, 0, 255},
|
{_T("MAGENTA"), 255, 0, 255},
|
||||||
{"MAROON", 142, 35, 107},
|
{_T("MAROON"), 142, 35, 107},
|
||||||
{"MEDIUM AQUAMARINE", 50, 204, 153},
|
{_T("MEDIUM AQUAMARINE"), 50, 204, 153},
|
||||||
{"MEDIUM GREY", 100, 100, 100},
|
{_T("MEDIUM GREY"), 100, 100, 100},
|
||||||
{"MEDIUM BLUE", 50, 50, 204},
|
{_T("MEDIUM BLUE"), 50, 50, 204},
|
||||||
{"MEDIUM FOREST GREEN", 107, 142, 35},
|
{_T("MEDIUM FOREST GREEN"), 107, 142, 35},
|
||||||
{"MEDIUM GOLDENROD", 234, 234, 173},
|
{_T("MEDIUM GOLDENROD"), 234, 234, 173},
|
||||||
{"MEDIUM ORCHID", 147, 112, 219},
|
{_T("MEDIUM ORCHID"), 147, 112, 219},
|
||||||
{"MEDIUM SEA GREEN", 66, 111, 66},
|
{_T("MEDIUM SEA GREEN"), 66, 111, 66},
|
||||||
{"MEDIUM SLATE BLUE", 127, 0, 255},
|
{_T("MEDIUM SLATE BLUE"), 127, 0, 255},
|
||||||
{"MEDIUM SPRING GREEN", 127, 255, 0},
|
{_T("MEDIUM SPRING GREEN"), 127, 255, 0},
|
||||||
{"MEDIUM TURQUOISE", 112, 219, 219},
|
{_T("MEDIUM TURQUOISE"), 112, 219, 219},
|
||||||
{"MEDIUM VIOLET RED", 219, 112, 147},
|
{_T("MEDIUM VIOLET RED"), 219, 112, 147},
|
||||||
{"MIDNIGHT BLUE", 47, 47, 79},
|
{_T("MIDNIGHT BLUE"), 47, 47, 79},
|
||||||
{"NAVY", 35, 35, 142},
|
{_T("NAVY"), 35, 35, 142},
|
||||||
{"ORANGE", 204, 50, 50},
|
{_T("ORANGE"), 204, 50, 50},
|
||||||
{"ORANGE RED", 255, 0, 127},
|
{_T("ORANGE RED"), 255, 0, 127},
|
||||||
{"ORCHID", 219, 112, 219},
|
{_T("ORCHID"), 219, 112, 219},
|
||||||
{"PALE GREEN", 143, 188, 143},
|
{_T("PALE GREEN"), 143, 188, 143},
|
||||||
{"PINK", 188, 143, 234},
|
{_T("PINK"), 188, 143, 234},
|
||||||
{"PLUM", 234, 173, 234},
|
{_T("PLUM"), 234, 173, 234},
|
||||||
{"PURPLE", 176, 0, 255},
|
{_T("PURPLE"), 176, 0, 255},
|
||||||
{"RED", 255, 0, 0},
|
{_T("RED"), 255, 0, 0},
|
||||||
{"SALMON", 111, 66, 66},
|
{_T("SALMON"), 111, 66, 66},
|
||||||
{"SEA GREEN", 35, 142, 107},
|
{_T("SEA GREEN"), 35, 142, 107},
|
||||||
{"SIENNA", 142, 107, 35},
|
{_T("SIENNA"), 142, 107, 35},
|
||||||
{"SKY BLUE", 50, 153, 204},
|
{_T("SKY BLUE"), 50, 153, 204},
|
||||||
{"SLATE BLUE", 0, 127, 255},
|
{_T("SLATE BLUE"), 0, 127, 255},
|
||||||
{"SPRING GREEN", 0, 255, 127},
|
{_T("SPRING GREEN"), 0, 255, 127},
|
||||||
{"STEEL BLUE", 35, 107, 142},
|
{_T("STEEL BLUE"), 35, 107, 142},
|
||||||
{"TAN", 219, 147, 112},
|
{_T("TAN"), 219, 147, 112},
|
||||||
{"THISTLE", 216, 191, 216},
|
{_T("THISTLE"), 216, 191, 216},
|
||||||
{"TURQUOISE", 173, 234, 234},
|
{_T("TURQUOISE"), 173, 234, 234},
|
||||||
{"VIOLET", 79, 47, 79},
|
{_T("VIOLET"), 79, 47, 79},
|
||||||
{"VIOLET RED", 204, 50, 153},
|
{_T("VIOLET RED"), 204, 50, 153},
|
||||||
{"WHEAT", 216, 216, 191},
|
{_T("WHEAT"), 216, 216, 191},
|
||||||
{"WHITE", 255, 255, 255},
|
{_T("WHITE"), 255, 255, 255},
|
||||||
{"YELLOW", 255, 255, 0},
|
{_T("YELLOW"), 255, 255, 0},
|
||||||
{"YELLOW GREEN", 153, 204, 50},
|
{_T("YELLOW GREEN"), 153, 204, 50},
|
||||||
// #endif
|
// #endif
|
||||||
|
|
||||||
#if defined(__WXGTK__) || defined(__X__)
|
#if defined(__WXGTK__) || defined(__X__)
|
||||||
{"MEDIUM GOLDENROD", 234, 234, 173},
|
{_T("MEDIUM GOLDENROD"), 234, 234, 173},
|
||||||
{"MEDIUM FOREST GREEN", 107, 142, 35},
|
{_T("MEDIUM FOREST GREEN"), 107, 142, 35},
|
||||||
{"LIGHT MAGENTA", 255, 0, 255},
|
{_T("LIGHT MAGENTA"), 255, 0, 255},
|
||||||
{"MEDIUM GREY", 100, 100, 100},
|
{_T("MEDIUM GREY"), 100, 100, 100},
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
{0,0,0,0}
|
{0,0,0,0}
|
||||||
@@ -331,7 +331,7 @@ wxString wxColourDatabase::FindName (const wxColour& colour) const
|
|||||||
|
|
||||||
if (col->Red () == red && col->Green () == green && col->Blue () == blue)
|
if (col->Red () == red && col->Green () == green && col->Blue () == blue)
|
||||||
{
|
{
|
||||||
const char *found = node->GetKeyString();
|
const wxChar *found = node->GetKeyString();
|
||||||
if (found)
|
if (found)
|
||||||
return wxString(found);
|
return wxString(found);
|
||||||
}
|
}
|
||||||
|
@@ -92,7 +92,7 @@ void wxHashTable::Put (long key, long value, wxObject * object)
|
|||||||
hash_table[position]->Append (value, object);
|
hash_table[position]->Append (value, object);
|
||||||
}
|
}
|
||||||
|
|
||||||
void wxHashTable::Put (long key, const char *value, wxObject * object)
|
void wxHashTable::Put (long key, const wxChar *value, wxObject * object)
|
||||||
{
|
{
|
||||||
// Should NEVER be
|
// Should NEVER be
|
||||||
long k = (long) key;
|
long k = (long) key;
|
||||||
@@ -120,7 +120,7 @@ void wxHashTable::Put (long key, wxObject * object)
|
|||||||
hash_table[position]->Append (k, object);
|
hash_table[position]->Append (k, object);
|
||||||
}
|
}
|
||||||
|
|
||||||
void wxHashTable::Put (const char *key, wxObject * object)
|
void wxHashTable::Put (const wxChar *key, wxObject * object)
|
||||||
{
|
{
|
||||||
int position = (int) (MakeKey (key) % n);
|
int position = (int) (MakeKey (key) % n);
|
||||||
|
|
||||||
@@ -150,7 +150,7 @@ wxObject *wxHashTable::Get (long key, long value) const
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
wxObject *wxHashTable::Get (long key, const char *value) const
|
wxObject *wxHashTable::Get (long key, const wxChar *value) const
|
||||||
{
|
{
|
||||||
// Should NEVER be
|
// Should NEVER be
|
||||||
long k = (long) key;
|
long k = (long) key;
|
||||||
@@ -187,7 +187,7 @@ wxObject *wxHashTable::Get (long key) const
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
wxObject *wxHashTable::Get (const char *key) const
|
wxObject *wxHashTable::Get (const wxChar *key) const
|
||||||
{
|
{
|
||||||
int position = (int) (MakeKey (key) % n);
|
int position = (int) (MakeKey (key) % n);
|
||||||
|
|
||||||
@@ -224,7 +224,7 @@ wxObject *wxHashTable::Delete (long key)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
wxObject *wxHashTable::Delete (const char *key)
|
wxObject *wxHashTable::Delete (const wxChar *key)
|
||||||
{
|
{
|
||||||
int position = (int) (MakeKey (key) % n);
|
int position = (int) (MakeKey (key) % n);
|
||||||
if (!hash_table[position])
|
if (!hash_table[position])
|
||||||
@@ -267,7 +267,7 @@ wxObject *wxHashTable::Delete (long key, int value)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
wxObject *wxHashTable::Delete (long key, const char *value)
|
wxObject *wxHashTable::Delete (long key, const wxChar *value)
|
||||||
{
|
{
|
||||||
int position = (int) (key % n);
|
int position = (int) (key % n);
|
||||||
if (!hash_table[position])
|
if (!hash_table[position])
|
||||||
@@ -286,12 +286,12 @@ wxObject *wxHashTable::Delete (long key, const char *value)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
long wxHashTable::MakeKey (const char *string) const
|
long wxHashTable::MakeKey (const wxChar *string) const
|
||||||
{
|
{
|
||||||
long int_key = 0;
|
long int_key = 0;
|
||||||
|
|
||||||
while (*string)
|
while (*string)
|
||||||
int_key += (unsigned char) *string++;
|
int_key += (wxUChar) *string++;
|
||||||
|
|
||||||
return int_key;
|
return int_key;
|
||||||
}
|
}
|
||||||
|
@@ -156,15 +156,15 @@ wxImage wxImage::Scale( int width, int height )
|
|||||||
{
|
{
|
||||||
wxImage image;
|
wxImage image;
|
||||||
|
|
||||||
wxCHECK_MSG( Ok(), image, "invlaid image" );
|
wxCHECK_MSG( Ok(), image, _T("invalid image") );
|
||||||
|
|
||||||
wxCHECK_MSG( (width > 0) && (height > 0), image, "invalid image size" );
|
wxCHECK_MSG( (width > 0) && (height > 0), image, _T("invalid image size") );
|
||||||
|
|
||||||
image.Create( width, height );
|
image.Create( width, height );
|
||||||
|
|
||||||
char unsigned *data = image.GetData();
|
char unsigned *data = image.GetData();
|
||||||
|
|
||||||
wxCHECK_MSG( data, image, "unable to create image" );
|
wxCHECK_MSG( data, image, _T("unable to create image") );
|
||||||
|
|
||||||
if (M_IMGDATA->m_hasMask)
|
if (M_IMGDATA->m_hasMask)
|
||||||
image.SetMaskColour( M_IMGDATA->m_maskRed, M_IMGDATA->m_maskGreen, M_IMGDATA->m_maskBlue );
|
image.SetMaskColour( M_IMGDATA->m_maskRed, M_IMGDATA->m_maskGreen, M_IMGDATA->m_maskBlue );
|
||||||
@@ -193,12 +193,12 @@ wxImage wxImage::Scale( int width, int height )
|
|||||||
|
|
||||||
void wxImage::SetRGB( int x, int y, unsigned char r, unsigned char g, unsigned char b )
|
void wxImage::SetRGB( int x, int y, unsigned char r, unsigned char g, unsigned char b )
|
||||||
{
|
{
|
||||||
wxCHECK_RET( Ok(), "invalid image" );
|
wxCHECK_RET( Ok(), _T("invalid image") );
|
||||||
|
|
||||||
int w = M_IMGDATA->m_width;
|
int w = M_IMGDATA->m_width;
|
||||||
int h = M_IMGDATA->m_height;
|
int h = M_IMGDATA->m_height;
|
||||||
|
|
||||||
wxCHECK_RET( (x>=0) && (y>=0) && (x<w) && (y<h), "invalid image index" );
|
wxCHECK_RET( (x>=0) && (y>=0) && (x<w) && (y<h), _T("invalid image index") );
|
||||||
|
|
||||||
long pos = (y * w + x) * 3;
|
long pos = (y * w + x) * 3;
|
||||||
|
|
||||||
@@ -209,12 +209,12 @@ void wxImage::SetRGB( int x, int y, unsigned char r, unsigned char g, unsigned c
|
|||||||
|
|
||||||
unsigned char wxImage::GetRed( int x, int y )
|
unsigned char wxImage::GetRed( int x, int y )
|
||||||
{
|
{
|
||||||
wxCHECK_MSG( Ok(), 0, "invalid image" );
|
wxCHECK_MSG( Ok(), 0, _T("invalid image") );
|
||||||
|
|
||||||
int w = M_IMGDATA->m_width;
|
int w = M_IMGDATA->m_width;
|
||||||
int h = M_IMGDATA->m_height;
|
int h = M_IMGDATA->m_height;
|
||||||
|
|
||||||
wxCHECK_MSG( (x>=0) && (y>=0) && (x<w) && (y<h), 0, "invalid image index" );
|
wxCHECK_MSG( (x>=0) && (y>=0) && (x<w) && (y<h), 0, _T("invalid image index") );
|
||||||
|
|
||||||
long pos = (y * w + x) * 3;
|
long pos = (y * w + x) * 3;
|
||||||
|
|
||||||
@@ -223,12 +223,12 @@ unsigned char wxImage::GetRed( int x, int y )
|
|||||||
|
|
||||||
unsigned char wxImage::GetGreen( int x, int y )
|
unsigned char wxImage::GetGreen( int x, int y )
|
||||||
{
|
{
|
||||||
wxCHECK_MSG( Ok(), 0, "invalid image" );
|
wxCHECK_MSG( Ok(), 0, _T("invalid image") );
|
||||||
|
|
||||||
int w = M_IMGDATA->m_width;
|
int w = M_IMGDATA->m_width;
|
||||||
int h = M_IMGDATA->m_height;
|
int h = M_IMGDATA->m_height;
|
||||||
|
|
||||||
wxCHECK_MSG( (x>=0) && (y>=0) && (x<w) && (y<h), 0, "invalid image index" );
|
wxCHECK_MSG( (x>=0) && (y>=0) && (x<w) && (y<h), 0, _T("invalid image index") );
|
||||||
|
|
||||||
long pos = (y * w + x) * 3;
|
long pos = (y * w + x) * 3;
|
||||||
|
|
||||||
@@ -237,12 +237,12 @@ unsigned char wxImage::GetGreen( int x, int y )
|
|||||||
|
|
||||||
unsigned char wxImage::GetBlue( int x, int y )
|
unsigned char wxImage::GetBlue( int x, int y )
|
||||||
{
|
{
|
||||||
wxCHECK_MSG( Ok(), 0, "invalid image" );
|
wxCHECK_MSG( Ok(), 0, _T("invalid image") );
|
||||||
|
|
||||||
int w = M_IMGDATA->m_width;
|
int w = M_IMGDATA->m_width;
|
||||||
int h = M_IMGDATA->m_height;
|
int h = M_IMGDATA->m_height;
|
||||||
|
|
||||||
wxCHECK_MSG( (x>=0) && (y>=0) && (x<w) && (y<h), 0, "invalid image index" );
|
wxCHECK_MSG( (x>=0) && (y>=0) && (x<w) && (y<h), 0, _T("invalid image index") );
|
||||||
|
|
||||||
long pos = (y * w + x) * 3;
|
long pos = (y * w + x) * 3;
|
||||||
|
|
||||||
@@ -256,21 +256,21 @@ bool wxImage::Ok() const
|
|||||||
|
|
||||||
char unsigned *wxImage::GetData() const
|
char unsigned *wxImage::GetData() const
|
||||||
{
|
{
|
||||||
wxCHECK_MSG( Ok(), (char unsigned *)NULL, "invalid image" );
|
wxCHECK_MSG( Ok(), (char unsigned *)NULL, _T("invalid image") );
|
||||||
|
|
||||||
return M_IMGDATA->m_data;
|
return M_IMGDATA->m_data;
|
||||||
}
|
}
|
||||||
|
|
||||||
void wxImage::SetData( char unsigned *data )
|
void wxImage::SetData( char unsigned *data )
|
||||||
{
|
{
|
||||||
wxCHECK_RET( Ok(), "invalid image" );
|
wxCHECK_RET( Ok(), _T("invalid image") );
|
||||||
|
|
||||||
memcpy(M_IMGDATA->m_data, data, M_IMGDATA->m_width * M_IMGDATA->m_height * 3);
|
memcpy(M_IMGDATA->m_data, data, M_IMGDATA->m_width * M_IMGDATA->m_height * 3);
|
||||||
}
|
}
|
||||||
|
|
||||||
void wxImage::SetMaskColour( unsigned char r, unsigned char g, unsigned char b )
|
void wxImage::SetMaskColour( unsigned char r, unsigned char g, unsigned char b )
|
||||||
{
|
{
|
||||||
wxCHECK_RET( Ok(), "invalid image" );
|
wxCHECK_RET( Ok(), _T("invalid image") );
|
||||||
|
|
||||||
M_IMGDATA->m_maskRed = r;
|
M_IMGDATA->m_maskRed = r;
|
||||||
M_IMGDATA->m_maskGreen = g;
|
M_IMGDATA->m_maskGreen = g;
|
||||||
@@ -280,49 +280,49 @@ void wxImage::SetMaskColour( unsigned char r, unsigned char g, unsigned char b )
|
|||||||
|
|
||||||
unsigned char wxImage::GetMaskRed() const
|
unsigned char wxImage::GetMaskRed() const
|
||||||
{
|
{
|
||||||
wxCHECK_MSG( Ok(), 0, "invalid image" );
|
wxCHECK_MSG( Ok(), 0, _T("invalid image") );
|
||||||
|
|
||||||
return M_IMGDATA->m_maskRed;
|
return M_IMGDATA->m_maskRed;
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned char wxImage::GetMaskGreen() const
|
unsigned char wxImage::GetMaskGreen() const
|
||||||
{
|
{
|
||||||
wxCHECK_MSG( Ok(), 0, "invalid image" );
|
wxCHECK_MSG( Ok(), 0, _T("invalid image") );
|
||||||
|
|
||||||
return M_IMGDATA->m_maskGreen;
|
return M_IMGDATA->m_maskGreen;
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned char wxImage::GetMaskBlue() const
|
unsigned char wxImage::GetMaskBlue() const
|
||||||
{
|
{
|
||||||
wxCHECK_MSG( Ok(), 0, "invalid image" );
|
wxCHECK_MSG( Ok(), 0, _T("invalid image") );
|
||||||
|
|
||||||
return M_IMGDATA->m_maskBlue;
|
return M_IMGDATA->m_maskBlue;
|
||||||
}
|
}
|
||||||
|
|
||||||
void wxImage::SetMask( bool mask )
|
void wxImage::SetMask( bool mask )
|
||||||
{
|
{
|
||||||
wxCHECK_RET( Ok(), "invalid image" );
|
wxCHECK_RET( Ok(), _T("invalid image") );
|
||||||
|
|
||||||
M_IMGDATA->m_hasMask = mask;
|
M_IMGDATA->m_hasMask = mask;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool wxImage::HasMask() const
|
bool wxImage::HasMask() const
|
||||||
{
|
{
|
||||||
wxCHECK_MSG( Ok(), FALSE, "invalid image" );
|
wxCHECK_MSG( Ok(), FALSE, _T("invalid image") );
|
||||||
|
|
||||||
return M_IMGDATA->m_hasMask;
|
return M_IMGDATA->m_hasMask;
|
||||||
}
|
}
|
||||||
|
|
||||||
int wxImage::GetWidth() const
|
int wxImage::GetWidth() const
|
||||||
{
|
{
|
||||||
wxCHECK_MSG( Ok(), 0, "invalid image" );
|
wxCHECK_MSG( Ok(), 0, _T("invalid image") );
|
||||||
|
|
||||||
return M_IMGDATA->m_width;
|
return M_IMGDATA->m_width;
|
||||||
}
|
}
|
||||||
|
|
||||||
int wxImage::GetHeight() const
|
int wxImage::GetHeight() const
|
||||||
{
|
{
|
||||||
wxCHECK_MSG( Ok(), 0, "invalid image" );
|
wxCHECK_MSG( Ok(), 0, _T("invalid image") );
|
||||||
|
|
||||||
return M_IMGDATA->m_height;
|
return M_IMGDATA->m_height;
|
||||||
}
|
}
|
||||||
@@ -337,7 +337,7 @@ bool wxImage::LoadFile( const wxString& filename, long type )
|
|||||||
}
|
}
|
||||||
|
|
||||||
else {
|
else {
|
||||||
wxLogError( "Can't load image from file '%s': file does not exist.", filename.c_str() );
|
wxLogError( _T("Can't load image from file '%s': file does not exist."), filename.c_str() );
|
||||||
|
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
@@ -356,7 +356,7 @@ bool wxImage::LoadFile( const wxString& filename, const wxString& mimetype )
|
|||||||
}
|
}
|
||||||
|
|
||||||
else {
|
else {
|
||||||
wxLogError( "Can't load image from file '%s': file does not exist.", filename.c_str() );
|
wxLogError( _T("Can't load image from file '%s': file does not exist."), filename.c_str() );
|
||||||
|
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
@@ -400,7 +400,7 @@ bool wxImage::LoadFile( wxInputStream& stream, long type )
|
|||||||
|
|
||||||
if (handler == NULL)
|
if (handler == NULL)
|
||||||
{
|
{
|
||||||
wxLogWarning( "No image handler for type %d defined.", type );
|
wxLogWarning( _T("No image handler for type %d defined."), type );
|
||||||
|
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
@@ -418,7 +418,7 @@ bool wxImage::LoadFile( wxInputStream& stream, const wxString& mimetype )
|
|||||||
|
|
||||||
if (handler == NULL)
|
if (handler == NULL)
|
||||||
{
|
{
|
||||||
wxLogWarning( "No image handler for type %s defined.", mimetype.GetData() );
|
wxLogWarning( _T("No image handler for type %s defined."), mimetype.GetData() );
|
||||||
|
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
@@ -428,13 +428,13 @@ bool wxImage::LoadFile( wxInputStream& stream, const wxString& mimetype )
|
|||||||
|
|
||||||
bool wxImage::SaveFile( wxOutputStream& stream, int type )
|
bool wxImage::SaveFile( wxOutputStream& stream, int type )
|
||||||
{
|
{
|
||||||
wxCHECK_MSG( Ok(), FALSE, "invalid image" );
|
wxCHECK_MSG( Ok(), FALSE, _T("invalid image") );
|
||||||
|
|
||||||
wxImageHandler *handler = FindHandler(type);
|
wxImageHandler *handler = FindHandler(type);
|
||||||
|
|
||||||
if (handler == NULL)
|
if (handler == NULL)
|
||||||
{
|
{
|
||||||
wxLogWarning( "No image handler for type %d defined.", type );
|
wxLogWarning( _T("No image handler for type %d defined."), type );
|
||||||
|
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
@@ -444,13 +444,13 @@ bool wxImage::SaveFile( wxOutputStream& stream, int type )
|
|||||||
|
|
||||||
bool wxImage::SaveFile( wxOutputStream& stream, const wxString& mimetype )
|
bool wxImage::SaveFile( wxOutputStream& stream, const wxString& mimetype )
|
||||||
{
|
{
|
||||||
wxCHECK_MSG( Ok(), FALSE, "invalid image" );
|
wxCHECK_MSG( Ok(), FALSE, _T("invalid image") );
|
||||||
|
|
||||||
wxImageHandler *handler = FindHandlerMime(mimetype);
|
wxImageHandler *handler = FindHandlerMime(mimetype);
|
||||||
|
|
||||||
if (handler == NULL)
|
if (handler == NULL)
|
||||||
{
|
{
|
||||||
wxLogWarning( "No image handler for type %s defined.", mimetype.GetData() );
|
wxLogWarning( _T("No image handler for type %s defined."), mimetype.GetData() );
|
||||||
|
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
@@ -630,12 +630,12 @@ bool wxBMPHandler::LoadFile( wxImage *image, wxInputStream& stream )
|
|||||||
int height = (int)dbuf[1];
|
int height = (int)dbuf[1];
|
||||||
if (width > 32767)
|
if (width > 32767)
|
||||||
{
|
{
|
||||||
wxLogError( "Image width > 32767 pixels for file\n" );
|
wxLogError( _T("Image width > 32767 pixels for file\n") );
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
if (height > 32767)
|
if (height > 32767)
|
||||||
{
|
{
|
||||||
wxLogError( "Image height > 32767 pixels for file\n" );
|
wxLogError( _T("Image height > 32767 pixels for file\n") );
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
stream.Read(&word, 2);
|
stream.Read(&word, 2);
|
||||||
@@ -644,14 +644,14 @@ bool wxBMPHandler::LoadFile( wxImage *image, wxInputStream& stream )
|
|||||||
bpp = (int)word;
|
bpp = (int)word;
|
||||||
if (bpp != 1 && bpp != 4 && bpp != 8 && bpp && 16 && bpp != 24 && bpp != 32)
|
if (bpp != 1 && bpp != 4 && bpp != 8 && bpp && 16 && bpp != 24 && bpp != 32)
|
||||||
{
|
{
|
||||||
wxLogError( "unknown bitdepth in file\n" );
|
wxLogError( _T("unknown bitdepth in file\n") );
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
stream.Read(dbuf, 4 * 4);
|
stream.Read(dbuf, 4 * 4);
|
||||||
comp = (int)dbuf[0];
|
comp = (int)dbuf[0];
|
||||||
if (comp != BI_RGB && comp != BI_RLE4 && comp != BI_RLE8 && comp != BI_BITFIELDS)
|
if (comp != BI_RGB && comp != BI_RLE4 && comp != BI_RLE8 && comp != BI_BITFIELDS)
|
||||||
{
|
{
|
||||||
wxLogError( "unknown encoding in Windows BMP file\n" );
|
wxLogError( _T("unknown encoding in Windows BMP file\n") );
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
stream.Read(dbuf, 4 * 2);
|
stream.Read(dbuf, 4 * 2);
|
||||||
@@ -661,7 +661,7 @@ bool wxBMPHandler::LoadFile( wxImage *image, wxInputStream& stream )
|
|||||||
/* some more sanity checks */
|
/* some more sanity checks */
|
||||||
if (((comp == BI_RLE4) && (bpp != 4)) || ((comp == BI_RLE8) && (bpp != 8)) || ((comp == BI_BITFIELDS) && (bpp != 16 && bpp != 32)))
|
if (((comp == BI_RLE4) && (bpp != 4)) || ((comp == BI_RLE8) && (bpp != 8)) || ((comp == BI_BITFIELDS) && (bpp != 16 && bpp != 32)))
|
||||||
{
|
{
|
||||||
wxLogError( "encoding of BMP doesn't match bitdepth\n" );
|
wxLogError( _T("encoding of BMP doesn't match bitdepth\n") );
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
if (bpp < 16)
|
if (bpp < 16)
|
||||||
@@ -670,7 +670,7 @@ bool wxBMPHandler::LoadFile( wxImage *image, wxInputStream& stream )
|
|||||||
|
|
||||||
if (!cmap)
|
if (!cmap)
|
||||||
{
|
{
|
||||||
wxLogError( "Cannot allocate RAM for color map in BMP file\n" );
|
wxLogError( _T("Cannot allocate RAM for color map in BMP file\n") );
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -681,7 +681,7 @@ bool wxBMPHandler::LoadFile( wxImage *image, wxInputStream& stream )
|
|||||||
ptr = image->GetData();
|
ptr = image->GetData();
|
||||||
if (!ptr)
|
if (!ptr)
|
||||||
{
|
{
|
||||||
wxLogError( "Cannot allocate RAM for RGB data in file\n" );
|
wxLogError( _T("Cannot allocate RAM for RGB data in file\n") );
|
||||||
if (cmap)
|
if (cmap)
|
||||||
free(cmap);
|
free(cmap);
|
||||||
return FALSE;
|
return FALSE;
|
||||||
@@ -795,7 +795,7 @@ bool wxBMPHandler::LoadFile( wxImage *image, wxInputStream& stream )
|
|||||||
{
|
{
|
||||||
if (comp == BI_RLE4)
|
if (comp == BI_RLE4)
|
||||||
{
|
{
|
||||||
wxLogError( "can't deal with 4bit encoded yet.\n");
|
wxLogError( _T("can't deal with 4bit encoded yet.\n") );
|
||||||
image->Destroy();
|
image->Destroy();
|
||||||
free(cmap);
|
free(cmap);
|
||||||
return FALSE;
|
return FALSE;
|
||||||
@@ -973,7 +973,7 @@ wxBitmap wxImage::ConvertToBitmap() const
|
|||||||
|
|
||||||
// set bitmap parameters
|
// set bitmap parameters
|
||||||
wxBitmap bitmap;
|
wxBitmap bitmap;
|
||||||
wxCHECK_MSG( Ok(), bitmap, "invalid image" );
|
wxCHECK_MSG( Ok(), bitmap, _T("invalid image") );
|
||||||
bitmap.SetWidth( width );
|
bitmap.SetWidth( width );
|
||||||
bitmap.SetHeight( bmpHeight );
|
bitmap.SetHeight( bmpHeight );
|
||||||
bitmap.SetDepth( wxDisplayDepth() );
|
bitmap.SetDepth( wxDisplayDepth() );
|
||||||
@@ -981,7 +981,7 @@ wxBitmap wxImage::ConvertToBitmap() const
|
|||||||
// create a DIB header
|
// create a DIB header
|
||||||
int headersize = sizeof(BITMAPINFOHEADER);
|
int headersize = sizeof(BITMAPINFOHEADER);
|
||||||
LPBITMAPINFO lpDIBh = (BITMAPINFO *) malloc( headersize );
|
LPBITMAPINFO lpDIBh = (BITMAPINFO *) malloc( headersize );
|
||||||
wxCHECK_MSG( lpDIBh, bitmap, "could not allocate memory for DIB header" );
|
wxCHECK_MSG( lpDIBh, bitmap, _T("could not allocate memory for DIB header") );
|
||||||
// Fill in the DIB header
|
// Fill in the DIB header
|
||||||
lpDIBh->bmiHeader.biSize = headersize;
|
lpDIBh->bmiHeader.biSize = headersize;
|
||||||
lpDIBh->bmiHeader.biWidth = (DWORD)width;
|
lpDIBh->bmiHeader.biWidth = (DWORD)width;
|
||||||
@@ -1002,7 +1002,7 @@ wxBitmap wxImage::ConvertToBitmap() const
|
|||||||
lpBits = (unsigned char *)malloc( lpDIBh->bmiHeader.biSizeImage );
|
lpBits = (unsigned char *)malloc( lpDIBh->bmiHeader.biSizeImage );
|
||||||
if( !lpBits )
|
if( !lpBits )
|
||||||
{
|
{
|
||||||
wxFAIL_MSG( "could not allocate memory for DIB" );
|
wxFAIL_MSG( _T("could not allocate memory for DIB") );
|
||||||
free( lpDIBh );
|
free( lpDIBh );
|
||||||
return bitmap;
|
return bitmap;
|
||||||
}
|
}
|
||||||
@@ -1145,7 +1145,7 @@ wxImage::wxImage( const wxBitmap &bitmap )
|
|||||||
// check the bitmap
|
// check the bitmap
|
||||||
if( !bitmap.Ok() )
|
if( !bitmap.Ok() )
|
||||||
{
|
{
|
||||||
wxFAIL_MSG( "invalid bitmap" );
|
wxFAIL_MSG( _T("invalid bitmap") );
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1156,7 +1156,7 @@ wxImage::wxImage( const wxBitmap &bitmap )
|
|||||||
unsigned char *data = GetData();
|
unsigned char *data = GetData();
|
||||||
if( !data )
|
if( !data )
|
||||||
{
|
{
|
||||||
wxFAIL_MSG( "could not allocate data for image" );
|
wxFAIL_MSG( _T("could not allocate data for image") );
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1176,7 +1176,7 @@ wxImage::wxImage( const wxBitmap &bitmap )
|
|||||||
LPBITMAPINFO lpDIBh = (BITMAPINFO *) malloc( headersize );
|
LPBITMAPINFO lpDIBh = (BITMAPINFO *) malloc( headersize );
|
||||||
if( !lpDIBh )
|
if( !lpDIBh )
|
||||||
{
|
{
|
||||||
wxFAIL_MSG( "could not allocate data for DIB header" );
|
wxFAIL_MSG( _T("could not allocate data for DIB header") );
|
||||||
free( data );
|
free( data );
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -1198,7 +1198,7 @@ wxImage::wxImage( const wxBitmap &bitmap )
|
|||||||
lpBits = (unsigned char *) malloc( lpDIBh->bmiHeader.biSizeImage );
|
lpBits = (unsigned char *) malloc( lpDIBh->bmiHeader.biSizeImage );
|
||||||
if( !lpBits )
|
if( !lpBits )
|
||||||
{
|
{
|
||||||
wxFAIL_MSG( "could not allocate data for DIB" );
|
wxFAIL_MSG( _T("could not allocate data for DIB") );
|
||||||
free( data );
|
free( data );
|
||||||
free( lpDIBh );
|
free( lpDIBh );
|
||||||
return;
|
return;
|
||||||
@@ -1281,7 +1281,7 @@ wxBitmap wxImage::ConvertToBitmap() const
|
|||||||
{
|
{
|
||||||
wxBitmap bitmap;
|
wxBitmap bitmap;
|
||||||
|
|
||||||
wxCHECK_MSG( Ok(), bitmap, "invalid image" );
|
wxCHECK_MSG( Ok(), bitmap, _T("invalid image") );
|
||||||
|
|
||||||
int width = GetWidth();
|
int width = GetWidth();
|
||||||
int height = GetHeight();
|
int height = GetHeight();
|
||||||
@@ -1460,13 +1460,13 @@ wxBitmap wxImage::ConvertToBitmap() const
|
|||||||
|
|
||||||
wxImage::wxImage( const wxBitmap &bitmap )
|
wxImage::wxImage( const wxBitmap &bitmap )
|
||||||
{
|
{
|
||||||
wxCHECK_RET( bitmap.Ok(), "invalid bitmap" );
|
wxCHECK_RET( bitmap.Ok(), _T("invalid bitmap") );
|
||||||
|
|
||||||
GdkImage *gdk_image = gdk_image_get( bitmap.GetPixmap(),
|
GdkImage *gdk_image = gdk_image_get( bitmap.GetPixmap(),
|
||||||
0, 0,
|
0, 0,
|
||||||
bitmap.GetWidth(), bitmap.GetHeight() );
|
bitmap.GetWidth(), bitmap.GetHeight() );
|
||||||
|
|
||||||
wxCHECK_RET( gdk_image, "couldn't create image" );
|
wxCHECK_RET( gdk_image, _T("couldn't create image") );
|
||||||
|
|
||||||
Create( bitmap.GetWidth(), bitmap.GetHeight() );
|
Create( bitmap.GetWidth(), bitmap.GetHeight() );
|
||||||
char unsigned *data = GetData();
|
char unsigned *data = GetData();
|
||||||
@@ -1474,7 +1474,7 @@ wxImage::wxImage( const wxBitmap &bitmap )
|
|||||||
if (!data)
|
if (!data)
|
||||||
{
|
{
|
||||||
gdk_image_destroy( gdk_image );
|
gdk_image_destroy( gdk_image );
|
||||||
wxFAIL_MSG( "couldn't create image" );
|
wxFAIL_MSG( _T("couldn't create image") );
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1554,7 +1554,7 @@ wxBitmap wxImage::ConvertToBitmap() const
|
|||||||
{
|
{
|
||||||
wxBitmap bitmap;
|
wxBitmap bitmap;
|
||||||
|
|
||||||
wxCHECK_MSG( Ok(), bitmap, "invalid image" );
|
wxCHECK_MSG( Ok(), bitmap, _T("invalid image") );
|
||||||
|
|
||||||
int width = GetWidth();
|
int width = GetWidth();
|
||||||
int height = GetHeight();
|
int height = GetHeight();
|
||||||
@@ -1758,7 +1758,7 @@ wxBitmap wxImage::ConvertToBitmap() const
|
|||||||
|
|
||||||
wxImage::wxImage( const wxBitmap &bitmap )
|
wxImage::wxImage( const wxBitmap &bitmap )
|
||||||
{
|
{
|
||||||
wxCHECK_RET( bitmap.Ok(), "invalid bitmap" );
|
wxCHECK_RET( bitmap.Ok(), _T("invalid bitmap") );
|
||||||
|
|
||||||
Display *dpy = (Display*) wxGetDisplay();
|
Display *dpy = (Display*) wxGetDisplay();
|
||||||
Visual* vis = DefaultVisual( dpy, DefaultScreen( dpy ) );
|
Visual* vis = DefaultVisual( dpy, DefaultScreen( dpy ) );
|
||||||
@@ -1770,7 +1770,7 @@ wxImage::wxImage( const wxBitmap &bitmap )
|
|||||||
bitmap.GetWidth(), bitmap.GetHeight(),
|
bitmap.GetWidth(), bitmap.GetHeight(),
|
||||||
AllPlanes, ZPixmap );
|
AllPlanes, ZPixmap );
|
||||||
|
|
||||||
wxCHECK_RET( ximage, "couldn't create image" );
|
wxCHECK_RET( ximage, _T("couldn't create image") );
|
||||||
|
|
||||||
Create( bitmap.GetWidth(), bitmap.GetHeight() );
|
Create( bitmap.GetWidth(), bitmap.GetHeight() );
|
||||||
char unsigned *data = GetData();
|
char unsigned *data = GetData();
|
||||||
@@ -1778,7 +1778,7 @@ wxImage::wxImage( const wxBitmap &bitmap )
|
|||||||
if (!data)
|
if (!data)
|
||||||
{
|
{
|
||||||
XDestroyImage( ximage );
|
XDestroyImage( ximage );
|
||||||
wxFAIL_MSG( "couldn't create image" );
|
wxFAIL_MSG( _T("couldn't create image") );
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1891,4 +1891,3 @@ public:
|
|||||||
};
|
};
|
||||||
|
|
||||||
IMPLEMENT_DYNAMIC_CLASS(wxImageModule, wxModule)
|
IMPLEMENT_DYNAMIC_CLASS(wxImageModule, wxModule)
|
||||||
|
|
||||||
|
@@ -390,7 +390,7 @@ bool wxGIFHandler::LoadFile( wxImage *image, wxInputStream& stream )
|
|||||||
decod = new gifDecoder(&stream);
|
decod = new gifDecoder(&stream);
|
||||||
|
|
||||||
if (decod -> readgif(&igif) != E_OK) {
|
if (decod -> readgif(&igif) != E_OK) {
|
||||||
wxLogDebug("Error reading GIF");
|
wxLogDebug(_T("Error reading GIF"));
|
||||||
delete decod;
|
delete decod;
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
@@ -427,7 +427,7 @@ bool wxGIFHandler::LoadFile( wxImage *image, wxInputStream& stream )
|
|||||||
|
|
||||||
bool wxGIFHandler::SaveFile( wxImage *image, wxOutputStream& stream )
|
bool wxGIFHandler::SaveFile( wxImage *image, wxOutputStream& stream )
|
||||||
{
|
{
|
||||||
wxLogDebug("wxGIFHandler is read-only!!");
|
wxLogDebug(_T("wxGIFHandler is read-only!!"));
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -59,12 +59,12 @@ bool wxListKey::operator==(wxListKeyValue value) const
|
|||||||
switch ( m_keyType )
|
switch ( m_keyType )
|
||||||
{
|
{
|
||||||
default:
|
default:
|
||||||
wxFAIL_MSG("bad key type.");
|
wxFAIL_MSG(_T("bad key type."));
|
||||||
// let compiler optimize the line above away in release build
|
// let compiler optimize the line above away in release build
|
||||||
// by not putting return here...
|
// by not putting return here...
|
||||||
|
|
||||||
case wxKEY_STRING:
|
case wxKEY_STRING:
|
||||||
return strcmp(m_key.string, value.string) == 0;
|
return wxStrcmp(m_key.string, value.string) == 0;
|
||||||
|
|
||||||
case wxKEY_INTEGER:
|
case wxKEY_INTEGER:
|
||||||
return m_key.integer == value.integer;
|
return m_key.integer == value.integer;
|
||||||
@@ -95,11 +95,11 @@ wxNodeBase::wxNodeBase(wxListBase *list,
|
|||||||
|
|
||||||
case wxKEY_STRING:
|
case wxKEY_STRING:
|
||||||
// to be free()d later
|
// to be free()d later
|
||||||
m_key.string = strdup(key.GetString());
|
m_key.string = wxStrdup(key.GetString());
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
wxFAIL_MSG("invalid key type");
|
wxFAIL_MSG(_T("invalid key type"));
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( previous )
|
if ( previous )
|
||||||
@@ -127,7 +127,7 @@ wxNodeBase::~wxNodeBase()
|
|||||||
|
|
||||||
int wxNodeBase::IndexOf() const
|
int wxNodeBase::IndexOf() const
|
||||||
{
|
{
|
||||||
wxCHECK_MSG( m_list, wxNOT_FOUND, "node doesn't belong to a list in IndexOf");
|
wxCHECK_MSG( m_list, wxNOT_FOUND, _T("node doesn't belong to a list in IndexOf"));
|
||||||
|
|
||||||
// It would be more efficient to implement IndexOf() completely inside
|
// It would be more efficient to implement IndexOf() completely inside
|
||||||
// wxListBase (only traverse the list once), but this is probably a more
|
// wxListBase (only traverse the list once), but this is probably a more
|
||||||
@@ -170,7 +170,7 @@ wxListBase::wxListBase(size_t count, void *elements[])
|
|||||||
void wxListBase::DoCopy(const wxListBase& list)
|
void wxListBase::DoCopy(const wxListBase& list)
|
||||||
{
|
{
|
||||||
wxASSERT_MSG( !list.m_destroy,
|
wxASSERT_MSG( !list.m_destroy,
|
||||||
"copying list which owns it's elements is a bad idea" );
|
_T("copying list which owns it's elements is a bad idea") );
|
||||||
|
|
||||||
m_count = list.m_count;
|
m_count = list.m_count;
|
||||||
m_destroy = list.m_destroy;
|
m_destroy = list.m_destroy;
|
||||||
@@ -217,7 +217,7 @@ wxNodeBase *wxListBase::Append(void *object)
|
|||||||
{
|
{
|
||||||
// all objects in a keyed list should have a key
|
// all objects in a keyed list should have a key
|
||||||
wxCHECK_MSG( m_keyType == wxKEY_NONE, (wxNodeBase *)NULL,
|
wxCHECK_MSG( m_keyType == wxKEY_NONE, (wxNodeBase *)NULL,
|
||||||
"need a key for the object to append" );
|
_T("need a key for the object to append") );
|
||||||
|
|
||||||
wxNodeBase *node = CreateNode(m_nodeLast, (wxNodeBase *)NULL, object);
|
wxNodeBase *node = CreateNode(m_nodeLast, (wxNodeBase *)NULL, object);
|
||||||
|
|
||||||
@@ -229,18 +229,18 @@ wxNodeBase *wxListBase::Append(long key, void *object)
|
|||||||
wxCHECK_MSG( (m_keyType == wxKEY_INTEGER) ||
|
wxCHECK_MSG( (m_keyType == wxKEY_INTEGER) ||
|
||||||
(m_keyType == wxKEY_NONE && m_count == 0),
|
(m_keyType == wxKEY_NONE && m_count == 0),
|
||||||
(wxNodeBase *)NULL,
|
(wxNodeBase *)NULL,
|
||||||
"can't append object with numeric key to this list" );
|
_T("can't append object with numeric key to this list") );
|
||||||
|
|
||||||
wxNodeBase *node = CreateNode(m_nodeLast, (wxNodeBase *)NULL, object, key);
|
wxNodeBase *node = CreateNode(m_nodeLast, (wxNodeBase *)NULL, object, key);
|
||||||
return AppendCommon(node);
|
return AppendCommon(node);
|
||||||
}
|
}
|
||||||
|
|
||||||
wxNodeBase *wxListBase::Append (const char *key, void *object)
|
wxNodeBase *wxListBase::Append (const wxChar *key, void *object)
|
||||||
{
|
{
|
||||||
wxCHECK_MSG( (m_keyType == wxKEY_STRING) ||
|
wxCHECK_MSG( (m_keyType == wxKEY_STRING) ||
|
||||||
(m_keyType == wxKEY_NONE && m_count == 0),
|
(m_keyType == wxKEY_NONE && m_count == 0),
|
||||||
(wxNodeBase *)NULL,
|
(wxNodeBase *)NULL,
|
||||||
"can't append object with string key to this list" );
|
_T("can't append object with string key to this list") );
|
||||||
|
|
||||||
wxNodeBase *node = CreateNode(m_nodeLast, (wxNodeBase *)NULL, object, key);
|
wxNodeBase *node = CreateNode(m_nodeLast, (wxNodeBase *)NULL, object, key);
|
||||||
return AppendCommon(node);
|
return AppendCommon(node);
|
||||||
@@ -250,10 +250,10 @@ wxNodeBase *wxListBase::Insert(wxNodeBase *position, void *object)
|
|||||||
{
|
{
|
||||||
// all objects in a keyed list should have a key
|
// all objects in a keyed list should have a key
|
||||||
wxCHECK_MSG( m_keyType == wxKEY_NONE, (wxNodeBase *)NULL,
|
wxCHECK_MSG( m_keyType == wxKEY_NONE, (wxNodeBase *)NULL,
|
||||||
"need a key for the object to insert" );
|
_T("need a key for the object to insert") );
|
||||||
|
|
||||||
wxCHECK_MSG( !position || position->m_list == this, (wxNodeBase *)NULL,
|
wxCHECK_MSG( !position || position->m_list == this, (wxNodeBase *)NULL,
|
||||||
"can't insert before a node from another list" );
|
_T("can't insert before a node from another list") );
|
||||||
|
|
||||||
// previous and next node for the node being inserted
|
// previous and next node for the node being inserted
|
||||||
wxNodeBase *prev, *next;
|
wxNodeBase *prev, *next;
|
||||||
@@ -295,7 +295,7 @@ wxNodeBase *wxListBase::Item(size_t n) const
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
wxFAIL_MSG( "invalid index in wxListBase::Item" );
|
wxFAIL_MSG( _T("invalid index in wxListBase::Item") );
|
||||||
|
|
||||||
return (wxNodeBase *)NULL;
|
return (wxNodeBase *)NULL;
|
||||||
}
|
}
|
||||||
@@ -303,7 +303,7 @@ wxNodeBase *wxListBase::Item(size_t n) const
|
|||||||
wxNodeBase *wxListBase::Find(const wxListKey& key) const
|
wxNodeBase *wxListBase::Find(const wxListKey& key) const
|
||||||
{
|
{
|
||||||
wxASSERT_MSG( m_keyType == key.GetKeyType(),
|
wxASSERT_MSG( m_keyType == key.GetKeyType(),
|
||||||
"this list is not keyed on the type of this key" );
|
_T("this list is not keyed on the type of this key") );
|
||||||
|
|
||||||
for ( wxNodeBase *current = GetFirst(); current; current = current->GetNext() )
|
for ( wxNodeBase *current = GetFirst(); current; current = current->GetNext() )
|
||||||
{
|
{
|
||||||
@@ -356,9 +356,9 @@ void wxListBase::DoDeleteNode(wxNodeBase *node)
|
|||||||
|
|
||||||
wxNodeBase *wxListBase::DetachNode(wxNodeBase *node)
|
wxNodeBase *wxListBase::DetachNode(wxNodeBase *node)
|
||||||
{
|
{
|
||||||
wxCHECK_MSG( node, NULL, "detaching NULL wxNodeBase" );
|
wxCHECK_MSG( node, NULL, _T("detaching NULL wxNodeBase") );
|
||||||
wxCHECK_MSG( node->m_list == this, NULL,
|
wxCHECK_MSG( node->m_list == this, NULL,
|
||||||
"detaching node which is not from this list" );
|
_T("detaching node which is not from this list") );
|
||||||
|
|
||||||
// update the list
|
// update the list
|
||||||
wxNodeBase **prevNext = node->GetPrevious() ? &node->GetPrevious()->m_next
|
wxNodeBase **prevNext = node->GetPrevious() ? &node->GetPrevious()->m_next
|
||||||
@@ -524,13 +524,13 @@ void wxStringListNode::DeleteData()
|
|||||||
delete [] (char *)GetData();
|
delete [] (char *)GetData();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool wxStringList::Delete(const char *s)
|
bool wxStringList::Delete(const wxChar *s)
|
||||||
{
|
{
|
||||||
wxStringListNode *current;
|
wxStringListNode *current;
|
||||||
|
|
||||||
for ( current = GetFirst(); current; current = current->GetNext() )
|
for ( current = GetFirst(); current; current = current->GetNext() )
|
||||||
{
|
{
|
||||||
if ( strcmp(current->GetData(), s) == 0 )
|
if ( wxStrcmp(current->GetData(), s) == 0 )
|
||||||
{
|
{
|
||||||
DeleteNode(current);
|
DeleteNode(current);
|
||||||
return TRUE;
|
return TRUE;
|
||||||
@@ -554,7 +554,7 @@ void wxStringList::DoCopy(const wxStringList& other)
|
|||||||
|
|
||||||
// Variable argument list, terminated by a zero
|
// Variable argument list, terminated by a zero
|
||||||
// Makes new storage for the strings
|
// Makes new storage for the strings
|
||||||
wxStringList::wxStringList (const char *first, ...)
|
wxStringList::wxStringList (const wxChar *first, ...)
|
||||||
{
|
{
|
||||||
if ( !first )
|
if ( !first )
|
||||||
return;
|
return;
|
||||||
@@ -562,12 +562,12 @@ wxStringList::wxStringList (const char *first, ...)
|
|||||||
va_list ap;
|
va_list ap;
|
||||||
va_start(ap, first);
|
va_start(ap, first);
|
||||||
|
|
||||||
const char *s = first;
|
const wxChar *s = first;
|
||||||
for (;;)
|
for (;;)
|
||||||
{
|
{
|
||||||
Add(s);
|
Add(s);
|
||||||
|
|
||||||
s = va_arg(ap, const char *);
|
s = va_arg(ap, const wxChar *);
|
||||||
// if (s == NULL)
|
// if (s == NULL)
|
||||||
#ifdef __WXMSW__
|
#ifdef __WXMSW__
|
||||||
if ((int) s == 0)
|
if ((int) s == 0)
|
||||||
@@ -581,13 +581,13 @@ wxStringList::wxStringList (const char *first, ...)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Only makes new strings if arg is TRUE
|
// Only makes new strings if arg is TRUE
|
||||||
char **wxStringList::ListToArray(bool new_copies) const
|
wxChar **wxStringList::ListToArray(bool new_copies) const
|
||||||
{
|
{
|
||||||
char **string_array = new char *[GetCount()];
|
wxChar **string_array = new wxChar *[GetCount()];
|
||||||
wxStringListNode *node = GetFirst();
|
wxStringListNode *node = GetFirst();
|
||||||
for (size_t i = 0; i < GetCount(); i++)
|
for (size_t i = 0; i < GetCount(); i++)
|
||||||
{
|
{
|
||||||
char *s = node->GetData();
|
wxChar *s = node->GetData();
|
||||||
if ( new_copies )
|
if ( new_copies )
|
||||||
string_array[i] = copystring(s);
|
string_array[i] = copystring(s);
|
||||||
else
|
else
|
||||||
@@ -599,12 +599,12 @@ char **wxStringList::ListToArray(bool new_copies) const
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Checks whether s is a member of the list
|
// Checks whether s is a member of the list
|
||||||
bool wxStringList::Member(const char *s) const
|
bool wxStringList::Member(const wxChar *s) const
|
||||||
{
|
{
|
||||||
for ( wxStringListNode *node = GetFirst(); node; node = node->GetNext() )
|
for ( wxStringListNode *node = GetFirst(); node; node = node->GetNext() )
|
||||||
{
|
{
|
||||||
const char *s1 = node->GetData();
|
const wxChar *s1 = node->GetData();
|
||||||
if (s == s1 || strcmp (s, s1) == 0)
|
if (s == s1 || wxStrcmp (s, s1) == 0)
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -614,17 +614,17 @@ bool wxStringList::Member(const char *s) const
|
|||||||
static int
|
static int
|
||||||
wx_comparestrings(const void *arg1, const void *arg2)
|
wx_comparestrings(const void *arg1, const void *arg2)
|
||||||
{
|
{
|
||||||
char **s1 = (char **) arg1;
|
wxChar **s1 = (wxChar **) arg1;
|
||||||
char **s2 = (char **) arg2;
|
wxChar **s2 = (wxChar **) arg2;
|
||||||
|
|
||||||
return strcmp (*s1, *s2);
|
return wxStrcmp (*s1, *s2);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Sort a list of strings - deallocates old nodes, allocates new
|
// Sort a list of strings - deallocates old nodes, allocates new
|
||||||
void wxStringList::Sort()
|
void wxStringList::Sort()
|
||||||
{
|
{
|
||||||
size_t N = GetCount();
|
size_t N = GetCount();
|
||||||
char **array = new char *[N];
|
wxChar **array = new wxChar *[N];
|
||||||
wxStringListNode *node;
|
wxStringListNode *node;
|
||||||
|
|
||||||
size_t i = 0;
|
size_t i = 0;
|
||||||
@@ -633,7 +633,7 @@ void wxStringList::Sort()
|
|||||||
array[i++] = node->GetData();
|
array[i++] = node->GetData();
|
||||||
}
|
}
|
||||||
|
|
||||||
qsort (array, N, sizeof (char *), wx_comparestrings);
|
qsort (array, N, sizeof (wxChar *), wx_comparestrings);
|
||||||
|
|
||||||
i = 0;
|
i = 0;
|
||||||
for ( node = GetFirst(); node; node = node->GetNext() )
|
for ( node = GetFirst(); node; node = node->GetNext() )
|
||||||
|
@@ -93,15 +93,15 @@ static wxFrame *gs_pFrame; // FIXME MT-unsafe
|
|||||||
#define LOG_BUFFER_SIZE (4096)
|
#define LOG_BUFFER_SIZE (4096)
|
||||||
|
|
||||||
// static buffer for error messages (FIXME MT-unsafe)
|
// static buffer for error messages (FIXME MT-unsafe)
|
||||||
static char s_szBuf[LOG_BUFFER_SIZE];
|
static wxChar s_szBuf[LOG_BUFFER_SIZE];
|
||||||
|
|
||||||
// generic log function
|
// generic log function
|
||||||
void wxLogGeneric(wxLogLevel level, const char *szFormat, ...)
|
void wxLogGeneric(wxLogLevel level, const wxChar *szFormat, ...)
|
||||||
{
|
{
|
||||||
if ( wxLog::GetActiveTarget() != NULL ) {
|
if ( wxLog::GetActiveTarget() != NULL ) {
|
||||||
va_list argptr;
|
va_list argptr;
|
||||||
va_start(argptr, szFormat);
|
va_start(argptr, szFormat);
|
||||||
vsprintf(s_szBuf, szFormat, argptr);
|
wxVsprintf(s_szBuf, szFormat, argptr);
|
||||||
va_end(argptr);
|
va_end(argptr);
|
||||||
|
|
||||||
wxLog::OnLog(level, s_szBuf, time(NULL));
|
wxLog::OnLog(level, s_szBuf, time(NULL));
|
||||||
@@ -109,12 +109,12 @@ void wxLogGeneric(wxLogLevel level, const char *szFormat, ...)
|
|||||||
}
|
}
|
||||||
|
|
||||||
#define IMPLEMENT_LOG_FUNCTION(level) \
|
#define IMPLEMENT_LOG_FUNCTION(level) \
|
||||||
void wxLog##level(const char *szFormat, ...) \
|
void wxLog##level(const wxChar *szFormat, ...) \
|
||||||
{ \
|
{ \
|
||||||
if ( wxLog::GetActiveTarget() != NULL ) { \
|
if ( wxLog::GetActiveTarget() != NULL ) { \
|
||||||
va_list argptr; \
|
va_list argptr; \
|
||||||
va_start(argptr, szFormat); \
|
va_start(argptr, szFormat); \
|
||||||
vsprintf(s_szBuf, szFormat, argptr); \
|
wxVsprintf(s_szBuf, szFormat, argptr); \
|
||||||
va_end(argptr); \
|
va_end(argptr); \
|
||||||
\
|
\
|
||||||
wxLog::OnLog(wxLOG_##level, s_szBuf, time(NULL)); \
|
wxLog::OnLog(wxLOG_##level, s_szBuf, time(NULL)); \
|
||||||
@@ -130,13 +130,13 @@ IMPLEMENT_LOG_FUNCTION(Status)
|
|||||||
|
|
||||||
// accepts an additional argument which tells to which frame the output should
|
// accepts an additional argument which tells to which frame the output should
|
||||||
// be directed
|
// be directed
|
||||||
void wxLogStatus(wxFrame *pFrame, const char *szFormat, ...)
|
void wxLogStatus(wxFrame *pFrame, const wxChar *szFormat, ...)
|
||||||
{
|
{
|
||||||
wxLog *pLog = wxLog::GetActiveTarget();
|
wxLog *pLog = wxLog::GetActiveTarget();
|
||||||
if ( pLog != NULL ) {
|
if ( pLog != NULL ) {
|
||||||
va_list argptr;
|
va_list argptr;
|
||||||
va_start(argptr, szFormat);
|
va_start(argptr, szFormat);
|
||||||
vsprintf(s_szBuf, szFormat, argptr);
|
wxVsprintf(s_szBuf, szFormat, argptr);
|
||||||
va_end(argptr);
|
va_end(argptr);
|
||||||
|
|
||||||
wxASSERT( gs_pFrame == NULL ); // should be reset!
|
wxASSERT( gs_pFrame == NULL ); // should be reset!
|
||||||
@@ -147,13 +147,13 @@ void wxLogStatus(wxFrame *pFrame, const char *szFormat, ...)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// same as info, but only if 'verbose' mode is on
|
// same as info, but only if 'verbose' mode is on
|
||||||
void wxLogVerbose(const char *szFormat, ...)
|
void wxLogVerbose(const wxChar *szFormat, ...)
|
||||||
{
|
{
|
||||||
wxLog *pLog = wxLog::GetActiveTarget();
|
wxLog *pLog = wxLog::GetActiveTarget();
|
||||||
if ( pLog != NULL && pLog->GetVerbose() ) {
|
if ( pLog != NULL && pLog->GetVerbose() ) {
|
||||||
va_list argptr;
|
va_list argptr;
|
||||||
va_start(argptr, szFormat);
|
va_start(argptr, szFormat);
|
||||||
vsprintf(s_szBuf, szFormat, argptr);
|
wxVsprintf(s_szBuf, szFormat, argptr);
|
||||||
va_end(argptr);
|
va_end(argptr);
|
||||||
|
|
||||||
wxLog::OnLog(wxLOG_Info, s_szBuf, time(NULL));
|
wxLog::OnLog(wxLOG_Info, s_szBuf, time(NULL));
|
||||||
@@ -163,33 +163,33 @@ void wxLogVerbose(const char *szFormat, ...)
|
|||||||
// debug functions
|
// debug functions
|
||||||
#ifdef __WXDEBUG__
|
#ifdef __WXDEBUG__
|
||||||
#define IMPLEMENT_LOG_DEBUG_FUNCTION(level) \
|
#define IMPLEMENT_LOG_DEBUG_FUNCTION(level) \
|
||||||
void wxLog##level(const char *szFormat, ...) \
|
void wxLog##level(const wxChar *szFormat, ...) \
|
||||||
{ \
|
{ \
|
||||||
if ( wxLog::GetActiveTarget() != NULL ) { \
|
if ( wxLog::GetActiveTarget() != NULL ) { \
|
||||||
va_list argptr; \
|
va_list argptr; \
|
||||||
va_start(argptr, szFormat); \
|
va_start(argptr, szFormat); \
|
||||||
vsprintf(s_szBuf, szFormat, argptr); \
|
wxVsprintf(s_szBuf, szFormat, argptr); \
|
||||||
va_end(argptr); \
|
va_end(argptr); \
|
||||||
\
|
\
|
||||||
wxLog::OnLog(wxLOG_##level, s_szBuf, time(NULL)); \
|
wxLog::OnLog(wxLOG_##level, s_szBuf, time(NULL)); \
|
||||||
} \
|
} \
|
||||||
}
|
}
|
||||||
|
|
||||||
void wxLogTrace(const char *mask, const char *szFormat, ...)
|
void wxLogTrace(const wxChar *mask, const wxChar *szFormat, ...)
|
||||||
{
|
{
|
||||||
wxLog *pLog = wxLog::GetActiveTarget();
|
wxLog *pLog = wxLog::GetActiveTarget();
|
||||||
|
|
||||||
if ( pLog != NULL && wxLog::IsAllowedTraceMask(mask) ) {
|
if ( pLog != NULL && wxLog::IsAllowedTraceMask(mask) ) {
|
||||||
va_list argptr;
|
va_list argptr;
|
||||||
va_start(argptr, szFormat);
|
va_start(argptr, szFormat);
|
||||||
vsprintf(s_szBuf, szFormat, argptr);
|
wxVsprintf(s_szBuf, szFormat, argptr);
|
||||||
va_end(argptr);
|
va_end(argptr);
|
||||||
|
|
||||||
wxLog::OnLog(wxLOG_Trace, s_szBuf, time(NULL));
|
wxLog::OnLog(wxLOG_Trace, s_szBuf, time(NULL));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void wxLogTrace(wxTraceMask mask, const char *szFormat, ...)
|
void wxLogTrace(wxTraceMask mask, const wxChar *szFormat, ...)
|
||||||
{
|
{
|
||||||
wxLog *pLog = wxLog::GetActiveTarget();
|
wxLog *pLog = wxLog::GetActiveTarget();
|
||||||
|
|
||||||
@@ -199,7 +199,7 @@ void wxLogVerbose(const char *szFormat, ...)
|
|||||||
if ( pLog != NULL && ((pLog->GetTraceMask() & mask) == mask) ) {
|
if ( pLog != NULL && ((pLog->GetTraceMask() & mask) == mask) ) {
|
||||||
va_list argptr;
|
va_list argptr;
|
||||||
va_start(argptr, szFormat);
|
va_start(argptr, szFormat);
|
||||||
vsprintf(s_szBuf, szFormat, argptr);
|
wxVsprintf(s_szBuf, szFormat, argptr);
|
||||||
va_end(argptr);
|
va_end(argptr);
|
||||||
|
|
||||||
wxLog::OnLog(wxLOG_Trace, s_szBuf, time(NULL));
|
wxLog::OnLog(wxLOG_Trace, s_szBuf, time(NULL));
|
||||||
@@ -219,28 +219,28 @@ IMPLEMENT_LOG_DEBUG_FUNCTION(Trace)
|
|||||||
// common part of both wxLogSysError
|
// common part of both wxLogSysError
|
||||||
void wxLogSysErrorHelper(long lErrCode)
|
void wxLogSysErrorHelper(long lErrCode)
|
||||||
{
|
{
|
||||||
char szErrMsg[LOG_BUFFER_SIZE / 2];
|
wxChar szErrMsg[LOG_BUFFER_SIZE / 2];
|
||||||
sprintf(szErrMsg, _(" (error %ld: %s)"), lErrCode, wxSysErrorMsg(lErrCode));
|
wxSprintf(szErrMsg, _(" (error %ld: %s)"), lErrCode, wxSysErrorMsg(lErrCode));
|
||||||
strncat(s_szBuf, szErrMsg, WXSIZEOF(s_szBuf) - strlen(s_szBuf));
|
wxStrncat(s_szBuf, szErrMsg, WXSIZEOF(s_szBuf) - wxStrlen(s_szBuf));
|
||||||
|
|
||||||
wxLog::OnLog(wxLOG_Error, s_szBuf, time(NULL));
|
wxLog::OnLog(wxLOG_Error, s_szBuf, time(NULL));
|
||||||
}
|
}
|
||||||
|
|
||||||
void WXDLLEXPORT wxLogSysError(const char *szFormat, ...)
|
void WXDLLEXPORT wxLogSysError(const wxChar *szFormat, ...)
|
||||||
{
|
{
|
||||||
va_list argptr;
|
va_list argptr;
|
||||||
va_start(argptr, szFormat);
|
va_start(argptr, szFormat);
|
||||||
vsprintf(s_szBuf, szFormat, argptr);
|
wxVsprintf(s_szBuf, szFormat, argptr);
|
||||||
va_end(argptr);
|
va_end(argptr);
|
||||||
|
|
||||||
wxLogSysErrorHelper(wxSysErrorCode());
|
wxLogSysErrorHelper(wxSysErrorCode());
|
||||||
}
|
}
|
||||||
|
|
||||||
void WXDLLEXPORT wxLogSysError(long lErrCode, const char *szFormat, ...)
|
void WXDLLEXPORT wxLogSysError(long lErrCode, const wxChar *szFormat, ...)
|
||||||
{
|
{
|
||||||
va_list argptr;
|
va_list argptr;
|
||||||
va_start(argptr, szFormat);
|
va_start(argptr, szFormat);
|
||||||
vsprintf(s_szBuf, szFormat, argptr);
|
wxVsprintf(s_szBuf, szFormat, argptr);
|
||||||
va_end(argptr);
|
va_end(argptr);
|
||||||
|
|
||||||
wxLogSysErrorHelper(lErrCode);
|
wxLogSysErrorHelper(lErrCode);
|
||||||
@@ -311,7 +311,7 @@ void wxLog::RemoveTraceMask(const wxString& str)
|
|||||||
ms_aTraceMasks.Remove((size_t)index);
|
ms_aTraceMasks.Remove((size_t)index);
|
||||||
}
|
}
|
||||||
|
|
||||||
void wxLog::DoLog(wxLogLevel level, const char *szString, time_t t)
|
void wxLog::DoLog(wxLogLevel level, const wxChar *szString, time_t t)
|
||||||
{
|
{
|
||||||
wxString str;
|
wxString str;
|
||||||
|
|
||||||
@@ -354,9 +354,9 @@ void wxLog::DoLog(wxLogLevel level, const char *szString, time_t t)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void wxLog::DoLogString(const char *WXUNUSED(szString), time_t t)
|
void wxLog::DoLogString(const wxChar *WXUNUSED(szString), time_t t)
|
||||||
{
|
{
|
||||||
wxFAIL_MSG("DoLogString must be overriden if it's called.");
|
wxFAIL_MSG(_T("DoLogString must be overriden if it's called."));
|
||||||
}
|
}
|
||||||
|
|
||||||
void wxLog::Flush()
|
void wxLog::Flush()
|
||||||
@@ -376,18 +376,18 @@ wxLogStderr::wxLogStderr(FILE *fp)
|
|||||||
m_fp = fp;
|
m_fp = fp;
|
||||||
}
|
}
|
||||||
|
|
||||||
void wxLogStderr::DoLogString(const char *szString, time_t t)
|
void wxLogStderr::DoLogString(const wxChar *szString, time_t t)
|
||||||
{
|
{
|
||||||
wxString str(szString);
|
wxString str(szString);
|
||||||
str << '\n';
|
str << _T('\n');
|
||||||
|
|
||||||
fputs(str, m_fp);
|
fputs(str.mb_str(), m_fp);
|
||||||
fflush(m_fp);
|
fflush(m_fp);
|
||||||
|
|
||||||
// under Windows, programs usually don't have stderr at all, so make show the
|
// under Windows, programs usually don't have stderr at all, so make show the
|
||||||
// messages also under debugger
|
// messages also under debugger
|
||||||
#ifdef __WXMSW__
|
#ifdef __WXMSW__
|
||||||
OutputDebugString(str + '\r');
|
OutputDebugString(str + _T('\r'));
|
||||||
#endif // MSW
|
#endif // MSW
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -404,7 +404,7 @@ wxLogStream::wxLogStream(ostream *ostr)
|
|||||||
m_ostr = ostr;
|
m_ostr = ostr;
|
||||||
}
|
}
|
||||||
|
|
||||||
void wxLogStream::DoLogString(const char *szString, time_t t)
|
void wxLogStream::DoLogString(const wxChar *szString, time_t t)
|
||||||
{
|
{
|
||||||
(*m_ostr) << szString << endl << flush;
|
(*m_ostr) << szString << endl << flush;
|
||||||
}
|
}
|
||||||
@@ -469,10 +469,10 @@ void wxLogGui::Flush()
|
|||||||
if ( nLines > 25 ) // don't put too many lines in message box
|
if ( nLines > 25 ) // don't put too many lines in message box
|
||||||
break;
|
break;
|
||||||
|
|
||||||
str << m_aMessages[n - 1] << "\n";
|
str << m_aMessages[n - 1] << _T("\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
const char *title;
|
const wxChar *title;
|
||||||
long style;
|
long style;
|
||||||
|
|
||||||
if ( m_bErrors ) {
|
if ( m_bErrors ) {
|
||||||
@@ -496,7 +496,7 @@ void wxLogGui::Flush()
|
|||||||
|
|
||||||
// the default behaviour is to discard all informational messages if there
|
// the default behaviour is to discard all informational messages if there
|
||||||
// are any errors/warnings.
|
// are any errors/warnings.
|
||||||
void wxLogGui::DoLog(wxLogLevel level, const char *szString, time_t t)
|
void wxLogGui::DoLog(wxLogLevel level, const wxChar *szString, time_t t)
|
||||||
{
|
{
|
||||||
switch ( level ) {
|
switch ( level ) {
|
||||||
case wxLOG_Info:
|
case wxLOG_Info:
|
||||||
@@ -532,12 +532,12 @@ void wxLogGui::DoLog(wxLogLevel level, const char *szString, time_t t)
|
|||||||
#ifdef __WXMSW__
|
#ifdef __WXMSW__
|
||||||
// don't prepend debug/trace here: it goes to the
|
// don't prepend debug/trace here: it goes to the
|
||||||
// debug window anyhow, but do put a timestamp
|
// debug window anyhow, but do put a timestamp
|
||||||
OutputDebugString(wxString(szString) + "\n\r");
|
OutputDebugString(wxString(szString) + _T("\n\r"));
|
||||||
#else
|
#else
|
||||||
// send them to stderr
|
// send them to stderr
|
||||||
fprintf(stderr, "%s: %s\n",
|
fprintf(stderr, "%s: %s\n",
|
||||||
level == wxLOG_Trace ? "Trace" : "Debug",
|
level == wxLOG_Trace ? "Trace" : "Debug",
|
||||||
szString);
|
(const char*)wxConv_libc.cWX2MB(szString));
|
||||||
fflush(stderr);
|
fflush(stderr);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
@@ -586,7 +586,7 @@ class wxLogFrame : public wxFrame
|
|||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
// ctor & dtor
|
// ctor & dtor
|
||||||
wxLogFrame(wxFrame *pParent, wxLogWindow *log, const char *szTitle);
|
wxLogFrame(wxFrame *pParent, wxLogWindow *log, const wxChar *szTitle);
|
||||||
virtual ~wxLogFrame();
|
virtual ~wxLogFrame();
|
||||||
|
|
||||||
// menu callbacks
|
// menu callbacks
|
||||||
@@ -626,7 +626,7 @@ BEGIN_EVENT_TABLE(wxLogFrame, wxFrame)
|
|||||||
EVT_CLOSE(wxLogFrame::OnCloseWindow)
|
EVT_CLOSE(wxLogFrame::OnCloseWindow)
|
||||||
END_EVENT_TABLE()
|
END_EVENT_TABLE()
|
||||||
|
|
||||||
wxLogFrame::wxLogFrame(wxFrame *pParent, wxLogWindow *log, const char *szTitle)
|
wxLogFrame::wxLogFrame(wxFrame *pParent, wxLogWindow *log, const wxChar *szTitle)
|
||||||
: wxFrame(pParent, -1, szTitle)
|
: wxFrame(pParent, -1, szTitle)
|
||||||
{
|
{
|
||||||
m_log = log;
|
m_log = log;
|
||||||
@@ -667,7 +667,7 @@ void wxLogFrame::OnSave(wxCommandEvent& WXUNUSED(event))
|
|||||||
{
|
{
|
||||||
// get the file name
|
// get the file name
|
||||||
// -----------------
|
// -----------------
|
||||||
const char *szFileName = wxSaveFileSelector("log", "txt", "log.txt");
|
const wxChar *szFileName = wxSaveFileSelector(_T("log"), _T("txt"), _T("log.txt"));
|
||||||
if ( szFileName == NULL ) {
|
if ( szFileName == NULL ) {
|
||||||
// cancelled
|
// cancelled
|
||||||
return;
|
return;
|
||||||
@@ -747,7 +747,7 @@ wxLogFrame::~wxLogFrame()
|
|||||||
// wxLogWindow
|
// wxLogWindow
|
||||||
// -----------
|
// -----------
|
||||||
wxLogWindow::wxLogWindow(wxFrame *pParent,
|
wxLogWindow::wxLogWindow(wxFrame *pParent,
|
||||||
const char *szTitle,
|
const wxChar *szTitle,
|
||||||
bool bShow,
|
bool bShow,
|
||||||
bool bDoPass)
|
bool bDoPass)
|
||||||
{
|
{
|
||||||
@@ -773,7 +773,7 @@ void wxLogWindow::Flush()
|
|||||||
m_bHasMessages = FALSE;
|
m_bHasMessages = FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
void wxLogWindow::DoLog(wxLogLevel level, const char *szString, time_t t)
|
void wxLogWindow::DoLog(wxLogLevel level, const wxChar *szString, time_t t)
|
||||||
{
|
{
|
||||||
// first let the previous logger show it
|
// first let the previous logger show it
|
||||||
if ( m_pOldLog != NULL && m_bPassMessages ) {
|
if ( m_pOldLog != NULL && m_bPassMessages ) {
|
||||||
@@ -812,7 +812,7 @@ void wxLogWindow::DoLog(wxLogLevel level, const char *szString, time_t t)
|
|||||||
m_bHasMessages = TRUE;
|
m_bHasMessages = TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
void wxLogWindow::DoLogString(const char *szString, time_t t)
|
void wxLogWindow::DoLogString(const wxChar *szString, time_t t)
|
||||||
{
|
{
|
||||||
// put the text into our window
|
// put the text into our window
|
||||||
wxTextCtrl *pText = m_pLogFrame->TextCtrl();
|
wxTextCtrl *pText = m_pLogFrame->TextCtrl();
|
||||||
@@ -824,7 +824,7 @@ void wxLogWindow::DoLogString(const char *szString, time_t t)
|
|||||||
#endif // Windows
|
#endif // Windows
|
||||||
|
|
||||||
pText->WriteText(szString);
|
pText->WriteText(szString);
|
||||||
pText->WriteText("\n"); // "\n" ok here (_not_ "\r\n")
|
pText->WriteText(_T("\n")); // "\n" ok here (_not_ "\r\n")
|
||||||
|
|
||||||
// TODO ensure that the line can be seen
|
// TODO ensure that the line can be seen
|
||||||
}
|
}
|
||||||
@@ -924,14 +924,14 @@ unsigned long wxSysErrorCode()
|
|||||||
}
|
}
|
||||||
|
|
||||||
// get error message from system
|
// get error message from system
|
||||||
const char *wxSysErrorMsg(unsigned long nErrCode)
|
const wxChar *wxSysErrorMsg(unsigned long nErrCode)
|
||||||
{
|
{
|
||||||
if ( nErrCode == 0 )
|
if ( nErrCode == 0 )
|
||||||
nErrCode = wxSysErrorCode();
|
nErrCode = wxSysErrorCode();
|
||||||
|
|
||||||
#ifdef __WXMSW__
|
#ifdef __WXMSW__
|
||||||
#ifdef __WIN32__
|
#ifdef __WIN32__
|
||||||
static char s_szBuf[LOG_BUFFER_SIZE / 2];
|
static wxChar s_szBuf[LOG_BUFFER_SIZE / 2];
|
||||||
|
|
||||||
// get error message from system
|
// get error message from system
|
||||||
LPVOID lpMsgBuf;
|
LPVOID lpMsgBuf;
|
||||||
@@ -942,17 +942,17 @@ const char *wxSysErrorMsg(unsigned long nErrCode)
|
|||||||
0, NULL);
|
0, NULL);
|
||||||
|
|
||||||
// copy it to our buffer and free memory
|
// copy it to our buffer and free memory
|
||||||
strncpy(s_szBuf, (const char *)lpMsgBuf, WXSIZEOF(s_szBuf) - 1);
|
wxStrncpy(s_szBuf, (const wxChar *)lpMsgBuf, WXSIZEOF(s_szBuf) - 1);
|
||||||
s_szBuf[WXSIZEOF(s_szBuf) - 1] = '\0';
|
s_szBuf[WXSIZEOF(s_szBuf) - 1] = _T('\0');
|
||||||
LocalFree(lpMsgBuf);
|
LocalFree(lpMsgBuf);
|
||||||
|
|
||||||
// returned string is capitalized and ended with '\r\n' - bad
|
// returned string is capitalized and ended with '\r\n' - bad
|
||||||
s_szBuf[0] = (char)tolower(s_szBuf[0]);
|
s_szBuf[0] = (wxChar)wxTolower(s_szBuf[0]);
|
||||||
size_t len = strlen(s_szBuf);
|
size_t len = wxStrlen(s_szBuf);
|
||||||
if ( len > 0 ) {
|
if ( len > 0 ) {
|
||||||
// truncate string
|
// truncate string
|
||||||
if ( s_szBuf[len - 2] == '\r' )
|
if ( s_szBuf[len - 2] == _T('\r') )
|
||||||
s_szBuf[len - 2] = '\0';
|
s_szBuf[len - 2] = _T('\0');
|
||||||
}
|
}
|
||||||
|
|
||||||
return s_szBuf;
|
return s_szBuf;
|
||||||
@@ -961,7 +961,13 @@ const char *wxSysErrorMsg(unsigned long nErrCode)
|
|||||||
return NULL;
|
return NULL;
|
||||||
#endif // Win16/32
|
#endif // Win16/32
|
||||||
#else // Unix
|
#else // Unix
|
||||||
|
#if wxUSE_UNICODE
|
||||||
|
static wxChar s_szBuf[LOG_BUFFER_SIZE / 2];
|
||||||
|
wxConv_libc.MB2WC(s_szBuf, strerror(nErrCode), WXSIZEOF(s_szBuf) -1);
|
||||||
|
return s_szBuf;
|
||||||
|
#else
|
||||||
return strerror(nErrCode);
|
return strerror(nErrCode);
|
||||||
|
#endif
|
||||||
#endif // Win/Unix
|
#endif // Win/Unix
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -990,7 +996,7 @@ void Trap()
|
|||||||
}
|
}
|
||||||
|
|
||||||
// this function is called when an assert fails
|
// this function is called when an assert fails
|
||||||
void wxOnAssert(const char *szFile, int nLine, const char *szMsg)
|
void wxOnAssert(const char *szFile, int nLine, const wxChar *szMsg)
|
||||||
{
|
{
|
||||||
// this variable can be set to true to suppress "assert failure" messages
|
// this variable can be set to true to suppress "assert failure" messages
|
||||||
static bool s_bNoAsserts = FALSE;
|
static bool s_bNoAsserts = FALSE;
|
||||||
@@ -1007,23 +1013,27 @@ void wxOnAssert(const char *szFile, int nLine, const char *szMsg)
|
|||||||
|
|
||||||
s_bInAssert = TRUE;
|
s_bInAssert = TRUE;
|
||||||
|
|
||||||
char szBuf[LOG_BUFFER_SIZE];
|
wxChar szBuf[LOG_BUFFER_SIZE];
|
||||||
|
|
||||||
// make life easier for people using VC++ IDE: clicking on the message
|
// make life easier for people using VC++ IDE: clicking on the message
|
||||||
// will take us immediately to the place of the failed assert
|
// will take us immediately to the place of the failed assert
|
||||||
#ifdef __VISUALC__
|
#ifdef __VISUALC__
|
||||||
sprintf(szBuf, "%s(%d): assert failed", szFile, nLine);
|
sprintf(szBuf, _T("%s(%d): assert failed"), szFile, nLine);
|
||||||
#else // !VC++
|
#else // !VC++
|
||||||
// make the error message more clear for all the others
|
// make the error message more clear for all the others
|
||||||
sprintf(szBuf, "Assert failed in file %s at line %d", szFile, nLine);
|
#ifdef wxSprintf
|
||||||
|
wxSprintf(szBuf, _T("Assert failed in file %s at line %d"), szFile, nLine);
|
||||||
|
#else
|
||||||
|
wxSprintf(szBuf, _T("Assert failed in file %hs at line %d"), szFile, nLine);
|
||||||
|
#endif
|
||||||
#endif // VC/!VC
|
#endif // VC/!VC
|
||||||
|
|
||||||
if ( szMsg != NULL ) {
|
if ( szMsg != NULL ) {
|
||||||
strcat(szBuf, ": ");
|
wxStrcat(szBuf, _T(": "));
|
||||||
strcat(szBuf, szMsg);
|
wxStrcat(szBuf, szMsg);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
strcat(szBuf, ".");
|
wxStrcat(szBuf, _T("."));
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( !s_bNoAsserts ) {
|
if ( !s_bNoAsserts ) {
|
||||||
@@ -1035,9 +1045,9 @@ void wxOnAssert(const char *szFile, int nLine, const char *szMsg)
|
|||||||
#else
|
#else
|
||||||
// this message is intentionally not translated - it is for
|
// this message is intentionally not translated - it is for
|
||||||
// developpers only
|
// developpers only
|
||||||
strcat(szBuf, "\nDo you want to stop the program?"
|
wxStrcat(szBuf, _T("\nDo you want to stop the program?"
|
||||||
"\nYou can also choose [Cancel] to suppress "
|
"\nYou can also choose [Cancel] to suppress "
|
||||||
"further warnings.");
|
"further warnings."));
|
||||||
|
|
||||||
switch ( wxMessageBox(szBuf, _("Debug"),
|
switch ( wxMessageBox(szBuf, _("Debug"),
|
||||||
wxYES_NO | wxCANCEL | wxICON_STOP ) ) {
|
wxYES_NO | wxCANCEL | wxICON_STOP ) ) {
|
||||||
|
@@ -233,7 +233,7 @@ public:
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
wxASSERT_MSG( n == pos, "invalid position in MailCapEntry::Insert" );
|
wxASSERT_MSG( n == pos, _T("invalid position in MailCapEntry::Insert") );
|
||||||
|
|
||||||
m_next = cur->m_next;
|
m_next = cur->m_next;
|
||||||
cur->m_next = this;
|
cur->m_next = this;
|
||||||
@@ -241,7 +241,7 @@ public:
|
|||||||
// append this element to the list
|
// append this element to the list
|
||||||
void Append(MailCapEntry *next)
|
void Append(MailCapEntry *next)
|
||||||
{
|
{
|
||||||
wxCHECK_RET( next != NULL, "Append()ing to what?" );
|
wxCHECK_RET( next != NULL, _T("Append()ing to what?") );
|
||||||
|
|
||||||
// FIXME slooow...
|
// FIXME slooow...
|
||||||
MailCapEntry *cur;
|
MailCapEntry *cur;
|
||||||
@@ -250,7 +250,7 @@ public:
|
|||||||
|
|
||||||
cur->m_next = this;
|
cur->m_next = this;
|
||||||
|
|
||||||
wxASSERT_MSG( !m_next, "Append()ing element already in the list?" );
|
wxASSERT_MSG( !m_next, _T("Append()ing element already in the list?") );
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
@@ -349,57 +349,57 @@ wxString wxFileType::ExpandCommand(const wxString& command,
|
|||||||
bool hasFilename = FALSE;
|
bool hasFilename = FALSE;
|
||||||
|
|
||||||
wxString str;
|
wxString str;
|
||||||
for ( const char *pc = command.c_str(); *pc != '\0'; pc++ ) {
|
for ( const wxChar *pc = command.c_str(); *pc != _T('\0'); pc++ ) {
|
||||||
if ( *pc == '%' ) {
|
if ( *pc == _T('%') ) {
|
||||||
switch ( *++pc ) {
|
switch ( *++pc ) {
|
||||||
case 's':
|
case _T('s'):
|
||||||
// '%s' expands into file name (quoted because it might
|
// '%s' expands into file name (quoted because it might
|
||||||
// contain spaces) - except if there are already quotes
|
// contain spaces) - except if there are already quotes
|
||||||
// there because otherwise some programs may get confused
|
// there because otherwise some programs may get confused
|
||||||
// by double double quotes
|
// by double double quotes
|
||||||
#if 0
|
#if 0
|
||||||
if ( *(pc - 2) == '"' )
|
if ( *(pc - 2) == _T('"') )
|
||||||
str << params.GetFileName();
|
str << params.GetFileName();
|
||||||
else
|
else
|
||||||
str << '"' << params.GetFileName() << '"';
|
str << _T('"') << params.GetFileName() << _T('"');
|
||||||
#endif
|
#endif
|
||||||
str << params.GetFileName();
|
str << params.GetFileName();
|
||||||
hasFilename = TRUE;
|
hasFilename = TRUE;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 't':
|
case _T('t'):
|
||||||
// '%t' expands into MIME type (quote it too just to be
|
// '%t' expands into MIME type (quote it too just to be
|
||||||
// consistent)
|
// consistent)
|
||||||
str << '\'' << params.GetMimeType() << '\'';
|
str << _T('\'') << params.GetMimeType() << _T('\'');
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case '{':
|
case _T('{'):
|
||||||
{
|
{
|
||||||
const char *pEnd = strchr(pc, '}');
|
const wxChar *pEnd = wxStrchr(pc, _T('}'));
|
||||||
if ( pEnd == NULL ) {
|
if ( pEnd == NULL ) {
|
||||||
wxString mimetype;
|
wxString mimetype;
|
||||||
wxLogWarning(_("Unmatched '{' in an entry for "
|
wxLogWarning(_("Unmatched '{' in an entry for "
|
||||||
"mime type %s."),
|
"mime type %s."),
|
||||||
params.GetMimeType().c_str());
|
params.GetMimeType().c_str());
|
||||||
str << "%{";
|
str << _T("%{");
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
wxString param(pc + 1, pEnd - pc - 1);
|
wxString param(pc + 1, pEnd - pc - 1);
|
||||||
str << '\'' << params.GetParamValue(param) << '\'';
|
str << _T('\'') << params.GetParamValue(param) << _T('\'');
|
||||||
pc = pEnd;
|
pc = pEnd;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'n':
|
case _T('n'):
|
||||||
case 'F':
|
case _T('F'):
|
||||||
// TODO %n is the number of parts, %F is an array containing
|
// TODO %n is the number of parts, %F is an array containing
|
||||||
// the names of temp files these parts were written to
|
// the names of temp files these parts were written to
|
||||||
// and their mime types.
|
// and their mime types.
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
wxLogDebug("Unknown field %%%c in command '%s'.",
|
wxLogDebug(_T("Unknown field %%%c in command '%s'."),
|
||||||
*pc, command.c_str());
|
*pc, command.c_str());
|
||||||
str << *pc;
|
str << *pc;
|
||||||
}
|
}
|
||||||
@@ -412,7 +412,7 @@ wxString wxFileType::ExpandCommand(const wxString& command,
|
|||||||
// metamail(1) man page states that if the mailcap entry doesn't have '%s'
|
// metamail(1) man page states that if the mailcap entry doesn't have '%s'
|
||||||
// the program will accept the data on stdin: so give it to it!
|
// the program will accept the data on stdin: so give it to it!
|
||||||
if ( !hasFilename && !str.IsEmpty() ) {
|
if ( !hasFilename && !str.IsEmpty() ) {
|
||||||
str << " < '" << params.GetFileName() << '\'';
|
str << _T(" < '") << params.GetFileName() << _T('\'');
|
||||||
}
|
}
|
||||||
|
|
||||||
return str;
|
return str;
|
||||||
@@ -469,16 +469,16 @@ wxFileType::GetPrintCommand(wxString *printCmd,
|
|||||||
bool wxMimeTypesManager::IsOfType(const wxString& mimeType,
|
bool wxMimeTypesManager::IsOfType(const wxString& mimeType,
|
||||||
const wxString& wildcard)
|
const wxString& wildcard)
|
||||||
{
|
{
|
||||||
wxASSERT_MSG( mimeType.Find('*') == wxNOT_FOUND,
|
wxASSERT_MSG( mimeType.Find(_T('*')) == wxNOT_FOUND,
|
||||||
"first MIME type can't contain wildcards" );
|
_T("first MIME type can't contain wildcards") );
|
||||||
|
|
||||||
// all comparaisons are case insensitive (2nd arg of IsSameAs() is FALSE)
|
// all comparaisons are case insensitive (2nd arg of IsSameAs() is FALSE)
|
||||||
if ( wildcard.BeforeFirst('/').IsSameAs(mimeType.BeforeFirst('/'), FALSE) )
|
if ( wildcard.BeforeFirst(_T('/')).IsSameAs(mimeType.BeforeFirst(_T('/')), FALSE) )
|
||||||
{
|
{
|
||||||
wxString strSubtype = wildcard.AfterFirst('/');
|
wxString strSubtype = wildcard.AfterFirst(_T('/'));
|
||||||
|
|
||||||
if ( strSubtype == '*' ||
|
if ( strSubtype == _T('*') ||
|
||||||
strSubtype.IsSameAs(mimeType.AfterFirst('/'), FALSE) )
|
strSubtype.IsSameAs(mimeType.AfterFirst(_T('/')), FALSE) )
|
||||||
{
|
{
|
||||||
// matches (either exactly or it's a wildcard)
|
// matches (either exactly or it's a wildcard)
|
||||||
return TRUE;
|
return TRUE;
|
||||||
@@ -526,27 +526,27 @@ bool wxMimeTypesManager::ReadMimeTypes(const wxString& filename)
|
|||||||
|
|
||||||
#ifdef __WXMSW__
|
#ifdef __WXMSW__
|
||||||
|
|
||||||
bool wxFileTypeImpl::GetCommand(wxString *command, const char *verb) const
|
bool wxFileTypeImpl::GetCommand(wxString *command, const wxChar *verb) const
|
||||||
{
|
{
|
||||||
// suppress possible error messages
|
// suppress possible error messages
|
||||||
wxLogNull nolog;
|
wxLogNull nolog;
|
||||||
wxString strKey;
|
wxString strKey;
|
||||||
strKey << m_strFileType << "\\shell\\" << verb << "\\command";
|
strKey << m_strFileType << _T("\\shell\\") << verb << _T("\\command");
|
||||||
wxRegKey key(wxRegKey::HKCR, strKey);
|
wxRegKey key(wxRegKey::HKCR, strKey);
|
||||||
|
|
||||||
if ( key.Open() ) {
|
if ( key.Open() ) {
|
||||||
// it's the default value of the key
|
// it's the default value of the key
|
||||||
if ( key.QueryValue("", *command) ) {
|
if ( key.QueryValue(_T(""), *command) ) {
|
||||||
// transform it from '%1' to '%s' style format string
|
// transform it from '%1' to '%s' style format string
|
||||||
// NB: we don't make any attempt to verify that the string is valid,
|
// NB: we don't make any attempt to verify that the string is valid,
|
||||||
// i.e. doesn't contain %2, or second %1 or .... But we do make
|
// i.e. doesn't contain %2, or second %1 or .... But we do make
|
||||||
// sure that we return a string with _exactly_ one '%s'!
|
// sure that we return a string with _exactly_ one '%s'!
|
||||||
size_t len = command->Len();
|
size_t len = command->Len();
|
||||||
for ( size_t n = 0; n < len; n++ ) {
|
for ( size_t n = 0; n < len; n++ ) {
|
||||||
if ( command->GetChar(n) == '%' &&
|
if ( command->GetChar(n) == _T('%') &&
|
||||||
(n + 1 < len) && command->GetChar(n + 1) == '1' ) {
|
(n + 1 < len) && command->GetChar(n + 1) == _T('1') ) {
|
||||||
// replace it with '%s'
|
// replace it with '%s'
|
||||||
command->SetChar(n + 1, 's');
|
command->SetChar(n + 1, _T('s'));
|
||||||
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
@@ -554,7 +554,7 @@ bool wxFileTypeImpl::GetCommand(wxString *command, const char *verb) const
|
|||||||
|
|
||||||
// we didn't find any '%1'!
|
// we didn't find any '%1'!
|
||||||
// HACK: append the filename at the end, hope that it will do
|
// HACK: append the filename at the end, hope that it will do
|
||||||
*command << " %s";
|
*command << _T(" %s");
|
||||||
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
@@ -585,8 +585,8 @@ bool wxFileTypeImpl::GetMimeType(wxString *mimeType) const
|
|||||||
{
|
{
|
||||||
// suppress possible error messages
|
// suppress possible error messages
|
||||||
wxLogNull nolog;
|
wxLogNull nolog;
|
||||||
wxRegKey key(wxRegKey::HKCR, /*m_strFileType*/ "." + m_ext);
|
wxRegKey key(wxRegKey::HKCR, /*m_strFileType*/ _T(".") + m_ext);
|
||||||
if ( key.Open() && key.QueryValue("Content Type", *mimeType) ) {
|
if ( key.Open() && key.QueryValue(_T("Content Type"), *mimeType) ) {
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
@@ -597,7 +597,7 @@ bool wxFileTypeImpl::GetMimeType(wxString *mimeType) const
|
|||||||
bool wxFileTypeImpl::GetIcon(wxIcon *icon) const
|
bool wxFileTypeImpl::GetIcon(wxIcon *icon) const
|
||||||
{
|
{
|
||||||
wxString strIconKey;
|
wxString strIconKey;
|
||||||
strIconKey << m_strFileType << "\\DefaultIcon";
|
strIconKey << m_strFileType << _T("\\DefaultIcon");
|
||||||
|
|
||||||
// suppress possible error messages
|
// suppress possible error messages
|
||||||
wxLogNull nolog;
|
wxLogNull nolog;
|
||||||
@@ -606,18 +606,18 @@ bool wxFileTypeImpl::GetIcon(wxIcon *icon) const
|
|||||||
if ( key.Open() ) {
|
if ( key.Open() ) {
|
||||||
wxString strIcon;
|
wxString strIcon;
|
||||||
// it's the default value of the key
|
// it's the default value of the key
|
||||||
if ( key.QueryValue("", strIcon) ) {
|
if ( key.QueryValue(_T(""), strIcon) ) {
|
||||||
// the format is the following: <full path to file>, <icon index>
|
// the format is the following: <full path to file>, <icon index>
|
||||||
// NB: icon index may be negative as well as positive and the full
|
// NB: icon index may be negative as well as positive and the full
|
||||||
// path may contain the environment variables inside '%'
|
// path may contain the environment variables inside '%'
|
||||||
wxString strFullPath = strIcon.BeforeLast(','),
|
wxString strFullPath = strIcon.BeforeLast(_T(',')),
|
||||||
strIndex = strIcon.AfterLast(',');
|
strIndex = strIcon.AfterLast(_T(','));
|
||||||
|
|
||||||
// index may be omitted, in which case BeforeLast(',') is empty and
|
// index may be omitted, in which case BeforeLast(',') is empty and
|
||||||
// AfterLast(',') is the whole string
|
// AfterLast(',') is the whole string
|
||||||
if ( strFullPath.IsEmpty() ) {
|
if ( strFullPath.IsEmpty() ) {
|
||||||
strFullPath = strIndex;
|
strFullPath = strIndex;
|
||||||
strIndex = "0";
|
strIndex = _T("0");
|
||||||
}
|
}
|
||||||
|
|
||||||
wxString strExpPath = wxExpandEnvVars(strFullPath);
|
wxString strExpPath = wxExpandEnvVars(strFullPath);
|
||||||
@@ -627,7 +627,7 @@ bool wxFileTypeImpl::GetIcon(wxIcon *icon) const
|
|||||||
switch ( (int)hIcon ) {
|
switch ( (int)hIcon ) {
|
||||||
case 0: // means no icons were found
|
case 0: // means no icons were found
|
||||||
case 1: // means no such file or it wasn't a DLL/EXE/OCX/ICO/...
|
case 1: // means no such file or it wasn't a DLL/EXE/OCX/ICO/...
|
||||||
wxLogDebug("incorrect registry entry '%s': no such icon.",
|
wxLogDebug(_T("incorrect registry entry '%s': no such icon."),
|
||||||
key.GetName().c_str());
|
key.GetName().c_str());
|
||||||
break;
|
break;
|
||||||
|
|
||||||
@@ -650,7 +650,7 @@ bool wxFileTypeImpl::GetDescription(wxString *desc) const
|
|||||||
|
|
||||||
if ( key.Open() ) {
|
if ( key.Open() ) {
|
||||||
// it's the default value of the key
|
// it's the default value of the key
|
||||||
if ( key.QueryValue("", *desc) ) {
|
if ( key.QueryValue(_T(""), *desc) ) {
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -664,8 +664,8 @@ wxMimeTypesManagerImpl::GetFileTypeFromExtension(const wxString& ext)
|
|||||||
{
|
{
|
||||||
// add the leading point if necessary
|
// add the leading point if necessary
|
||||||
wxString str;
|
wxString str;
|
||||||
if ( ext[0u] != '.' ) {
|
if ( ext[0u] != _T('.') ) {
|
||||||
str = '.';
|
str = _T('.');
|
||||||
}
|
}
|
||||||
str << ext;
|
str << ext;
|
||||||
|
|
||||||
@@ -676,7 +676,7 @@ wxMimeTypesManagerImpl::GetFileTypeFromExtension(const wxString& ext)
|
|||||||
wxRegKey key(wxRegKey::HKCR, str);
|
wxRegKey key(wxRegKey::HKCR, str);
|
||||||
if ( key.Open() ) {
|
if ( key.Open() ) {
|
||||||
// it's the default value of the key
|
// it's the default value of the key
|
||||||
if ( key.QueryValue("", strFileType) ) {
|
if ( key.QueryValue(_T(""), strFileType) ) {
|
||||||
// create the new wxFileType object
|
// create the new wxFileType object
|
||||||
wxFileType *fileType = new wxFileType;
|
wxFileType *fileType = new wxFileType;
|
||||||
fileType->m_impl->SetFileType(strFileType);
|
fileType->m_impl->SetFileType(strFileType);
|
||||||
@@ -696,7 +696,7 @@ wxMimeTypesManagerImpl::GetFileTypeFromMimeType(const wxString& mimeType)
|
|||||||
{
|
{
|
||||||
// HACK I don't know of any official documentation which mentions this
|
// HACK I don't know of any official documentation which mentions this
|
||||||
// location, but as a matter of fact IE uses it, so why not we?
|
// location, but as a matter of fact IE uses it, so why not we?
|
||||||
static const char *szMimeDbase = "MIME\\Database\\Content Type\\";
|
static const wxChar *szMimeDbase = _T("MIME\\Database\\Content Type\\");
|
||||||
|
|
||||||
wxString strKey = szMimeDbase;
|
wxString strKey = szMimeDbase;
|
||||||
strKey << mimeType;
|
strKey << mimeType;
|
||||||
@@ -707,7 +707,7 @@ wxMimeTypesManagerImpl::GetFileTypeFromMimeType(const wxString& mimeType)
|
|||||||
wxString ext;
|
wxString ext;
|
||||||
wxRegKey key(wxRegKey::HKCR, strKey);
|
wxRegKey key(wxRegKey::HKCR, strKey);
|
||||||
if ( key.Open() ) {
|
if ( key.Open() ) {
|
||||||
if ( key.QueryValue("Extension", ext) ) {
|
if ( key.QueryValue(_T("Extension"), ext) ) {
|
||||||
return GetFileTypeFromExtension(ext);
|
return GetFileTypeFromExtension(ext);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -727,14 +727,14 @@ wxFileTypeImpl::GetEntry(const wxFileType::MessageParameters& params) const
|
|||||||
// notice that an empty command would always succeed (it's ok)
|
// notice that an empty command would always succeed (it's ok)
|
||||||
command = wxFileType::ExpandCommand(entry->GetTestCmd(), params);
|
command = wxFileType::ExpandCommand(entry->GetTestCmd(), params);
|
||||||
|
|
||||||
if ( command.IsEmpty() || (system(command) == 0) ) {
|
if ( command.IsEmpty() || (wxSystem(command) == 0) ) {
|
||||||
// ok, passed
|
// ok, passed
|
||||||
wxLogTrace("Test '%s' for mime type '%s' succeeded.",
|
wxLogTrace(_T("Test '%s' for mime type '%s' succeeded."),
|
||||||
command.c_str(), params.GetMimeType().c_str());
|
command.c_str(), params.GetMimeType().c_str());
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
wxLogTrace("Test '%s' for mime type '%s' failed.",
|
wxLogTrace(_T("Test '%s' for mime type '%s' failed."),
|
||||||
command.c_str(), params.GetMimeType().c_str());
|
command.c_str(), params.GetMimeType().c_str());
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -772,8 +772,8 @@ bool wxFileTypeImpl::GetExtensions(wxArrayString& extensions)
|
|||||||
|
|
||||||
// one extension in the space or comma delimitid list
|
// one extension in the space or comma delimitid list
|
||||||
wxString strExt;
|
wxString strExt;
|
||||||
for ( const char *p = strExtensions; ; p++ ) {
|
for ( const wxChar *p = strExtensions; ; p++ ) {
|
||||||
if ( *p == ' ' || *p == ',' || *p == '\0' ) {
|
if ( *p == _T(' ') || *p == _T(',') || *p == _T('\0') ) {
|
||||||
if ( !strExt.IsEmpty() ) {
|
if ( !strExt.IsEmpty() ) {
|
||||||
extensions.Add(strExt);
|
extensions.Add(strExt);
|
||||||
strExt.Empty();
|
strExt.Empty();
|
||||||
@@ -781,13 +781,13 @@ bool wxFileTypeImpl::GetExtensions(wxArrayString& extensions)
|
|||||||
//else: repeated spaces (shouldn't happen, but it's not that
|
//else: repeated spaces (shouldn't happen, but it's not that
|
||||||
// important if it does happen)
|
// important if it does happen)
|
||||||
|
|
||||||
if ( *p == '\0' )
|
if ( *p == _T('\0') )
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
else if ( *p == '.' ) {
|
else if ( *p == _T('.') ) {
|
||||||
// remove the dot from extension (but only if it's the first char)
|
// remove the dot from extension (but only if it's the first char)
|
||||||
if ( !strExt.IsEmpty() ) {
|
if ( !strExt.IsEmpty() ) {
|
||||||
strExt += '.';
|
strExt += _T('.');
|
||||||
}
|
}
|
||||||
//else: no, don't append it
|
//else: no, don't append it
|
||||||
}
|
}
|
||||||
@@ -804,40 +804,40 @@ wxMimeTypesManagerImpl::wxMimeTypesManagerImpl()
|
|||||||
{
|
{
|
||||||
// directories where we look for mailcap and mime.types by default
|
// directories where we look for mailcap and mime.types by default
|
||||||
// (taken from metamail(1) sources)
|
// (taken from metamail(1) sources)
|
||||||
static const char *aStandardLocations[] =
|
static const wxChar *aStandardLocations[] =
|
||||||
{
|
{
|
||||||
"/etc",
|
_T("/etc"),
|
||||||
"/usr/etc",
|
_T("/usr/etc"),
|
||||||
"/usr/local/etc",
|
_T("/usr/local/etc"),
|
||||||
"/etc/mail",
|
_T("/etc/mail"),
|
||||||
"/usr/public/lib"
|
_T("/usr/public/lib")
|
||||||
};
|
};
|
||||||
|
|
||||||
// first read the system wide file(s)
|
// first read the system wide file(s)
|
||||||
for ( size_t n = 0; n < WXSIZEOF(aStandardLocations); n++ ) {
|
for ( size_t n = 0; n < WXSIZEOF(aStandardLocations); n++ ) {
|
||||||
wxString dir = aStandardLocations[n];
|
wxString dir = aStandardLocations[n];
|
||||||
|
|
||||||
wxString file = dir + "/mailcap";
|
wxString file = dir + _T("/mailcap");
|
||||||
if ( wxFile::Exists(file) ) {
|
if ( wxFile::Exists(file) ) {
|
||||||
ReadMailcap(file);
|
ReadMailcap(file);
|
||||||
}
|
}
|
||||||
|
|
||||||
file = dir + "/mime.types";
|
file = dir + _T("/mime.types");
|
||||||
if ( wxFile::Exists(file) ) {
|
if ( wxFile::Exists(file) ) {
|
||||||
ReadMimeTypes(file);
|
ReadMimeTypes(file);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
wxString strHome = getenv("HOME");
|
wxString strHome = wxGetenv(_T("HOME"));
|
||||||
|
|
||||||
// and now the users mailcap
|
// and now the users mailcap
|
||||||
wxString strUserMailcap = strHome + "/.mailcap";
|
wxString strUserMailcap = strHome + _T("/.mailcap");
|
||||||
if ( wxFile::Exists(strUserMailcap) ) {
|
if ( wxFile::Exists(strUserMailcap) ) {
|
||||||
ReadMailcap(strUserMailcap);
|
ReadMailcap(strUserMailcap);
|
||||||
}
|
}
|
||||||
|
|
||||||
// read the users mime.types
|
// read the users mime.types
|
||||||
wxString strUserMimeTypes = strHome + "/.mime.types";
|
wxString strUserMimeTypes = strHome + _T("/.mime.types");
|
||||||
if ( wxFile::Exists(strUserMimeTypes) ) {
|
if ( wxFile::Exists(strUserMimeTypes) ) {
|
||||||
ReadMimeTypes(strUserMimeTypes);
|
ReadMimeTypes(strUserMimeTypes);
|
||||||
}
|
}
|
||||||
@@ -850,8 +850,8 @@ wxMimeTypesManagerImpl::GetFileTypeFromExtension(const wxString& ext)
|
|||||||
for ( size_t n = 0; n < count; n++ ) {
|
for ( size_t n = 0; n < count; n++ ) {
|
||||||
wxString extensions = m_aExtensions[n];
|
wxString extensions = m_aExtensions[n];
|
||||||
while ( !extensions.IsEmpty() ) {
|
while ( !extensions.IsEmpty() ) {
|
||||||
wxString field = extensions.BeforeFirst(' ');
|
wxString field = extensions.BeforeFirst(_T(' '));
|
||||||
extensions = extensions.AfterFirst(' ');
|
extensions = extensions.AfterFirst(_T(' '));
|
||||||
|
|
||||||
// consider extensions as not being case-sensitive
|
// consider extensions as not being case-sensitive
|
||||||
if ( field.IsSameAs(ext, FALSE /* no case */) ) {
|
if ( field.IsSameAs(ext, FALSE /* no case */) ) {
|
||||||
@@ -881,12 +881,12 @@ wxMimeTypesManagerImpl::GetFileTypeFromMimeType(const wxString& mimeType)
|
|||||||
// then try to find "text/*" as match for "text/plain" (for example)
|
// then try to find "text/*" as match for "text/plain" (for example)
|
||||||
// NB: if mimeType doesn't contain '/' at all, BeforeFirst() will return
|
// NB: if mimeType doesn't contain '/' at all, BeforeFirst() will return
|
||||||
// the whole string - ok.
|
// the whole string - ok.
|
||||||
wxString strCategory = mimetype.BeforeFirst('/');
|
wxString strCategory = mimetype.BeforeFirst(_T('/'));
|
||||||
|
|
||||||
size_t nCount = m_aTypes.Count();
|
size_t nCount = m_aTypes.Count();
|
||||||
for ( size_t n = 0; n < nCount; n++ ) {
|
for ( size_t n = 0; n < nCount; n++ ) {
|
||||||
if ( (m_aTypes[n].BeforeFirst('/') == strCategory ) &&
|
if ( (m_aTypes[n].BeforeFirst(_T('/')) == strCategory ) &&
|
||||||
m_aTypes[n].AfterFirst('/') == "*" ) {
|
m_aTypes[n].AfterFirst(_T('/')) == _T("*") ) {
|
||||||
index = n;
|
index = n;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -907,7 +907,7 @@ wxMimeTypesManagerImpl::GetFileTypeFromMimeType(const wxString& mimeType)
|
|||||||
|
|
||||||
bool wxMimeTypesManagerImpl::ReadMimeTypes(const wxString& strFileName)
|
bool wxMimeTypesManagerImpl::ReadMimeTypes(const wxString& strFileName)
|
||||||
{
|
{
|
||||||
wxLogTrace("--- Parsing mime.types file '%s' ---", strFileName.c_str());
|
wxLogTrace(_T("--- Parsing mime.types file '%s' ---"), strFileName.c_str());
|
||||||
|
|
||||||
wxTextFile file(strFileName);
|
wxTextFile file(strFileName);
|
||||||
if ( !file.Open() )
|
if ( !file.Open() )
|
||||||
@@ -917,7 +917,7 @@ bool wxMimeTypesManagerImpl::ReadMimeTypes(const wxString& strFileName)
|
|||||||
wxString strMimeType, strDesc, strExtensions;
|
wxString strMimeType, strDesc, strExtensions;
|
||||||
|
|
||||||
size_t nLineCount = file.GetLineCount();
|
size_t nLineCount = file.GetLineCount();
|
||||||
const char *pc = NULL;
|
const wxChar *pc = NULL;
|
||||||
for ( size_t nLine = 0; nLine < nLineCount; nLine++ ) {
|
for ( size_t nLine = 0; nLine < nLineCount; nLine++ ) {
|
||||||
if ( pc == NULL ) {
|
if ( pc == NULL ) {
|
||||||
// now we're at the start of the line
|
// now we're at the start of the line
|
||||||
@@ -929,29 +929,29 @@ bool wxMimeTypesManagerImpl::ReadMimeTypes(const wxString& strFileName)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// skip whitespace
|
// skip whitespace
|
||||||
while ( isspace(*pc) )
|
while ( wxIsspace(*pc) )
|
||||||
pc++;
|
pc++;
|
||||||
|
|
||||||
// comment?
|
// comment?
|
||||||
if ( *pc == '#' ) {
|
if ( *pc == _T('#') ) {
|
||||||
// skip the whole line
|
// skip the whole line
|
||||||
pc = NULL;
|
pc = NULL;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
// detect file format
|
// detect file format
|
||||||
const char *pEqualSign = strchr(pc, '=');
|
const wxChar *pEqualSign = wxStrchr(pc, _T('='));
|
||||||
if ( pEqualSign == NULL ) {
|
if ( pEqualSign == NULL ) {
|
||||||
// brief format
|
// brief format
|
||||||
// ------------
|
// ------------
|
||||||
|
|
||||||
// first field is mime type
|
// first field is mime type
|
||||||
for ( strMimeType.Empty(); !isspace(*pc) && *pc != '\0'; pc++ ) {
|
for ( strMimeType.Empty(); !wxIsspace(*pc) && *pc != _T('\0'); pc++ ) {
|
||||||
strMimeType += *pc;
|
strMimeType += *pc;
|
||||||
}
|
}
|
||||||
|
|
||||||
// skip whitespace
|
// skip whitespace
|
||||||
while ( isspace(*pc) )
|
while ( wxIsspace(*pc) )
|
||||||
pc++;
|
pc++;
|
||||||
|
|
||||||
// take all the rest of the string
|
// take all the rest of the string
|
||||||
@@ -968,13 +968,13 @@ bool wxMimeTypesManagerImpl::ReadMimeTypes(const wxString& strFileName)
|
|||||||
wxString strLHS(pc, pEqualSign - pc);
|
wxString strLHS(pc, pEqualSign - pc);
|
||||||
|
|
||||||
// eat whitespace
|
// eat whitespace
|
||||||
for ( pc = pEqualSign + 1; isspace(*pc); pc++ )
|
for ( pc = pEqualSign + 1; wxIsspace(*pc); pc++ )
|
||||||
;
|
;
|
||||||
|
|
||||||
const char *pEnd;
|
const wxChar *pEnd;
|
||||||
if ( *pc == '"' ) {
|
if ( *pc == _T('"') ) {
|
||||||
// the string is quoted and ends at the matching quote
|
// the string is quoted and ends at the matching quote
|
||||||
pEnd = strchr(++pc, '"');
|
pEnd = wxStrchr(++pc, _T('"'));
|
||||||
if ( pEnd == NULL ) {
|
if ( pEnd == NULL ) {
|
||||||
wxLogWarning(_("Mime.types file %s, line %d: unterminated "
|
wxLogWarning(_("Mime.types file %s, line %d: unterminated "
|
||||||
"quoted string."),
|
"quoted string."),
|
||||||
@@ -983,7 +983,7 @@ bool wxMimeTypesManagerImpl::ReadMimeTypes(const wxString& strFileName)
|
|||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
// unquoted string ends at the first space
|
// unquoted string ends at the first space
|
||||||
for ( pEnd = pc; !isspace(*pEnd); pEnd++ )
|
for ( pEnd = pc; !wxIsspace(*pEnd); pEnd++ )
|
||||||
;
|
;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -991,30 +991,30 @@ bool wxMimeTypesManagerImpl::ReadMimeTypes(const wxString& strFileName)
|
|||||||
wxString strRHS(pc, pEnd - pc);
|
wxString strRHS(pc, pEnd - pc);
|
||||||
|
|
||||||
// check what follows this entry
|
// check what follows this entry
|
||||||
if ( *pEnd == '"' ) {
|
if ( *pEnd == _T('"') ) {
|
||||||
// skip this quote
|
// skip this quote
|
||||||
pEnd++;
|
pEnd++;
|
||||||
}
|
}
|
||||||
|
|
||||||
for ( pc = pEnd; isspace(*pc); pc++ )
|
for ( pc = pEnd; wxIsspace(*pc); pc++ )
|
||||||
;
|
;
|
||||||
|
|
||||||
// if there is something left, it may be either a '\\' to continue
|
// if there is something left, it may be either a '\\' to continue
|
||||||
// the line or the next field of the same entry
|
// the line or the next field of the same entry
|
||||||
bool entryEnded = *pc == '\0',
|
bool entryEnded = *pc == _T('\0'),
|
||||||
nextFieldOnSameLine = FALSE;
|
nextFieldOnSameLine = FALSE;
|
||||||
if ( !entryEnded ) {
|
if ( !entryEnded ) {
|
||||||
nextFieldOnSameLine = ((*pc != '\\') || (pc[1] != '\0'));
|
nextFieldOnSameLine = ((*pc != _T('\\')) || (pc[1] != _T('\0')));
|
||||||
}
|
}
|
||||||
|
|
||||||
// now see what we got
|
// now see what we got
|
||||||
if ( strLHS == "type" ) {
|
if ( strLHS == _T("type") ) {
|
||||||
strMimeType = strRHS;
|
strMimeType = strRHS;
|
||||||
}
|
}
|
||||||
else if ( strLHS == "desc" ) {
|
else if ( strLHS == _T("desc") ) {
|
||||||
strDesc = strRHS;
|
strDesc = strRHS;
|
||||||
}
|
}
|
||||||
else if ( strLHS == "exts" ) {
|
else if ( strLHS == _T("exts") ) {
|
||||||
strExtensions = strRHS;
|
strExtensions = strRHS;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
@@ -1037,10 +1037,10 @@ bool wxMimeTypesManagerImpl::ReadMimeTypes(const wxString& strFileName)
|
|||||||
// although it doesn't seem to be covered by RFCs, some programs
|
// although it doesn't seem to be covered by RFCs, some programs
|
||||||
// (notably Netscape) create their entries with several comma
|
// (notably Netscape) create their entries with several comma
|
||||||
// separated extensions (RFC mention the spaces only)
|
// separated extensions (RFC mention the spaces only)
|
||||||
strExtensions.Replace(",", " ");
|
strExtensions.Replace(_T(","), _T(" "));
|
||||||
|
|
||||||
// also deal with the leading dot
|
// also deal with the leading dot
|
||||||
if ( !strExtensions.IsEmpty() && strExtensions[0] == '.' ) {
|
if ( !strExtensions.IsEmpty() && strExtensions[0] == _T('.') ) {
|
||||||
strExtensions.erase(0, 1);
|
strExtensions.erase(0, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1075,7 +1075,7 @@ bool wxMimeTypesManagerImpl::ReadMimeTypes(const wxString& strFileName)
|
|||||||
bool wxMimeTypesManagerImpl::ReadMailcap(const wxString& strFileName,
|
bool wxMimeTypesManagerImpl::ReadMailcap(const wxString& strFileName,
|
||||||
bool fallback)
|
bool fallback)
|
||||||
{
|
{
|
||||||
wxLogTrace("--- Parsing mailcap file '%s' ---", strFileName.c_str());
|
wxLogTrace(_T("--- Parsing mailcap file '%s' ---"), strFileName.c_str());
|
||||||
|
|
||||||
wxTextFile file(strFileName);
|
wxTextFile file(strFileName);
|
||||||
if ( !file.Open() )
|
if ( !file.Open() )
|
||||||
@@ -1092,14 +1092,14 @@ bool wxMimeTypesManagerImpl::ReadMailcap(const wxString& strFileName,
|
|||||||
size_t nLineCount = file.GetLineCount();
|
size_t nLineCount = file.GetLineCount();
|
||||||
for ( size_t nLine = 0; nLine < nLineCount; nLine++ ) {
|
for ( size_t nLine = 0; nLine < nLineCount; nLine++ ) {
|
||||||
// now we're at the start of the line
|
// now we're at the start of the line
|
||||||
const char *pc = file[nLine].c_str();
|
const wxChar *pc = file[nLine].c_str();
|
||||||
|
|
||||||
// skip whitespace
|
// skip whitespace
|
||||||
while ( isspace(*pc) )
|
while ( wxIsspace(*pc) )
|
||||||
pc++;
|
pc++;
|
||||||
|
|
||||||
// comment or empty string?
|
// comment or empty string?
|
||||||
if ( *pc == '#' || *pc == '\0' )
|
if ( *pc == _T('#') || *pc == _T('\0') )
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
// no, do parse
|
// no, do parse
|
||||||
@@ -1125,10 +1125,10 @@ bool wxMimeTypesManagerImpl::ReadMailcap(const wxString& strFileName,
|
|||||||
curField; // accumulator
|
curField; // accumulator
|
||||||
for ( bool cont = TRUE; cont; pc++ ) {
|
for ( bool cont = TRUE; cont; pc++ ) {
|
||||||
switch ( *pc ) {
|
switch ( *pc ) {
|
||||||
case '\\':
|
case _T('\\'):
|
||||||
// interpret the next character literally (notice that
|
// interpret the next character literally (notice that
|
||||||
// backslash can be used for line continuation)
|
// backslash can be used for line continuation)
|
||||||
if ( *++pc == '\0' ) {
|
if ( *++pc == _T('\0') ) {
|
||||||
// fetch the next line.
|
// fetch the next line.
|
||||||
|
|
||||||
// pc currently points to nowhere, but after the next
|
// pc currently points to nowhere, but after the next
|
||||||
@@ -1142,12 +1142,12 @@ bool wxMimeTypesManagerImpl::ReadMailcap(const wxString& strFileName,
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case '\0':
|
case _T('\0'):
|
||||||
cont = FALSE; // end of line reached, exit the loop
|
cont = FALSE; // end of line reached, exit the loop
|
||||||
|
|
||||||
// fall through
|
// fall through
|
||||||
|
|
||||||
case ';':
|
case _T(';'):
|
||||||
// store this field and start looking for the next one
|
// store this field and start looking for the next one
|
||||||
|
|
||||||
// trim whitespaces from both sides
|
// trim whitespaces from both sides
|
||||||
@@ -1156,9 +1156,9 @@ bool wxMimeTypesManagerImpl::ReadMailcap(const wxString& strFileName,
|
|||||||
switch ( currentToken ) {
|
switch ( currentToken ) {
|
||||||
case Field_Type:
|
case Field_Type:
|
||||||
strType = curField;
|
strType = curField;
|
||||||
if ( strType.Find('/') == wxNOT_FOUND ) {
|
if ( strType.Find(_T('/')) == wxNOT_FOUND ) {
|
||||||
// we interpret "type" as "type/*"
|
// we interpret "type" as "type/*"
|
||||||
strType += "/*";
|
strType += _T("/*");
|
||||||
}
|
}
|
||||||
|
|
||||||
currentToken = Field_OpenCmd;
|
currentToken = Field_OpenCmd;
|
||||||
@@ -1176,22 +1176,22 @@ bool wxMimeTypesManagerImpl::ReadMailcap(const wxString& strFileName,
|
|||||||
bool ok = TRUE;
|
bool ok = TRUE;
|
||||||
|
|
||||||
// is this something of the form foo=bar?
|
// is this something of the form foo=bar?
|
||||||
const char *pEq = strchr(curField, '=');
|
const wxChar *pEq = wxStrchr(curField, _T('='));
|
||||||
if ( pEq != NULL ) {
|
if ( pEq != NULL ) {
|
||||||
wxString lhs = curField.BeforeFirst('='),
|
wxString lhs = curField.BeforeFirst(_T('=')),
|
||||||
rhs = curField.AfterFirst('=');
|
rhs = curField.AfterFirst(_T('='));
|
||||||
|
|
||||||
lhs.Trim(TRUE); // from right
|
lhs.Trim(TRUE); // from right
|
||||||
rhs.Trim(FALSE); // from left
|
rhs.Trim(FALSE); // from left
|
||||||
|
|
||||||
if ( lhs == "print" )
|
if ( lhs == _T("print") )
|
||||||
strPrintCmd = rhs;
|
strPrintCmd = rhs;
|
||||||
else if ( lhs == "test" )
|
else if ( lhs == _T("test") )
|
||||||
strTest = rhs;
|
strTest = rhs;
|
||||||
else if ( lhs == "description" ) {
|
else if ( lhs == _T("description") ) {
|
||||||
// it might be quoted
|
// it might be quoted
|
||||||
if ( rhs[0u] == '"' &&
|
if ( rhs[0u] == _T('"') &&
|
||||||
rhs.Last() == '"' ) {
|
rhs.Last() == _T('"') ) {
|
||||||
strDesc = wxString(rhs.c_str() + 1,
|
strDesc = wxString(rhs.c_str() + 1,
|
||||||
rhs.Len() - 2);
|
rhs.Len() - 2);
|
||||||
}
|
}
|
||||||
@@ -1199,10 +1199,10 @@ bool wxMimeTypesManagerImpl::ReadMailcap(const wxString& strFileName,
|
|||||||
strDesc = rhs;
|
strDesc = rhs;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if ( lhs == "compose" ||
|
else if ( lhs == _T("compose") ||
|
||||||
lhs == "composetyped" ||
|
lhs == _T("composetyped") ||
|
||||||
lhs == "notes" ||
|
lhs == _T("notes") ||
|
||||||
lhs == "edit" )
|
lhs == _T("edit") )
|
||||||
; // ignore
|
; // ignore
|
||||||
else
|
else
|
||||||
ok = FALSE;
|
ok = FALSE;
|
||||||
@@ -1213,11 +1213,11 @@ bool wxMimeTypesManagerImpl::ReadMailcap(const wxString& strFileName,
|
|||||||
// TODO support the flags:
|
// TODO support the flags:
|
||||||
// 1. create an xterm for 'needsterminal'
|
// 1. create an xterm for 'needsterminal'
|
||||||
// 2. append "| $PAGER" for 'copiousoutput'
|
// 2. append "| $PAGER" for 'copiousoutput'
|
||||||
if ( curField == "needsterminal" )
|
if ( curField == _T("needsterminal") )
|
||||||
needsterminal = TRUE;
|
needsterminal = TRUE;
|
||||||
else if ( curField == "copiousoutput" )
|
else if ( curField == _T("copiousoutput") )
|
||||||
copiousoutput = TRUE;
|
copiousoutput = TRUE;
|
||||||
else if ( curField == "textualnewlines" )
|
else if ( curField == _T("textualnewlines") )
|
||||||
; // ignore
|
; // ignore
|
||||||
else
|
else
|
||||||
ok = FALSE;
|
ok = FALSE;
|
||||||
@@ -1232,9 +1232,9 @@ bool wxMimeTypesManagerImpl::ReadMailcap(const wxString& strFileName,
|
|||||||
// programmer
|
// programmer
|
||||||
wxLogDebug
|
wxLogDebug
|
||||||
(
|
(
|
||||||
"Mailcap file %s, line %d: unknown "
|
_T("Mailcap file %s, line %d: unknown "
|
||||||
"field '%s' for the MIME type "
|
"field '%s' for the MIME type "
|
||||||
"'%s' ignored.",
|
"'%s' ignored."),
|
||||||
strFileName.c_str(),
|
strFileName.c_str(),
|
||||||
nLine + 1,
|
nLine + 1,
|
||||||
curField.c_str(),
|
curField.c_str(),
|
||||||
@@ -1248,7 +1248,7 @@ bool wxMimeTypesManagerImpl::ReadMailcap(const wxString& strFileName,
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
wxFAIL_MSG("unknown field type in mailcap");
|
wxFAIL_MSG(_T("unknown field type in mailcap"));
|
||||||
}
|
}
|
||||||
|
|
||||||
// next token starts immediately after ';'
|
// next token starts immediately after ';'
|
||||||
@@ -1278,7 +1278,7 @@ bool wxMimeTypesManagerImpl::ReadMailcap(const wxString& strFileName,
|
|||||||
m_aTypes.Add(strType);
|
m_aTypes.Add(strType);
|
||||||
|
|
||||||
m_aEntries.Add(entry);
|
m_aEntries.Add(entry);
|
||||||
m_aExtensions.Add("");
|
m_aExtensions.Add(_T(""));
|
||||||
m_aDescriptions.Add(strDesc);
|
m_aDescriptions.Add(strDesc);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
Reference in New Issue
Block a user