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 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 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);
// Register XBM/XPM data
WXDLLEXPORT extern bool wxResourceRegisterBitmapData(const wxString& name, char bits[], int width, int height, wxResourceTable *table = (wxResourceTable *) NULL);
wxExpr(wxExprType the_type, wxChar *word_or_string, bool allocate);
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(double the_real);
wxExpr(wxList *the_list);
// Compatibility
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); }
private:
#endif
#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
#include "wx/resource.h"
// the TEXT resource, for some reason, so either run-time file loading
// or file inclusion should be used.
-#if defined(__WXMSW__)
+#if defined(__WXMSW__) && !wxUSE_UNICODE
// Under Windows, some compilers can't include
// a whole .wxr file. So we use a .rc user-defined resource
// instead. dialog1 will point to the whole .wxr 'file'.
// main frame
bool MyApp::OnInit(void)
{
-#if defined(__WXMSW__)
+#if defined(__WXMSW__) && !wxUSE_UNICODE
// 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"));
menu1 = wxLoadUserResource(wxT("menu1"), wxT("WXRDATA"));
// All resources in the file (only one in this case) get parsed
// Create the main frame window
frame = new MyFrame( (wxFrame *) NULL, -1,
- (char *) "wxWindows Resource Sample",
+ wxT("wxWindows Resource Sample"),
wxPoint(-1, -1), wxSize(300, 250) );
// Give it a status line
frame->CreateStatusBar(2);
- wxMenuBar *menu_bar = wxResourceCreateMenuBar("menu1");
+ wxMenuBar *menu_bar = wxResourceCreateMenuBar(wxT("menu1"));
// Associate the menu bar with the frame
frame->SetMenuBar(menu_bar);
// Make a panel
frame->panel = new MyPanel( frame, -1, wxPoint(0, 0), wxSize(400, 400),
- 0, "MyMainFrame" );
+ 0, wxT("MyMainFrame") );
frame->Show(TRUE);
SetTopWindow(frame);
MyApp::~MyApp()
{
-#if defined(__WXMSW__)
+#if defined(__WXMSW__) && !wxUSE_UNICODE
delete dialog1;
delete menu1;
#endif
void MyFrame::OnAbout( wxCommandEvent& WXUNUSED(event) )
{
- wxMessageBox("wxWindows resource sample.\n"
- "(c) Julian Smart", "About wxWindows sample",
+ wxMessageBox(wxT("wxWindows resource sample.\n")
+ wxT("(c) Julian Smart"), wxT("About wxWindows sample"),
wxICON_INFORMATION | wxOK);
}
{
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)
{
- text->SetValue("wxWindows resource demo");
+ text->SetValue(wxT("wxWindows resource demo"));
}
dialog->ShowModal();
delete[] wxResourceBuffer;
}
+#if 0
void wxLogWarning(char *msg)
{
wxMessageBox(msg, _("Warning"), wxOK);
}
+#endif
IMPLEMENT_DYNAMIC_CLASS(wxItemResource, wxObject)
IMPLEMENT_DYNAMIC_CLASS(wxResourceTable, wxHashTable)
wxItemResource::wxItemResource()
{
- m_itemType = "";
- m_title = "";
- m_name = "";
+ m_itemType = wxT("");
+ m_title = wxT("");
+ m_name = wxT("");
m_windowStyle = 0;
m_x = m_y = m_width = m_height = 0;
m_value1 = m_value2 = m_value3 = m_value5 = 0;
- m_value4 = "";
+ m_value4 = wxT("");
m_windowId = 0;
m_exStyle = 0;
}
{
wxExprDatabase db;
- FILE *fd = wxFopen(filename, _T("r"));
+ FILE *fd = wxFopen(filename, wxT("r"));
if (!fd)
return FALSE;
bool eof = FALSE;
//
bitmap.LoadFile(wxCROSS_BITMAP, wxBITMAP_TYPE_BMP_RESOURCE);
#else
- bitmap.LoadFile("cross_bmp", wxBITMAP_TYPE_BMP_RESOURCE);
+ bitmap.LoadFile(wxT("cross_bmp"), wxBITMAP_TYPE_BMP_RESOURCE);
#endif
control = new wxBitmapButton(parent, id, bitmap, pos, size,
childResource->GetStyle() | wxBU_AUTODRAW, wxDefaultValidator, childResource->GetName());
#ifdef __WXMSW__
// Use a default bitmap
if (!bitmap.Ok())
- bitmap.LoadFile("cross_bmp", wxBITMAP_TYPE_BMP_RESOURCE);
+ bitmap.LoadFile(wxT("cross_bmp"), wxBITMAP_TYPE_BMP_RESOURCE);
#endif
if (bitmap.Ok())
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)
{
if (!table)
if (!table)
table = wxDefaultResourceTable;
- FILE *fd = wxFopen(f, _T("r"));
+ FILE *fd = wxFopen(f, wxT("r"));
if (!fd)
{
return FALSE;
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)
{
if (!table)
wxNode *node = string_list->First();
while (node)
{
- char *string = (char *)node->Data();
+ wxChar *string = (wxChar*)node->GetData();
wxExpr *expr = new wxExpr(wxExprString, wxString(string));
listExpr->Append(expr);
node = node->Next();
if (term->Type() == wxExprList)
{
- wxExpr *value = term->AttributeValue("id");
+ wxExpr *value = term->AttributeValue(wxT("id"));
if (value->Type() == wxExprInteger && value->IntegerValue() == id)
found = term;
}
char *wxmake_word(char *str)
{
- wxExpr *x = new wxExpr(wxExprWord, str);
+ wxExpr *x = new wxExpr(wxExprWord, wxString(str, wxConvLibc).c_str());
return (char *)x;
}