/*
 * Created on Mar 26, 2004
 *
 */
package LumiSoft.UI.Controls;

import java.io.*;
import java.awt.*;
import java.awt.event.*;
import javax.swing.event.*;

import LumiSoft.Data.*;
import LumiSoft.UI.Controls.WOutlookBar.*;

/**
 * Viewstyle for UI.
 * 
 */
public class ViewStyle
{
	private static ViewStyle m_ViewStyle = null;

	private EventListenerList m_pListners                = null;
	private Color             m_FormColor                = GetColorFromRgb(212,208,200);
	private Color             m_BorderColor              = GetColorFromRgb(169,169,169);
	private Color             m_BorderHotColor           = GetColorFromRgb(0,0,0);
	private Color             m_ButtonColor              = GetColorFromRgb(212,208,200);
	private Color             m_ButtonHotColor           = GetColorFromRgb(182,193,214);
	private Color             m_ButtonPressedColor       = GetColorFromRgb(210,218,232);
	private Color             m_EditColor                = GetColorFromRgb(255,255,255);
	private Color             m_EditFocusedColor         = GetColorFromRgb(245,245,220);
	private Color             m_EditReadOnlyColor        = GetColorFromRgb(228,224,220);
	private Color             m_EditDisabledColor        = GetColorFromRgb(220,220,220);
	private Color             m_EditDisabledTextColor    = Color.LIGHT_GRAY;
	private Color             m_FlashColor               = GetColorFromRgb(255,192,203);
	private Color             m_BarColor                 = GetColorFromRgb(212,208,200);
	private Color             m_BarHotColor              = GetColorFromRgb(182,193,214);
	private Color             m_BarTextColor             = GetColorFromRgb(0,0,00);
	private Color             m_BarHotTextColor          = GetColorFromRgb(0,0,0);
	private Color             m_BarPressedColor          = GetColorFromRgb(210,218,232);
	private Color             m_BarBorderColor           = GetColorFromRgb(169,169,169);
	private Color             m_BarHotBorderColor        = GetColorFromRgb(0,0,0);
	private Color             m_BarClientAreaColor       = GetColorFromRgb(128,128,128);
	private Color             m_BarItemSelectedColor     = GetColorFromRgb(192,192,192);
	private Color             m_BarItemSelectedTextColor = Color.BLACK;
	private Color             m_BarItemHotColor          = GetColorFromRgb(182,193,214);
	private Color             m_BarItemPressedColor      = GetColorFromRgb(210,218,232);
	private Color             m_BarItemBorderHotColor    = GetColorFromRgb(0,0,0);
	private Color             m_BarItemTextColor         = GetColorFromRgb(255,255,255);
	private Color             m_BarItemHotTextColor      = GetColorFromRgb(212,208,200);
	private int               m_BarItemsStyle            = ItemsStyle.IconSelect;
	private Color             m_TextColor                = GetColorFromRgb(0,0,0);
	private Color             m_Text3DColor              = GetColorFromRgb(255,255,255);
	private Color             m_TextShadowColor          = GetColorFromRgb(169,169,169);
	private Color             m_GridRowColor             = Color.WHITE;
	private Color             m_GridRowTextColor         = Color.BLACK;
	private Color             m_GridEvenRowColor         = GetColorFromRgb(245,245,245);
	private Color             m_GridEvenRowTextColor     = Color.BLACK;
	private Color             m_GridRowSelectedColor     = ViewStyle.GetColorFromRgb(64,56,181);
	private Color             m_GridRowSelectedTextColor = Color.WHITE;
	private boolean           m_ReadOnly                 = false;

	/**
	 * Default constructor.
	 *
	 */
	public ViewStyle()
	{
		m_pListners = new EventListenerList();
	}

	/**
	 * Gets Color from rgb.
	 * @param r Red value.
	 * @param g Green value.
	 * @param b Blue value.
	 * @return
	 */
	public static Color GetColorFromRgb(int r,int g,int b)
	{  
		float[] f = new float[3];
		Color.RGBtoHSB(r,g,b,f);
		return Color.getHSBColor(f[0],f[1],f[2]);
	}
	
	/**
	 * Converts color to 32-bit argb color.
	 * @param c
	 * @return
	 */
	public static int ColorToArgb(Color c)
	{
		return c.getRGB();
	//	return (c.getAlpha() << 24) | (c.getRed() << 16) | (c.getRed() << 8) | c.getBlue();
	}
	
	/**
	 * Converts 32-bit argb color to Color.
	 * @param argb
	 * @return
	 */
	public static Color ColorFromArgb(int argb)
	{
		return GetColorFromRgb((0x00FF0000 & argb) >> 16,(0x0000FF00 & argb) >> 8,(0x000000FF & argb));
	}

