turbo ipro: update layout in Paint if needed

git-svn-id: trunk@31203 -
This commit is contained in:
mattias 2011-06-13 17:59:40 +00:00
parent 34e18ab3f9
commit e974f302e5
7 changed files with 57 additions and 47 deletions

View File

@ -342,7 +342,6 @@ var
Stream: TStream; Stream: TStream;
NewHTML: TIpHtml; NewHTML: TIpHtml;
NewURL: String; NewURL: String;
ok: Boolean;
begin begin
if IDEProvider=nil then raise Exception.Create('TIPLazHtmlControl.SetURL missing Provider'); if IDEProvider=nil then raise Exception.Create('TIPLazHtmlControl.SetURL missing Provider');
if FURL=AValue then exit; if FURL=AValue then exit;
@ -351,18 +350,13 @@ begin
FURL:=NewURL; FURL:=NewURL;
try try
Stream:=IDEProvider.GetStream(FURL,true); Stream:=IDEProvider.GetStream(FURL,true);
ok:=false;
NewHTML:=nil;
try try
NewHTML:=TIpHtml.Create; // Beware: Will be freed automatically TIpHtmlPanel NewHTML:=TIpHtml.Create; // Beware: Will be freed automatically TIpHtmlPanel
FIPHTMLPanel.SetHtml(NewHTML);
NewHTML.LoadFromStream(Stream); NewHTML.LoadFromStream(Stream);
ok:=true;
finally finally
if not ok then FreeAndNil(NewHTML);
IDEProvider.ReleaseStream(FURL); IDEProvider.ReleaseStream(FURL);
end; end;
if NewHTML<>nil then
FIPHTMLPanel.SetHtml(NewHTML);
except except
on E: Exception do begin on E: Exception do begin
MessageDlg('Unable to open HTML file', MessageDlg('Unable to open HTML file',
@ -376,21 +370,12 @@ procedure TLazIPHtmlControl.SetHTMLContent(Stream: TStream; const NewURL: string
); );
var var
NewHTML: TIpHtml; NewHTML: TIpHtml;
ok: Boolean;
begin begin
FURL:=NewURL; FURL:=NewURL;
try try
NewHTML:=nil; NewHTML:=TIpHtml.Create; // Beware: Will be freed automatically TIpHtmlPanel
ok:=false; FIPHTMLPanel.SetHtml(NewHTML);
try NewHTML.LoadFromStream(Stream);
NewHTML:=TIpHtml.Create; // Beware: Will be freed automatically TIpHtmlPanel
NewHTML.LoadFromStream(Stream);
ok:=true;
finally
if not ok then FreeAndNil(NewHTML);
end;
if NewHTML<>nil then
FIPHTMLPanel.SetHtml(NewHTML);
except except
on E: Exception do begin on E: Exception do begin
MessageDlg('Unable to load HTML stream', MessageDlg('Unable to load HTML stream',
@ -405,7 +390,6 @@ begin
AWidth:=0; AWidth:=0;
AHeight:=0; AHeight:=0;
inherited GetPreferredSize(AWidth, AHeight); inherited GetPreferredSize(AWidth, AHeight);
//debugln(['TLazIPHtmlControl.GetPreferredControlSize Width=',AWidth,' Height=',AHeight]);
end; end;
finalization finalization

View File

@ -100,7 +100,9 @@
public public
constructor Create; constructor Create;
destructor Destroy; override; destructor Destroy; override;
//procedure DumpProps; {$IFDEF IP_LAZARUS_DBG}
procedure DumpProps;
{$ENDIF}
function GetElement(AElementID: String; ClassID: String = ''; CreateIfNotExist: Boolean = False): TCSSProps; function GetElement(AElementID: String; ClassID: String = ''; CreateIfNotExist: Boolean = False): TCSSProps;
end; end;
@ -951,7 +953,6 @@ end;
procedure TCSSGlobalProps.DumpProps; procedure TCSSGlobalProps.DumpProps;
var var
n: integer; n: integer;
props: TCSSProps;
begin begin
for n:=0 to FElements.Count-1 do for n:=0 to FElements.Count-1 do
begin begin

View File

@ -43,6 +43,8 @@
{ Global defines potentially affecting this unit } { Global defines potentially affecting this unit }
{$I IPDEFINE.INC} {$I IPDEFINE.INC}
{off $DEFINE IP_LAZARUS_DBG}
unit IpHtml; unit IpHtml;
interface interface
@ -2940,7 +2942,7 @@ type
function FindElement(const Name: string): TIpHtmlNode; function FindElement(const Name: string): TIpHtmlNode;
procedure Clear; {clear any contents} procedure Clear; {clear any contents}
procedure Home; procedure Home;
function GetPageRect(TargetCanvas: TCanvas; Width, Height : Integer): TRect; function GetPageRect(TargetCanvas: TCanvas; Width, Height : Integer): TRect; // computes the layout for this Canvas
procedure MouseMove(Pt : TPoint); procedure MouseMove(Pt : TPoint);
{$IFDEF IP_LAZARUS} {$IFDEF IP_LAZARUS}
procedure DeselectAllItems(Item: Pointer); procedure DeselectAllItems(Item: Pointer);
@ -3102,11 +3104,13 @@ type
private private
FHyper : TIpHtml; FHyper : TIpHtml;
FPageRect : TRect; FPageRect : TRect;
FPageRectValid: boolean;
FAutoScroll: Boolean; FAutoScroll: Boolean;
FOnHotChange : TNotifyEvent; FOnHotChange : TNotifyEvent;
FOnCurElementChange : TNotifyEvent; FOnCurElementChange : TNotifyEvent;
FOnHotClick : TNotifyEvent; FOnHotClick : TNotifyEvent;
FOnClick : TNotifyEvent; FOnClick : TNotifyEvent;
function GetPageRect: TRect;
procedure SetHtml(const Value: TIpHtml); procedure SetHtml(const Value: TIpHtml);
procedure SetPageRect(const Value: TRect); procedure SetPageRect(const Value: TRect);
protected protected
@ -3170,7 +3174,7 @@ type
PageCount: Integer; {!!.10} PageCount: Integer; {!!.10}
procedure InvalidateSize; procedure InvalidateSize;
property Hyper : TIpHtml read FHyper write SetHtml; property Hyper : TIpHtml read FHyper write SetHtml;
property PageRect : TRect read FPageRect write SetPageRect; property PageRect : TRect read GetPageRect write SetPageRect;
constructor Create(AOwner: TComponent); override; constructor Create(AOwner: TComponent); override;
property AutoScroll: Boolean read FAutoScroll write FAutoScroll; property AutoScroll: Boolean read FAutoScroll write FAutoScroll;
property OnHotChange : TNotifyEvent read FOnHotChange write FOnHotChange; property OnHotChange : TNotifyEvent read FOnHotChange write FOnHotChange;
@ -3710,7 +3714,7 @@ begin
writeln('TIpHtmlProps is nil'); writeln('TIpHtmlProps is nil');
exit; exit;
end; end;
writeln('>>> ', aProps.FOwner.ClassName, ': ', Integer(@aProps)); writeln('>>> ', aProps.FOwner.ClassName, ': ', dbgs(@aProps));
if aProps.PropA <> nil then if aProps.PropA <> nil then
begin begin
propA := aProps.PropA.FPropRec; propA := aProps.PropA.FPropRec;
@ -3737,7 +3741,7 @@ begin
end; end;
end; end;
procedure DebugBox(Canvas: TCanvas; R: Trect; cl:TColor; dbg:boolean=false); procedure DebugBox(Canvas: TCanvas; R: TRect; cl:TColor; dbg:boolean=false);
var var
OldPenColor: TColor; OldPenColor: TColor;
begin begin
@ -3748,7 +3752,7 @@ begin
Canvas.MoveTo(r.Left, r.top+(r.bottom-r.top) div 2); Canvas.MoveTo(r.Left, r.top+(r.bottom-r.top) div 2);
Canvas.LineTo(r.right, r.top+(r.bottom-r.top) div 2); Canvas.LineTo(r.right, r.top+(r.bottom-r.top) div 2);
if Dbg then if Dbg then
DebugLn(dbgs(R)); DebugLn('DebugBox:R=',dbgs(R));
Canvas.Pen.Color := OldPenColor; Canvas.Pen.Color := OldPenColor;
end; end;
{$ENDIF} {$ENDIF}
@ -7592,7 +7596,7 @@ procedure TIpHtml.ParseBlock(Parent : TIpHtmlNode;
const EndTokens: TIpHtmlTokenSet); const EndTokens: TIpHtmlTokenSet);
begin begin
case CurToken of case CurToken of
IpHtmlTagH1 : ParseHeader(Parent, IpHtmlTagH1end, 1); IpHtmlTagH1 : ParseHeader(Parent, IpHtmlTagH1end, 1);
IpHtmlTagH2 : ParseHeader(Parent, IpHtmlTagH2end, 2); IpHtmlTagH2 : ParseHeader(Parent, IpHtmlTagH2end, 2);
IpHtmlTagH3 : ParseHeader(Parent, IpHtmlTagH3end, 3); IpHtmlTagH3 : ParseHeader(Parent, IpHtmlTagH3end, 3);
IpHtmlTagH4 : ParseHeader(Parent, IpHtmlTagH4end, 4); IpHtmlTagH4 : ParseHeader(Parent, IpHtmlTagH4end, 4);
@ -7629,7 +7633,7 @@ procedure TIpHtml.ParseStyleSheet(Parent: TIpHtmlNode; HRef: String);
var var
StyleStream: TStream; StyleStream: TStream;
begin begin
debugln(['TIpHtml.ParseStyleSheet ',href,' ',Parent is TIpHtmlNodeHEAD,' ',DbgSName(FDataProvider)]); //debugln(['TIpHtml.ParseStyleSheet ',href,' ',Parent is TIpHtmlNodeHEAD,' ',DbgSName(FDataProvider)]);
StyleStream:=nil; StyleStream:=nil;
if Parent is TIpHtmlNodeHEAD then begin if Parent is TIpHtmlNodeHEAD then begin
@ -9006,10 +9010,10 @@ begin
end; end;
procedure TIpHtml.DebugAll; procedure TIpHtml.DebugAll;
var //var
i: Integer; //i: Integer;
item: PIpHtmlRectListEntry; //item: PIpHtmlRectListEntry;
Node: TIpHtmlNode; //Node: TIpHtmlNode;
begin begin
CCC := 0; CCC := 0;
Fhtml.EnumChildren(DebugChild, FHtml); Fhtml.EnumChildren(DebugChild, FHtml);
@ -9174,6 +9178,7 @@ var
DefPageRect : TRect; DefPageRect : TRect;
Min, Max, W, H : Integer; Min, Max, W, H : Integer;
begin begin
//debugln(['TIpHtml.GetPageRect START DoneLoading=',DoneLoading,' FHtml=',FHtml<>nil]);
if not DoneLoading then begin if not DoneLoading then begin
{$IFDEF IP_LAZARUS} {$IFDEF IP_LAZARUS}
// always set Result // always set Result
@ -10137,7 +10142,6 @@ begin
L0 := Level0; L0 := Level0;
LastProp := nil; LastProp := nil;
aCanvas := Owner.Target; aCanvas := Owner.Target;
for i := 0 to Pred(ElementQueue.Count) do begin for i := 0 to Pred(ElementQueue.Count) do begin
CurWord := PIpHtmlElement(ElementQueue[i]); CurWord := PIpHtmlElement(ElementQueue[i]);
@ -10170,6 +10174,7 @@ begin
//DumpTIpHtmlProps(LastProp); //DumpTIpHtmlProps(LastProp);
{$endif} {$endif}
//debugln(['TIpHtmlNodeBlock.RenderQueue ',i,' ',IntersectRect(R, CurWord.WordRect2, Owner.PageViewRect),' CurWord.WordRect2=',dbgs(CurWord.WordRect2),' Owner.PageViewRect=',dbgs(Owner.PageViewRect)]);
if IntersectRect(R, CurWord.WordRect2, Owner.PageViewRect) then if IntersectRect(R, CurWord.WordRect2, Owner.PageViewRect) then
case CurWord.ElementType of case CurWord.ElementType of
etWord : etWord :
@ -10193,7 +10198,8 @@ begin
else else
{$ENDIF} {$ENDIF}
aCanvas.Brush.Style := bsClear; aCanvas.Brush.Style := bsClear;
if CurWord.AnsiWord <> NAnchorChar then //JMN //debugln(['TIpHtmlNodeBlock.RenderQueue ',CurWord.AnsiWord]);
if CurWord.AnsiWord <> NAnchorChar then //JMN
aCanvas.TextOut(P.x, P.y, NoBreakToSpace(CurWord.AnsiWord)); aCanvas.TextOut(P.x, P.y, NoBreakToSpace(CurWord.AnsiWord));
{$IFDEF IP_LAZARUS} {$IFDEF IP_LAZARUS}
restoreCanvasProperties; restoreCanvasProperties;
@ -17479,7 +17485,10 @@ var
begin begin
CR := GetClientRect; CR := GetClientRect;
if not ScaleBitmaps {printing} {!!.10} if not ScaleBitmaps {printing} {!!.10}
and (Hyper <> nil) then and (Hyper <> nil) then begin
// update layout
GetPageRect;
// render
Hyper.Render(Canvas, Hyper.Render(Canvas,
Rect( Rect(
ViewLeft, ViewTop, ViewLeft, ViewTop,
@ -17487,8 +17496,10 @@ begin
ViewTop + (CR.Bottom - CR.Top)), ViewTop + (CR.Bottom - CR.Top)),
True, True,
Point(0, 0)) {!!.10} Point(0, 0)) {!!.10}
end
else else
Canvas.FillRect(CR); Canvas.FillRect(CR);
//debugln(['TIpHtmlInternalPanel.Paint ',dbgs(CR)]);
{$IFDEF IP_LAZARUS_DBG} {$IFDEF IP_LAZARUS_DBG}
DebugBox(Canvas, CR, clYellow); DebugBox(Canvas, CR, clYellow);
Debugbox(Canvas, Canvas.ClipRect, clLime, true); Debugbox(Canvas, Canvas.ClipRect, clLime, true);
@ -17682,8 +17693,7 @@ end;
procedure TIpHtmlInternalPanel.InvalidateSize; procedure TIpHtmlInternalPanel.InvalidateSize;
begin begin
if Hyper <> nil then FPageRectValid:=false;
PageRect := Hyper.GetPageRect(Canvas, ClientWidth, 0);
Invalidate; Invalidate;
end; end;
@ -17762,6 +17772,18 @@ begin
InvalidateSize; InvalidateSize;
end; end;
function TIpHtmlInternalPanel.GetPageRect: TRect;
begin
if not FPageRectValid then begin
if Hyper <> nil then
PageRect := Hyper.GetPageRect(Canvas, ClientWidth, 0)
else
PageRect:=Rect(0,0,0,0);
FPageRectValid:=true;
end;
Result:=FPageRect;
end;
procedure TIpHtmlInternalPanel.SetPageRect(const Value: TRect); procedure TIpHtmlInternalPanel.SetPageRect(const Value: TRect);
begin begin
if not SettingPageRect then begin if not SettingPageRect then begin
@ -19375,7 +19397,7 @@ begin
or (FMasterFrame.FHtml = nil) or (FMasterFrame.FHtml = nil)
or (not FMasterFrame.FHtml.CanPaint) then or (not FMasterFrame.FHtml.CanPaint) then
if not (csDesigning in ComponentState) then if not (csDesigning in ComponentState) then
FillRect(Message.DC, ClientRect, Brush.Handle); FillRect(Message.DC, ClientRect, Brush.Reference.Handle);
Message.Result := 1; Message.Result := 1;
end; end;
@ -19674,11 +19696,10 @@ procedure TIpHtmlCustomPanel.CalculatePreferredSize(var PreferredWidth,
var var
r: TRect; r: TRect;
begin begin
// FMasterFrame.InvalidateSize(Self); //debugln(['TIpHtmlCustomPanel.CalculatePreferredSize ',DbgSName(Self)]);
r:=Rect(0,0,0,0); r:=Rect(0,0,0,0);
if (FMasterFrame<>nil) and (FMasterFrame.FHtml<>nil) if (FMasterFrame<>nil) and (FMasterFrame.FHtml<>nil) then
and (FMasterFrame.HyperPanel<>nil) then r:=FMasterFrame.HyperPanel.PageRect;
r:=FMasterFrame.FHtml.GetPageRect(FMasterFrame.HyperPanel.Canvas,ClientWidth,0);
inherited CalculatePreferredSize(PreferredWidth, PreferredHeight, inherited CalculatePreferredSize(PreferredWidth, PreferredHeight,
WithThemeSpace); WithThemeSpace);
if PreferredWidth<r.Right-r.Left then if PreferredWidth<r.Right-r.Left then

View File

@ -12,6 +12,10 @@ div {
padding: 0 0 0 0; padding: 0 0 0 0;
} }
div.header {
margin-bottom: 0px;
}
tt, span.keyword, pre { tt, span.keyword, pre {
font-family: Courier, monospace font-family: Courier, monospace
} }

View File

@ -59,8 +59,8 @@ uses
// IDE units // IDE units
IDEDialogs, LazarusIDEStrConsts, IDECommands, EditorOptions, EnvironmentOpts, IDEDialogs, LazarusIDEStrConsts, IDECommands, EditorOptions, EnvironmentOpts,
WordCompletion, FindReplaceDialog, IDEProcs, IDEOptionDefs, WordCompletion, FindReplaceDialog, IDEProcs, IDEOptionDefs,
MacroPromptDlg, TransferMacros, CodeContextForm, SrcEditHintFrm, MsgView, InputHistory, CodeMacroPrompt, MacroPromptDlg, TransferMacros, CodeContextForm, SrcEditHintFrm, MsgView,
CodeTemplatesDlg, CodeToolsOptions, InputHistory, CodeMacroPrompt, CodeTemplatesDlg, CodeToolsOptions,
SortSelectionDlg, EncloseSelectionDlg, ConDef, InvertAssignTool, SortSelectionDlg, EncloseSelectionDlg, ConDef, InvertAssignTool,
SourceEditProcs, SourceMarks, CharacterMapDlg, SearchFrm, SourceEditProcs, SourceMarks, CharacterMapDlg, SearchFrm,
FPDocHints, FPDocHints,

View File

@ -289,7 +289,7 @@ begin
OnDestroy:=@FormDestroy; OnDestroy:=@FormDestroy;
OnKeyDown:=@FormKeyDown; OnKeyDown:=@FormKeyDown;
OnUTF8KeyPress:=@FormUTF8KeyPress; OnUTF8KeyPress:=@FormUTF8KeyPress;
FPreferredWidth:=300; FPreferredWidth:=400;
FPreferredHeight:=200; FPreferredHeight:=200;
FormCreate(Self); FormCreate(Self);
end; end;

View File

@ -685,7 +685,7 @@ type
constructor Create; override; constructor Create; override;
destructor Destroy; override; destructor Destroy; override;
property Bitmap: TCustomBitmap read FBitmap write SetBitmap; property Bitmap: TCustomBitmap read FBitmap write SetBitmap;
property Handle: HBRUSH read GetHandle write SetHandle; deprecated; property Handle: HBRUSH read GetHandle write SetHandle; deprecated; // use instead Reference.Handle
property Reference: TWSBrushReference read GetReference; property Reference: TWSBrushReference read GetReference;
published published
property Color: TColor read FColor write SetColor default clWhite; property Color: TColor read FColor write SetColor default clWhite;