small fixes for htmllite

git-svn-id: trunk@3772 -
This commit is contained in:
mattias 2003-01-01 10:48:55 +00:00
parent b37432d3e7
commit 43623c4fbb
5 changed files with 96 additions and 9 deletions

View File

@ -858,7 +858,9 @@ try
end;
hlParser.ParseThread := ParseThread;
hlParser.AllowSuspend := True;
{$IFNDEF NoThreads}
ParseThread.Resume;
{$ENDIF}
except
SetProcessing(False);
Raise;
@ -2722,8 +2724,16 @@ var
ABitmap: HBitmap;
ARect: TRect;
OldPal: HPalette;
p: TPoint;
begin
if (FViewer as ThtmlLite).DontDraw then Exit;
GetWindowOrgEx(Canvas.Handle,@p);
writeln('TPaintPanel.PaintA Canvas.Handle=',HexStr(Cardinal(Canvas.Handle),8),
' ',Width,',',Height,' ',ClientWidth,',',ClientHeight,' ',
' ',p.x,',',p.y,' ',Visible);
Canvas.Brush.Color:=clGreen;
Canvas.FillRect(Rect(0,0,200,200));
exit;
ThtmlLite(FViewer).DrawBorder;
OldPal := 0;
Canvas.Font := Font;
@ -2747,8 +2757,10 @@ try
SetWindowOrgEx(memDC, Left, Top, Nil);
Canvas2.Handle := MemDC;
{$ENDIF}
DoBackground(Canvas2, False);
if Assigned(FOnPaint) then FOnPaint(Self);
//DoBackground(Canvas2, False);
Canvas2.Brush.Color:=clBlue;
Canvas2.FillRect(Rect(0,0,200,200));
//if Assigned(FOnPaint) then FOnPaint(Self);
{$IFDEF HL_LAZARUS}
{$ELSE}
OldPal := SelectPalette(Canvas.Handle, ThePalette, False);
@ -2766,6 +2778,10 @@ try
end;
{$ENDIF}
finally
writeln('TPaintPanel.Paint B Canvas.Handle=',HexStr(Cardinal(Canvas.Handle),8));
{$IFDEF HL_LAZARUS}
Canvas2.Handle:=0;
{$ENDIF}
Canvas2.Free;
end;
end;
@ -2781,6 +2797,7 @@ var
DC: HDC;
CopyFromDC: boolean;
begin
writeln('TPaintPanel.DoBackground A ',HexStr(Cardinal(ACanvas),8));
DC := ACanvas.handle;
if DC <> 0 then
begin

View File

