📄 resource.cpp
字号:
{ // Success - we have an id, so the 2nd element must be the control class. controlType = expr->Nth(1)->StringValue(); count = 2; } } } else if (expr1->Type() == PrologInteger) { id = (int)expr1->IntegerValue(); // Success - we have an id, so the 2nd element must be the control class. controlType = expr->Nth(1)->StringValue(); count = 2; } expr1 = expr->Nth(count); count ++; if ( expr1 ) title = expr1->StringValue(); expr1 = expr->Nth(count); count ++; if (expr1) { 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); controlItem->SetSize(x, y, width, height); controlItem->SetType(controlType); controlItem->SetId(id); // Check for wxWin 1.68-style specifications if (style.Find(wxT("VERTICAL_LABEL")) != wxNOT_FOUND) controlItem->SetResourceStyle(controlItem->GetResourceStyle() | wxRESOURCE_VERTICAL_LABEL); else if (style.Find(wxT("HORIZONTAL_LABEL")) != wxNOT_FOUND) controlItem->SetResourceStyle(controlItem->GetResourceStyle() | wxRESOURCE_HORIZONTAL_LABEL); if (controlType == wxT("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.empty()) { controlItem->SetValue4(str); controlItem->SetType(wxT("wxBitmapButton")); } } if (expr->Nth(count) && expr->Nth(count)->Type() == PrologList) controlItem->SetFont(wxResourceInterpretFontSpec(expr->Nth(count))); } else if (controlType == wxT("wxBitmapButton")) { // Check for bitmap resource name if (expr->Nth(count) && ((expr->Nth(count)->Type() == PrologString) || (expr->Nth(count)->Type() == PrologWord))) { 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))); } } else if (controlType == wxT("wxCheckBox")) { // Check for default value if (expr->Nth(count) && (expr->Nth(count)->Type() == PrologInteger)) { controlItem->SetValue1(expr->Nth(count)->IntegerValue()); count ++; if (expr->Nth(count) && expr->Nth(count)->Type() == PrologList) controlItem->SetFont(wxResourceInterpretFontSpec(expr->Nth(count))); } }#if wxUSE_RADIOBTN else if (controlType == wxT("wxRadioButton")) { // Check for default value if (expr->Nth(count) && (expr->Nth(count)->Type() == PrologInteger)) { controlItem->SetValue1(expr->Nth(count)->IntegerValue()); count ++; if (expr->Nth(count) && expr->Nth(count)->Type() == PrologList) controlItem->SetFont(wxResourceInterpretFontSpec(expr->Nth(count))); } }#endif else if (controlType == wxT("wxText") || controlType == wxT("wxTextCtrl") || controlType == wxT("wxMultiText")) { // Check for default value if (expr->Nth(count) && ((expr->Nth(count)->Type() == PrologString) || (expr->Nth(count)->Type() == PrologWord))) { 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))); // Skip past the obsolete label font spec if there are two consecutive specs if (expr->Nth(count+1) && expr->Nth(count+1)->Type() == PrologList) count ++; controlItem->SetFont(wxResourceInterpretFontSpec(expr->Nth(count))); } } } else if (controlType == wxT("wxMessage") || controlType == wxT("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(wxT("wxStaticText")); } if (expr->Nth(count) && expr->Nth(count)->Type() == PrologList) controlItem->SetFont(wxResourceInterpretFontSpec(expr->Nth(count))); } else if (controlType == wxT("wxStaticBitmap")) { // Check for bitmap resource name if (expr->Nth(count) && ((expr->Nth(count)->Type() == PrologString) || (expr->Nth(count)->Type() == PrologWord))) { 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))); } else if (controlType == wxT("wxGroupBox") || controlType == wxT("wxStaticBox")) { if (expr->Nth(count) && expr->Nth(count)->Type() == PrologList) controlItem->SetFont(wxResourceInterpretFontSpec(expr->Nth(count))); } else if (controlType == wxT("wxGauge")) { // Check for default value if (expr->Nth(count) && (expr->Nth(count)->Type() == PrologInteger)) { 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 if (expr->Nth(count+1) && expr->Nth(count+1)->Type() == PrologList) count ++; controlItem->SetFont(wxResourceInterpretFontSpec(expr->Nth(count))); } } } } else if (controlType == wxT("wxSlider")) { // Check for default value if (expr->Nth(count) && (expr->Nth(count)->Type() == PrologInteger)) { 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))); } } } } } else if (controlType == wxT("wxScrollBar")) { // DEFAULT VALUE if (expr->Nth(count) && (expr->Nth(count)->Type() == PrologInteger)) { 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()); } } } } else if (controlType == wxT("wxListBox")) { wxExpr *valueList = (wxExpr *) NULL; if (((valueList = expr->Nth(count)) != 0) && (valueList->Type() == PrologList)) { wxStringList stringList; wxExpr *stringExpr = valueList->GetFirst(); while (stringExpr) { stringList.Add(stringExpr->StringValue()); stringExpr = stringExpr->GetNext(); } 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)) != 0) && ((mult->Type() == PrologString)||(mult->Type() == PrologWord))) { /* wxString m(mult->StringValue()); if (m == "wxLB_MULTIPLE") controlItem->SetValue1(wxLB_MULTIPLE); else if (m == "wxLB_EXTENDED") controlItem->SetValue1(wxLB_EXTENDED); */ // Ignore the value count ++; } if (expr->Nth(count) && expr->Nth(count)->Type() == PrologList) { // Skip past the obsolete label font spec if there are two consecutive specs if (expr->Nth(count+1) && expr->Nth(count+1)->Type() == PrologList) count ++; controlItem->SetFont(wxResourceInterpretFontSpec(expr->Nth(count))); } } } else if (controlType == wxT("wxChoice")) { wxExpr *valueList = (wxExpr *) NULL; // Check for default value list if (((valueList = expr->Nth(count)) != 0) && (valueList->Type() == PrologList)) { wxStringList stringList; wxExpr *stringExpr = valueList->GetFirst(); while (stringExpr) { stringList.Add(stringExpr->StringValue()); 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 if (expr->Nth(count+1) && expr->Nth(count+1)->Type() == PrologList) count ++; controlItem->SetFont(wxResourceInterpretFontSpec(expr->Nth(count))); } } }#if wxUSE_COMBOBOX else if (controlType == wxT("wxComboBox")) { wxExpr *textValue = expr->Nth(count); if (textValue && (textValue->Type() == PrologString || textValue->Type() == PrologWord)) { wxString str(textValue->StringValue()); controlItem->SetValue4(str); count ++; wxExpr *valueList = (wxExpr *) NULL; // Check for default value list if (((valueList = expr->Nth(count)) != 0) && (valueList->Type() == PrologList)) { wxStringList stringList; wxExpr *stringExpr = valueList->GetFirst(); while (stringExpr) { stringList.Add(stringExpr->StringValue()); 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 if (expr->Nth(count+1) && expr->Nth(count+1)->Type() == PrologList) count ++; controlItem->SetFont(wxResourceInterpretFontSpec(expr->Nth(count))); } } } }#endif#if 1 else if (controlType == wxT("wxRadioBox")) { wxExpr *valueList = (wxExpr *) NULL; // Check for default value list if (((valueList = expr->Nth(count)) != 0) && (valueList->Type() == PrologList)) { wxStringList stringList; wxExpr *stringExpr = valueList->GetFirst(); while (stringExpr) { stringList.Add(stringExpr->StringValue()); stringExpr = stringExpr->GetNext(); } controlItem->SetStringValues(stringList); count ++; // majorDim (number of rows or cols) if (expr->Nth(count) && (expr->Nth(count)->Type() == PrologInteger)) { controlItem->SetValue1(expr->Nth(count)->IntegerValue()); count ++; } 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 if (expr->Nth(count+1) && expr->Nth(count+1)->Type() == PrologList) count ++; controlItem->SetFont(wxResourceInterpretFontSpec(expr->Nth(count))); } } }#endif else { delete controlItem; return (wxItemResource *) NULL; } return controlItem;}// Forward declarationwxItemResource *wxResourceInterpretMenu1(wxResourceTable& table, wxExpr *expr);/** Interpet a menu item*/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);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -