Commit 6c83a6da authored by Juha Manninen's avatar Juha Manninen
Browse files

LCL-GTK2: Improve TextRect and regions. Issue #37219, patch from Joeny Ang.

git-svn-id: trunk@63436 -
parent fd9a80af
......@@ -6046,9 +6046,19 @@ end;
function TGtk2WidgetSet.CreateEmptyRegion: hRGN;
var
GObject: PGdiObject;
R: TGDKRectangle;
RegionObj: PGdkRegion;
RRGN: PGDKRegion;
begin
GObject := NewGDIObject(gdiRegion);
GObject^.GDIRegionObject := gdk_region_new;
R.x := -1;
R.y := -1;
R.width := 1;
R.height := 1;
RRGN := gdk_region_new;
RegionObj := PGdkRegion(gdk_region_union_with_rect(RRGN,@R));
GObject^.GDIRegionObject := RegionObj;
gdk_region_destroy(RRGN);
Result := HRGN({%H-}PtrUInt(GObject));
//DebugLn('TGtk2WidgetSet.CreateEmptyRgn A RGN=',DbgS(Result));
end;
......
......@@ -1866,6 +1866,13 @@ begin
Result := RegionType(D);
//DebugLn('TGtk2WidgetSet.CombineRgn B Mode=',dbgs(fnCombineMode),
// ' S1=',GDKRegionAsString(S1),' S2=',GDKRegionAsString(S2),' D=',GDKRegionAsString(D),'');
if (Result = NullRegion) and
((RegionType(S1) <> NullRegion) or ((RegionType(S2) <> NullRegion))) then
begin
DeleteObject(Dest);
Dest := CreateEmptyRegion;
Result := RegionType(D);
end;
end;
end;
......@@ -7535,28 +7542,20 @@ end;
function TGtk2WidgetSet.RestoreDC(DC: HDC; SavedDC: Integer): Boolean;
var
DevCtx: TGtkDeviceContext absolute DC;
SavedDevCtx: TGtkDeviceContext;
ClipRegionChanged: Boolean;
begin
if not IsValidDC(DC) then Exit(False);
if SavedDC <= 0 then Exit(False);
repeat
SavedDevCtx := DevCtx.SavedContext;
Dec(SavedDC);
// TODO copy bitmap too
ClipRegionChanged := DevCtx.ClipRegion <> SavedDevCtx.ClipRegion;
// clear the GDIObjects in pSavedDC, so they are not freed by DeleteDC
Result := DevCtx.CopyDataFrom(SavedDevCtx, True, True, True);
DevCtx.SavedContext := SavedDevCtx.SavedContext;
SavedDevCtx.SavedContext := nil;
if ClipRegionChanged then
DevCtx.SelectRegion;
DevCtx.SelectRegion;
// free saved DC
DeleteDC(HDC(SavedDevCtx));
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment