/* 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_IOSDManagerImpl_HPP
#define NMM_IOSDManagerImpl_HPP

#include "nmm/nmm_prefix.hpp"

#include "nmm/comm/NMMObject.hpp"
#include "IOSDManager.hpp"

#include "IWidgetImpl.hpp"
#include "IWindowImpl.hpp"
#include "IBitmapReaderImpl.hpp"

#include "visibility.hpp"

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

  class DLLEXPORT IOSDManagerImpl  : public virtual NMM::NMMObject { 
  public:
    IOSDManagerImpl() { addInterface(new IOSDManager(*this)); registerEvents(); };

    virtual ~IOSDManagerImpl() {};

  protected:
    /**
     * 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) = 0;
    /**
     * Get list of all fonts.
     */

    virtual list<string >  getFontList() const = 0;
    /**
     * Update the OSD.
     * This will update all widgets.
     */

    virtual Result update() = 0;
    /**
     * 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) = 0;
    /**
     * 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) = 0;
    /**
     * Create a window.
     * Creates a new window and returns an interface for it.
     * @return interface for window
     */

    virtual IWindow* createWindow() = 0;
    /**
     * Deletes a window.
     * Removes the window from the manager's window list and destroys it.
     */

    virtual void deleteWindow(const IWindow& window) = 0;
    /** Delete a widget. */

    virtual void deleteWidget(const IWidget& widget) = 0;
    /**
     * 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) = 0;
    /** Delete current message. */

    virtual Result deleteMessage() = 0;
    /**
     * 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) = 0;

    virtual Result createTime(const nmm_bool& ct) = 0;

    virtual Result resetTime() = 0;

    virtual Result hideTime() = 0;

    virtual Result setTime(const nmm_uint64& time) = 0;

    virtual nmm_uint64 getTime() = 0;
    /**
     * 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) = 0;

    virtual Result hideSymbol() = 0;

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

    virtual Result hideProgressBar() = 0;

    virtual void setMaxProgress(const nmm_uint64& max) = 0;

    virtual void setProgress(const nmm_uint64& progress) = 0;

    virtual void updateProgress() = 0;
    /**
     * 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) = 0;
    /**
     * Hides the color bar. 
     */

    virtual Result hideColorBar() = 0;
    /**
     * 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) = 0;
    /**
     * Sets the text of the red color field in the color bar.
     */

    virtual void setRedColorBarText(const string& text) = 0;
    /**
     * Sets the text of the green color field in the color bar.
     */

    virtual void setGreenColorBarText(const string& text) = 0;
    /**
     * Sets the text of the yellow color field in the color bar.
     */

    virtual void setYellowColorBarText(const string& text) = 0;
    /**
     * Sets the text of the blue color field in the color bar.
     */

    virtual void setBlueColorBarText(const string& text) = 0;
    /**
     * Returns the text of the red color field in the color bar.
     */

    virtual string getRedColorBarText() = 0;
    /**
     * Returns the text of the green color field in the color bar.
     */

    virtual string getGreenColorBarText() = 0;
    /**
     * Returns the text of the yellow color field in the color bar.
     */

    virtual string getYellowColorBarText() = 0;
    /**
     * Returns the text of the blue color field in the color bar.
     */

    virtual string getBlueColorBarText() = 0;

    virtual Result messageLeft() = 0;

    virtual Result messageRight() = 0;

    virtual string messageID() = 0;
    /**
     * 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) = 0;
    /**
     * Send pause event.
     * Make the OSD manager send a pause event.
     */

    virtual void sendPauseEvent() = 0;

    virtual IBitmapReader* getBitmapReader() = 0;
    /**
     * 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 = 0;
    /**
     * Get maximum width of font.
     * @param id font id
     * @return the maximum width of a character
     */

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

    virtual nmm_uint32 getMaxHeight(const string& id) const = 0;
    /**
     * Set space (pixels) between 2 lines.
     * @param id font id
     */

    virtual void setLineSpace(const string& id, const nmm_uint32& space) = 0;
    /**
     * Get line space.
     * @param id font id
     */

    virtual nmm_uint32 getLineSpace(const string& id) const = 0;


  private:
    void registerEvents();
  };

}

#include "nmm/nmm_suffix.hpp"

#endif
