// {{{ the iWear header
/**
 * $Id$
 * $Revision$
 * $Author$
 * $Date$
 *
 * This file is part of The iWear Framework.
 * In particular this file is part of the Framework Test Library
 *
 * The iWear Framework is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by the
 * Free Software Foundation as in version 2 of the License.

 * 
 * The iWear Framework is distributed in the hope that it will be useful, but
 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
 * or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
 * more details.
 * 
 * You should have received a copy of the GNU General Public License along with
 * The iWear Framework; if not, write to the Free Software Foundation, Inc., 59
 * Temple Place, Suite 330, Boston, MA  02111-1307  USA
 */
// }}}

#ifndef __LANGUAGESELECTOR_H
#define __LANGUAGESELECTOR_H

#ifndef __WIDGETDATA_H
#include <iwear_output/widgetdata.h>
#endif

#ifndef __MENUDATA_H
#include <iwear_uiservices/menudata.h>
#endif

#ifndef __IMAGEDATA_H
#include <iwear_output/imagedata.h>
#endif

#ifndef __APPLICATION_H
#include <iwear_uiservices/application.h>
#endif

#ifndef __LANGUAGESELECTORMENUFUNCTOR_H
#include <iwear_languageselector/languageselectormenufunctor.h>
#endif

#ifndef __INISAVER_H
#include <iwear/inisaver.h>
#endif

#ifndef __INILOADER_H
#include <iwear/iniloader.h>
#endif

#include <dirent.h>
#include <sys/types.h>
#include <fstream>
#include <stdio.h>

using namespace iwear::output;
using namespace iwear::uiservices;

namespace iwear {
    namespace languageselector {

// forward declaration
class LanguageSelectorMenuFunctor;

class LanguageSelector : public Application
{
    friend class LanguageSelectorMenuFunctor;

public:
    
    /**
     * The constructor
     * @param as A pointer to the application service
     */
    LanguageSelector(ApplicationService* as,
	    const std::string& dn = "languageselector",
	    const std::string& dd = string(i18n::trans("Choose the language you like for your system.")));

    /**
     * A special constructor which is required to load the language
     * selector as a plugin (Development version)
     */
//    LanguageSelector( void );

    /**
     * The Destructor. 
     */
    virtual ~LanguageSelector(void);

    void Run(void);
    
    void set_active_language(uint32_t language_button_id);

    void set_active_language(string language);

    /**
     * Get all available languages from config.
     */
    void get_available_languages( void );


protected:

    /** 
     * To initial the widget_data and menu_data
     */
    void Init_Application(void);

    /**
     * This function create four buttons for the submenu of the
     * languageselector application. 
     * 
     */
    void build_menu(void);

    /**
     * This function displays the submenu of the languageselector
     * application.
     */
    void display_menu(void);

    /**
     * This function displays the submenu of the languageselector
     * application.
     */
    void display_widget(void);


    /**
     * Adds a language to the applications menu.
     * @param language The language which should be add to the menu.
     *  This might be i.e. C, en_US, de_DE or fr_FR
     */
    void add_language_to_menu(string& language);

    void Final_Application(void);

    virtual void set_default_configuration(void);

    LanguageSelectorMenuFunctor* language_selector_menu_functor;
    
    /**
     * A pointer to a menu data. It's used for Output Manager to
     * display the submenu of the languageselector.
     */
    MenuData* menu_data;
    
    /**
     * A pointer to the widget data 
     */
    WidgetData* widget_data;

    /** The about information image data. */
    ImageData* about_data;

    /** List of all available languages. */
    list<string> languages;

    map<const uint32_t, string> language_button_map;

    /** Displays the about information. */
    void display_about_info();

    /** Stops displaying the about information */
    void stop_about_info();

    /** Execute on menu element activation */
    void on_element_activated(const uint32_t button_id);

    /** Execute on menu element selection */
    void on_element_selected(const uint32_t button_id);

private:

    /** The id of the about button. */
    uint32_t about_button_id;
};

    } // namespace languageselector
} // namespace iwear

#endif //__LANGUAGESELECTOR_H