	/**
	 * Copies colors and settings of this ViewStyle to specified destination ViewStyle.
	 * @param destViewStyle
	 */	
	public void CopyTo(ViewStyle destViewStyle)
	{
		destViewStyle.setBorderColor(this.getBorderColor());
		destViewStyle.setBorderHotColor(this.getBorderHotColor());
		destViewStyle.setButtonColor(this.getButtonColor());
		destViewStyle.setButtonHotColor(this.getButtonHotColor());
		destViewStyle.setButtonPressedColor(this.getButtonPressedColor());
		destViewStyle.setFormColor(this.getFormColor());
		destViewStyle.setEditColor(this.getEditColor());
		destViewStyle.setEditFocusedColor(this.getEditFocusedColor());
		destViewStyle.setEditReadOnlyColor(this.getEditReadOnlyColor());
		destViewStyle.setEditDisabledColor(this.getEditDisabledColor());
		destViewStyle.setEditDisabledTextColor(this.getEditDisabledTextColor());
		destViewStyle.setBarColor(this.getBarColor());
		destViewStyle.setBarHotColor(this.getBarHotColor());
		destViewStyle.setBarTextColor(this.getBarTextColor());
		destViewStyle.setBarHotTextColor(this.getBarHotTextColor());
		destViewStyle.setBarPressedColor(this.getBarPressedColor());
		destViewStyle.setBarBorderColor(this.getBarBorderColor());
		destViewStyle.setBarHotBorderColor(this.getBarHotBorderColor());
		destViewStyle.setBarClientAreaColor(this.getBarClientAreaColor());
		destViewStyle.setBarItemSelectedColor(this.getBarItemSelectedColor());
		destViewStyle.setBarItemSelectedTextColor(this.getBarItemSelectedTextColor());
		destViewStyle.setBarItemHotColor(this.getBarItemHotColor());
		destViewStyle.setBarItemPressedColor(this.getBarItemPressedColor());
		destViewStyle.setBarItemBorderHotColor(this.getBarItemBorderHotColor());
		destViewStyle.setBarItemTextColor(this.getBarItemTextColor());
		destViewStyle.setBarItemHotTextColor(this.getBarItemHotTextColor());
		destViewStyle.setBarItemsStyle(this.getBarItemsStyle());
		destViewStyle.setTextColor(this.getTextColor());
		destViewStyle.setText3DColor(this.getText3DColor());
		destViewStyle.setTextShadowColor(this.getTextShadowColor());
		destViewStyle.setFlashColor(this.getFlashColor());		
		destViewStyle.setGridRowColor(this.getGridRowColor());
		destViewStyle.setGridRowTextColor(this.getGridRowTextColor());
		destViewStyle.setGridEvenRowColor(this.getGridEvenRowColor());
		destViewStyle.setGridEvenRowTextColor(this.getGridEvenRowTextColor());
		destViewStyle.setGridRowSelectedColor(this.getGridRowSelectedColor());
		destViewStyle.setGridRowSelectedTextColor(this.getGridRowSelectedTextColor());
	}



    /**
     * Gets control editable part color.
     * @param readOnly Specified if contol is readonly.
     * @param enabled Specifies if control is enabled.
     * @return
     */
    public Color GetEditColor(boolean readOnly,boolean enabled)
    {
        return GetEditColor(readOnly,enabled,false);
    }

    /**
     * Gets control editable part color.
     * @param readOnly Specified if contol is readonly.
     * @param enabled Specifies if control is enabled.
     * @param focused Specifies if control is focused.
     * @return
     */
    public Color GetEditColor(boolean readOnly,boolean enabled,boolean focused)
    {
    	// Normal edit color wanted
        if(!readOnly && enabled){
        	if(focused){
            	return this.getEditFocusedColor();
         	}
            return this.getEditColor();
        }
        else{
        	// ReadOnly edit color wanted
            if(readOnly && enabled){
            	return this.getEditReadOnlyColor();
            }
            else{ // Disabled edit color wanted
            	return this.getEditDisabledColor();
            }
        }
	}


    /**
     * Gets control border color.
     * @param hot Specifies if control is hot.
     * @return
     */
    public Color GetBorderColor(boolean hot)
    {
    	if(hot){
        	return m_BorderHotColor;
        }
        else{
        	return m_BorderColor;
        }
    }


    /**
     * Gets button color.
     * @param hot Specifies if button is hot.
     * @param pressed Specifies if button is pressed.
     * @return
     */
    public Color GetButtonColor(boolean hot,boolean pressed)
    {
 		if(hot){
 			if(pressed){
 				return m_ButtonPressedColor;
 			}
			else{
 				return m_ButtonHotColor;
 			}
		}
 		else{
 			return m_ButtonColor;
		}
    }


