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

#include <iwear_output/outputdata.h>
#include <iwear/debugstream.h>

#include <string>


namespace iwear {
namespace output {

/**
 * What can happen on an image?
 */
enum WIDGET_EVENT
{
    WIDGET_CHANGED_CONTENT,
    WIDGET_ALERT,
    num_WIDGET_EVENT
};


/**
 * to_string() method for ImageData changes 
 */
inline const char* to_string(WIDGET_EVENT widget_event)
{
    switch(widget_event)
	{
	case WIDGET_CHANGED_CONTENT : 
	    return "WIDGET_EVENT::WIDGET_CHANGED_CONTENT";
	case WIDGET_ALERT : 
	    return "WIDGET_EVENT::WIDGET_ALERT";
	default :
	    return "IMAGE_EVENT::<invalid_value>";
	}
}


/**
 * This class represents a widget
 * @author Carsten Rachuy
 */
class WidgetData : public OutputData{
	
public:

    /**
     * Contains the OutputData type of this object.
     */
    static const string TYPE;

    /**
     * Constructor
     * @param name The name of the output data
     * @param description A description of the output data
     * @param content The content, the path of the 
     */	
    WidgetData(const uid& application_id,
	       const string& name, 
	       const string& description, 
	       const string& content,
	       bool  global = false);
	    
    /**
     * Destructor
     */
    virtual ~WidgetData(void);
    
	
    /**
     * @return The content of the text.
     */
    inline string get_content(void) {
	ThreadLocker tl(Mutex);
	return content;
    }

    /**
     * @return The content of the text.
     */
    inline const bool is_global(void) {
	return global;
    }

    /**
     * Set the content      
     * @param content The new content to be set.
     */
    void set_content(const string& content);

    /**
     * Send an alert
     */
    void send_alert(const string& alert_message);

	
private:    

    /** 
     * The actual content of this widget
     */
    string content;

    /** 
     * The alert message
     */
    string alert_message;

    /**
     * Global or local widget
     */
    bool global;

};

} // namespace output
} // namespace iwear


#endif // __WIDGETDATA_H

