Пример #1
0
void PediaMainForm::prepareWikipedia()
{
    DefinitionModel* model = new_nt DefinitionModel();   
    if (NULL == model)   
    {   
       //application().alert(notEnoughMemoryAlert);   
       return;   
    }
    Definition::Elements_t& elems = model->elements; 
    setTitle("iPedia - Wikipedia");
    TextElement* text;
    FontEffects fxBold;
    fxBold.setWeight(FontEffects::weightBold);

    elems.push_back(text=new TextElement("All the articles in iPedia come from WikiPedia project and are licensed under "));
    elems.push_back(text=new TextElement("GNU Free Documentation License"));
    text->setHyperlink("http://www.gnu.org/copyleft/fdl.html", hyperlinkExternal);
    elems.push_back(text=new TextElement("."));
    elems.push_back(new LineBreakElement());

    elems.push_back(text=new TextElement("To find out more about WikiPedia project, visit "));
    elems.push_back(text=new TextElement("wikipedia.org"));
    text->setHyperlink("http://www.wikipedia.org", hyperlinkExternal);
    elems.push_back(text=new TextElement(" website. "));
    elems.push_back(new LineBreakElement());

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

    //infoRenderer_.replaceElements(elems);
    infoRenderer_.setModel(model, Definition::ownModel);
}    
Пример #2
0
// TODO: make those on-demand only to save memory
void PediaMainForm::prepareHowToRegister()
{
    DefinitionModel* model = new_nt DefinitionModel();   
    if (NULL == model)   
    {   
       //application().alert(notEnoughMemoryAlert);   
       return;   
    }
    Definition::Elements_t& elems = model->elements; 
    setTitle("iPedia - How to register");
    TextElement* text;

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

    elems.push_back(text=new TextElement("Unregistered version of iPedia limits how many articles can be viewed in one day (there are no limits on random articles.)"));
    elems.push_back(new LineBreakElement());

    elems.push_back(text=new TextElement("In order to register iPedia you need to purchase registration code at "));

// those 3 #defines should be mutually exclusive
#ifdef PALMGEAR
    elems.push_back(text=new TextElement("palmgear.com?67708"));
#endif

#ifdef HANDANGO
    elems.push_back(text=new TextElement("handango.com/purchase, product id: 128991"));
#endif

#ifdef ARSLEXIS_VERSION
    elems.push_back(text=new TextElement("our website "));
    elems.push_back(text=new TextElement("http://www.arslexis.com"));
    text->setHyperlink("http://www.arslexis.com/pda/palm.html", hyperlinkExternal);
#endif
    elems.push_back(new LineBreakElement());

    elems.push_back(text=new TextElement("After obtaining registration code use menu item 'Options/Register' (or "));
    elems.push_back(text=new TextElement("click here"));
    // url doesn't really matter, it's only to establish a hotspot
    text->setHyperlink("", hyperlinkTerm);
    text->setActionCallback( registerActionCallback, static_cast<void*>(this) );
    elems.push_back(text=new TextElement(") to enter registration code. "));

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

    //infoRenderer_.replaceElements(elems);
    infoRenderer_.setModel(model, Definition::ownModel);
}
Пример #3
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);
}
Пример #4
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);
}
Пример #5
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);   
}
Пример #6
0
// TODO: make those on-demand only to save memory
void PediaMainForm::prepareTutorial()
{
    DefinitionModel* model = new_nt DefinitionModel();   
    if (NULL == model)   
    {   
       //application().alert(notEnoughMemoryAlert);   
       return;   
    }
    Definition::Elements_t& elems = model->elements; 
    setTitle("iPedia - Tutorial");
    TextElement* text;

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

    elems.push_back(text=new TextElement("Go back to main screen."));
    text->setJustification(DefinitionElement::justifyLeft);
    // url doesn't really matter, it's only to establish a hotspot
    text->setHyperlink("", hyperlinkTerm);
    text->setActionCallback( aboutActionCallback, static_cast<void*>(this) );
    elems.push_back(new LineBreakElement(4,3));

    elems.push_back(text=new TextElement("iPedia is a wireless encyclopedia. Use it to get information and facts on just about anything."));
    elems.push_back(new LineBreakElement(4,3));

    elems.push_back(text=new TextElement("Finding an encyclopedia article."));
//    text->setEffects(fxBold);
    elems.push_back(text=new TextElement(" Let's assume you want to read an encyclopedia article on Seattle. Enter 'Seattle' in the text field at the bottom of the screen and press 'Search' (or center button on Treo's 5-way navigator)."));
    text->setJustification(DefinitionElement::justifyLeft);
    elems.push_back(new LineBreakElement(4,3));

    elems.push_back(text=new TextElement("Finding all articles with a given word."));
//    text->setEffects(fxBold);
    elems.push_back(text=new TextElement(" Let's assume you want to find all articles that mention Seattle. Enter 'Seattle' in the text field and use 'Main/Extended search' menu item. In response you'll receive a list of articles that contain word 'Seattle'."));
    text->setJustification(DefinitionElement::justifyLeft);
    elems.push_back(new LineBreakElement(4,3));

    elems.push_back(text=new TextElement("Refining the search."));
//    text->setEffects(fxBold);
    elems.push_back(text=new TextElement(" If there are too many results, you can refine (narrow) the search results by adding additional terms e.g. type 'museum' and press 'Refine' button. You'll get a smaller list of articles that contain both 'Seattle' and 'museum'."));
    text->setJustification(DefinitionElement::justifyLeft);
    elems.push_back(new LineBreakElement(4,3));

    elems.push_back(text=new TextElement("Results of last extended search."));
//    text->setEffects(fxBold);
    elems.push_back(text=new TextElement(" At any time you can get a list of results from last extended search by using menu item 'Main/Extended search results'."));
    text->setJustification(DefinitionElement::justifyLeft);
    elems.push_back(new LineBreakElement(4,3));

    elems.push_back(text=new TextElement("Random article."));
//    text->setEffects(fxBold);
    elems.push_back(text=new TextElement(" You can use menu 'Main/Random article' (or "));
    text->setJustification(DefinitionElement::justifyLeft);
    elems.push_back(text=new TextElement("click here"));
    text->setJustification(DefinitionElement::justifyLeft);
    // url doesn't really matter, it's only to establish a hotspot
    text->setHyperlink("", hyperlinkTerm);
    text->setActionCallback( randomArticleActionCallback, static_cast<void*>(this) );
    elems.push_back(text=new TextElement(") to get a random article."));
    text->setJustification(DefinitionElement::justifyLeft);
    elems.push_back(new LineBreakElement(4,3));

    elems.push_back(text=new TextElement("More information."));
//    text->setEffects(fxBold);
    elems.push_back(text=new TextElement(" Please visit our website "));
    text->setJustification(DefinitionElement::justifyLeft);

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

    elems.push_back(text=new TextElement(" for more information about iPedia."));
    text->setJustification(DefinitionElement::justifyLeft);
    elems.push_back(new LineBreakElement(4,3));

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

    //infoRenderer_.replaceElements(elems);
    infoRenderer_.setModel(model, Definition::ownModel);
}
Пример #7
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);
}