    /**
     * Restores default ViewStyle colors and settings.
     *
     */
    public void RestoreDefault()
    {
    	this.setBorderColor(GetColorFromRgb(169,169,169));
        this.setBorderHotColor(GetColorFromRgb(0,0,0));
        this.setButtonColor(GetColorFromRgb(212,208,200));
        this.setButtonHotColor(GetColorFromRgb(182,193,214));
        this.setButtonPressedColor(GetColorFromRgb(210,218,232));
        this.setFormColor(GetColorFromRgb(212,208,200));
        this.setEditColor(GetColorFromRgb(255,255,255));
        this.setEditFocusedColor(GetColorFromRgb(245,245,220));
        this.setEditReadOnlyColor(GetColorFromRgb(228,224,220));
        this.setEditDisabledColor(GetColorFromRgb(220,220,220));
        this.setEditDisabledTextColor(Color.LIGHT_GRAY);
        this.setFlashColor(GetColorFromRgb(255,192,203));
        this.setBarColor(GetColorFromRgb(212,208,200));
        this.setBarHotColor(GetColorFromRgb(182,193,214));
        this.setBarTextColor(GetColorFromRgb(0,0,0));
        this.setBarHotTextColor(GetColorFromRgb(0,0,0));
        this.setBarPressedColor(GetColorFromRgb(210,218,232));
        this.setBarBorderColor(GetColorFromRgb(169,169,169));
        this.setBarHotBorderColor(GetColorFromRgb(0,0,0));
        this.setBarClientAreaColor(GetColorFromRgb(128,128,128));
        this.setBarItemSelectedColor(GetColorFromRgb(192,192,192));
        this.setBarItemSelectedTextColor(Color.BLACK);
        this.setBarItemHotColor(GetColorFromRgb(182,193,214));
        this.setBarItemPressedColor(GetColorFromRgb(210,218,232));
        this.setBarItemBorderHotColor(GetColorFromRgb(0,0,0));
        this.setBarItemTextColor(GetColorFromRgb(255,255,255));
        this.setBarItemHotTextColor(GetColorFromRgb(255,255,255));
   		this.setBarItemsStyle(ItemsStyle.IconSelect);
        this.setTextColor(GetColorFromRgb(0,0,0));
        this.setText3DColor(GetColorFromRgb(255,255,255));
        this.setTextShadowColor(GetColorFromRgb(169,169,169));
        this.setGridRowColor(Color.WHITE);
        this.setGridRowTextColor(Color.BLACK);
        this.setGridEvenRowColor(GetColorFromRgb(245,245,245));
        this.setGridEvenRowTextColor(Color.BLACK);
        this.setGridRowSelectedColor(GetColorFromRgb(64,56,181));
        this.setGridRowSelectedTextColor(Color.WHITE);
	}

       
    /**
     * Saves current viewStyle to xml.
     */
    public byte[] SaveToXml() throws Exception
    {    	
        DataSet ds = new DataSet("dsViewStyle");
        DataTable dt = ds.getTables().Add("ViewStyle");

        dt.getColumns().Add("FormColor");
        dt.getColumns().Add("BorderColor");
        dt.getColumns().Add("BorderHotColor");
        dt.getColumns().Add("ButtonColor");
        dt.getColumns().Add("ButtonHotColor");
        dt.getColumns().Add("ButtonPressedColor");
        dt.getColumns().Add("EditColor");
        dt.getColumns().Add("EditFocusedColor");
        dt.getColumns().Add("EditReadOnlyColor");
        dt.getColumns().Add("EditDisabledColor");
        dt.getColumns().Add("EditDisabledTextColor");
        dt.getColumns().Add("FlashColor");
        dt.getColumns().Add("BarColor");
        dt.getColumns().Add("BarHotColor");
        dt.getColumns().Add("BarTextColor");
        dt.getColumns().Add("BarHotTextColor");
        dt.getColumns().Add("BarPressedColor");
        dt.getColumns().Add("BarBorderColor");
        dt.getColumns().Add("BarHotBorderColor");
        dt.getColumns().Add("BarClientAreaColor");
        dt.getColumns().Add("BarItemSelectedColor");
        dt.getColumns().Add("BarItemSelectedTextColor");
        dt.getColumns().Add("BarItemSelectedBorder");
        dt.getColumns().Add("BarItemHotColor");
        dt.getColumns().Add("BarItemPressedColor");
        dt.getColumns().Add("BarItemBorderHotColor");
        dt.getColumns().Add("BarItemTextColor");
        dt.getColumns().Add("BarItemHotTextColor");
        dt.getColumns().Add("BarItemsStyle");
        dt.getColumns().Add("TextColor");
        dt.getColumns().Add("Text3DColor");
        dt.getColumns().Add("TextShadowColor");
        dt.getColumns().Add("GridRowColor");
        dt.getColumns().Add("GridRowTextColor");
        dt.getColumns().Add("GridEvenRowColor");
        dt.getColumns().Add("GridEvenRowTextColor");
        dt.getColumns().Add("GridRowSelectedColor");
        dt.getColumns().Add("GridRowSelectedTextColor");


        DataRow dr = dt.NewRow();
        dr.set("FormColor"                , new Integer(ColorToArgb(getFormColor())));
        dr.set("BorderColor"              , new Integer(ColorToArgb(getBorderColor())));
        dr.set("BorderHotColor"           , new Integer(ColorToArgb(getBorderHotColor())));
        dr.set("ButtonColor"              , new Integer(ColorToArgb(getButtonColor())));
        dr.set("ButtonHotColor"           , new Integer(ColorToArgb(getButtonHotColor())));
        dr.set("ButtonPressedColor"       , new Integer(ColorToArgb(getButtonPressedColor())));
        dr.set("EditColor"                , new Integer(ColorToArgb(getEditColor())));
        dr.set("EditDisabledColor"        , new Integer(ColorToArgb(getEditDisabledColor())));
        dr.set("EditDisabledTextColor"    , new Integer(ColorToArgb(getEditDisabledTextColor())));
        dr.set("EditFocusedColor"         , new Integer(ColorToArgb(getEditFocusedColor())));
        dr.set("EditReadOnlyColor"        , new Integer(ColorToArgb(getEditReadOnlyColor())));
        dr.set("FlashColor"               , new Integer(ColorToArgb(getFlashColor())));
        dr.set("BarColor"                 , new Integer(ColorToArgb(getBarColor())));
        dr.set("BarHotColor"              , new Integer(ColorToArgb(getBarHotColor())));
        dr.set("BarTextColor"             , new Integer(ColorToArgb(getBarTextColor())));
        dr.set("BarHotTextColor"          , new Integer(ColorToArgb(getBarHotTextColor())));
        dr.set("BarPressedColor"          , new Integer(ColorToArgb(getBarPressedColor())));
        dr.set("BarBorderColor"           , new Integer(ColorToArgb(getBarBorderColor())));
        dr.set("BarHotBorderColor"        , new Integer(ColorToArgb(getBarHotBorderColor())));
        dr.set("BarClientAreaColor"       , new Integer(ColorToArgb(getBarClientAreaColor())));
        dr.set("BarItemSelectedColor"     , new Integer(ColorToArgb(getBarItemSelectedColor())));
        dr.set("BarItemSelectedTextColor" , new Integer(ColorToArgb(getBarItemSelectedTextColor())));
        dr.set("BarItemHotColor"          , new Integer(ColorToArgb(getBarItemHotColor())));
        dr.set("BarItemPressedColor"      , new Integer(ColorToArgb(getBarItemPressedColor())));
        dr.set("BarItemBorderHotColor"    , new Integer(ColorToArgb(getBarItemBorderHotColor())));
        dr.set("BarItemTextColor"         , new Integer(ColorToArgb(getBarItemTextColor())));
        dr.set("BarItemHotTextColor"      , new Integer(ColorToArgb(getBarItemHotTextColor())));
        dr.set("BarItemsStyle"            , new Integer(getBarItemsStyle()));
        dr.set("FlashColor"               , new Integer(ColorToArgb(getFlashColor())));
        dr.set("TextColor"                , new Integer(ColorToArgb(getTextColor())));
        dr.set("Text3DColor"              , new Integer(ColorToArgb(getText3DColor())));
        dr.set("TextShadowColor"          , new Integer(ColorToArgb(getTextShadowColor())));
        dr.set("GridRowColor"             , new Integer(ColorToArgb(getGridRowColor())));
        dr.set("GridRowTextColor"         , new Integer(ColorToArgb(getGridRowTextColor())));
        dr.set("GridEvenRowColor"         , new Integer(ColorToArgb(getGridEvenRowColor())));
        dr.set("GridEvenRowTextColor"     , new Integer(ColorToArgb(getGridEvenRowTextColor())));
        dr.set("GridRowSelectedColor"     , new Integer(ColorToArgb(getGridRowSelectedColor())));
        dr.set("GridRowSelectedTextColor" , new Integer(ColorToArgb(getGridRowSelectedTextColor())));

        dt.getRows().Add(dr);

        ByteArrayOutputStream ms = new ByteArrayOutputStream();
        ds.WriteXml(ms,false);
        
        return ms.toByteArray();
	}

    
    /**
     * Loads viewStyle from xml data.
     */
    public void LoadFromXml(byte[] viewStyleXML)
    {
    	try{
    		ByteArrayInputStream ms = new ByteArrayInputStream(viewStyleXML);        	
            DataSet ds = new DataSet();
            ds.ReadXml(ms);

            DataRow dr = ds.getTables().get("ViewStyle").getRows().get(0);

            setFormColor(                 ColorFromArgb(Integer.parseInt(dr.get("FormColor").toString())));
            setBorderColor(               ColorFromArgb(Integer.parseInt(dr.get("BorderColor").toString())));
            setBorderHotColor(            ColorFromArgb(Integer.parseInt(dr.get("BorderHotColor").toString())));
            setButtonColor(               ColorFromArgb(Integer.parseInt(dr.get("ButtonColor").toString())));
            setButtonHotColor(            ColorFromArgb(Integer.parseInt(dr.get("ButtonHotColor").toString())));
            setButtonPressedColor(        ColorFromArgb(Integer.parseInt(dr.get("ButtonPressedColor").toString())));
            setEditColor(                 ColorFromArgb(Integer.parseInt(dr.get("EditColor").toString())));
            setEditFocusedColor(          ColorFromArgb(Integer.parseInt(dr.get("EditFocusedColor").toString())));
            setEditReadOnlyColor(         ColorFromArgb(Integer.parseInt(dr.get("EditReadOnlyColor").toString())));
            setEditDisabledColor(         ColorFromArgb(Integer.parseInt(dr.get("EditDisabledColor").toString())));
            setEditDisabledTextColor(     ColorFromArgb(Integer.parseInt(dr.get("EditDisabledTextColor").toString())));
            setBarColor(                  ColorFromArgb(Integer.parseInt(dr.get("BarColor").toString())));
            setBarHotColor(               ColorFromArgb(Integer.parseInt(dr.get("BarHotColor").toString())));
            setBarTextColor(              ColorFromArgb(Integer.parseInt(dr.get("BarTextColor").toString())));
            setBarHotTextColor(           ColorFromArgb(Integer.parseInt(dr.get("BarHotTextColor").toString())));
            setBarPressedColor(           ColorFromArgb(Integer.parseInt(dr.get("BarPressedColor").toString())));
            setBarBorderColor(            ColorFromArgb(Integer.parseInt(dr.get("BarBorderColor").toString())));
            setBarHotBorderColor(         ColorFromArgb(Integer.parseInt(dr.get("BarHotBorderColor").toString())));
            setBarClientAreaColor(        ColorFromArgb(Integer.parseInt(dr.get("BarClientAreaColor").toString())));
            setBarItemSelectedColor(      ColorFromArgb(Integer.parseInt(dr.get("BarItemSelectedColor").toString())));
            setBarItemSelectedTextColor(  ColorFromArgb(Integer.parseInt(dr.get("BarItemSelectedTextColor").toString())));
            setBarItemHotColor(           ColorFromArgb(Integer.parseInt(dr.get("BarItemHotColor").toString())));
            setBarItemPressedColor(       ColorFromArgb(Integer.parseInt(dr.get("BarItemPressedColor").toString())));
            setBarItemBorderHotColor(     ColorFromArgb(Integer.parseInt(dr.get("BarItemBorderHotColor").toString())));
            setBarItemTextColor(          ColorFromArgb(Integer.parseInt(dr.get("BarItemTextColor").toString())));
            setBarItemHotTextColor(       ColorFromArgb(Integer.parseInt(dr.get("BarItemHotTextColor").toString())));
            setBarItemsStyle(             Integer.parseInt(dr.get("BarItemsStyle").toString()));
            setFlashColor(                ColorFromArgb(Integer.parseInt(dr.get("FlashColor").toString())));
            setTextColor(                 ColorFromArgb(Integer.parseInt(dr.get("TextColor").toString())));
            setText3DColor(               ColorFromArgb(Integer.parseInt(dr.get("Text3DColor").toString())));
            setTextShadowColor(           ColorFromArgb(Integer.parseInt(dr.get("TextShadowColor").toString())));
            setGridRowColor(              ColorFromArgb(Integer.parseInt(dr.get("GridRowColor").toString())));
            setGridRowTextColor(          ColorFromArgb(Integer.parseInt(dr.get("GridRowTextColor").toString())));
            setGridEvenRowColor(          ColorFromArgb(Integer.parseInt(dr.get("GridEvenRowColor").toString())));
            setGridEvenRowTextColor(      ColorFromArgb(Integer.parseInt(dr.get("GridEvenRowTextColor").toString())));
            setGridRowSelectedColor(      ColorFromArgb(Integer.parseInt(dr.get("GridRowSelectedColor").toString())));
            setGridRowSelectedTextColor(  ColorFromArgb(Integer.parseInt(dr.get("GridRowSelectedTextColor").toString())));
		}
		catch(Exception x){
            RestoreDefault();
        }
	}

/*
    /// <summary>
    /// Checks if specified property must be serialized.
    /// </summary>
    /// <param name="propertyName">Property name.</param>
    /// <returns></returns>
    public bool ShouldSerialize(string propertyName)
    {
    	bool retVal = false;

        switch(propertyName)
        {
        	case "BorderColor":
            	if(ViewStyle.staticViewStyle.BorderColor != this.BorderColor){
                	retVal = true;
                }
                break;
            case "BorderHotColor":
                if(ViewStyle.staticViewStyle.BorderHotColor != this.BorderHotColor){
                    retVal = true;
                }
                break;
            case "ButtonColor":
               if(ViewStyle.staticViewStyle.ButtonColor != this.ButtonColor){
                    retVal = true;
               }
               break;
            case "ButtonHotColor":
               if(ViewStyle.staticViewStyle.ButtonHotColor != this.ButtonHotColor){
                   retVal = true;
               }
               break;
            case "ButtonPressedColor":
            	if(ViewStyle.staticViewStyle.ButtonPressedColor != this.ButtonPressedColor){
                	retVal = true;
                }
                break;
            case "ControlBackColor":
                if(ViewStyle.staticViewStyle.ControlBackColor != this.ControlBackColor){
                    retVal = true;
            	}
                break;
            case "ControlForeColor":
                if(ViewStyle.staticViewStyle.ControlForeColor != this.ControlForeColor){
                    retVal = true;
                }
                break;
            case "EditColor":
               if(ViewStyle.staticViewStyle.EditColor != this.EditColor){
                    retVal = true;
               }
               break;
            case "EditFocusedColor":
               if(ViewStyle.staticViewStyle.EditFocusedColor != this.EditFocusedColor){
                    retVal = true;
               }
               break;
            case "EditReadOnlyColor":
               if(ViewStyle.staticViewStyle.EditReadOnlyColor != this.EditReadOnlyColor){
                    retVal = true;
               }
               break;
            case "EditDisabledColor":
               if(ViewStyle.staticViewStyle.EditDisabledColor != this.EditDisabledColor){
                    retVal = true;
            	}
                break;
            case "BarColor":
               if(ViewStyle.staticViewStyle.BarColor != this.BarColor){
                    retVal = true;
               }
               break;
            case "BarHotColor":
               if(ViewStyle.staticViewStyle.BarHotColor != this.BarHotColor){
                    retVal = true;
            	}
                break;
            case "BarTextColor":
               if(ViewStyle.staticViewStyle.BarTextColor != this.BarTextColor){
                    retVal = true;
               }
               break;
           case "BarHotTextColor":
               if(ViewStyle.staticViewStyle.BarHotTextColor != this.BarHotTextColor){
                    retVal = true;
               }
               break;
           case "BarPressedColor":
               if(ViewStyle.staticViewStyle.BarPressedColor != this.BarPressedColor){
                     retVal = true;
      		   }
               break;
           case "BarBorderColor":
               if(ViewStyle.staticViewStyle.BarBorderColor != this.BarBorderColor){
                     retVal = true;
           	    }
                break;
           case "BarHotBorderColor":
               if(ViewStyle.staticViewStyle.BarHotBorderColor != this.BarHotBorderColor){
                     retVal = true;
               }
               break;
           case "BarClientAreaColor":
               if(ViewStyle.staticViewStyle.BarClientAreaColor != this.BarClientAreaColor){
                     retVal = true;
               }
               break;
           case "BarItemSelectedColor":
               if(ViewStyle.staticViewStyle.BarItemSelectedColor != this.BarItemSelectedColor){
                     retVal = true;
               }
               break;
           case "BarItemSelectedTextColor":
               if(ViewStyle.staticViewStyle.BarItemSelectedTextColor != this.BarItemSelectedTextColor){
                     retVal = true;
               }
               break;
           case "BarItemHotColor":
               if(ViewStyle.staticViewStyle.BarItemHotColor != this.BarItemHotColor){
                     retVal = true;
               }
               break;
           case "BarItemPressedColor":
               if(ViewStyle.staticViewStyle.BarItemPressedColor != this.BarItemPressedColor){
                      retVal = true;
               }
               break;
           case "BarItemBorderHotColor":
               if(ViewStyle.staticViewStyle.BarItemBorderHotColor != this.BarItemBorderHotColor){
                      retVal = true;
               }
               break;
           case "BarItemTextColor":
               if(ViewStyle.staticViewStyle.BarItemTextColor != this.BarItemTextColor){
                      retVal = true;
               }
               break;
           case "BarItemHotTextColor":
               if(ViewStyle.staticViewStyle.BarItemHotTextColor != this.BarItemHotTextColor){
                      retVal = true;
               }
               break;
           case "BarItemsStyle":
               if(ViewStyle.staticViewStyle.BarItemsStyle != this.BarItemsStyle){
                       retVal = true;
               }
               break;
           case "FlashColor":
               if(ViewStyle.staticViewStyle.FlashColor != this.FlashColor){
                       retVal = true;
               }
               break;
           case "TextColor":
               if(ViewStyle.staticViewStyle.TextColor != this.TextColor){
                       retVal = true;
               }
              break;
           case "Text3DColor":
               if(ViewStyle.staticViewStyle.Text3DColor != this.Text3DColor){
                        retVal = true;
               }
             break;
           case "TextShadowColor":
               if(ViewStyle.staticViewStyle.TextShadowColor != this.TextShadowColor){
                        retVal = true;
               }
               break;
		}

        return retVal;
	}
*/

