Make wxr resources work in Unicode mode.
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@19093 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -183,8 +183,10 @@ WXDLLEXPORT extern wxIcon wxResourceCreateIcon(const wxString& resource, wxResou
|
|||||||
WXDLLEXPORT extern wxMenuBar* wxResourceCreateMenuBar(const wxString& resource, wxResourceTable *table = (wxResourceTable *) NULL, wxMenuBar *menuBar = (wxMenuBar *) NULL);
|
WXDLLEXPORT extern wxMenuBar* wxResourceCreateMenuBar(const wxString& resource, wxResourceTable *table = (wxResourceTable *) NULL, wxMenuBar *menuBar = (wxMenuBar *) NULL);
|
||||||
WXDLLEXPORT extern wxMenu* wxResourceCreateMenu(const wxString& resource, wxResourceTable *table = (wxResourceTable *) NULL);
|
WXDLLEXPORT extern wxMenu* wxResourceCreateMenu(const wxString& resource, wxResourceTable *table = (wxResourceTable *) NULL);
|
||||||
WXDLLEXPORT extern bool wxResourceParseData(const wxString& resource, wxResourceTable *table = (wxResourceTable *) NULL);
|
WXDLLEXPORT extern bool wxResourceParseData(const wxString& resource, wxResourceTable *table = (wxResourceTable *) NULL);
|
||||||
|
WXDLLEXPORT extern bool wxResourceParseData(const char* resource, wxResourceTable *table = (wxResourceTable *) NULL);
|
||||||
WXDLLEXPORT extern bool wxResourceParseFile(const wxString& filename, wxResourceTable *table = (wxResourceTable *) NULL);
|
WXDLLEXPORT extern bool wxResourceParseFile(const wxString& filename, wxResourceTable *table = (wxResourceTable *) NULL);
|
||||||
WXDLLEXPORT extern bool wxResourceParseString(char* s, wxResourceTable *table = (wxResourceTable *) NULL);
|
WXDLLEXPORT extern bool wxResourceParseString(char* s, wxResourceTable *table = (wxResourceTable *) NULL);
|
||||||
|
WXDLLEXPORT extern bool wxResourceParseString(const wxString& s, wxResourceTable *table = (wxResourceTable *) NULL);
|
||||||
WXDLLEXPORT extern void wxResourceClear(wxResourceTable *table = (wxResourceTable *) NULL);
|
WXDLLEXPORT extern void wxResourceClear(wxResourceTable *table = (wxResourceTable *) NULL);
|
||||||
// Register XBM/XPM data
|
// Register XBM/XPM data
|
||||||
WXDLLEXPORT extern bool wxResourceRegisterBitmapData(const wxString& name, char bits[], int width, int height, wxResourceTable *table = (wxResourceTable *) NULL);
|
WXDLLEXPORT extern bool wxResourceRegisterBitmapData(const wxString& name, char bits[], int width, int height, wxResourceTable *table = (wxResourceTable *) NULL);
|
||||||
|
@@ -82,7 +82,7 @@ class WXDLLEXPORT wxExpr
|
|||||||
|
|
||||||
wxExpr(wxExprType the_type, wxChar *word_or_string, bool allocate);
|
wxExpr(wxExprType the_type, wxChar *word_or_string, bool allocate);
|
||||||
wxExpr(const wxString& functor); // Assume this is a new clause - pass functor
|
wxExpr(const wxString& functor); // Assume this is a new clause - pass functor
|
||||||
wxExpr(wxExprType the_type, const wxString& word_or_string = "");
|
wxExpr(wxExprType the_type, const wxString& word_or_string = wxT(""));
|
||||||
wxExpr(long the_integer);
|
wxExpr(long the_integer);
|
||||||
wxExpr(double the_real);
|
wxExpr(double the_real);
|
||||||
wxExpr(wxList *the_list);
|
wxExpr(wxList *the_list);
|
||||||
@@ -246,7 +246,10 @@ public:
|
|||||||
|
|
||||||
// Compatibility
|
// Compatibility
|
||||||
inline bool ReadProlog(wxChar *filename) { return Read(wxString(filename)); }
|
inline bool ReadProlog(wxChar *filename) { return Read(wxString(filename)); }
|
||||||
inline bool ReadPrologFromString(char *buffer) { return ReadFromString(wxString(buffer)); }
|
inline bool ReadPrologFromString(char *buffer)
|
||||||
|
{
|
||||||
|
return ReadFromString(wxString(buffer, wxConvLibc));
|
||||||
|
}
|
||||||
inline void WriteProlog(FILE* stream) { Write(stream); }
|
inline void WriteProlog(FILE* stream) { Write(stream); }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
@@ -29,7 +29,7 @@
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if wxUSE_UNICODE
|
#if wxUSE_UNICODE
|
||||||
#error "This sample can't be compiled in Unicode mode."
|
// #error "This sample can't be compiled in Unicode mode."
|
||||||
#endif // wxUSE_UNICODE
|
#endif // wxUSE_UNICODE
|
||||||
|
|
||||||
#include "wx/resource.h"
|
#include "wx/resource.h"
|
||||||
@@ -56,7 +56,7 @@
|
|||||||
// the TEXT resource, for some reason, so either run-time file loading
|
// the TEXT resource, for some reason, so either run-time file loading
|
||||||
// or file inclusion should be used.
|
// or file inclusion should be used.
|
||||||
|
|
||||||
#if defined(__WXMSW__)
|
#if defined(__WXMSW__) && !wxUSE_UNICODE
|
||||||
// Under Windows, some compilers can't include
|
// Under Windows, some compilers can't include
|
||||||
// a whole .wxr file. So we use a .rc user-defined resource
|
// a whole .wxr file. So we use a .rc user-defined resource
|
||||||
// instead. dialog1 will point to the whole .wxr 'file'.
|
// instead. dialog1 will point to the whole .wxr 'file'.
|
||||||
@@ -83,8 +83,9 @@ MyApp::MyApp()
|
|||||||
// main frame
|
// main frame
|
||||||
bool MyApp::OnInit(void)
|
bool MyApp::OnInit(void)
|
||||||
{
|
{
|
||||||
#if defined(__WXMSW__)
|
#if defined(__WXMSW__) && !wxUSE_UNICODE
|
||||||
// Load the .wxr 'file' from a .rc resource, under Windows.
|
// Load the .wxr 'file' from a .rc resource, under Windows.
|
||||||
|
// note that the resource really is a char*, not a wxChar*!
|
||||||
dialog1 = wxLoadUserResource(wxT("dialog1"), wxT("WXRDATA"));
|
dialog1 = wxLoadUserResource(wxT("dialog1"), wxT("WXRDATA"));
|
||||||
menu1 = wxLoadUserResource(wxT("menu1"), wxT("WXRDATA"));
|
menu1 = wxLoadUserResource(wxT("menu1"), wxT("WXRDATA"));
|
||||||
// All resources in the file (only one in this case) get parsed
|
// All resources in the file (only one in this case) get parsed
|
||||||
@@ -101,20 +102,20 @@ bool MyApp::OnInit(void)
|
|||||||
|
|
||||||
// Create the main frame window
|
// Create the main frame window
|
||||||
frame = new MyFrame( (wxFrame *) NULL, -1,
|
frame = new MyFrame( (wxFrame *) NULL, -1,
|
||||||
(char *) "wxWindows Resource Sample",
|
wxT("wxWindows Resource Sample"),
|
||||||
wxPoint(-1, -1), wxSize(300, 250) );
|
wxPoint(-1, -1), wxSize(300, 250) );
|
||||||
|
|
||||||
// Give it a status line
|
// Give it a status line
|
||||||
frame->CreateStatusBar(2);
|
frame->CreateStatusBar(2);
|
||||||
|
|
||||||
wxMenuBar *menu_bar = wxResourceCreateMenuBar("menu1");
|
wxMenuBar *menu_bar = wxResourceCreateMenuBar(wxT("menu1"));
|
||||||
|
|
||||||
// Associate the menu bar with the frame
|
// Associate the menu bar with the frame
|
||||||
frame->SetMenuBar(menu_bar);
|
frame->SetMenuBar(menu_bar);
|
||||||
|
|
||||||
// Make a panel
|
// Make a panel
|
||||||
frame->panel = new MyPanel( frame, -1, wxPoint(0, 0), wxSize(400, 400),
|
frame->panel = new MyPanel( frame, -1, wxPoint(0, 0), wxSize(400, 400),
|
||||||
0, "MyMainFrame" );
|
0, wxT("MyMainFrame") );
|
||||||
frame->Show(TRUE);
|
frame->Show(TRUE);
|
||||||
|
|
||||||
SetTopWindow(frame);
|
SetTopWindow(frame);
|
||||||
@@ -124,7 +125,7 @@ bool MyApp::OnInit(void)
|
|||||||
|
|
||||||
MyApp::~MyApp()
|
MyApp::~MyApp()
|
||||||
{
|
{
|
||||||
#if defined(__WXMSW__)
|
#if defined(__WXMSW__) && !wxUSE_UNICODE
|
||||||
delete dialog1;
|
delete dialog1;
|
||||||
delete menu1;
|
delete menu1;
|
||||||
#endif
|
#endif
|
||||||
@@ -169,8 +170,8 @@ MyFrame::MyFrame
|
|||||||
|
|
||||||
void MyFrame::OnAbout( wxCommandEvent& WXUNUSED(event) )
|
void MyFrame::OnAbout( wxCommandEvent& WXUNUSED(event) )
|
||||||
{
|
{
|
||||||
wxMessageBox("wxWindows resource sample.\n"
|
wxMessageBox(wxT("wxWindows resource sample.\n")
|
||||||
"(c) Julian Smart", "About wxWindows sample",
|
wxT("(c) Julian Smart"), wxT("About wxWindows sample"),
|
||||||
wxICON_INFORMATION | wxOK);
|
wxICON_INFORMATION | wxOK);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -183,12 +184,12 @@ void MyFrame::OnTestDialog(wxCommandEvent& WXUNUSED(event) )
|
|||||||
{
|
{
|
||||||
MyDialog *dialog = new MyDialog;
|
MyDialog *dialog = new MyDialog;
|
||||||
|
|
||||||
if (dialog->LoadFromResource(this, "dialog1"))
|
if (dialog->LoadFromResource(this, wxT("dialog1")))
|
||||||
{
|
{
|
||||||
wxTextCtrl *text = (wxTextCtrl *)wxFindWindowByName("multitext3", dialog);
|
wxTextCtrl *text = (wxTextCtrl *)wxFindWindowByName(wxT("multitext3"), dialog);
|
||||||
if (text)
|
if (text)
|
||||||
{
|
{
|
||||||
text->SetValue("wxWindows resource demo");
|
text->SetValue(wxT("wxWindows resource demo"));
|
||||||
}
|
}
|
||||||
|
|
||||||
dialog->ShowModal();
|
dialog->ShowModal();
|
||||||
|
@@ -119,23 +119,25 @@ void wxCleanUpResourceSystem()
|
|||||||
delete[] wxResourceBuffer;
|
delete[] wxResourceBuffer;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if 0
|
||||||
void wxLogWarning(char *msg)
|
void wxLogWarning(char *msg)
|
||||||
{
|
{
|
||||||
wxMessageBox(msg, _("Warning"), wxOK);
|
wxMessageBox(msg, _("Warning"), wxOK);
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
IMPLEMENT_DYNAMIC_CLASS(wxItemResource, wxObject)
|
IMPLEMENT_DYNAMIC_CLASS(wxItemResource, wxObject)
|
||||||
IMPLEMENT_DYNAMIC_CLASS(wxResourceTable, wxHashTable)
|
IMPLEMENT_DYNAMIC_CLASS(wxResourceTable, wxHashTable)
|
||||||
|
|
||||||
wxItemResource::wxItemResource()
|
wxItemResource::wxItemResource()
|
||||||
{
|
{
|
||||||
m_itemType = "";
|
m_itemType = wxT("");
|
||||||
m_title = "";
|
m_title = wxT("");
|
||||||
m_name = "";
|
m_name = wxT("");
|
||||||
m_windowStyle = 0;
|
m_windowStyle = 0;
|
||||||
m_x = m_y = m_width = m_height = 0;
|
m_x = m_y = m_width = m_height = 0;
|
||||||
m_value1 = m_value2 = m_value3 = m_value5 = 0;
|
m_value1 = m_value2 = m_value3 = m_value5 = 0;
|
||||||
m_value4 = "";
|
m_value4 = wxT("");
|
||||||
m_windowId = 0;
|
m_windowId = 0;
|
||||||
m_exStyle = 0;
|
m_exStyle = 0;
|
||||||
}
|
}
|
||||||
@@ -230,7 +232,7 @@ bool wxResourceTable::ParseResourceFile(const wxString& filename)
|
|||||||
{
|
{
|
||||||
wxExprDatabase db;
|
wxExprDatabase db;
|
||||||
|
|
||||||
FILE *fd = wxFopen(filename, _T("r"));
|
FILE *fd = wxFopen(filename, wxT("r"));
|
||||||
if (!fd)
|
if (!fd)
|
||||||
return FALSE;
|
return FALSE;
|
||||||
bool eof = FALSE;
|
bool eof = FALSE;
|
||||||
@@ -341,7 +343,7 @@ wxControl *wxResourceTable::CreateItem(wxWindow *parent, const wxItemResource* c
|
|||||||
//
|
//
|
||||||
bitmap.LoadFile(wxCROSS_BITMAP, wxBITMAP_TYPE_BMP_RESOURCE);
|
bitmap.LoadFile(wxCROSS_BITMAP, wxBITMAP_TYPE_BMP_RESOURCE);
|
||||||
#else
|
#else
|
||||||
bitmap.LoadFile("cross_bmp", wxBITMAP_TYPE_BMP_RESOURCE);
|
bitmap.LoadFile(wxT("cross_bmp"), wxBITMAP_TYPE_BMP_RESOURCE);
|
||||||
#endif
|
#endif
|
||||||
control = new wxBitmapButton(parent, id, bitmap, pos, size,
|
control = new wxBitmapButton(parent, id, bitmap, pos, size,
|
||||||
childResource->GetStyle() | wxBU_AUTODRAW, wxDefaultValidator, childResource->GetName());
|
childResource->GetStyle() | wxBU_AUTODRAW, wxDefaultValidator, childResource->GetName());
|
||||||
@@ -367,7 +369,7 @@ wxControl *wxResourceTable::CreateItem(wxWindow *parent, const wxItemResource* c
|
|||||||
#ifdef __WXMSW__
|
#ifdef __WXMSW__
|
||||||
// Use a default bitmap
|
// Use a default bitmap
|
||||||
if (!bitmap.Ok())
|
if (!bitmap.Ok())
|
||||||
bitmap.LoadFile("cross_bmp", wxBITMAP_TYPE_BMP_RESOURCE);
|
bitmap.LoadFile(wxT("cross_bmp"), wxBITMAP_TYPE_BMP_RESOURCE);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (bitmap.Ok())
|
if (bitmap.Ok())
|
||||||
@@ -2735,6 +2737,15 @@ bool wxResourceParseData(const wxString& resource, wxResourceTable *table)
|
|||||||
return table->ParseResourceData(resource);
|
return table->ParseResourceData(resource);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool wxResourceParseData(const char* resource, wxResourceTable *table)
|
||||||
|
{
|
||||||
|
wxString str(resource, wxConvLibc);
|
||||||
|
if (!table)
|
||||||
|
table = wxDefaultResourceTable;
|
||||||
|
|
||||||
|
return table->ParseResourceData(str);
|
||||||
|
}
|
||||||
|
|
||||||
bool wxResourceParseFile(const wxString& filename, wxResourceTable *table)
|
bool wxResourceParseFile(const wxString& filename, wxResourceTable *table)
|
||||||
{
|
{
|
||||||
if (!table)
|
if (!table)
|
||||||
@@ -2798,7 +2809,7 @@ bool wxResourceParseIncludeFile(const wxString& f, wxResourceTable *table)
|
|||||||
if (!table)
|
if (!table)
|
||||||
table = wxDefaultResourceTable;
|
table = wxDefaultResourceTable;
|
||||||
|
|
||||||
FILE *fd = wxFopen(f, _T("r"));
|
FILE *fd = wxFopen(f, wxT("r"));
|
||||||
if (!fd)
|
if (!fd)
|
||||||
{
|
{
|
||||||
return FALSE;
|
return FALSE;
|
||||||
@@ -3100,6 +3111,15 @@ bool wxResourceReadOneResourceString(char *s, wxExprDatabase& db, bool *eof, wxR
|
|||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool wxResourceParseString(const wxString& s, wxResourceTable *table)
|
||||||
|
{
|
||||||
|
#if wxUSE_UNICODE
|
||||||
|
return wxResourceParseString( (char*)s.mb_str().data() );
|
||||||
|
#else
|
||||||
|
return wxResourceParseString( (char*)s.c_str() );
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
bool wxResourceParseString(char *s, wxResourceTable *table)
|
bool wxResourceParseString(char *s, wxResourceTable *table)
|
||||||
{
|
{
|
||||||
if (!table)
|
if (!table)
|
||||||
|
@@ -608,7 +608,7 @@ void wxExpr::AddAttributeValueStringList(const wxString& attribute, wxList *stri
|
|||||||
wxNode *node = string_list->First();
|
wxNode *node = string_list->First();
|
||||||
while (node)
|
while (node)
|
||||||
{
|
{
|
||||||
char *string = (char *)node->Data();
|
wxChar *string = (wxChar*)node->GetData();
|
||||||
wxExpr *expr = new wxExpr(wxExprString, wxString(string));
|
wxExpr *expr = new wxExpr(wxExprString, wxString(string));
|
||||||
listExpr->Append(expr);
|
listExpr->Append(expr);
|
||||||
node = node->Next();
|
node = node->Next();
|
||||||
@@ -920,7 +920,7 @@ wxExpr *wxExprDatabase::FindClause(long id) // Find a term based on an integer
|
|||||||
|
|
||||||
if (term->Type() == wxExprList)
|
if (term->Type() == wxExprList)
|
||||||
{
|
{
|
||||||
wxExpr *value = term->AttributeValue("id");
|
wxExpr *value = term->AttributeValue(wxT("id"));
|
||||||
if (value->Type() == wxExprInteger && value->IntegerValue() == id)
|
if (value->Type() == wxExprInteger && value->IntegerValue() == id)
|
||||||
found = term;
|
found = term;
|
||||||
}
|
}
|
||||||
@@ -1196,7 +1196,7 @@ char *wxmake_exp2(char *str1, char *str2, char *str3)
|
|||||||
|
|
||||||
char *wxmake_word(char *str)
|
char *wxmake_word(char *str)
|
||||||
{
|
{
|
||||||
wxExpr *x = new wxExpr(wxExprWord, str);
|
wxExpr *x = new wxExpr(wxExprWord, wxString(str, wxConvLibc).c_str());
|
||||||
return (char *)x;
|
return (char *)x;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user