X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/8552e6f031ded8ae61b4a5b489fbf06962365da7..3030ae493df7500fd5da7555f141c0c8a690bd8a:/contrib/src/deprecated/resource.cpp diff --git a/contrib/src/deprecated/resource.cpp b/contrib/src/deprecated/resource.cpp index 3d0188a9ec..0a567750bf 100644 --- a/contrib/src/deprecated/resource.cpp +++ b/contrib/src/deprecated/resource.cpp @@ -1,18 +1,14 @@ ///////////////////////////////////////////////////////////////////////////// -// Name: resource.cpp +// Name: contrib/src/deprecated/resource.cpp // Purpose: Resource system // Author: Julian Smart // Modified by: // Created: 04/01/98 // RCS-ID: $Id$ // Copyright: (c) Julian Smart -// Licence: wxWindows licence +// Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// -#ifdef __GNUG__ -#pragma implementation "resource.h" -#endif - // For compilers that support precompilation, includes "wx.h". #include "wx/wxprec.h" @@ -29,30 +25,28 @@ #endif // VC++ #ifndef WX_PRECOMP -#include "wx/defs.h" -#include "wx/setup.h" -#include "wx/list.h" -#include "wx/hash.h" -#include "wx/gdicmn.h" -#include "wx/utils.h" -#include "wx/types.h" -#include "wx/menu.h" -#include "wx/stattext.h" -#include "wx/button.h" -#include "wx/bmpbuttn.h" -#include "wx/radiobox.h" -#include "wx/listbox.h" -#include "wx/choice.h" -#include "wx/checkbox.h" -#include "wx/settings.h" -#include "wx/slider.h" -#include "wx/icon.h" -#include "wx/statbox.h" -#include "wx/statbmp.h" -#include "wx/gauge.h" -#include "wx/textctrl.h" -#include "wx/msgdlg.h" -#include "wx/intl.h" + #include "wx/list.h" + #include "wx/hash.h" + #include "wx/gdicmn.h" + #include "wx/utils.h" + #include "wx/types.h" + #include "wx/menu.h" + #include "wx/stattext.h" + #include "wx/button.h" + #include "wx/bmpbuttn.h" + #include "wx/radiobox.h" + #include "wx/listbox.h" + #include "wx/choice.h" + #include "wx/checkbox.h" + #include "wx/settings.h" + #include "wx/slider.h" + #include "wx/icon.h" + #include "wx/statbox.h" + #include "wx/statbmp.h" + #include "wx/gauge.h" + #include "wx/textctrl.h" + #include "wx/msgdlg.h" + #include "wx/intl.h" #endif #include "wx/treebase.h" @@ -96,7 +90,7 @@ static inline wxChar* copystring(const wxChar* s) // Forward (private) declarations bool wxResourceInterpretResources(wxResourceTable& table, wxExprDatabase& db); -wxItemResource *wxResourceInterpretDialog(wxResourceTable& table, wxExpr *expr, bool isPanel = FALSE); +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); @@ -137,7 +131,7 @@ class wxResourceModule: public wxModule { public: wxResourceModule() : wxModule() {} - virtual bool OnInit() { wxInitializeResourceSystem(); return TRUE; } + virtual bool OnInit() { wxInitializeResourceSystem(); return true; } virtual void OnExit() { wxCleanUpResourceSystem(); } DECLARE_DYNAMIC_CLASS(wxResourceModule) @@ -151,13 +145,13 @@ IMPLEMENT_DYNAMIC_CLASS(wxResourceTable, wxHashTable) wxItemResource::wxItemResource() { - m_itemType = wxT(""); - m_title = wxT(""); - m_name = wxT(""); + m_itemType = wxEmptyString; + m_title = wxEmptyString; + m_name = wxEmptyString; m_windowStyle = 0; m_x = m_y = m_width = m_height = 0; m_value1 = m_value2 = m_value3 = m_value5 = 0; - m_value4 = wxT(""); + m_value4 = wxEmptyString; m_windowId = 0; m_exStyle = 0; } @@ -196,9 +190,9 @@ wxItemResource *wxResourceTable::FindResource(const wxString& name) const void wxResourceTable::AddResource(wxItemResource *item) { wxString name = item->GetName(); - if (name == wxT("")) + if (name.empty()) name = item->GetTitle(); - if (name == wxT("")) + if (name.empty()) name = wxT("no name"); // Delete existing resource, if any. @@ -215,7 +209,7 @@ bool wxResourceTable::DeleteResource(const wxString& name) // See if any resource has this as its child; if so, delete from // parent's child list. BeginFind(); - wxNode *node = Next(); + wxHashTable::Node *node = Next(); while (node != NULL) { wxItemResource *parent = (wxItemResource *)node->GetData(); @@ -228,10 +222,10 @@ bool wxResourceTable::DeleteResource(const wxString& name) } delete item; - return TRUE; + return true; } else - return FALSE; + return false; } bool wxResourceTable::ParseResourceFile( wxInputStream *is ) @@ -239,7 +233,7 @@ bool wxResourceTable::ParseResourceFile( wxInputStream *is ) wxExprDatabase db; int len = is->GetSize() ; - bool eof = FALSE; + bool eof = false; while ( is->TellI() + 10 < len) // it's a hack because the streams dont support EOF { wxResourceReadOneResource(is, db, &eof, this) ; @@ -253,8 +247,8 @@ bool wxResourceTable::ParseResourceFile(const wxString& filename) FILE *fd = wxFopen(filename, wxT("r")); if (!fd) - return FALSE; - bool eof = FALSE; + return false; + bool eof = false; while (wxResourceReadOneResource(fd, db, &eof, this) && !eof) { // Loop @@ -269,7 +263,7 @@ bool wxResourceTable::ParseResourceData(const wxString& data) if (!db.ReadFromString(data)) { wxLogWarning(_("Ill-formed resource file syntax.")); - return FALSE; + return false; } return wxResourceInterpretResources(*this, db); @@ -286,7 +280,7 @@ bool wxResourceTable::RegisterResourceBitmapData(const wxString& name, char bits item->SetValue2((long)width); item->SetValue3((long)height); AddResource(item); - return TRUE; + return true; } bool wxResourceTable::RegisterResourceBitmapData(const wxString& name, char **data) @@ -298,21 +292,21 @@ bool wxResourceTable::RegisterResourceBitmapData(const wxString& name, char **da item->SetName(name); item->SetValue1((long)data); AddResource(item); - return TRUE; + return true; } bool wxResourceTable::SaveResource(const wxString& WXUNUSED(filename)) { - return FALSE; + return false; } void wxResourceTable::ClearTable() { BeginFind(); - wxNode *node = Next(); + wxHashTable::Node *node = Next(); while (node) { - wxNode *next = Next(); + wxHashTable::Node *next = Next(); wxItemResource *item = (wxItemResource *)node->GetData(); delete item; delete node; @@ -324,7 +318,7 @@ wxControl *wxResourceTable::CreateItem(wxWindow *parent, const wxItemResource* c { int id = childResource->GetId(); if ( id == 0 ) - id = -1; + id = wxID_ANY; bool dlgUnits = ((parentResource->GetResourceStyle() & wxRESOURCE_DIALOG_UNITS) != 0); @@ -346,7 +340,7 @@ wxControl *wxResourceTable::CreateItem(wxWindow *parent, const wxItemResource* c if (itemType == wxString(wxT("wxButton")) || itemType == wxString(wxT("wxBitmapButton"))) { - if (childResource->GetValue4() != wxT("")) + if (!childResource->GetValue4().empty()) { // Bitmap button wxBitmap bitmap = childResource->GetBitmap(); @@ -375,7 +369,7 @@ wxControl *wxResourceTable::CreateItem(wxWindow *parent, const wxItemResource* c else if (itemType == wxString(wxT("wxMessage")) || itemType == wxString(wxT("wxStaticText")) || itemType == wxString(wxT("wxStaticBitmap"))) { - if (childResource->GetValue4() != wxT("") || itemType == wxString(wxT("wxStaticBitmap")) ) + if (!childResource->GetValue4().empty() || itemType == wxString(wxT("wxStaticBitmap")) ) { // Bitmap message wxBitmap bitmap = childResource->GetBitmap(); @@ -443,7 +437,7 @@ wxControl *wxResourceTable::CreateItem(wxWindow *parent, const wxItemResource* c ((wxScrollBar *)control)->SetViewLength((int)(long)childResource->GetValue5()); */ ((wxScrollBar *)control)->SetScrollbar((int)childResource->GetValue1(),(int)childResource->GetValue2(), - (int)childResource->GetValue3(),(int)(long)childResource->GetValue5(),FALSE); + (int)childResource->GetValue3(),(int)(long)childResource->GetValue5(),false); } #endif @@ -572,7 +566,7 @@ wxControl *wxResourceTable::CreateItem(wxWindow *parent, const wxItemResource* c // Force the layout algorithm since the size changes the layout if (control->IsKindOf(CLASSINFO(wxRadioBox))) { - control->SetSize(-1, -1, -1, -1, wxSIZE_AUTO_WIDTH|wxSIZE_AUTO_HEIGHT); + control->SetSize(wxDefaultCoord, wxDefaultCoord, wxDefaultCoord, wxDefaultCoord, wxSIZE_AUTO_WIDTH|wxSIZE_AUTO_HEIGHT); } #endif } @@ -596,7 +590,7 @@ bool wxResourceInterpretResources(wxResourceTable& table, wxExprDatabase& db) if (functor == wxT("dialog")) item = wxResourceInterpretDialog(table, clause); else if (functor == wxT("panel")) - item = wxResourceInterpretDialog(table, clause, TRUE); + item = wxResourceInterpretDialog(table, clause, true); else if (functor == wxT("menubar")) item = wxResourceInterpretMenuBar(table, clause); else if (functor == wxT("menu")) @@ -611,13 +605,13 @@ bool wxResourceInterpretResources(wxResourceTable& table, wxExprDatabase& db) if (item) { // Remove any existing resource of same name - if (item->GetName() != wxT("")) + if (!item->GetName().empty()) table.DeleteResource(item->GetName()); table.AddResource(item); } node = node->GetNext(); } - return TRUE; + return true; } static const wxChar *g_ValidControlClasses[] = @@ -649,9 +643,9 @@ static bool wxIsValidControlClass(const wxString& c) for ( size_t i = 0; i < WXSIZEOF(g_ValidControlClasses); i++ ) { if ( c == g_ValidControlClasses[i] ) - return TRUE; + return true; } - return FALSE; + return false; } wxItemResource *wxResourceInterpretDialog(wxResourceTable& table, wxExpr *expr, bool isPanel) @@ -661,18 +655,18 @@ wxItemResource *wxResourceInterpretDialog(wxResourceTable& table, wxExpr *expr, dialogItem->SetType(wxT("wxPanel")); else dialogItem->SetType(wxT("wxDialog")); - wxString style = wxT(""); - wxString title = wxT(""); - wxString name = wxT(""); - wxString backColourHex = wxT(""); - wxString labelColourHex = wxT(""); - wxString buttonColourHex = wxT(""); + wxString style = wxEmptyString; + wxString title = wxEmptyString; + wxString name = wxEmptyString; + wxString backColourHex = wxEmptyString; + wxString labelColourHex = wxEmptyString; + wxString buttonColourHex = wxEmptyString; long windowStyle = wxDEFAULT_DIALOG_STYLE; if (isPanel) windowStyle = 0; - int x = 0; int y = 0; int width = -1; int height = -1; + int x = 0; int y = 0; int width = wxDefaultCoord; int height = wxDefaultCoord; int isModal = 0; wxExpr *labelFontExpr = (wxExpr *) NULL; wxExpr *buttonFontExpr = (wxExpr *) NULL; @@ -706,26 +700,37 @@ wxItemResource *wxResourceInterpretDialog(wxResourceTable& table, wxExpr *expr, expr->GetAttributeValue(wxT("id"), id); dialogItem->SetId(id); - if (style != wxT("")) + if (!style.empty()) { windowStyle = wxParseWindowStyle(style); } dialogItem->SetStyle(windowStyle); dialogItem->SetValue1(isModal); - if (windowStyle & wxDIALOG_MODAL) // Uses style in wxWin 2 - dialogItem->SetValue1(TRUE); + +#if WXWIN_COMPATIBILITY_2_6 + +#ifdef __VMS +#pragma message disable CODCAUUNR +#endif + if (windowStyle & wxDIALOG_MODAL) // Uses style in wxWin 2 + dialogItem->SetValue1(true); +#ifdef __VMS +#pragma message enable CODCAUUNR +#endif + +#endif // WXWIN_COMPATIBILITY_2_6 dialogItem->SetName(name); dialogItem->SetTitle(title); dialogItem->SetSize(x, y, width, height); // Check for wxWin 1.68-style specifications - if (style.Find(wxT("VERTICAL_LABEL")) != -1) + if (style.Find(wxT("VERTICAL_LABEL")) != wxNOT_FOUND) dialogItem->SetResourceStyle(dialogItem->GetResourceStyle() | wxRESOURCE_VERTICAL_LABEL); - else if (style.Find(wxT("HORIZONTAL_LABEL")) != -1) + else if (style.Find(wxT("HORIZONTAL_LABEL")) != wxNOT_FOUND) dialogItem->SetResourceStyle(dialogItem->GetResourceStyle() | wxRESOURCE_HORIZONTAL_LABEL); - if (backColourHex != wxT("")) + if (!backColourHex.empty()) { int r = 0; int g = 0; @@ -735,7 +740,7 @@ wxItemResource *wxResourceInterpretDialog(wxResourceTable& table, wxExpr *expr, b = wxHexToDec(backColourHex.Mid(4, 2)); dialogItem->SetBackgroundColour(wxColour((unsigned char)r,(unsigned char)g,(unsigned char)b)); } - if (labelColourHex != wxT("")) + if (!labelColourHex.empty()) { int r = 0; int g = 0; @@ -745,7 +750,7 @@ wxItemResource *wxResourceInterpretDialog(wxResourceTable& table, wxExpr *expr, b = wxHexToDec(labelColourHex.Mid(4, 2)); dialogItem->SetLabelColour(wxColour((unsigned char)r,(unsigned char)g,(unsigned char)b)); } - if (buttonColourHex != wxT("")) + if (!buttonColourHex.empty()) { int r = 0; int g = 0; @@ -770,7 +775,7 @@ wxItemResource *wxResourceInterpretDialog(wxResourceTable& table, wxExpr *expr, if (controlExpr->Number() == 3) { wxString controlKeyword(controlExpr->Nth(1)->StringValue()); - if (controlKeyword != wxT("") && controlKeyword == wxT("control")) + if (!controlKeyword.empty() && controlKeyword == wxT("control")) { // The value part: always a list. wxExpr *listExpr = controlExpr->Nth(2); @@ -802,7 +807,7 @@ wxItemResource *wxResourceInterpretControl(wxResourceTable& table, wxExpr *expr) wxString name; int id = 0; long windowStyle = 0; - int x = 0; int y = 0; int width = -1; int height = -1; + int x = 0; int y = 0; int width = wxDefaultCoord; int height = wxDefaultCoord; int count = 0; wxExpr *expr1 = expr->Nth(0); @@ -887,9 +892,9 @@ wxItemResource *wxResourceInterpretControl(wxResourceTable& table, wxExpr *expr) controlItem->SetId(id); // Check for wxWin 1.68-style specifications - if (style.Find(wxT("VERTICAL_LABEL")) != -1) + if (style.Find(wxT("VERTICAL_LABEL")) != wxNOT_FOUND) controlItem->SetResourceStyle(controlItem->GetResourceStyle() | wxRESOURCE_VERTICAL_LABEL); - else if (style.Find(wxT("HORIZONTAL_LABEL")) != -1) + else if (style.Find(wxT("HORIZONTAL_LABEL")) != wxNOT_FOUND) controlItem->SetResourceStyle(controlItem->GetResourceStyle() | wxRESOURCE_HORIZONTAL_LABEL); if (controlType == wxT("wxButton")) @@ -900,7 +905,7 @@ wxItemResource *wxResourceInterpretControl(wxResourceTable& table, wxExpr *expr) wxString str(expr->Nth(count)->StringValue()); count ++; - if (str != wxT("")) + if (!str.empty()) { controlItem->SetValue4(str); controlItem->SetType(wxT("wxBitmapButton")); @@ -1410,18 +1415,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() != wxT("")) + if (nameExpr && !nameExpr->StringValue().empty()) { bitmapSpec->SetName(nameExpr->StringValue()); } - if (typeExpr && typeExpr->StringValue() != wxT("")) + if (typeExpr && !typeExpr->StringValue().empty()) { bitmapSpec->SetValue1(wxParseWindowStyle(typeExpr->StringValue())); } else bitmapSpec->SetValue1(0); - if (platformExpr && platformExpr->StringValue() != wxT("")) + if (platformExpr && !platformExpr->StringValue().empty()) { wxString plat(platformExpr->StringValue()); if (plat == wxT("windows") || plat == wxT("WINDOWS")) @@ -1480,7 +1485,7 @@ wxFont wxResourceInterpretFontSpec(wxExpr *expr) int style = wxNORMAL; int weight = wxNORMAL; int underline = 0; - wxString faceName(wxT("")); + wxString faceName; wxExpr *pointExpr = expr->Nth(0); wxExpr *familyExpr = expr->Nth(1); @@ -1526,7 +1531,7 @@ bool wxReallocateResourceBuffer() { wxResourceBufferSize = 1000; wxResourceBuffer = new char[wxResourceBufferSize]; - return TRUE; + return true; } if (wxResourceBuffer) { @@ -1537,7 +1542,7 @@ bool wxReallocateResourceBuffer() wxResourceBuffer = tmp; wxResourceBufferSize = newSize; } - return TRUE; + return true; } static bool wxEatWhiteSpace(FILE *fd) @@ -1560,7 +1565,7 @@ static bool wxEatWhiteSpace(FILE *fd) if (ch == EOF) { ungetc(prev_ch, fd); - return TRUE; + return true; } if (ch == '*') @@ -1584,25 +1589,25 @@ static bool wxEatWhiteSpace(FILE *fd) { ungetc(prev_ch, fd); ungetc(ch, fd); - return TRUE; + return true; } } break; default: ungetc(ch, fd); - return TRUE; + return true; } } - return FALSE; + return false; } static bool wxEatWhiteSpace(wxInputStream *is) { - int ch = is->GetC() ; + char ch = is->GetC() ; if ((ch != ' ') && (ch != '/') && (ch != ' ') && (ch != 10) && (ch != 13) && (ch != 9)) { is->Ungetch(ch); - return TRUE; + return true; } // Eat whitespace @@ -1614,17 +1619,17 @@ static bool wxEatWhiteSpace(wxInputStream *is) ch = is->GetC(); if (ch == '*') { - bool finished = FALSE; + bool finished = false; while (!finished) { ch = is->GetC(); - if (ch == EOF) - return FALSE; + if (is->LastRead() == 0) + return false; if (ch == '*') { int newCh = is->GetC(); if (newCh == '/') - finished = TRUE; + finished = true; else { is->Ungetch(ch); @@ -1633,7 +1638,7 @@ static bool wxEatWhiteSpace(wxInputStream *is) } } else // False alarm - return FALSE; + return false; } else is->Ungetch(ch); @@ -1659,7 +1664,7 @@ bool wxGetResourceToken(FILE *fd) if (ch == EOF) { wxResourceBuffer[wxResourceBufferCount] = 0; - return FALSE; + return false; } // Escaped characters else if (ch == '\\') @@ -1698,9 +1703,9 @@ bool wxGetResourceToken(FILE *fd) } wxResourceBuffer[wxResourceBufferCount] = 0; if (ch == EOF) - return FALSE; + return false; } - return TRUE; + return true; } bool wxGetResourceToken(wxInputStream *is) @@ -1722,12 +1727,12 @@ bool wxGetResourceToken(wxInputStream *is) if (ch == EOF) { wxResourceBuffer[wxResourceBufferCount] = 0; - return FALSE; + return false; } // Escaped characters else if (ch == '\\') { - int newCh = is->GetC(); + char newCh = is->GetC(); if (newCh == '"') actualCh = '"'; else if (newCh == 10) @@ -1763,9 +1768,9 @@ bool wxGetResourceToken(wxInputStream *is) } wxResourceBuffer[wxResourceBufferCount] = 0; if (ch == EOF) - return FALSE; + return false; } - return TRUE; + return true; } /* @@ -1782,8 +1787,8 @@ bool wxResourceReadOneResource(FILE *fd, wxExprDatabase& db, bool *eof, wxResour // static or #define if (!wxGetResourceToken(fd)) { - *eof = TRUE; - return FALSE; + *eof = true; + return false; } if (strcmp(wxResourceBuffer, "#define") == 0) @@ -1802,12 +1807,12 @@ bool wxResourceReadOneResource(FILE *fd, wxExprDatabase& db, bool *eof, wxResour wxLogWarning(_("#define %s must be an integer."), name); delete[] name; delete[] value; - return FALSE; + return false; } delete[] name; delete[] value; - return TRUE; + return true; } else if (strcmp(wxResourceBuffer, "#include") == 0) { @@ -1824,44 +1829,44 @@ bool wxResourceReadOneResource(FILE *fd, wxExprDatabase& db, bool *eof, wxResour wxLogWarning(_("Could not find resource include file %s."), actualName); } delete[] name; - return TRUE; + return true; } else if (strcmp(wxResourceBuffer, "static") != 0) { wxChar buf[300]; wxStrcpy(buf, _("Found ")); wxStrncat(buf, wxConvCurrent->cMB2WX(wxResourceBuffer), 30); - wxStrcat(buf, _(", expected static, #include or #define\nwhilst parsing resource.")); + wxStrcat(buf, _(", expected static, #include or #define\nwhile parsing resource.")); wxLogWarning(buf); - return FALSE; + return false; } // char if (!wxGetResourceToken(fd)) { - wxLogWarning(_("Unexpected end of file whilst parsing resource.")); - *eof = TRUE; - return FALSE; + wxLogWarning(_("Unexpected end of file while parsing resource.")); + *eof = true; + return false; } if (strcmp(wxResourceBuffer, "char") != 0) { - wxLogWarning(_("Expected 'char' whilst parsing resource.")); - return FALSE; + wxLogWarning(_("Expected 'char' while parsing resource.")); + return false; } // *name if (!wxGetResourceToken(fd)) { - wxLogWarning(_("Unexpected end of file whilst parsing resource.")); - *eof = TRUE; - return FALSE; + wxLogWarning(_("Unexpected end of file while parsing resource.")); + *eof = true; + return false; } if (wxResourceBuffer[0] != '*') { - wxLogWarning(_("Expected '*' whilst parsing resource.")); - return FALSE; + wxLogWarning(_("Expected '*' while parsing resource.")); + return false; } wxChar nameBuf[100]; wxMB2WX(nameBuf, wxResourceBuffer+1, 99); @@ -1870,38 +1875,38 @@ bool wxResourceReadOneResource(FILE *fd, wxExprDatabase& db, bool *eof, wxResour // = if (!wxGetResourceToken(fd)) { - wxLogWarning(_("Unexpected end of file whilst parsing resource.")); - *eof = TRUE; - return FALSE; + wxLogWarning(_("Unexpected end of file while parsing resource.")); + *eof = true; + return false; } if (strcmp(wxResourceBuffer, "=") != 0) { - wxLogWarning(_("Expected '=' whilst parsing resource.")); - return FALSE; + wxLogWarning(_("Expected '=' while parsing resource.")); + return false; } // String if (!wxGetResourceToken(fd)) { - wxLogWarning(_("Unexpected end of file whilst parsing resource.")); - *eof = TRUE; - return FALSE; + wxLogWarning(_("Unexpected end of file while parsing resource.")); + *eof = true; + return false; } else { if (!db.ReadPrologFromString(wxResourceBuffer)) { wxLogWarning(_("%s: ill-formed resource file syntax."), nameBuf); - return FALSE; + return false; } } // Semicolon if (!wxGetResourceToken(fd)) { - *eof = TRUE; + *eof = true; } - return TRUE; + return true; } bool wxResourceReadOneResource(wxInputStream *fd, wxExprDatabase& db, bool *eof, wxResourceTable *table) @@ -1912,8 +1917,8 @@ bool wxResourceReadOneResource(wxInputStream *fd, wxExprDatabase& db, bool *eof, // static or #define if (!wxGetResourceToken(fd)) { - *eof = TRUE; - return FALSE; + *eof = true; + return false; } if (strcmp(wxResourceBuffer, "#define") == 0) @@ -1932,12 +1937,12 @@ bool wxResourceReadOneResource(wxInputStream *fd, wxExprDatabase& db, bool *eof, wxLogWarning(_("#define %s must be an integer."), name); delete[] name; delete[] value; - return FALSE; + return false; } delete[] name; delete[] value; - return TRUE; + return true; } else if (strcmp(wxResourceBuffer, "#include") == 0) { @@ -1954,44 +1959,44 @@ bool wxResourceReadOneResource(wxInputStream *fd, wxExprDatabase& db, bool *eof, wxLogWarning(_("Could not find resource include file %s."), actualName); } delete[] name; - return TRUE; + return true; } else if (strcmp(wxResourceBuffer, "static") != 0) { wxChar buf[300]; wxStrcpy(buf, _("Found ")); wxStrncat(buf, wxConvLibc.cMB2WX(wxResourceBuffer), 30); - wxStrcat(buf, _(", expected static, #include or #define\nwhilst parsing resource.")); + wxStrcat(buf, _(", expected static, #include or #define\nwhile parsing resource.")); wxLogWarning(buf); - return FALSE; + return false; } // char if (!wxGetResourceToken(fd)) { - wxLogWarning(_("Unexpected end of file whilst parsing resource.")); - *eof = TRUE; - return FALSE; + wxLogWarning(_("Unexpected end of file while parsing resource.")); + *eof = true; + return false; } if (strcmp(wxResourceBuffer, "char") != 0) { - wxLogWarning(_("Expected 'char' whilst parsing resource.")); - return FALSE; + wxLogWarning(_("Expected 'char' while parsing resource.")); + return false; } // *name if (!wxGetResourceToken(fd)) { - wxLogWarning(_("Unexpected end of file whilst parsing resource.")); - *eof = TRUE; - return FALSE; + wxLogWarning(_("Unexpected end of file while parsing resource.")); + *eof = true; + return false; } if (wxResourceBuffer[0] != '*') { - wxLogWarning(_("Expected '*' whilst parsing resource.")); - return FALSE; + wxLogWarning(_("Expected '*' while parsing resource.")); + return false; } char nameBuf[100]; strncpy(nameBuf, wxResourceBuffer+1, 99); @@ -1999,38 +2004,38 @@ bool wxResourceReadOneResource(wxInputStream *fd, wxExprDatabase& db, bool *eof, // = if (!wxGetResourceToken(fd)) { - wxLogWarning(_("Unexpected end of file whilst parsing resource.")); - *eof = TRUE; - return FALSE; + wxLogWarning(_("Unexpected end of file while parsing resource.")); + *eof = true; + return false; } if (strcmp(wxResourceBuffer, "=") != 0) { - wxLogWarning(_("Expected '=' whilst parsing resource.")); - return FALSE; + wxLogWarning(_("Expected '=' while parsing resource.")); + return false; } // String if (!wxGetResourceToken(fd)) { - wxLogWarning(_("Unexpected end of file whilst parsing resource.")); - *eof = TRUE; - return FALSE; + wxLogWarning(_("Unexpected end of file while parsing resource.")); + *eof = true; + return false; } else { if (!db.ReadPrologFromString(wxResourceBuffer)) { wxLogWarning(_("%s: ill-formed resource file syntax."), nameBuf); - return FALSE; + return false; } } // Semicolon if (!wxGetResourceToken(fd)) { - *eof = TRUE; + *eof = true; } - return TRUE; + return true; } /* @@ -2100,13 +2105,17 @@ static wxResourceBitListStruct wxResourceBitListTable[] = { wxT("wxCB_SORT"), wxCB_SORT }, /* wxGauge */ +#if WXWIN_COMPATIBILITY_2_6 { wxT("wxGA_PROGRESSBAR"), wxGA_PROGRESSBAR }, +#endif // WXWIN_COMPATIBILITY_2_6 { wxT("wxGA_HORIZONTAL"), wxGA_HORIZONTAL }, { wxT("wxGA_VERTICAL"), wxGA_VERTICAL }, /* wxTextCtrl */ - { wxT("wxPASSWORD"), wxPASSWORD}, - { wxT("wxPROCESS_ENTER"), wxPROCESS_ENTER}, +#if WXWIN_COMPATIBILITY_2_6 + { wxT("wxPASSWORD"), wxTE_PASSWORD}, + { wxT("wxPROCESS_ENTER"), wxTE_PROCESS_ENTER}, +#endif { wxT("wxTE_PASSWORD"), wxTE_PASSWORD}, { wxT("wxTE_READONLY"), wxTE_READONLY}, { wxT("wxTE_PROCESS_ENTER"), wxTE_PROCESS_ENTER}, @@ -2195,8 +2204,10 @@ static wxResourceBitListStruct wxResourceBitListTable[] = { wxT("wxTB_VERTICAL"), wxTB_VERTICAL}, { wxT("wxTB_FLAT"), wxTB_FLAT}, +#if WXWIN_COMPATIBILITY_2_6 /* wxDialog */ { wxT("wxDIALOG_MODAL"), wxDIALOG_MODAL }, +#endif // WXWIN_COMPATIBILITY_2_6 /* Generic */ { wxT("wxVSCROLL"), wxVSCROLL }, @@ -2209,12 +2220,14 @@ static wxResourceBitListStruct wxResourceBitListTable[] = { wxT("wxSDI"), 0}, { wxT("wxMDI_PARENT"), 0}, { wxT("wxMDI_CHILD"), 0}, - { wxT("wxTHICK_FRAME"), wxTHICK_FRAME}, + { wxT("wxTHICK_FRAME"), wxRESIZE_BORDER}, { wxT("wxRESIZE_BORDER"), wxRESIZE_BORDER}, { wxT("wxSYSTEM_MENU"), wxSYSTEM_MENU}, { wxT("wxMINIMIZE_BOX"), wxMINIMIZE_BOX}, { wxT("wxMAXIMIZE_BOX"), wxMAXIMIZE_BOX}, +#if WXWIN_COMPATIBILITY_2_6 { wxT("wxRESIZE_BOX"), wxRESIZE_BOX}, +#endif // WXWIN_COMPATIBILITY_2_6 { wxT("wxDEFAULT_FRAME_STYLE"), wxDEFAULT_FRAME_STYLE}, { wxT("wxDEFAULT_FRAME"), wxDEFAULT_FRAME_STYLE}, { wxT("wxDEFAULT_DIALOG_STYLE"), wxDEFAULT_DIALOG_STYLE}, @@ -2316,7 +2329,9 @@ static wxResourceBitListStruct wxResourceBitListTable[] = { wxT("wxICON_MASK"), wxICON_MASK}, { wxT("wxCENTRE"), wxCENTRE}, { wxT("wxCENTER"), wxCENTRE}, +#if WXWIN_COMPATIBILITY_2_6 { wxT("wxUSER_COLOURS"), wxUSER_COLOURS}, +#endif // WXWIN_COMPATIBILITY_2_6 { wxT("wxVERTICAL_LABEL"), 0}, { wxT("wxHORIZONTAL_LABEL"), 0}, @@ -2347,18 +2362,18 @@ long wxParseWindowStyle(const wxString& bitListString) word = wxResourceParseWord(WXSTRINGCAST bitListString, &i); while (word != NULL) { - bool found = FALSE; + bool found = false; int j; for (j = 0; j < wxResourceBitListCount; j++) if (wxStrcmp(wxResourceBitListTable[j].word, word) == 0) { bitList |= wxResourceBitListTable[j].bits; - found = TRUE; + found = true; break; } if (!found) { - wxLogWarning(_("Unrecognized style %s whilst parsing resource."), word); + wxLogWarning(_("Unrecognized style %s while parsing resource."), word); return 0; } word = wxResourceParseWord(WXSTRINGCAST bitListString, &i); @@ -2367,7 +2382,7 @@ long wxParseWindowStyle(const wxString& bitListString) } /* -* Load a bitmap from a wxWindows resource, choosing an optimum +* Load a bitmap from a wxWidgets resource, choosing an optimum * depth and appropriate type. */ @@ -2379,7 +2394,7 @@ wxBitmap wxResourceCreateBitmap(const wxString& resource, wxResourceTable *table wxItemResource *item = table->FindResource(resource); if (item) { - if ((item->GetType() == wxT("")) || (item->GetType() != wxT("wxBitmap"))) + if ((item->GetType().empty()) || (item->GetType() != wxT("wxBitmap"))) { wxLogWarning(_("%s not a bitmap resource specification."), (const wxChar*) resource); return wxNullBitmap; @@ -2521,7 +2536,7 @@ wxBitmap wxResourceCreateBitmap(const wxString& resource, wxResourceTable *table } /* -* Load an icon from a wxWindows resource, choosing an optimum +* Load an icon from a wxWidgets resource, choosing an optimum * depth and appropriate type. */ @@ -2533,7 +2548,7 @@ wxIcon wxResourceCreateIcon(const wxString& resource, wxResourceTable *table) wxItemResource *item = table->FindResource(resource); if (item) { - if ((item->GetType() == wxT("")) || wxStrcmp(item->GetType(), wxT("wxIcon")) != 0) + if ((item->GetType().empty()) || wxStrcmp(item->GetType(), wxT("wxIcon")) != 0) { wxLogWarning(_("%s not an icon resource specification."), (const wxChar*) resource); return wxNullIcon; @@ -2646,7 +2661,7 @@ wxIcon wxResourceCreateIcon(const wxString& resource, wxResourceTable *table) } case wxBITMAP_TYPE_XPM_DATA: { - // *** XPM ICON NOT YET IMPLEMENTED IN WXWINDOWS *** + // *** XPM ICON NOT YET IMPLEMENTED IN wxWidgets *** /* wxItemResource *item = table->FindResource(name); if (!item) @@ -2689,7 +2704,7 @@ wxMenu *wxResourceCreateMenu(wxItemResource *item) while (node) { wxItemResource *child = (wxItemResource *)node->GetData(); - if ((child->GetType() != wxT("")) && (child->GetType() == wxT("wxMenuSeparator"))) + if ((!child->GetType().empty()) && (child->GetType() == wxT("wxMenuSeparator"))) menu->AppendSeparator(); else if (child->GetChildren().GetCount() > 0) { @@ -2712,7 +2727,7 @@ wxMenuBar *wxResourceCreateMenuBar(const wxString& resource, wxResourceTable *ta table = wxDefaultResourceTable; wxItemResource *menuResource = table->FindResource(resource); - if (menuResource && (menuResource->GetType() != wxT("")) && (menuResource->GetType() == wxT("wxMenu"))) + if (menuResource && (!menuResource->GetType().empty()) && (menuResource->GetType() == wxT("wxMenu"))) { if (!menuBar) menuBar = new wxMenuBar; @@ -2736,7 +2751,7 @@ wxMenu *wxResourceCreateMenu(const wxString& resource, wxResourceTable *table) table = wxDefaultResourceTable; wxItemResource *menuResource = table->FindResource(resource); - if (menuResource && (menuResource->GetType() != wxT("")) && (menuResource->GetType() == wxT("wxMenu"))) + if (menuResource && (!menuResource->GetType().empty()) && (menuResource->GetType() == wxT("wxMenu"))) // if (menuResource && (menuResource->GetType() == wxTYPE_MENU)) return wxResourceCreateMenu(menuResource); return (wxMenu *) NULL; @@ -2805,7 +2820,7 @@ bool wxResourceAddIdentifier(const wxString& name, int value, wxResourceTable *t table = wxDefaultResourceTable; table->identifiers.Put(name, (wxObject *)(long)value); - return TRUE; + return true; } int wxResourceGetIdentifier(const wxString& name, wxResourceTable *table) @@ -2828,7 +2843,7 @@ bool wxResourceParseIncludeFile(const wxString& f, wxResourceTable *table) FILE *fd = wxFopen(f, wxT("r")); if (!fd) { - return FALSE; + return false; } while (wxGetResourceToken(fd)) { @@ -2848,7 +2863,7 @@ bool wxResourceParseIncludeFile(const wxString& f, wxResourceTable *table) } } fclose(fd); - return TRUE; + return true; } /* @@ -2892,7 +2907,7 @@ bool wxEatWhiteSpaceString(char *s) if (ch == EOF) { ungetc_string(); - return TRUE; + return true; } if (ch == '*') @@ -2910,17 +2925,17 @@ bool wxEatWhiteSpaceString(char *s) { ungetc_string(); ungetc_string(); - return TRUE; + return true; } } break; default: ungetc_string(); - return TRUE; + return true; } } - return FALSE; + return false; } bool wxGetResourceTokenString(char *s) @@ -2942,7 +2957,7 @@ bool wxGetResourceTokenString(char *s) if (ch == EOF) { wxResourceBuffer[wxResourceBufferCount] = 0; - return FALSE; + return false; } // Escaped characters else if (ch == '\\') @@ -2981,9 +2996,9 @@ bool wxGetResourceTokenString(char *s) } wxResourceBuffer[wxResourceBufferCount] = 0; if (ch == EOF) - return FALSE; + return false; } - return TRUE; + return true; } /* @@ -3000,8 +3015,8 @@ bool wxResourceReadOneResourceString(char *s, wxExprDatabase& db, bool *eof, wxR // static or #define if (!wxGetResourceTokenString(s)) { - *eof = TRUE; - return FALSE; + *eof = true; + return false; } if (strcmp(wxResourceBuffer, "#define") == 0) @@ -3020,12 +3035,12 @@ bool wxResourceReadOneResourceString(char *s, wxExprDatabase& db, bool *eof, wxR wxLogWarning(_("#define %s must be an integer."), name); delete[] name; delete[] value; - return FALSE; + return false; } delete[] name; delete[] value; - return TRUE; + return true; } /* else if (strcmp(wxResourceBuffer, "#include") == 0) @@ -3045,7 +3060,7 @@ bool wxResourceReadOneResourceString(char *s, wxExprDatabase& db, bool *eof, wxR wxLogWarning(buf); } delete[] name; - return TRUE; + return true; } */ else if (strcmp(wxResourceBuffer, "static") != 0) @@ -3053,37 +3068,37 @@ bool wxResourceReadOneResourceString(char *s, wxExprDatabase& db, bool *eof, wxR wxChar buf[300]; wxStrcpy(buf, _("Found ")); wxStrncat(buf, wxConvCurrent->cMB2WX(wxResourceBuffer), 30); - wxStrcat(buf, _(", expected static, #include or #define\nwhilst parsing resource.")); + wxStrcat(buf, _(", expected static, #include or #define\nwhile parsing resource.")); wxLogWarning(buf); - return FALSE; + return false; } // char if (!wxGetResourceTokenString(s)) { - wxLogWarning(_("Unexpected end of file whilst parsing resource.")); - *eof = TRUE; - return FALSE; + wxLogWarning(_("Unexpected end of file while parsing resource.")); + *eof = true; + return false; } if (strcmp(wxResourceBuffer, "char") != 0) { - wxLogWarning(_("Expected 'char' whilst parsing resource.")); - return FALSE; + wxLogWarning(_("Expected 'char' while parsing resource.")); + return false; } // *name if (!wxGetResourceTokenString(s)) { - wxLogWarning(_("Unexpected end of file whilst parsing resource.")); - *eof = TRUE; - return FALSE; + wxLogWarning(_("Unexpected end of file while parsing resource.")); + *eof = true; + return false; } if (wxResourceBuffer[0] != '*') { - wxLogWarning(_("Expected '*' whilst parsing resource.")); - return FALSE; + wxLogWarning(_("Expected '*' while parsing resource.")); + return false; } wxChar nameBuf[100]; wxMB2WX(nameBuf, wxResourceBuffer+1, 99); @@ -3092,38 +3107,38 @@ bool wxResourceReadOneResourceString(char *s, wxExprDatabase& db, bool *eof, wxR // = if (!wxGetResourceTokenString(s)) { - wxLogWarning(_("Unexpected end of file whilst parsing resource.")); - *eof = TRUE; - return FALSE; + wxLogWarning(_("Unexpected end of file while parsing resource.")); + *eof = true; + return false; } if (strcmp(wxResourceBuffer, "=") != 0) { - wxLogWarning(_("Expected '=' whilst parsing resource.")); - return FALSE; + wxLogWarning(_("Expected '=' while parsing resource.")); + return false; } // String if (!wxGetResourceTokenString(s)) { - wxLogWarning(_("Unexpected end of file whilst parsing resource.")); - *eof = TRUE; - return FALSE; + wxLogWarning(_("Unexpected end of file while parsing resource.")); + *eof = true; + return false; } else { if (!db.ReadPrologFromString(wxResourceBuffer)) { wxLogWarning(_("%s: ill-formed resource file syntax."), nameBuf); - return FALSE; + return false; } } // Semicolon if (!wxGetResourceTokenString(s)) { - *eof = TRUE; + *eof = true; } - return TRUE; + return true; } bool wxResourceParseString(const wxString& s, wxResourceTable *WXUNUSED(table)) @@ -3141,7 +3156,7 @@ bool wxResourceParseString(char *s, wxResourceTable *table) table = wxDefaultResourceTable; if (!s) - return FALSE; + return false; // Turn backslashes into spaces if (s) @@ -3159,7 +3174,7 @@ bool wxResourceParseString(char *s, wxResourceTable *table) wxExprDatabase db; wxResourceStringPtr = 0; - bool eof = FALSE; + bool eof = false; while (wxResourceReadOneResourceString(s, db, &eof, table) && !eof) { // Loop @@ -3178,9 +3193,9 @@ bool wxLoadFromResource(wxWindow* thisWindow, wxWindow *parent, const wxString& wxItemResource *resource = table->FindResource((const wxChar *)resourceName); // if (!resource || (resource->GetType() != wxTYPE_DIALOG_BOX)) - if (!resource || (resource->GetType() == wxT("")) || + if (!resource || (resource->GetType().empty()) || ! ((resource->GetType() == wxT("wxDialog")) || (resource->GetType() == wxT("wxPanel")))) - return FALSE; + return false; wxString title(resource->GetTitle()); long theWindowStyle = resource->GetStyle(); @@ -3197,9 +3212,15 @@ bool wxLoadFromResource(wxWindow* thisWindow, wxWindow *parent, const wxString& if (thisWindow->IsKindOf(CLASSINFO(wxDialog))) { wxDialog *dialogBox = (wxDialog *)thisWindow; - long modalStyle = isModal ? wxDIALOG_MODAL : 0; - if (!dialogBox->Create(parent, -1, title, wxPoint(x, y), wxSize(width, height), theWindowStyle|modalStyle, name)) - return FALSE; + long modalStyle = isModal ? +#if WXWIN_COMPATIBILITY_2_6 + wxDIALOG_MODAL +#else + 0 +#endif // WXWIN_COMPATIBILITY_2_6 + : 0; + if (!dialogBox->Create(parent, wxID_ANY, 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) @@ -3208,13 +3229,13 @@ bool wxLoadFromResource(wxWindow* thisWindow, wxWindow *parent, const wxString& else if (thisWindow->IsKindOf(CLASSINFO(wxPanel))) { wxPanel* panel = (wxPanel *)thisWindow; - if (!panel->Create(parent, -1, wxPoint(x, y), wxSize(width, height), theWindowStyle | wxTAB_TRAVERSAL, name)) - return FALSE; + if (!panel->Create(parent, wxID_ANY, wxPoint(x, y), wxSize(width, height), theWindowStyle | wxTAB_TRAVERSAL, name)) + return false; } else { - if (!((wxWindow *)thisWindow)->Create(parent, -1, wxPoint(x, y), wxSize(width, height), theWindowStyle, name)) - return FALSE; + if (!((wxWindow *)thisWindow)->Create(parent, wxID_ANY, wxPoint(x, y), wxSize(width, height), theWindowStyle, name)) + return false; } } @@ -3258,7 +3279,7 @@ bool wxLoadFromResource(wxWindow* thisWindow, wxWindow *parent, const wxString& node = node->GetNext(); } - return TRUE; + return true; } wxControl *wxCreateItem(wxWindow* thisWindow, const wxItemResource *resource, const wxItemResource* parentResource, const wxResourceTable *table) @@ -3273,4 +3294,3 @@ wxControl *wxCreateItem(wxWindow* thisWindow, const wxItemResource *resource, co #endif // VC++ #endif // wxUSE_WX_RESOURCES -