    /**
     * Gets control border color.
     */
	public Color getBorderColor()
	{
		return m_BorderColor;
	}
	/**
	 * Sets control border color.
	 * @param value
	 */
	public void setBorderColor(Color value)
	{
		if(!m_ReadOnly && m_BorderColor != value){
			m_BorderColor = value;
			OnStyleChanged("BorderColor",value);
		}
	}
	
	/**
	 * Gets control hot border color.
	 * @return
	 */
	public Color getBorderHotColor()
	{
		return m_BorderHotColor;
	}
	/**
	 * Sets control hot border color.
	 * @param value
	 */
	public void setBorderHotColor(Color value)
	{
		if(!m_ReadOnly && m_BorderHotColor != value){
			m_BorderHotColor = value;
			OnStyleChanged("BorderHotColor",value);
		}
	}
	
	/**
	 * Gets button color.
	 * @return
	 */
	public Color getButtonColor()
	{
		return m_ButtonColor;
	}
	/**
	 * Sets button color.
	 * @param value
	 */
	public void setButtonColor(Color value)
	{
		if(!m_ReadOnly && m_ButtonColor != value){
			m_ButtonColor = value;
			OnStyleChanged("ButtonColor",value);
		}
	}
	
	/**
	 * Gets button hot color.
	 * @return
	 */
	public Color getButtonHotColor()
	{
		return m_ButtonHotColor;
	}
	/**
	 * Sets button hot color.
	 * @param value
	 */
	public void setButtonHotColor(Color value)
	{
		if(!m_ReadOnly && m_ButtonHotColor != value){
			m_ButtonHotColor = value;
			OnStyleChanged("ButtonHotColor",value);
		}
	}
	
