示例#1
0
void XmlStackWalker::OnStackFrame(const wxStackFrame& frame)
{
    m_isOk = true;

    wxXmlNode *nodeFrame = new wxXmlNode(wxXML_ELEMENT_NODE, wxT("frame"));
    m_nodeStack->AddChild(nodeFrame);

    NumProperty(nodeFrame, wxT("level"), frame.GetLevel());
    wxString func = frame.GetName();
    if ( !func.empty() )
    {
        nodeFrame->AddAttribute(wxT("function"), func);
        HexProperty(nodeFrame, wxT("offset"), frame.GetOffset());
    }

    if ( frame.HasSourceLocation() )
    {
        nodeFrame->AddAttribute(wxT("file"), frame.GetFileName());
        NumProperty(nodeFrame, wxT("line"), frame.GetLine());
    }

    const size_t nParams = frame.GetParamCount();
    if ( nParams )
    {
        wxXmlNode *nodeParams = new wxXmlNode(wxXML_ELEMENT_NODE, wxT("parameters"));
        nodeFrame->AddChild(nodeParams);

        for ( size_t n = 0; n < nParams; n++ )
        {
            wxXmlNode *
                nodeParam = new wxXmlNode(wxXML_ELEMENT_NODE, wxT("parameter"));
            nodeParams->AddChild(nodeParam);

            NumProperty(nodeParam, wxT("number"), n);

            wxString type, name, value;
            if ( !frame.GetParam(n, &type, &name, &value) )
                continue;

            if ( !type.empty() )
                TextElement(nodeParam, wxT("type"), type);

            if ( !name.empty() )
                TextElement(nodeParam, wxT("name"), name);

            if ( !value.empty() )
                TextElement(nodeParam, wxT("value"), value);
        }
    }
}
示例#2
0
static inline void
HexElement(wxXmlNode *node, const wxChar *name, unsigned long value)
{
    TextElement(node, name, wxString::Format(wxT("%08lx"), value));
}
示例#3
0
void PediaMainForm::prepareAbout()
{
    PediaPreferences& prefs = application().preferences().pediaPrefs;

    infoRenderer_.clear();

    DefinitionModel* model = new_nt DefinitionModel();
    if (NULL == model)
    {
        application().alert(notEnoughMemoryAlert);
        return;
    }

    DefinitionModel::Elements_t& elems = model->elements;
    TextElement*  text;

    elems.push_back(text=new TextElement("Welcome to Encyclopedia."));
    text->setJustification(DefinitionElement::justifyCenter);
    text->setStyle(StyleGetStaticStyle(styleNameHeader));

    elems.push_back(new LineBreakElement(1, 2));
    elems.push_back(new LineBreakElement(1, 2));

    CDynStr str;
    const char_t* lang = GetLangNameByLangCode(prefs.languageCode, tstrlen(prefs.languageCode));
    if (NULL == str.AppendCharP3("You're using ", lang, " encyclopedia"))
        goto NoMemory;

    bool noStats = false;
    if (8 == tstrlen(prefs.dbDate))
    {
        if (NULL == str.AppendCharP(" last updated on "))
            goto NoMemory;
        if (NULL == str.AppendCharPBuf(prefs.dbDate, 4))
            goto NoMemory;
        if (NULL == str.AppendCharP("-"))
            goto NoMemory;
        if (NULL == str.AppendCharPBuf(&prefs.dbDate[4], 2))
            goto NoMemory;
        if (NULL == str.AppendCharP("-"))
            goto NoMemory;
        if (NULL == str.AppendCharPBuf(&prefs.dbDate[6], 2))
            goto NoMemory;
    }
    else
        noStats = true;

    if (prefs.articleCountNotChecked != prefs.articleCount)
    {
        char_t buffer[24];
        int len = formatNumber(prefs.articleCount, buffer, sizeof(buffer));
        if (NULL == str.AppendCharP(" with "))
            goto NoMemory;
        if (NULL == str.AppendCharPBuf(buffer, len))
            goto NoMemory;
        if (NULL == str.AppendCharP(" articles"))
            goto NoMemory;
    }
    else
        noStats = true;

//    if (noStats)
//        fetchStats();

    if (NULL == str.AppendCharP("."))
        goto NoMemory;

    elems.push_back(text = new TextElement(str.GetCStr()));
    text->setJustification(DefinitionElement::justifyLeft);

    uint_t l = 0;
    elems.push_back(text = new TextElement(" You can change encyclopedia to "));
    elems.back()->setJustification(DefinitionElement::justifyLeft);
    for (ulong_t i = 0; i < availLangCodesCount_; ++i)
    {
        const char_t* code = availLangCodes_[i];
        if (0 == tstrcmp(code, prefs.languageCode))
            continue;

        const char_t* name = GetLangNameByLangCode(code, tstrlen(code));
        assert(NULL != name);
        if (NULL == name)
            continue;

        text = new_nt TextElement(name);
        if (NULL == text)
            goto NoMemory;
        elems.push_back(text);
        elems.back()->setJustification(DefinitionElement::justifyLeft);

        if (NULL == str.AssignCharP(urlSchemaEncyclopedia urlSeparatorSchemaStr pediaUrlPartSetLang urlSeparatorSchemaStr))
            goto NoMemory;

        if (NULL == str.AppendCharP(code))
            goto NoMemory;

        text->setHyperlink(str.GetCStr(), hyperlinkUrl);

        const char_t* delim = _T(", ");
        ++l;
        if (availLangCodesCount_ - 2 == l)
            delim = _T(" or ");                        
        else if (availLangCodesCount_ - 1 == l)
            delim = NULL;

        if (NULL != delim)
        {
            text = new_nt TextElement(delim);
            if (NULL == text)
                goto NoMemory;
            elems.push_back(text);
            elems.back()->setJustification(DefinitionElement::justifyLeft);
        }    
    }

    elems.push_back(new LineBreakElement(1, 2));
    elems.push_back(new LineBreakElement(1, 2));
    //elems.back()->setJustification(DefinitionElement::justifyLeft);

    elems.push_back(new TextElement("You can "));
    elems.back()->setJustification(DefinitionElement::justifyLeft);

    elems.push_back(text = new TextElement("search"));
    elems.back()->setJustification(DefinitionElement::justifyLeft);

    text->setHyperlink(urlSchemaEncyclopedia urlSeparatorSchemaStr pediaUrlPartSearchDialog, hyperlinkUrl);
    elems.push_back(new TextElement(" for articles or get a "));
    elems.back()->setJustification(DefinitionElement::justifyLeft);

    elems.push_back(text = new TextElement("random"));
    if (NULL == str.AssignCharP(urlSchemaEncyclopediaRandom urlSeparatorSchemaStr))
        goto NoMemory;
    if (NULL == str.AppendCharP(prefs.languageCode))
        goto NoMemory;
    text->setHyperlink(str.GetCStr(), hyperlinkUrl);
    elems.back()->setJustification(DefinitionElement::justifyLeft);
    elems.push_back(new TextElement(" article."));
    elems.back()->setJustification(DefinitionElement::justifyLeft);
    infoRenderer_.setModel(model, Definition::ownModel);
    return;
NoMemory:
    delete model;
    application().alert(notEnoughMemoryAlert);   
}