//------------------------------------------------------------------------------
// <copyright company="Telligent Systems">
//     Copyright (c) Telligent Systems Corporation.  All rights reserved.
// </copyright> 
//------------------------------------------------------------------------------

using System;

using System.Web.UI;
using CommunityServer.Components;
using System.Web.UI.WebControls;

//How can we validate an unknown child control?

namespace CommunityServer.Controls
{
	/// <summary>
	/// Summary description for Editor.
	/// </summary>
	[ValidationPropertyAttribute("Text")]
    public class Editor : TemplatedWebControl, ITextEditor   
	{
		CSContext csContext = CSContext.Current;
		private ITextEditor _iText = null;

		protected override void AttachChildControls() 
		{
			_iText = (ITextEditor) FindControl("Editor");
		}

		protected override String ExternalSkinFileName
		{
			get
			{
				return csContext.User.Editor.SkinName;
			}
		}

        public bool IsRichTextCapable
        {
            get
            {
                EnsureChildControls();
                return _iText.IsRichTextCapable;
            }   
        }

	    public string GetClientSideMethod
	    {
	        get 
			{ 
				EnsureChildControls();
				return _iText.GetClientSideMethod; 
			}
	    }

	    public override Unit Height
		{
			set
			{
				EnsureChildControls();
			    _iText.Height = value;
			}
            get
            {
                EnsureChildControls();
                return _iText.Height;
            }
		}

		public override Unit Width
		{
			set
			{
				EnsureChildControls();
			    _iText.Width = value;
			}
            get
            {
                EnsureChildControls();
                return _iText.Width;
            }
		}

		public int Rows
		{
			set
			{
				EnsureChildControls();
			    _iText.Rows = value;
			}
            get
            {
                EnsureChildControls();
                return _iText.Rows;
            }
		}

		public int Columns
		{
			set
			{
				EnsureChildControls();
			    _iText.Columns = value;
			}
            get
            {
                EnsureChildControls();
                return _iText.Columns;
            }
		}

		public string StyleName
		{
			set
			{
				EnsureChildControls();
			    _iText.StyleName = value;
			}
            get
            {
                EnsureChildControls();
                return _iText.StyleName;
            }
		}

        public string ClientSideText
        {
            get
            {
                EnsureChildControls();
                return _iText.GetClientSideMethod;
            }
        }
    
        /// <summary>
        /// Property EnableHtmlModeEditing (bool)
        /// </summary>
        public bool EnableHtmlModeEditing
        {
            get
            {   
                EnsureChildControls();
                return _iText.EnableHtmlModeEditing; 
			}
            set
            {  
				EnsureChildControls();
                _iText.EnableHtmlModeEditing = value; 
			}
        }
   
        
        public string Text
        {
            get
            { 
                EnsureChildControls();
                return _iText.Text;
            }
            set
            {  
				EnsureChildControls();
                _iText.Text = value;
            }
        }


	}
}