@ -1798,9 +1798,11 @@ var
end;
begin
writeln('ThlParser.DoCommonSy A ',SymbNames[Sy]);
case Sy of
TextSy :
begin
writeln('ThlParser.DoCommonSy B ',Assigned(Section),' ',LCToken.S);
if not Assigned(Section) then
Section := TSection.Create(MasterList, Lev, FontStack[StackIndex],
CurrentUrlTarget, Justify);
@ -2277,6 +2279,7 @@ var
begin
repeat
writeln('ThlParser.DoBody ',SymbNames[Sy]);
case Sy of
TextSy, BRSy, PSy, PEndSy,
NameSy, HRefSy, ASy, AEndSy,
@ -2293,6 +2296,7 @@ repeat
begin
if SectionList.Count = 0 then {make sure we're at beginning}
begin
writeln('ThlParser.DoBody B ',SymbNames[Sy],' ');
Section.Free; {Will start with a new section}
for I := 0 to Attributes.Count-1 do
with TAttribute(Attributes[I]) do

View File

@ -125,7 +125,7 @@ end;
procedure TFakeThread.CallOnTerminate;
begin
if Assigned(OnTerminate) then OnTerminate(Self);
end;
function TFakeThread.GetPriority: TThreadPriority;
@ -153,25 +153,29 @@ end;
procedure TFakeThread.DoTerminate;
begin
if Assigned(FOnTerminate) then
FOnTerminate(Self);
writeln('TFakeThread.DoTerminate ',HexStr(Cardinal(Self),8));
CallOnTerminate;
FFinished:=true;
if FFreeOnTerminate then Free;
FTerminated:=true;
end;
procedure TFakeThread.Synchronize(Method: TThreadMethod);
begin
writeln('TFakeThread.Synchronize ',HexStr(Cardinal(Self),8));
Method();
end;
constructor TFakeThread.Create(CreateSuspended: Boolean);
begin
writeln('TFakeThread.Create CreateSuspended=',CreateSuspended,' ',HexStr(Cardinal(Self),8));
inherited Create;
if CreateSuspended then Suspend else DoExecute;
end;
destructor TFakeThread.Destroy;
begin
writeln('TFakeThread.Destroy ',HexStr(Cardinal(Self),8));
if not FFinished and not Suspended then
begin
Terminate;
@ -182,21 +186,25 @@ end;
procedure TFakeThread.Resume;
begin
if not FFinished then DoExecute;
writeln('TFakeThread.Resume Self=',HexStr(Cardinal(Self),8));
DoExecute;
end;
procedure TFakeThread.Suspend;
begin
FSuspended := true;
writeln('TFakeThread.Suspend Self=',HexStr(Cardinal(Self),8));
FSuspended:=true;
end;
procedure TFakeThread.Terminate;
begin
FTerminated := True;
writeln('TFakeThread.Terminate Self=',HexStr(Cardinal(Self),8));
DoTerminate;
end;
function TFakeThread.WaitFor: Integer;
begin
writeln('TFakeThread.WaitFor Self=',HexStr(Cardinal(Self),8));
Result:=0;
end;

View File

@ -2189,6 +2189,7 @@ begin
end;
end;
Len := Curs - StartCurs;
writeln('TCell.DoLogic ',HexStr(Cardinal(Self),8),' ',Curs,' ',StartCurs,' Len=',Len);
Result := H;
IB := IMgr.ImageBottom - YValue; {check for image overhang}
if IB > Result then
@ -2225,6 +2226,7 @@ begin
H := Y;
for I := 0 to Count-1 do
begin
writeln('TCell.Draw ',HexStr(Cardinal(Self),8),' ',I,' ',TSectionBase(Items[I]).ClassName);
H := TSectionBase(Items[I]).Draw(Canvas, ARect, IMgr, X, H);
end;
Result := H;
@ -2494,6 +2496,7 @@ for I := 0 to AGifList.Count-1 do
OldPal := SelectPalette(Canvas.Handle, ThePalette, True);
RealizePalette(Canvas.Handle);
try
writeln('TSectionList.Draw ');
Result := inherited Draw(Canvas, ARect, ClipWidth, X, Y);
finally
SelectPalette(Canvas.Handle, OldPal, True);
@ -3929,6 +3932,7 @@ Inc(CaptionIndent, IMgr.LeftIndent(YValue));
Indent := CaptionIndent + (CaptionWidth-TableWidth) div 2; {table indent}
Len := Curs-StartCurs;
writeln('ThtmlTable.DrawLogic ',HexStr(Cardinal(Self),8),' ',Curs,' ',StartCurs,' Len=',Len);
MaxWidth := CaptionWidth;
if Float then
begin
@ -4375,6 +4379,7 @@ inherited Create(AMasterList);
Parser := ThlParser(ParentSectionList.Parser);
Buff := Nil;
Len := 0;
writeln('TSection.Create ',HexStr(Cardinal(Self),8),' Len=',Len);
BuffSize := 0;
Parser.CurrentSScript := Normal;
Fonts := TFontList.Create;
@ -4404,6 +4409,7 @@ end;
{----------------TSection.Destroy}
destructor TSection.Destroy;
begin
writeln('TSection.Destroy ',HexStr(Cardinal(Self),8));
if Assigned(Buff) then FreeMem(Buff, BuffSize);
if Assigned(XP) then
FreeMem(XP);
@ -4549,6 +4555,7 @@ if BuffSize < L+1 then Allocate(L + 100); {L+1 so there is always extra for fon
Move(S.S[1], (Buff+Len)^, Length(S.S));
Move(S.I[1], XP^[Len], Length(S.S)*Sizeof(integer));
Len := L;
writeln('TSection.AddTokenObj ',HexStr(Cardinal(Self),8),' Len=',Len);
end;
function TSection.BreakInfo(Index: integer; NoBreak: boolean): JustifyType; {called when <br> encountered}
@ -5310,6 +5317,7 @@ var
end;
begin {Y is at bottom of line here}
writeln('DrawTheText A Cnt=',Cnt);
ImageAtStart := True;
XX := X + LR.LineIndent;
LR.DrawY := Y-LR.LineHt;
@ -5377,6 +5385,7 @@ var
end
else
begin
writeln('DrawTheText B ');
J := IntMin(J1, J2);
J := IntMin(J, J4);
Inverted := ChkInversion(Start-Buff, J3);
@ -5400,6 +5409,7 @@ var
S[J] := ' ';
J := Pos(#160, S);
end;
writeln('DrawTheText C ',Self is TPreformated);
if Self is TPreformated then
begin {so will clip in Table cells}
ARect := Rect(X, Y-LR.LineHt-LR.SpaceBefore-YOffset, X+IMgr.ClipWidth, Y-YOffset+1);
@ -5413,6 +5423,9 @@ var
if SScript = Normal then Addon := 0
else if SScript = SupSc then Addon := -(FontHeight div 3)
else Addon := Descent div 2 +1;
writeln('DrawTheText D ',S,' ',HexStr(Cardinal(Canvas.Font.Color),8));
Canvas.Brush.Color:=clRed;
Canvas.FillRect(Rect(0,0,200,200));
TextOut(Canvas.Handle, XX-OHang div 2, Y - Descent + Addon - YOffset, PChar(S), I);
end;
{Put in a dummy caret to show character position}
@ -5458,6 +5471,7 @@ var
begin
Inc(Y, LineHt+SpaceBefore);
XS := LevelIndent + X;
writeln('DoDraw ',I,' ',ListType <> None);
if (I = 0) and (ListType <> None) then
if ListType = Definition then {definition list, do nothing}
else if ListType = Ordered then {ordered list}
@ -5507,6 +5521,9 @@ begin
Result := Y + SectionHeight;
YOffset := ParentSectionList.YOff;
writeln('TSection.Draw A ',HexStr(Cardinal(Self),8),' Lines.Count=',Lines.Count,
' Len=',Len,' Y=',Y,' YOffset=',YOffset,
' DrawHeight=',DrawHeight,' ARect.Top=',ARect.Top,' ARect.Bottom=',ARect.Bottom);
if (Len > 0) and (Y-YOffset+DrawHeight >= ARect.Top) and (Y-YOffset < ARect.Bottom) then
begin
DC := Canvas.Handle;
@ -5514,12 +5531,19 @@ if (Len > 0) and (Y-YOffset+DrawHeight >= ARect.Top) and (Y-YOffset < ARect.Bott
MySelB := ParentSectionList.SelB-StartCurs;
MySelE := ParentSectionList.SelE-StartCurs;
writeln('TSection.Draw Lines.Count=',Lines.Count);
Canvas.Brush.Color:=clMaroon;
Canvas.FillRect(Rect(0,0,200,200));
for I := 0 to Lines.Count-1 do
with LineRec(Lines[I]) do
begin
writeln('TSection.Draw ',I,' ',Y-YOffset+LineImgHt,' >= ',ARect.Top,
' and ',Y-YOffset,' < ',ARect.Bottom);
if (Y-YOffset+LineImgHt >= ARect.Top) and (Y-YOffset < ARect.Bottom) then
DoDraw(I)
else {do not completely draw extremely long paragraphs}
Inc(Y, SpaceBefore + LineHt + SpaceAfter);
end;
end;
end;

View File

@ -267,6 +267,40 @@ procedure FreeAndNil(var Obj);
{$endif}
{$endif}
{$IFDEF HL_LAZARUS}
const
SymbNames: array[Symb] of string = (
'HtmlSy', 'TitleSy', 'BodySy', 'HeadSy', 'PSy', 'PEndSy', 'BSy', 'BEndSy', 'ISy', 'IEndSy',
'HtmlEndSy', 'TitleEndSy', 'BodyEndSy', 'HeadEndSy', 'BRSy', 'HeadingSy', 'HeadingEndSy',
'EmSy', 'EmEndSy', 'StrongSy', 'StrongEndSy', 'USy', 'UEndSy', 'HRSy',
'CiteSy', 'VarSy', 'CiteEndSy', 'VarEndSy', 'BaseSy',
{Keep order}
'TTSy', 'CodeSy', 'KbdSy', 'SampSy', ' TTEndSy', 'CodeEndSy', 'KbdEndSy', 'SampEndSy',
{end order}
'OLSy', 'OLEndSy', 'LISy', 'ULSy', 'ULEndSy', 'DirSy', 'DirEndSy', 'MenuSy', 'MenuEndSy',
'DLSy', 'DLEndSy', 'DDSy', 'DTSy', 'AddressSy', 'AddressEndSy', 'BlockQuoteSy', 'BlockQuoteEndSy',
'PreSy', 'PreEndSy', 'ImageSy', 'Centersy', 'CenterEndSy',
'OtherAttribute', 'ASy', 'AEndSy', 'HrefSy', 'NameSy', 'SrcSy', 'AltSy', 'AlignSy',
'OtherChar', 'OtherSy', 'CommandSy', 'TextSy', 'EofSy', 'LinkSy', 'BGColorSy',
'BackgroundSy', 'TableSy', 'TableEndSy', 'TDSy', 'TDEndSy', 'TRSy', 'TREndSy', 'THSy', 'THEndSy',
'ColSpanSy', 'RowSpanSy', 'BorderSy', 'CellPaddingSy', 'CellSpacingSy', 'VAlignSy',
'WidthSy', 'CaptionSy', 'CaptionEndSy', 'StartSy', 'ButtonSy', 'InputSy', 'ValueSy',
'TypeSy', 'CheckBoxSy', 'RadioSy', 'FormSy', 'FormEndSy', 'MethodSy', 'ActionSy',
'CheckedSy', 'SizeSy', 'MaxLengthSy', 'TextAreaSy', 'TextAreaEndSy', 'ColsSy',
'RowsSy', 'SelectSy', 'SelectEndSy', 'OptionSy', 'OptionEndSy', 'SelectedSy',
'MultipleSy', 'FontSy', 'FontEndSy', 'ColorSy', 'FaceSy', 'BaseFontSy',
'TranspSy', 'SubSy', 'SubEndSy', 'SupSy', 'SupEndSy', 'ClearSy', 'IsMapSy',
'BigSy', 'BigEndSy', 'SmallSy', 'SmallEndSy', 'BorderColorSy', 'MapSy', 'MapEndSy',
'AreaSy', 'ShapeSy', 'CoordsSy', 'NoHrefSy', 'UseMapSy', 'HeightSy', 'PlainSy',
'FrameSetSy', 'FrameSetEndSy', 'FrameSy', 'TargetSy', 'NoFramesSy', 'NoFramesEndSy',
'NoResizeSy', 'ScrollingSy', 'HSpaceSy', 'VSpaceSy', 'ScriptSy', 'ScriptEndSy',
'LanguageSy', 'DivSy', 'DivEndSy', 'SSy', 'SEndSy', 'StrikeSy', 'StrikeEndSy',
'FrameBorderSy', 'MarginWidthSy', 'MarginHeightSy', 'BgSoundSy', 'LoopSy',
'OnClickSy', 'WrapSy', 'NoShadeSy', 'MetaSy', 'HttpEqSy', 'ContentSy', 'EncTypeSy',
'VLinkSy', 'OLinkSy', 'ActiveSy', 'NoBrSy', 'NoBrEndSy', 'WbrSy',
'NoWrapSy', 'EolSy');
{$ENDIF}
implementation
uses