Example #1
0
void MoviesMainForm::prepareTheatreInfo(uint_t theatreRow)
{
    assert(NULL != theatres);
    theatreRow *= 2;
    assert(theatreRow < theatres->getItemsCount());
    
    const char_t* theatreName = theatres->getItemText(theatreRow, theatreNameIndex);
    const char_t* theatreAddress = theatres->getItemText(theatreRow, theatreAddressIndex);

    DefinitionModel* model = new_nt DefinitionModel();
    if (NULL == model)
    {
        application().alert(notEnoughMemoryAlert);
        return;
    }
    Definition::Elements_t& elems = model->elements;
    TextElement* text;
    elems.push_back(text=new TextElement(theatreName));
    text->setStyle(StyleGetStaticStyle(styleNamePageTitle));
    if (0 != tstrlen(theatreAddress))
    {
        elems.push_back(new LineBreakElement());
        elems.push_back(text=new TextElement(theatreAddress));
    }
    elems.push_back(new LineBreakElement());
    const uint_t moviesRow = theatreRow + 1;
    const uint_t moviesCount = theatres->getItemElementsCount(moviesRow)/2;
    for (uint_t i = 0; i<moviesCount; ++i)
    {   
        const char_t* movieTitle = theatres->getItemText(moviesRow, i*2);
        const char_t* movieHours = theatres->getItemText(moviesRow, i*2+1);
        BulletElement* bull;
        elems.push_back(bull = new BulletElement());
        bull->setStyle(StyleGetStaticStyle(styleNameHeader));
        elems.push_back(text=new TextElement(movieTitle));
        text->setParent(bull);
        text->setStyle(StyleGetStaticStyle(styleNameHeader));
        text->setHyperlink(buildUrl(urlSchemaMovie, movieTitle), hyperlinkUrl);
        elems.push_back(new LineBreakElement());
        elems.push_back(text=new TextElement(movieHours));
        text->setParent(bull);
    }
    infoRenderer_.setModel(model, Definition::ownModel);
}
Example #2
0
void MoviesMainForm::prepareMovieInfo(uint_t movie)
{
    assert(movie < movies.size());
    const Movie& mv=*(movies[movie]);
    
    DefinitionModel* model = new_nt DefinitionModel();
    if (NULL == model)
    {
        application().alert(notEnoughMemoryAlert);
        return;
    }
    Definition::Elements_t& elems = model->elements;

    TextElement* text;
    elems.push_back(text=new TextElement(mv.title));
    text->setStyle(StyleGetStaticStyle(styleNamePageTitle));

    elems.push_back(new LineBreakElement());

    Movie::TheatresByMovie_t::const_iterator end=mv.theatres.end();
    for (Movie::TheatresByMovie_t::const_iterator it=mv.theatres.begin(); it!=end; ++it)
    {   
        const TheatreByMovie& th=*(*it);
        BulletElement* bull;
        elems.push_back(bull=new BulletElement());
        bull->setStyle(StyleGetStaticStyle(styleNameHeader));
        elems.push_back(text=new TextElement(th.name));
        text->setParent(bull);
        text->setStyle(StyleGetStaticStyle(styleNameHeader));
        text->setHyperlink(buildUrl(urlSchemaTheatre, th.name.c_str()), hyperlinkUrl);
        elems.push_back(new LineBreakElement());
        elems.push_back(text=new TextElement(th.hours));
        text->setParent(bull);
    }
    infoRenderer_.setModel(model, Definition::ownModel);
}
Example #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);   
}
Example #4
0
void PediaMainForm::prepareAbout()
{
    DefinitionModel* model = new_nt DefinitionModel();   
    if (NULL == model)   
    {   
       //application().alert(notEnoughMemoryAlert);   
       return;   
    }   
     
    Definition::Elements_t& elems = model->elements; 

    TextElement *  text;
    TextElement *  articleCountElement;
    setTitle("iPedia");

    FontEffects fxBold;
    fxBold.setWeight(FontEffects::weightBold);

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

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

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

    const char* version="Ver " appVersion
#ifdef INTERNAL_BUILD
    " (internal)"
#endif
/*
#ifdef DEBUG
        " (debug)"
#endif*/
    ;
    elems.push_back(text=new TextElement(version));
    text->setJustification(DefinitionElement::justifyCenter);
    elems.push_back(new LineBreakElement(1,4));

#ifdef UNLOCKED
    elems.push_back(text=new TextElement("Registered PalmSource version"));
    text->setJustification(DefinitionElement::justifyCenter);
    elems.push_back(new LineBreakElement(1,2));
#else
    if (app().preferences().regCode.empty())
    {
        elems.push_back(text=new TextElement("Unregistered ("));
        text->setJustification(DefinitionElement::justifyCenter);
        elems.push_back(text=new TextElement("how to register"));
        text->setJustification(DefinitionElement::justifyCenter);
        // url doesn't really matter, it's only to establish a hotspot
        text->setHyperlink("", hyperlinkTerm);
        text->setActionCallback( unregisteredActionCallback, static_cast<void*>(this) );
        elems.push_back(text=new TextElement(")"));
        text->setJustification(DefinitionElement::justifyCenter);
        elems.push_back(new LineBreakElement(1,2));
    }
    else
    {
        elems.push_back(text=new TextElement("Registered"));
        text->setJustification(DefinitionElement::justifyCenter);
        elems.push_back(new LineBreakElement(1,2));
    }
#endif

    elems.push_back(text=new TextElement("Software \251 "));
    text->setJustification(DefinitionElement::justifyCenter);

    elems.push_back(text=new TextElement("ArsLexis"));
    text->setJustification(DefinitionElement::justifyCenter);
    text->setHyperlink("http://www.arslexis.com/pda/palm.html", hyperlinkExternal);

    elems.push_back(new LineBreakElement(1,4));
    elems.push_back(text=new TextElement("Data \251 "));
    text->setJustification(DefinitionElement::justifyCenter);

    elems.push_back(text=new TextElement("WikiPedia"));
    text->setJustification(DefinitionElement::justifyCenter);
    // url doesn't really matter, it's only to establish a hotspot
    text->setHyperlink("", hyperlinkTerm);
    text->setActionCallback(wikipediaActionCallback, static_cast<void*>(this) );

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

    articleCountElement = new TextElement(" ");

    if (-1 != app().preferences().articleCount)    
    {
        prepareArticleCountEl(articleCountElement, app().preferences().articleCount, app().preferences().databaseTime);
    }

    elems.push_back(articleCountElement);
    articleCountElement->setJustification(DefinitionElement::justifyCenter);

    elems.push_back(new LineBreakElement(1, 2));
    elems.push_back(text=new TextElement("Using iPedia: "));
    text->setJustification(DefinitionElement::justifyLeft);

    elems.push_back(text=new TextElement("tutorial"));
    text->setJustification(DefinitionElement::justifyLeft);
    // url doesn't really matter, it's only to establish a hotspot
    text->setHyperlink("", hyperlinkTerm);
    text->setActionCallback(tutorialActionCallback, this);

    //infoRenderer_.replaceElements(elems);
    infoRenderer_.setModel(model, Definition::ownModel);
}