	/**
	 * Get button pressed color.
	 * @return
	 */
	public Color getButtonPressedColor()
	{
		return m_ButtonPressedColor;
	}
	/**
	 * Sets button pressed color.
	 * @param value
	 */
	public void setButtonPressedColor(Color value)
	{
		if(!m_ReadOnly && m_ButtonPressedColor != value){
			m_ButtonPressedColor = value;
			OnStyleChanged("ButtonPressedColor",value);
		}
	}
	
	/**
	 * Gets form backround color.
	 * @return
	 */
	public Color getFormColor()
	{
		return m_FormColor;
	}
	/**
	 * Sets form backrond color.
	 * @param value
	 */
	public void setFormColor(Color value)
	{
		if(!m_ReadOnly && m_FormColor != value){
			m_FormColor = value;
			OnStyleChanged("FormColor",value);
		}
	}
		
	/**
	 * Gets flash color.
	 */
	public Color getFlashColor()
	{
		return m_FlashColor;
	}
	/**
	 * Sets flash color.
	 * @param value
	 */
	public void setFlashColor(Color value)
	{
		if(!m_ReadOnly && m_FlashColor != value){
			m_FlashColor = value;
			OnStyleChanged("FlashColor",value);
		}
	}
	
	/**
	 * Gets control editable part color. 
	 * @return
	 */
	public Color getEditColor()
	{
		return m_EditColor;
	}
	/**
	 * Sets control editable part color.
	 * @param value
	 */
	public void setEditColor(Color value)
	{
		if(!m_ReadOnly && m_EditColor != value){
			m_EditColor = value;
			OnStyleChanged("EditColor",value);
		}
	}
	
