IDE: fixed painting datamodules

git-svn-id: trunk@23103 -
This commit is contained in:
mattias 2009-12-12 15:51:01 +00:00
parent 6deb52fdc0
commit c64b628c67
3 changed files with 71 additions and 58 deletions

View File

@ -2294,13 +2294,13 @@ var
if not DC.RectVisible(RLeft, RTop, RRight, RBottom) then Exit;
if not RestoreBrush then
begin
DC.Save;
DC.BeginPainting;
RestoreBrush := True;
with DC.Canvas do
begin
OldBrushColor := Brush.Color;
Brush.Color := GrabberColor;
end;
RestoreBrush := True;
end;
DC.Canvas.FillRect(Rect(RLeft, RTop, RRight, RBottom));
//DC.Canvas.TextOut(RLeft,RTop,dbgs(ord(g)));
@ -2327,7 +2327,7 @@ begin
if RestoreBrush then
begin
DC.Canvas.Brush.Color:=OldBrushColor;
DC.Restore;
DC.EndPainting;
end;
end;
@ -2342,7 +2342,7 @@ var
if not DC.RectVisible(RLeft, RTop, RRight, RBottom) then exit;
if not RestoreBrush then
begin
DC.Save;
DC.BeginPainting;
OldBrushColor:=DC.Canvas.Brush.Color;
DC.Canvas.Brush.Color:=MarkerColor;
RestoreBrush := True;
@ -2360,7 +2360,7 @@ begin
if RestoreBrush then
begin
DC.Canvas.Brush.Color:=OldBrushColor;
DC.Restore;
DC.EndPainting;
end;
end;
@ -2465,7 +2465,7 @@ var
begin
if not DC.RectVisible(StartX, StartY, EndX, EndY) then exit;
if not RestorePen then begin
DC.Save;
DC.BeginPainting;
with DC.Canvas do begin
OldPenColor:=Pen.Color;
if RubberbandType=rbtSelection then
@ -2499,7 +2499,7 @@ var
if RestorePen then
begin
DC.Canvas.Pen.Color:=OldPenColor;
DC.Restore;
DC.EndPainting;
Include(FStates,cssRubberbandPainted);
end;
end;
@ -3109,7 +3109,7 @@ var
if not DC.RectVisible(ARect.Left,ARect.Top,ARect.Right,ARect.Bottom) then
exit;
if not RestorePen then begin
DC.Save;
DC.BeginPainting;
OldPenColor:=DC.Canvas.Pen.Color;
RestorePen:=true;
end;
@ -3136,7 +3136,6 @@ begin
RestorePen:=false;
DC.Save;
DCOrigin:=DC.FormOrigin;
OldPenColor:=DC.Canvas.Pen.Color;
// draw bottom guideline
@ -3160,9 +3159,8 @@ begin
if RestorePen then
begin
DC.Canvas.Pen.Color:=OldPenColor;
DC.Restore;
DC.EndPainting;
end;
DC.Restore;
Include(FStates,cssGuideLinesPainted);
end;

View File

