{***************************************************************************}
{ TMS IntraWeb Component Pack Pro                                           }
{ for Delphi & C++Builder                                                   }
{                                                                           }
{ written by TMS Software                                                   }
{            copyright © 2002 - 2007                                        }
{            Email : info@tmssoftware.com                                   }
{            Web : http://www.tmssoftware.com                               }
{                                                                           }
{ The source code is given as is. The author is not responsible             }
{ for any possible damage done due to the use of this code.                 }
{ The component can be freely used in any application. The complete         }
{ source code remains property of the author and may not be distributed,    }
{ published, given or sold in any form as such. No parts of the source      }
{ code can be included in any other component or application without        }
{ written authorization of the author.                                      }
{***************************************************************************}

unit IWTickerPanel;

interface

{$I TMSDEFS.INC}

uses
  {$IFDEF LINUX}
  QGraphics,
  {$ELSE}
  Windows, Graphics,
  {$ENDIF}
  {$IFDEF DELPHI6_LVL}
  Types,
  {$ENDIF}
  Classes,
  IWControl, IWAppForm, IWFont, IWHTMLTag, IWTMSBase, IWTypes
  {$IFDEF TMSIW51}
  ,IWColor
  {$ENDIF}
  {$IFDEF TMSIW6}
  , IWRenderContext
  {$ENDIF}
  ;

type
  IWTickerPanelState = (stExpanded, stCollapsed);
  TTIWTickerPanel = class(TIWControl)
  private
    FRotateTime: Integer;
    FLines: TStringList;
    FButtonWidth: Integer;
    FFont: TIWFont;
    FCaptionFont: TIWFont;
    FState: IWTickerPanelState;
    FButtonCollapsGlyph: TBitmap;
    FButtonCollapsGlyphURL: string;
    FButtonExpandGlyph: TBitmap;
    FButtonExpandGlyphURL: string;
    FBorderColor: TIWColor;
    FButtonColor: TIWColor;
    FCaptionColor: TIWColor;
    FShowButton: Boolean;
    procedure SetLines(const Value: TStringList);
    procedure SetRotateTime(const Value: Integer);
    procedure SetBorderColor(const Value: TIWColor);
    procedure SetButtonCollapsGlyph(const Value: TBitmap);
    procedure SetButtonColor(const Value: TIWColor);
    procedure SetButtonExpandGlyph(const Value: TBitmap);
    procedure SetButtonWidth(const Value: Integer);
    procedure SetCaptionFont(const Value: TIWFont);
    procedure SetFont(const Value: TIWFont);
    procedure SetState(const Value: IWTickerPanelState);
    procedure SetCaptionColor(const Value: TIWColor);
    procedure SetShowButton(const Value: Boolean);
  protected
    HeadStrings,BodyStrings:TStringList;
    function  AddName(s:array of string):string;
    {$IFDEF TMSIW6}
    procedure LoadStrings(AContext: TIWBaseComponentContext);
    {$ELSE}
    procedure LoadStrings;
    {$ENDIF}
    function BMPtoHTML(var bmp:TBitmap; var url:string):string;
    function HTMLClr(color: TIWColor): string;
  public
    {$IFDEF TMSIW6}
    procedure IWPaint; override;
    function RenderHTML(AContext: TIWBaseComponentContext): TIWHTMLTag; override;
    {$ELSE}
    procedure Paint; override;
    function RenderHTML: TIWHTMLTag; override;
    {$ENDIF}
    constructor Create(AOwner: TComponent); override;
    destructor Destroy;override;
  published
    property Lines:TStringList read FLines write SetLines;
    property RotateTime: Integer read FRotateTime write SetRotateTime;
    property CaptionColor: TIWColor read FCaptionColor write SetCaptionColor;
    property CaptionFont: TIWFont read FCaptionFont write SetCaptionFont;
    property BorderColor: TIWColor read FBorderColor write SetBorderColor;
    property ButtonColor: TIWColor read FButtonColor write SetButtonColor;
    property ButtonWidth: integer read FButtonWidth write SetButtonWidth;
    property ButtonExpandGlyph: TBitmap read FButtonExpandGlyph write SetButtonExpandGlyph;
    property ButtonExpandGlyphURL: string read FButtonExpandGlyphURL write FButtonExpandGlyphURL;
    property ButtonCollapsGlyph: TBitmap read FButtonCollapsGlyph write SetButtonCollapsGlyph;
    property ButtonCollapsGlyphURL: string read FButtonCollapsGlyphURL write FButtonCollapsGlyphURL;    
    property Font : TIWFont read FFont write SetFont;
    property State : IWTickerPanelState read FState write SetState;
    property ShowButton: Boolean read FShowButton write SetShowButton;
    property Color;
    property TabOrder;
  end;

  TTIWSmartPanel = class(TIWControl)
  private
    FLines: TStringList;
    FButtonWidth: integer;
    FFont: TIWFont;
    FCaptionFont: TIWFont;
    FState: IWTickerPanelState;
    FButtonCollapsGlyph: TBitmap;
    FButtonCollapsGlyphURL: string;
    FButtonExpandGlyph: TBitmap;
    FButtonExpandGlyphURL: string;
    FBorderColor: TIWColor;
    FCaptionExpandColor: TIWColor;
    FCaptionExpandFontColor: TIWColor;
    FCaptionCollapsColor: TIWColor;
    FCaptionCollapsFontColor: TIWColor;
    FButtonColor: TIWColor;
    FCaption: string;
    procedure SetLines(const Value: TStringList);
    procedure SetBorderColor(const Value: TIWColor);
    procedure SetButtonCollapsGlyph(const Value: TBitmap);
    procedure SetButtonColor(const Value: TIWColor);
    procedure SetButtonExpandGlyph(const Value: TBitmap);
    procedure SetButtonWidth(const Value: integer);
    procedure SetCaptionCollapsColor(const Value: TIWColor);
    procedure SetCaptionCollapsFontColor(const Value: TIWColor);
    procedure SetCaptionExpandColor(const Value: TIWColor);
    procedure SetCaptionExpandFontColor(const Value: TIWColor);
    procedure SetCaptionFont(const Value: TIWFont);
    procedure SetFont(const Value: TIWFont);
    procedure SetState(const Value: IWTickerPanelState);
    procedure SetCaption(const Value: string);
  protected
    HeadStrings,BodyStrings:TStringList;
    function  AddName(s:array of string):string;
    {$IFDEF TMSIW6}
    procedure LoadStrings(AContext: TIWBaseComponentContext);
    {$ELSE}
    procedure LoadStrings;
    {$ENDIF}
    function BMPtoHTML(var bmp:TBitmap; var url:string):string;
    function HTMLClr(color: TIWColor): string;
    procedure Submit(const AValue: string); override;
    procedure SetValue(const AValue: string); override;
  public
    {$IFDEF TMSIW6}
    procedure IWPaint; override;
    function RenderHTML(AContext: TIWBaseComponentContext): TIWHTMLTag; override;
    {$ELSE}
    procedure Paint; override;
    function RenderHTML: TIWHTMLTag; override;
    {$ENDIF}
    constructor Create(AOwner: TComponent); override;
    destructor  Destroy;override;
  published
    property Lines: TStringList read FLines write SetLines;
    property Caption: string read FCaption write SetCaption;
    property CaptionExpandColor: TIWColor read FCaptionExpandColor write SetCaptionExpandColor;
    property CaptionExpandFontColor: TIWColor read FCaptionExpandFontColor write SetCaptionExpandFontColor;
    property CaptionCollapsColor: TIWColor read FCaptionCollapsColor write SetCaptionCollapsColor;
    property CaptionCollapsFontColor: TIWColor read FCaptionCollapsFontColor write SetCaptionCollapsFontColor;
    property CaptionFont: TIWFont read FCaptionFont write SetCaptionFont;
    property BorderColor: TIWColor read FBorderColor write SetBorderColor;
    property ButtonColor: TIWColor read FButtonColor write SetButtonColor;
    property ButtonWidth: Integer read FButtonWidth write SetButtonWidth;
    property ButtonExpandGlyph: TBitmap read FButtonExpandGlyph write SetButtonExpandGlyph;
    property ButtonExpandGlyphURL: string read FButtonExpandGlyphURL write FButtonExpandGlyphURL;
    property ButtonCollapsGlyph: TBitmap read FButtonCollapsGlyph write SetButtonCollapsGlyph;
    property ButtonCollapsGlyphURL: string read FButtonCollapsGlyphURL write FButtonCollapsGlyphURL;
    property Font: TIWFont read FFont write SetFont;
    property State: IWTickerPanelState read FState write SetState;
    property Color;
    property TabOrder;
  end;


implementation

{$R tmsiwtp.res}

uses
  Sysutils,Math,IWServerControllerBase;


{ TTIWTickerPanel }

function TTIWTickerPanel.AddName(s:array of string): string;
var
  i:integer;
begin
  Result:='';
  for i := Low(s) to High(s) - 1 do
    Result := Result + s[i] + HTMLName;
  Result := Result +s[High(s)];
end;

function TTIWTickerPanel.BMPtoHTML(var bmp: TBitmap; var url:string): string;
var
  LPathname: string;
begin
  Result := '';

  if url <> EmptyStr then
  begin
    Result := '<IMG SRC="' + url + '" NAME="'+HTMLName+'image" ID="'+HTMLName+'image" BORDER="0">';
  end
  else if not bmp.Empty then
  begin
    {$IFDEF TMSIW71}
    LPathname := TIWServerControllerBase.NewCacheFile('bmp',true);
    {$ELSE}
    LPathname := TIWServerControllerBase.NewCacheFile('bmp');
    {$ENDIF}
    bmp.SaveToFile(LPathname);
    Result := '<IMG SRC="' + GetCacheDir(Self) + ExtractFilename(LPathname)+
              '" NAME="'+HTMLName+'image" ID="'+HTMLName+'image" BORDER="0">';
  end;
end;


constructor TTIWTickerPanel.Create(AOwner: TComponent);
begin
  inherited;
  FFont := TIWFont.Create;
  FCaptionFont := TIWFont.Create;
  FButtonCollapsGlyph := TBitmap.Create;
  FButtonExpandGlyph := TBitmap.Create;
  FLines := TStringList.Create;
  HeadStrings := TStringList.Create;
  BodyStrings := TStringList.Create;
  Height := 25;
  Width := 240;
  FButtonWidth := 32;
  FState := stCollapsed;
  Color := clWhite;
  FBorderColor := clBlack;
  FCaptionColor := clYellow;
  FButtonColor := clSilver;
  FRotateTime := 2000;
  ZIndex := 1;
  ShowButton := True;
  {$IFDEF TMSIW6}
  SetRenderSize(True);
  {$ELSE}
  FRenderSize := True;
  {$ENDIF}
end;

destructor TTIWTickerPanel.Destroy;
begin
  HeadStrings.Free;
  BodyStrings.Free;
  FLines.Free;
  FFont.Free;
  FCaptionFont.Free;
  FButtonCollapsGlyph.Free;
  FButtonExpandGlyph.Free;
  inherited;
end;

{$IFDEF TMSIW6}
procedure TTIWTickerPanel.LoadStrings(AContext: TIWBaseComponentContext);
{$ELSE}
procedure TTIWTickerPanel.LoadStrings;
{$ENDIF}
var
  i,tempwidth: Integer;
  tempS:string;
begin
  tempwidth := 0;
  if ShowButton then
  begin
    if (ButtonExpandGlyphURL <> EmptyStr) then
      tempwidth := FButtonWidth
    else if (FState = stExpanded) and (not FButtonCollapsGlyph.Empty) then
      tempwidth := FButtonCollapsGlyph.Width;

    if (ButtonCollapsGlyphURL <> EmptyStr) then
      tempwidth := FButtonWidth
    else if (FState = stCollapsed)and (not FButtonExpandGlyph.Empty) then
      tempwidth := FButtonExpandGlyph.Width

  end;

  HeadStrings.Clear;
  BodyStrings.Clear;
  HeadStrings.Add('<style>');
  HeadStrings.Add('<!--');
  HeadStrings.Add('');
  HeadStrings.Add(AddName(['#tpbtn','{']));
  HeadStrings.Add('position:relative;');
  HeadStrings.Add('border:0px solid #4B4B4B;');
  HeadStrings.Add('height:12px;');
  HeadStrings.Add('background-color:#'+HTMLClr(ButtonColor)+';');
  HeadStrings.Add('width:'+inttostr(tempwidth)+'px;');
  {$IFDEF TMSIW6}
  HeadStrings.Add(CaptionFont.FontToStringStyle(AContext.WebApplication.Browser));
  {$ELSE}
  HeadStrings.Add(CaptionFont.FontToStringStyle(WebApplication.Browser));
  {$ENDIF}

  HeadStrings.Add('text-align:center;');
  HeadStrings.Add('cursor:hand;');
  HeadStrings.Add('}');
  HeadStrings.Add('');
  HeadStrings.Add('.expandhighlight, .expandhighlight a{');
  HeadStrings.Add('color:red;');
  HeadStrings.Add('}');
  HeadStrings.Add('');
  HeadStrings.Add('-->');
  HeadStrings.Add('</style>');


  BodyStrings.Add('<script language="JavaScript1.2">');
  BodyStrings.Add('');
  BodyStrings.Add(AddName(['var tickercontents','=new Array()']));

  for i := FLines.Count-1 downto 0 do
    BodyStrings.Add(AddName(['tickercontents','['+inttostr(i)+']='#39+FLines.Strings[i]+#39]));

  BodyStrings.Add('');
  BodyStrings.Add(AddName(['var buttonwidth','='+inttostr(tempwidth)]));
  BodyStrings.Add(AddName(['var columnwidth','='+inttostr(Width-tempwidth)]));

  if FRotateTime = 0 then
    i := High(i)
  else
    i := FRotateTime;

  BodyStrings.Add(AddName(['var tickdelay','='+inttostr(i)]));
  BodyStrings.Add(AddName(['var tickerwidth','='+inttostr(Width)]));
  BodyStrings.Add(AddName(['var tickerbgcolor','='#39+HTMLClr(Color)+#39]));
  BodyStrings.Add(AddName(['var captionbgcolor','='#39+HTMLClr(FCaptionColor)+#39]));
  BodyStrings.Add(AddName(['var borderbgcolor','='#39+HTMLClr(FBorderColor)+#39]));
//  BodyStrings.Add(AddName(['var ie4','=document.all&&navigator.userAgent.indexOf("Opera")==-1']));
//  BodyStrings.Add(AddName(['var ns6','=document.getElementById&&navigator.userAgent.indexOf("Opera")==-1']));
  BodyStrings.Add(AddName(['var ie4','=document.all']));
  BodyStrings.Add(AddName(['var ns6','=document.getElementById']));

  BodyStrings.Add(AddName(['var ns4','=document.layers']));
  BodyStrings.Add('');
  BodyStrings.Add(AddName(['var currentmessage','=0']));
  BodyStrings.Add(AddName(['var tickercontentstotal','='#39#39]));
  BodyStrings.Add('');
  BodyStrings.Add(AddName(['function changetickercontent','(){']));
  BodyStrings.Add(AddName(['if (ns4','){']));
  BodyStrings.Add(AddName(['tickerobj','.document.tickernssub','.document.write('#39'<b><a href="#" onClick="return expandlist','(event)">Expand</a></b> | '#39'+tickercontents','[currentmessage','])']));
  BodyStrings.Add(AddName(['tickerobj','.document.tickernssub','.document.close()']));
  BodyStrings.Add('}');
  BodyStrings.Add(AddName(['else if (ie4','||ns6','){']));
  BodyStrings.Add(AddName(['tickerobj','.innerHTML=tickercontents','[currentmessage',']']));
  BodyStrings.Add(AddName(['previousmessage','=(currentmessage','==0)? tickercontents','.length-1 : currentmessage','-1']));
  BodyStrings.Add(AddName(['tickerexpand_item','=ns6','? document.getElementById("exp','"+currentmessage',') : eval("expand','"+currentmessage',')']));
  BodyStrings.Add(AddName(['tickerexpand_previousitem','=ns6','? document.getElementById("exp','"+previousmessage',') : eval("expand','"+previousmessage',')']));
  BodyStrings.Add(AddName(['tickerexpand_previousitem','.className=""']));
  BodyStrings.Add(AddName(['tickerexpand_item','.className="expandhighlight"']));
  BodyStrings.Add('}');
  BodyStrings.Add('');
  BodyStrings.Add(AddName(['currentmessage','=(currentmessage','==tickercontents','.length-1)? 0 : currentmessage','+1']));
  BodyStrings.Add(AddName(['setTimeout("changetickercontent','()",tickdelay',')']));
  BodyStrings.Add('}');
  BodyStrings.Add('');
  BodyStrings.Add(AddName(['function expandlist','(e){']));
  BodyStrings.Add(AddName(['if (ie4','||ns6','){']));
  BodyStrings.Add(AddName(['tickerexpand_parent','=ie4','? tckrexp','.parentElement : document.getElementById("tckrexp','").parentNode']));
  BodyStrings.Add(AddName(['tickerexpand_parent','.style.display=(tickerexpand_parent','.style.display=="none")? "" : "none"']));

  BodyStrings.Add(AddName(['if (tickerexpand_parent','.style.display == "none")']));
  BodyStrings.Add(AddName(['document.getElementById("tpbtn','").innerHTML = '#39+BMPtoHTML(FButtonCollapsGlyph,FButtonCollapsGlyphURL)+#39';']));
  BodyStrings.Add('else');
  BodyStrings.Add(AddName(['document.getElementById("tpbtn','").innerHTML = '#39+BMPtoHTML(FButtonExpandGlyph,FButtonExpandGlyphURL)+#39';']));


  BodyStrings.Add('}');
  BodyStrings.Add('else{');
  BodyStrings.Add(AddName(['document.expandlayer','.visibility=(document.expandlayer','.visibility=="hide")? "show" : "hide"']));
  BodyStrings.Add(AddName(['document.expandlayer','.left=e.pageX-e.layerX']));
  BodyStrings.Add(AddName(['document.expandlayer','.top= e.pageY-e.layerY+20']));
  BodyStrings.Add('}');


  BodyStrings.Add('return false');

  BodyStrings.Add('}');
  BodyStrings.Add('');
  BodyStrings.Add(AddName(['if (ie4','||ns6',')']));

  BodyStrings.Add( AddName(['document.write('#39'<table border="0" style="width:'#39'+tickerwidth','+'#39';border:1px solid #'+HTMLClr(FBorderColor)+';text-indent:2px" bgcolor="'#39'+tickerbgcolor','+' ]));
  {$IFDEF TMSIW6}
  BodyStrings.Add(AddName([ #39'" cellspacing="0" cellpadding="0"><tr><td style="'+StringReplace(FCaptionFont.FontToStringStyle(AContext.WebApplication.Browser),#39,'',[rfReplaceAll])+'" width='#39'+columnwidth','+'#39' id="tckrlst','" bgcolor="'#39'+captionbgcolor','+']));
  {$ELSE}
  BodyStrings.Add(AddName([ #39'" cellspacing="0" cellpadding="0"><tr><td style="'+StringReplace(FCaptionFont.FontToStringStyle(WebApplication.Browser),#39,'',[rfReplaceAll])+'" width='#39'+columnwidth','+'#39' id="tckrlst','" bgcolor="'#39'+captionbgcolor','+']));
  {$ENDIF}
  BodyStrings.Add(AddName([ #39'"></td><td width='#39'+buttonwidth','+'#39' bgcolor="'#39'+captionbgcolor','+']));

  temps := '';
  if ShowButton then
  begin
    if (FState=stCollapsed) and ((not FButtonCollapsGlyph.Empty) or (FButtonCollapsGlyphURL <> EmptyStr) ) then
        temps:=BMPtoHTML(FButtonCollapsGlyph, FButtonCollapsGlyphURL)
    else if (FState=stExpanded) and ((not FButtonExpandGlyph.Empty) or (FButtonExpandGlyphURL <> EmptyStr) ) then
        temps:=BMPtoHTML(FButtonExpandGlyph, FButtonExpandGlyphURL)
    else
        temps := 'Expand';
  end;

  {$IFDEF TMSIW6}
  BodyStrings.Add(AddName([ #39'"><div id="tpbtn','" onClick="expandlist','()">'+tempS+'</div></td></tr><tr style="display:none"><td id="tckrexp','" style="'+StringReplace(FFont.FontToStringStyle(AContext.WebApplication.Browser),#39,'',[rfReplaceAll])+'"  width='#39'+columnwidth','+'#39' bgcolor="'#39'+tickerbgcolor','+']));
  {$ELSE}
  BodyStrings.Add(AddName([ #39'"><div id="tpbtn','" onClick="expandlist','()">'+tempS+'</div></td></tr><tr style="display:none"><td id="tckrexp','" style="'+StringReplace(FFont.FontToStringStyle(WebApplication.Browser),#39,'',[rfReplaceAll])+'"  width='#39'+columnwidth','+'#39' bgcolor="'#39'+tickerbgcolor','+']));
  {$ENDIF}

  BodyStrings.Add(AddName([ #39'"> </td><td width='#39'+buttonwidth','+'#39'></td></tr></table>'#39')']));
  BodyStrings.Add('');
  BodyStrings.Add(AddName(['if (ns4',') document.tickernsmain','.visibility="show"']));
  BodyStrings.Add(AddName(['tickerobj','=ie4','? '+'tckrlst',' : ns6','? document.getElementById("tckrlst','") : ns4','? document.tickernsmain',' : ""']));
  BodyStrings.Add(AddName(['tickerexpandobj','=ie4','? tckrexp',' : ns6','? document.getElementById("tckrexp','") : ns4','? document.expandlayer',' : ""']));
  BodyStrings.Add('');
  BodyStrings.Add(AddName(['for (i=0;i<tickercontents','.length;i++)' ]));
  BodyStrings.Add(AddName(['tickercontentstotal','+='#39'<div style="position:relative" id="exp',''#39'+i+'#39'">- '#39'+tickercontents','[i]+'#39'</div>'#39]));
  BodyStrings.Add(AddName(['if (ie4','||ns6',')']));
  BodyStrings.Add(AddName(['tickerexpandobj','.innerHTML=tickercontentstotal','']));
  BodyStrings.Add('else{');
  BodyStrings.Add(AddName(['tickerexpandobj','.document.write(tickercontentstotal',')']));
  BodyStrings.Add(AddName(['tickerexpandobj','.document.close()']));
  BodyStrings.Add('}');
  BodyStrings.Add(AddName(['changetickercontent','()']));

//  if FState=stExpanded
//    then BodyStrings.Add(AddName(['expandlist','()']));

  BodyStrings.Add('</script>');
  BodyStrings.Add('');

  BodyStrings.Add(AddName(['<ilayer id="tckrmain','" width=&{tickerwidth','}; bgColor=&{tickerbgcolor','}; visibility=hide><layer id="tckrsub','" width=&{tickerwidth','}; left=0 top=0></layer></ilayer>']));
  BodyStrings.Add(AddName(['<layer id="explyr','" bgColor=&{tickerbgcolor','}; visibility=hide></layer>']));
end;

{$IFDEF TMSIW6}
procedure TTIWTickerPanel.IWPaint;
{$ELSE}
procedure TTIWTickerPanel.Paint;
{$ENDIF}
var
  i,bw: Integer;
begin
  if FState = stExpanded then
    SetBounds(Left,Top,Width,(FLines.Count*20+22))
  else
    SetBounds(Left,Top,Width,22);

  if Font.FontName <> '' then
    Canvas.Font.Name := Font.FontName;

  Canvas.Font.Size := 10;

  Canvas.Font.Style := Font.Style;

  Canvas.Brush.Color := Color;
  Canvas.Pen.Color := FBorderColor;
  Canvas.Rectangle(0,0, Width,Height);
  Canvas.Brush.Color := FCaptionColor;
  Canvas.Pen.Color := FCaptionColor;
  Canvas.Rectangle(1,1, Width - 1,21);

  if not ShowButton then
    bw := 0
  else
    bw := ButtonWidth;

  if (FState = stExpanded) and not FButtonCollapsGlyph.Empty then
    Canvas.Draw(Width-FButtonCollapsGlyph.Width,1,FButtonCollapsGlyph)
  else
    if (FState = stCollapsed)and not FButtonExpandGlyph.Empty then
      Canvas.Draw(Width-FButtonExpandGlyph.Width,1,FButtonExpandGlyph)
    else
    begin
      Canvas.Brush.Color := ButtonColor;
      Canvas.Pen.Color := clBlack;
      Canvas.Font.Height := 10;
      Canvas.Font.Color := clBlack;
      Canvas.Rectangle(Width-bw,1, Width-1,20);
      Canvas.TextOut(Width-bw+5,3,'Expand');
    end;

  Canvas.Brush.Color := FCaptionColor;
  Canvas.Font.Color := CaptionFont.Color;
  if Lines.Count < 1  then Exit;

  Canvas.TextOut(1,2,FLines.Strings[0]);
  Canvas.Brush.Color := Color;
  Canvas.Font.Color := Font.Color;
  if FState = stExpanded  then
    for i := 0 to FLines.Count - 1 do
      Canvas.TextOut(1,22+i*20,'-'+FLines.Strings[i]);
end;

{$IFDEF TMSIW6}
function TTIWTickerPanel.RenderHTML(AContext: TIWBaseComponentContext): TIWHTMLTag;
{$ELSE}
function TTIWTickerPanel.RenderHTML: TIWHTMLTag;
{$ENDIF}
var
  htmlres: string;
begin
  htmlres := '';

  {$IFDEF TMSIW6}
  if not (State = stCollapsed) then
    TIWComponent40Context(AContext).AddToInitProc('expandlist'+HTMLName+'();');
  {$ELSE}
  if not (State = stCollapsed) then
    TIWAppForm(Form).AddToInitProc('expandlist'+HTMLName+'();');
  {$ENDIF}

  if FLines.Count > 0 then
  begin
    {$IFDEF TMSIW6}
    LoadStrings(AContext);

    TIWPageContext40(AContext.PageContext).ExtraHeader.AddStrings(HeadStrings);

    {$ELSE}
    LoadStrings;
    if Parent is TIWAppForm then
      (Parent as TIWAppForm).ExtraHeader.AddStrings(HeadStrings);
    {$ENDIF}

    htmlres := BodyStrings.Text;
  end;

  Result := TIWHTMLTag.CreateTag('DIV');
  Result.Contents.AddText(htmlres);
end;


procedure TTIWTickerPanel.SetBorderColor(const Value: TIWColor);
begin
  FBorderColor := Value;
  Invalidate;
end;

procedure TTIWTickerPanel.SetButtonCollapsGlyph(const Value: TBitmap);
begin
  FButtonCollapsGlyph.Assign(Value);
  Invalidate;
end;

procedure TTIWTickerPanel.SetButtonColor(const Value: TIWColor);
begin
  FButtonColor := Value;
  Invalidate;
end;

procedure TTIWTickerPanel.SetButtonExpandGlyph(const Value: TBitmap);
begin
  FButtonExpandGlyph.Assign(Value);
  Invalidate;
end;

procedure TTIWTickerPanel.SetShowButton(const Value: Boolean);
begin
  FShowButton := Value;
  Invalidate;
end;

procedure TTIWTickerPanel.SetButtonWidth(const Value: integer);
begin
  FButtonWidth := Value;
  Invalidate;
end;

procedure TTIWTickerPanel.SetCaptionColor(const Value: TIWColor);
begin
  FCaptionColor := Value;
  Invalidate;
end;

procedure TTIWTickerPanel.SetCaptionFont(const Value: TIWFont);
begin
  FCaptionFont.Assign(Value);
  Invalidate;
end;

procedure TTIWTickerPanel.SetFont(const Value: TIWFont);
begin
  FFont.Assign(Value);
  Invalidate;
end;

procedure TTIWTickerPanel.SetLines(const Value: TStringList);
begin
  FLines.Assign(Value);
  Invalidate;
end;

procedure TTIWTickerPanel.SetRotateTime(const Value: integer);
begin
  if value >= 0 then
  FRotateTime := Value;
end;

procedure TTIWTickerPanel.SetState(const Value: IWTickerPanelState);
begin
  if FState <> Value  then
  begin
    FState := Value;
    Invalidate;
  end;
end;

function TTIWTickerPanel.HTMLClr(color: TIWColor):string;
begin
  Result := ColorToRGBString(color);
end;


{ TTIWSmartPanel }

 function TTIWSmartPanel.AddName(s:array of string): string;
var
  i: Integer;
begin
  Result := '';
  for i := Low(s) to High(s) - 1 do
    Result := Result + s[i] + HTMLName;
  Result := Result + s[High(s)];
end;

function TTIWSmartPanel.BMPtoHTML(var bmp: TBitmap; var url: string): string;
var
  LPathname: string;
begin
  Result := '';

  if url <> EmptyStr then
  begin
     Result := '<IMG SRC="' + url + '" NAME="image" BORDER="0">';
  end
  else if not bmp.Empty then
   begin
     {$IFDEF TMSIW71}
     LPathname := TIWServerControllerBase.NewCacheFile('bmp',true);
     {$ELSE}
     LPathname := TIWServerControllerBase.NewCacheFile('bmp');
     {$ENDIF}
     bmp.SaveToFile(LPathname);

     Result := '<IMG SRC="' + GetCacheDir(Self) + ExtractFilename(LPathname)+
               '" NAME="image" BORDER="0">';
   end;
end;


constructor TTIWSmartPanel.Create(AOwner: TComponent);
begin
  inherited;
  FFont := TIWFont.Create;
  FCaptionFont := TIWFont.Create;
  FCaptionFont.Color := clWhite;
  FButtonCollapsGlyph := TBitmap.Create;
  FButtonExpandGlyph := TBitmap.Create;
  if (csDesigning in ComponentState) then
  begin
    FButtonCollapsGlyph.LoadFromResourceName(hInstance,'IWSPUP');
    FButtonExpandGlyph.LoadFromResourceName(hInstance,'IWSPDWN');
  end;

  FLines := TStringList.Create;
  HeadStrings := TStringList.Create;
  BodyStrings := TStringList.Create;
  Height := 25;
  Width := 240;
  FButtonWidth := 50;
  FState := stCollapsed;
  Color := clWhite;
  FBorderColor := clBlack;
  FCaptionExpandColor := clSilver;
  FCaptionExpandFontColor := clBlack;

  FCaptionCollapsColor := $00DF9D79;
  FCaptionCollapsFontColor := clWhite;

  FButtonColor := clSilver;
  ZIndex := 1;

  {$IFDEF TMSIW6}
  SetRenderSize(True);
  {TODO}
  {$ELSE}
  FSupportsInput := True;
  FSupportsSubmit := True;
  FRenderSize := True;
  {$ENDIF}
end;

destructor TTIWSmartPanel.Destroy;
begin
  HeadStrings.Free;
  BodyStrings.Free;
  FLines.Free;
  FFont.Free;
  FCaptionFont.Free;
  FButtonCollapsGlyph.Free;
  FButtonExpandGlyph.Free;
  inherited;
end;

//Added Tine//
function JSAdapt(s:string):string;
var
  i: integer;
begin
  Result := '';
  for i := 1 to length(s) do
  begin
    if s[i] = #39 then
      Result := Result + '\'#39
    else if s[i] = '"' then
           Result := Result + '\"'
         else
           Result := Result + s[i];
  end;
end;
//End Added//

{$IFDEF TMSIW6}
procedure TTIWSmartPanel.LoadStrings(AContext: TIWBaseComponentContext);
{$ELSE}
procedure TTIWSmartPanel.LoadStrings;
{$ENDIF}
var
  i,tempwidth: Integer;
  tempS:string;
begin

  if (ButtonCollapsGlyphURL <> EmptyStr) or (ButtonExpandGlyphURL <> EmptyStr) then
    TempWidth := FButtonWidth
  else if (FState = stExpanded) and not FButtonCollapsGlyph.Empty then
    TempWidth := FButtonCollapsGlyph.Width
  else
    if (FState = stCollapsed)and not FButtonExpandGlyph.Empty then
      TempWidth := FButtonExpandGlyph.Width
    else
      TempWidth := FButtonWidth;

  HeadStrings.Clear;
  BodyStrings.Clear;
  HeadStrings.Add('<style>');
  HeadStrings.Add('<!--');
  HeadStrings.Add('');
  HeadStrings.Add(AddName(['#lstbtn','{']));
  HeadStrings.Add('position:relative;');
  HeadStrings.Add('border:0px solid #4B4B4B;');
  HeadStrings.Add('height:12px;');
  HeadStrings.Add('background-color:#'+HTMLClr(ButtonColor)+';');
  HeadStrings.Add('width:'+IntToStr(Tempwidth)+'px;');
  {$IFDEF TMSIW6}
  HeadStrings.Add(CaptionFont.FontToStringStyle(AContext.WebApplication.Browser));
  {$ELSE}
  HeadStrings.Add(CaptionFont.FontToStringStyle(WebApplication.Browser));
  {$ENDIF}
  HeadStrings.Add('text-align:center;');
  HeadStrings.Add('cursor:pointer;cursor:hand;');
  HeadStrings.Add('}');
  HeadStrings.Add('');
  HeadStrings.Add('.expandhighlight, .expandhighlight a{');
  HeadStrings.Add('color:red;');
  HeadStrings.Add('}');
  HeadStrings.Add('');
  HeadStrings.Add('-->');
  HeadStrings.Add('</style>');

  BodyStrings.Add('<script language="JavaScript1.2">');
  BodyStrings.Add('');
  BodyStrings.Add(AddName(['var tickercontents','=new Array()']));

//Added Tine//
  for i := FLines.Count - 1 downto 0 do
  begin
//    BodyStrings.Add(AddName(['tickercontents','['+IntToStr(i)+']='#39+FLines.Strings[i]+'<BR>'#39]));
    BodyStrings.Add(AddName(['tickercontents','['+IntToStr(i)+']='#39+JSAdapt(Lines.Strings[i])+'<BR>'#39]));
  end;
{
  for i := FLines.Count - 1 downto 0 do
    BodyStrings.Add(AddName(['tickercontents','['+IntToStr(i)+']='#39+FLines.Strings[i]+'<BR>'#39]));
}
//End Added//

  BodyStrings.Add('');
  BodyStrings.Add(AddName(['var buttonwidth','='+IntToStr(Tempwidth)]));
  BodyStrings.Add(AddName(['var columnwidth','='+IntToStr(Width-Tempwidth)]));

  BodyStrings.Add(AddName(['var tickerwidth','='+IntToStr(Width)]));
  BodyStrings.Add(AddName(['var tickerbgcolor','='#39+HTMLClr(Color)+#39]));
  BodyStrings.Add(AddName(['var captionbgcolor','='#39+HTMLClr(FCaptionExpandColor)+#39]));
  BodyStrings.Add(AddName(['var borderbgcolor','='#39+HTMLClr(FBorderColor)+#39]));
  BodyStrings.Add(AddName(['var buttonbgcolor','='#39+HTMLClr(FButtonColor)+#39]));
//  BodyStrings.Add(AddName(['var ie4','=document.all&&navigator.userAgent.indexOf("Opera")==-1']));
//  BodyStrings.Add(AddName(['var ns6','=document.getElementById&&navigator.userAgent.indexOf("Opera")==-1']));
  BodyStrings.Add(AddName(['var ie4','=document.all']));
  BodyStrings.Add(AddName(['var ns6','=document.getElementById']));

  BodyStrings.Add(AddName(['var ns4','=document.layers']));
  BodyStrings.Add('');
  BodyStrings.Add(AddName(['var currentmessage','=0']));
  BodyStrings.Add(AddName(['var tickercontentstotal','='#39#39]));
  BodyStrings.Add('');
  BodyStrings.Add(AddName(['function expandlist','(e){']));
  BodyStrings.Add(AddName(['if (ie4','||ns6','){']));
  BodyStrings.Add(AddName(['tickerexpand_parent','=ie4','? tckrexp','.parentElement : document.getElementById("tckrexp','").parentNode']));
  BodyStrings.Add(AddName(['tickerexpand_parent','.style.display=(tickerexpand_parent','.style.display=="none")? "" : "none"']));
  BodyStrings.Add(AddName(['if (tickerexpand_parent','.style.display == "none") {']));
  BodyStrings.Add(AddName(['document.getElementById("lstbtn','").innerHTML='#39+BMPtoHTML(FButtonExpandGlyph,FButtonExpandGlyphURL)+#39';']));
  BodyStrings.Add(AddName(['document.getElementById("tckrlst','").style.color = '#39+HTMLClr(FCaptionExpandFontColor)+#39';']));
  BodyStrings.Add(AddName(['document.getElementById("lstbtn','").style.backgroundColor = '#39+HTMLClr(FCaptionExpandColor)+#39';']));
  BodyStrings.Add(AddName(['document.getElementById("tckrlst','").style.backgroundColor = '#39+HTMLClr(FCaptionExpandColor)+#39';']));
  BodyStrings.Add(AddName(['FindElem("','").value = "COLLAPS"; }']));
  BodyStrings.Add('else {');
  BodyStrings.Add(AddName(['document.getElementById("lstbtn','").innerHTML='#39+BMPtoHTML(FButtonCollapsGlyph,FButtonCollapsGlyphURL)+#39';']));
  BodyStrings.Add(AddName(['document.getElementById("tckrlst','").style.color = '#39+HTMLClr(FCaptionCollapsFontColor)+#39';']));
  BodyStrings.Add(AddName(['document.getElementById("lstbtn','").style.backgroundColor = '#39+HTMLClr(FCaptionCollapsColor)+#39';']));
  BodyStrings.Add(AddName(['document.getElementById("tckrlst','").style.backgroundColor = '#39+HTMLClr(FCaptionCollapsColor)+#39';']));
  BodyStrings.Add(AddName(['FindElem("','").value = "EXPAND"; }']));
  BodyStrings.Add('}');
  BodyStrings.Add('else{');
  BodyStrings.Add(AddName(['document.expandlayer','.left = e.pageX-e.layerX']));
  BodyStrings.Add(AddName(['document.expandlayer','.top = e.pageY-e.layerY']));

  BodyStrings.Add(AddName(['document.expandlayer','.visibility=(document.expandlayer','.visibility=="hide")? "show" : "hide";']));
  BodyStrings.Add(AddName(['if (document.expandlayer','.visibility == "hide") {']));
  BodyStrings.Add(AddName(['document.getElementById("lstbtn','").innerHTML = '#39+BMPtoHTML(FButtonCollapsGlyph,FButtonCollapsGlyphURL)+#39';']));
  BodyStrings.Add(AddName(['document.getElementById("tckrlst','").style.color = '#39+HTMLClr(FCaptionCollapsFontColor)+#39';']));
  BodyStrings.Add(AddName(['document.getElementById("lstbtn','").style.backgroundColor = '#39+HTMLClr(FCaptionCollapsColor)+#39';']));
  BodyStrings.Add(AddName(['document.getElementById("tckrlst','").style.backgroundColor = '#39+HTMLClr(FCaptionCollapsColor)+#39'; }']));
  BodyStrings.Add('else {');
  BodyStrings.Add(AddName(['document.getElementById("lstbtn','").innerHTML = '#39+BMPtoHTML(FButtonExpandGlyph,FButtonExpandGlyphURL)+#39';']));
  BodyStrings.Add(AddName(['document.getElementById("tckrlst','").style.color = '#39+HTMLClr(FCaptionExpandFontColor)+#39'; ']));
  BodyStrings.Add(AddName(['document.getElementById("lstbtn','").style.backgroundColor = '#39+HTMLClr(FCaptionExpandColor)+#39';']));  
  BodyStrings.Add(AddName(['document.getElementById("tckrlst','").style.backgroundColor = '#39+HTMLClr(FCaptionExpandColor)+#39'; }']));
  BodyStrings.Add('return false');
  BodyStrings.Add('}');
  BodyStrings.Add('}');
  BodyStrings.Add('');
  BodyStrings.Add(AddName(['if (ie4','||ns6',')']));

  BodyStrings.Add( AddName(['document.write('#39'<table border="0" style="width:'#39'+tickerwidth','+'#39';border:1px solid '+HTMLClr(FBorderColor)+';text-indent:2px" bgcolor="'#39'+tickerbgcolor','+' ]));
  {$IFDEF TMSIW6}
  BodyStrings.Add(AddName([ #39'" cellspacing="0" cellpadding="0" border="0"><tr><td style="'+StringReplace(FCaptionFont.FontToStringStyle(AContext.WebApplication.Browser),#39,'',[rfReplaceAll])+'"; width='#39'+columnwidth','+'#39' id="tckrlst','" bgcolor="'#39'+captionbgcolor','+']));
  {$ELSE}
  BodyStrings.Add(AddName([ #39'" cellspacing="0" cellpadding="0" border="0"><tr><td style="'+StringReplace(FCaptionFont.FontToStringStyle(WebApplication.Browser),#39,'',[rfReplaceAll])+'"; width='#39'+columnwidth','+'#39' id="tckrlst','" bgcolor="'#39'+captionbgcolor','+']));
  {$ENDIF}
  BodyStrings.Add(AddName([ #39'">'+FCaption+'</td><td id="btn','" width='#39'+buttonwidth','+'#39' bgcolor="'#39'+captionbgcolor','+']));

  if (FState = stCollapsed) and (not FButtonExpandGlyph.Empty or (FButtonExpandGlyphURL <> EmptyStr) ) then
    temps := BMPtoHTML(FButtonExpandGlyph,FButtonExpandGlyphURL)
  else
    temps := 'Expand';

  {$IFDEF TMSIW6}
  BodyStrings.Add(AddName([ #39'"><div id="lstbtn','" onClick="expandlist','()">'+tempS+'</div></td></tr><tr style="display:none"><td colspan=2 id="tckrexp','"style="'+StringReplace(FFont.FontToStringStyle(AContext.WebApplication.Browser),#39,'',[rfReplaceAll])+'"  width='#39'+columnwidth','+'#39' bgcolor="'#39'+tickerbgcolor','+']));
  {$ELSE}
  BodyStrings.Add(AddName([ #39'"><div id="lstbtn','" onClick="expandlist','()">'+tempS+'</div></td></tr><tr style="display:none"><td colspan=2 id="tckrexp','"style="'+StringReplace(FFont.FontToStringStyle(WebApplication.Browser),#39,'',[rfReplaceAll])+'"  width='#39'+columnwidth','+'#39' bgcolor="'#39'+tickerbgcolor','+']));
  {$ENDIF}
  BodyStrings.Add(AddName([ #39'"> </td></tr></table>'#39')']));
  BodyStrings.Add('');
  BodyStrings.Add(AddName(['if (ns4',') document.tckrmain','.visibility="show"']));
  BodyStrings.Add(AddName(['tickerobj','=ie4','? tckrlst',' : ns6','? document.getElementById("tckrlst','") : ns4','? document.tckrmain',' : ""']));
  BodyStrings.Add(AddName(['tickerexpandobj','=ie4','? tckrexp',' : ns6','? document.getElementById("tckrexp','") : ns4','? document.explyr',' : ""']));
  BodyStrings.Add('');
  BodyStrings.Add(AddName(['for (i=0;i<tickercontents','.length;i++)' ]));
  BodyStrings.Add(AddName(['tickercontentstotal','+=tickercontents','[i];']));

  BodyStrings.Add(AddName(['if (ie4','||ns6',')']));
  BodyStrings.Add(AddName(['tickerexpandobj','.innerHTML=tickercontentstotal','']));
  BodyStrings.Add('else{');
  BodyStrings.Add(AddName(['tickerexpandobj','.document.write(tickercontentstotal',')']));
  BodyStrings.Add(AddName(['tickerexpandobj','.document.close()']));
  BodyStrings.Add('}');

//  if FState = stExpanded then
//    BodyStrings.Add(AddName(['expandlist','()']));


  BodyStrings.Add('</script>');
  BodyStrings.Add('');

  BodyStrings.Add(AddName(['<ilayer id="tckrmain','" width=&{tickerwidth','}; bgColor=&{tickerbgcolor','}; visibility=hide><layer id="tckrsub','" width=&{tickerwidth','}; left=0 top=0></layer></ilayer>']));
  BodyStrings.Add(AddName(['<layer id="explyr','" bgColor=&{tickerbgcolor','}; visibility=hide></layer>']));
end;

procedure TTIWSmartPanel.SetValue(const AValue: string);
begin
  inherited;
  if AValue = 'COLLAPS' then
  begin
    State := stCollapsed
  end;

  if AValue = 'EXPAND' then
  begin
    State := stExpanded
  end;
end;

procedure TTIWSmartPanel.Submit(const AValue: string);
begin
  inherited;
  if AValue = 'COLLAPS' then
  begin
    State := stCollapsed
  end;

  if AValue = 'EXPAND' then
  begin
    State := stExpanded
  end;
end;


{$IFDEF TMSIW6}
procedure TTIWSmartPanel.IWPaint;
{$ELSE}
procedure TTIWSmartPanel.Paint;
{$ENDIF}
var
  i: Integer;
begin
  if FState = stExpanded then
    SetBounds(Left,Top,Width,(FLines.Count*20+22))
  else
    SetBounds(Left,Top,Width,22);

  inherited;

  if Font.FontName <> '' then
    Canvas.Font.Name := CaptionFont.FontName;

  Canvas.Font.Size := CaptionFont.Size;

  Canvas.Font.Style := CaptionFont.Style;
  

  Canvas.Brush.Color := Color;
  Canvas.Pen.Color := FBorderColor;
  Canvas.Rectangle(0,0, Width,Height);

  if State = stCollapsed then
  begin
    Canvas.Brush.Color := FCaptionExpandColor;
    Canvas.Pen.Color := FCaptionExpandColor;
    Canvas.Font.Color := CaptionExpandFontColor;
  end
  else
  begin
    Canvas.Brush.Color := FCaptionCollapsColor;
    Canvas.Pen.Color := FCaptionCollapsColor;
    Canvas.Font.Color := CaptionCollapsFontColor;    
  end;


  Canvas.Rectangle(1,1, Width-1,21);

  Canvas.TextOut(1,2,FCaption);

  if (FState = stExpanded) and not FButtonCollapsGlyph.Empty then
    Canvas.Draw(Width-FButtonCollapsGlyph.Width,1,FButtonCollapsGlyph)
  else
    if (FState=stCollapsed) and not FButtonExpandGlyph.Empty then
      Canvas.Draw(Width-FButtonExpandGlyph.Width,1,FButtonExpandGlyph)
    else
    begin
      Canvas.Brush.Color := ButtonColor;
      Canvas.Pen.Color := clBlack;
      Canvas.Font.Height := 10;
      Canvas.Font.Color := clBlack;
      Canvas.Rectangle(Width - ButtonWidth,1, Width - 1,20);
      Canvas.TextOut(Width - ButtonWidth+5,3,'Expand');
    end;

  Canvas.Brush.Color := CaptionExpandColor;


  Canvas.Brush.Color := Color;
  Canvas.Font.Color := Font.Color;
  if FState = stExpanded  then
    for i := 0 to FLines.Count - 1 do
      Canvas.TextOut(1,22+i*20,FLines.Strings[i]);
end;

{$IFDEF TMSIW6}
function TTIWSmartPanel.RenderHTML(AContext: TIWBaseComponentContext): TIWHTMLTag;
{$ELSE}
function TTIWSmartPanel.RenderHTML: TIWHTMLTag;
{$ENDIF}
var
  htmlres: string;
begin
  {$IFDEF TMSIW6}
  if State = stCollapsed then
    TIWComponent40Context(AContext).AddToInitProc('FindElem(''' + HTMLName + ''').value="COLLAPS";')
  else
  begin
    TIWComponent40Context(AContext).AddToInitProc('FindElem(''' + HTMLName + ''').value="EXPAND";');

    TIWComponent40Context(AContext).AddToInitProc('expandlist'+HTMLName+'();');
  end;
  {$ELSE}
  if State = stCollapsed then
    TIWAppForm(Form).AddToInitProc('FindElem(''' + HTMLName + ''').value="COLLAPS";')
  else
  begin
    TIWAppForm(Form).AddToInitProc('FindElem(''' + HTMLName + ''').value="EXPAND";');
    TIWAppForm(Form).AddToInitProc('expandlist'+HTMLName+'();');
  end;
  {$ENDIF}

  htmlres := '';

  {$IFDEF TMSIW6}
  LoadStrings(AContext);
  {TODO}
  {$ELSE}
  LoadStrings;
  if Parent is TIWAppForm then
    (Parent as TIWAppForm).ExtraHeader.AddStrings(HeadStrings);
  {$ENDIF}
    
  htmlres := BodyStrings.Text;
  
  Result := TIWHTMLTag.CreateTag('DIV');
  Result.Contents.AddText(htmlres);
  with Result.Contents.AddTag('INPUT') do
  begin
    AddStringParam('TYPE','hidden');
    AddStringParam('NAME',HTMLName);
    AddStringParam('ID',HTMLName+'_INPUT');
  end;
end;


procedure TTIWSmartPanel.SetBorderColor(const Value: TIWColor);
begin
  FBorderColor := Value;
  Invalidate;
end;

procedure TTIWSmartPanel.SetButtonCollapsGlyph(const Value: TBitmap);
begin
  FButtonCollapsGlyph.Assign(Value);
  Invalidate;
end;

procedure TTIWSmartPanel.SetButtonColor(const Value: TIWColor);
begin
  FButtonColor := Value;
  Invalidate;
end;

procedure TTIWSmartPanel.SetButtonExpandGlyph(const Value: TBitmap);
begin
  FButtonExpandGlyph.Assign(Value);
  Invalidate;
end;

procedure TTIWSmartPanel.SetButtonWidth(const Value: integer);
begin
  FButtonWidth := Value;
  Invalidate;
end;

procedure TTIWSmartPanel.SetCaptionCollapsFontColor(const Value: TIWColor);
begin
  FCaptionCollapsFontColor := Value;
  Invalidate;
end;


procedure TTIWSmartPanel.SetCaptionExpandFontColor(const Value: TIWColor);
begin
  FCaptionExpandFontColor := Value;
  Invalidate;
end;

procedure TTIWSmartPanel.SetCaptionCollapsColor(const Value: TIWColor);
begin
  FCaptionCollapsColor := Value;
  Invalidate;
end;

procedure TTIWSmartPanel.SetCaptionExpandColor(const Value: TIWColor);
begin
  FCaptionExpandColor := Value;
  Invalidate;
end;

procedure TTIWSmartPanel.SetCaptionFont(const Value: TIWFont);
begin
  FCaptionFont.Assign(Value);
  Invalidate;
end;

procedure TTIWSmartPanel.SetFont(const Value: TIWFont);
begin
  FFont.Assign(Value);
  Invalidate;
end;

procedure TTIWSmartPanel.SetLines(const Value: TStringList);
begin
  FLines.Assign(Value);
  Invalidate;
end;

procedure TTIWSmartPanel.SetState(const Value: IWTickerPanelState);
begin
  if FState <> Value  then
  begin
    FState := Value;

    Invalidate;
  end;
end;

procedure TTIWSmartPanel.SetCaption(const Value: string);
begin
  FCaption := Value;
  Invalidate;
end;

function TTIWSmartPanel.HTMLClr(color: TIWColor):string;
begin
  Result := ColorToRGBString(Color);
end;



end.


