X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/f6bcfd974ef26faf6f91a62cac09827e09463fd1..6443de026310552cacd68a6d0318e73d14929680:/src/common/resource.cpp?ds=sidebyside diff --git a/src/common/resource.cpp b/src/common/resource.cpp index e80276a71e..8f7a71f1d3 100644 --- a/src/common/resource.cpp +++ b/src/common/resource.cpp @@ -53,6 +53,8 @@ #include "wx/intl.h" #endif +#include "wx/listctrl.h" + #if wxUSE_RADIOBTN #include "wx/radiobut.h" #endif @@ -175,10 +177,10 @@ void wxResourceTable::AddResource(wxItemResource *item) name = item->GetTitle(); if (name == wxT("")) name = wxT("no name"); - + // Delete existing resource, if any. Delete(name); - + Put(name, item); } @@ -202,7 +204,7 @@ bool wxResourceTable::DeleteResource(const wxString& name) } node = Next(); } - + delete item; return TRUE; } @@ -214,7 +216,7 @@ bool wxResourceTable::ParseResourceFile( wxInputStream *is ) { wxExprDatabase db; int len = is->StreamSize() ; - + bool eof = FALSE; while ( is->TellI() + 10 < len) // it's a hack because the streams dont support EOF { @@ -226,12 +228,8 @@ bool wxResourceTable::ParseResourceFile( wxInputStream *is ) bool wxResourceTable::ParseResourceFile(const wxString& filename) { wxExprDatabase db; - -#ifdef __WXMAC__ - FILE *fd = fopen(wxUnix2MacFilename(filename.fn_str()), "r"); -#else + FILE *fd = wxFopen(filename, _T("r")); -#endif if (!fd) return FALSE; bool eof = FALSE; @@ -251,7 +249,7 @@ bool wxResourceTable::ParseResourceData(const wxString& data) wxLogWarning(_("Ill-formed resource file syntax.")); return FALSE; } - + return wxResourceInterpretResources(*this, db); } @@ -305,12 +303,12 @@ wxControl *wxResourceTable::CreateItem(wxWindow *parent, const wxItemResource* c int id = childResource->GetId(); if ( id == 0 ) id = -1; - + bool dlgUnits = ((parentResource->GetResourceStyle() & wxRESOURCE_DIALOG_UNITS) != 0); - + wxControl *control = (wxControl *) NULL; wxString itemType(childResource->GetType()); - + wxPoint pos; wxSize size; if (dlgUnits) @@ -323,7 +321,7 @@ wxControl *wxResourceTable::CreateItem(wxWindow *parent, const wxItemResource* c pos = wxPoint(childResource->GetX(), childResource->GetY()); size = wxSize(childResource->GetWidth(), childResource->GetHeight()); } - + if (itemType == wxString(wxT("wxButton")) || itemType == wxString(wxT("wxBitmapButton"))) { if (childResource->GetValue4() != wxT("")) @@ -363,7 +361,7 @@ wxControl *wxResourceTable::CreateItem(wxWindow *parent, const wxItemResource* c if (!bitmap.Ok()) bitmap.LoadFile("cross_bmp", wxBITMAP_TYPE_BMP_RESOURCE); #endif - + if (bitmap.Ok()) control = new wxStaticBitmap(parent, id, bitmap, pos, size, childResource->GetStyle(), childResource->GetName()); @@ -384,7 +382,7 @@ wxControl *wxResourceTable::CreateItem(wxWindow *parent, const wxItemResource* c { control = new wxCheckBox(parent, id, childResource->GetTitle(), pos, size, childResource->GetStyle(), wxDefaultValidator, childResource->GetName()); - + ((wxCheckBox *)control)->SetValue((childResource->GetValue1() != 0)); } #if wxUSE_GAUGE @@ -392,7 +390,7 @@ wxControl *wxResourceTable::CreateItem(wxWindow *parent, const wxItemResource* c { control = new wxGauge(parent, id, (int)childResource->GetValue2(), pos, size, childResource->GetStyle(), wxDefaultValidator, childResource->GetName()); - + ((wxGauge *)control)->SetValue((int)childResource->GetValue1()); } #endif @@ -417,7 +415,7 @@ wxControl *wxResourceTable::CreateItem(wxWindow *parent, const wxItemResource* c */ ((wxScrollBar *)control)->SetScrollbar((int)childResource->GetValue1(),(int)childResource->GetValue2(), (int)childResource->GetValue3(),(int)(long)childResource->GetValue5(),FALSE); - + } #endif else if (itemType == wxString(wxT("wxSlider"))) @@ -451,7 +449,7 @@ wxControl *wxResourceTable::CreateItem(wxWindow *parent, const wxItemResource* c } control = new wxListBox(parent, id, pos, size, noStrings, strings, childResource->GetStyle(), wxDefaultValidator, childResource->GetName()); - + if (strings) delete[] strings; } @@ -475,7 +473,7 @@ wxControl *wxResourceTable::CreateItem(wxWindow *parent, const wxItemResource* c } control = new wxChoice(parent, id, pos, size, noStrings, strings, childResource->GetStyle(), wxDefaultValidator, childResource->GetName()); - + if (strings) delete[] strings; } @@ -500,7 +498,7 @@ wxControl *wxResourceTable::CreateItem(wxWindow *parent, const wxItemResource* c } control = new wxComboBox(parent, id, childResource->GetValue4(), pos, size, noStrings, strings, childResource->GetStyle(), wxDefaultValidator, childResource->GetName()); - + if (strings) delete[] strings; } @@ -526,11 +524,11 @@ wxControl *wxResourceTable::CreateItem(wxWindow *parent, const wxItemResource* c control = new wxRadioBox(parent, (wxWindowID) id, wxString(childResource->GetTitle()), pos, size, noStrings, strings, (int)childResource->GetValue1(), childResource->GetStyle(), wxDefaultValidator, childResource->GetName()); - + if (strings) delete[] strings; } - + if ((parentResource->GetResourceStyle() & wxRESOURCE_USE_DEFAULTS) != 0) { // Don't set font; will be inherited from parent. @@ -540,7 +538,7 @@ wxControl *wxResourceTable::CreateItem(wxWindow *parent, const wxItemResource* c if (control && childResource->GetFont().Ok()) { control->SetFont(childResource->GetFont()); - + #ifdef __WXMSW__ // Force the layout algorithm since the size changes the layout if (control->IsKindOf(CLASSINFO(wxRadioBox))) @@ -564,7 +562,7 @@ bool wxResourceInterpretResources(wxResourceTable& table, wxExprDatabase& db) { wxExpr *clause = (wxExpr *)node->Data(); wxString functor(clause->Functor()); - + wxItemResource *item = (wxItemResource *) NULL; if (functor == wxT("dialog")) item = wxResourceInterpretDialog(table, clause); @@ -580,7 +578,7 @@ bool wxResourceInterpretResources(wxResourceTable& table, wxExprDatabase& db) item = wxResourceInterpretBitmap(table, clause); else if (functor == wxT("icon")) item = wxResourceInterpretIcon(table, clause); - + if (item) { // Remove any existing resource of same name @@ -640,11 +638,11 @@ wxItemResource *wxResourceInterpretDialog(wxResourceTable& table, wxExpr *expr, wxString backColourHex = wxT(""); wxString labelColourHex = wxT(""); wxString buttonColourHex = wxT(""); - + 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; @@ -664,21 +662,21 @@ wxItemResource *wxResourceInterpretDialog(wxResourceTable& table, wxExpr *expr, expr->GetAttributeValue(wxT("background_colour"), backColourHex); expr->GetAttributeValue(wxT("label_colour"), labelColourHex); expr->GetAttributeValue(wxT("button_colour"), buttonColourHex); - + int useDialogUnits = 0; expr->GetAttributeValue(wxT("use_dialog_units"), useDialogUnits); if (useDialogUnits != 0) dialogItem->SetResourceStyle(dialogItem->GetResourceStyle() | wxRESOURCE_DIALOG_UNITS); - + int useDefaults = 0; expr->GetAttributeValue(wxT("use_system_defaults"), useDefaults); if (useDefaults != 0) dialogItem->SetResourceStyle(dialogItem->GetResourceStyle() | wxRESOURCE_USE_DEFAULTS); - + int id = 0; expr->GetAttributeValue(wxT("id"), id); dialogItem->SetId(id); - + if (style != wxT("")) { windowStyle = wxParseWindowStyle(style); @@ -687,7 +685,7 @@ wxItemResource *wxResourceInterpretDialog(wxResourceTable& table, wxExpr *expr, dialogItem->SetValue1(isModal); if (windowStyle & wxDIALOG_MODAL) // Uses style in wxWin 2 dialogItem->SetValue1(TRUE); - + dialogItem->SetName(name); dialogItem->SetTitle(title); dialogItem->SetSize(x, y, width, height); @@ -696,8 +694,8 @@ wxItemResource *wxResourceInterpretDialog(wxResourceTable& table, wxExpr *expr, if (style.Find(wxT("VERTICAL_LABEL")) != -1) dialogItem->SetResourceStyle(dialogItem->GetResourceStyle() | wxRESOURCE_VERTICAL_LABEL); else if (style.Find(wxT("HORIZONTAL_LABEL")) != -1) - dialogItem->SetResourceStyle(dialogItem->GetResourceStyle() | wxRESOURCE_HORIZONTAL_LABEL); - + dialogItem->SetResourceStyle(dialogItem->GetResourceStyle() | wxRESOURCE_HORIZONTAL_LABEL); + if (backColourHex != wxT("")) { int r = 0; @@ -728,14 +726,14 @@ wxItemResource *wxResourceInterpretDialog(wxResourceTable& table, wxExpr *expr, b = wxHexToDec(buttonColourHex.Mid(4, 2)); dialogItem->SetButtonColour(wxColour((unsigned char)r,(unsigned char)g,(unsigned char)b)); } - + if (fontExpr) dialogItem->SetFont(wxResourceInterpretFontSpec(fontExpr)); else if (buttonFontExpr) dialogItem->SetFont(wxResourceInterpretFontSpec(buttonFontExpr)); else if (labelFontExpr) dialogItem->SetFont(wxResourceInterpretFontSpec(labelFontExpr)); - + // Now parse all controls wxExpr *controlExpr = expr->GetFirst(); while (controlExpr) @@ -765,10 +763,10 @@ wxItemResource *wxResourceInterpretDialog(wxResourceTable& table, wxExpr *expr, wxItemResource *wxResourceInterpretControl(wxResourceTable& table, wxExpr *expr) { wxItemResource *controlItem = new wxItemResource; - + // First, find the standard features of a control definition: // [optional integer/string id], control name, title, style, name, x, y, width, height - + wxString controlType; wxString style; wxString title; @@ -777,9 +775,9 @@ wxItemResource *wxResourceInterpretControl(wxResourceTable& table, wxExpr *expr) long windowStyle = 0; int x = 0; int y = 0; int width = -1; int height = -1; int count = 0; - + wxExpr *expr1 = expr->Nth(0); - + if ( expr1->Type() == PrologString || expr1->Type() == PrologWord ) { if ( wxIsValidControlClass(expr1->StringValue()) ) @@ -813,12 +811,12 @@ wxItemResource *wxResourceInterpretControl(wxResourceTable& table, wxExpr *expr) controlType = expr->Nth(1)->StringValue(); count = 2; } - + expr1 = expr->Nth(count); count ++; if ( expr1 ) title = expr1->StringValue(); - + expr1 = expr->Nth(count); count ++; if (expr1) @@ -826,32 +824,32 @@ wxItemResource *wxResourceInterpretControl(wxResourceTable& table, wxExpr *expr) style = expr1->StringValue(); windowStyle = wxParseWindowStyle(style); } - + expr1 = expr->Nth(count); count ++; if (expr1) name = expr1->StringValue(); - + expr1 = expr->Nth(count); count ++; if (expr1) x = (int)expr1->IntegerValue(); - + expr1 = expr->Nth(count); count ++; if (expr1) y = (int)expr1->IntegerValue(); - + expr1 = expr->Nth(count); count ++; if (expr1) width = (int)expr1->IntegerValue(); - + expr1 = expr->Nth(count); count ++; if (expr1) height = (int)expr1->IntegerValue(); - + controlItem->SetStyle(windowStyle); controlItem->SetName(name); controlItem->SetTitle(title); @@ -864,7 +862,7 @@ wxItemResource *wxResourceInterpretControl(wxResourceTable& table, wxExpr *expr) controlItem->SetResourceStyle(controlItem->GetResourceStyle() | wxRESOURCE_VERTICAL_LABEL); else if (style.Find(wxT("HORIZONTAL_LABEL")) != -1) controlItem->SetResourceStyle(controlItem->GetResourceStyle() | wxRESOURCE_HORIZONTAL_LABEL); - + if (controlType == wxT("wxButton")) { // Check for bitmap resource name (in case loading old-style resource file) @@ -872,7 +870,7 @@ wxItemResource *wxResourceInterpretControl(wxResourceTable& table, wxExpr *expr) { wxString str(expr->Nth(count)->StringValue()); count ++; - + if (str != wxT("")) { controlItem->SetValue4(str); @@ -926,7 +924,7 @@ 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->SetLabelFont(wxResourceInterpretFontSpec(expr->Nth(count))); @@ -974,13 +972,13 @@ wxItemResource *wxResourceInterpretControl(wxResourceTable& table, wxExpr *expr) { controlItem->SetValue1(expr->Nth(count)->IntegerValue()); count ++; - + // Check for range if (expr->Nth(count) && (expr->Nth(count)->Type() == PrologInteger)) { controlItem->SetValue2(expr->Nth(count)->IntegerValue()); count ++; - + if (expr->Nth(count) && expr->Nth(count)->Type() == PrologList) { // Skip past the obsolete label font spec if there are two consecutive specs @@ -998,25 +996,25 @@ wxItemResource *wxResourceInterpretControl(wxResourceTable& table, wxExpr *expr) { controlItem->SetValue1(expr->Nth(count)->IntegerValue()); count ++; - + // Check for min if (expr->Nth(count) && (expr->Nth(count)->Type() == PrologInteger)) { controlItem->SetValue2(expr->Nth(count)->IntegerValue()); count ++; - + // Check for max if (expr->Nth(count) && (expr->Nth(count)->Type() == PrologInteger)) { controlItem->SetValue3(expr->Nth(count)->IntegerValue()); count ++; - + if (expr->Nth(count) && expr->Nth(count)->Type() == PrologList) { // controlItem->SetLabelFont(wxResourceInterpretFontSpec(expr->Nth(count))); // do nothing count ++; - + if (expr->Nth(count) && expr->Nth(count)->Type() == PrologList) controlItem->SetFont(wxResourceInterpretFontSpec(expr->Nth(count))); } @@ -1031,19 +1029,19 @@ wxItemResource *wxResourceInterpretControl(wxResourceTable& table, wxExpr *expr) { controlItem->SetValue1(expr->Nth(count)->IntegerValue()); count ++; - + // PAGE LENGTH if (expr->Nth(count) && (expr->Nth(count)->Type() == PrologInteger)) { controlItem->SetValue2(expr->Nth(count)->IntegerValue()); count ++; - + // OBJECT LENGTH if (expr->Nth(count) && (expr->Nth(count)->Type() == PrologInteger)) { controlItem->SetValue3(expr->Nth(count)->IntegerValue()); count ++; - + // VIEW LENGTH if (expr->Nth(count) && (expr->Nth(count)->Type() == PrologInteger)) controlItem->SetValue5(expr->Nth(count)->IntegerValue()); @@ -1054,8 +1052,8 @@ wxItemResource *wxResourceInterpretControl(wxResourceTable& table, wxExpr *expr) else if (controlType == wxT("wxListBox")) { wxExpr *valueList = (wxExpr *) NULL; - - if ((valueList = expr->Nth(count)) && (valueList->Type() == PrologList)) + + if (((valueList = expr->Nth(count)) != 0) && (valueList->Type() == PrologList)) { wxStringList stringList; wxExpr *stringExpr = valueList->GetFirst(); @@ -1072,7 +1070,7 @@ wxItemResource *wxResourceInterpretControl(wxResourceTable& table, wxExpr *expr) /* controlItem->SetValue1(wxLB_SINGLE); */ - if ((mult = expr->Nth(count)) && ((mult->Type() == PrologString)||(mult->Type() == PrologWord))) + if (((mult = expr->Nth(count)) != 0) && ((mult->Type() == PrologString)||(mult->Type() == PrologWord))) { /* wxString m(mult->StringValue()); @@ -1097,7 +1095,7 @@ wxItemResource *wxResourceInterpretControl(wxResourceTable& table, wxExpr *expr) { wxExpr *valueList = (wxExpr *) NULL; // Check for default value list - if ((valueList = expr->Nth(count)) && (valueList->Type() == PrologList)) + if (((valueList = expr->Nth(count)) != 0) && (valueList->Type() == PrologList)) { wxStringList stringList; wxExpr *stringExpr = valueList->GetFirst(); @@ -1107,9 +1105,9 @@ wxItemResource *wxResourceInterpretControl(wxResourceTable& table, wxExpr *expr) stringExpr = stringExpr->GetNext(); } controlItem->SetStringValues(stringList); - + count ++; - + if (expr->Nth(count) && expr->Nth(count)->Type() == PrologList) { // Skip past the obsolete label font spec if there are two consecutive specs @@ -1127,12 +1125,12 @@ wxItemResource *wxResourceInterpretControl(wxResourceTable& table, wxExpr *expr) { wxString str(textValue->StringValue()); controlItem->SetValue4(str); - + count ++; - + wxExpr *valueList = (wxExpr *) NULL; // Check for default value list - if ((valueList = expr->Nth(count)) && (valueList->Type() == PrologList)) + if (((valueList = expr->Nth(count)) != 0) && (valueList->Type() == PrologList)) { wxStringList stringList; wxExpr *stringExpr = valueList->GetFirst(); @@ -1142,9 +1140,9 @@ wxItemResource *wxResourceInterpretControl(wxResourceTable& table, wxExpr *expr) stringExpr = stringExpr->GetNext(); } controlItem->SetStringValues(stringList); - + count ++; - + if (expr->Nth(count) && expr->Nth(count)->Type() == PrologList) { // Skip past the obsolete label font spec if there are two consecutive specs @@ -1161,7 +1159,7 @@ wxItemResource *wxResourceInterpretControl(wxResourceTable& table, wxExpr *expr) { wxExpr *valueList = (wxExpr *) NULL; // Check for default value list - if ((valueList = expr->Nth(count)) && (valueList->Type() == PrologList)) + if (((valueList = expr->Nth(count)) != 0) && (valueList->Type() == PrologList)) { wxStringList stringList; wxExpr *stringExpr = valueList->GetFirst(); @@ -1172,7 +1170,7 @@ wxItemResource *wxResourceInterpretControl(wxResourceTable& table, wxExpr *expr) } controlItem->SetStringValues(stringList); count ++; - + // majorDim (number of rows or cols) if (expr->Nth(count) && (expr->Nth(count)->Type() == PrologInteger)) { @@ -1181,7 +1179,7 @@ wxItemResource *wxResourceInterpretControl(wxResourceTable& table, wxExpr *expr) } else controlItem->SetValue1(0); - + if (expr->Nth(count) && expr->Nth(count)->Type() == PrologList) { // Skip past the obsolete label font spec if there are two consecutive specs @@ -1210,12 +1208,12 @@ 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); wxExpr *checkableExpr = expr->Nth(3); - + // Further keywords/attributes to follow sometime... if (expr->Number() == 0) { @@ -1257,12 +1255,12 @@ wxItemResource *wxResourceInterpretMenuItem(wxResourceTable& table, wxExpr *expr } if (checkableExpr) item->SetValue2(checkableExpr->IntegerValue()); - + // Find the first expression that's a list, for submenu wxExpr *subMenuExpr = expr->GetFirst(); while (subMenuExpr && (subMenuExpr->Type() != PrologList)) subMenuExpr = subMenuExpr->GetNext(); - + while (subMenuExpr) { wxItemResource *child = wxResourceInterpretMenuItem(table, subMenuExpr); @@ -1300,18 +1298,18 @@ wxItemResource *wxResourceInterpretMenu(wxResourceTable& table, wxExpr *expr) expr->GetAttributeValue(wxT("menu"), &listExpr); if (!listExpr) return (wxItemResource *) NULL; - + wxItemResource *menuResource = wxResourceInterpretMenuItem(table, listExpr); - + if (!menuResource) return (wxItemResource *) NULL; - + wxString name; if (expr->GetAttributeValue(wxT("name"), name)) { menuResource->SetName(name); } - + return menuResource; } @@ -1321,11 +1319,11 @@ wxItemResource *wxResourceInterpretMenuBar(wxResourceTable& table, wxExpr *expr) expr->GetAttributeValue(wxT("menu"), &listExpr); if (!listExpr) return (wxItemResource *) NULL; - + wxItemResource *resource = new wxItemResource; resource->SetType(wxT("wxMenu")); // resource->SetType(wxTYPE_MENU); - + wxExpr *element = listExpr->GetFirst(); while (element) { @@ -1333,13 +1331,13 @@ wxItemResource *wxResourceInterpretMenuBar(wxResourceTable& table, wxExpr *expr) resource->GetChildren().Append(menuResource); element = element->GetNext(); } - + wxString name; if (expr->GetAttributeValue(wxT("name"), name)) { resource->SetName(name); } - + return resource; } @@ -1374,7 +1372,7 @@ wxItemResource *wxResourceInterpretBitmap(wxResourceTable& WXUNUSED(table), wxEx wxItemResource *bitmapSpec = new wxItemResource; // bitmapSpec->SetType(wxTYPE_BITMAP); bitmapSpec->SetType(wxT("wxBitmap")); - + // List is of form: [filename, bitmaptype, platform, colours, xresolution, yresolution] // where everything after 'filename' is optional. wxExpr *nameExpr = listExpr->Nth(0); @@ -1393,7 +1391,7 @@ wxItemResource *wxResourceInterpretBitmap(wxResourceTable& WXUNUSED(table), wxEx } else bitmapSpec->SetValue1(0); - + if (platformExpr && platformExpr->StringValue() != wxT("")) { wxString plat(platformExpr->StringValue()); @@ -1408,7 +1406,7 @@ wxItemResource *wxResourceInterpretBitmap(wxResourceTable& WXUNUSED(table), wxEx } else bitmapSpec->SetValue2(RESOURCE_PLATFORM_ANY); - + if (coloursExpr) bitmapSpec->SetValue3(coloursExpr->IntegerValue()); int xres = 0; @@ -1418,14 +1416,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; } @@ -1447,14 +1445,14 @@ wxFont wxResourceInterpretFontSpec(wxExpr *expr) { if (expr->Type() != PrologList) return wxNullFont; - + int point = 10; int family = wxSWISS; int style = wxNORMAL; int weight = wxNORMAL; int underline = 0; wxString faceName(wxT("")); - + wxExpr *pointExpr = expr->Nth(0); wxExpr *familyExpr = expr->Nth(1); wxExpr *styleExpr = expr->Nth(2); @@ -1463,7 +1461,7 @@ wxFont wxResourceInterpretFontSpec(wxExpr *expr) wxExpr *faceNameExpr = expr->Nth(5); if (pointExpr) point = (int)pointExpr->IntegerValue(); - + wxString str; if (familyExpr) { @@ -1484,7 +1482,7 @@ wxFont wxResourceInterpretFontSpec(wxExpr *expr) underline = (int)underlineExpr->IntegerValue(); if (faceNameExpr) faceName = faceNameExpr->StringValue(); - + wxFont font(point, family, style, weight, (underline != 0), faceName); return font; } @@ -1519,7 +1517,7 @@ bool wxReallocateResourceBuffer() static bool wxEatWhiteSpace(FILE *fd) { int ch = 0; - + while ((ch = getc(fd)) != EOF) { switch (ch) @@ -1538,7 +1536,7 @@ static bool wxEatWhiteSpace(FILE *fd) ungetc(prev_ch, fd); return TRUE; } - + if (ch == '*') { // Eat C comment @@ -1567,7 +1565,7 @@ static bool wxEatWhiteSpace(FILE *fd) default: ungetc(ch, fd); return TRUE; - + } } return FALSE; @@ -1580,7 +1578,7 @@ static bool wxEatWhiteSpace(wxInputStream *is) is->Ungetch(ch); return TRUE; } - + // Eat whitespace while (ch == ' ' || ch == 10 || ch == 13 || ch == 9) ch = is->GetC(); @@ -1622,7 +1620,7 @@ bool wxGetResourceToken(FILE *fd) wxReallocateResourceBuffer(); wxResourceBuffer[0] = 0; wxEatWhiteSpace(fd); - + int ch = getc(fd); if (ch == '"') { @@ -1650,7 +1648,7 @@ bool wxGetResourceToken(FILE *fd) ungetc(newCh, fd); } } - + if (wxResourceBufferCount >= wxResourceBufferSize-1) wxReallocateResourceBuffer(); wxResourceBuffer[wxResourceBufferCount] = (char)actualCh; @@ -1669,7 +1667,7 @@ bool wxGetResourceToken(FILE *fd) wxReallocateResourceBuffer(); wxResourceBuffer[wxResourceBufferCount] = (char)ch; wxResourceBufferCount ++; - + ch = getc(fd); } wxResourceBuffer[wxResourceBufferCount] = 0; @@ -1685,7 +1683,7 @@ bool wxGetResourceToken(wxInputStream *is) wxReallocateResourceBuffer(); wxResourceBuffer[0] = 0; wxEatWhiteSpace(is); - + int ch = is->GetC() ; if (ch == '"') { @@ -1715,7 +1713,7 @@ bool wxGetResourceToken(wxInputStream *is) is->Ungetch(newCh); } } - + if (wxResourceBufferCount >= wxResourceBufferSize-1) wxReallocateResourceBuffer(); wxResourceBuffer[wxResourceBufferCount] = (char)actualCh; @@ -1734,7 +1732,7 @@ bool wxGetResourceToken(wxInputStream *is) wxReallocateResourceBuffer(); wxResourceBuffer[wxResourceBufferCount] = (char)ch; wxResourceBufferCount ++; - + ch = is->GetC(); } wxResourceBuffer[wxResourceBufferCount] = 0; @@ -1754,14 +1752,14 @@ bool wxResourceReadOneResource(FILE *fd, wxExprDatabase& db, bool *eof, wxResour { if (!table) table = wxDefaultResourceTable; - + // static or #define if (!wxGetResourceToken(fd)) { *eof = TRUE; return FALSE; } - + if (strcmp(wxResourceBuffer, "#define") == 0) { wxGetResourceToken(fd); @@ -1782,7 +1780,7 @@ bool wxResourceReadOneResource(FILE *fd, wxExprDatabase& db, bool *eof, wxResour } delete[] name; delete[] value; - + return TRUE; } else if (strcmp(wxResourceBuffer, "#include") == 0) @@ -1811,7 +1809,7 @@ bool wxResourceReadOneResource(FILE *fd, wxExprDatabase& db, bool *eof, wxResour wxLogWarning(buf); return FALSE; } - + // char if (!wxGetResourceToken(fd)) { @@ -1819,13 +1817,13 @@ bool wxResourceReadOneResource(FILE *fd, wxExprDatabase& db, bool *eof, wxResour *eof = TRUE; return FALSE; } - + if (strcmp(wxResourceBuffer, "char") != 0) { wxLogWarning(_("Expected 'char' whilst parsing resource.")); return FALSE; } - + // *name if (!wxGetResourceToken(fd)) { @@ -1833,7 +1831,7 @@ bool wxResourceReadOneResource(FILE *fd, wxExprDatabase& db, bool *eof, wxResour *eof = TRUE; return FALSE; } - + if (wxResourceBuffer[0] != '*') { wxLogWarning(_("Expected '*' whilst parsing resource.")); @@ -1842,7 +1840,7 @@ bool wxResourceReadOneResource(FILE *fd, wxExprDatabase& db, bool *eof, wxResour wxChar nameBuf[100]; wxMB2WX(nameBuf, wxResourceBuffer+1, 99); nameBuf[99] = 0; - + // = if (!wxGetResourceToken(fd)) { @@ -1850,13 +1848,13 @@ bool wxResourceReadOneResource(FILE *fd, wxExprDatabase& db, bool *eof, wxResour *eof = TRUE; return FALSE; } - + if (strcmp(wxResourceBuffer, "=") != 0) { wxLogWarning(_("Expected '=' whilst parsing resource.")); return FALSE; } - + // String if (!wxGetResourceToken(fd)) { @@ -1884,14 +1882,14 @@ bool wxResourceReadOneResource(wxInputStream *fd, wxExprDatabase& db, bool *eof, { if (!table) table = wxDefaultResourceTable; - + // static or #define if (!wxGetResourceToken(fd)) { *eof = TRUE; return FALSE; } - + if (strcmp(wxResourceBuffer, "#define") == 0) { wxGetResourceToken(fd); @@ -1912,7 +1910,7 @@ bool wxResourceReadOneResource(wxInputStream *fd, wxExprDatabase& db, bool *eof, } delete[] name; delete[] value; - + return TRUE; } else if (strcmp(wxResourceBuffer, "#include") == 0) @@ -1941,7 +1939,7 @@ bool wxResourceReadOneResource(wxInputStream *fd, wxExprDatabase& db, bool *eof, wxLogWarning(buf); return FALSE; } - + // char if (!wxGetResourceToken(fd)) { @@ -1949,13 +1947,13 @@ bool wxResourceReadOneResource(wxInputStream *fd, wxExprDatabase& db, bool *eof, *eof = TRUE; return FALSE; } - + if (strcmp(wxResourceBuffer, "char") != 0) { wxLogWarning(_("Expected 'char' whilst parsing resource.")); return FALSE; } - + // *name if (!wxGetResourceToken(fd)) { @@ -1963,7 +1961,7 @@ bool wxResourceReadOneResource(wxInputStream *fd, wxExprDatabase& db, bool *eof, *eof = TRUE; return FALSE; } - + if (wxResourceBuffer[0] != '*') { wxLogWarning(_("Expected '*' whilst parsing resource.")); @@ -1971,7 +1969,7 @@ bool wxResourceReadOneResource(wxInputStream *fd, wxExprDatabase& db, bool *eof, } char nameBuf[100]; strncpy(nameBuf, wxResourceBuffer+1, 99); - + // = if (!wxGetResourceToken(fd)) { @@ -1979,13 +1977,13 @@ bool wxResourceReadOneResource(wxInputStream *fd, wxExprDatabase& db, bool *eof, *eof = TRUE; return FALSE; } - + if (strcmp(wxResourceBuffer, "=") != 0) { wxLogWarning(_("Expected '=' whilst parsing resource.")); return FALSE; } - + // String if (!wxGetResourceToken(fd)) { @@ -2022,7 +2020,7 @@ wxChar* wxResourceParseWord(wxChar*s, int *i) { if (!s) return (wxChar*) NULL; - + static wxChar buf[150]; int len = wxStrlen(s); int j = 0; @@ -2034,7 +2032,7 @@ wxChar* wxResourceParseWord(wxChar*s, int *i) ii ++; } buf[j] = 0; - + // Eat whitespace and conjunction characters while ((ii < len) && ((s[ii] == wxT(' ')) || (s[ii] == wxT('|')) || (s[ii] == wxT(',')))) @@ -2068,18 +2066,18 @@ static wxResourceBitListStruct wxResourceBitListTable[] = { wxT("wxLB_SORT"), wxLB_SORT }, { wxT("wxLB_OWNERDRAW"), wxLB_OWNERDRAW }, { wxT("wxLB_HSCROLL"), wxLB_HSCROLL }, - + /* wxComboxBox */ { wxT("wxCB_SIMPLE"), wxCB_SIMPLE }, { wxT("wxCB_DROPDOWN"), wxCB_DROPDOWN }, { wxT("wxCB_READONLY"), wxCB_READONLY }, { wxT("wxCB_SORT"), wxCB_SORT }, - + /* wxGauge */ { wxT("wxGA_PROGRESSBAR"), wxGA_PROGRESSBAR }, { wxT("wxGA_HORIZONTAL"), wxGA_HORIZONTAL }, { wxT("wxGA_VERTICAL"), wxGA_VERTICAL }, - + /* wxTextCtrl */ { wxT("wxPASSWORD"), wxPASSWORD}, { wxT("wxPROCESS_ENTER"), wxPROCESS_ENTER}, @@ -2088,14 +2086,14 @@ static wxResourceBitListStruct wxResourceBitListTable[] = { wxT("wxTE_PROCESS_ENTER"), wxTE_PROCESS_ENTER}, { wxT("wxTE_MULTILINE"), wxTE_MULTILINE}, { wxT("wxTE_NO_VSCROLL"), wxTE_NO_VSCROLL}, - + /* wxRadioBox/wxRadioButton */ { wxT("wxRB_GROUP"), wxRB_GROUP }, { wxT("wxRA_SPECIFY_COLS"), wxRA_SPECIFY_COLS }, { wxT("wxRA_SPECIFY_ROWS"), wxRA_SPECIFY_ROWS }, { wxT("wxRA_HORIZONTAL"), wxRA_HORIZONTAL }, { wxT("wxRA_VERTICAL"), wxRA_VERTICAL }, - + /* wxSlider */ { wxT("wxSL_HORIZONTAL"), wxSL_HORIZONTAL }, { wxT("wxSL_VERTICAL"), wxSL_VERTICAL }, @@ -2107,20 +2105,20 @@ static wxResourceBitListStruct wxResourceBitListTable[] = { wxT("wxSL_BOTTOM"), wxSL_BOTTOM }, { wxT("wxSL_BOTH"), wxSL_BOTH }, { wxT("wxSL_SELRANGE"), wxSL_SELRANGE }, - + /* wxScrollBar */ { wxT("wxSB_HORIZONTAL"), wxSB_HORIZONTAL }, { wxT("wxSB_VERTICAL"), wxSB_VERTICAL }, - + /* wxButton */ { wxT("wxBU_AUTODRAW"), wxBU_AUTODRAW }, { wxT("wxBU_NOAUTODRAW"), wxBU_NOAUTODRAW }, - + /* wxTreeCtrl */ { wxT("wxTR_HAS_BUTTONS"), wxTR_HAS_BUTTONS }, { wxT("wxTR_EDIT_LABELS"), wxTR_EDIT_LABELS }, { wxT("wxTR_LINES_AT_ROOT"), wxTR_LINES_AT_ROOT }, - + /* wxListCtrl */ { wxT("wxLC_ICON"), wxLC_ICON }, { wxT("wxLC_SMALL_ICON"), wxLC_SMALL_ICON }, @@ -2136,27 +2134,27 @@ static wxResourceBitListStruct wxResourceBitListTable[] = { wxT("wxLC_SINGLE_SEL"), wxLC_SINGLE_SEL }, { wxT("wxLC_SORT_ASCENDING"), wxLC_SORT_ASCENDING }, { wxT("wxLC_SORT_DESCENDING"), wxLC_SORT_DESCENDING }, - + /* wxSpinButton */ { wxT("wxSP_VERTICAL"), wxSP_VERTICAL}, { wxT("wxSP_HORIZONTAL"), wxSP_HORIZONTAL}, { wxT("wxSP_ARROW_KEYS"), wxSP_ARROW_KEYS}, { wxT("wxSP_WRAP"), wxSP_WRAP}, - + /* wxSplitterWnd */ { wxT("wxSP_NOBORDER"), wxSP_NOBORDER}, { wxT("wxSP_3D"), wxSP_3D}, { wxT("wxSP_BORDER"), wxSP_BORDER}, - + /* wxTabCtrl */ { wxT("wxTC_MULTILINE"), wxTC_MULTILINE}, { wxT("wxTC_RIGHTJUSTIFY"), wxTC_RIGHTJUSTIFY}, { wxT("wxTC_FIXEDWIDTH"), wxTC_FIXEDWIDTH}, { wxT("wxTC_OWNERDRAW"), wxTC_OWNERDRAW}, - + /* wxStatusBar95 */ { wxT("wxST_SIZEGRIP"), wxST_SIZEGRIP}, - + /* wxControl */ { wxT("wxFIXED_LENGTH"), wxFIXED_LENGTH}, { wxT("wxALIGN_LEFT"), wxALIGN_LEFT}, @@ -2164,16 +2162,16 @@ static wxResourceBitListStruct wxResourceBitListTable[] = { wxT("wxALIGN_CENTRE"), wxALIGN_CENTRE}, { wxT("wxALIGN_RIGHT"), wxALIGN_RIGHT}, { wxT("wxCOLOURED"), wxCOLOURED}, - + /* wxToolBar */ { wxT("wxTB_3DBUTTONS"), wxTB_3DBUTTONS}, { wxT("wxTB_HORIZONTAL"), wxTB_HORIZONTAL}, { wxT("wxTB_VERTICAL"), wxTB_VERTICAL}, { wxT("wxTB_FLAT"), wxTB_FLAT}, - + /* wxDialog */ { wxT("wxDIALOG_MODAL"), wxDIALOG_MODAL }, - + /* Generic */ { wxT("wxVSCROLL"), wxVSCROLL }, { wxT("wxHSCROLL"), wxHSCROLL }, @@ -2210,11 +2208,12 @@ static wxResourceBitListStruct wxResourceBitListTable[] = { wxT("wxTRANSPARENT_WINDOW"), wxTRANSPARENT_WINDOW}, { wxT("wxNO_BORDER"), wxNO_BORDER}, { wxT("wxCLIP_CHILDREN"), wxCLIP_CHILDREN}, + { wxT("wxCLIP_SIBLINGS"), wxCLIP_SIBLINGS}, { wxT("wxTAB_TRAVERSAL"), 0}, // Compatibility only - + { wxT("wxTINY_CAPTION_HORIZ"), wxTINY_CAPTION_HORIZ}, { wxT("wxTINY_CAPTION_VERT"), wxTINY_CAPTION_VERT}, - + // Text font families { wxT("wxDEFAULT"), wxDEFAULT}, { wxT("wxDECORATIVE"), wxDECORATIVE}, @@ -2250,7 +2249,7 @@ static wxResourceBitListStruct wxResourceBitListTable[] = { wxT("wxCAP_ROUND"), wxCAP_ROUND}, { wxT("wxCAP_PROJECTING"), wxCAP_PROJECTING}, { wxT("wxCAP_BUTT"), wxCAP_BUTT}, - + // Logical ops { wxT("wxCLEAR"), wxCLEAR}, { wxT("wxXOR"), wxXOR}, @@ -2268,7 +2267,7 @@ static wxResourceBitListStruct wxResourceBitListTable[] = { wxT("wxNAND"), wxNAND}, { wxT("wxOR"), wxOR}, { wxT("wxSET"), wxSET}, - + { wxT("wxFLOOD_SURFACE"), wxFLOOD_SURFACE}, { wxT("wxFLOOD_BORDER"), wxFLOOD_BORDER}, { wxT("wxODDEVEN_RULE"), wxODDEVEN_RULE}, @@ -2294,7 +2293,7 @@ static wxResourceBitListStruct wxResourceBitListTable[] = { wxT("wxUSER_COLOURS"), wxUSER_COLOURS}, { wxT("wxVERTICAL_LABEL"), 0}, { wxT("wxHORIZONTAL_LABEL"), 0}, - + // Bitmap types (not strictly styles) { wxT("wxBITMAP_TYPE_XPM"), wxBITMAP_TYPE_XPM}, { wxT("wxBITMAP_TYPE_XBM"), wxBITMAP_TYPE_XBM}, @@ -2350,7 +2349,7 @@ wxBitmap wxResourceCreateBitmap(const wxString& resource, wxResourceTable *table { if (!table) table = wxDefaultResourceTable; - + wxItemResource *item = table->FindResource(resource); if (item) { @@ -2361,9 +2360,9 @@ wxBitmap wxResourceCreateBitmap(const wxString& resource, wxResourceTable *table } int thisDepth = wxDisplayDepth(); 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) @@ -2377,7 +2376,7 @@ wxBitmap wxResourceCreateBitmap(const wxString& resource, wxResourceTable *table int xRes = child->GetWidth(); int yRes = child->GetHeight(); */ - + switch (platform) { case RESOURCE_PLATFORM_ANY: @@ -2444,7 +2443,7 @@ wxBitmap wxResourceCreateBitmap(const wxString& resource, wxResourceTable *table // If no matching resource, fail. if (!optResource) return wxNullBitmap; - + wxString name = optResource->GetName(); int bitmapType = (int)optResource->GetValue1(); switch (bitmapType) @@ -2467,7 +2466,6 @@ wxBitmap wxResourceCreateBitmap(const wxString& resource, wxResourceTable *table } case wxBITMAP_TYPE_XPM_DATA: { -#if (defined(__WXGTK__)) || (defined(__WXMSW__) && wxUSE_XPM_IN_MSW) wxItemResource *item = table->FindResource(name); if (!item) { @@ -2475,14 +2473,10 @@ wxBitmap wxResourceCreateBitmap(const wxString& resource, wxResourceTable *table return wxNullBitmap; } return wxBitmap((char **)item->GetValue1()); -#else - wxLogWarning(_("No XPM facility available!")); - break; -#endif } default: { - return wxBitmap(name, bitmapType); + return wxBitmap(name, (wxBitmapType)bitmapType); } } #ifndef __WXGTK__ @@ -2505,7 +2499,7 @@ wxIcon wxResourceCreateIcon(const wxString& resource, wxResourceTable *table) { if (!table) table = wxDefaultResourceTable; - + wxItemResource *item = table->FindResource(resource); if (item) { @@ -2516,9 +2510,9 @@ wxIcon wxResourceCreateIcon(const wxString& resource, wxResourceTable *table) } int thisDepth = wxDisplayDepth(); 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) @@ -2532,7 +2526,7 @@ wxIcon wxResourceCreateIcon(const wxString& resource, wxResourceTable *table) int xRes = child->GetWidth(); int yRes = child->GetHeight(); */ - + switch (platform) { case RESOURCE_PLATFORM_ANY: @@ -2599,7 +2593,7 @@ wxIcon wxResourceCreateIcon(const wxString& resource, wxResourceTable *table) // If no matching resource, fail. if (!optResource) return wxNullIcon; - + wxString name = optResource->GetName(); int bitmapType = (int)optResource->GetValue1(); switch (bitmapType) @@ -2624,7 +2618,6 @@ wxIcon wxResourceCreateIcon(const wxString& resource, wxResourceTable *table) { // *** XPM ICON NOT YET IMPLEMENTED IN WXWINDOWS *** /* - #if (defined(__WXGTK__)) || (defined(__WXMSW__) && wxUSE_XPM_IN_MSW) wxItemResource *item = table->FindResource(name); if (!item) { @@ -2634,9 +2627,6 @@ wxIcon wxResourceCreateIcon(const wxString& resource, wxResourceTable *table) return NULL; } return wxIcon((char **)item->GetValue1()); - #else - wxLogWarning(_("No XPM facility available!")); - #endif */ wxLogWarning(_("No XPM icon facility available!")); break; @@ -2645,10 +2635,10 @@ wxIcon wxResourceCreateIcon(const wxString& resource, wxResourceTable *table) { #ifdef __WXGTK__ wxLogWarning(_("Icon resource specification %s not found."), (const wxChar*) resource); + break; #else return wxIcon(name, bitmapType); #endif - break; } } return wxNullIcon; @@ -2660,6 +2650,8 @@ wxIcon wxResourceCreateIcon(const wxString& resource, wxResourceTable *table) } } +#if wxUSE_MENUS + wxMenu *wxResourceCreateMenu(wxItemResource *item) { wxMenu *menu = new wxMenu; @@ -2688,7 +2680,7 @@ wxMenuBar *wxResourceCreateMenuBar(const wxString& resource, wxResourceTable *ta { if (!table) table = wxDefaultResourceTable; - + wxItemResource *menuResource = table->FindResource(resource); if (menuResource && (menuResource->GetType() != wxT("")) && (menuResource->GetType() == wxT("wxMenu"))) { @@ -2712,7 +2704,7 @@ wxMenu *wxResourceCreateMenu(const wxString& resource, wxResourceTable *table) { if (!table) table = wxDefaultResourceTable; - + wxItemResource *menuResource = table->FindResource(resource); if (menuResource && (menuResource->GetType() != wxT("")) && (menuResource->GetType() == wxT("wxMenu"))) // if (menuResource && (menuResource->GetType() == wxTYPE_MENU)) @@ -2720,12 +2712,14 @@ wxMenu *wxResourceCreateMenu(const wxString& resource, wxResourceTable *table) return (wxMenu *) NULL; } +#endif // wxUSE_MENUS + // Global equivalents (so don't have to refer to default table explicitly) bool wxResourceParseData(const wxString& resource, wxResourceTable *table) { if (!table) table = wxDefaultResourceTable; - + return table->ParseResourceData(resource); } @@ -2733,7 +2727,7 @@ bool wxResourceParseFile(const wxString& filename, wxResourceTable *table) { if (!table) table = wxDefaultResourceTable; - + return table->ParseResourceFile(filename); } @@ -2742,7 +2736,7 @@ bool wxResourceRegisterBitmapData(const wxString& name, char bits[], int width, { if (!table) table = wxDefaultResourceTable; - + return table->RegisterResourceBitmapData(name, bits, width, height); } @@ -2750,7 +2744,7 @@ bool wxResourceRegisterBitmapData(const wxString& name, char **data, wxResourceT { if (!table) table = wxDefaultResourceTable; - + return table->RegisterResourceBitmapData(name, data); } @@ -2758,7 +2752,7 @@ void wxResourceClear(wxResourceTable *table) { if (!table) table = wxDefaultResourceTable; - + table->ClearTable(); } @@ -2770,7 +2764,7 @@ bool wxResourceAddIdentifier(const wxString& name, int value, wxResourceTable *t { if (!table) table = wxDefaultResourceTable; - + table->identifiers.Put(name, (wxObject *)(long)value); return TRUE; } @@ -2779,7 +2773,7 @@ int wxResourceGetIdentifier(const wxString& name, wxResourceTable *table) { if (!table) table = wxDefaultResourceTable; - + return (int)(long)table->identifiers.Get(name); } @@ -2791,7 +2785,7 @@ bool wxResourceParseIncludeFile(const wxString& f, wxResourceTable *table) { if (!table) table = wxDefaultResourceTable; - + FILE *fd = wxFopen(f, _T("r")); if (!fd) { @@ -2843,7 +2837,7 @@ static int ungetc_string() bool wxEatWhiteSpaceString(char *s) { int ch = 0; - + while ((ch = getc_string(s)) != EOF) { switch (ch) @@ -2862,7 +2856,7 @@ bool wxEatWhiteSpaceString(char *s) ungetc_string(); return TRUE; } - + if (ch == '*') { // Eat C comment @@ -2885,7 +2879,7 @@ bool wxEatWhiteSpaceString(char *s) default: ungetc_string(); return TRUE; - + } } return FALSE; @@ -2897,7 +2891,7 @@ bool wxGetResourceTokenString(char *s) wxReallocateResourceBuffer(); wxResourceBuffer[0] = 0; wxEatWhiteSpaceString(s); - + int ch = getc_string(s); if (ch == '"') { @@ -2925,7 +2919,7 @@ bool wxGetResourceTokenString(char *s) ungetc_string(); } } - + if (wxResourceBufferCount >= wxResourceBufferSize-1) wxReallocateResourceBuffer(); wxResourceBuffer[wxResourceBufferCount] = (char)actualCh; @@ -2944,7 +2938,7 @@ bool wxGetResourceTokenString(char *s) wxReallocateResourceBuffer(); wxResourceBuffer[wxResourceBufferCount] = (char)ch; wxResourceBufferCount ++; - + ch = getc_string(s); } wxResourceBuffer[wxResourceBufferCount] = 0; @@ -2964,14 +2958,14 @@ bool wxResourceReadOneResourceString(char *s, wxExprDatabase& db, bool *eof, wxR { if (!table) table = wxDefaultResourceTable; - + // static or #define if (!wxGetResourceTokenString(s)) { *eof = TRUE; return FALSE; } - + if (strcmp(wxResourceBuffer, "#define") == 0) { wxGetResourceTokenString(s); @@ -2992,7 +2986,7 @@ bool wxResourceReadOneResourceString(char *s, wxExprDatabase& db, bool *eof, wxR } delete[] name; delete[] value; - + return TRUE; } /* @@ -3025,7 +3019,7 @@ bool wxResourceReadOneResourceString(char *s, wxExprDatabase& db, bool *eof, wxR wxLogWarning(buf); return FALSE; } - + // char if (!wxGetResourceTokenString(s)) { @@ -3033,13 +3027,13 @@ bool wxResourceReadOneResourceString(char *s, wxExprDatabase& db, bool *eof, wxR *eof = TRUE; return FALSE; } - + if (strcmp(wxResourceBuffer, "char") != 0) { wxLogWarning(_("Expected 'char' whilst parsing resource.")); return FALSE; } - + // *name if (!wxGetResourceTokenString(s)) { @@ -3047,7 +3041,7 @@ bool wxResourceReadOneResourceString(char *s, wxExprDatabase& db, bool *eof, wxR *eof = TRUE; return FALSE; } - + if (wxResourceBuffer[0] != '*') { wxLogWarning(_("Expected '*' whilst parsing resource.")); @@ -3056,7 +3050,7 @@ bool wxResourceReadOneResourceString(char *s, wxExprDatabase& db, bool *eof, wxR wxChar nameBuf[100]; wxMB2WX(nameBuf, wxResourceBuffer+1, 99); nameBuf[99] = 0; - + // = if (!wxGetResourceTokenString(s)) { @@ -3064,13 +3058,13 @@ bool wxResourceReadOneResourceString(char *s, wxExprDatabase& db, bool *eof, wxR *eof = TRUE; return FALSE; } - + if (strcmp(wxResourceBuffer, "=") != 0) { wxLogWarning(_("Expected '=' whilst parsing resource.")); return FALSE; } - + // String if (!wxGetResourceTokenString(s)) { @@ -3098,10 +3092,10 @@ bool wxResourceParseString(char *s, wxResourceTable *table) { if (!table) table = wxDefaultResourceTable; - + if (!s) return FALSE; - + // Turn backslashes into spaces if (s) { @@ -3114,10 +3108,10 @@ bool wxResourceParseString(char *s, wxResourceTable *table) s[i+1] = ' '; } } - + wxExprDatabase db; wxResourceStringPtr = 0; - + bool eof = FALSE; while (wxResourceReadOneResourceString(s, db, &eof, table) && !eof) { @@ -3134,13 +3128,13 @@ bool wxWindowBase::LoadFromResource(wxWindow *parent, const wxString& resourceNa { if (!table) table = wxDefaultResourceTable; - + wxItemResource *resource = table->FindResource((const wxChar *)resourceName); // if (!resource || (resource->GetType() != wxTYPE_DIALOG_BOX)) if (!resource || (resource->GetType() == wxT("")) || ! ((resource->GetType() == wxT("wxDialog")) || (resource->GetType() == wxT("wxPanel")))) return FALSE; - + wxString title(resource->GetTitle()); long theWindowStyle = resource->GetStyle(); bool isModal = (resource->GetValue1() != 0) ; @@ -3149,14 +3143,14 @@ bool wxWindowBase::LoadFromResource(wxWindow *parent, const wxString& resourceNa int width = resource->GetWidth(); int height = resource->GetHeight(); wxString name = resource->GetName(); - + if (IsKindOf(CLASSINFO(wxDialog))) { wxDialog *dialogBox = (wxDialog *)this; 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); @@ -3172,7 +3166,7 @@ bool wxWindowBase::LoadFromResource(wxWindow *parent, const wxString& resourceNa if (!((wxWindow *)this)->Create(parent, -1, wxPoint(x, y), wxSize(width, height), theWindowStyle, name)) return FALSE; } - + if ((resource->GetResourceStyle() & wxRESOURCE_USE_DEFAULTS) != 0) { // No need to do this since it's done in wxPanel or wxDialog constructor. @@ -3185,32 +3179,32 @@ bool wxWindowBase::LoadFromResource(wxWindow *parent, const wxString& resourceNa 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)); - + // 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); } - + // Now create children wxNode *node = resource->GetChildren().First(); while (node) { wxItemResource *childResource = (wxItemResource *)node->Data(); - + (void) CreateItem(childResource, resource, table); - + node = node->Next(); } return TRUE;