/* Network-Integrated Multimedia Middleware (NMM)
 * http://www.motama.com/nmm.html
 *
 * Copyright (C) 2006-2007
 * Motama GmbH, Saarbruecken, Germany
 * http://www.motama.com
 *
 * This file is part of NMM. 
 * 
 * NMM 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; only version 2 of the License.      
 * 
 * NMM 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 NMM; if not, write to the Free Software Foundation,    
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
 *
 */

#ifndef NMM_IOSDManager_HPP
#define NMM_IOSDManager_HPP

#include "nmm/nmm_prefix.hpp"

#include "nmm/comm/Interface.hpp"
#include "nmm/comm/messaging/Event.hpp"
#include "nmm/comm/messaging/IllegalStateException.hpp"
#include <memory>

#include "IWidget.hpp"
#include "IWindow.hpp"
#include "IBitmapReader.hpp"

#include "visibility.hpp"

namespace NMM
{
  /**
   * OSD Manager.
   * Interface for a OSD manager.
   */

  class DLLEXPORT IOSDManager : virtual public NMM::Interface { 
  public:
    IOSDManager() : NMM::Interface(IOSDManager::IOSDManager_type, "NMM") { };

    IOSDManager(NMM::NMMObject& parent) : NMM::Interface (parent, IOSDManager::IOSDManager_type, "NMM") { };

    virtual ~IOSDManager() {};

    static const char* IOSDManager_type;

    virtual  string getInterfaceType() const { return IOSDManager_type; }

    NMM::Interface* copy() const { return new IOSDManager(*this); }
    static void used(); 
    static const char* loadFont_event;
    static const char* getFontList_event;
    static const char* update_event;
    static const char* getWidget_event;
    static const char* getWindow_event;
    static const char* createWindow_event;
    static const char* deleteWindow_event;
    static const char* deleteWidget_event;
    static const char* displayMessage_event;
    static const char* deleteMessage_event;
    static const char* displayTime_event;
    static const char* createTime_event;
    static const char* resetTime_event;
    static const char* hideTime_event;
    static const char* setTime_event;
    static const char* getTime_event;
    static const char* displaySymbol_event;
    static const char* hideSymbol_event;
    static const char* displayProgressBar_event;
    static const char* hideProgressBar_event;
    static const char* setMaxProgress_event;
    static const char* setProgress_event;
    static const char* updateProgress_event;
    static const char* displayColorBar_event;
    static const char* hideColorBar_event;
    static const char* setColorBarText_event;
    static const char* setRedColorBarText_event;
    static const char* setGreenColorBarText_event;
    static const char* setYellowColorBarText_event;
    static const char* setBlueColorBarText_event;
    static const char* getRedColorBarText_event;
    static const char* getGreenColorBarText_event;
    static const char* getYellowColorBarText_event;
    static const char* getBlueColorBarText_event;
    static const char* messageLeft_event;
    static const char* messageRight_event;
    static const char* messageID_event;
    static const char* setPause_event;
    static const char* sendPauseEvent_event;
    static const char* getBitmapReader_event;
    static const char* checkCharDimension_event;
    static const char* getMaxWidth_event;
    static const char* getMaxHeight_event;
    static const char* setLineSpace_event;
    static const char* getLineSpace_event;
    /**
     * add font to list
     * @param id font identifier
     * @param xmfilename filename of the XML file where the font is described
     * @param fontname as a XML font file can describe several fonts, this parameter describes
     *        the desired fontname, if this name is empty, the first font is loaded
     */

    virtual Result loadFont(const string& id, const string& xmlfilename, const string& fontname)
      throw(const NMM::SerializedException&);
    /**
     * Get list of all fonts.
     */

    virtual list<string >  getFontList() const
      throw(const NMM::SerializedException&);
    /**
     * Update the OSD.
     * This will update all widgets.
     */

    virtual Result update()
      throw(const NMM::SerializedException&);
    /**
     * Get widget.
     * Returns an interface to access a widget.
     * @param id widget id
     * @return an interface to access the widget
     */

    virtual IWidget* getWidget(const nmm_int32& id)
      throw(const NMM::SerializedException&);
    /**
     * Get window.
     * Returns an interface to access the window of a widget.
     * @param id window id
     * @return an interface to access the window
     */

    virtual IWindow* getWindow(const nmm_int32& id)
      throw(const NMM::SerializedException&);
    /**
     * Create a window.
     * Creates a new window and returns an interface for it.
     * @return interface for window
     */

    virtual IWindow* createWindow()
      throw(const NMM::SerializedException&);
    /**
     * Deletes a window.
     * Removes the window from the manager's window list and destroys it.
     */

    virtual void deleteWindow(const IWindow& window)
      throw(const NMM::SerializedException&);
    /** Delete a widget. */

    virtual void deleteWidget(const IWidget& widget)
      throw(const NMM::SerializedException&);
    /**
     * Display a message.
     * @param header message header
     * @param text message text
     * @param label1 button label 1 text
     * @param label2 button label 2 text
     * @param label3 button label 3 text
     * @param sel initial selection
     */

    virtual Result displayMessage(const string& header, const string& text, const string& label1, const string& label2 = "", const string& label3 = "", const nmm_uint32& sel = 0)
      throw(const NMM::SerializedException&);
    /** Delete current message. */

    virtual Result deleteMessage()
      throw(const NMM::SerializedException&);
    /**
     * Display time.
     * @param header header text
     * @param x x position
     * @param y y position
     */