	/**
	 * Gets control editable part focused color.
	 * @return
	 */
	public Color getEditFocusedColor()
	{
		return m_EditFocusedColor;
	}
	/**
	 * Sets control editable part focused color.
	 * @param value
	 */
	public void setEditFocusedColor(Color value)
	{
		if(!m_ReadOnly && m_EditFocusedColor != value){
			m_EditFocusedColor = value;
			OnStyleChanged("EditFocusedColor",value);
		}
	}
	
	/**
	 * Gets control editable part readonly color.
	 * @return
	 */
	public Color getEditReadOnlyColor()
	{
		return m_EditReadOnlyColor;
	}
	/**
	 * Sets control editable part readonly color.
	 * @param value
	 */
	public void setEditReadOnlyColor(Color value)
	{
		if(!m_ReadOnly && m_EditReadOnlyColor != value){
			m_EditReadOnlyColor = value;
			OnStyleChanged("EditReadOnlyColor",value);
		}
	}
	
	/**
	 * Gets control editable part disabled color.
	 * @return
	 */
	public Color getEditDisabledColor()
	{
		return m_EditDisabledColor;
	}
	/**
	 * Sets control editable part disabled color.
	 * @param value
	 */
	public void setEditDisabledColor(Color value)
	{
		if(!m_ReadOnly && m_EditDisabledColor != value){
			m_EditDisabledColor = value;
			OnStyleChanged("EditDisabledColor",value);
		}
	}
	
	/**
	 * Gets control editable part disabled text color.
	 * @return
	 */
	public Color getEditDisabledTextColor()
	{
		return m_EditDisabledTextColor;
	}
	/**
	 * Sets control editable part disabled text color.
	 * @param value
	 */
	public void setEditDisabledTextColor(Color value)
	{
		if(!m_ReadOnly && m_EditDisabledTextColor != value){
			m_EditDisabledTextColor = value;
			OnStyleChanged("EditDisabledTextColor",value);
		}
	}
	
	/**
	 * Gets outlookbar bar color.
	 * @return
	 */
	public Color getBarColor()
	{
		return m_BarColor;
	}
	/**
	 * Sets outlookbar bar color. 
	 * @param value
	 */
	public void setBarColor(Color value)
	{
		if(!m_ReadOnly && m_BarColor != value){
			m_BarColor = value;
			OnStyleChanged("BarColor",value);
		}
	}
	
	/**
	 * Gets outlookbar bar hot color.
	 * @return
	 */
	public Color getBarHotColor()
	{
		return m_BarHotColor;
	}
	/**
	 * Sets outlookbar bar hot color.
	 * @param value
	 */
	public void setBarHotColor(Color value)
	{
		if(!m_ReadOnly && m_BarHotColor != value){
			m_BarHotColor = value;
			OnStyleChanged("BarHotColor",value);
		}
	}
	
	/**
	 * Gets outlookbar bar text color.
	 * @return
	 */
	public Color getBarTextColor()
	{
		return m_BarTextColor;
	}
	/**
	 * Sets outlookbar bar text color.
	 * @param value
	 */
	public void setBarTextColor(Color value)
	{
		if(!m_ReadOnly && m_BarTextColor != value){
			m_BarTextColor = value;
			OnStyleChanged("BarTextColor",value);
		}
	}
	
	/**
	 * Gets outlookbar bar text hot color.
	 * @return
	 */
	public Color getBarHotTextColor()
	{
		return m_BarHotTextColor;
	}
	/**
	 * Sets outlookbar bar text hot color.
	 * @param value
	 */
	public void setBarHotTextColor(Color value)
	{
		if(!m_ReadOnly && m_BarHotTextColor != value){
			m_BarHotTextColor = value;
			OnStyleChanged("BarHotTextColor",value);
		}
	}
	
