mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-08-07 20:56:31 +02:00
Gtk2: formatting
git-svn-id: trunk@34065 -
This commit is contained in:
parent
4ee63e0524
commit
33b5efc277
@ -34,12 +34,12 @@ end;
|
|||||||
function TGtkDeviceContext.GetGDIObjects(ID: TGDIType): PGdiObject;
|
function TGtkDeviceContext.GetGDIObjects(ID: TGDIType): PGdiObject;
|
||||||
begin
|
begin
|
||||||
case ID of
|
case ID of
|
||||||
gdiBitmap: Result:=CurrentBitmap;
|
gdiBitmap: Result:=CurrentBitmap;
|
||||||
gdiFont: Result:=CurrentFont;
|
gdiFont: Result:=CurrentFont;
|
||||||
gdiBrush: Result:=CurrentBrush;
|
gdiBrush: Result:=CurrentBrush;
|
||||||
gdiPen: Result:=CurrentPen;
|
gdiPen: Result:=CurrentPen;
|
||||||
gdiPalette: Result:=CurrentPalette;
|
gdiPalette: Result:=CurrentPalette;
|
||||||
gdiRegion: Result:=ClipRegion;
|
gdiRegion: Result:=ClipRegion;
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
@ -70,8 +70,8 @@ function TGtkDeviceContext.GetOffset: TPoint;
|
|||||||
var
|
var
|
||||||
Fixed: Pointer;
|
Fixed: Pointer;
|
||||||
begin
|
begin
|
||||||
if Self = nil
|
if Self = nil then
|
||||||
then begin
|
begin
|
||||||
Result.X := 0;
|
Result.X := 0;
|
||||||
Result.Y := 0;
|
Result.Y := 0;
|
||||||
Exit;
|
Exit;
|
||||||
@ -107,8 +107,8 @@ end;
|
|||||||
procedure TGtkDeviceContext.SetCurrentBrush(const AValue: PGdiObject);
|
procedure TGtkDeviceContext.SetCurrentBrush(const AValue: PGdiObject);
|
||||||
begin
|
begin
|
||||||
ChangeGDIObject(FCurrentBrush,AValue);
|
ChangeGDIObject(FCurrentBrush,AValue);
|
||||||
if FSelectedColors = dcscBrush
|
if FSelectedColors = dcscBrush then
|
||||||
then FSelectedColors := dcscCustom;
|
FSelectedColors := dcscCustom;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TGtkDeviceContext.SetCurrentFont(const AValue: PGdiObject);
|
procedure TGtkDeviceContext.SetCurrentFont(const AValue: PGdiObject);
|
||||||
@ -126,8 +126,8 @@ end;
|
|||||||
procedure TGtkDeviceContext.SetCurrentPen(const AValue: PGdiObject);
|
procedure TGtkDeviceContext.SetCurrentPen(const AValue: PGdiObject);
|
||||||
begin
|
begin
|
||||||
ChangeGDIObject(FCurrentPen,AValue);
|
ChangeGDIObject(FCurrentPen,AValue);
|
||||||
if FSelectedColors = dcscPen
|
if FSelectedColors = dcscPen then
|
||||||
then FSelectedColors := dcscCustom;
|
FSelectedColors := dcscCustom;
|
||||||
if FHasTransf then
|
if FHasTransf then
|
||||||
TransfUpdatePen;
|
TransfUpdatePen;
|
||||||
end;
|
end;
|
||||||
@ -136,8 +136,8 @@ procedure TGtkDeviceContext.ChangeGDIObject(var GDIObject: PGdiObject;
|
|||||||
const NewValue: PGdiObject);
|
const NewValue: PGdiObject);
|
||||||
begin
|
begin
|
||||||
if GdiObject = NewValue then exit;
|
if GdiObject = NewValue then exit;
|
||||||
if GdiObject <> nil
|
if GdiObject <> nil then
|
||||||
then begin
|
begin
|
||||||
dec(GdiObject^.DCCount);
|
dec(GdiObject^.DCCount);
|
||||||
if GdiObject^.DCCount < 0 then
|
if GdiObject^.DCCount < 0 then
|
||||||
RaiseGDBException('');
|
RaiseGDBException('');
|
||||||
@ -146,8 +146,8 @@ begin
|
|||||||
|
|
||||||
GdiObject := NewValue;
|
GdiObject := NewValue;
|
||||||
|
|
||||||
if GdiObject <> nil
|
if GdiObject <> nil then
|
||||||
then begin
|
begin
|
||||||
inc(GdiObject^.DCCount);
|
inc(GdiObject^.DCCount);
|
||||||
ReferenceGDIObject(GDIObject);
|
ReferenceGDIObject(GDIObject);
|
||||||
end;
|
end;
|
||||||
@ -298,9 +298,10 @@ end;
|
|||||||
|
|
||||||
procedure TGtkDeviceContext.SetTextMetricsValid(AValid: Boolean);
|
procedure TGtkDeviceContext.SetTextMetricsValid(AValid: Boolean);
|
||||||
begin
|
begin
|
||||||
if AValid
|
if AValid then
|
||||||
then Include(FFlags, dcfTextMetricsValid)
|
Include(FFlags, dcfTextMetricsValid)
|
||||||
else Exclude(FFlags, dcfTextMetricsValid);
|
else
|
||||||
|
Exclude(FFlags, dcfTextMetricsValid);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TGtkDeviceContext.InvTransfPoint(var X1, Y1: Integer);
|
procedure TGtkDeviceContext.InvTransfPoint(var X1, Y1: Integer);
|
||||||
@ -490,36 +491,36 @@ procedure TGtkDeviceContext.SetWidget(AWidget: PGtkWidget; AWindow: PGdkWindow;
|
|||||||
var
|
var
|
||||||
ClientWidget: PGtkWidget;
|
ClientWidget: PGtkWidget;
|
||||||
begin
|
begin
|
||||||
if FWidget <> nil
|
if FWidget <> nil then
|
||||||
then RaiseWidgetAlreadySet;
|
RaiseWidgetAlreadySet;
|
||||||
|
|
||||||
FWithChildWindows := AWithChildWindows;
|
FWithChildWindows := AWithChildWindows;
|
||||||
FWidget := AWidget;
|
FWidget := AWidget;
|
||||||
|
|
||||||
if AWidget = nil
|
if AWidget = nil then
|
||||||
then begin
|
begin
|
||||||
// screen: ToDo: multiple desktops
|
// screen: ToDo: multiple desktops
|
||||||
FDrawable := gdk_screen_get_root_window(gdk_screen_get_default);
|
FDrawable := gdk_screen_get_root_window(gdk_screen_get_default);
|
||||||
end
|
end else
|
||||||
else begin
|
begin
|
||||||
if ADoubleBuffer <> nil
|
if ADoubleBuffer <> nil then
|
||||||
then begin
|
begin
|
||||||
Include(FFlags, dcfDoubleBuffer);
|
Include(FFlags, dcfDoubleBuffer);
|
||||||
FOriginalDrawable := AWindow;
|
FOriginalDrawable := AWindow;
|
||||||
FDrawable := ADoubleBuffer;
|
FDrawable := ADoubleBuffer;
|
||||||
end
|
end else
|
||||||
else begin
|
begin
|
||||||
// create a new devicecontext for this window
|
// create a new devicecontext for this window
|
||||||
Exclude(FFlags, dcfDoubleBuffer);
|
Exclude(FFlags, dcfDoubleBuffer);
|
||||||
|
|
||||||
if AWindow = nil
|
if AWindow = nil then
|
||||||
then begin
|
begin
|
||||||
ClientWidget := GetFixedWidget(AWidget);
|
ClientWidget := GetFixedWidget(AWidget);
|
||||||
if ClientWidget = nil then RaiseWidgetWithoutClientArea;
|
if ClientWidget = nil then RaiseWidgetWithoutClientArea;
|
||||||
|
|
||||||
AWindow := GetControlWindow(ClientWidget);
|
AWindow := GetControlWindow(ClientWidget);
|
||||||
if AWindow = nil
|
if AWindow = nil then
|
||||||
then begin
|
begin
|
||||||
//force creation
|
//force creation
|
||||||
gtk_widget_realize(ClientWidget);
|
gtk_widget_realize(ClientWidget);
|
||||||
AWindow := GetControlWindow(ClientWidget);
|
AWindow := GetControlWindow(ClientWidget);
|
||||||
@ -527,8 +528,8 @@ begin
|
|||||||
// http://bugs.freepascal.org/view.php?id=14035
|
// http://bugs.freepascal.org/view.php?id=14035
|
||||||
//if AWindow = nil then RaiseUnableToRealize;
|
//if AWindow = nil then RaiseUnableToRealize;
|
||||||
end;
|
end;
|
||||||
end
|
end else
|
||||||
else begin
|
begin
|
||||||
ClientWidget := AWidget;
|
ClientWidget := AWidget;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
@ -624,14 +625,14 @@ begin
|
|||||||
Result := (Self <> nil) and (ASource <> nil);
|
Result := (Self <> nil) and (ASource <> nil);
|
||||||
if not Result then Exit;
|
if not Result then Exit;
|
||||||
|
|
||||||
if ARestore
|
if ARestore then
|
||||||
then begin
|
begin
|
||||||
if FWidget <> ASource.FWidget
|
if FWidget <> ASource.FWidget then
|
||||||
then RaiseRestoreDifferentWidget;
|
RaiseRestoreDifferentWidget;
|
||||||
end
|
end else
|
||||||
else begin
|
begin
|
||||||
if FWidget <> nil
|
if FWidget <> nil then
|
||||||
then RaiseWidgetAlreadySet;
|
RaiseWidgetAlreadySet;
|
||||||
FWidget := ASource.FWidget;
|
FWidget := ASource.FWidget;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
@ -639,16 +640,16 @@ begin
|
|||||||
FDrawable := ASource.FDrawable;
|
FDrawable := ASource.FDrawable;
|
||||||
FOriginalDrawable := ASource.FOriginalDrawable;
|
FOriginalDrawable := ASource.FOriginalDrawable;
|
||||||
|
|
||||||
if FGC <> nil
|
if FGC <> nil then
|
||||||
then begin
|
begin
|
||||||
// free old GC
|
// free old GC
|
||||||
gdk_gc_unref(FGC);
|
gdk_gc_unref(FGC);
|
||||||
FGC := nil;
|
FGC := nil;
|
||||||
Exclude(FFlags, dcfPenSelected);
|
Exclude(FFlags, dcfPenSelected);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
if (ASource.FGC <> nil) and (FDrawable <> nil)
|
if (ASource.FGC <> nil) and (FDrawable <> nil) then
|
||||||
then begin
|
begin
|
||||||
gdk_gc_get_values(ASource.FGC, @FGCValues);
|
gdk_gc_get_values(ASource.FGC, @FGCValues);
|
||||||
FGC := gdk_gc_new_with_values(FDrawable, @FGCValues,
|
FGC := gdk_gc_new_with_values(FDrawable, @FGCValues,
|
||||||
GDK_GC_FOREGROUND or GDK_GC_BACKGROUND or GDK_GC_SUBWINDOW);
|
GDK_GC_FOREGROUND or GDK_GC_BACKGROUND or GDK_GC_SUBWINDOW);
|
||||||
@ -659,8 +660,8 @@ begin
|
|||||||
FSpecialOrigin := ASource.FSpecialOrigin;
|
FSpecialOrigin := ASource.FSpecialOrigin;
|
||||||
PenPos := ASource.PenPos;
|
PenPos := ASource.PenPos;
|
||||||
|
|
||||||
if dcfTextMetricsValid in ASource.Flags
|
if dcfTextMetricsValid in ASource.Flags then
|
||||||
then begin
|
begin
|
||||||
Include(FFlags, dcfTextMetricsValid);
|
Include(FFlags, dcfTextMetricsValid);
|
||||||
DCTextMetric := ASource.DCTextMetric;
|
DCTextMetric := ASource.DCTextMetric;
|
||||||
end
|
end
|
||||||
@ -673,17 +674,17 @@ begin
|
|||||||
if AClearSource then
|
if AClearSource then
|
||||||
ASource.GDIObjects[g] := nil;
|
ASource.GDIObjects[g] := nil;
|
||||||
|
|
||||||
if AMoveGDIOwnerShip
|
if AMoveGDIOwnerShip then
|
||||||
then begin
|
begin
|
||||||
if OwnedGDIObjects[g]<>nil
|
if OwnedGDIObjects[g]<>nil then
|
||||||
then begin
|
begin
|
||||||
DeleteObject(HGDIOBJ(PtrUInt(OwnedGDIObjects[g])));
|
DeleteObject(HGDIOBJ(PtrUInt(OwnedGDIObjects[g])));
|
||||||
end;
|
end;
|
||||||
|
|
||||||
CurGDIObject := ASource.OwnedGDIObjects[g];
|
CurGDIObject := ASource.OwnedGDIObjects[g];
|
||||||
|
|
||||||
if CurGDIObject<>nil
|
if CurGDIObject<>nil then
|
||||||
then begin
|
begin
|
||||||
ASource.OwnedGDIObjects[g] := nil;
|
ASource.OwnedGDIObjects[g] := nil;
|
||||||
OwnedGDIObjects[g] := CurGDIObject;
|
OwnedGDIObjects[g] := CurGDIObject;
|
||||||
end;
|
end;
|
||||||
@ -795,8 +796,8 @@ begin
|
|||||||
if FCurrentFont <> nil then exit;
|
if FCurrentFont <> nil then exit;
|
||||||
|
|
||||||
// create font
|
// create font
|
||||||
if FWidget <> nil
|
if FWidget <> nil then
|
||||||
then begin
|
begin
|
||||||
ClientWidget := GetFixedWidget(FWidget);
|
ClientWidget := GetFixedWidget(FWidget);
|
||||||
|
|
||||||
NewFont := Gtk2Widgetset.NewGDIObject(gdiFont);
|
NewFont := Gtk2Widgetset.NewGDIObject(gdiFont);
|
||||||
@ -832,19 +833,19 @@ function TGtkDeviceContext.CreateGC: PGdkGC;
|
|||||||
begin
|
begin
|
||||||
// create GC
|
// create GC
|
||||||
|
|
||||||
if Drawable <> nil
|
if Drawable <> nil then
|
||||||
then begin
|
begin
|
||||||
if FWithChildWindows
|
if FWithChildWindows then
|
||||||
then begin
|
begin
|
||||||
FillChar(FGCValues, SizeOf(FGCValues), 0);
|
FillChar(FGCValues, SizeOf(FGCValues), 0);
|
||||||
FGCValues.subwindow_mode := GDK_INCLUDE_INFERIORS;
|
FGCValues.subwindow_mode := GDK_INCLUDE_INFERIORS;
|
||||||
Result := gdk_gc_new_with_values(Drawable, @FGCValues, GDK_GC_FUNCTION or GDK_GC_SUBWINDOW);
|
Result := gdk_gc_new_with_values(Drawable, @FGCValues, GDK_GC_FUNCTION or GDK_GC_SUBWINDOW);
|
||||||
end
|
end else
|
||||||
else begin
|
begin
|
||||||
Result := gdk_gc_new(Drawable);
|
Result := gdk_gc_new(Drawable);
|
||||||
end;
|
end;
|
||||||
end
|
end else
|
||||||
else begin
|
begin
|
||||||
// create default GC
|
// create default GC
|
||||||
Result := gdk_gc_new(gdk_screen_get_root_window(gdk_screen_get_default));
|
Result := gdk_gc_new(gdk_screen_get_root_window(gdk_screen_get_default));
|
||||||
end;
|
end;
|
||||||
@ -883,31 +884,31 @@ end;
|
|||||||
|
|
||||||
function TGtkDeviceContext.GetGC: pgdkGC;
|
function TGtkDeviceContext.GetGC: pgdkGC;
|
||||||
begin
|
begin
|
||||||
if FGC = nil
|
if FGC = nil then
|
||||||
then FGC := CreateGC;
|
FGC := CreateGC;
|
||||||
Result := FGC;
|
Result := FGC;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
function TGtkDeviceContext.GetFont: PGdiObject;
|
function TGtkDeviceContext.GetFont: PGdiObject;
|
||||||
begin
|
begin
|
||||||
if FCurrentFont = nil
|
if FCurrentFont = nil then
|
||||||
then CreateFont;
|
CreateFont;
|
||||||
|
|
||||||
Result := FCurrentFont;
|
Result := FCurrentFont;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
function TGtkDeviceContext.GetBrush: PGdiObject;
|
function TGtkDeviceContext.GetBrush: PGdiObject;
|
||||||
begin
|
begin
|
||||||
if FCurrentBrush = nil
|
if FCurrentBrush = nil then
|
||||||
then CreateBrush;
|
CreateBrush;
|
||||||
|
|
||||||
Result := FCurrentBrush;
|
Result := FCurrentBrush;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
function TGtkDeviceContext.GetPen: PGdiObject;
|
function TGtkDeviceContext.GetPen: PGdiObject;
|
||||||
begin
|
begin
|
||||||
if FCurrentPen = nil
|
if FCurrentPen = nil then
|
||||||
then CreatePen;
|
CreatePen;
|
||||||
|
|
||||||
Result := FCurrentPen;
|
Result := FCurrentPen;
|
||||||
end;
|
end;
|
||||||
@ -999,8 +1000,8 @@ begin
|
|||||||
// no drawable: this is normal, when restoring the default bitmap (FreeDC)
|
// no drawable: this is normal, when restoring the default bitmap (FreeDC)
|
||||||
if NewDrawable = nil then Exit;
|
if NewDrawable = nil then Exit;
|
||||||
|
|
||||||
if FGC <> nil
|
if FGC <> nil then
|
||||||
then gdk_gc_unref(FGC);
|
gdk_gc_unref(FGC);
|
||||||
FDrawable := NewDrawable;
|
FDrawable := NewDrawable;
|
||||||
FGC := gdk_gc_new(FDrawable);
|
FGC := gdk_gc_new(FDrawable);
|
||||||
gdk_gc_set_function(FGC, GDK_COPY);
|
gdk_gc_set_function(FGC, GDK_COPY);
|
||||||
@ -1053,8 +1054,8 @@ begin
|
|||||||
|
|
||||||
CurrentPen := AGDIObject;
|
CurrentPen := AGDIObject;
|
||||||
Exclude(FFlags, dcfPenSelected);
|
Exclude(FFlags, dcfPenSelected);
|
||||||
if FGC <> nil
|
if FGC <> nil then
|
||||||
then SelectPenProps;
|
SelectPenProps;
|
||||||
SelectedColors := dcscCustom;
|
SelectedColors := dcscCustom;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
@ -1189,11 +1190,11 @@ begin
|
|||||||
gdk_gc_set_clip_region(FGC, nil);
|
gdk_gc_set_clip_region(FGC, nil);
|
||||||
gdk_gc_set_clip_rectangle(FGC, nil);
|
gdk_gc_set_clip_rectangle(FGC, nil);
|
||||||
|
|
||||||
if ClipRegion <> nil
|
if ClipRegion <> nil then
|
||||||
then begin
|
begin
|
||||||
RGNType := RegionType(ClipRegion^.GDIRegionObject);
|
RGNType := RegionType(ClipRegion^.GDIRegionObject);
|
||||||
if (RGNType <> ERROR) and (RGNType <> NULLREGION)
|
if (RGNType <> ERROR) and (RGNType <> NULLREGION) then
|
||||||
then gdk_gc_set_clip_region(FGC, ClipRegion^.GDIRegionObject);
|
gdk_gc_set_clip_region(FGC, ClipRegion^.GDIRegionObject);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
{$IFDEF DebugGDK}EndGDKErrorTrap;{$ENDIF}
|
{$IFDEF DebugGDK}EndGDKErrorTrap;{$ENDIF}
|
||||||
@ -1214,8 +1215,8 @@ end;
|
|||||||
|
|
||||||
function TGtkDeviceContext.GetBitmap: PGdiObject;
|
function TGtkDeviceContext.GetBitmap: PGdiObject;
|
||||||
begin
|
begin
|
||||||
if FCurrentBitmap = nil
|
if FCurrentBitmap = nil then
|
||||||
then CreateBitmap;
|
CreateBitmap;
|
||||||
|
|
||||||
Result := FCurrentBitmap;
|
Result := FCurrentBitmap;
|
||||||
end;
|
end;
|
||||||
|
Loading…
Reference in New Issue
Block a user