/* 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_ITextViewImpl_HPP
#define NMM_ITextViewImpl_HPP

#include "nmm/nmm_prefix.hpp"

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

#include "IWidgetImpl.hpp"

#include "visibility.hpp"

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

  class DLLEXPORT ITextViewImpl  : virtual public IWidgetImpl { 
  public:
    ITextViewImpl() { addInterface(new ITextView(*this)); registerEvents(); };

    virtual ~ITextViewImpl() {};

  protected:
    /**
     * Set font.
     * Set the font all text on this widget is drawn in.
     * @param value font name
     */

    virtual void setFont(const string& value) = 0;
    /**
     * 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) = 0;
    /**
     * 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) = 0;
    /**
     * Deselect line ( set selected_line = 0).
     */

    virtual void deSelectLine() = 0;
    /**
     * Deselect second line ( set selected_line2 = 0).
     */

    virtual void deSelectLine2() = 0;
    /**
     * Get selected line.
     * @return selected line (0, if no line is selected)
     */

    virtual nmm_uint32 getSelectedLine() const = 0;
    /**
     * Get selected line (second selection).
     * @return second selected line (0, if no line is selected)
     */

    virtual nmm_uint32 getSelectedLine2() const = 0;
    /**
     * Get line content.
     * @param line line number
     * @returns the text displayed in that line
     */

    virtual string getLineContent(const nmm_uint32& line) const = 0;
    /**
     * 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) = 0;
    /**
     * 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 = 0;
    /**
     * 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 = 0;
    /**
     * Set autofocus for selectLine.
     * @param value autofocus mode. on=true or off=false.
     */

    virtual void setAutoFocus(const nmm_bool& value) = 0;
    /**
     * Sets selection color.
     * @param color rgba color
     */

    virtual void setSelectionColor(const nmm_uint32& color) = 0;
    /**
     * Sets selection color for second highlight.
     * @param color rgba color
     */

    virtual void setSelectionColor2(const nmm_uint32& color) = 0;
    /**
     * Sets standard selection color, deselects line.
     */

    virtual void reset() = 0;
    /** Sets maximum number of visible lines. */

    virtual void setMaxLines(const nmm_uint32& value) = 0;
    /** Gets maximum number of visible lines. */

    virtual nmm_uint32 getMaxLines() const = 0;
    /**
     * Sets first visible line.
     * @return first visible line
     */

    virtual nmm_uint32 setStartLine(const nmm_uint32& start) = 0;
    /** Get first visible line. */

    virtual nmm_uint32 getStartLine() const = 0;
    /** Get number of lines. */

    virtual nmm_uint32 getNumLines() const = 0;
    /**
     * Focus selection.
     * Adjusts first visible line so that the selected line is visible
     */

    virtual void focusSelection() = 0;
    /**
     * 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 = "") = 0;
    /**
     * 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 = "") = 0;
    /**
     * Set line widget
     * Add a widget to a line (such as another text view).
     */

    virtual void addLineWidget(const nmm_uint32& line, const IWidget& widget) = 0;
    /** Delete the given line. */

    virtual void deleteLine(const nmm_uint32& line) = 0;
    /** Delete all lines. */

    virtual void deleteAllLines() = 0;
    /** mark line (using selection_color_2)
     *@param line line to mark
     */

    virtual void markLine(const nmm_uint32& line) = 0;
    /** unmark line
     *@param line line to unmark
     */

    virtual void unmarkLine(const nmm_uint32& line) = 0;
    /** get marked line-numbers
     *@return list of line-numbers
     */

    virtual list<nmm_uint32 >  getMarkedLines() = 0;


  private:
    void registerEvents();
  };

}

#include "nmm/nmm_suffix.hpp"

#endif