	/**
	 * Gets outlookbar bar pressed color.
	 * @return
	 */
	public Color getBarPressedColor()
	{
		return m_BarPressedColor;
	}
	/**
	 * Sets outlookbar bar pressed color.
	 * @param value
	 */
	public void setBarPressedColor(Color value)
	{
		if(!m_ReadOnly && m_BarPressedColor != value){
			m_BarPressedColor = value;
			OnStyleChanged("BarPressedColor",value);
		}
	}

	/**
	 * Gets outlookbar bar border color.
	 * @return
	 */
	public Color getBarBorderColor()
	{
		return m_BarBorderColor;
	}
	/**
	 * Sets outlookbar bar border color.
	 * @param value
	 */
	public void setBarBorderColor(Color value)
	{
		if(!m_ReadOnly && m_BarBorderColor != value){
			m_BarBorderColor = value;
			OnStyleChanged("BarBorderColor",value);
		}
	}
	
	/**
	 * Gets outlookbar bar border hot color.
	 * @return
	 */
	public Color getBarHotBorderColor()
	{
		return m_BarHotBorderColor;
	}
	/**
	 * Sets outlookbar bar border hot color.
	 * @param value
	 */
	public void setBarHotBorderColor(Color value)
	{
		if(!m_ReadOnly && m_BarHotBorderColor != value){
			m_BarHotBorderColor = value;
			OnStyleChanged("BarHotBorderColor",value);
		}
	}
	
	/**
	 * Gets outlookbar bar items area backround  color.
	 * @return
	 */
	public Color getBarClientAreaColor()
	{
		return m_BarClientAreaColor;
	}
	/**
	 * Sets outlookbar bar items area backround color.
	 * @param value
	 */
	public void setBarClientAreaColor(Color value)
	{
		if(!m_ReadOnly && m_BarClientAreaColor != value){
			m_BarClientAreaColor = value;
			OnStyleChanged("BarClientAreaColor",value);
		}
	}
	
	/**
	 * Gets outlookbar item selected color.
	 * @return
	 */
	public Color getBarItemSelectedColor()
	{
		return m_BarItemSelectedColor;
	}
	/**
	 * Sets outlookbar item selected color.
	 * @param value
	 */
	public void setBarItemSelectedColor(Color value)
	{
		if(!m_ReadOnly && m_BarItemSelectedColor != value){
			m_BarItemSelectedColor = value;
			OnStyleChanged("BarItemSelectedColor",value);
		}
	}
	
	/**
	 * Gets outlookbar item selected text color.
	 * @return
	 */
	public Color getBarItemSelectedTextColor()
	{
		return m_BarItemSelectedTextColor;
	}
	/**
	 * Sets outlookbar item selected text color.
	 * @param value
	 */
	public void setBarItemSelectedTextColor(Color value)
	{
		if(!m_ReadOnly && m_BarItemSelectedTextColor != value){
			m_BarItemSelectedTextColor = value;
			OnStyleChanged("BarItemSelectedTextColor",value);
		}
	}
	
	/**
	 * Gets outlookbar item hot color.
	 * @return
	 */
	public Color getBarItemHotColor()
	{
		return m_BarItemHotColor;
	}
	/**
	 * Sets outlookbar item hot color.
	 * @param value
	 */
	public void setBarItemHotColor(Color value)
	{
		if(!m_ReadOnly && m_BarItemHotColor != value){
			m_BarItemHotColor = value;
			OnStyleChanged("BarItemHotColor",value);
		}
	}
	
	/**
	 * Gets outlookbar item pressed color.
	 * @return
	 */
	public Color getBarItemPressedColor()
	{
		return m_BarItemPressedColor;
	}
	/**
	 * Sets outlookbar item pressed color.
	 * @param value
	 */
	public void setBarItemPressedColor(Color value)
	{
		if(!m_ReadOnly && m_BarItemPressedColor != value){
			m_BarItemPressedColor = value;
			OnStyleChanged("BarItemPressedColor",value);
		}
	}
	
	/**
	 * Gets outlookbar item border hot color.
	 * @return
	 */
	public Color getBarItemBorderHotColor()
	{
		return m_BarItemBorderHotColor;
	}
	/**
	 * Gets outlookbar item border hot color.
	 * @param value
	 */
	public void setBarItemBorderHotColor(Color value)
	{
		if(!m_ReadOnly && m_BarItemBorderHotColor != value){
			m_BarItemBorderHotColor = value;
			OnStyleChanged("BarItemBorderHotColor",value);
		}
	}
	
	/**
	 * Gets outlookbar item text color.
	 * @return
	 */
	public Color getBarItemTextColor()
	{
		return m_BarItemTextColor;
	}
	/**
	 * Sets outlookbar item text color.
	 * @param value
	 */
	public void setBarItemTextColor(Color value)
	{
		if(!m_ReadOnly && m_BarItemTextColor != value){
			m_BarItemTextColor = value;
			OnStyleChanged("BarItemTextColor",value);
		}
	}
	
	/**
	 * Gets outlookbar item text hot color.
	 * @return
	 */
	public Color getBarItemHotTextColor()
	{
		return m_BarItemHotTextColor;
	}
	/**
	 * Sets outlookbar item text hot color.
	 * @param value
	 */
	public void setBarItemHotTextColor(Color value)
	{
		if(!m_ReadOnly && m_BarItemHotTextColor != value){
			m_BarItemHotTextColor = value;
			OnStyleChanged("BarItemHotTextColor",value);
		}
	}
	
	/**
	 * Gets outlookbar items style color.
	 * @return
	 */
	public int getBarItemsStyle()
	{
		return m_BarItemsStyle;
	}
	/**
	 * Sets outlookbar items style color.
	 * @param value
	 */
	public void setBarItemsStyle(int value)
	{
		if(!m_ReadOnly && m_BarItemsStyle != value){
			m_BarItemsStyle = value;
			OnStyleChanged("BarItemsStyle",new Integer(value));
		 }
	}

	/**
	 * Gets label text color.
	 * @return
	 */
	public Color getTextColor()
	{
		return m_TextColor;
	}
	/**
	 * Sets lable text color.
	 * @param value
	 */
	public void setTextColor(Color value)
	{
		if(!m_ReadOnly && m_TextColor != value){
			m_TextColor = value;
			OnStyleChanged("TextColor",value);
		}
	}
	
