/**
 * $Id$
 * $Revision$
 * $Author$
 * $Date$
 *
 * This file is part of The iWear Framework.
 * In particular this file is part of the Framework Griffin
 *
 * 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 __LAYOUTINFORMATION_H
#define __LAYOUTINFORMATION_H

// Standard includes
#include <stdlib.h>

// iWear includes
#include <iwear_output/imagedata.h>
#include <iwear_uiservices/menudata.h>
#include <iwear_output/textdata.h>
#include <iwear_output/widgetdata.h>
#include <iwear/configuration.h>

// Other includes
#include <SDL/SDL.h>

using namespace iwear::uiservices;

namespace iwear{
namespace output{

/**
 * @author Carsten Rachuy
 */
class LayoutInformation {

    enum DATA_CHANGE{
	DATA_ADDED,
	DATA_REMOVED
    };

 public:

    /**
     * Constructor
     */
    LayoutInformation(Configuration& configuration);

    /**
     * Destructor
     */
    virtual ~LayoutInformation(void);

    /**
     * Adds a certain type
     */
    void add_data(const string& type);

    /**
     * Removes a certain type
     */
    void remove_data(const string& type);

    /**
     * Get the render area for a certain type
     */
    SDL_Rect* get_render_area(const string& type);

    /**
     * Get the informatuion whether a certain render area changed
     */
    bool render_area_changed(const string& type);
    
    /**
     * Returns true if the application holds no data
     */
    inline bool is_empty(void){
	if (this->displayed_image_data  == 0 &&
	    this->displayed_menu_data   == 0 &&
	    this->displayed_text_data   == 0 &&
	    this->displayed_widget_data == 0     ){
	    return true;
	} else {
	    return false;
	}
    }


 private:

    /**
     * Method that does the recalculatio of an SDL_Rect after each
     * add / remove call and sets the appropriate changed-variable
     * to true (if needed).
     */
    void recalculate_display_area(const string& type, DATA_CHANGE change);

    /**
     * Switching screens from split-screen to normal and vice versa
     */
    void switch_screen(void);

    /**
     * Configuration
     */
    Configuration& configuration;

    /**
     * Are we in split-screen mode
     */
    bool split_screen;

    /**
     * Flags which are set to 'true' when the SDL_Rect for a certain
     * type has changed. These variables are eventually set to 'true'
     * when "add data" is called and are set to 'false' after
     * 'get_render_area' has been called for this certain type
     */

    /**
     * Flag for changes on image data display area
     */
    bool image_area_changed;

    /**
     * Flag for changes on menu data display area
     */
    bool menu_area_changed;

    /**
     * Flag for changes on text data display area
     */
    bool text_area_changed;

    /**
     * Flag for changes on widget data display area
     */
    bool widget_area_changed;
    	
    /**
     * Number of image datas
     */
    uint32_t displayed_image_data;

    /**
     * Number of menu datas
     */
    uint32_t displayed_menu_data;

    /**
     * Number of text datas
     */
    uint32_t displayed_text_data;

    /**
     * Number of widget datas
     */
    uint32_t displayed_widget_data;

    /**
     * Image render area
     */
    SDL_Rect* image_area;

    /**
     * Menu render area
     */
    SDL_Rect* menu_area;

    /**
     * Text render area
     */
    SDL_Rect* text_area;

    /**
     * Widget render area
     */
    SDL_Rect* widget_area;

};


} // namespace output
} // namespace iwear

#endif // __LAYOUTINFORMATION_H

