From 2483d1f7d5b9c47505542e8d89e7dec0586157e0 Mon Sep 17 00:00:00 2001 From: macpgmr Date: Mon, 27 Dec 2010 02:47:07 +0000 Subject: [PATCH] Fixed support for JPEG; htmldemo should now load HTML with image files okay on Darwin/Linux. git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@1409 8e941d3f-bd1b-0410-a28a-d453659cc2b4 --- components/thtmlport/package/htmlcons.inc | 4 ++++ components/thtmlport/package/htmlun2.pas | 24 ++++++++++++++--------- components/thtmlport/package/htmlview.pas | 21 ++++++++++++++++---- 3 files changed, 36 insertions(+), 13 deletions(-) diff --git a/components/thtmlport/package/htmlcons.inc b/components/thtmlport/package/htmlcons.inc index 47d26ea7c..be2310a02 100755 --- a/components/thtmlport/package/htmlcons.inc +++ b/components/thtmlport/package/htmlcons.inc @@ -117,10 +117,14 @@ {$Define NoOldPNG} //Exclude .obj files, PNGZLIB1 and PngImage1. {$ENDIF} +{$IFDEF MSWINDOWS} {.$Define NoGDIPlus} {The gdiplus.dll provides Alpha transparency support for PNG images. If, for some reason the use of the gdiplus.dll is undesirable, define "NoGDIPlus" by removing the '.'. Defining both NoGDIPlus and NoOldPNG will remove support for PNG images entirely.} +{$ELSE} +{$Define NoGDIPlus} //No point in trying to load gdiplus.dll if not Windows. +{$ENDIF} {$Define NoMetaFile} {Metafiles may be displayed by undefining this constant. NoMetaFile is defined by default to emphasize the fact that Metafile diff --git a/components/thtmlport/package/htmlun2.pas b/components/thtmlport/package/htmlun2.pas index 2f9734483..2c3f268c9 100755 --- a/components/thtmlport/package/htmlun2.pas +++ b/components/thtmlport/package/htmlun2.pas @@ -490,7 +490,7 @@ type EGDIPlus = class (Exception); TJpegMod = class(TJpegImage) public -{$IFNDEF LCL} //For now +{$IFNDEF LCL} //Don't need since TJpegImage is a bitmap. property Bitmap; {$ENDIF} end; @@ -2134,15 +2134,22 @@ try jpImage := TJpegMod.Create; try jpImage.LoadFromStream(Stream); -{$IFNDEF LCL} if ColorBits <= 8 then begin +{$IFNDEF LCL} jpImage.PixelFormat := jf8bit; +{$ELSE} + jpImage.PixelFormat := pf8bit; +{$ENDIF} if not jpImage.GrayScale and (ColorBits = 8) then jpImage.Palette := CopyPalette(ThePalette); end +{$IFNDEF LCL} else jpImage.PixelFormat := jf24bit; Result.Assign(jpImage.Bitmap); +{$ELSE} + else jpImage.PixelFormat := pf24bit; + Result.Assign(jpImage); {$ENDIF} finally jpImage.Free; @@ -2298,9 +2305,9 @@ var begin Result := TBitmap.Create; try -{$IFNDEF LCL} +//{$IFNDEF LCL} Result.Assign(TmpGif.Bitmap); -{$ENDIF} +//{$ENDIF} except Result.Free; Result := Nil; @@ -2363,7 +2370,7 @@ var {$IFNDEF LCL} BM: Windows.TBitmap; {$ELSE} - BM: BITMAP; + BM: LclType.BITMAP; {$ENDIF} Image: TBitmap; @@ -4279,15 +4286,14 @@ Screen.Cursors[UpDownCursor] := LoadCursor(HInstance, 'UPDOWNCURSOR'); Screen.Cursors[UpOnlyCursor] := LoadCursor(HInstance, 'UPONLYCURSOR'); Screen.Cursors[DownOnlyCursor] := LoadCursor(HInstance, 'DOWNONLYCURSOR'); {$ELSE} -DefBitMap.LoadFromLazarusResource('ErrBitmap'); -ErrorBitMap.LoadFromLazarusResource('DefaultBitmap'); +DefBitMap.LoadFromLazarusResource('DefaultBitmap'); +ErrorBitMap.LoadFromLazarusResource('ErrBitmap'); ErrorBitMapMask.LoadFromLazarusResource('ErrBitmapMask'); -// {$IFDEF MSWINDOWS} //For now until fixed on Carbon. +//Don't need since equal to crHandPoint (and jumps around on Carbon). //Screen.Cursors[HandCursor] := LoadCursorFromLazarusResource('Hand_Cursor'); Screen.Cursors[UpDownCursor] := LoadCursorFromLazarusResource('UPDOWNCURSOR'); Screen.Cursors[UpOnlyCursor] := LoadCursorFromLazarusResource('UPONLYCURSOR'); Screen.Cursors[DownOnlyCursor] := LoadCursorFromLazarusResource('DOWNONLYCURSOR'); -// {$ENDIF} {$ENDIF} WaitStream := TMemoryStream.Create; diff --git a/components/thtmlport/package/htmlview.pas b/components/thtmlport/package/htmlview.pas index e5841cd12..55d843b6c 100755 --- a/components/thtmlport/package/htmlview.pas +++ b/components/thtmlport/package/htmlview.pas @@ -635,6 +635,13 @@ FCharset := DEFAULT_CHARSET; FMarginHeight := 5; FMarginWidth := 10; +// LCL port note: BorderPanel presumably used to simulate viewer border +// since TWinControl does not have BorderStyle property. But this use of +// TPanel interferes with Win32/GTK2 text display. However, eliminating +// it altogether interferes with Carbon animated GIFs, so create and add, +// but don't do anything with it. +// Since we're using TCustomControl, which introduces BorderStyle in LCL, +// instead of TWinControl, might eventually be able to set its border. BorderPanel := TPanel.Create(Self); BorderPanel.BevelInner := bvNone; BorderPanel.BevelOuter := bvNone; @@ -1203,7 +1210,7 @@ HScrollBar.LargeChange := IntMax(1, Wid - 20); HScrollBar.SetBounds(WFactor, Height-sbWidth-WFactor, Wid -WFactor, sbWidth); VScrollBar.SetBounds(Width-sbWidth-WFactor, WFactor, sbWidth, VHeight); VScrollBar.LargeChange := IntMax(1, PaintPanel.Height - VScrollBar.SmallChange); - //LCL port: Added IntMax per HScrollBar above to avoid range-check error. + // LCL port: Added IntMax per HScrollBar above to avoid range-check error. if htShowVScroll in FOptions then begin VScrollBar.Visible := ( FScrollBars in [ssBoth, ssVertical] ); @@ -2306,9 +2313,15 @@ else begin Result := HTMLServerToDos(Trim(Filename), FServerRoot); +{$IFDEF MSWINDOWS} if Pos('\', Result) = 1 then Result := ExpandFilename(Result) else if (Pos(':', Result)<> 2) and (Pos('\\', Result) <> 1) then +{$ELSE} + if Pos('/', Result) > 1 then + Result := ExpandFilename(Result) + else if (Pos('/', Result) <> 1) then +{$ENDIF} if CompareText(FBase, 'DosPath') = 0 then {let Dos find the path} else if FBase <> '' then begin @@ -4338,8 +4351,8 @@ begin PaintPanel.RePaint; {$IFNDEF LCL} BorderPanel.RePaint; -VScrollbar.RePaint; // -HScrollbar.RePaint; // +VScrollbar.RePaint; //Don't need this anymore (and causes +HScrollbar.RePaint; // endless loop with GTK2). {$ENDIF} end; @@ -4700,7 +4713,7 @@ if (Focused and (FBorderStyle = htFocused)) or (FBorderStyle = htSingle) BorderPanel.BorderStyle := bsSingle else BorderPanel.BorderStyle := bsNone; -{$ELSE} +{$ELSE} //Setting viewer's BorderStyle currently does not work. // inherited BorderStyle := bsSingle //else // inherited BorderStyle := bsNone;