designer: woraround gtk2 bug with drawing text on GDK_INCLUDE_INFERIOR graphic context

git-svn-id: trunk@21641 -
This commit is contained in:
paul 2009-09-10 01:43:48 +00:00
parent 78a3277b28
commit 3c12d6c41b
2 changed files with 22 additions and 11 deletions

View File

@ -2564,14 +2564,24 @@ begin
// draw component Name
if ShowComponentCaptions and (((GetKeyState(VK_LBUTTON) and $80) = 0) or not IsSelected) then
begin
TextSize := aDDC.Canvas.TextExtent(AComponent.Name);
TextRect.Left := (IconRect.Left + IconRect.Right - TextSize.cx) div 2;
TextRect.Top := IconRect.Bottom + NonVisualCompBorder + 2;
TextRect.Right := TextRect.Left + TextSize.cx;
TextRect.Bottom := TextRect.Top + TextSize.cy;
aDDC.Canvas.FillRect(TextRect);
DrawText(aDDC.Canvas.Handle, PChar(AComponent.Name), -1, TextRect,
DT_CENTER or DT_VCENTER or DT_SINGLELINE or DT_NOCLIP);
// 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
// into account
Icon := TBitmap.Create;
try
TextSize := aDDC.Canvas.TextExtent(AComponent.Name);
Icon.SetSize(TextSize.cx, TextSize.cy);
TextRect := Rect(0, 0, TextSize.cx, TextSize.cy);
Icon.Canvas.Brush.Color := clBtnFace;
Icon.Canvas.FillRect(TextRect);
DrawText(Icon.Canvas.Handle, PChar(AComponent.Name), -1, TextRect,
DT_CENTER or DT_VCENTER or DT_SINGLELINE or DT_NOCLIP);
aDDC.Canvas.Draw(
(IconRect.Left + IconRect.Right - TextSize.cx) div 2,
IconRect.Bottom + NonVisualCompBorder + 2, Icon);
finally
Icon.Free;
end;
end;
// draw component icon
if Assigned(FOnGetNonVisualCompIcon) then

View File

@ -6389,9 +6389,10 @@ begin
Assert(False, Format('Trace:> TODO FINISH[TGtkWidgetSet.GetTextMetrics] DC: 0x%x', [DC]));
Result := IsValidDC(DC);
if Result then begin
UpdateDCTextMetric(TGtkDeviceContext(DC));
TM:=TGtkDeviceContext(DC).DCTextMetric.TextMetric;
if Result then
begin
UpdateDCTextMetric(DevCtx);
TM := DevCtx.DCTextMetric.TextMetric;
end;
Assert(False, Format('Trace:< TODO FINISH[TGtkWidgetSet.GetTextMetrics] DC: 0x%x', [DC]));