    virtual Result displayTime(const string& header = "", const nmm_uint32& x = 500, const nmm_uint32& y = 410)
      throw(const NMM::SerializedException&);

    virtual Result createTime(const nmm_bool& ct)
      throw(const NMM::SerializedException&);

    virtual Result resetTime()
      throw(const NMM::SerializedException&);

    virtual Result hideTime()
      throw(const NMM::SerializedException&);

    virtual Result setTime(const nmm_uint64& time)
      throw(const NMM::SerializedException&);

    virtual nmm_uint64 getTime()
      throw(const NMM::SerializedException&);
    /**
     * Display symbol.
     * @param symbol symbol id
     * @param x x position
     * @param y y position
     */

    virtual Result displaySymbol(const string& symbol, const nmm_uint32& x = 600, const nmm_uint32& y = 50)
      throw(const NMM::SerializedException&);

    virtual Result hideSymbol()
      throw(const NMM::SerializedException&);

    virtual Result displayProgressBar(const string& header = "", const nmm_uint32& x = 50, const nmm_uint32& y = 470, const nmm_uint32& width = 620)
      throw(const NMM::SerializedException&);

    virtual Result hideProgressBar()
      throw(const NMM::SerializedException&);

    virtual void setMaxProgress(const nmm_uint64& max)
      throw(const NMM::SerializedException&);

    virtual void setProgress(const nmm_uint64& progress)
      throw(const NMM::SerializedException&);

    virtual void updateProgress()
      throw(const NMM::SerializedException&);
    /**
     * Displays the color bar which can be used to show the functionality of the four color buttons of a remote control.
     * @param x x position
     * @param y y position
     */

    virtual Result displayColorBar(const nmm_uint32& x = 80, const nmm_uint32& y = 480)
      throw(const NMM::SerializedException&);
    /**
     * Hides the color bar. 
     */

    virtual Result hideColorBar()
      throw(const NMM::SerializedException&);
    /**
     * Sets the text of all four color fields in the color bar.
     */

    virtual void setColorBarText(const string& red, const string& green, const string& yellow, const string& blue)
      throw(const NMM::SerializedException&);
    /**
     * Sets the text of the red color field in the color bar.
     */

    virtual void setRedColorBarText(const string& text)
      throw(const NMM::SerializedException&);
    /**
     * Sets the text of the green color field in the color bar.
     */

    virtual void setGreenColorBarText(const string& text)
      throw(const NMM::SerializedException&);
    /**
     * Sets the text of the yellow color field in the color bar.
     */

    virtual void setYellowColorBarText(const string& text)
      throw(const NMM::SerializedException&);
    /**
     * Sets the text of the blue color field in the color bar.
     */

    virtual void setBlueColorBarText(const string& text)
      throw(const NMM::SerializedException&);
    /**
     * Returns the text of the red color field in the color bar.
     */

    virtual string getRedColorBarText()
      throw(const NMM::SerializedException&);
    /**
     * Returns the text of the green color field in the color bar.
     */

    virtual string getGreenColorBarText()
      throw(const NMM::SerializedException&);
    /**
     * Returns the text of the yellow color field in the color bar.
     */

    virtual string getYellowColorBarText()
      throw(const NMM::SerializedException&);
    /**
     * Returns the text of the blue color field in the color bar.
     */

    virtual string getBlueColorBarText()
      throw(const NMM::SerializedException&);

    virtual Result messageLeft()
      throw(const NMM::SerializedException&);

    virtual Result messageRight()
      throw(const NMM::SerializedException&);

    virtual string messageID()
      throw(const NMM::SerializedException&);
    /**
     * Set pause mode.
     * the pause flag is a hint to the OSD manager that it receives no buffers and must set its
     * working flag explicitely to redraw the OSD whenever it has been updated.
     */

    virtual void setPause(const nmm_bool& value)
      throw(const NMM::SerializedException&);
    /**
     * Send pause event.
     * Make the OSD manager send a pause event.
     */

    virtual void sendPauseEvent()
      throw(const NMM::SerializedException&);

    virtual IBitmapReader* getBitmapReader()
      throw(const NMM::SerializedException&);
    /**
     * Gets width and height of a character.
     * @param id font id
     * @param c character that dimension is desired
     * @param x here the width is saved
     * @param y here the height is saved
     */

    virtual void checkCharDimension(const string& id, const nmm_uchar& c, nmm_uint32& x, nmm_uint32& y) const
      throw(const NMM::SerializedException&);
    /**
     * Get maximum width of font.
     * @param id font id
     * @return the maximum width of a character
     */

    virtual nmm_uint32 getMaxWidth(const string& id) const
      throw(const NMM::SerializedException&);
    /**
     * Get maximum height of font.
     * @param id font id
     * @return the maximum height of a character
     */

    virtual nmm_uint32 getMaxHeight(const string& id) const
      throw(const NMM::SerializedException&);
    /**
     * Set space (pixels) between 2 lines.
     * @param id font id
     */

    virtual void setLineSpace(const string& id, const nmm_uint32& space)
      throw(const NMM::SerializedException&);
    /**
     * Get line space.
     * @param id font id
     */

    virtual nmm_uint32 getLineSpace(const string& id) const
      throw(const NMM::SerializedException&);


  };

  typedef auto_ptr<IOSDManager> IOSDManager_var;




}

#include "nmm/nmm_suffix.hpp"

#endif