@ -1428,19 +1428,17 @@ begin
end;
function TDesigner.NonVisualComponentLeftTop(AComponent: TComponent): TPoint;
var
ParentForm: TPoint;
begin
Result.X := LeftFromDesignInfo(AComponent.DesignInfo);
Result.Y := TopFromDesignInfo(AComponent.DesignInfo);
// convert to lookuproot coords
if (AComponent.Owner <> FLookupRoot) and (FLookupRoot is TControl) then
if (AComponent.Owner <> FLookupRoot) then
begin
AComponent := AComponent.Owner;
if AComponent is TControl then
with TControl(FLookupRoot).ScreenToClient(TControl(AComponent).ClientToScreen(Point(0, 0))) do
begin
inc(Result.X, X);
inc(Result.Y, Y);
end;
ParentForm:=GetParentFormRelativeClientOrigin(AComponent.Owner);
inc(Result.X,ParentForm.X);
inc(Result.Y,ParentForm.Y);
end;
end;
@ -2683,7 +2681,7 @@ begin
or (not (csAcceptsControls in AWinControl.ControlStyle))
or ((not ShowGrid) and (not ShowBorderSpacing)) then exit;
aDDC.Save;
aDDC.BeginPainting;
try
// exclude all child control areas
Count:=AWinControl.ControlCount;
@ -2724,7 +2722,7 @@ begin
end;
end;
finally
aDDC.Restore;
aDDC.EndPainting;
end;
end;
@ -2995,19 +2993,45 @@ var
OwnerRect, IconRect, TextRect: TRect;
TextSize: TSize;
IsSelected: Boolean;
Root: TComponent;
RGN: HRGN;
begin
// also call draw for the inline components children
if (csInline in AComponent.ComponentState) or (AComponent.Owner=nil) then
Root:=AComponent
else
Root:=AComponent.Owner;
TComponentAccess(AComponent).GetChildren(@DrawNonVisualComponent, Root);
if (AComponent is TControl)
and (csNoDesignVisible in TControl(AComponent).ControlStyle) then
exit;
// draw children
if (AComponent.Owner=nil) then
begin
FDDC.BeginPainting;
TComponentAccess(AComponent).GetChildren(@DrawNonVisualComponent, AComponent);
FDDC.EndPainting;
end
else if (csInline in AComponent.ComponentState) then
begin
if AComponent is TControl then
begin
// clip to client area
FDDC.BeginPainting;
FDDC.Canvas.SaveHandleState;
OwnerRect := TControl(AComponent).ClientRect;
GetParentFormRelativeClientOrigin(AComponent);
with OwnerRect do
RGN := CreateRectRGN(Left, Top, Right, Bottom);
SelectClipRGN(FDDC.DC, RGN);
DeleteObject(RGN);
end;
TComponentAccess(AComponent).GetChildren(@DrawNonVisualComponent, AComponent);
if AComponent is TControl then
begin
FDDC.Canvas.RestoreHandleState;
FDDC.EndPainting;
end;
end else begin
TComponentAccess(AComponent).GetChildren(@DrawNonVisualComponent, AComponent.Owner);
end;
if not ComponentIsIcon(AComponent) or (AComponent.Owner = nil) then
Exit;
if not (AComponent.Owner is TControl) then
Exit;
// actual draw
Diff := FDDC.FormOrigin;
//DebugLn(['FDDC.FormOrigin - ', Diff.X, ' : ' ,Diff.Y]);
@ -3021,20 +3045,6 @@ begin
Exit;
IsSelected := ControlSelection.IsSelected(AComponent);
FDDC.Save;
// set clipping
if AComponent.Owner <> FDDC.Form then
begin
OwnerRect := TControl(AComponent.Owner).ClientRect;
Diff := FDDC.Form.ScreenToClient(TControl(AComponent.Owner).ClientToScreen(Point(0, 0)));
OffsetRect(OwnerRect, Diff.X, Diff.Y);
// don't restore later FDDC.Restore will do this itself
with OwnerRect do
RGN := CreateRectRGN(Left, Top, Right, Bottom);
SelectClipRGN(FDDC.DC, RGN);
DeleteObject(RGN);
end;
if FSurface = nil then
begin
@ -3051,7 +3061,8 @@ begin
InflateRect(IconRect, -NonVisualCompBorder + 1, -NonVisualCompBorder + 1);
// draw component Name
if ShowComponentCaptions and (((GetKeyState(VK_LBUTTON) and $80) = 0) or not IsSelected) then
if ShowComponentCaptions
and (((GetKeyState(VK_LBUTTON) and $80) = 0) or not IsSelected) then
begin
// workarounds gtk2 problem with DrawText on gc with GDK_INCLUDE_INFERIORS
// it uses pango drawing and this for some reason does not take subwindow_mode
@ -3093,17 +3104,13 @@ begin
if (ControlSelection.Count > 1) and IsSelected then
ControlSelection.DrawMarkerAt(FDDC,
ItemLeft, ItemTop, NonVisualCompWidth, NonVisualCompWidth);
FDDC.Restore;
end;
procedure TDesigner.DrawNonVisualComponents(aDDC: TDesignerDeviceContext);
var
i: integer;
begin
FSurface := nil;
FDDC := aDDC;
for i := 0 to FLookupRoot.ComponentCount - 1 do
DrawNonVisualComponent(FLookupRoot.Components[i]);
DrawNonVisualComponent(FLookupRoot);
FDDC := nil;
if FSurface <> nil then
FSurface.Free;
@ -3122,7 +3129,9 @@ begin
//writeln('TDesigner.DrawDesignerItems B painting');
DesignerDC := GetDesignerDC(Form.Handle);
DDC.SetDC(Form, Form, DesignerDC);
DDC.BeginPainting;
DoPaintDesignerItems;
DDC.EndPainting;
DDC.Clear;
ReleaseDesignerDC(Form.Handle, DesignerDC);
end;

View File

@ -54,9 +54,10 @@ type
FFlags: TDesignerDCFlags;
FFormClientOrigin: TPoint; // Form client origin on desktop
FFormOrigin: TPoint; // DC origin relative to designer Form
FSavedDC: HDC;
FDcSize: TPoint;
FForm: TCustomForm;
FSavedDC: HDC;
FPaintCount: integer;
function GetDCOrigin: TPoint;
function GetDCSize: TPoint;
function GetFormClientOrigin: TPoint;
@ -66,8 +67,8 @@ type
destructor Destroy; override;
procedure SetDC(AForm: TCustomForm; ADCControl: TWinControl; ADC: HDC);
procedure Clear;
procedure Save;
procedure Restore;
procedure BeginPainting;
procedure EndPainting;
function RectVisible(ALeft, ATop, ARight, ABottom: integer): boolean;
property Canvas: TCanvas read FCanvas;
property DC: HDC read FDC;
@ -455,23 +456,28 @@ end;
procedure TDesignerDeviceContext.Clear;
begin
Restore;
if (FSavedDC<>0) or (FPaintCount>0) then
RaiseGDBException('');
FDC := 0;
FFlags := FFlags - [ddcFormOriginValid, ddcFormClientOriginValid, ddcDCOriginValid, ddcSizeValid];
end;
procedure TDesignerDeviceContext.Save;
procedure TDesignerDeviceContext.BeginPainting;
begin
if FSavedDC = 0 then
if FSavedDC = 0 then
begin
FSavedDC := SaveDC(DC);
FCanvas.Handle := DC;
end;
inc(FPaintCount);
//DebugLn(['TDesignerDeviceContext.BeginPainting ',FPaintCount]);
end;
procedure TDesignerDeviceContext.Restore;
procedure TDesignerDeviceContext.EndPainting;
begin
if FSavedDC <> 0 then
//DebugLn(['TDesignerDeviceContext.EndPainting ',FPaintCount]);
dec(FPaintCount);
if (FPaintCount=0) and (FSavedDC <> 0) then
begin
FCanvas.Handle := 0;
RestoreDC(DC, FSavedDC);