	/**
	 * Gets label 3D text color.
	 * @return
	 */
	public Color getText3DColor()
	{
		return m_Text3DColor;
	}
	/**
	 * Sets label 3D text color.
	 * @param value
	 */
	public void setText3DColor(Color value)
	{
		if(!m_ReadOnly && m_Text3DColor != value){
			m_Text3DColor = value;
			OnStyleChanged("Text3DColor",value);
		}
	}
	
	/**
	 * Gets label shadow text color.
	 * @return
	 */
	public Color getTextShadowColor()
	{
		return m_TextShadowColor;
	}
	/**
	 * Sets label shadow text color.
	 * @param value
	 */
	public void setTextShadowColor(Color value)
	{
		if(!m_ReadOnly && m_TextShadowColor != value){
			m_TextShadowColor = value;
			OnStyleChanged("TextShadowColor",value);
		}
	}
	
	
	/**
	 * Gets grid row color. (Rows 1,3,5,7, ...) 
	 * @return
	 */
	public Color getGridRowColor()
	{
		return m_GridRowColor;
	}
	/**
	 * Sets grid row text color. (Rows 1,3,5,7, ...)
	 * @param value
	 */
	public void setGridRowColor(Color value)
	{
		if(!m_ReadOnly && m_GridRowColor != value){
			m_GridRowColor = value;
			OnStyleChanged("GridRowColor",value);
		}
	}
	
	/**
	 * Gets grid row color. (Rows 1,3,5,7, ...) 
	 * @return
	 */
	public Color getGridRowTextColor()
	{
		return m_GridRowTextColor;
	}
	/**
	 * Sets grid row text color. (Rows 1,3,5,7, ...)
	 * @param value
	 */
	public void setGridRowTextColor(Color value)
	{
		if(!m_ReadOnly && m_GridRowTextColor != value){
			m_GridRowTextColor = value;
			OnStyleChanged("GridRowTextColor",value);
		}
	}
	
	/**
	 * Gets grid even row color. (Rows 2,4,6,8, ...) 
	 * @return
	 */
	public Color getGridEvenRowColor()
	{
		return m_GridEvenRowColor;
	}
	/**
	 * Sets grid even row color. (Rows 2,4,6,8, ...) 
	 * @param value
	 */
	public void setGridEvenRowColor(Color value)
	{
		if(!m_ReadOnly && m_GridEvenRowColor != value){
			m_GridEvenRowColor = value;
			OnStyleChanged("GridEvenRowColor",value);
		}
	}
	
	/**
	 * Gets grid even row color. (Rows 2,4,6,8, ...) 
	 * @return
	 */
	public Color getGridEvenRowTextColor()
	{
		return m_GridEvenRowTextColor;
	}
	/**
	 * Sets grid even row text color. (Rows 2,4,6,8, ...) 
	 * @param value
	 */
	public void setGridEvenRowTextColor(Color value)
	{
		if(!m_ReadOnly && m_GridEvenRowTextColor != value){
			m_GridEvenRowTextColor = value;
			OnStyleChanged("GridEvenRowTextColor",value);
		}
	}
	
	/**
	 * Gets selected grid row color.
	 * @return
	 */
	public Color getGridRowSelectedColor()
	{
		return m_GridRowSelectedColor;
	}
	/**
	 * Sets selected grid row color.
	 * @param value
	 */
	public void setGridRowSelectedColor(Color value)
	{
		if(!m_ReadOnly && m_GridRowSelectedColor != value){
			m_GridRowSelectedColor = value;
			OnStyleChanged("GridRowSelectedColor",value);
		}
	}
	
	/**
	 * Gets selected grid row text color.
	 * @return
	 */
	public Color getGridRowSelectedTextColor()
	{
		return m_GridRowSelectedTextColor;
	}
	/**
	 * Sets selected grid row text color.
	 * @param value
	 */
	public void setGridRowSelectedTextColor(Color value)
	{
		if(!m_ReadOnly && m_GridRowSelectedTextColor != value){
			m_GridRowSelectedTextColor = value;
			OnStyleChanged("GridRowSelectedTextColor",value);
		}
	}
		

//	public TextStyle TextStyle
//	{
//		get{ return m_TextStyle; }


	/**
	 * Gets if ViewStyle is readonly.
	 * @return
	 */
	public boolean getReadOnly()
	{
		return m_ReadOnly;
	}
	/**
	 * Sets if ViewStyle is readonly.
	 * @param c
	 */
	public void setReadOnly(boolean c)
	{
		if(m_ReadOnly != c){
			m_ReadOnly = c;
		}
	}

    
	private void OnStyleChanged(String propertyName,Object popertyValue)
	{
		RaiseViewStyleChanged();
	}


    //------ Static functions / properties ----------//


	/**
	 * Gets static ViewStyle.
	 * @return
	 */
	public static ViewStyle getstaticViewStyle()
	{		
		if(m_ViewStyle == null){
			m_ViewStyle = new ViewStyle();
		}

		return m_ViewStyle;
	}
    //-----------------------------------------------//
	
	
	/**
	 * Adds the specified action listener to receive action events
	 * from this button.
	 * @param l the action listener
	 */ 
	public void addViewStyleChanged(ActionListener l) 
	{
		m_pListners.add(ActionListener.class,l);
	}

	/**
	 * Removes the specified action listener so it no longer receives
	 * action events from this button.
	 * @param l the action listener
	 */ 
	public void removeViewStyleChanged(ActionListener l) 
	{
		m_pListners.remove(ActionListener.class,l);
	}
	
	/**
	 * Raises DateChanged event.
	 *
	 */
	protected void RaiseViewStyleChanged()
	{
		Object[] listeners = m_pListners.getListenerList();
		// loop through each listener and pass on the event if needed		
		for(int i=0;i < listeners.length;i++){
			if(listeners[i] == ActionListener.class){
				// pass the event to the listeners event dispatch method
				((ActionListener)listeners[i+1]).actionPerformed(new ActionEvent(this,1,""));
			}            
		}
	}

}
