X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/75ed1d15d0d866cac78f7c0da176db8dd5288bc8..1eddcfafba914bff0c9674985d5c8a7205a741c6:/src/common/resource.cpp diff --git a/src/common/resource.cpp b/src/common/resource.cpp index ecc8121d7d..031a211c74 100644 --- a/src/common/resource.cpp +++ b/src/common/resource.cpp @@ -20,6 +20,12 @@ #pragma hdrstop #endif +#if wxUSE_WX_RESOURCES + +#ifdef _MSC_VER + #pragma warning(disable:4706) // assignment within conditional expression +#endif // VC++ + #ifndef WX_PRECOMP #include "wx/defs.h" #include "wx/setup.h" @@ -33,12 +39,14 @@ #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" +#include "wx/statbmp.h" #if wxUSE_GAUGE #include "wx/gauge.h" #endif @@ -47,6 +55,10 @@ #include "wx/intl.h" #endif +#if wxUSE_RADIOBUTTON +#include "wx/radiobut.h" +#endif + #if wxUSE_SCROLLBAR #include "wx/scrolbar.h" #endif @@ -59,8 +71,6 @@ #include "wx/log.h" -#if wxUSE_WX_RESOURCES - #include #include #include @@ -89,10 +99,10 @@ bool wxResourceParseIncludeFile(const wxString& f, wxResourceTable *table = (wxR wxResourceTable *wxDefaultResourceTable = (wxResourceTable *) NULL; -static char *wxResourceBuffer = (char *) 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() { @@ -144,7 +154,7 @@ wxItemResource::~wxItemResource() /* * Resource table */ - + wxResourceTable::wxResourceTable():wxHashTable(wxKEY_STRING), identifiers(wxKEY_STRING) { } @@ -153,7 +163,7 @@ wxResourceTable::~wxResourceTable() { ClearTable(); } - + wxItemResource *wxResourceTable::FindResource(const wxString& name) const { wxItemResource *item = (wxItemResource *)Get((char *)(const char *)name); @@ -192,7 +202,7 @@ bool wxResourceTable::DeleteResource(const wxString& name) break; } } - + delete item; return TRUE; } @@ -375,10 +385,15 @@ wxControl *wxResourceTable::CreateItem(wxWindow *parent, const wxItemResource* c { 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")) @@ -544,17 +559,33 @@ bool wxResourceInterpretResources(wxResourceTable& table, wxExprDatabase& 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 char *g_ValidControlClasses[] = +{ + "wxButton", + "wxBitmapButton", + "wxMessage", + "wxStaticText", + "wxStaticBitmap", + "wxText", + "wxTextCtrl", + "wxMultiText", + "wxListBox", + "wxRadioBox", + "wxRadioButton", + "wxCheckBox", + "wxBitmapCheckBox", + "wxGroupBox", + "wxStaticBox", + "wxSlider", + "wxGauge", + "wxScrollBar", + "wxChoice", + "wxComboBox" +}; static bool wxIsValidControlClass(const wxString& c) { - int i; - for ( i = 0; i < g_ValidControlClassesCount; i++) + for ( size_t i = 0; i < WXSIZEOF(g_ValidControlClasses); i++ ) { if ( c == g_ValidControlClasses[i] ) return TRUE; @@ -579,7 +610,7 @@ wxItemResource *wxResourceInterpretDialog(wxResourceTable& table, wxExpr *expr, long windowStyle = wxDEFAULT_DIALOG_STYLE; if (isPanel) windowStyle = 0; - + int x = 0; int y = 0; int width = -1; int height = -1; int isModal = 0; wxExpr *labelFontExpr = (wxExpr *) NULL; @@ -623,7 +654,7 @@ wxItemResource *wxResourceInterpretDialog(wxResourceTable& table, wxExpr *expr, dialogItem->SetName(name); dialogItem->SetTitle(title); dialogItem->SetSize(x, y, width, height); - + if (backColourHex != "") { int r = 0; @@ -788,6 +819,19 @@ wxItemResource *wxResourceInterpretControl(wxResourceTable& table, wxExpr *expr) controlItem->SetId(id); if (controlType == "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()); + controlItem->SetValue4(str); + count ++; + controlItem->SetType("wxBitmapButton"); + } + if (expr->Nth(count) && expr->Nth(count)->Type() == PrologList) + controlItem->SetFont(wxResourceInterpretFontSpec(expr->Nth(count))); + } + else if (controlType == "wxBitmapButton") { // Check for bitmap resource name if (expr->Nth(count) && ((expr->Nth(count)->Type() == PrologString) || (expr->Nth(count)->Type() == PrologWord))) @@ -843,6 +887,19 @@ wxItemResource *wxResourceInterpretControl(wxResourceTable& table, wxExpr *expr) } } else if (controlType == "wxMessage" || controlType == "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("wxStaticText"); + } + if (expr->Nth(count) && expr->Nth(count)->Type() == PrologList) + controlItem->SetFont(wxResourceInterpretFontSpec(expr->Nth(count))); + } + else if (controlType == "wxStaticBitmap") { // Check for bitmap resource name if (expr->Nth(count) && ((expr->Nth(count)->Type() == PrologString) || (expr->Nth(count)->Type() == PrologWord))) @@ -850,9 +907,9 @@ wxItemResource *wxResourceInterpretControl(wxResourceTable& table, wxExpr *expr) 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") { @@ -960,26 +1017,31 @@ wxItemResource *wxResourceInterpretControl(wxResourceTable& table, wxExpr *expr) } controlItem->SetStringValues(stringList); count ++; - +// This is now obsolete: it's in the window style. // Check for wxSINGLE/wxMULTIPLE 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); +*/ + // Ignore the value count ++; - if (expr->Nth(count) && expr->Nth(count)->Type() == PrologList) - { - // controlItem->SetLabelFont(wxResourceInterpretFontSpec(expr->Nth(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))); - } - } + if (expr->Nth(count) && expr->Nth(count)->Type() == PrologList) + controlItem->SetFont(wxResourceInterpretFontSpec(expr->Nth(count))); + } } } else if (controlType == "wxChoice") @@ -1019,7 +1081,7 @@ wxItemResource *wxResourceInterpretControl(wxResourceTable& table, wxExpr *expr) controlItem->SetValue4(str); count ++; - + wxExpr *valueList = (wxExpr *) NULL; // Check for default value list if ((valueList = expr->Nth(count)) && (valueList->Type() == PrologList)) @@ -1092,7 +1154,7 @@ wxItemResource *wxResourceInterpretControl(wxResourceTable& table, wxExpr *expr) return controlItem; } -// Forward declaration +// Forward declaration wxItemResource *wxResourceInterpretMenu1(wxResourceTable& table, wxExpr *expr); /* @@ -1102,7 +1164,7 @@ wxItemResource *wxResourceInterpretMenu1(wxResourceTable& table, wxExpr *expr); wxItemResource *wxResourceInterpretMenuItem(wxResourceTable& table, wxExpr *expr) { wxItemResource *item = new wxItemResource; - + wxExpr *labelExpr = expr->Nth(0); wxExpr *idExpr = expr->Nth(1); wxExpr *helpExpr = expr->Nth(2); @@ -1156,7 +1218,7 @@ wxItemResource *wxResourceInterpretMenuItem(wxResourceTable& table, wxExpr *expr wxExpr *subMenuExpr = expr->GetFirst(); while (subMenuExpr && (subMenuExpr->Type() != PrologList)) subMenuExpr = subMenuExpr->GetNext(); - + while (subMenuExpr) { wxItemResource *child = wxResourceInterpretMenuItem(table, subMenuExpr); @@ -1194,7 +1256,7 @@ wxItemResource *wxResourceInterpretMenu(wxResourceTable& table, wxExpr *expr) expr->GetAttributeValue("menu", &listExpr); if (!listExpr) return (wxItemResource *) NULL; - + wxItemResource *menuResource = wxResourceInterpretMenuItem(table, listExpr); if (!menuResource) @@ -1205,7 +1267,7 @@ wxItemResource *wxResourceInterpretMenu(wxResourceTable& table, wxExpr *expr) { menuResource->SetName(name); } - + return menuResource; } @@ -1219,7 +1281,7 @@ wxItemResource *wxResourceInterpretMenuBar(wxResourceTable& table, wxExpr *expr) wxItemResource *resource = new wxItemResource; resource->SetType("wxMenu"); // resource->SetType(wxTYPE_MENU); - + wxExpr *element = listExpr->GetFirst(); while (element) { @@ -1233,7 +1295,7 @@ wxItemResource *wxResourceInterpretMenuBar(wxResourceTable& table, wxExpr *expr) { resource->SetName(name); } - + return resource; } @@ -1277,18 +1339,18 @@ wxItemResource *wxResourceInterpretBitmap(wxResourceTable& WXUNUSED(table), wxEx wxExpr *coloursExpr = listExpr->Nth(3); wxExpr *xresExpr = listExpr->Nth(4); wxExpr *yresExpr = listExpr->Nth(5); - if (nameExpr && nameExpr->StringValue()) + if (nameExpr && nameExpr->StringValue() != "") { bitmapSpec->SetName(nameExpr->StringValue()); } - if (typeExpr && typeExpr->StringValue()) + if (typeExpr && typeExpr->StringValue() != "") { bitmapSpec->SetValue1(wxParseWindowStyle(typeExpr->StringValue())); } else bitmapSpec->SetValue1(0); - - if (platformExpr && platformExpr->StringValue()) + + if (platformExpr && platformExpr->StringValue() != "") { wxString plat(platformExpr->StringValue()); if (plat == "windows" || plat == "WINDOWS") @@ -1312,14 +1374,14 @@ wxItemResource *wxResourceInterpretBitmap(wxResourceTable& WXUNUSED(table), wxEx if (yresExpr) yres = (int)yresExpr->IntegerValue(); bitmapSpec->SetSize(0, 0, xres, yres); - + bitmapItem->GetChildren().Append(bitmapSpec); } } } bitmapExpr = bitmapExpr->GetNext(); } - + return bitmapItem; } @@ -1348,7 +1410,7 @@ wxFont wxResourceInterpretFontSpec(wxExpr *expr) int weight = wxNORMAL; int underline = 0; wxString faceName(""); - + wxExpr *pointExpr = expr->Nth(0); wxExpr *familyExpr = expr->Nth(1); wxExpr *styleExpr = expr->Nth(2); @@ -1383,6 +1445,9 @@ wxFont wxResourceInterpretFontSpec(wxExpr *expr) 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 */ @@ -1504,7 +1569,7 @@ bool wxGetResourceToken(FILE *fd) wxReallocateResourceBuffer(); wxResourceBuffer[wxResourceBufferCount] = (char)ch; wxResourceBufferCount ++; - + ch = getc(fd); } wxResourceBuffer[wxResourceBufferCount] = 0; @@ -1519,12 +1584,12 @@ bool wxGetResourceToken(FILE *fd) static char *name = "...."; with possible comments. */ - + bool wxResourceReadOneResource(FILE *fd, wxExprDatabase& db, bool *eof, wxResourceTable *table) { if (!table) table = wxDefaultResourceTable; - + // static or #define if (!wxGetResourceToken(fd)) { @@ -1552,7 +1617,7 @@ bool wxResourceReadOneResource(FILE *fd, wxExprDatabase& db, bool *eof, wxResour } delete[] name; delete[] value; - + return TRUE; } else if (strcmp(wxResourceBuffer, "#include") == 0) @@ -1595,7 +1660,7 @@ bool wxResourceReadOneResource(FILE *fd, wxExprDatabase& db, bool *eof, wxResour wxLogWarning(_("Expected 'char' whilst parsing resource.")); return FALSE; } - + // *name if (!wxGetResourceToken(fd)) { @@ -1611,7 +1676,7 @@ bool wxResourceReadOneResource(FILE *fd, wxExprDatabase& db, bool *eof, wxResour } char nameBuf[100]; strncpy(nameBuf, wxResourceBuffer+1, 99); - + // = if (!wxGetResourceToken(fd)) { @@ -1652,7 +1717,7 @@ bool wxResourceReadOneResource(FILE *fd, wxExprDatabase& db, bool *eof, wxResour /* * Parses string window style into integer window style */ - + /* * Style flag parsing, e.g. * "wxSYSTEM_MENU | wxBORDER" -> integer @@ -1708,13 +1773,13 @@ static wxResourceBitListStruct wxResourceBitListTable[] = { "wxLB_SORT", wxLB_SORT }, { "wxLB_OWNERDRAW", wxLB_OWNERDRAW }, { "wxLB_HSCROLL", wxLB_HSCROLL }, - + /* wxComboxBox */ { "wxCB_SIMPLE", wxCB_SIMPLE }, { "wxCB_DROPDOWN", wxCB_DROPDOWN }, { "wxCB_READONLY", wxCB_READONLY }, { "wxCB_SORT", wxCB_SORT }, - + /* wxGauge */ { "wxGA_PROGRESSBAR", wxGA_PROGRESSBAR }, { "wxGA_HORIZONTAL", wxGA_HORIZONTAL }, @@ -1730,6 +1795,8 @@ static wxResourceBitListStruct wxResourceBitListTable[] = /* wxRadioBox/wxRadioButton */ { "wxRB_GROUP", wxRB_GROUP }, + { "wxRA_SPECIFY_COLS", wxRA_SPECIFY_COLS }, + { "wxRA_SPECIFY_ROWS", wxRA_SPECIFY_ROWS }, { "wxRA_HORIZONTAL", wxRA_HORIZONTAL }, { "wxRA_VERTICAL", wxRA_VERTICAL }, @@ -1801,7 +1868,7 @@ static wxResourceBitListStruct wxResourceBitListTable[] = { "wxALIGN_CENTRE", wxALIGN_CENTRE}, { "wxALIGN_RIGHT", wxALIGN_RIGHT}, { "wxCOLOURED", wxCOLOURED}, - + /* wxToolBar */ { "wxTB_3DBUTTONS", wxTB_3DBUTTONS}, { "wxTB_HORIZONTAL", wxTB_HORIZONTAL}, @@ -1825,7 +1892,8 @@ static wxResourceBitListStruct wxResourceBitListTable[] = { "wxMINIMIZE_BOX", wxMINIMIZE_BOX}, { "wxMAXIMIZE_BOX", wxMAXIMIZE_BOX}, { "wxRESIZE_BOX", wxRESIZE_BOX}, - { "wxDEFAULT_FRAME", wxDEFAULT_FRAME}, + { "wxDEFAULT_FRAME_STYLE", wxDEFAULT_FRAME_STYLE}, + { "wxDEFAULT_FRAME", wxDEFAULT_FRAME_STYLE}, { "wxDEFAULT_DIALOG_STYLE", wxDEFAULT_DIALOG_STYLE}, { "wxBORDER", wxBORDER}, { "wxRETAINED", wxRETAINED}, @@ -1975,16 +2043,16 @@ long wxParseWindowStyle(const wxString& bitListString) * Load a bitmap from a wxWindows resource, choosing an optimum * depth and appropriate type. */ - + 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")) { wxLogWarning(_("%s not a bitmap resource specification."), (const char*) resource); return wxNullBitmap; @@ -1993,7 +2061,7 @@ wxBitmap wxResourceCreateBitmap(const wxString& resource, wxResourceTable *table long thisNoColours = (long)pow(2.0, (double)thisDepth); wxItemResource *optResource = (wxItemResource *) NULL; - + // Try to find optimum bitmap for this platform/colour depth wxNode *node = item->GetChildren().First(); while (node) @@ -2087,7 +2155,7 @@ wxBitmap wxResourceCreateBitmap(const wxString& resource, wxResourceTable *table { wxLogWarning(_("Failed to find XBM resource %s.\n" "Forgot to use wxResourceLoadBitmapData?"), (const char*) name); - return (wxBitmap *) NULL; + return wxNullBitmap; } return wxBitmap(item->GetValue1(), (int)item->GetValue2(), (int)item->GetValue3()) ; #else @@ -2103,7 +2171,7 @@ wxBitmap wxResourceCreateBitmap(const wxString& resource, wxResourceTable *table { wxLogWarning(_("Failed to find XPM resource %s.\n" "Forgot to use wxResourceLoadBitmapData?"), (const char*) name); - return (wxBitmap *) NULL; + return wxNullBitmap; } return wxBitmap(item->GetValue1()); #else @@ -2130,12 +2198,12 @@ wxBitmap wxResourceCreateBitmap(const wxString& resource, wxResourceTable *table * Load an icon from a wxWindows resource, choosing an optimum * depth and appropriate type. */ - + wxIcon wxResourceCreateIcon(const wxString& resource, wxResourceTable *table) { if (!table) table = wxDefaultResourceTable; - + wxItemResource *item = table->FindResource(resource); if (item) { @@ -2148,7 +2216,7 @@ wxIcon wxResourceCreateIcon(const wxString& resource, wxResourceTable *table) long thisNoColours = (long)pow(2.0, (double)thisDepth); wxItemResource *optResource = (wxItemResource *) NULL; - + // Try to find optimum icon for this platform/colour depth wxNode *node = item->GetChildren().First(); while (node) @@ -2242,9 +2310,9 @@ wxIcon wxResourceCreateIcon(const wxString& resource, wxResourceTable *table) { wxLogWarning(_("Failed to find XBM resource %s.\n" "Forgot to use wxResourceLoadIconData?"), (const char*) name); - return (wxIcon *) NULL; + return wxNullIcon; } - return wxIcon((char **)item->GetValue1(), (int)item->GetValue2(), (int)item->GetValue3()); + return wxIcon((const char **)item->GetValue1(), (int)item->GetValue2(), (int)item->GetValue3()); #else wxLogWarning(_("No XBM facility available!")); #endif @@ -2286,7 +2354,7 @@ wxIcon wxResourceCreateIcon(const wxString& resource, wxResourceTable *table) else { wxLogWarning(_("Icon resource specification %s not found."), (const char*) resource); - return (wxIcon *) NULL; + return wxNullIcon; } } @@ -2318,7 +2386,7 @@ wxMenuBar *wxResourceCreateMenuBar(const wxString& resource, wxResourceTable *ta { if (!table) table = wxDefaultResourceTable; - + wxItemResource *menuResource = table->FindResource(resource); if (menuResource && (menuResource->GetType() != "") && (menuResource->GetType() == "wxMenu")) { @@ -2342,7 +2410,7 @@ wxMenu *wxResourceCreateMenu(const wxString& resource, wxResourceTable *table) { if (!table) table = wxDefaultResourceTable; - + wxItemResource *menuResource = table->FindResource(resource); if (menuResource && (menuResource->GetType() != "") && (menuResource->GetType() == "wxMenu")) // if (menuResource && (menuResource->GetType() == wxTYPE_MENU)) @@ -2355,7 +2423,7 @@ bool wxResourceParseData(const wxString& resource, wxResourceTable *table) { if (!table) table = wxDefaultResourceTable; - + return table->ParseResourceData(resource); } @@ -2363,7 +2431,7 @@ bool wxResourceParseFile(const wxString& filename, wxResourceTable *table) { if (!table) table = wxDefaultResourceTable; - + return table->ParseResourceFile(filename); } @@ -2372,7 +2440,7 @@ bool wxResourceRegisterBitmapData(const wxString& name, char bits[], int width, { if (!table) table = wxDefaultResourceTable; - + return table->RegisterResourceBitmapData(name, bits, width, height); } @@ -2400,7 +2468,7 @@ bool wxResourceAddIdentifier(const wxString& name, int value, wxResourceTable *t { if (!table) table = wxDefaultResourceTable; - + table->identifiers.Put(name, (wxObject *)value); return TRUE; } @@ -2409,7 +2477,7 @@ int wxResourceGetIdentifier(const wxString& name, wxResourceTable *table) { if (!table) table = wxDefaultResourceTable; - + return (int)table->identifiers.Get(name); } @@ -2421,7 +2489,7 @@ bool wxResourceParseIncludeFile(const wxString& f, wxResourceTable *table) { if (!table) table = wxDefaultResourceTable; - + FILE *fd = fopen(f, "r"); if (!fd) { @@ -2475,7 +2543,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(); @@ -2570,7 +2638,7 @@ bool wxGetResourceTokenString(char *s) wxReallocateResourceBuffer(); wxResourceBuffer[wxResourceBufferCount] = (char)ch; wxResourceBufferCount ++; - + ch = getc_string(s); } wxResourceBuffer[wxResourceBufferCount] = 0; @@ -2585,12 +2653,12 @@ bool wxGetResourceTokenString(char *s) static char *name = "...."; with possible comments. */ - + bool wxResourceReadOneResourceString(char *s, wxExprDatabase& db, bool *eof, wxResourceTable *table) { if (!table) table = wxDefaultResourceTable; - + // static or #define if (!wxGetResourceTokenString(s)) { @@ -2618,7 +2686,7 @@ bool wxResourceReadOneResourceString(char *s, wxExprDatabase& db, bool *eof, wxR } delete[] name; delete[] value; - + return TRUE; } /* @@ -2665,7 +2733,7 @@ bool wxResourceReadOneResourceString(char *s, wxExprDatabase& db, bool *eof, wxR wxLogWarning(_("Expected 'char' whilst parsing resource.")); return FALSE; } - + // *name if (!wxGetResourceTokenString(s)) { @@ -2681,7 +2749,7 @@ bool wxResourceReadOneResourceString(char *s, wxExprDatabase& db, bool *eof, wxR } char nameBuf[100]; strncpy(nameBuf, wxResourceBuffer+1, 99); - + // = if (!wxGetResourceTokenString(s)) { @@ -2723,11 +2791,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); @@ -2759,11 +2827,11 @@ bool wxWindow::LoadFromResource(wxWindow *parent, const wxString& resourceName, { if (!table) table = wxDefaultResourceTable; - + wxItemResource *resource = table->FindResource((const char *)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() == "") || + ! ((resource->GetType() == "wxDialog") || (resource->GetType() == "wxPanel"))) return FALSE; wxString title(resource->GetTitle()); @@ -2812,7 +2880,7 @@ bool wxWindow::LoadFromResource(wxWindow *parent, const wxString& resourceName, } // Should have some kind of font at this point - if (!GetFont()->Ok()) + if (!GetFont().Ok()) SetFont(wxSystemSettings::GetSystemFont(wxSYS_DEFAULT_GUI_FONT)); if (!GetBackgroundColour().Ok()) SetBackgroundColour(wxSystemSettings::GetSystemColour(wxSYS_COLOUR_3DFACE)); @@ -2833,7 +2901,7 @@ bool wxWindow::LoadFromResource(wxWindow *parent, const wxString& resourceName, while (node) { wxItemResource *childResource = (wxItemResource *)node->Data(); - + (void) CreateItem(childResource, resource, table); node = node->Next(); @@ -2848,4 +2916,11 @@ wxControl *wxWindow::CreateItem(const wxItemResource *resource, const wxItemReso return table->CreateItem((wxWindow *)this, resource, parentResource); } +#ifdef _MSC_VER + #pragma warning(default:4706) // assignment within conditional expression +#endif // VC++ + +#endif + // BC++/Win16 + #endif // wxUSE_WX_RESOURCES