/* 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_ITextView_HPP
#define NMM_ITextView_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 "visibility.hpp"

namespace NMM
{
  /**
   * Text view widget.
   * Interface for a text view widget.
   */

  class DLLEXPORT ITextView : virtual public IWidget { 
  public:
    ITextView() : NMM::Interface(ITextView::ITextView_type, "NMM") { };

    ITextView(NMM::NMMObject& parent) : NMM::Interface (parent, ITextView::ITextView_type, "NMM") { };

    virtual ~ITextView() {};

    static const char* ITextView_type;

    virtual  string getInterfaceType() const { return ITextView_type; }

    NMM::Interface* copy() const { return new ITextView(*this); }
    static void used(); 
    static const char* setFont_event;
    static const char* selectLine_event;
    static const char* selectLine2_event;
    static const char* deSelectLine_event;
    static const char* deSelectLine2_event;
    static const char* getSelectedLine_event;
    static const char* getSelectedLine2_event;
    static const char* getLineContent_event;
    static const char* changeLineContent_event;
    static const char* getLineURL_event;
    static const char* getLineWidget_event;
    static const char* setAutoFocus_event;
    static const char* setSelectionColor_event;
    static const char* setSelectionColor2_event;
    static const char* reset_event;
    static const char* setMaxLines_event;
    static const char* getMaxLines_event;
    static const char* setStartLine_event;
    static const char* getStartLine_event;
    static const char* getNumLines_event;
    static const char* focusSelection_event;
    static const char* insertLine_event;
    static const char* addLine_event;
    static const char* addLineWidget_event;
    static const char* deleteLine_event;
    static const char* deleteAllLines_event;
    static const char* markLine_event;
    static const char* unmarkLine_event;
    static const char* getMarkedLines_event;
    /**
     * Set font.
     * Set the font all text on this widget is drawn in.
     * @param value font name
     */

    virtual void setFont(const string& value)
      throw(const NMM::SerializedException&);
    /**
     * Selects the given line.
     * @param line line that should be selected (0 if no line should be selected)
     * @return linenumber that was selected
     */

    virtual nmm_uint32 selectLine(const nmm_uint32& line)
      throw(const NMM::SerializedException&);
    /**
     * Selects the given line (second selection).
     * @param line line that should be selected (0 if no line should be selected)
     * @return linenumber that was selected
     */

    virtual nmm_uint32 selectLine2(const nmm_uint32& line)
      throw(const NMM::SerializedException&);
    /**
     * Deselect line ( set selected_line = 0).
     */

    virtual void deSelectLine()
      throw(const NMM::SerializedException&);
    /**
     * Deselect second line ( set selected_line2 = 0).
     */

    virtual void deSelectLine2()
      throw(const NMM::SerializedException&);
    /**
     * Get selected line.
     * @return selected line (0, if no line is selected)
     */

    virtual nmm_uint32 getSelectedLine() const
      throw(const NMM::SerializedException&);
    /**
     * Get selected line (second selection).
     * @return second selected line (0, if no line is selected)
     */

    virtual nmm_uint32 getSelectedLine2() const
      throw(const NMM::SerializedException&);
    /**
     * Get line content.
     * @param line line number
     * @returns the text displayed in that line
     */

    virtual string getLineContent(const nmm_uint32& line) const
      throw(const NMM::SerializedException&);
    /**
     * changes the content of a line
     * @param text new content of the line
     * @param line to be changed
     */

    virtual void changeLineContent(const nmm_uint32& line, const string& text)
      throw(const NMM::SerializedException&);
    /**
     * Get line url.
     * @param line line number
     * @returns the url in that line, if it contains one.
     */

    virtual string getLineURL(const nmm_uint32& line) const
      throw(const NMM::SerializedException&);
    /**
     * Get line widget.
     * @param line line number
     * @returns the widget in that line, if it contains one.
     */

    virtual IWidget* getLineWidget(const nmm_uint32& line) const
      throw(const NMM::SerializedException&);
    /**
     * Set autofocus for selectLine.
     * @param value autofocus mode. on=true or off=false.
     */

    virtual void setAutoFocus(const nmm_bool& value)
      throw(const NMM::SerializedException&);
    /**
     * Sets selection color.
     * @param color rgba color
     */

    virtual void setSelectionColor(const nmm_uint32& color)
      throw(const NMM::SerializedException&);
    /**
     * Sets selection color for second highlight.
     * @param color rgba color
     */

    virtual void setSelectionColor2(const nmm_uint32& color)
      throw(const NMM::SerializedException&);
    /**
     * Sets standard selection color, deselects line.
     */

    virtual void reset()
      throw(const NMM::SerializedException&);
    /** Sets maximum number of visible lines. */

    virtual void setMaxLines(const nmm_uint32& value)
      throw(const NMM::SerializedException&);
    /** Gets maximum number of visible lines. */

    virtual nmm_uint32 getMaxLines() const
      throw(const NMM::SerializedException&);
    /**
     * Sets first visible line.
     * @return first visible line
     */

    virtual nmm_uint32 setStartLine(const nmm_uint32& start)
      throw(const NMM::SerializedException&);
    /** Get first visible line. */

    virtual nmm_uint32 getStartLine() const
      throw(const NMM::SerializedException&);
    /** Get number of lines. */

    virtual nmm_uint32 getNumLines() const
      throw(const NMM::SerializedException&);
    /**
     * Focus selection.
     * Adjusts first visible line so that the selected line is visible
     */

    virtual void focusSelection()
      throw(const NMM::SerializedException&);
    /**
     * Insert a line with content.
     * @param pos position where the new line should be inserted.
     * @param text line text
     * @param url url associated with this line
     */

    virtual void insertLine(const nmm_int32& pos, const string& text, const string& url = "")
      throw(const NMM::SerializedException&);
    /**
     * Adds a line with content.
     * @param pos position where the new line should be inserted.
     * @param text line text
     * @param url url associated with this line
     * @return line number of the new line
     */

    virtual nmm_int32 addLine(const string& text, const string& url = "")
      throw(const NMM::SerializedException&);
    /**
     * Set line widget
     * Add a widget to a line (such as another text view).
     */

    virtual void addLineWidget(const nmm_uint32& line, const IWidget& widget)
      throw(const NMM::SerializedException&);
    /** Delete the given line. */

    virtual void deleteLine(const nmm_uint32& line)
      throw(const NMM::SerializedException&);
    /** Delete all lines. */

    virtual void deleteAllLines()
      throw(const NMM::SerializedException&);
    /** mark line (using selection_color_2)
     *@param line line to mark
     */

    virtual void markLine(const nmm_uint32& line)
      throw(const NMM::SerializedException&);
    /** unmark line
     *@param line line to unmark
     */

    virtual void unmarkLine(const nmm_uint32& line)
      throw(const NMM::SerializedException&);
    /** get marked line-numbers
     *@return list of line-numbers
     */

    virtual list<nmm_uint32 >  getMarkedLines()
      throw(const NMM::SerializedException&);


  };

  typedef auto_ptr<ITextView> ITextView_var;




}

#include "nmm/nmm_suffix.hpp"

#endif
