X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/e9c7dfb9b5ed703284c642709df3f62e36c33b89..03715438eb3d56600ab3cba83fd43bc145978a4b:/src/common/resource.cpp diff --git a/src/common/resource.cpp b/src/common/resource.cpp index 785d7b8014..2a8430f6b5 100644 --- a/src/common/resource.cpp +++ b/src/common/resource.cpp @@ -6,7 +6,7 @@ // Created: 04/01/98 // RCS-ID: $Id$ // Copyright: (c) Julian Smart and Markus Holzem -// Licence: wxWindows license +// Licence: wxWindows license ///////////////////////////////////////////////////////////////////////////// #ifdef __GNUG__ @@ -20,6 +20,12 @@ #pragma hdrstop #endif +#if wxUSE_WX_RESOURCES + +#ifdef __VISUALC__ + #pragma warning(disable:4706) // assignment within conditional expression +#endif // VC++ + #ifndef WX_PRECOMP #include "wx/defs.h" #include "wx/setup.h" @@ -31,30 +37,39 @@ #include "wx/menu.h" #include "wx/stattext.h" #include "wx/button.h" +#include "wx/bmpbuttn.h" #include "wx/radiobox.h" +#include "wx/radiobut.h" #include "wx/listbox.h" #include "wx/choice.h" #include "wx/checkbox.h" +#include "wx/settings.h" #include "wx/slider.h" #include "wx/statbox.h" -#if USE_GAUGE +#include "wx/statbmp.h" +#if wxUSE_GAUGE #include "wx/gauge.h" #endif #include "wx/textctrl.h" -#include "wx/msgbxdlg.h" +#include "wx/msgdlg.h" +#include "wx/intl.h" +#endif + +#if wxUSE_RADIOBUTTON +#include "wx/radiobut.h" #endif -#if USE_SCROLLBAR +#if wxUSE_SCROLLBAR #include "wx/scrolbar.h" #endif -#if USE_COMBOBOX +#if wxUSE_COMBOBOX #include "wx/combobox.h" #endif #include "wx/validate.h" -#if USE_WX_RESOURCES +#include "wx/log.h" #include #include @@ -65,41 +80,45 @@ #include "wx/string.h" #include "wx/wxexpr.h" +#include "wx/settings.h" + // Forward (private) declarations -bool wxResourceInterpretResources(wxResourceTable& table, PrologDatabase& db); -wxItemResource *wxResourceInterpretDialog(wxResourceTable& table, PrologExpr *expr, bool isPanel = FALSE); -wxItemResource *wxResourceInterpretControl(wxResourceTable& table, PrologExpr *expr); -wxItemResource *wxResourceInterpretMenu(wxResourceTable& table, PrologExpr *expr); -wxItemResource *wxResourceInterpretMenuBar(wxResourceTable& table, PrologExpr *expr); -wxItemResource *wxResourceInterpretString(wxResourceTable& table, PrologExpr *expr); -wxItemResource *wxResourceInterpretBitmap(wxResourceTable& table, PrologExpr *expr); -wxItemResource *wxResourceInterpretIcon(wxResourceTable& table, PrologExpr *expr); +bool wxResourceInterpretResources(wxResourceTable& table, wxExprDatabase& db); +wxItemResource *wxResourceInterpretDialog(wxResourceTable& table, wxExpr *expr, bool isPanel = FALSE); +wxItemResource *wxResourceInterpretControl(wxResourceTable& table, wxExpr *expr); +wxItemResource *wxResourceInterpretMenu(wxResourceTable& table, wxExpr *expr); +wxItemResource *wxResourceInterpretMenuBar(wxResourceTable& table, wxExpr *expr); +wxItemResource *wxResourceInterpretString(wxResourceTable& table, wxExpr *expr); +wxItemResource *wxResourceInterpretBitmap(wxResourceTable& table, wxExpr *expr); +wxItemResource *wxResourceInterpretIcon(wxResourceTable& table, wxExpr *expr); // Interpret list expression -wxFont *wxResourceInterpretFontSpec(PrologExpr *expr); +wxFont wxResourceInterpretFontSpec(wxExpr *expr); -bool wxResourceReadOneResource(FILE *fd, PrologDatabase& db, bool *eof, wxResourceTable *table = NULL); -bool wxResourceParseIncludeFile(char *f, wxResourceTable *table = NULL); +bool wxResourceReadOneResource(FILE *fd, wxExprDatabase& db, bool *eof, wxResourceTable *table = (wxResourceTable *) NULL); +bool wxResourceParseIncludeFile(const wxString& f, wxResourceTable *table = (wxResourceTable *) NULL); -wxResourceTable *wxDefaultResourceTable = NULL; +wxResourceTable *wxDefaultResourceTable = (wxResourceTable *) NULL; -static char *wxResourceBuffer = NULL; -static long wxResourceBufferSize = 0; -static long wxResourceBufferCount = 0; -static int wxResourceStringPtr = 0; +char *wxResourceBuffer = (char *) NULL; +long wxResourceBufferSize = 0; +long wxResourceBufferCount = 0; +int wxResourceStringPtr = 0; -void wxInitializeResourceSystem(void) +void wxInitializeResourceSystem() { wxDefaultResourceTable = new wxResourceTable; } -void wxCleanUpResourceSystem(void) +void wxCleanUpResourceSystem() { delete wxDefaultResourceTable; + if (wxResourceBuffer) + delete[] wxResourceBuffer; } -void wxWarning(char *msg) +void wxLogWarning(char *msg) { - wxMessageBox(msg, "Warning", wxOK); + wxMessageBox(msg, _("Warning"), wxOK); } #if !USE_SHARED_LIBRARY @@ -107,132 +126,57 @@ IMPLEMENT_DYNAMIC_CLASS(wxItemResource, wxObject) IMPLEMENT_DYNAMIC_CLASS(wxResourceTable, wxHashTable) #endif -wxItemResource::wxItemResource(void) +wxItemResource::wxItemResource() { - itemType = NULL; - title = NULL; - name = NULL; - windowStyle = 0; - x = y = width = height = 0; - value1 = value2 = value3 = value5 = 0; - value4 = NULL; - stringValues = NULL; - bitmap = NULL; - backgroundColour = labelColour = buttonColour = NULL; - windowFont = NULL; + m_itemType = ""; + m_title = ""; + m_name = ""; + m_windowStyle = 0; + m_x = m_y = m_width = m_height = 0; + m_value1 = m_value2 = m_value3 = m_value5 = 0; + m_value4 = ""; m_windowId = 0; + m_exStyle = 0; } -wxItemResource::~wxItemResource(void) +wxItemResource::~wxItemResource() { - if (itemType) delete[] itemType; - if (title) delete[] title; - if (name) delete[] name; - if (value4) delete[] value4; - if (stringValues) - delete stringValues; - if (bitmap) - delete bitmap; - if (backgroundColour) - delete backgroundColour; - if (labelColour) - delete labelColour; - if (buttonColour) - delete buttonColour; - wxNode *node = children.First(); + wxNode *node = m_children.First(); while (node) { wxItemResource *item = (wxItemResource *)node->Data(); delete item; delete node; - node = children.First(); + node = m_children.First(); } } -void wxItemResource::SetTitle(char *t) -{ - if (t == title) - return; - - if (title) delete[] title; - if (t) - title = copystring(t); - else - title = NULL; -} - -void wxItemResource::SetType(char *t) -{ - if (itemType == t) - return; - - if (itemType) delete[] itemType; - if (t) - itemType = copystring(t); - else - itemType = NULL; -} - -void wxItemResource::SetName(char *n) -{ - if (n == name) - return; - - if (name) delete[] name; - if (n) - name = copystring(n); - else - name = NULL; -} - -void wxItemResource::SetStringValues(wxStringList *svalues) -{ - if (stringValues) - delete stringValues; - if (svalues) - stringValues = svalues; - else - stringValues = NULL; -} - -void wxItemResource::SetValue4(char *v) -{ - if (value4 == v) - return; - - if (value4) delete[] value4; - if (v) - value4 = copystring(v); - else - value4 = NULL; -} - /* * Resource table */ - -wxResourceTable::wxResourceTable(void):wxHashTable(wxKEY_STRING), identifiers(wxKEY_STRING) + +wxResourceTable::wxResourceTable():wxHashTable(wxKEY_STRING), identifiers(wxKEY_STRING) { } -wxResourceTable::~wxResourceTable(void) +wxResourceTable::~wxResourceTable() { ClearTable(); } - + wxItemResource *wxResourceTable::FindResource(const wxString& name) const { - wxItemResource *item = (wxItemResource *)Get((char *)(const char *)name); + wxItemResource *item = (wxItemResource *)Get(WXSTRINGCAST name); return item; } void wxResourceTable::AddResource(wxItemResource *item) { - char *name = item->GetName(); - if (!name) + wxString name = item->GetName(); + if (name == _T("")) name = item->GetTitle(); - if (!name) - name = "no name"; + if (name == _T("")) + name = _T("no name"); // Delete existing resource, if any. Delete(name); @@ -242,13 +186,13 @@ void wxResourceTable::AddResource(wxItemResource *item) bool wxResourceTable::DeleteResource(const wxString& name) { - wxItemResource *item = (wxItemResource *)Delete((char *)(const char *)name); + wxItemResource *item = (wxItemResource *)Delete(WXSTRINGCAST name); if (item) { // See if any resource has this as its child; if so, delete from // parent's child list. BeginFind(); - wxNode *node = NULL; + wxNode *node = (wxNode *) NULL; while ((node = Next())) { wxItemResource *parent = (wxItemResource *)node->Data(); @@ -258,7 +202,7 @@ bool wxResourceTable::DeleteResource(const wxString& name) break; } } - + delete item; return TRUE; } @@ -266,11 +210,11 @@ bool wxResourceTable::DeleteResource(const wxString& name) return FALSE; } -bool wxResourceTable::ParseResourceFile(char *filename) +bool wxResourceTable::ParseResourceFile(const wxString& filename) { - PrologDatabase db; + wxExprDatabase db; - FILE *fd = fopen(filename, "r"); + FILE *fd = fopen(filename.fn_str(), "r"); if (!fd) return FALSE; bool eof = FALSE; @@ -282,24 +226,24 @@ bool wxResourceTable::ParseResourceFile(char *filename) return wxResourceInterpretResources(*this, db); } -bool wxResourceTable::ParseResourceData(char *data) +bool wxResourceTable::ParseResourceData(const wxString& data) { - PrologDatabase db; - if (!db.ReadPrologFromString(data)) + wxExprDatabase db; + if (!db.ReadFromString(data)) { - wxWarning("Ill-formed resource file syntax."); + wxLogWarning(_("Ill-formed resource file syntax.")); return FALSE; } return wxResourceInterpretResources(*this, db); } -bool wxResourceTable::RegisterResourceBitmapData(char *name, char bits[], int width, int height) +bool wxResourceTable::RegisterResourceBitmapData(const wxString& name, char bits[], int width, int height) { // Register pre-loaded bitmap data wxItemResource *item = new wxItemResource; // item->SetType(wxRESOURCE_TYPE_XBM_DATA); - item->SetType("wxXBMData"); + item->SetType(_T("wxXBMData")); item->SetName(name); item->SetValue1((long)bits); item->SetValue2((long)width); @@ -308,24 +252,24 @@ bool wxResourceTable::RegisterResourceBitmapData(char *name, char bits[], int wi return TRUE; } -bool wxResourceTable::RegisterResourceBitmapData(char *name, char **data) +bool wxResourceTable::RegisterResourceBitmapData(const wxString& name, char **data) { // Register pre-loaded bitmap data wxItemResource *item = new wxItemResource; // item->SetType(wxRESOURCE_TYPE_XPM_DATA); - item->SetType("wxXPMData"); + item->SetType(_T("wxXPMData")); item->SetName(name); item->SetValue1((long)data); AddResource(item); return TRUE; } -bool wxResourceTable::SaveResource(char *WXUNUSED(filename)) +bool wxResourceTable::SaveResource(const wxString& WXUNUSED(filename)) { return FALSE; } -void wxResourceTable::ClearTable(void) +void wxResourceTable::ClearTable() { BeginFind(); wxNode *node = Next(); @@ -339,240 +283,239 @@ void wxResourceTable::ClearTable(void) } } -wxControl *wxResourceTable::CreateItem(wxWindow *parent, wxItemResource *childResource) const +wxControl *wxResourceTable::CreateItem(wxWindow *parent, const wxItemResource* childResource, const wxItemResource* parentResource) const { int id = childResource->GetId(); if ( id == 0 ) - id = -1; + id = -1; - wxControl *control = NULL; + bool dlgUnits = ((parentResource->GetResourceStyle() & wxRESOURCE_DIALOG_UNITS) != 0); + + wxControl *control = (wxControl *) NULL; wxString itemType(childResource->GetType()); - if (itemType == wxString("wxButton") || itemType == wxString("wxBitmapButton")) + + wxPoint pos; + wxSize size; + if (dlgUnits) + { + pos = parent->ConvertDialogToPixels(wxPoint(childResource->GetX(), childResource->GetY())); + size = parent->ConvertDialogToPixels(wxSize(childResource->GetWidth(), childResource->GetHeight())); + } + else + { + pos = wxPoint(childResource->GetX(), childResource->GetY()); + size = wxSize(childResource->GetWidth(), childResource->GetHeight()); + } + + if (itemType == wxString(_T("wxButton")) || itemType == wxString(_T("wxBitmapButton"))) { - if (childResource->GetValue4()) + if (childResource->GetValue4() != _T("")) { // Bitmap button - wxBitmap *bitmap = childResource->GetBitmap(); - if (!bitmap) + wxBitmap bitmap = childResource->GetBitmap(); + if (!bitmap.Ok()) { bitmap = wxResourceCreateBitmap(childResource->GetValue4(), (wxResourceTable *)this); - childResource->SetBitmap(bitmap); + ((wxItemResource*) childResource)->SetBitmap(bitmap); } - if (bitmap) - control = new wxBitmapButton(parent, id, *bitmap, - wxPoint(childResource->GetX(), childResource->GetY()), - wxSize(childResource->GetWidth(), childResource->GetHeight()), - childResource->GetStyle(), wxDefaultValidator, childResource->GetName()); + if (bitmap.Ok()) + control = new wxBitmapButton(parent, id, bitmap, pos, size, + childResource->GetStyle(), wxDefaultValidator, childResource->GetName()); } else // Normal, text button - control = new wxButton(parent, id, childResource->GetTitle(), - wxPoint(childResource->GetX(), childResource->GetY()), - wxSize(childResource->GetWidth(), childResource->GetHeight()), + control = new wxButton(parent, id, childResource->GetTitle(), pos, size, childResource->GetStyle(), wxDefaultValidator, childResource->GetName()); } - else if (itemType == wxString("wxMessage") || itemType == wxString("wxStaticText") || - itemType == wxString("wxStaticBitmap")) + else if (itemType == wxString(_T("wxMessage")) || itemType == wxString(_T("wxStaticText")) || + itemType == wxString(_T("wxStaticBitmap"))) { - if (childResource->GetValue4()) + if (childResource->GetValue4() != _T("")) { // Bitmap message - wxBitmap *bitmap = childResource->GetBitmap(); - if (!bitmap) + wxBitmap bitmap = childResource->GetBitmap(); + if (!bitmap.Ok()) { bitmap = wxResourceCreateBitmap(childResource->GetValue4(), (wxResourceTable *)this); - childResource->SetBitmap(bitmap); + ((wxItemResource*) childResource)->SetBitmap(bitmap); } -#if USE_BITMAP_MESSAGE - if (bitmap) - control = new wxStaticBitmap(parent, id, *bitmap, - wxPoint(childResource->GetX(), childResource->GetY()), - wxSize(childResource->GetWidth(), childResource->GetHeight()), +#if wxUSE_BITMAP_MESSAGE + if (bitmap.Ok()) + control = new wxStaticBitmap(parent, id, bitmap, pos, size, childResource->GetStyle(), childResource->GetName()); #endif } else { - control = new wxStaticText(parent, id, childResource->GetTitle(), - wxPoint(childResource->GetX(), childResource->GetY()), - wxSize(childResource->GetWidth(), childResource->GetHeight()), + control = new wxStaticText(parent, id, childResource->GetTitle(), pos, size, childResource->GetStyle(), childResource->GetName()); } } - else if (itemType == wxString("wxText") || itemType == wxString("wxTextCtrl") || itemType == wxString("wxMultiText")) + else if (itemType == wxString(_T("wxText")) || itemType == wxString(_T("wxTextCtrl")) || itemType == wxString(_T("wxMultiText"))) { - control = new wxTextCtrl(parent, id, childResource->GetValue4(), - wxPoint(childResource->GetX(), childResource->GetY()), - wxSize(childResource->GetWidth(), childResource->GetHeight()), + control = new wxTextCtrl(parent, id, childResource->GetValue4(), pos, size, childResource->GetStyle(), wxDefaultValidator, childResource->GetName()); } - else if (itemType == wxString("wxCheckBox")) + else if (itemType == wxString(_T("wxCheckBox"))) { - control = new wxCheckBox(parent, id, childResource->GetTitle(), - wxPoint(childResource->GetX(), childResource->GetY()), - wxSize(childResource->GetWidth(), childResource->GetHeight()), + control = new wxCheckBox(parent, id, childResource->GetTitle(), pos, size, childResource->GetStyle(), wxDefaultValidator, childResource->GetName()); ((wxCheckBox *)control)->SetValue((childResource->GetValue1() != 0)); } -#if USE_GAUGE - else if (itemType == wxString("wxGauge")) +#if wxUSE_GAUGE + else if (itemType == wxString(_T("wxGauge"))) { - control = new wxGauge(parent, id, (int)childResource->GetValue2(), - wxPoint(childResource->GetX(), childResource->GetY()), - wxSize(childResource->GetWidth(), childResource->GetHeight()), + control = new wxGauge(parent, id, (int)childResource->GetValue2(), pos, size, childResource->GetStyle(), wxDefaultValidator, childResource->GetName()); ((wxGauge *)control)->SetValue((int)childResource->GetValue1()); } #endif -#if USE_RADIOBUTTON - else if (itemType == wxString("wxRadioButton")) +#if wxUSE_RADIOBUTTON + else if (itemType == wxString(_T("wxRadioButton"))) { control = new wxRadioButton(parent, id, childResource->GetTitle(), // (int)childResource->GetValue1(), - wxPoint(childResource->GetX(), childResource->GetY()), - wxSize(childResource->GetWidth(), childResource->GetHeight()), + pos, size, childResource->GetStyle(), wxDefaultValidator, childResource->GetName()); } #endif -#if USE_SCROLLBAR - else if (itemType == wxString("wxScrollBar")) +#if wxUSE_SCROLLBAR + else if (itemType == wxString(_T("wxScrollBar"))) { - control = new wxScrollBar(parent, id, - wxPoint(childResource->GetX(), childResource->GetY()), - wxSize(childResource->GetWidth(), childResource->GetHeight()), + control = new wxScrollBar(parent, id, pos, size, childResource->GetStyle(), wxDefaultValidator, childResource->GetName()); +/* ((wxScrollBar *)control)->SetValue((int)childResource->GetValue1()); ((wxScrollBar *)control)->SetPageSize((int)childResource->GetValue2()); ((wxScrollBar *)control)->SetObjectLength((int)childResource->GetValue3()); ((wxScrollBar *)control)->SetViewLength((int)(long)childResource->GetValue5()); +*/ + ((wxScrollBar *)control)->SetScrollbar((int)childResource->GetValue1(),(int)childResource->GetValue2(), + (int)childResource->GetValue3(),(int)(long)childResource->GetValue5(),FALSE); + } #endif - else if (itemType == wxString("wxSlider")) + else if (itemType == wxString(_T("wxSlider"))) { control = new wxSlider(parent, id, (int)childResource->GetValue1(), - (int)childResource->GetValue2(), (int)childResource->GetValue3(), - wxPoint(childResource->GetX(), childResource->GetY()), - wxSize(childResource->GetWidth(), childResource->GetHeight()), + (int)childResource->GetValue2(), (int)childResource->GetValue3(), pos, size, childResource->GetStyle(), wxDefaultValidator, childResource->GetName()); } - else if (itemType == wxString("wxGroupBox") || itemType == wxString("wxStaticBox")) + else if (itemType == wxString(_T("wxGroupBox")) || itemType == wxString(_T("wxStaticBox"))) { - control = new wxStaticBox(parent, id, childResource->GetTitle(), - wxPoint(childResource->GetX(), childResource->GetY()), - wxSize(childResource->GetWidth(), childResource->GetHeight()), + control = new wxStaticBox(parent, id, childResource->GetTitle(), pos, size, childResource->GetStyle(), childResource->GetName()); } - else if (itemType == wxString("wxListBox")) + else if (itemType == wxString(_T("wxListBox"))) { - wxStringList *stringList = childResource->GetStringValues(); - wxString *strings = NULL; + wxStringList& stringList = childResource->GetStringValues(); + wxString *strings = (wxString *) NULL; int noStrings = 0; - if (stringList && (stringList->Number() > 0)) + if (stringList.Number() > 0) { - noStrings = stringList->Number(); + noStrings = stringList.Number(); strings = new wxString[noStrings]; - wxNode *node = stringList->First(); + wxNode *node = stringList.First(); int i = 0; while (node) { - strings[i] = (char *)node->Data(); + strings[i] = (wxChar *)node->Data(); i ++; node = node->Next(); } } - control = new wxListBox(parent, id, - wxPoint(childResource->GetX(), childResource->GetY()), - wxSize(childResource->GetWidth(), childResource->GetHeight()), + control = new wxListBox(parent, id, pos, size, noStrings, strings, childResource->GetStyle(), wxDefaultValidator, childResource->GetName()); if (strings) delete[] strings; } - else if (itemType == wxString("wxChoice")) + else if (itemType == wxString(_T("wxChoice"))) { - wxStringList *stringList = childResource->GetStringValues(); - wxString *strings = NULL; + wxStringList& stringList = childResource->GetStringValues(); + wxString *strings = (wxString *) NULL; int noStrings = 0; - if (stringList && (stringList->Number() > 0)) + if (stringList.Number() > 0) { - noStrings = stringList->Number(); + noStrings = stringList.Number(); strings = new wxString[noStrings]; - wxNode *node = stringList->First(); + wxNode *node = stringList.First(); int i = 0; while (node) { - strings[i] = (char *)node->Data(); + strings[i] = (wxChar *)node->Data(); i ++; node = node->Next(); } } - control = new wxChoice(parent, id, - wxPoint(childResource->GetX(), childResource->GetY()), - wxSize(childResource->GetWidth(), childResource->GetHeight()), + control = new wxChoice(parent, id, pos, size, noStrings, strings, childResource->GetStyle(), wxDefaultValidator, childResource->GetName()); if (strings) delete[] strings; } -#if USE_COMBOBOX - else if (itemType == wxString("wxComboBox")) +#if wxUSE_COMBOBOX + else if (itemType == wxString(_T("wxComboBox"))) { - wxStringList *stringList = childResource->GetStringValues(); - wxString *strings = NULL; + wxStringList& stringList = childResource->GetStringValues(); + wxString *strings = (wxString *) NULL; int noStrings = 0; - if (stringList && (stringList->Number() > 0)) + if (stringList.Number() > 0) { - noStrings = stringList->Number(); + noStrings = stringList.Number(); strings = new wxString[noStrings]; - wxNode *node = stringList->First(); + wxNode *node = stringList.First(); int i = 0; while (node) { - strings[i] = (char *)node->Data(); + strings[i] = (wxChar *)node->Data(); i ++; node = node->Next(); } } - control = new wxComboBox(parent, id, childResource->GetValue4(), - wxPoint(childResource->GetX(), childResource->GetY()), - wxSize(childResource->GetWidth(), childResource->GetHeight()), + control = new wxComboBox(parent, id, childResource->GetValue4(), pos, size, noStrings, strings, childResource->GetStyle(), wxDefaultValidator, childResource->GetName()); if (strings) delete[] strings; } #endif - else if (itemType == wxString("wxRadioBox")) + else if (itemType == wxString(_T("wxRadioBox"))) { - wxStringList *stringList = childResource->GetStringValues(); - wxString *strings = NULL; + wxStringList& stringList = childResource->GetStringValues(); + wxString *strings = (wxString *) NULL; int noStrings = 0; - if (stringList && (stringList->Number() > 0)) + if (stringList.Number() > 0) { - noStrings = stringList->Number(); + noStrings = stringList.Number(); strings = new wxString[noStrings]; - wxNode *node = stringList->First(); + wxNode *node = stringList.First(); int i = 0; while (node) { - strings[i] = (char *)node->Data(); + strings[i] = (wxChar *)node->Data(); i ++; node = node->Next(); } } - control = new wxRadioBox(parent, (const wxWindowID) id, wxString(childResource->GetTitle()), - wxPoint(childResource->GetX(), childResource->GetY()), - wxSize(childResource->GetWidth(), childResource->GetHeight()), + control = new wxRadioBox(parent, (wxWindowID) id, wxString(childResource->GetTitle()), pos, size, noStrings, strings, (int)childResource->GetValue1(), childResource->GetStyle(), wxDefaultValidator, - childResource->GetName()); + childResource->GetName()); if (strings) delete[] strings; } - if (control && childResource->GetFont()) - control->SetFont(*childResource->GetFont()); + if ((parentResource->GetResourceStyle() & wxRESOURCE_USE_DEFAULTS) != 0) + { + // Don't set font; will be inherited from parent. + } + else + { + if (control && childResource->GetFont().Ok()) + control->SetFont(childResource->GetFont()); + } return control; } @@ -580,34 +523,34 @@ wxControl *wxResourceTable::CreateItem(wxWindow *parent, wxItemResource *childRe * Interpret database as a series of resources */ -bool wxResourceInterpretResources(wxResourceTable& table, PrologDatabase& db) +bool wxResourceInterpretResources(wxResourceTable& table, wxExprDatabase& db) { wxNode *node = db.First(); while (node) { - PrologExpr *clause = (PrologExpr *)node->Data(); - wxString functor(clause->Functor()); + wxExpr *clause = (wxExpr *)node->Data(); + wxString functor(clause->Functor()); - wxItemResource *item = NULL; - if (functor == "dialog") + wxItemResource *item = (wxItemResource *) NULL; + if (functor == _T("dialog")) item = wxResourceInterpretDialog(table, clause); - else if (functor == "panel") + else if (functor == _T("panel")) item = wxResourceInterpretDialog(table, clause, TRUE); - else if (functor == "menubar") + else if (functor == _T("menubar")) item = wxResourceInterpretMenuBar(table, clause); - else if (functor == "menu") + else if (functor == _T("menu")) item = wxResourceInterpretMenu(table, clause); - else if (functor == "string") + else if (functor == _T("string")) item = wxResourceInterpretString(table, clause); - else if (functor == "bitmap") + else if (functor == _T("bitmap")) item = wxResourceInterpretBitmap(table, clause); - else if (functor == "icon") + else if (functor == _T("icon")) item = wxResourceInterpretIcon(table, clause); if (item) { // Remove any existing resource of same name - if (item->GetName()) + if (item->GetName() != _T("")) table.DeleteResource(item->GetName()); table.AddResource(item); } @@ -616,115 +559,133 @@ bool wxResourceInterpretResources(wxResourceTable& table, PrologDatabase& db) return TRUE; } -static char *g_ValidControlClasses[] = { "wxButton", "wxBitmapButton", "wxMessage", - "wxStaticText", "wxStaticBitmap", "wxText", "wxTextCtrl", "wxMultiText", - "wxListBox", "wxRadioBox", "wxRadioButton", "wxCheckBox", "wxBitmapCheckBox", - "wxGroupBox", "wxStaticBox", "wxSlider", "wxGauge", "wxScrollBar", - "wxChoice", "wxComboBox" } ; -static int g_ValidControlClassesCount = sizeof(g_ValidControlClasses) / sizeof(char *) ; +static const wxChar *g_ValidControlClasses[] = +{ + _T("wxButton"), + _T("wxBitmapButton"), + _T("wxMessage"), + _T("wxStaticText"), + _T("wxStaticBitmap"), + _T("wxText"), + _T("wxTextCtrl"), + _T("wxMultiText"), + _T("wxListBox"), + _T("wxRadioBox"), + _T("wxRadioButton"), + _T("wxCheckBox"), + _T("wxBitmapCheckBox"), + _T("wxGroupBox"), + _T("wxStaticBox"), + _T("wxSlider"), + _T("wxGauge"), + _T("wxScrollBar"), + _T("wxChoice"), + _T("wxComboBox") +}; static bool wxIsValidControlClass(const wxString& c) { - int i; - for ( i = 0; i < g_ValidControlClassesCount; i++) - { - if ( c == g_ValidControlClasses[i] ) - return TRUE; - } - return FALSE; + for ( size_t i = 0; i < WXSIZEOF(g_ValidControlClasses); i++ ) + { + if ( c == g_ValidControlClasses[i] ) + return TRUE; + } + return FALSE; } -wxItemResource *wxResourceInterpretDialog(wxResourceTable& table, PrologExpr *expr, bool isPanel) +wxItemResource *wxResourceInterpretDialog(wxResourceTable& table, wxExpr *expr, bool isPanel) { wxItemResource *dialogItem = new wxItemResource; if (isPanel) - dialogItem->SetType("wxPanel"); + dialogItem->SetType(_T("wxPanel")); else - dialogItem->SetType("wxDialog"); - char *style = NULL; - char *title = NULL; - char *name = NULL; - char *backColourHex = NULL; - char *labelColourHex = NULL; - char *buttonColourHex = NULL; + dialogItem->SetType(_T("wxDialog")); + wxString style = _T(""); + wxString title = _T(""); + wxString name = _T(""); + wxString backColourHex = _T(""); + wxString labelColourHex = _T(""); + wxString buttonColourHex = _T(""); long windowStyle = wxDEFAULT_DIALOG_STYLE; if (isPanel) windowStyle = 0; - + int x = 0; int y = 0; int width = -1; int height = -1; int isModal = 0; - PrologExpr *labelFontExpr = NULL; - PrologExpr *buttonFontExpr = NULL; - PrologExpr *fontExpr = NULL; - expr->AssignAttributeValue("style", &style); - expr->AssignAttributeValue("name", &name); - expr->AssignAttributeValue("title", &title); - expr->AssignAttributeValue("x", &x); - expr->AssignAttributeValue("y", &y); - expr->AssignAttributeValue("width", &width); - expr->AssignAttributeValue("height", &height); - expr->AssignAttributeValue("modal", &isModal); - expr->AssignAttributeValue("label_font", &labelFontExpr); - expr->AssignAttributeValue("button_font", &buttonFontExpr); - expr->AssignAttributeValue("font", &fontExpr); - expr->AssignAttributeValue("background_colour", &backColourHex); - expr->AssignAttributeValue("label_colour", &labelColourHex); - expr->AssignAttributeValue("button_colour", &buttonColourHex); - - if (style) + wxExpr *labelFontExpr = (wxExpr *) NULL; + wxExpr *buttonFontExpr = (wxExpr *) NULL; + wxExpr *fontExpr = (wxExpr *) NULL; + expr->GetAttributeValue(_T("style"), style); + expr->GetAttributeValue(_T("name"), name); + expr->GetAttributeValue(_T("title"), title); + expr->GetAttributeValue(_T("x"), x); + expr->GetAttributeValue(_T("y"), y); + expr->GetAttributeValue(_T("width"), width); + expr->GetAttributeValue(_T("height"), height); + expr->GetAttributeValue(_T("modal"), isModal); + expr->GetAttributeValue(_T("label_font"), &labelFontExpr); + expr->GetAttributeValue(_T("button_font"), &buttonFontExpr); + expr->GetAttributeValue(_T("font"), &fontExpr); + expr->GetAttributeValue(_T("background_colour"), backColourHex); + expr->GetAttributeValue(_T("label_colour"), labelColourHex); + expr->GetAttributeValue(_T("button_colour"), buttonColourHex); + + int useDialogUnits = 0; + expr->GetAttributeValue(_T("use_dialog_units"), useDialogUnits); + if (useDialogUnits != 0) + dialogItem->SetResourceStyle(dialogItem->GetResourceStyle() | wxRESOURCE_DIALOG_UNITS); + + int useDefaults = 0; + expr->GetAttributeValue(_T("use_system_defaults"), useDefaults); + if (useDefaults != 0) + dialogItem->SetResourceStyle(dialogItem->GetResourceStyle() | wxRESOURCE_USE_DEFAULTS); + + long id = 0; + expr->GetAttributeValue(_T("id"), id); + dialogItem->SetId(id); + + if (style != _T("")) { windowStyle = wxParseWindowStyle(style); } dialogItem->SetStyle(windowStyle); dialogItem->SetValue1(isModal); - if (name) - dialogItem->SetName(name); - if (title) - dialogItem->SetTitle(title); + dialogItem->SetName(name); + dialogItem->SetTitle(title); dialogItem->SetSize(x, y, width, height); - - if (backColourHex) + + if (backColourHex != _T("")) { int r = 0; int g = 0; int b = 0; - r = wxHexToDec(backColourHex); - g = wxHexToDec(backColourHex+2); - b = wxHexToDec(backColourHex+4); - dialogItem->SetBackgroundColour(new wxColour((unsigned char)r,(unsigned char)g,(unsigned char)b)); - delete[] backColourHex; + r = wxHexToDec(backColourHex.Mid(0, 2)); + g = wxHexToDec(backColourHex.Mid(2, 2)); + b = wxHexToDec(backColourHex.Mid(4, 2)); + dialogItem->SetBackgroundColour(wxColour((unsigned char)r,(unsigned char)g,(unsigned char)b)); } - if (labelColourHex) + if (labelColourHex != _T("")) { int r = 0; int g = 0; int b = 0; - r = wxHexToDec(labelColourHex); - g = wxHexToDec(labelColourHex+2); - b = wxHexToDec(labelColourHex+4); - dialogItem->SetLabelColour(new wxColour((unsigned char)r,(unsigned char)g,(unsigned char)b)); - delete[] labelColourHex; + r = wxHexToDec(labelColourHex.Mid(0, 2)); + g = wxHexToDec(labelColourHex.Mid(2, 2)); + b = wxHexToDec(labelColourHex.Mid(4, 2)); + dialogItem->SetLabelColour(wxColour((unsigned char)r,(unsigned char)g,(unsigned char)b)); } - if (buttonColourHex) + if (buttonColourHex != _T("")) { int r = 0; int g = 0; int b = 0; - r = wxHexToDec(buttonColourHex); - g = wxHexToDec(buttonColourHex+2); - b = wxHexToDec(buttonColourHex+4); - dialogItem->SetButtonColour(new wxColour((unsigned char)r,(unsigned char)g,(unsigned char)b)); - delete[] buttonColourHex; + r = wxHexToDec(buttonColourHex.Mid(0, 2)); + g = wxHexToDec(buttonColourHex.Mid(2, 2)); + b = wxHexToDec(buttonColourHex.Mid(4, 2)); + dialogItem->SetButtonColour(wxColour((unsigned char)r,(unsigned char)g,(unsigned char)b)); } - if (name) - delete[] name; - if (title) - delete[] title; - if (style) - delete[] style; - if (fontExpr) dialogItem->SetFont(wxResourceInterpretFontSpec(fontExpr)); else if (buttonFontExpr) @@ -733,16 +694,16 @@ wxItemResource *wxResourceInterpretDialog(wxResourceTable& table, PrologExpr *ex dialogItem->SetFont(wxResourceInterpretFontSpec(labelFontExpr)); // Now parse all controls - PrologExpr *controlExpr = expr->GetFirst(); + wxExpr *controlExpr = expr->GetFirst(); while (controlExpr) { if (controlExpr->Number() == 3) { wxString controlKeyword(controlExpr->Nth(1)->StringValue()); - if (controlKeyword != "" && controlKeyword == "control") + if (controlKeyword != _T("") && controlKeyword == _T("control")) { // The value part: always a list. - PrologExpr *listExpr = controlExpr->Nth(2); + wxExpr *listExpr = controlExpr->Nth(2); if (listExpr->Type() == PrologList) { wxItemResource *controlItem = wxResourceInterpretControl(table, listExpr); @@ -758,7 +719,7 @@ wxItemResource *wxResourceInterpretDialog(wxResourceTable& table, PrologExpr *ex return dialogItem; } -wxItemResource *wxResourceInterpretControl(wxResourceTable& table, PrologExpr *expr) +wxItemResource *wxResourceInterpretControl(wxResourceTable& table, wxExpr *expr) { wxItemResource *controlItem = new wxItemResource; @@ -774,54 +735,55 @@ wxItemResource *wxResourceInterpretControl(wxResourceTable& table, PrologExpr *e int x = 0; int y = 0; int width = -1; int height = -1; int count = 0; - PrologExpr *expr1 = expr->Nth(0); + wxExpr *expr1 = expr->Nth(0); if ( expr1->Type() == PrologString || expr1->Type() == PrologWord ) { - if ( wxIsValidControlClass(expr1->StringValue()) ) - { - count = 1; - controlType = expr1->StringValue(); - } - else - { - id = wxResourceGetIdentifier(WXSTRINGCAST expr1->StringValue(), &table); + if ( wxIsValidControlClass(expr1->StringValue()) ) + { + count = 1; + controlType = expr1->StringValue(); + } + else + { + wxString str(expr1->StringValue()); + id = wxResourceGetIdentifier(str, &table); if (id == 0) { - char buf[300]; - sprintf(buf, "Could not resolve control class or id '%s'. Use (non-zero) integer instead\n or provide #define (see manual for caveats)", - (const char*) expr1->StringValue()); - wxWarning(buf); - delete controlItem; - return NULL; + wxLogWarning(_("Could not resolve control class or id '%s'. " + "Use (non-zero) integer instead\n or provide #define " + "(see manual for caveats)"), + (const wxChar*) expr1->StringValue()); + delete controlItem; + return (wxItemResource *) NULL; } - else - { - // Success - we have an id, so the 2nd element must be the control class. - controlType = expr->Nth(1)->StringValue(); - count = 2; - } - } + else + { + // Success - we have an id, so the 2nd element must be the control class. + controlType = expr->Nth(1)->StringValue(); + count = 2; + } + } } else if (expr1->Type() == PrologInteger) { id = (int)expr1->IntegerValue(); - // Success - we have an id, so the 2nd element must be the control class. - controlType = expr->Nth(1)->StringValue(); - count = 2; + // Success - we have an id, so the 2nd element must be the control class. + controlType = expr->Nth(1)->StringValue(); + count = 2; } expr1 = expr->Nth(count); count ++; if ( expr1 ) - title = expr1->StringValue(); + title = expr1->StringValue(); expr1 = expr->Nth(count); count ++; if (expr1) { style = expr1->StringValue(); - windowStyle = wxParseWindowStyle(WXSTRINGCAST style); + windowStyle = wxParseWindowStyle(style); } expr1 = expr->Nth(count); @@ -850,343 +812,383 @@ wxItemResource *wxResourceInterpretControl(wxResourceTable& table, PrologExpr *e height = (int)expr1->IntegerValue(); controlItem->SetStyle(windowStyle); - controlItem->SetName(WXSTRINGCAST name); - controlItem->SetTitle(WXSTRINGCAST title); + controlItem->SetName(name); + controlItem->SetTitle(title); controlItem->SetSize(x, y, width, height); - controlItem->SetType(WXSTRINGCAST controlType); + controlItem->SetType(controlType); controlItem->SetId(id); - if (controlType == "wxButton") + if (controlType == _T("wxButton")) + { + // Check for bitmap resource name (in case loading old-style resource file) + if (expr->Nth(count) && ((expr->Nth(count)->Type() == PrologString) || (expr->Nth(count)->Type() == PrologWord))) + { + wxString str(expr->Nth(count)->StringValue()); + count ++; + + if (str != "") + { + controlItem->SetValue4(str); + controlItem->SetType(_T("wxBitmapButton")); + } + } + if (expr->Nth(count) && expr->Nth(count)->Type() == PrologList) + controlItem->SetFont(wxResourceInterpretFontSpec(expr->Nth(count))); + } + else if (controlType == _T("wxBitmapButton")) { // Check for bitmap resource name if (expr->Nth(count) && ((expr->Nth(count)->Type() == PrologString) || (expr->Nth(count)->Type() == PrologWord))) { - controlItem->SetValue4(WXSTRINGCAST expr->Nth(count)->StringValue()); - count ++; - if (expr->Nth(count) && expr->Nth(count)->Type() == PrologList) - controlItem->SetFont(wxResourceInterpretFontSpec(expr->Nth(count))); + wxString str(expr->Nth(count)->StringValue()); + controlItem->SetValue4(str); + count ++; + if (expr->Nth(count) && expr->Nth(count)->Type() == PrologList) + controlItem->SetFont(wxResourceInterpretFontSpec(expr->Nth(count))); } } - else if (controlType == "wxCheckBox") + else if (controlType == _T("wxCheckBox")) { // Check for default value if (expr->Nth(count) && (expr->Nth(count)->Type() == PrologInteger)) - { + { controlItem->SetValue1(expr->Nth(count)->IntegerValue()); - count ++; + count ++; if (expr->Nth(count) && expr->Nth(count)->Type() == PrologList) controlItem->SetFont(wxResourceInterpretFontSpec(expr->Nth(count))); } } -#if USE_RADIOBUTTON - else if (controlType == "wxRadioButton") +#if wxUSE_RADIOBUTTON + else if (controlType == _T("wxRadioButton")) { // Check for default value if (expr->Nth(count) && (expr->Nth(count)->Type() == PrologInteger)) - { + { controlItem->SetValue1(expr->Nth(count)->IntegerValue()); - count ++; + count ++; if (expr->Nth(count) && expr->Nth(count)->Type() == PrologList) controlItem->SetFont(wxResourceInterpretFontSpec(expr->Nth(count))); } } #endif - else if (controlType == "wxText" || controlType == "wxTextCtrl") + else if (controlType == _T("wxText") || controlType == _T("wxTextCtrl") || controlType == _T("wxMultiText")) { // Check for default value if (expr->Nth(count) && ((expr->Nth(count)->Type() == PrologString) || (expr->Nth(count)->Type() == PrologWord))) - { - controlItem->SetValue4(WXSTRINGCAST expr->Nth(count)->StringValue()); - count ++; + { + wxString str(expr->Nth(count)->StringValue()); + controlItem->SetValue4(str); + count ++; if (expr->Nth(count) && expr->Nth(count)->Type() == PrologList) - { + { // controlItem->SetLabelFont(wxResourceInterpretFontSpec(expr->Nth(count))); - // Do nothing - no label font any more - count ++; + // Do nothing - no label font any more + count ++; if (expr->Nth(count) && expr->Nth(count)->Type() == PrologList) controlItem->SetFont(wxResourceInterpretFontSpec(expr->Nth(count))); - } - } + } + } } - else if (controlType == "wxMessage" || controlType == "wxStaticText") + else if (controlType == _T("wxMessage") || controlType == _T("wxStaticText")) + { + // Check for bitmap resource name (in case it's an old-style .wxr file) + if (expr->Nth(count) && ((expr->Nth(count)->Type() == PrologString) || (expr->Nth(count)->Type() == PrologWord))) + { + wxString str(expr->Nth(count)->StringValue()); + controlItem->SetValue4(str); + count ++; + controlItem->SetType(_T("wxStaticText")); + } + if (expr->Nth(count) && expr->Nth(count)->Type() == PrologList) + controlItem->SetFont(wxResourceInterpretFontSpec(expr->Nth(count))); + } + else if (controlType == _T("wxStaticBitmap")) { // Check for bitmap resource name if (expr->Nth(count) && ((expr->Nth(count)->Type() == PrologString) || (expr->Nth(count)->Type() == PrologWord))) { - controlItem->SetValue4(WXSTRINGCAST expr->Nth(count)->StringValue()); + wxString str(expr->Nth(count)->StringValue()); + controlItem->SetValue4(str); count ++; - if (expr->Nth(count) && expr->Nth(count)->Type() == PrologList) - controlItem->SetFont(wxResourceInterpretFontSpec(expr->Nth(count))); } + if (expr->Nth(count) && expr->Nth(count)->Type() == PrologList) + controlItem->SetFont(wxResourceInterpretFontSpec(expr->Nth(count))); } - else if (controlType == "wxGroupBox" || controlType == "wxStaticBox") + else if (controlType == _T("wxGroupBox") || controlType == _T("wxStaticBox")) { if (expr->Nth(count) && expr->Nth(count)->Type() == PrologList) controlItem->SetFont(wxResourceInterpretFontSpec(expr->Nth(count))); } - else if (controlType == "wxGauge") + else if (controlType == _T("wxGauge")) { // Check for default value if (expr->Nth(count) && (expr->Nth(count)->Type() == PrologInteger)) - { + { controlItem->SetValue1(expr->Nth(count)->IntegerValue()); - count ++; + count ++; // Check for range if (expr->Nth(count) && (expr->Nth(count)->Type() == PrologInteger)) - { + { controlItem->SetValue2(expr->Nth(count)->IntegerValue()); - count ++; + count ++; if (expr->Nth(count) && expr->Nth(count)->Type() == PrologList) { - // controlItem->SetLabelFont(wxResourceInterpretFontSpec(expr->Nth(count))); - // Do nothing - count ++; + // controlItem->SetLabelFont(wxResourceInterpretFontSpec(expr->Nth(count))); + // Do nothing + count ++; if (expr->Nth(count) && expr->Nth(count)->Type() == PrologList) controlItem->SetFont(wxResourceInterpretFontSpec(expr->Nth(count))); - } - } - } + } + } + } } - else if (controlType == "wxSlider") + else if (controlType == _T("wxSlider")) { // Check for default value if (expr->Nth(count) && (expr->Nth(count)->Type() == PrologInteger)) - { + { controlItem->SetValue1(expr->Nth(count)->IntegerValue()); - count ++; + count ++; // Check for min if (expr->Nth(count) && (expr->Nth(count)->Type() == PrologInteger)) - { + { controlItem->SetValue2(expr->Nth(count)->IntegerValue()); - count ++; + count ++; // Check for max if (expr->Nth(count) && (expr->Nth(count)->Type() == PrologInteger)) - { + { controlItem->SetValue3(expr->Nth(count)->IntegerValue()); - count ++; + count ++; if (expr->Nth(count) && expr->Nth(count)->Type() == PrologList) - { + { // controlItem->SetLabelFont(wxResourceInterpretFontSpec(expr->Nth(count))); - // do nothing - count ++; + // do nothing + count ++; if (expr->Nth(count) && expr->Nth(count)->Type() == PrologList) controlItem->SetFont(wxResourceInterpretFontSpec(expr->Nth(count))); - } - } - } - } + } + } + } + } } - else if (controlType == "wxScrollBar") + else if (controlType == _T("wxScrollBar")) { // DEFAULT VALUE if (expr->Nth(count) && (expr->Nth(count)->Type() == PrologInteger)) - { + { controlItem->SetValue1(expr->Nth(count)->IntegerValue()); - count ++; + count ++; // PAGE LENGTH if (expr->Nth(count) && (expr->Nth(count)->Type() == PrologInteger)) - { + { controlItem->SetValue2(expr->Nth(count)->IntegerValue()); - count ++; + count ++; // OBJECT LENGTH if (expr->Nth(count) && (expr->Nth(count)->Type() == PrologInteger)) - { + { controlItem->SetValue3(expr->Nth(count)->IntegerValue()); - count ++; + count ++; // VIEW LENGTH if (expr->Nth(count) && (expr->Nth(count)->Type() == PrologInteger)) controlItem->SetValue5(expr->Nth(count)->IntegerValue()); - } - } - } + } + } + } } - else if (controlType == "wxListBox") + else if (controlType == _T("wxListBox")) { - PrologExpr *valueList = NULL; + wxExpr *valueList = (wxExpr *) NULL; if ((valueList = expr->Nth(count)) && (valueList->Type() == PrologList)) { - wxStringList *stringList = new wxStringList; - PrologExpr *stringExpr = valueList->GetFirst(); + wxStringList stringList; + wxExpr *stringExpr = valueList->GetFirst(); while (stringExpr) { - stringList->Add(stringExpr->StringValue()); + stringList.Add(stringExpr->StringValue()); stringExpr = stringExpr->GetNext(); } controlItem->SetStringValues(stringList); - count ++; - + count ++; +// This is now obsolete: it's in the window style. // Check for wxSINGLE/wxMULTIPLE - PrologExpr *mult = NULL; + wxExpr *mult = (wxExpr *) NULL; +/* controlItem->SetValue1(wxLB_SINGLE); +*/ if ((mult = expr->Nth(count)) && ((mult->Type() == PrologString)||(mult->Type() == PrologWord))) { +/* wxString m(mult->StringValue()); - if (m == "wxMULTIPLE") + if (m == "wxLB_MULTIPLE") controlItem->SetValue1(wxLB_MULTIPLE); - else if (m == "wxEXTENDED") + else if (m == "wxLB_EXTENDED") controlItem->SetValue1(wxLB_EXTENDED); - count ++; - if (expr->Nth(count) && expr->Nth(count)->Type() == PrologList) - { - // controlItem->SetLabelFont(wxResourceInterpretFontSpec(expr->Nth(count))); - count ++; - if (expr->Nth(count) && expr->Nth(count)->Type() == PrologList) - controlItem->SetFont(wxResourceInterpretFontSpec(expr->Nth(count))); - } - } - } +*/ + // Ignore the value + count ++; + } + if (expr->Nth(count) && expr->Nth(count)->Type() == PrologList) + { + // controlItem->SetLabelFont(wxResourceInterpretFontSpec(expr->Nth(count))); + count ++; + if (expr->Nth(count) && expr->Nth(count)->Type() == PrologList) + controlItem->SetFont(wxResourceInterpretFontSpec(expr->Nth(count))); + } + } } - else if (controlType == "wxChoice") + else if (controlType == _T("wxChoice")) { - PrologExpr *valueList = NULL; + wxExpr *valueList = (wxExpr *) NULL; // Check for default value list if ((valueList = expr->Nth(count)) && (valueList->Type() == PrologList)) { - wxStringList *stringList = new wxStringList; - PrologExpr *stringExpr = valueList->GetFirst(); + wxStringList stringList; + wxExpr *stringExpr = valueList->GetFirst(); while (stringExpr) { - stringList->Add(stringExpr->StringValue()); + stringList.Add(stringExpr->StringValue()); stringExpr = stringExpr->GetNext(); } controlItem->SetStringValues(stringList); - count ++; + count ++; if (expr->Nth(count) && expr->Nth(count)->Type() == PrologList) - { + { // controlItem->SetLabelFont(wxResourceInterpretFontSpec(expr->Nth(count))); - count ++; + count ++; if (expr->Nth(count) && expr->Nth(count)->Type() == PrologList) controlItem->SetFont(wxResourceInterpretFontSpec(expr->Nth(count))); - } - } + } + } } -#if USE_COMBOBOX - else if (controlType == "wxComboBox") +#if wxUSE_COMBOBOX + else if (controlType == _T("wxComboBox")) { - PrologExpr *textValue = expr->Nth(count); + wxExpr *textValue = expr->Nth(count); if (textValue && (textValue->Type() == PrologString || textValue->Type() == PrologWord)) - { - controlItem->SetValue4(WXSTRINGCAST textValue->StringValue()); + { + wxString str(textValue->StringValue()); + controlItem->SetValue4(str); - count ++; - - PrologExpr *valueList = NULL; + count ++; + + wxExpr *valueList = (wxExpr *) NULL; // Check for default value list if ((valueList = expr->Nth(count)) && (valueList->Type() == PrologList)) { - wxStringList *stringList = new wxStringList; - PrologExpr *stringExpr = valueList->GetFirst(); + wxStringList stringList; + wxExpr *stringExpr = valueList->GetFirst(); while (stringExpr) { - stringList->Add(stringExpr->StringValue()); + stringList.Add(stringExpr->StringValue()); stringExpr = stringExpr->GetNext(); } controlItem->SetStringValues(stringList); - count ++; + count ++; if (expr->Nth(count) && expr->Nth(count)->Type() == PrologList) - { + { // controlItem->SetLabelFont(wxResourceInterpretFontSpec(expr->Nth(count))); - count ++; + count ++; if (expr->Nth(count) && expr->Nth(count)->Type() == PrologList) controlItem->SetFont(wxResourceInterpretFontSpec(expr->Nth(count))); - } - } - } + } + } + } } #endif -#if 0 - else if (controlType == "wxRadioBox") +#if 1 + else if (controlType == _T("wxRadioBox")) { - PrologExpr *valueList = NULL; + wxExpr *valueList = (wxExpr *) NULL; // Check for default value list if ((valueList = expr->Nth(count)) && (valueList->Type() == PrologList)) { - wxStringList *stringList = new wxStringList; - PrologExpr *stringExpr = valueList->GetFirst(); + wxStringList stringList; + wxExpr *stringExpr = valueList->GetFirst(); while (stringExpr) { - stringList->Add(stringExpr->StringValue()); + stringList.Add(stringExpr->StringValue()); stringExpr = stringExpr->GetNext(); } controlItem->SetStringValues(stringList); - count ++; + count ++; // majorDim (number of rows or cols) if (expr->Nth(count) && (expr->Nth(count)->Type() == PrologInteger)) - { + { controlItem->SetValue1(expr->Nth(count)->IntegerValue()); - count ++; - } + count ++; + } else controlItem->SetValue1(0); if (expr->Nth(count) && expr->Nth(count)->Type() == PrologList) - { + { // controlItem->SetLabelFont(wxResourceInterpretFontSpec(expr->Nth(count))); - count ++; + count ++; if (expr->Nth(count) && expr->Nth(count)->Type() == PrologList) controlItem->SetFont(wxResourceInterpretFontSpec(expr->Nth(count))); - } - } + } + } } #endif else { delete controlItem; - return NULL; + return (wxItemResource *) NULL; } return controlItem; } -// Forward declaration -wxItemResource *wxResourceInterpretMenu1(wxResourceTable& table, PrologExpr *expr); +// Forward declaration +wxItemResource *wxResourceInterpretMenu1(wxResourceTable& table, wxExpr *expr); /* * Interpet a menu item */ -wxItemResource *wxResourceInterpretMenuItem(wxResourceTable& table, PrologExpr *expr) +wxItemResource *wxResourceInterpretMenuItem(wxResourceTable& table, wxExpr *expr) { wxItemResource *item = new wxItemResource; - - PrologExpr *labelExpr = expr->Nth(0); - PrologExpr *idExpr = expr->Nth(1); - PrologExpr *helpExpr = expr->Nth(2); - PrologExpr *checkableExpr = expr->Nth(3); + + wxExpr *labelExpr = expr->Nth(0); + wxExpr *idExpr = expr->Nth(1); + wxExpr *helpExpr = expr->Nth(2); + wxExpr *checkableExpr = expr->Nth(3); // Further keywords/attributes to follow sometime... if (expr->Number() == 0) { // item->SetType(wxRESOURCE_TYPE_SEPARATOR); - item->SetType("wxMenuSeparator"); + item->SetType(_T("wxMenuSeparator")); return item; } else { // item->SetType(wxTYPE_MENU); // Well, menu item, but doesn't matter. - item->SetType("wxMenu"); // Well, menu item, but doesn't matter. + item->SetType(_T("wxMenu")); // Well, menu item, but doesn't matter. if (labelExpr) { - item->SetTitle(WXSTRINGCAST labelExpr->StringValue()); + wxString str(labelExpr->StringValue()); + item->SetTitle(str); } if (idExpr) { @@ -1194,13 +1196,14 @@ wxItemResource *wxResourceInterpretMenuItem(wxResourceTable& table, PrologExpr * // If a string or word, must look up in identifier table. if ((idExpr->Type() == PrologString) || (idExpr->Type() == PrologWord)) { - id = wxResourceGetIdentifier(WXSTRINGCAST idExpr->StringValue(), &table); + wxString str(idExpr->StringValue()); + id = wxResourceGetIdentifier(str, &table); if (id == 0) { - char buf[300]; - sprintf(buf, "Could not resolve menu id '%s'. Use (non-zero) integer instead\n or provide #define (see manual for caveats)", - (const char*) idExpr->StringValue()); - wxWarning(buf); + wxLogWarning(_("Could not resolve menu id '%s'. " + "Use (non-zero) integer instead\n" + "or provide #define (see manual for caveats)"), + (const wxChar*) idExpr->StringValue()); } } else if (idExpr->Type() == PrologInteger) @@ -1209,16 +1212,17 @@ wxItemResource *wxResourceInterpretMenuItem(wxResourceTable& table, PrologExpr * } if (helpExpr) { - item->SetValue4(WXSTRINGCAST helpExpr->StringValue()); + wxString str(helpExpr->StringValue()); + item->SetValue4(str); } if (checkableExpr) item->SetValue2(checkableExpr->IntegerValue()); // Find the first expression that's a list, for submenu - PrologExpr *subMenuExpr = expr->GetFirst(); + wxExpr *subMenuExpr = expr->GetFirst(); while (subMenuExpr && (subMenuExpr->Type() != PrologList)) subMenuExpr = subMenuExpr->GetNext(); - + while (subMenuExpr) { wxItemResource *child = wxResourceInterpretMenuItem(table, subMenuExpr); @@ -1233,12 +1237,12 @@ wxItemResource *wxResourceInterpretMenuItem(wxResourceTable& table, PrologExpr * * Interpret a nested list as a menu */ /* -wxItemResource *wxResourceInterpretMenu1(wxResourceTable& table, PrologExpr *expr) +wxItemResource *wxResourceInterpretMenu1(wxResourceTable& table, wxExpr *expr) { wxItemResource *menu = new wxItemResource; // menu->SetType(wxTYPE_MENU); menu->SetType("wxMenu"); - PrologExpr *element = expr->GetFirst(); + wxExpr *element = expr->GetFirst(); while (element) { wxItemResource *item = wxResourceInterpretMenuItem(table, element); @@ -1250,41 +1254,39 @@ wxItemResource *wxResourceInterpretMenu1(wxResourceTable& table, PrologExpr *exp } */ -wxItemResource *wxResourceInterpretMenu(wxResourceTable& table, PrologExpr *expr) +wxItemResource *wxResourceInterpretMenu(wxResourceTable& table, wxExpr *expr) { - PrologExpr *listExpr = NULL; - expr->AssignAttributeValue("menu", &listExpr); + wxExpr *listExpr = (wxExpr *) NULL; + expr->GetAttributeValue(_T("menu"), &listExpr); if (!listExpr) - return NULL; - + return (wxItemResource *) NULL; + wxItemResource *menuResource = wxResourceInterpretMenuItem(table, listExpr); if (!menuResource) - return NULL; - - char *name = NULL; - expr->AssignAttributeValue("name", &name); - if (name) + return (wxItemResource *) NULL; + + wxString name; + if (expr->GetAttributeValue(_T("name"), name)) { menuResource->SetName(name); - delete[] name; } - + return menuResource; } -wxItemResource *wxResourceInterpretMenuBar(wxResourceTable& table, PrologExpr *expr) +wxItemResource *wxResourceInterpretMenuBar(wxResourceTable& table, wxExpr *expr) { - PrologExpr *listExpr = NULL; - expr->AssignAttributeValue("menu", &listExpr); + wxExpr *listExpr = (wxExpr *) NULL; + expr->GetAttributeValue(_T("menu"), &listExpr); if (!listExpr) - return NULL; + return (wxItemResource *) NULL; wxItemResource *resource = new wxItemResource; - resource->SetType("wxMenu"); + resource->SetType(_T("wxMenu")); // resource->SetType(wxTYPE_MENU); - - PrologExpr *element = listExpr->GetFirst(); + + wxExpr *element = listExpr->GetFirst(); while (element) { wxItemResource *menuResource = wxResourceInterpretMenuItem(table, listExpr); @@ -1292,74 +1294,74 @@ wxItemResource *wxResourceInterpretMenuBar(wxResourceTable& table, PrologExpr *e element = element->GetNext(); } - char *name = NULL; - expr->AssignAttributeValue("name", &name); - if (name) + wxString name; + if (expr->GetAttributeValue(_T("name"), name)) { resource->SetName(name); - delete[] name; } - + return resource; } -wxItemResource *wxResourceInterpretString(wxResourceTable& WXUNUSED(table), PrologExpr *WXUNUSED(expr)) +wxItemResource *wxResourceInterpretString(wxResourceTable& WXUNUSED(table), wxExpr *WXUNUSED(expr)) { - return NULL; + return (wxItemResource *) NULL; } -wxItemResource *wxResourceInterpretBitmap(wxResourceTable& WXUNUSED(table), PrologExpr *expr) +wxItemResource *wxResourceInterpretBitmap(wxResourceTable& WXUNUSED(table), wxExpr *expr) { wxItemResource *bitmapItem = new wxItemResource; // bitmapItem->SetType(wxTYPE_BITMAP); - bitmapItem->SetType("wxBitmap"); - char *name = NULL; - expr->AssignAttributeValue("name", &name); - if (name) + bitmapItem->SetType(_T("wxBitmap")); + wxString name; + if (expr->GetAttributeValue(_T("name"), name)) { bitmapItem->SetName(name); - delete[] name; } // Now parse all bitmap specifications - PrologExpr *bitmapExpr = expr->GetFirst(); + wxExpr *bitmapExpr = expr->GetFirst(); while (bitmapExpr) { if (bitmapExpr->Number() == 3) { wxString bitmapKeyword(bitmapExpr->Nth(1)->StringValue()); - if (bitmapKeyword == "bitmap" || bitmapKeyword == "icon") + if (bitmapKeyword == _T("bitmap") || bitmapKeyword == _T("icon")) { // The value part: always a list. - PrologExpr *listExpr = bitmapExpr->Nth(2); + wxExpr *listExpr = bitmapExpr->Nth(2); if (listExpr->Type() == PrologList) { wxItemResource *bitmapSpec = new wxItemResource; // bitmapSpec->SetType(wxTYPE_BITMAP); - bitmapSpec->SetType("wxBitmap"); + bitmapSpec->SetType(_T("wxBitmap")); // List is of form: [filename, bitmaptype, platform, colours, xresolution, yresolution] // where everything after 'filename' is optional. - PrologExpr *nameExpr = listExpr->Nth(0); - PrologExpr *typeExpr = listExpr->Nth(1); - PrologExpr *platformExpr = listExpr->Nth(2); - PrologExpr *coloursExpr = listExpr->Nth(3); - PrologExpr *xresExpr = listExpr->Nth(4); - PrologExpr *yresExpr = listExpr->Nth(5); - if (nameExpr && nameExpr->StringValue()) - bitmapSpec->SetName(WXSTRINGCAST nameExpr->StringValue()); - if (typeExpr && typeExpr->StringValue()) - bitmapSpec->SetValue1(wxParseWindowStyle(WXSTRINGCAST typeExpr->StringValue())); + wxExpr *nameExpr = listExpr->Nth(0); + wxExpr *typeExpr = listExpr->Nth(1); + wxExpr *platformExpr = listExpr->Nth(2); + wxExpr *coloursExpr = listExpr->Nth(3); + wxExpr *xresExpr = listExpr->Nth(4); + wxExpr *yresExpr = listExpr->Nth(5); + if (nameExpr && nameExpr->StringValue() != _T("")) + { + bitmapSpec->SetName(nameExpr->StringValue()); + } + if (typeExpr && typeExpr->StringValue() != _T("")) + { + bitmapSpec->SetValue1(wxParseWindowStyle(typeExpr->StringValue())); + } else bitmapSpec->SetValue1(0); - - if (platformExpr && platformExpr->StringValue()) + + if (platformExpr && platformExpr->StringValue() != _T("")) { wxString plat(platformExpr->StringValue()); - if (plat == "windows" || plat == "WINDOWS") + if (plat == _T("windows") || plat == _T("WINDOWS")) bitmapSpec->SetValue2(RESOURCE_PLATFORM_WINDOWS); - else if (plat == "x" || plat == "X") + else if (plat == _T("x") || plat == _T("X")) bitmapSpec->SetValue2(RESOURCE_PLATFORM_X); - else if (plat == "mac" || plat == "MAC") + else if (plat == _T("mac") || plat == _T("MAC")) bitmapSpec->SetValue2(RESOURCE_PLATFORM_MAC); else bitmapSpec->SetValue2(RESOURCE_PLATFORM_ANY); @@ -1376,74 +1378,85 @@ wxItemResource *wxResourceInterpretBitmap(wxResourceTable& WXUNUSED(table), Prol if (yresExpr) yres = (int)yresExpr->IntegerValue(); bitmapSpec->SetSize(0, 0, xres, yres); - + bitmapItem->GetChildren().Append(bitmapSpec); } } } bitmapExpr = bitmapExpr->GetNext(); } - + return bitmapItem; } -wxItemResource *wxResourceInterpretIcon(wxResourceTable& table, PrologExpr *expr) +wxItemResource *wxResourceInterpretIcon(wxResourceTable& table, wxExpr *expr) { wxItemResource *item = wxResourceInterpretBitmap(table, expr); if (item) { // item->SetType(wxTYPE_ICON); - item->SetType("wxIcon"); + item->SetType(_T("wxIcon")); return item; } else - return NULL; + return (wxItemResource *) NULL; } // Interpret list expression as a font -wxFont *wxResourceInterpretFontSpec(PrologExpr *expr) +wxFont wxResourceInterpretFontSpec(wxExpr *expr) { if (expr->Type() != PrologList) - return NULL; + return wxNullFont; int point = 10; int family = wxSWISS; int style = wxNORMAL; int weight = wxNORMAL; int underline = 0; - wxString faceName(""); - - PrologExpr *pointExpr = expr->Nth(0); - PrologExpr *familyExpr = expr->Nth(1); - PrologExpr *styleExpr = expr->Nth(2); - PrologExpr *weightExpr = expr->Nth(3); - PrologExpr *underlineExpr = expr->Nth(4); - PrologExpr *faceNameExpr = expr->Nth(5); + wxString faceName(_T("")); + + wxExpr *pointExpr = expr->Nth(0); + wxExpr *familyExpr = expr->Nth(1); + wxExpr *styleExpr = expr->Nth(2); + wxExpr *weightExpr = expr->Nth(3); + wxExpr *underlineExpr = expr->Nth(4); + wxExpr *faceNameExpr = expr->Nth(5); if (pointExpr) point = (int)pointExpr->IntegerValue(); + + wxString str; if (familyExpr) - family = (int)wxParseWindowStyle(WXSTRINGCAST familyExpr->StringValue()); + { + str = familyExpr->StringValue(); + family = (int)wxParseWindowStyle(str); + } if (styleExpr) - style = (int)wxParseWindowStyle(WXSTRINGCAST styleExpr->StringValue()); + { + str = styleExpr->StringValue(); + style = (int)wxParseWindowStyle(str); + } if (weightExpr) - weight = (int)wxParseWindowStyle(WXSTRINGCAST weightExpr->StringValue()); + { + str = weightExpr->StringValue(); + weight = (int)wxParseWindowStyle(str); + } if (underlineExpr) underline = (int)underlineExpr->IntegerValue(); if (faceNameExpr) faceName = faceNameExpr->StringValue(); - char *faceName1 = NULL; - if (faceName != "") - faceName1 = WXSTRINGCAST faceName; - wxFont *font = wxTheFontList->FindOrCreateFont(point, family, style, weight, (underline != 0), faceName1); + wxFont font(point, family, style, weight, (underline != 0), faceName); return font; } +// Separate file for the remainder of this, for BC++/Win16 + +#if !((defined(__BORLANDC__) || defined(__SC__)) && defined(__WIN16__)) /* * (Re)allocate buffer for reading in from resource file */ -bool wxReallocateResourceBuffer(void) +bool wxReallocateResourceBuffer() { if (!wxResourceBuffer) { @@ -1560,7 +1573,7 @@ bool wxGetResourceToken(FILE *fd) wxReallocateResourceBuffer(); wxResourceBuffer[wxResourceBufferCount] = (char)ch; wxResourceBufferCount ++; - + ch = getc(fd); } wxResourceBuffer[wxResourceBufferCount] = 0; @@ -1575,12 +1588,12 @@ bool wxGetResourceToken(FILE *fd) static char *name = "...."; with possible comments. */ - -bool wxResourceReadOneResource(FILE *fd, PrologDatabase& db, bool *eof, wxResourceTable *table) + +bool wxResourceReadOneResource(FILE *fd, wxExprDatabase& db, bool *eof, wxResourceTable *table) { if (!table) table = wxDefaultResourceTable; - + // static or #define if (!wxGetResourceToken(fd)) { @@ -1591,105 +1604,102 @@ bool wxResourceReadOneResource(FILE *fd, PrologDatabase& db, bool *eof, wxResour if (strcmp(wxResourceBuffer, "#define") == 0) { wxGetResourceToken(fd); - char *name = copystring(wxResourceBuffer); + wxChar *name = copystring(wxConv_libc.cMB2WX(wxResourceBuffer)); wxGetResourceToken(fd); - char *value = copystring(wxResourceBuffer); - if (isalpha(value[0])) + wxChar *value = copystring(wxConv_libc.cMB2WX(wxResourceBuffer)); + if (wxIsalpha(value[0])) { - int val = (int)atol(value); + int val = (int)wxAtol(value); wxResourceAddIdentifier(name, val, table); } else { - char buf[300]; - sprintf(buf, "#define %s must be an integer.", name); - wxWarning(buf); + wxLogWarning(_("#define %s must be an integer."), name); delete[] name; delete[] value; return FALSE; } delete[] name; delete[] value; - + return TRUE; } else if (strcmp(wxResourceBuffer, "#include") == 0) { wxGetResourceToken(fd); - char *name = copystring(wxResourceBuffer); - char *actualName = name; - if (name[0] == '"') + wxChar *name = copystring(wxConv_libc.cMB2WX(wxResourceBuffer)); + wxChar *actualName = name; + if (name[0] == _T('"')) actualName = name + 1; - int len = strlen(name); - if ((len > 0) && (name[len-1] == '"')) + int len = wxStrlen(name); + if ((len > 0) && (name[len-1] == _T('"'))) name[len-1] = 0; if (!wxResourceParseIncludeFile(actualName, table)) { - char buf[400]; - sprintf(buf, "Could not find resource include file %s.", actualName); - wxWarning(buf); + wxLogWarning(_("Could not find resource include file %s."), actualName); } delete[] name; return TRUE; } else if (strcmp(wxResourceBuffer, "static") != 0) { - char buf[300]; - strcpy(buf, "Found "); - strncat(buf, wxResourceBuffer, 30); - strcat(buf, ", expected static, #include or #define\nwhilst parsing resource."); - wxWarning(buf); + wxChar buf[300]; + wxStrcpy(buf, _("Found ")); + wxStrncat(buf, wxConv_libc.cMB2WX(wxResourceBuffer), 30); + wxStrcat(buf, _(", expected static, #include or #define\nwhilst parsing resource.")); + wxLogWarning(buf); return FALSE; } // char if (!wxGetResourceToken(fd)) { - wxWarning("Unexpected end of file whilst parsing resource."); + wxLogWarning(_("Unexpected end of file whilst parsing resource.")); *eof = TRUE; return FALSE; } if (strcmp(wxResourceBuffer, "char") != 0) { - wxWarning("Expected 'char' whilst parsing resource."); + wxLogWarning(_("Expected 'char' whilst parsing resource.")); return FALSE; } - + // *name if (!wxGetResourceToken(fd)) { - wxWarning("Unexpected end of file whilst parsing resource."); + wxLogWarning(_("Unexpected end of file whilst parsing resource.")); *eof = TRUE; return FALSE; } if (wxResourceBuffer[0] != '*') { - wxWarning("Expected '*' whilst parsing resource."); + wxLogWarning(_("Expected '*' whilst parsing resource.")); return FALSE; } - char nameBuf[100]; - strncpy(nameBuf, wxResourceBuffer+1, 99); - + wxChar nameBuf[100]; + wxMB2WX(nameBuf, wxResourceBuffer+1, 99); + nameBuf[99] = 0; + // = if (!wxGetResourceToken(fd)) { - wxWarning("Unexpected end of file whilst parsing resource."); + wxLogWarning(_("Unexpected end of file whilst parsing resource.")); *eof = TRUE; return FALSE; } if (strcmp(wxResourceBuffer, "=") != 0) { - wxWarning("Expected '=' whilst parsing resource."); + wxLogWarning(_("Expected '=' whilst parsing resource.")); return FALSE; } // String if (!wxGetResourceToken(fd)) { - wxWarning("Unexpected end of file whilst parsing resource."); + wxLogWarning(_("Unexpected end of file whilst parsing resource.")); *eof = TRUE; return FALSE; } @@ -1697,9 +1707,7 @@ bool wxResourceReadOneResource(FILE *fd, PrologDatabase& db, bool *eof, wxResour { if (!db.ReadPrologFromString(wxResourceBuffer)) { - char buf[300]; - sprintf(buf, "%s: ill-formed resource file syntax.", nameBuf); - wxWarning(buf); + wxLogWarning(_("%s: ill-formed resource file syntax."), nameBuf); return FALSE; } } @@ -1714,22 +1722,22 @@ bool wxResourceReadOneResource(FILE *fd, PrologDatabase& db, bool *eof, wxResour /* * Parses string window style into integer window style */ - + /* * Style flag parsing, e.g. * "wxSYSTEM_MENU | wxBORDER" -> integer */ -char *wxResourceParseWord(char *s, int *i) +wxChar* wxResourceParseWord(wxChar*s, int *i) { if (!s) - return NULL; + return (wxChar*) NULL; - static char buf[150]; - int len = strlen(s); + static wxChar buf[150]; + int len = wxStrlen(s); int j = 0; int ii = *i; - while ((ii < len) && (isalpha(s[ii]) || (s[ii] == '_'))) + while ((ii < len) && (wxIsalpha(s[ii]) || (s[ii] == _T('_')))) { buf[j] = s[ii]; j ++; @@ -1739,223 +1747,289 @@ char *wxResourceParseWord(char *s, int *i) // Eat whitespace and conjunction characters while ((ii < len) && - ((s[ii] == ' ') || (s[ii] == '|') || (s[ii] == ','))) + ((s[ii] == _T(' ')) || (s[ii] == _T('|')) || (s[ii] == _T(',')))) { ii ++; } *i = ii; if (j == 0) - return NULL; + return (wxChar*) NULL; else return buf; } struct wxResourceBitListStruct { - char *word; + wxChar *word; long bits; }; static wxResourceBitListStruct wxResourceBitListTable[] = { /* wxListBox */ - { "wxSINGLE", wxLB_SINGLE }, - { "wxMULTIPLE", wxLB_MULTIPLE }, - { "wxEXTENDED", wxLB_EXTENDED }, - { "wxLB_SINGLE", wxLB_SINGLE }, - { "wxLB_MULTIPLE", wxLB_MULTIPLE }, - { "wxLB_EXTENDED", wxLB_EXTENDED }, - { "wxNEEDED_SB", wxNEEDED_SB }, - { "wxALWAYS_SB", wxALWAYS_SB }, - { "wxLB_NEEDED_SB", wxLB_NEEDED_SB }, - { "wxLB_ALWAYS_SB", wxLB_ALWAYS_SB }, - { "wxLB_SORT", wxLB_SORT }, - + { _T("wxSINGLE"), wxLB_SINGLE }, + { _T("wxMULTIPLE"), wxLB_MULTIPLE }, + { _T("wxEXTENDED"), wxLB_EXTENDED }, + { _T("wxLB_SINGLE"), wxLB_SINGLE }, + { _T("wxLB_MULTIPLE"), wxLB_MULTIPLE }, + { _T("wxLB_EXTENDED"), wxLB_EXTENDED }, + { _T("wxLB_NEEDED_SB"), wxLB_NEEDED_SB }, + { _T("wxLB_ALWAYS_SB"), wxLB_ALWAYS_SB }, + { _T("wxLB_SORT"), wxLB_SORT }, + { _T("wxLB_OWNERDRAW"), wxLB_OWNERDRAW }, + { _T("wxLB_HSCROLL"), wxLB_HSCROLL }, + /* wxComboxBox */ - { "wxCB_SIMPLE", wxCB_SIMPLE }, - { "wxCB_DROPDOWN", wxCB_DROPDOWN }, - { "wxCB_SORT", wxCB_SORT }, - + { _T("wxCB_SIMPLE"), wxCB_SIMPLE }, + { _T("wxCB_DROPDOWN"), wxCB_DROPDOWN }, + { _T("wxCB_READONLY"), wxCB_READONLY }, + { _T("wxCB_SORT"), wxCB_SORT }, + /* wxGauge */ - { "wxGA_PROGRESSBAR", wxGA_PROGRESSBAR }, + { _T("wxGA_PROGRESSBAR"), wxGA_PROGRESSBAR }, + { _T("wxGA_HORIZONTAL"), wxGA_HORIZONTAL }, + { _T("wxGA_VERTICAL"), wxGA_VERTICAL }, /* wxTextCtrl */ - { "wxPASSWORD", wxPASSWORD}, - { "wxPROCESS_ENTER", wxPROCESS_ENTER}, - { "wxTE_PASSWORD", wxTE_PASSWORD}, - { "wxTE_READONLY", wxTE_READONLY}, - { "wxTE_PROCESS_ENTER", wxTE_PROCESS_ENTER}, - - /* wxRadioButton */ - { "wxRB_GROUP", wxRB_GROUP }, - - /* wxItem */ - { "wxFIXED_LENGTH", wxFIXED_LENGTH}, - { "wxALIGN_LEFT", wxALIGN_LEFT}, - { "wxALIGN_CENTER", wxALIGN_CENTER}, - { "wxALIGN_CENTRE", wxALIGN_CENTRE}, - { "wxALIGN_RIGHT", wxALIGN_RIGHT}, - + { _T("wxPASSWORD"), wxPASSWORD}, + { _T("wxPROCESS_ENTER"), wxPROCESS_ENTER}, + { _T("wxTE_PASSWORD"), wxTE_PASSWORD}, + { _T("wxTE_READONLY"), wxTE_READONLY}, + { _T("wxTE_PROCESS_ENTER"), wxTE_PROCESS_ENTER}, + { _T("wxTE_MULTILINE"), wxTE_MULTILINE}, + + /* wxRadioBox/wxRadioButton */ + { _T("wxRB_GROUP"), wxRB_GROUP }, + { _T("wxRA_SPECIFY_COLS"), wxRA_SPECIFY_COLS }, + { _T("wxRA_SPECIFY_ROWS"), wxRA_SPECIFY_ROWS }, + { _T("wxRA_HORIZONTAL"), wxRA_HORIZONTAL }, + { _T("wxRA_VERTICAL"), wxRA_VERTICAL }, + + /* wxSlider */ + { _T("wxSL_HORIZONTAL"), wxSL_HORIZONTAL }, + { _T("wxSL_VERTICAL"), wxSL_VERTICAL }, + { _T("wxSL_AUTOTICKS"), wxSL_AUTOTICKS }, + { _T("wxSL_LABELS"), wxSL_LABELS }, + { _T("wxSL_LEFT"), wxSL_LEFT }, + { _T("wxSL_TOP"), wxSL_TOP }, + { _T("wxSL_RIGHT"), wxSL_RIGHT }, + { _T("wxSL_BOTTOM"), wxSL_BOTTOM }, + { _T("wxSL_BOTH"), wxSL_BOTH }, + { _T("wxSL_SELRANGE"), wxSL_SELRANGE }, + + /* wxScrollBar */ + { _T("wxSB_HORIZONTAL"), wxSB_HORIZONTAL }, + { _T("wxSB_VERTICAL"), wxSB_VERTICAL }, + + /* wxButton */ + { _T("wxBU_AUTODRAW"), wxBU_AUTODRAW }, + { _T("wxBU_NOAUTODRAW"), wxBU_NOAUTODRAW }, + + /* wxTreeCtrl */ + { _T("wxTR_HAS_BUTTONS"), wxTR_HAS_BUTTONS }, + { _T("wxTR_EDIT_LABELS"), wxTR_EDIT_LABELS }, + { _T("wxTR_LINES_AT_ROOT"), wxTR_LINES_AT_ROOT }, + + /* wxListCtrl */ + { _T("wxLC_ICON"), wxLC_ICON }, + { _T("wxLC_SMALL_ICON"), wxLC_SMALL_ICON }, + { _T("wxLC_LIST"), wxLC_LIST }, + { _T("wxLC_REPORT"), wxLC_REPORT }, + { _T("wxLC_ALIGN_TOP"), wxLC_ALIGN_TOP }, + { _T("wxLC_ALIGN_LEFT"), wxLC_ALIGN_LEFT }, + { _T("wxLC_AUTOARRANGE"), wxLC_AUTOARRANGE }, + { _T("wxLC_USER_TEXT"), wxLC_USER_TEXT }, + { _T("wxLC_EDIT_LABELS"), wxLC_EDIT_LABELS }, + { _T("wxLC_NO_HEADER"), wxLC_NO_HEADER }, + { _T("wxLC_NO_SORT_HEADER"), wxLC_NO_SORT_HEADER }, + { _T("wxLC_SINGLE_SEL"), wxLC_SINGLE_SEL }, + { _T("wxLC_SORT_ASCENDING"), wxLC_SORT_ASCENDING }, + { _T("wxLC_SORT_DESCENDING"), wxLC_SORT_DESCENDING }, + + /* wxSpinButton */ + { _T("wxSP_VERTICAL"), wxSP_VERTICAL}, + { _T("wxSP_HORIZONTAL"), wxSP_HORIZONTAL}, + { _T("wxSP_ARROW_KEYS"), wxSP_ARROW_KEYS}, + { _T("wxSP_WRAP"), wxSP_WRAP}, + + /* wxSplitterWnd */ + { _T("wxSP_NOBORDER"), wxSP_NOBORDER}, + { _T("wxSP_3D"), wxSP_3D}, + { _T("wxSP_BORDER"), wxSP_BORDER}, + + /* wxTabCtrl */ + { _T("wxTC_MULTILINE"), wxTC_MULTILINE}, + { _T("wxTC_RIGHTJUSTIFY"), wxTC_RIGHTJUSTIFY}, + { _T("wxTC_FIXEDWIDTH"), wxTC_FIXEDWIDTH}, + { _T("wxTC_OWNERDRAW"), wxTC_OWNERDRAW}, + + /* wxStatusBar95 */ + { _T("wxST_SIZEGRIP"), wxST_SIZEGRIP}, + + /* wxControl */ + { _T("wxFIXED_LENGTH"), wxFIXED_LENGTH}, + { _T("wxALIGN_LEFT"), wxALIGN_LEFT}, + { _T("wxALIGN_CENTER"), wxALIGN_CENTER}, + { _T("wxALIGN_CENTRE"), wxALIGN_CENTRE}, + { _T("wxALIGN_RIGHT"), wxALIGN_RIGHT}, + { _T("wxCOLOURED"), wxCOLOURED}, + /* wxToolBar */ - { "wxTB_3DBUTTONS", wxTB_3DBUTTONS}, + { _T("wxTB_3DBUTTONS"), wxTB_3DBUTTONS}, + { _T("wxTB_HORIZONTAL"), wxTB_HORIZONTAL}, + { _T("wxTB_VERTICAL"), wxTB_VERTICAL}, + { _T("wxTB_FLAT"), wxTB_FLAT}, /* Generic */ - { "wxVSCROLL", wxVSCROLL }, - { "wxHSCROLL", wxHSCROLL }, - { "wxCAPTION", wxCAPTION }, - { "wxSTAY_ON_TOP", wxSTAY_ON_TOP}, - { "wxICONIZE", wxICONIZE}, - { "wxMINIMIZE", wxICONIZE}, - { "wxMAXIMIZE", wxMAXIMIZE}, - { "wxSDI", 0}, - { "wxMDI_PARENT", 0}, - { "wxMDI_CHILD", 0}, - { "wxTHICK_FRAME", wxTHICK_FRAME}, - { "wxRESIZE_BORDER", wxRESIZE_BORDER}, - { "wxSYSTEM_MENU", wxSYSTEM_MENU}, - { "wxMINIMIZE_BOX", wxMINIMIZE_BOX}, - { "wxMAXIMIZE_BOX", wxMAXIMIZE_BOX}, - { "wxRESIZE_BOX", wxRESIZE_BOX}, - { "wxDEFAULT_FRAME", wxDEFAULT_FRAME}, - { "wxDEFAULT_DIALOG_STYLE", wxDEFAULT_DIALOG_STYLE}, - { "wxBORDER", wxBORDER}, - { "wxRETAINED", wxRETAINED}, - { "wxEDITABLE", wxEDITABLE}, - { "wxREADONLY", wxREADONLY}, - { "wxNATIVE_IMPL", 0}, - { "wxEXTENDED_IMPL", 0}, - { "wxBACKINGSTORE", wxBACKINGSTORE}, -// { "wxFLAT", wxFLAT}, -// { "wxMOTIF_RESIZE", wxMOTIF_RESIZE}, - { "wxFIXED_LENGTH", wxFIXED_LENGTH}, - -#if USE_ENHANCED_DIALOG - // Enhanced dialog - { "wxBOTTOM_COMMANDS", wxBOTTOM_COMMANDS}, - { "wxRIGHT_COMMANDS", wxRIGHT_COMMANDS}, - { "wxSTATUS_FOOTER", wxSTATUS_FOOTER}, - { "wxNO_STATUS_FOOTER", wxNO_STATUS_FOOTER}, - { "wxNO_CANCEL_BUTTON", wxNO_CANCEL_BUTTON}, - { "wxCANCEL_BUTTON_FIRST", wxCANCEL_BUTTON_FIRST}, - { "wxCANCEL_BUTTON_SECOND", wxCANCEL_BUTTON_SECOND}, - { "wxCANCEL_BUTTON_LAST", wxCANCEL_BUTTON_LAST}, - { "wxENH_DEFAULT", wxENH_DEFAULT}, -#endif - - { "wxCOLOURED", wxCOLOURED}, - { "wxTINY_CAPTION_HORIZ", wxTINY_CAPTION_HORIZ}, - { "wxTINY_CAPTION_VERT", wxTINY_CAPTION_VERT}, + { _T("wxVSCROLL"), wxVSCROLL }, + { _T("wxHSCROLL"), wxHSCROLL }, + { _T("wxCAPTION"), wxCAPTION }, + { _T("wxSTAY_ON_TOP"), wxSTAY_ON_TOP}, + { _T("wxICONIZE"), wxICONIZE}, + { _T("wxMINIMIZE"), wxICONIZE}, + { _T("wxMAXIMIZE"), wxMAXIMIZE}, + { _T("wxSDI"), 0}, + { _T("wxMDI_PARENT"), 0}, + { _T("wxMDI_CHILD"), 0}, + { _T("wxTHICK_FRAME"), wxTHICK_FRAME}, + { _T("wxRESIZE_BORDER"), wxRESIZE_BORDER}, + { _T("wxSYSTEM_MENU"), wxSYSTEM_MENU}, + { _T("wxMINIMIZE_BOX"), wxMINIMIZE_BOX}, + { _T("wxMAXIMIZE_BOX"), wxMAXIMIZE_BOX}, + { _T("wxRESIZE_BOX"), wxRESIZE_BOX}, + { _T("wxDEFAULT_FRAME_STYLE"), wxDEFAULT_FRAME_STYLE}, + { _T("wxDEFAULT_FRAME"), wxDEFAULT_FRAME_STYLE}, + { _T("wxDEFAULT_DIALOG_STYLE"), wxDEFAULT_DIALOG_STYLE}, + { _T("wxBORDER"), wxBORDER}, + { _T("wxRETAINED"), wxRETAINED}, + { _T("wxNATIVE_IMPL"), 0}, + { _T("wxEXTENDED_IMPL"), 0}, + { _T("wxBACKINGSTORE"), wxBACKINGSTORE}, +// { _T("wxFLAT"), wxFLAT}, +// { _T("wxMOTIF_RESIZE"), wxMOTIF_RESIZE}, + { _T("wxFIXED_LENGTH"), 0}, + { _T("wxDOUBLE_BORDER"), wxDOUBLE_BORDER}, + { _T("wxSUNKEN_BORDER"), wxSUNKEN_BORDER}, + { _T("wxRAISED_BORDER"), wxRAISED_BORDER}, + { _T("wxSIMPLE_BORDER"), wxSIMPLE_BORDER}, + { _T("wxSTATIC_BORDER"), wxSTATIC_BORDER}, + { _T("wxTRANSPARENT_WINDOW"), wxTRANSPARENT_WINDOW}, + { _T("wxNO_BORDER"), wxNO_BORDER}, + { _T("wxCLIP_CHILDREN"), wxCLIP_CHILDREN}, + + { _T("wxTINY_CAPTION_HORIZ"), wxTINY_CAPTION_HORIZ}, + { _T("wxTINY_CAPTION_VERT"), wxTINY_CAPTION_VERT}, // Text font families - { "wxDEFAULT", wxDEFAULT}, - { "wxDECORATIVE", wxDECORATIVE}, - { "wxROMAN", wxROMAN}, - { "wxSCRIPT", wxSCRIPT}, - { "wxSWISS", wxSWISS}, - { "wxMODERN", wxMODERN}, - { "wxTELETYPE", wxTELETYPE}, - { "wxVARIABLE", wxVARIABLE}, - { "wxFIXED", wxFIXED}, - { "wxNORMAL", wxNORMAL}, - { "wxLIGHT", wxLIGHT}, - { "wxBOLD", wxBOLD}, - { "wxITALIC", wxITALIC}, - { "wxSLANT", wxSLANT}, - { "wxSOLID", wxSOLID}, - { "wxDOT", wxDOT}, - { "wxLONG_DASH", wxLONG_DASH}, - { "wxSHORT_DASH", wxSHORT_DASH}, - { "wxDOT_DASH", wxDOT_DASH}, - { "wxUSER_DASH", wxUSER_DASH}, - { "wxTRANSPARENT", wxTRANSPARENT}, - { "wxSTIPPLE", wxSTIPPLE}, - { "wxBDIAGONAL_HATCH", wxBDIAGONAL_HATCH}, - { "wxCROSSDIAG_HATCH", wxCROSSDIAG_HATCH}, - { "wxFDIAGONAL_HATCH", wxFDIAGONAL_HATCH}, - { "wxCROSS_HATCH", wxCROSS_HATCH}, - { "wxHORIZONTAL_HATCH", wxHORIZONTAL_HATCH}, - { "wxVERTICAL_HATCH", wxVERTICAL_HATCH}, - { "wxJOIN_BEVEL", wxJOIN_BEVEL}, - { "wxJOIN_MITER", wxJOIN_MITER}, - { "wxJOIN_ROUND", wxJOIN_ROUND}, - { "wxCAP_ROUND", wxCAP_ROUND}, - { "wxCAP_PROJECTING", wxCAP_PROJECTING}, - { "wxCAP_BUTT", wxCAP_BUTT}, + { _T("wxDEFAULT"), wxDEFAULT}, + { _T("wxDECORATIVE"), wxDECORATIVE}, + { _T("wxROMAN"), wxROMAN}, + { _T("wxSCRIPT"), wxSCRIPT}, + { _T("wxSWISS"), wxSWISS}, + { _T("wxMODERN"), wxMODERN}, + { _T("wxTELETYPE"), wxTELETYPE}, + { _T("wxVARIABLE"), wxVARIABLE}, + { _T("wxFIXED"), wxFIXED}, + { _T("wxNORMAL"), wxNORMAL}, + { _T("wxLIGHT"), wxLIGHT}, + { _T("wxBOLD"), wxBOLD}, + { _T("wxITALIC"), wxITALIC}, + { _T("wxSLANT"), wxSLANT}, + { _T("wxSOLID"), wxSOLID}, + { _T("wxDOT"), wxDOT}, + { _T("wxLONG_DASH"), wxLONG_DASH}, + { _T("wxSHORT_DASH"), wxSHORT_DASH}, + { _T("wxDOT_DASH"), wxDOT_DASH}, + { _T("wxUSER_DASH"), wxUSER_DASH}, + { _T("wxTRANSPARENT"), wxTRANSPARENT}, + { _T("wxSTIPPLE"), wxSTIPPLE}, + { _T("wxBDIAGONAL_HATCH"), wxBDIAGONAL_HATCH}, + { _T("wxCROSSDIAG_HATCH"), wxCROSSDIAG_HATCH}, + { _T("wxFDIAGONAL_HATCH"), wxFDIAGONAL_HATCH}, + { _T("wxCROSS_HATCH"), wxCROSS_HATCH}, + { _T("wxHORIZONTAL_HATCH"), wxHORIZONTAL_HATCH}, + { _T("wxVERTICAL_HATCH"), wxVERTICAL_HATCH}, + { _T("wxJOIN_BEVEL"), wxJOIN_BEVEL}, + { _T("wxJOIN_MITER"), wxJOIN_MITER}, + { _T("wxJOIN_ROUND"), wxJOIN_ROUND}, + { _T("wxCAP_ROUND"), wxCAP_ROUND}, + { _T("wxCAP_PROJECTING"), wxCAP_PROJECTING}, + { _T("wxCAP_BUTT"), wxCAP_BUTT}, // Logical ops - { "wxCLEAR", wxCLEAR}, - { "wxXOR", wxXOR}, - { "wxINVERT", wxINVERT}, - { "wxOR_REVERSE", wxOR_REVERSE}, - { "wxAND_REVERSE", wxAND_REVERSE}, - { "wxCOPY", wxCOPY}, - { "wxAND", wxAND}, - { "wxAND_INVERT", wxAND_INVERT}, - { "wxNO_OP", wxNO_OP}, - { "wxNOR", wxNOR}, - { "wxEQUIV", wxEQUIV}, - { "wxSRC_INVERT", wxSRC_INVERT}, - { "wxOR_INVERT", wxOR_INVERT}, - { "wxNAND", wxNAND}, - { "wxOR", wxOR}, - { "wxSET", wxSET}, - - { "wxFLOOD_SURFACE", wxFLOOD_SURFACE}, - { "wxFLOOD_BORDER", wxFLOOD_BORDER}, - { "wxODDEVEN_RULE", wxODDEVEN_RULE}, - { "wxWINDING_RULE", wxWINDING_RULE}, - { "wxHORIZONTAL", wxHORIZONTAL}, - { "wxVERTICAL", wxVERTICAL}, - { "wxBOTH", wxBOTH}, - { "wxCENTER_FRAME", wxCENTER_FRAME}, - { "wxOK", wxOK}, - { "wxYES_NO", wxYES_NO}, - { "wxCANCEL", wxCANCEL}, - { "wxYES", wxYES}, - { "wxNO", wxNO}, - { "wxICON_EXCLAMATION", wxICON_EXCLAMATION}, - { "wxICON_HAND", wxICON_HAND}, - { "wxICON_QUESTION", wxICON_QUESTION}, - { "wxICON_INFORMATION", wxICON_INFORMATION}, - { "wxICON_STOP", wxICON_STOP}, - { "wxICON_ASTERISK", wxICON_ASTERISK}, - { "wxICON_MASK", wxICON_MASK}, - { "wxCENTRE", wxCENTRE}, - { "wxCENTER", wxCENTRE}, - { "wxUSER_COLOURS", wxUSER_COLOURS}, - { "wxVERTICAL_LABEL", 0}, - { "wxHORIZONTAL_LABEL", 0}, + { _T("wxCLEAR"), wxCLEAR}, + { _T("wxXOR"), wxXOR}, + { _T("wxINVERT"), wxINVERT}, + { _T("wxOR_REVERSE"), wxOR_REVERSE}, + { _T("wxAND_REVERSE"), wxAND_REVERSE}, + { _T("wxCOPY"), wxCOPY}, + { _T("wxAND"), wxAND}, + { _T("wxAND_INVERT"), wxAND_INVERT}, + { _T("wxNO_OP"), wxNO_OP}, + { _T("wxNOR"), wxNOR}, + { _T("wxEQUIV"), wxEQUIV}, + { _T("wxSRC_INVERT"), wxSRC_INVERT}, + { _T("wxOR_INVERT"), wxOR_INVERT}, + { _T("wxNAND"), wxNAND}, + { _T("wxOR"), wxOR}, + { _T("wxSET"), wxSET}, + + { _T("wxFLOOD_SURFACE"), wxFLOOD_SURFACE}, + { _T("wxFLOOD_BORDER"), wxFLOOD_BORDER}, + { _T("wxODDEVEN_RULE"), wxODDEVEN_RULE}, + { _T("wxWINDING_RULE"), wxWINDING_RULE}, + { _T("wxHORIZONTAL"), wxHORIZONTAL}, + { _T("wxVERTICAL"), wxVERTICAL}, + { _T("wxBOTH"), wxBOTH}, + { _T("wxCENTER_FRAME"), wxCENTER_FRAME}, + { _T("wxOK"), wxOK}, + { _T("wxYES_NO"), wxYES_NO}, + { _T("wxCANCEL"), wxCANCEL}, + { _T("wxYES"), wxYES}, + { _T("wxNO"), wxNO}, + { _T("wxICON_EXCLAMATION"), wxICON_EXCLAMATION}, + { _T("wxICON_HAND"), wxICON_HAND}, + { _T("wxICON_QUESTION"), wxICON_QUESTION}, + { _T("wxICON_INFORMATION"), wxICON_INFORMATION}, + { _T("wxICON_STOP"), wxICON_STOP}, + { _T("wxICON_ASTERISK"), wxICON_ASTERISK}, + { _T("wxICON_MASK"), wxICON_MASK}, + { _T("wxCENTRE"), wxCENTRE}, + { _T("wxCENTER"), wxCENTRE}, + { _T("wxUSER_COLOURS"), wxUSER_COLOURS}, + { _T("wxVERTICAL_LABEL"), 0}, + { _T("wxHORIZONTAL_LABEL"), 0}, // Bitmap types (not strictly styles) - { "wxBITMAP_TYPE_XPM", wxBITMAP_TYPE_XPM}, - { "wxBITMAP_TYPE_XBM", wxBITMAP_TYPE_XBM}, - { "wxBITMAP_TYPE_BMP", wxBITMAP_TYPE_BMP}, - { "wxBITMAP_TYPE_RESOURCE", wxBITMAP_TYPE_BMP_RESOURCE}, - { "wxBITMAP_TYPE_BMP_RESOURCE", wxBITMAP_TYPE_BMP_RESOURCE}, - { "wxBITMAP_TYPE_GIF", wxBITMAP_TYPE_GIF}, - { "wxBITMAP_TYPE_TIF", wxBITMAP_TYPE_TIF}, - { "wxBITMAP_TYPE_ICO", wxBITMAP_TYPE_ICO}, - { "wxBITMAP_TYPE_ICO_RESOURCE", wxBITMAP_TYPE_ICO_RESOURCE}, - { "wxBITMAP_TYPE_CUR", wxBITMAP_TYPE_CUR}, - { "wxBITMAP_TYPE_CUR_RESOURCE", wxBITMAP_TYPE_CUR_RESOURCE}, - { "wxBITMAP_TYPE_XBM_DATA", wxBITMAP_TYPE_XBM_DATA}, - { "wxBITMAP_TYPE_XPM_DATA", wxBITMAP_TYPE_XPM_DATA}, - { "wxBITMAP_TYPE_ANY", wxBITMAP_TYPE_ANY} + { _T("wxBITMAP_TYPE_XPM"), wxBITMAP_TYPE_XPM}, + { _T("wxBITMAP_TYPE_XBM"), wxBITMAP_TYPE_XBM}, + { _T("wxBITMAP_TYPE_BMP"), wxBITMAP_TYPE_BMP}, + { _T("wxBITMAP_TYPE_RESOURCE"), wxBITMAP_TYPE_BMP_RESOURCE}, + { _T("wxBITMAP_TYPE_BMP_RESOURCE"), wxBITMAP_TYPE_BMP_RESOURCE}, + { _T("wxBITMAP_TYPE_GIF"), wxBITMAP_TYPE_GIF}, + { _T("wxBITMAP_TYPE_TIF"), wxBITMAP_TYPE_TIF}, + { _T("wxBITMAP_TYPE_ICO"), wxBITMAP_TYPE_ICO}, + { _T("wxBITMAP_TYPE_ICO_RESOURCE"), wxBITMAP_TYPE_ICO_RESOURCE}, + { _T("wxBITMAP_TYPE_CUR"), wxBITMAP_TYPE_CUR}, + { _T("wxBITMAP_TYPE_CUR_RESOURCE"), wxBITMAP_TYPE_CUR_RESOURCE}, + { _T("wxBITMAP_TYPE_XBM_DATA"), wxBITMAP_TYPE_XBM_DATA}, + { _T("wxBITMAP_TYPE_XPM_DATA"), wxBITMAP_TYPE_XPM_DATA}, + { _T("wxBITMAP_TYPE_ANY"), wxBITMAP_TYPE_ANY} }; static int wxResourceBitListCount = (sizeof(wxResourceBitListTable)/sizeof(wxResourceBitListStruct)); -long wxParseWindowStyle(char *bitListString) +long wxParseWindowStyle(const wxString& bitListString) { int i = 0; - char *word; + wxChar *word; long bitList = 0; - while ((word = wxResourceParseWord(bitListString, &i))) + while ((word = wxResourceParseWord(WXSTRINGCAST bitListString, &i))) { bool found = FALSE; int j; for (j = 0; j < wxResourceBitListCount; j++) - if (strcmp(wxResourceBitListTable[j].word, word) == 0) + if (wxStrcmp(wxResourceBitListTable[j].word, word) == 0) { bitList |= wxResourceBitListTable[j].bits; found = TRUE; @@ -1963,9 +2037,7 @@ long wxParseWindowStyle(char *bitListString) } if (!found) { - char buf[200]; - sprintf(buf, "Unrecognized style %s whilst parsing resource.", word); - wxWarning(buf); + wxLogWarning(_("Unrecognized style %s whilst parsing resource."), word); return 0; } } @@ -1976,27 +2048,25 @@ long wxParseWindowStyle(char *bitListString) * Load a bitmap from a wxWindows resource, choosing an optimum * depth and appropriate type. */ - -wxBitmap *wxResourceCreateBitmap(char *resource, wxResourceTable *table) + +wxBitmap wxResourceCreateBitmap(const wxString& resource, wxResourceTable *table) { if (!table) table = wxDefaultResourceTable; - + wxItemResource *item = table->FindResource(resource); if (item) { - if (!item->GetType() || strcmp(item->GetType(), "wxBitmap") != 0) + if ((item->GetType() == "") || (item->GetType() != "wxBitmap")) { - char buf[300]; - sprintf(buf, "%s not a bitmap resource specification.", resource); - wxWarning(buf); - return NULL; + wxLogWarning(_("%s not a bitmap resource specification."), (const wxChar*) resource); + return wxNullBitmap; } int thisDepth = wxDisplayDepth(); long thisNoColours = (long)pow(2.0, (double)thisDepth); - wxItemResource *optResource = NULL; - + wxItemResource *optResource = (wxItemResource *) NULL; + // Try to find optimum bitmap for this platform/colour depth wxNode *node = item->GetChildren().First(); while (node) @@ -2027,7 +2097,7 @@ wxBitmap *wxResourceCreateBitmap(char *resource, wxResourceTable *table) } break; } -#ifdef __WINDOWS__ +#ifdef __WXMSW__ case RESOURCE_PLATFORM_WINDOWS: { if (!optResource && ((noColours == 0) || (noColours <= thisNoColours))) @@ -2041,7 +2111,7 @@ wxBitmap *wxResourceCreateBitmap(char *resource, wxResourceTable *table) break; } #endif -#ifdef __X__ +#ifdef __WXGTK__ case RESOURCE_PLATFORM_X: { if (!optResource && ((noColours == 0) || (noColours <= thisNoColours))) @@ -2076,72 +2146,56 @@ wxBitmap *wxResourceCreateBitmap(char *resource, wxResourceTable *table) } // If no matching resource, fail. if (!optResource) - return NULL; + return wxNullBitmap; - char *name = optResource->GetName(); + wxString name = optResource->GetName(); int bitmapType = (int)optResource->GetValue1(); - wxBitmap *bitmap = NULL; switch (bitmapType) { case wxBITMAP_TYPE_XBM_DATA: { -#ifdef __X__ +#ifdef __WXGTK__ wxItemResource *item = table->FindResource(name); if (!item) { - char buf[400]; - sprintf(buf, "Failed to find XBM resource %s.\nForgot to use wxResourceLoadBitmapData?", name); - wxWarning(buf); - return NULL; + wxLogWarning(_("Failed to find XBM resource %s.\n" + "Forgot to use wxResourceLoadBitmapData?"), (const wxChar*) name); + return wxNullBitmap; } - bitmap = new wxBitmap((char *)item->GetValue1(), (int)item->GetValue2(), (int)item->GetValue3()); + return wxBitmap(item->GetValue1(), (int)item->GetValue2(), (int)item->GetValue3()) ; #else - wxWarning("No XBM facility available!"); + wxLogWarning(_("No XBM facility available!")); #endif break; } case wxBITMAP_TYPE_XPM_DATA: { -#if (defined(__X__) && USE_XPM_IN_X) || (defined(__WINDOWS__) && USE_XPM_IN_MSW) +#if (defined(__WXGTK__)) || (defined(__WXMSW__) && wxUSE_XPM_IN_MSW) wxItemResource *item = table->FindResource(name); if (!item) { - char buf[400]; - sprintf(buf, "Failed to find XPM resource %s.\nForgot to use wxResourceLoadBitmapData?", name); - wxWarning(buf); - return NULL; + wxLogWarning(_("Failed to find XPM resource %s.\n" + "Forgot to use wxResourceLoadBitmapData?"), (const wxChar*) name); + return wxNullBitmap; } - bitmap = new wxBitmap(item->GetValue1()); + return wxBitmap((char **)item->GetValue1()); #else - wxWarning("No XPM facility available!"); + wxLogWarning(_("No XPM facility available!")); #endif break; } default: { - bitmap = new wxBitmap(name, bitmapType); + return wxBitmap(name, bitmapType); break; } } - if (!bitmap) - return NULL; - - if (bitmap->Ok()) - { - return bitmap; - } - else - { - delete bitmap; - return NULL; - } + return wxNullBitmap; } else { - char buf[300]; - sprintf(buf, "Bitmap resource specification %s not found.", resource); - wxWarning(buf); - return NULL; + wxLogWarning(_("Bitmap resource specification %s not found."), (const wxChar*) resource); + return wxNullBitmap; } } @@ -2149,27 +2203,25 @@ wxBitmap *wxResourceCreateBitmap(char *resource, wxResourceTable *table) * Load an icon from a wxWindows resource, choosing an optimum * depth and appropriate type. */ - -wxIcon *wxResourceCreateIcon(char *resource, wxResourceTable *table) + +wxIcon wxResourceCreateIcon(const wxString& resource, wxResourceTable *table) { if (!table) - table = wxDefaultResourceTable; - + table = wxDefaultResourceTable; + wxItemResource *item = table->FindResource(resource); if (item) { - if (!item->GetType() || strcmp(item->GetType(), "wxIcon") != 0) + if ((item->GetType() == _T("")) || wxStrcmp(item->GetType(), _T("wxIcon")) != 0) { - char buf[300]; - sprintf(buf, "%s not an icon resource specification.", resource); - wxWarning(buf); - return NULL; + wxLogWarning(_("%s not an icon resource specification."), (const wxChar*) resource); + return wxNullIcon; } int thisDepth = wxDisplayDepth(); long thisNoColours = (long)pow(2.0, (double)thisDepth); - wxItemResource *optResource = NULL; - + wxItemResource *optResource = (wxItemResource *) NULL; + // Try to find optimum icon for this platform/colour depth wxNode *node = item->GetChildren().First(); while (node) @@ -2200,7 +2252,7 @@ wxIcon *wxResourceCreateIcon(char *resource, wxResourceTable *table) } break; } -#ifdef __WINDOWS__ +#ifdef __WXMSW__ case RESOURCE_PLATFORM_WINDOWS: { if (!optResource && ((noColours == 0) || (noColours <= thisNoColours))) @@ -2214,7 +2266,7 @@ wxIcon *wxResourceCreateIcon(char *resource, wxResourceTable *table) break; } #endif -#ifdef __X__ +#ifdef __WXGTK__ case RESOURCE_PLATFORM_X: { if (!optResource && ((noColours == 0) || (noColours <= thisNoColours))) @@ -2249,27 +2301,25 @@ wxIcon *wxResourceCreateIcon(char *resource, wxResourceTable *table) } // If no matching resource, fail. if (!optResource) - return NULL; + return wxNullIcon; - char *name = optResource->GetName(); + wxString name = optResource->GetName(); int bitmapType = (int)optResource->GetValue1(); - wxIcon *icon = NULL; switch (bitmapType) { case wxBITMAP_TYPE_XBM_DATA: { -#ifdef __X__ +#ifdef __WXGTK__ wxItemResource *item = table->FindResource(name); if (!item) { - char buf[400]; - sprintf(buf, "Failed to find XBM resource %s.\nForgot to use wxResourceLoadIconData?", name); - wxWarning(buf); - return NULL; + wxLogWarning(_("Failed to find XBM resource %s.\n" + "Forgot to use wxResourceLoadIconData?"), (const wxChar*) name); + return wxNullIcon; } - icon = new wxIcon((char *)item->GetValue1(), (int)item->GetValue2(), (int)item->GetValue3()); + return wxIcon((const char **)item->GetValue1(), (int)item->GetValue2(), (int)item->GetValue3()); #else - wxWarning("No XBM facility available!"); + wxLogWarning(_("No XBM facility available!")); #endif break; } @@ -2277,48 +2327,39 @@ wxIcon *wxResourceCreateIcon(char *resource, wxResourceTable *table) { // *** XPM ICON NOT YET IMPLEMENTED IN WXWINDOWS *** /* -#if (defined(__X__) && USE_XPM_IN_X) || (defined(__WINDOWS__) && USE_XPM_IN_MSW) +#if (defined(__WXGTK__)) || (defined(__WXMSW__) && wxUSE_XPM_IN_MSW) wxItemResource *item = table->FindResource(name); if (!item) { char buf[400]; - sprintf(buf, "Failed to find XPM resource %s.\nForgot to use wxResourceLoadIconData?", name); - wxWarning(buf); + sprintf(buf, _("Failed to find XPM resource %s.\nForgot to use wxResourceLoadIconData?"), name); + wxLogWarning(buf); return NULL; } - icon = new wxIcon((char **)item->GetValue1()); + return wxIcon((char **)item->GetValue1()); #else - wxWarning("No XPM facility available!"); + wxLogWarning(_("No XPM facility available!")); #endif */ - wxWarning("No XPM icon facility available!"); + wxLogWarning(_("No XPM icon facility available!")); break; } default: { - icon = new wxIcon(name, bitmapType); +#ifdef __WXGTK__ + wxLogWarning(_("Icon resource specification %s not found."), (const wxChar*) resource); +#else + return wxIcon(name, bitmapType); +#endif break; } } - if (!icon) - return NULL; - - if (icon->Ok()) - { - return icon; - } - else - { - delete icon; - return NULL; - } + return wxNullIcon; } else { - char buf[300]; - sprintf(buf, "Icon resource specification %s not found.", resource); - wxWarning(buf); - return NULL; + wxLogWarning(_("Icon resource specification %s not found."), (const wxChar*) resource); + return wxNullIcon; } } @@ -2329,7 +2370,7 @@ wxMenu *wxResourceCreateMenu(wxItemResource *item) while (node) { wxItemResource *child = (wxItemResource *)node->Data(); - if (child->GetType() && strcmp(child->GetType(), "wxMenuSeparator") == 0) + if ((child->GetType() != _T("")) && (child->GetType() == _T("wxMenuSeparator"))) menu->AppendSeparator(); else if (child->GetChildren().Number() > 0) { @@ -2346,13 +2387,13 @@ wxMenu *wxResourceCreateMenu(wxItemResource *item) return menu; } -wxMenuBar *wxResourceCreateMenuBar(char *resource, wxResourceTable *table, wxMenuBar *menuBar) +wxMenuBar *wxResourceCreateMenuBar(const wxString& resource, wxResourceTable *table, wxMenuBar *menuBar) { if (!table) table = wxDefaultResourceTable; - + wxItemResource *menuResource = table->FindResource(resource); - if (menuResource && menuResource->GetType() && strcmp(menuResource->GetType(), "wxMenu") == 0) + if (menuResource && (menuResource->GetType() != _T("")) && (menuResource->GetType() == _T("wxMenu"))) { if (!menuBar) menuBar = new wxMenuBar; @@ -2367,48 +2408,48 @@ wxMenuBar *wxResourceCreateMenuBar(char *resource, wxResourceTable *table, wxMen } return menuBar; } - return NULL; + return (wxMenuBar *) NULL; } -wxMenu *wxResourceCreateMenu(char *resource, wxResourceTable *table) +wxMenu *wxResourceCreateMenu(const wxString& resource, wxResourceTable *table) { if (!table) table = wxDefaultResourceTable; - + wxItemResource *menuResource = table->FindResource(resource); - if (menuResource && menuResource->GetType() && strcmp(menuResource->GetType(), "wxMenu") == 0) + if (menuResource && (menuResource->GetType() != _T("")) && (menuResource->GetType() == _T("wxMenu"))) // if (menuResource && (menuResource->GetType() == wxTYPE_MENU)) return wxResourceCreateMenu(menuResource); - return NULL; + return (wxMenu *) NULL; } // Global equivalents (so don't have to refer to default table explicitly) -bool wxResourceParseData(char *resource, wxResourceTable *table) +bool wxResourceParseData(const wxString& resource, wxResourceTable *table) { if (!table) table = wxDefaultResourceTable; - + return table->ParseResourceData(resource); } -bool wxResourceParseFile(char *filename, wxResourceTable *table) +bool wxResourceParseFile(const wxString& filename, wxResourceTable *table) { if (!table) table = wxDefaultResourceTable; - + return table->ParseResourceFile(filename); } // Register XBM/XPM data -bool wxResourceRegisterBitmapData(char *name, char bits[], int width, int height, wxResourceTable *table) +bool wxResourceRegisterBitmapData(const wxString& name, char bits[], int width, int height, wxResourceTable *table) { if (!table) table = wxDefaultResourceTable; - + return table->RegisterResourceBitmapData(name, bits, width, height); } -bool wxResourceRegisterBitmapData(char *name, char **data, wxResourceTable *table) +bool wxResourceRegisterBitmapData(const wxString& name, char **data, wxResourceTable *table) { if (!table) table = wxDefaultResourceTable; @@ -2428,20 +2469,20 @@ void wxResourceClear(wxResourceTable *table) * Identifiers */ -bool wxResourceAddIdentifier(char *name, int value, wxResourceTable *table) +bool wxResourceAddIdentifier(const wxString& name, int value, wxResourceTable *table) { if (!table) table = wxDefaultResourceTable; - + table->identifiers.Put(name, (wxObject *)value); return TRUE; } -int wxResourceGetIdentifier(char *name, wxResourceTable *table) +int wxResourceGetIdentifier(const wxString& name, wxResourceTable *table) { if (!table) table = wxDefaultResourceTable; - + return (int)table->identifiers.Get(name); } @@ -2449,12 +2490,12 @@ int wxResourceGetIdentifier(char *name, wxResourceTable *table) * Parse #include file for #defines (only) */ -bool wxResourceParseIncludeFile(char *f, wxResourceTable *table) +bool wxResourceParseIncludeFile(const wxString& f, wxResourceTable *table) { if (!table) table = wxDefaultResourceTable; - - FILE *fd = fopen(f, "r"); + + FILE *fd = fopen(f.fn_str(), "r"); if (!fd) { return FALSE; @@ -2464,12 +2505,12 @@ bool wxResourceParseIncludeFile(char *f, wxResourceTable *table) if (strcmp(wxResourceBuffer, "#define") == 0) { wxGetResourceToken(fd); - char *name = copystring(wxResourceBuffer); + wxChar *name = copystring(wxConv_libc.cMB2WX(wxResourceBuffer)); wxGetResourceToken(fd); - char *value = copystring(wxResourceBuffer); - if (isdigit(value[0])) + wxChar *value = copystring(wxConv_libc.cMB2WX(wxResourceBuffer)); + if (wxIsdigit(value[0])) { - int val = (int)atol(value); + int val = (int)wxAtol(value); wxResourceAddIdentifier(name, val, table); } delete[] name; @@ -2496,7 +2537,7 @@ static int getc_string(char *s) } } -static int ungetc_string(void) +static int ungetc_string() { wxResourceStringPtr --; return 0; @@ -2507,7 +2548,7 @@ bool wxEatWhiteSpaceString(char *s) int ch = getc_string(s); if (ch == EOF) return TRUE; - + if ((ch != ' ') && (ch != '/') && (ch != ' ') && (ch != 10) && (ch != 13) && (ch != 9)) { ungetc_string(); @@ -2602,7 +2643,7 @@ bool wxGetResourceTokenString(char *s) wxReallocateResourceBuffer(); wxResourceBuffer[wxResourceBufferCount] = (char)ch; wxResourceBufferCount ++; - + ch = getc_string(s); } wxResourceBuffer[wxResourceBufferCount] = 0; @@ -2617,12 +2658,12 @@ bool wxGetResourceTokenString(char *s) static char *name = "...."; with possible comments. */ - -bool wxResourceReadOneResourceString(char *s, PrologDatabase& db, bool *eof, wxResourceTable *table) + +bool wxResourceReadOneResourceString(char *s, wxExprDatabase& db, bool *eof, wxResourceTable *table) { if (!table) table = wxDefaultResourceTable; - + // static or #define if (!wxGetResourceTokenString(s)) { @@ -2633,26 +2674,24 @@ bool wxResourceReadOneResourceString(char *s, PrologDatabase& db, bool *eof, wxR if (strcmp(wxResourceBuffer, "#define") == 0) { wxGetResourceTokenString(s); - char *name = copystring(wxResourceBuffer); + wxChar *name = copystring(wxConv_libc.cMB2WX(wxResourceBuffer)); wxGetResourceTokenString(s); - char *value = copystring(wxResourceBuffer); - if (isalpha(value[0])) + wxChar *value = copystring(wxConv_libc.cMB2WX(wxResourceBuffer)); + if (wxIsalpha(value[0])) { - int val = (int)atol(value); + int val = (int)wxAtol(value); wxResourceAddIdentifier(name, val, table); } else { - char buf[300]; - sprintf(buf, "#define %s must be an integer.", name); - wxWarning(buf); + wxLogWarning(_("#define %s must be an integer."), name); delete[] name; delete[] value; return FALSE; } delete[] name; delete[] value; - + return TRUE; } /* @@ -2669,8 +2708,8 @@ bool wxResourceReadOneResourceString(char *s, PrologDatabase& db, bool *eof, wxR if (!wxResourceParseIncludeFile(actualName, table)) { char buf[400]; - sprintf(buf, "Could not find resource include file %s.", actualName); - wxWarning(buf); + sprintf(buf, _("Could not find resource include file %s."), actualName); + wxLogWarning(buf); } delete[] name; return TRUE; @@ -2678,62 +2717,63 @@ bool wxResourceReadOneResourceString(char *s, PrologDatabase& db, bool *eof, wxR */ else if (strcmp(wxResourceBuffer, "static") != 0) { - char buf[300]; - strcpy(buf, "Found "); - strncat(buf, wxResourceBuffer, 30); - strcat(buf, ", expected static, #include or #define\nwhilst parsing resource."); - wxWarning(buf); + wxChar buf[300]; + wxStrcpy(buf, _("Found ")); + wxStrncat(buf, wxConv_libc.cMB2WX(wxResourceBuffer), 30); + wxStrcat(buf, _(", expected static, #include or #define\nwhilst parsing resource.")); + wxLogWarning(buf); return FALSE; } // char if (!wxGetResourceTokenString(s)) { - wxWarning("Unexpected end of file whilst parsing resource."); + wxLogWarning(_("Unexpected end of file whilst parsing resource.")); *eof = TRUE; return FALSE; } if (strcmp(wxResourceBuffer, "char") != 0) { - wxWarning("Expected 'char' whilst parsing resource."); + wxLogWarning(_("Expected 'char' whilst parsing resource.")); return FALSE; } - + // *name if (!wxGetResourceTokenString(s)) { - wxWarning("Unexpected end of file whilst parsing resource."); + wxLogWarning(_("Unexpected end of file whilst parsing resource.")); *eof = TRUE; return FALSE; } if (wxResourceBuffer[0] != '*') { - wxWarning("Expected '*' whilst parsing resource."); + wxLogWarning(_("Expected '*' whilst parsing resource.")); return FALSE; } - char nameBuf[100]; - strncpy(nameBuf, wxResourceBuffer+1, 99); - + wxChar nameBuf[100]; + wxMB2WX(nameBuf, wxResourceBuffer+1, 99); + nameBuf[99] = 0; + // = if (!wxGetResourceTokenString(s)) { - wxWarning("Unexpected end of file whilst parsing resource."); + wxLogWarning(_("Unexpected end of file whilst parsing resource.")); *eof = TRUE; return FALSE; } if (strcmp(wxResourceBuffer, "=") != 0) { - wxWarning("Expected '=' whilst parsing resource."); + wxLogWarning(_("Expected '=' whilst parsing resource.")); return FALSE; } // String if (!wxGetResourceTokenString(s)) { - wxWarning("Unexpected end of file whilst parsing resource."); + wxLogWarning(_("Unexpected end of file whilst parsing resource.")); *eof = TRUE; return FALSE; } @@ -2741,9 +2781,7 @@ bool wxResourceReadOneResourceString(char *s, PrologDatabase& db, bool *eof, wxR { if (!db.ReadPrologFromString(wxResourceBuffer)) { - char buf[300]; - sprintf(buf, "%s: ill-formed resource file syntax.", nameBuf); - wxWarning(buf); + wxLogWarning(_("%s: ill-formed resource file syntax."), nameBuf); return FALSE; } } @@ -2759,11 +2797,11 @@ bool wxResourceParseString(char *s, wxResourceTable *table) { if (!table) table = wxDefaultResourceTable; - + if (!s) return FALSE; - - // Turn backslashes into spaces + + // Turn backslashes into spaces if (s) { int len = strlen(s); @@ -2776,7 +2814,7 @@ bool wxResourceParseString(char *s, wxResourceTable *table) } } - PrologDatabase db; + wxExprDatabase db; wxResourceStringPtr = 0; bool eof = FALSE; @@ -2795,67 +2833,100 @@ bool wxWindow::LoadFromResource(wxWindow *parent, const wxString& resourceName, { if (!table) table = wxDefaultResourceTable; - - wxItemResource *resource = table->FindResource((const char *)resourceName); + + wxItemResource *resource = table->FindResource((const wxChar *)resourceName); // if (!resource || (resource->GetType() != wxTYPE_DIALOG_BOX)) - if (!resource || !resource->GetType() || - ! ((strcmp(resource->GetType(), "wxDialog") == 0) || (strcmp(resource->GetType(), "wxPanel") == 0))) + if (!resource || (resource->GetType() == _T("")) || + ! ((resource->GetType() == _T("wxDialog")) || (resource->GetType() == _T("wxPanel")))) return FALSE; - char *title = resource->GetTitle(); + wxString title(resource->GetTitle()); long theWindowStyle = resource->GetStyle(); bool isModal = (resource->GetValue1() != 0); int x = resource->GetX(); int y = resource->GetY(); int width = resource->GetWidth(); int height = resource->GetHeight(); - char *name = resource->GetName(); - - wxFont *theFont = resource->GetFont(); + wxString name = resource->GetName(); if (IsKindOf(CLASSINFO(wxDialog))) { wxDialog *dialogBox = (wxDialog *)this; - long modalStyle = isModal ? wxDIALOG_MODAL : 0; + long modalStyle = isModal ? wxDIALOG_MODAL : 0; if (!dialogBox->Create(parent, -1, title, wxPoint(x, y), wxSize(width, height), theWindowStyle|modalStyle, name)) return FALSE; + + // Only reset the client size if we know we're not going to do it again below. + if ((resource->GetResourceStyle() & wxRESOURCE_DIALOG_UNITS) == 0) + dialogBox->SetClientSize(width, height); + } + else if (IsKindOf(CLASSINFO(wxPanel))) + { + wxPanel* panel = (wxPanel *)this; + if (!panel->Create(parent, -1, wxPoint(x, y), wxSize(width, height), theWindowStyle, name)) + return FALSE; } else { - if (!((wxWindow *)this)->Create(parent, -1, wxPoint(x, y), wxSize(width, height), theWindowStyle, name)) + if (!this->Create(parent, -1, wxPoint(x, y), wxSize(width, height), theWindowStyle, name)) return FALSE; } - if (theFont) - SetFont(*theFont); + if ((resource->GetResourceStyle() & wxRESOURCE_USE_DEFAULTS) != 0) + { + // No need to do this since it's done in wxPanel or wxDialog constructor. + // SetFont(wxSystemSettings::GetSystemFont(wxSYS_DEFAULT_GUI_FONT)); + } + else + { + if (resource->GetFont().Ok()) + SetFont(resource->GetFont()); + if (resource->GetBackgroundColour().Ok()) + SetBackgroundColour(resource->GetBackgroundColour()); + } + + // Should have some kind of font at this point + if (!GetFont().Ok()) + SetFont(wxSystemSettings::GetSystemFont(wxSYS_DEFAULT_GUI_FONT)); + if (!GetBackgroundColour().Ok()) + SetBackgroundColour(wxSystemSettings::GetSystemColour(wxSYS_COLOUR_3DFACE)); - if (resource->GetBackgroundColour()) - SetBackgroundColour(*resource->GetBackgroundColour()); + // Only when we've created the window and set the font can we set the correct size, + // if based on dialog units. + if ((resource->GetResourceStyle() & wxRESOURCE_DIALOG_UNITS) != 0) + { + wxSize sz = ConvertDialogToPixels(wxSize(width, height)); + SetClientSize(sz.x, sz.y); + + wxPoint pt = ConvertDialogToPixels(wxPoint(x, y)); + Move(pt.x, pt.y); + } - // TODO - if (resource->GetLabelColour()) - SetForegroundColour(*resource->GetLabelColour()); - else if (resource->GetButtonColour()) - SetForegroundColour(*resource->GetButtonColour()); - // Now create children wxNode *node = resource->GetChildren().First(); while (node) { wxItemResource *childResource = (wxItemResource *)node->Data(); - - (void) CreateItem(childResource, table); + + (void) CreateItem(childResource, resource, table); node = node->Next(); } return TRUE; } -wxControl *wxWindow::CreateItem(const wxItemResource *resource, const wxResourceTable *table) +wxControl *wxWindow::CreateItem(const wxItemResource *resource, const wxItemResource* parentResource, const wxResourceTable *table) { if (!table) table = wxDefaultResourceTable; - return table->CreateItem((wxWindow *)this, (wxItemResource *)resource); + return table->CreateItem((wxWindow *)this, resource, parentResource); } -#endif // USE_WX_RESOURCES +#ifdef __VISUALC__ + #pragma warning(default:4706) // assignment within conditional expression +#endif // VC++ + +#endif + // BC++/Win16 + +#endif // wxUSE_WX_RESOURCES