X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/fd71308fc89eac2dd212b715eba68a993fa78f53..a0d8a3052817fef6eef27e9a6ab8802495a39db8:/src/common/resource.cpp diff --git a/src/common/resource.cpp b/src/common/resource.cpp index 9198586a1f..ac44cbc882 100644 --- a/src/common/resource.cpp +++ b/src/common/resource.cpp @@ -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" @@ -33,11 +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 @@ -46,6 +55,10 @@ #include "wx/intl.h" #endif +#if wxUSE_RADIOBUTTON +#include "wx/radiobut.h" +#endif + #if wxUSE_SCROLLBAR #include "wx/scrolbar.h" #endif @@ -58,8 +71,6 @@ #include "wx/log.h" -#if wxUSE_WX_RESOURCES - #include #include #include @@ -69,6 +80,8 @@ #include "wx/string.h" #include "wx/wxexpr.h" +#include "wx/settings.h" + // Forward (private) declarations bool wxResourceInterpretResources(wxResourceTable& table, wxExprDatabase& db); wxItemResource *wxResourceInterpretDialog(wxResourceTable& table, wxExpr *expr, bool isPanel = FALSE); @@ -86,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() { @@ -141,7 +154,7 @@ wxItemResource::~wxItemResource() /* * Resource table */ - + wxResourceTable::wxResourceTable():wxHashTable(wxKEY_STRING), identifiers(wxKEY_STRING) { } @@ -150,7 +163,7 @@ wxResourceTable::~wxResourceTable() { ClearTable(); } - + wxItemResource *wxResourceTable::FindResource(const wxString& name) const { wxItemResource *item = (wxItemResource *)Get((char *)(const char *)name); @@ -189,7 +202,7 @@ bool wxResourceTable::DeleteResource(const wxString& name) break; } } - + delete item; return TRUE; } @@ -372,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")) @@ -541,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; @@ -576,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; @@ -620,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; @@ -785,6 +819,23 @@ 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()); + count ++; + + if (str != "") + { + controlItem->SetValue4(str); + 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))) @@ -840,6 +891,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))) @@ -847,9 +911,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") { @@ -957,26 +1021,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") @@ -1016,7 +1085,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)) @@ -1089,7 +1158,7 @@ wxItemResource *wxResourceInterpretControl(wxResourceTable& table, wxExpr *expr) return controlItem; } -// Forward declaration +// Forward declaration wxItemResource *wxResourceInterpretMenu1(wxResourceTable& table, wxExpr *expr); /* @@ -1099,7 +1168,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); @@ -1153,7 +1222,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); @@ -1191,7 +1260,7 @@ wxItemResource *wxResourceInterpretMenu(wxResourceTable& table, wxExpr *expr) expr->GetAttributeValue("menu", &listExpr); if (!listExpr) return (wxItemResource *) NULL; - + wxItemResource *menuResource = wxResourceInterpretMenuItem(table, listExpr); if (!menuResource) @@ -1202,7 +1271,7 @@ wxItemResource *wxResourceInterpretMenu(wxResourceTable& table, wxExpr *expr) { menuResource->SetName(name); } - + return menuResource; } @@ -1216,7 +1285,7 @@ wxItemResource *wxResourceInterpretMenuBar(wxResourceTable& table, wxExpr *expr) wxItemResource *resource = new wxItemResource; resource->SetType("wxMenu"); // resource->SetType(wxTYPE_MENU); - + wxExpr *element = listExpr->GetFirst(); while (element) { @@ -1230,7 +1299,7 @@ wxItemResource *wxResourceInterpretMenuBar(wxResourceTable& table, wxExpr *expr) { resource->SetName(name); } - + return resource; } @@ -1274,18 +1343,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") @@ -1309,14 +1378,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; } @@ -1345,7 +1414,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); @@ -1380,6 +1449,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 */ @@ -1501,7 +1573,7 @@ bool wxGetResourceToken(FILE *fd) wxReallocateResourceBuffer(); wxResourceBuffer[wxResourceBufferCount] = (char)ch; wxResourceBufferCount ++; - + ch = getc(fd); } wxResourceBuffer[wxResourceBufferCount] = 0; @@ -1516,12 +1588,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)) { @@ -1549,7 +1621,7 @@ bool wxResourceReadOneResource(FILE *fd, wxExprDatabase& db, bool *eof, wxResour } delete[] name; delete[] value; - + return TRUE; } else if (strcmp(wxResourceBuffer, "#include") == 0) @@ -1592,7 +1664,7 @@ bool wxResourceReadOneResource(FILE *fd, wxExprDatabase& db, bool *eof, wxResour wxLogWarning(_("Expected 'char' whilst parsing resource.")); return FALSE; } - + // *name if (!wxGetResourceToken(fd)) { @@ -1608,7 +1680,7 @@ bool wxResourceReadOneResource(FILE *fd, wxExprDatabase& db, bool *eof, wxResour } char nameBuf[100]; strncpy(nameBuf, wxResourceBuffer+1, 99); - + // = if (!wxGetResourceToken(fd)) { @@ -1649,7 +1721,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 @@ -1705,13 +1777,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 }, @@ -1727,6 +1799,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 }, @@ -1798,7 +1872,7 @@ static wxResourceBitListStruct wxResourceBitListTable[] = { "wxALIGN_CENTRE", wxALIGN_CENTRE}, { "wxALIGN_RIGHT", wxALIGN_RIGHT}, { "wxCOLOURED", wxCOLOURED}, - + /* wxToolBar */ { "wxTB_3DBUTTONS", wxTB_3DBUTTONS}, { "wxTB_HORIZONTAL", wxTB_HORIZONTAL}, @@ -1822,7 +1896,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}, @@ -1972,16 +2047,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; @@ -1990,7 +2065,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) @@ -2084,7 +2159,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 @@ -2100,9 +2175,9 @@ 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()); + return wxBitmap((char **)item->GetValue1()); #else wxLogWarning(_("No XPM facility available!")); #endif @@ -2127,12 +2202,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) { @@ -2145,7 +2220,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) @@ -2239,9 +2314,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 @@ -2283,7 +2358,7 @@ wxIcon wxResourceCreateIcon(const wxString& resource, wxResourceTable *table) else { wxLogWarning(_("Icon resource specification %s not found."), (const char*) resource); - return (wxIcon *) NULL; + return wxNullIcon; } } @@ -2315,7 +2390,7 @@ wxMenuBar *wxResourceCreateMenuBar(const wxString& resource, wxResourceTable *ta { if (!table) table = wxDefaultResourceTable; - + wxItemResource *menuResource = table->FindResource(resource); if (menuResource && (menuResource->GetType() != "") && (menuResource->GetType() == "wxMenu")) { @@ -2339,7 +2414,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)) @@ -2352,7 +2427,7 @@ bool wxResourceParseData(const wxString& resource, wxResourceTable *table) { if (!table) table = wxDefaultResourceTable; - + return table->ParseResourceData(resource); } @@ -2360,7 +2435,7 @@ bool wxResourceParseFile(const wxString& filename, wxResourceTable *table) { if (!table) table = wxDefaultResourceTable; - + return table->ParseResourceFile(filename); } @@ -2369,7 +2444,7 @@ bool wxResourceRegisterBitmapData(const wxString& name, char bits[], int width, { if (!table) table = wxDefaultResourceTable; - + return table->RegisterResourceBitmapData(name, bits, width, height); } @@ -2397,7 +2472,7 @@ bool wxResourceAddIdentifier(const wxString& name, int value, wxResourceTable *t { if (!table) table = wxDefaultResourceTable; - + table->identifiers.Put(name, (wxObject *)value); return TRUE; } @@ -2406,7 +2481,7 @@ int wxResourceGetIdentifier(const wxString& name, wxResourceTable *table) { if (!table) table = wxDefaultResourceTable; - + return (int)table->identifiers.Get(name); } @@ -2418,7 +2493,7 @@ bool wxResourceParseIncludeFile(const wxString& f, wxResourceTable *table) { if (!table) table = wxDefaultResourceTable; - + FILE *fd = fopen(f, "r"); if (!fd) { @@ -2472,7 +2547,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(); @@ -2567,7 +2642,7 @@ bool wxGetResourceTokenString(char *s) wxReallocateResourceBuffer(); wxResourceBuffer[wxResourceBufferCount] = (char)ch; wxResourceBufferCount ++; - + ch = getc_string(s); } wxResourceBuffer[wxResourceBufferCount] = 0; @@ -2582,12 +2657,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)) { @@ -2615,7 +2690,7 @@ bool wxResourceReadOneResourceString(char *s, wxExprDatabase& db, bool *eof, wxR } delete[] name; delete[] value; - + return TRUE; } /* @@ -2662,7 +2737,7 @@ bool wxResourceReadOneResourceString(char *s, wxExprDatabase& db, bool *eof, wxR wxLogWarning(_("Expected 'char' whilst parsing resource.")); return FALSE; } - + // *name if (!wxGetResourceTokenString(s)) { @@ -2678,7 +2753,7 @@ bool wxResourceReadOneResourceString(char *s, wxExprDatabase& db, bool *eof, wxR } char nameBuf[100]; strncpy(nameBuf, wxResourceBuffer+1, 99); - + // = if (!wxGetResourceTokenString(s)) { @@ -2720,11 +2795,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); @@ -2756,11 +2831,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()); @@ -2809,7 +2884,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)); @@ -2830,7 +2905,7 @@ bool wxWindow::LoadFromResource(wxWindow *parent, const wxString& resourceName, while (node) { wxItemResource *childResource = (wxItemResource *)node->Data(); - + (void) CreateItem(childResource, resource, table); node = node->Next(); @@ -2845,4 +2920,11 @@ wxControl *wxWindow::CreateItem(const wxItemResource *resource, const wxItemReso return table->CreateItem((wxWindow *)this, resource, parentResource); } +#ifdef __VISUALC__ + #pragma warning(default:4706) // assignment within conditional expression +#endif // VC++ + +#endif + // BC++/Win16 + #endif // wxUSE_WX_RESOURCES