X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/94b49b9303a9fd119e24d1b07263f5bb0643afa5..b1a39f47f8e4e9662ecdecab8f38fca1342202a7:/src/common/resource.cpp diff --git a/src/common/resource.cpp b/src/common/resource.cpp index 059a8315b4..a3c99026f9 100644 --- a/src/common/resource.cpp +++ b/src/common/resource.cpp @@ -22,7 +22,7 @@ #if wxUSE_WX_RESOURCES -#ifdef _MSC_VER +#ifdef __VISUALC__ #pragma warning(disable:4706) // assignment within conditional expression #endif // VC++ @@ -39,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 @@ -53,6 +55,10 @@ #include "wx/intl.h" #endif +#if wxUSE_RADIOBUTTON +#include "wx/radiobut.h" +#endif + #if wxUSE_SCROLLBAR #include "wx/scrolbar.h" #endif @@ -93,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() { @@ -553,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; @@ -801,10 +823,14 @@ wxItemResource *wxResourceInterpretControl(wxResourceTable& table, wxExpr *expr) // 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"); + wxString str(expr->Nth(count)->StringValue()); + + if (str != "") + { + controlItem->SetValue4(str); + controlItem->SetType("wxBitmapButton"); + } } if (expr->Nth(count) && expr->Nth(count)->Type() == PrologList) controlItem->SetFont(wxResourceInterpretFontSpec(expr->Nth(count))); @@ -1317,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") @@ -1423,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 */ @@ -2027,7 +2056,7 @@ wxBitmap wxResourceCreateBitmap(const wxString& resource, wxResourceTable *table 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; @@ -2148,7 +2177,7 @@ wxBitmap wxResourceCreateBitmap(const wxString& resource, wxResourceTable *table "Forgot to use wxResourceLoadBitmapData?"), (const char*) name); return wxNullBitmap; } - return wxBitmap(item->GetValue1()); + return wxBitmap((char **)item->GetValue1()); #else wxLogWarning(_("No XPM facility available!")); #endif @@ -2805,8 +2834,8 @@ bool wxWindow::LoadFromResource(wxWindow *parent, const wxString& resourceName, 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()); @@ -2891,8 +2920,11 @@ wxControl *wxWindow::CreateItem(const wxItemResource *resource, const wxItemReso return table->CreateItem((wxWindow *)this, resource, parentResource); } -#ifdef _MSC_VER +#ifdef __VISUALC__ #pragma warning(default:4706) // assignment within conditional expression #endif // VC++ +#endif + // BC++/Win16 + #endif // wxUSE_WX_RESOURCES