mirror of
				https://gitlab.com/freepascal.org/lazarus/lazarus.git
				synced 2025-10-31 09:02:05 +01:00 
			
		
		
		
	tpipro: use TR bg and fg color assigned from css, render table caption
git-svn-id: trunk@22561 -
This commit is contained in:
		
							parent
							
								
									43524639c2
								
							
						
					
					
						commit
						c5101d39fc
					
				| @ -2139,10 +2139,13 @@ type | |||||||
| 
 | 
 | ||||||
|   TIpHtmlVAlignment2 = (hva2Top, hva2Bottom, hva2Left, hva2Right); |   TIpHtmlVAlignment2 = (hva2Top, hva2Bottom, hva2Left, hva2Right); | ||||||
| 
 | 
 | ||||||
|  |   { TIpHtmlNodeCAPTION } | ||||||
|  | 
 | ||||||
|   TIpHtmlNodeCAPTION = class(TIpHtmlNodeBlock) |   TIpHtmlNodeCAPTION = class(TIpHtmlNodeBlock) | ||||||
|   private |   private | ||||||
|     FAlign: TIpHtmlVAlignment2; |     FAlign: TIpHtmlVAlignment2; | ||||||
|   public                                                   {!!.10} |   public                                                   {!!.10} | ||||||
|  |     constructor Create(ParentNode: TIpHtmlNode); | ||||||
|     property Align : TIpHtmlVAlignment2 read FAlign write FAlign; |     property Align : TIpHtmlVAlignment2 read FAlign write FAlign; | ||||||
|   end; |   end; | ||||||
| 
 | 
 | ||||||
| @ -2324,10 +2327,14 @@ type | |||||||
|     property Width : TIpHtmlMultiLength read FWidth write FWidth; |     property Width : TIpHtmlMultiLength read FWidth write FWidth; | ||||||
|   end; |   end; | ||||||
| 
 | 
 | ||||||
|   TIpHtmlNodeTR = class(TIpHtmlNodeCore) |   { TIpHtmlNodeTR } | ||||||
|  | 
 | ||||||
