mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-10-01 01:49:24 +02:00
LCL-GTK2: Improve TextRect and regions. Issue #37219, patch from Joeny Ang.
git-svn-id: trunk@63436 -
This commit is contained in:
parent
fd9a80af09
commit
6c83a6da9e
@ -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));
|
||||
|
Loading…
Reference in New Issue
Block a user