5.2.4. Initializing the applets

The applets and context are initialized:

  1. Create the theme and set the resolution. See Example 5.9:

    Example 5.9. Initializing the applets

    ...
            if (!configAppletsAdded) {
                configApplets = APPLETS_DEFAULT;
            }
    
            Lotion::Application* app = new Lotion::Application();
            Lotion::Theme* theme = 0;
    
            if (configTheme == THEME_BLUE)
                theme = new Lotion::Themes::Blue();
            else if (configTheme == THEME_ROBOT)
                theme = new Lotion::Themes::Robot();
            else if (configTheme == THEME_MINIMAL)
                theme = new Lotion::Themes::Minimal();
    
            if (theme == 0) {
                argErrorExit("Error: No theme specified!\n", NULL);
            }
            app->setResolution(configResolution);
            app->setup(theme);
    ...
    

  2. Configure the input device handler. See Example 5.10:

    Example 5.10. Initializing the applets

    
    ...
            if (configInputs.getSize() == 0) {
                // We need an input device, assume a mouse on the default device.
                printf("No input device specified, using default mouse device\n");
                input_descriptor d = { INPUT_MODE_MOUSE, "" };
                configInputs.add(d);
            }
    
            for (int i = 0; i < configInputs.getSize(); i++) {
                if (configInputs[i].mode == INPUT_MODE_MOUSE) {
                    app->addMultiTouchDevice(Lotion::MultiTouch::createMouseDevice(
                            app->getSystem(), app->getContext()));
                } else if (configInputs[i].mode == INPUT_MODE_TOUCH) {
    #ifdef MDE_OS_WIN32
                    // ...
    #else
                    app->addMultiTouchDevice(
                            Lotion::MultiTouch::createLinuxInputDevice(
                                    app->getContext(), configInputs[i].arg));
    #endif
                }
            }
    ...
    

    Note

    Touch screens are not supported on Windows.

  3. Instantiate the applets and add the associated icons to the theme. See Example 5.11:

    Example 5.11. Instantiate the applets

    ...
            // create instances of the individual applets
            Lotion::Applet* photo = new Lotion::Applets::Photo();
            Lotion::Applet* presentation = new Lotion::Applets::Presentation();
            Lotion::Applet* slideshow_presentation =
                    new Lotion::Applets::SlideshowPresentation();
            Lotion::Applet* buzzword = new Lotion::Applets::Buzzword();
            Lotion::Applet* planet = new Lotion::Applets::Planet();
            Lotion::Applet* lightshow = new Lotion::Applets::LightShow();
            Lotion::Applet* browser = new Lotion::Applets::Browser();
    
            // add icons for the applets
            theme->addAppletIcon(photo->getIconThumbDesc(),
                    Lotion::AppletCategoryPhotos);
            theme->addAppletIcon(presentation->getIconThumbDesc(),
                    Lotion::AppletCategoryPresentations);
            theme->addAppletIcon(slideshow_presentation->getIconThumbDesc(),
                    Lotion::AppletCategoryPresentations);
            theme->addAppletIcon(buzzword->getIconThumbDesc(),
                    Lotion::AppletCategoryTechdemos);
            theme->addAppletIcon(planet->getIconThumbDesc(),
                    Lotion::AppletCategoryTechdemos);
            theme->addAppletIcon(lightshow->getIconThumbDesc(),
                    Lotion::AppletCategoryTechdemos);
            theme->addAppletIcon(browser->getIconThumbDesc(),
                    Lotion::AppletCategoryTechdemos);
    ...
    

  4. Create the applet and add it to the theme. See Example 5.12:

    Example 5.12. Creating the applets

    ...
            // create the applet and add it to the theme
            if (configApplets & APPLET_PHOTO_BROWSER) {
                photo->create(app, photo, theme);
                theme->addApplet(photo, Lotion::AppletCategoryPhotos);
            }
            if (configApplets & APPLET_PRESENTATION) {
                presentation->create(app, presentation, theme);
                theme->addApplet(presentation, Lotion::AppletCategoryPresentations);
            }
            if (configApplets & APPLET_SLIDESHOW_PRESENTATION) {
                slideshow_presentation->create(app, slideshow_presentation, theme);
                theme->addApplet(slideshow_presentation,
                                 Lotion::AppletCategoryPresentations);
            }
            if (configApplets & APPLET_BUZZWORD) {
                buzzword->create(app, buzzword, theme);
                theme->addApplet(buzzword, Lotion::AppletCategoryTechdemos);
            }
            if (configApplets & APPLET_PLANET) {
                planet->create(app, planet, theme);
                theme->addApplet(planet, Lotion::AppletCategoryTechdemos);
            }
            if (configApplets & APPLET_LIGHTSHOW) {
                lightshow->create(app, lightshow, theme);
                theme->addApplet(lightshow, Lotion::AppletCategoryTechdemos);
            }
            if (configApplets & APPLET_BROWSER) {
                browser->create(app, browser, theme);
                theme->addApplet(browser, Lotion::AppletCategoryBrowser);
            }
    
            // Calibration - MUST BE THE LAST APPLET ADDED
            Lotion::CalibrationApplet* calibration =
                    new Lotion::CalibrationApplet();
            calibration->create(app, calibration, theme);
            theme->addApplet(calibration, Lotion::AppletCategoryTechdemos);
    
            theme->prepare();
    ...
    

Copyright © 2010 ARM. All rights reserved.ARM DUI 0527A‑02a
Non-Confidential - Draft - BetaID070710