|  |   TIpHtmlNodeTR = class(TIpHtmlNodeBlock) | ||||||
|   private |   private | ||||||
|     FAlign: TIpHtmlAlign; |     FAlign: TIpHtmlAlign; | ||||||
|     FVAlign: TIpHtmlVAlign; |     FVAlign: TIpHtmlVAlign; | ||||||
|  |   protected | ||||||
|  |     procedure SetProps(const RenderProps: TIpHtmlProps); override; | ||||||
|   public |   public | ||||||
|     constructor Create(ParentNode : TIpHtmlNode); |     constructor Create(ParentNode : TIpHtmlNode); | ||||||
|     property Align : TIpHtmlAlign read FAlign write FAlign; |     property Align : TIpHtmlAlign read FAlign write FAlign; | ||||||
| @ -2353,6 +2360,7 @@ type | |||||||
|     FPadRect : TRect; |     FPadRect : TRect; | ||||||
|     procedure Render(const RenderProps: TIpHtmlProps); override; |     procedure Render(const RenderProps: TIpHtmlProps); override; | ||||||
|     procedure Layout(const RenderProps: TIpHtmlProps; const TargetRect : TRect); override; |     procedure Layout(const RenderProps: TIpHtmlProps; const TargetRect : TRect); override; | ||||||
|  |     procedure SetProps(const RenderProps: TIpHtmlProps); override; | ||||||
|     procedure CalcMinMaxWidth(const RenderProps: TIpHtmlProps; |     procedure CalcMinMaxWidth(const RenderProps: TIpHtmlProps; | ||||||
|       var Min, Max: Integer); override; |       var Min, Max: Integer); override; | ||||||
|     property PadRect : TRect read FPadRect; |     property PadRect : TRect read FPadRect; | ||||||
| @ -7176,6 +7184,9 @@ procedure TIpHtml.ParseTableRows(Parent: TIpHtmlNode; | |||||||
| 
 | 
 | ||||||
| var | var | ||||||
|   CurRow : TIpHtmlNodeTR; |   CurRow : TIpHtmlNodeTR; | ||||||
|  |   {$IFDEF IP_LAZARUS} | ||||||
|  |   Element: TCSSProps = nil; | ||||||
|  |   {$ENDIF} | ||||||
| begin | begin | ||||||
|   CurRow := nil;                                                       {!!.12} |   CurRow := nil;                                                       {!!.12} | ||||||
|   while not (CurToken in EndTokens) do |   while not (CurToken in EndTokens) do | ||||||
| @ -7188,6 +7199,7 @@ begin | |||||||
|           CurRow.ParseBaseProps(Self); |           CurRow.ParseBaseProps(Self); | ||||||
|           CurRow.Align := ParseAlignment; |           CurRow.Align := ParseAlignment; | ||||||
|           CurRow.VAlign := ParseVAlignment; |           CurRow.VAlign := ParseVAlignment; | ||||||
|  |           CurRow.LoadCSSProps(CurRow.Owner, Element, CurRow.Props); | ||||||
|           NextRealToken; |           NextRealToken; | ||||||
|           ParseTableRow(CurRow, |           ParseTableRow(CurRow, | ||||||
|                         EndTokens + [IpHtmlTagTRend, IpHtmlTagTR] - |                         EndTokens + [IpHtmlTagTRend, IpHtmlTagTR] - | ||||||
| @ -7351,6 +7363,7 @@ begin | |||||||
|         if CurToken = IpHtmlTagCAPTIONend then |         if CurToken = IpHtmlTagCAPTIONend then | ||||||
|           NextToken; |           NextToken; | ||||||
|       end; |       end; | ||||||
|  |     CurTable.FCaption := CurCaption; | ||||||
|   end; |   end; | ||||||
|   ParseColgroup(CurTable); |   ParseColgroup(CurTable); | ||||||
|   SkipTextTokens;                                                      {!!.10} |   SkipTextTokens;                                                      {!!.10} | ||||||
| @ -10068,12 +10081,17 @@ begin | |||||||
|   end; |   end; | ||||||
| end; | end; | ||||||
| 
 | 
 | ||||||
| procedure TIpHtmlNodeBlock.Render( | procedure TIpHtmlNodeBlock.Render(const RenderProps: TIpHtmlProps); | ||||||
|   const RenderProps: TIpHtmlProps); | {$IFDEF IP_LAZARUS} | ||||||
|  | var | ||||||
|  |   Elem: TCSSProps = nil; | ||||||
|  | {$ENDIF} | ||||||
|  | begin | ||||||
|  |   if not RenderProps.IsEqualTo(Props) then | ||||||
|   begin |   begin | ||||||
|   if not RenderProps.IsEqualTo(Props) then begin |  | ||||||
|     SetProps(RenderProps); |  | ||||||
|     Props.Assign(RenderProps); |     Props.Assign(RenderProps); | ||||||
|  |     LoadCSSProps(Owner, Elem, Props); | ||||||
|  |     SetProps(Props); | ||||||
|   end; |   end; | ||||||
|   if ElementQueue.Count = 0 then |   if ElementQueue.Count = 0 then | ||||||
|     Enqueue; |     Enqueue; | ||||||
| @ -10364,14 +10382,19 @@ end; | |||||||
| 
 | 
 | ||||||
| procedure TIpHtmlNodeBlock.CalcMinMaxWidth(const RenderProps: TIpHtmlProps; | procedure TIpHtmlNodeBlock.CalcMinMaxWidth(const RenderProps: TIpHtmlProps; | ||||||
|       var Min, Max: Integer); |       var Min, Max: Integer); | ||||||
|  | {$IFDEF IP_LAZARUS} | ||||||
|  | var | ||||||
|  |   Elem: TCSSProps = nil; | ||||||
|  | {$ENDIF} | ||||||
| begin | begin | ||||||
|   if RenderProps.IsEqualTo(Props) and (FMin <> -1) and (FMax <> -1) then begin |   if RenderProps.IsEqualTo(Props) and (FMin <> -1) and (FMax <> -1) then begin | ||||||
|     Min := FMin; |     Min := FMin; | ||||||
|     Max := FMax; |     Max := FMax; | ||||||
|     Exit; |     Exit; | ||||||
|   end; |   end; | ||||||
|   SetProps(RenderProps); |  | ||||||
|   Props.Assign(RenderProps); |   Props.Assign(RenderProps); | ||||||
|  |   LoadCSSProps(Owner, Elem, Props); | ||||||
|  |   SetProps(Props); | ||||||
|   if ElementQueue.Count = 0 then |   if ElementQueue.Count = 0 then | ||||||
|     Enqueue; |     Enqueue; | ||||||
|   CalcMinMaxQueueWidth(Props, Min, Max); |   CalcMinMaxQueueWidth(Props, Min, Max); | ||||||
| @ -10415,11 +10438,17 @@ end; | |||||||
| 
 | 
 | ||||||
| procedure TIpHtmlNodeBlock.Layout(const RenderProps: TIpHtmlProps; | procedure TIpHtmlNodeBlock.Layout(const RenderProps: TIpHtmlProps; | ||||||
|   const TargetRect: TRect); |   const TargetRect: TRect); | ||||||
|  | {$IFDEF IP_LAZARUS} | ||||||
|  | var | ||||||
|  |   Elem: TCSSProps = nil; | ||||||
|  | {$ENDIF} | ||||||
| begin | begin | ||||||
|   if EqualRect(TargetRect, PageRect) then Exit; |   if EqualRect(TargetRect, PageRect) then Exit; | ||||||
|   if not RenderProps.IsEqualTo(Props) then begin |   if not RenderProps.IsEqualTo(Props) then | ||||||
|     SetProps(RenderProps); |   begin | ||||||
|     Props.Assign(RenderProps); |     Props.Assign(RenderProps); | ||||||
|  |     LoadCSSProps(Owner, Elem, Props); | ||||||
|  |     SetProps(Props); | ||||||
|   end; |   end; | ||||||
|   if ElementQueue.Count = 0 then |   if ElementQueue.Count = 0 then | ||||||
|     Enqueue; |     Enqueue; | ||||||
| @ -12858,7 +12887,7 @@ var | |||||||
| 
 | 
 | ||||||
|                         AL := AL0; |                         AL := AL0; | ||||||
| 
 | 
 | ||||||
|                         Props.Assign(Self.Props); |                         Props.Assign(Self.Props); // assign table props | ||||||
| 
 | 
 | ||||||
|                         CellRect1 := TargetRect; |                         CellRect1 := TargetRect; | ||||||
| 
 | 
 | ||||||
| @ -13425,6 +13454,7 @@ var | |||||||
|   z, i, j : Integer; |   z, i, j : Integer; | ||||||
|   R : TRect; |   R : TRect; | ||||||
|   Al : TIpHtmlVAlign3; |   Al : TIpHtmlVAlign3; | ||||||
|  |   TRBgColor, TrTextColor: TColor; | ||||||
|   aCanvas : TCanvas; |   aCanvas : TCanvas; | ||||||
| begin | begin | ||||||
|   aCanvas := Owner.Target; |   aCanvas := Owner.Target; | ||||||
| @ -13455,6 +13485,9 @@ begin | |||||||
|                 Al := hva3Bottom; |                 Al := hva3Bottom; | ||||||
|               end; |               end; | ||||||
| 
 | 
 | ||||||
|  |               TrBgColor := BgColor; | ||||||
|  |               TrTextColor := TextColor; | ||||||
|  | 
 | ||||||
|               for j := 0 to Pred(FChildren.Count) do |               for j := 0 to Pred(FChildren.Count) do | ||||||
|                 if TIpHtmlNode(FChildren[j]) is TIpHtmlNodeTableHeaderOrCell then |                 if TIpHtmlNode(FChildren[j]) is TIpHtmlNodeTableHeaderOrCell then | ||||||
|                   with TIpHtmlNodeTableHeaderOrCell(FChildren[j]) do begin |                   with TIpHtmlNodeTableHeaderOrCell(FChildren[j]) do begin | ||||||
| @ -13465,6 +13498,14 @@ begin | |||||||
|                     else |                     else | ||||||
|                       Al := VAlign; |                       Al := VAlign; | ||||||
|                     end; |                     end; | ||||||
|  | 
 | ||||||
|  |                     // set TR color, Render override them anyway if TD/TH have own settings | ||||||
|  |                     if TrBgColor <> -1 then | ||||||
|  |                       Props.BGColor := TrBgColor; | ||||||
|  | 
 | ||||||
|  |                     if TrTextColor <> -1 then | ||||||
|  |                       Props.FontColor := TrTextColor; | ||||||
|  | 
 | ||||||
|                     Props.VAlignment := Al; |                     Props.VAlignment := Al; | ||||||
|                     Render(Props); |                     Render(Props); | ||||||
|                     {paint left rule if selected} |                     {paint left rule if selected} | ||||||
| @ -13553,8 +13594,8 @@ begin | |||||||
|         RGB(128,128,128)); |         RGB(128,128,128)); | ||||||
| 
 | 
 | ||||||
|   {render caption} |   {render caption} | ||||||
|   //if assigned(FCaption) then |   if assigned(FCaption) then | ||||||
|   //  FCaption.Render(Props); |     FCaption.Render(Props); | ||||||
| end; | end; | ||||||
| 
 | 
 | ||||||
| procedure TIpHtmlNodeTABLE.SetProps(const RenderProps: TIpHtmlProps); | procedure TIpHtmlNodeTABLE.SetProps(const RenderProps: TIpHtmlProps); | ||||||
| @ -13777,7 +13818,13 @@ begin | |||||||
| end; | end; | ||||||
| {$ENDIF} | {$ENDIF} | ||||||
| 
 | 
 | ||||||
| { TIpHtmlNodeTR } | procedure TIpHtmlNodeTR.SetProps(const RenderProps: TIpHtmlProps); | ||||||
|  | begin | ||||||
|  |   Props.Assign(RenderProps); | ||||||
|  |   Props.FontColor := TextColor; | ||||||
|  |   Props.BgColor := BgColor; | ||||||
|  |   inherited SetProps(Props); | ||||||
|  | end; | ||||||
| 
 | 
 | ||||||
| constructor TIpHtmlNodeTR.Create(ParentNode: TIpHtmlNode); | constructor TIpHtmlNodeTR.Create(ParentNode: TIpHtmlNode); | ||||||
| begin | begin | ||||||
| @ -15433,8 +15480,7 @@ var | |||||||
| begin | begin | ||||||
|   for i := 0 to FChildren.Count - 1 do |   for i := 0 to FChildren.Count - 1 do | ||||||
|     if TIpHtmlNode(FChildren[i]) is TIpHtmlNodeBody then |     if TIpHtmlNode(FChildren[i]) is TIpHtmlNodeBody then | ||||||
|       TIpHtmlNodeBody(FChildren[i]).Layout( |       TIpHtmlNodeBody(FChildren[i]).Layout(RenderProps, TargetRect); | ||||||
|         RenderProps, TargetRect); |  | ||||||
| end; | end; | ||||||
| 
 | 
 | ||||||
| procedure TIpHtmlNodeHtml.Render(const RenderProps: TIpHtmlProps); | procedure TIpHtmlNodeHtml.Render(const RenderProps: TIpHtmlProps); | ||||||
| @ -15443,8 +15489,7 @@ var | |||||||
| begin | begin | ||||||
|   for i := 0 to FChildren.Count - 1 do |   for i := 0 to FChildren.Count - 1 do | ||||||
|     if TIpHtmlNode(FChildren[i]) is TIpHtmlNodeBody then |     if TIpHtmlNode(FChildren[i]) is TIpHtmlNodeBody then | ||||||
|       TIpHtmlNodeBody(FChildren[i]). |       TIpHtmlNodeBody(FChildren[i]).Render(RenderProps); | ||||||
|         Render(RenderProps); |  | ||||||
| end; | end; | ||||||
| 
 | 
 | ||||||
| { TIpHtmlNodeCore } | { TIpHtmlNodeCore } | ||||||
| @ -16517,14 +16562,18 @@ end; | |||||||
| 
 | 
 | ||||||
| procedure TIpHtmlNodeTableHeaderOrCell.CalcMinMaxWidth( | procedure TIpHtmlNodeTableHeaderOrCell.CalcMinMaxWidth( | ||||||
|   const RenderProps: TIpHtmlProps; var Min, Max: Integer); |   const RenderProps: TIpHtmlProps; var Min, Max: Integer); | ||||||
|  | var | ||||||
|  |   TmpBGColor, TmpFontColor: TColor; | ||||||
| begin | begin | ||||||
|  |   TmpBGColor := Props.BgColor; | ||||||
|  |   TmpFontColor := Props.FontColor; | ||||||
|   Props.Assign(RenderProps); |   Props.Assign(RenderProps); | ||||||
|  |   Props.BgColor := TmpBGColor; | ||||||
|  |   Props.FontColor := TmpFontColor; | ||||||
|   Props.Alignment := Align; |   Props.Alignment := Align; | ||||||
|   if Self is TIpHtmlNodeTH then |   if Self is TIpHtmlNodeTH then | ||||||
|     Props.FontStyle := Props.FontStyle + [fsBold]; |     Props.FontStyle := Props.FontStyle + [fsBold]; | ||||||
|   Props.VAlignment := VAlign; |   Props.VAlignment := VAlign; | ||||||
|   if BgColor <> -1 then |  | ||||||
|     Props.BgColor := BgColor; |  | ||||||
|   if NoWrap then |   if NoWrap then | ||||||
|     Props.NoBreak := True; |     Props.NoBreak := True; | ||||||
|   inherited CalcMinMaxWidth(Props, Min, Max); |   inherited CalcMinMaxWidth(Props, Min, Max); | ||||||
| @ -16544,14 +16593,6 @@ begin | |||||||
|   Props.DelayCache:=True; |   Props.DelayCache:=True; | ||||||
|   {$IFDEF IP_LAZARUS} |   {$IFDEF IP_LAZARUS} | ||||||
|   LoadCSSProps(Owner, Elem, Props); |   LoadCSSProps(Owner, Elem, Props); | ||||||
| { |  | ||||||
|   if (Elem <> nil) then |  | ||||||
|   begin |  | ||||||
|        if Elem.BGColor <> -1 then BgColor := Elem.BGColor; |  | ||||||
|   end |  | ||||||
|   else if (Props.BgColor <> -1) then |  | ||||||
|      BgColor := Props.BgColor; |  | ||||||
| } |  | ||||||
|   {$ENDIF} |   {$ENDIF} | ||||||
| //DebugLn('td :', IntToStr(Integer(Props.Alignment))); | //DebugLn('td :', IntToStr(Integer(Props.Alignment))); | ||||||
|   if BgColor <> -1 then |   if BgColor <> -1 then | ||||||
| @ -16573,12 +16614,10 @@ begin | |||||||
|   {$IFDEF IP_LAZARUS_DBG} |   {$IFDEF IP_LAZARUS_DBG} | ||||||
|   DebugBox(Owner.Target, PadRect, clYellow, True); |   DebugBox(Owner.Target, PadRect, clYellow, True); | ||||||
|   {$ENDIF} |   {$ENDIF} | ||||||
|   if PageRectToScreen(PadRect, R) then begin |   if PageRectToScreen(PadRect, R) then | ||||||
|     if (Props.BgColor <> -1) then begin |   begin | ||||||
|       //Props.BgColor := BgColor; |     if (Props.BgColor <> -1) then | ||||||
|       //if PtInRect(R, Owner.MousePoint) then |     begin | ||||||
|       //  Owner.Target.Brush.Color := clYellow |  | ||||||
|       //else |  | ||||||
|       Owner.Target.Brush.Color := Props.BGColor; |       Owner.Target.Brush.Color := Props.BGColor; | ||||||
|       Owner.Target.FillRect(R); |       Owner.Target.FillRect(R); | ||||||
|     end; |     end; | ||||||
| @ -19703,6 +19742,16 @@ begin | |||||||
|   {$ENDIF} |   {$ENDIF} | ||||||
| end; | end; | ||||||
| 
 | 
 | ||||||
|  | { TIpHtmlNodeCAPTION } | ||||||
|  | 
 | ||||||
|  | constructor TIpHtmlNodeCAPTION.Create(ParentNode: TIpHtmlNode); | ||||||
|  | begin | ||||||
|  |   inherited Create(ParentNode); | ||||||
|  |   {$IFDEF IP_LAZARUS} | ||||||
|  |   FElementName := 'caption'; | ||||||
|  |   {$ENDIF} | ||||||
|  | end; | ||||||
|  | 
 | ||||||
| initialization | initialization | ||||||
| {$IFDEF IP_LAZARUS} | {$IFDEF IP_LAZARUS} | ||||||
| {$I iphtml.lrs} | {$I iphtml.lrs} | ||||||
|  | |||||||
		Loading…
	
		Reference in New Issue
	
	Block a user
	 paul
						paul