mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-09-08 09:39:06 +02:00
gtk2 intf: the GC of device contexts are now created only when needed
git-svn-id: trunk@11106 -
This commit is contained in:
parent
cc70f5376b
commit
6a41acd5f4
@ -185,13 +185,18 @@ type
|
||||
dcscFont
|
||||
);
|
||||
|
||||
{ TDeviceContext }
|
||||
|
||||
TDeviceContext = class
|
||||
public
|
||||
WithChildWindows: boolean;// this DC covers sub gdkwindows
|
||||
|
||||
// device handles
|
||||
DCWidget: PGtkWidget; // the owner
|
||||
GC: pgdkGC;
|
||||
Drawable: PGDKDrawable;
|
||||
OriginalDrawable: PGDKDrawable; // only set if dcfDoubleBuffer in DCFlags
|
||||
GC: pgdkGC;
|
||||
GCValues: TGdkGCValues;
|
||||
|
||||
// origins
|
||||
Origin: TPoint;
|
||||
@ -217,7 +222,9 @@ type
|
||||
SelectedColors: TDevContextSelectedColorsType;
|
||||
SavedContext: TDeviceContext; // linked list of saved DCs
|
||||
DCFlags: TDeviceContextsFlags;
|
||||
|
||||
procedure Clear;
|
||||
function GetGC: pgdkGC;
|
||||
end;
|
||||
|
||||
|
||||
@ -388,6 +395,11 @@ procedure InternalDisposePGDIObject(GDIObject: PGdiObject);
|
||||
function NewDeviceContext: TDeviceContext;
|
||||
procedure DisposeDeviceContext(DeviceContext: TDeviceContext);
|
||||
|
||||
type
|
||||
TCreateGCForDC = procedure(DC: TDeviceContext) of object;
|
||||
var
|
||||
CreateGCForDC: TCreateGCForDC = nil;
|
||||
|
||||
{$IFDEF DebugLCLComponents}
|
||||
var
|
||||
DebugGtkWidgets: TDebugLCLItems = nil;
|
||||
@ -397,7 +409,6 @@ var
|
||||
|
||||
procedure GtkDefDone;
|
||||
|
||||
|
||||
implementation
|
||||
|
||||
|
||||
@ -587,8 +598,9 @@ end;
|
||||
procedure TDeviceContext.Clear;
|
||||
begin
|
||||
DCWidget:=nil;
|
||||
GC:=nil;
|
||||
Drawable:=nil;
|
||||
GC:=nil;
|
||||
FillChar(GCValues, SizeOf(GCValues), #0);
|
||||
|
||||
Origin.X:=0;
|
||||
Origin.Y:=0;
|
||||
@ -610,6 +622,13 @@ begin
|
||||
DCFlags:=[];
|
||||
end;
|
||||
|
||||
function TDeviceContext.GetGC: pgdkGC;
|
||||
begin
|
||||
if GC=nil then
|
||||
CreateGCForDC(Self);
|
||||
Result:=GC;
|
||||
end;
|
||||
|
||||
procedure GtkDefInit;
|
||||
begin
|
||||
{$IFDEF DebugLCLComponents}
|
||||
|
@ -243,6 +243,7 @@ type
|
||||
procedure RemoveCallbacks(Widget: PGtkWidget); virtual;
|
||||
function ROP2ModeToGdkFunction(Mode: Integer): TGdkFunction;
|
||||
function gdkFunctionToROP2Mode(aFunction: TGdkFunction): Integer;
|
||||
procedure OnCreateGCForDC(DC: TDeviceContext);
|
||||
|
||||
// for gtk specific components:
|
||||
procedure SetLabelCaption(const ALabel: PGtkLabel; const ACaption: String;
|
||||
|
@ -175,6 +175,7 @@ begin
|
||||
// DCs, GDIObjects
|
||||
FDeviceContexts := TDynHashArray.Create(-1);
|
||||
FDeviceContexts.Options:=FDeviceContexts.Options+[dhaoCacheContains];
|
||||
CreateGCForDC:=@OnCreateGCForDC;
|
||||
FGDIObjects := TDynHashArray.Create(-1);
|
||||
FGDIObjects.Options:=FGDIObjects.Options+[dhaoCacheContains];
|
||||
|
||||
@ -3078,7 +3079,7 @@ var
|
||||
SelectGDKBrushProps(DC);
|
||||
|
||||
If not CurrentBrush^.IsNullBrush then begin
|
||||
gdk_draw_rectangle(TempPixmap, GC, 1, 0, 0, Width, Height);
|
||||
gdk_draw_rectangle(TempPixmap, GetGC, 1, 0, 0, Width, Height);
|
||||
end;
|
||||
// Restore current brush
|
||||
SelectedColors := dcscCustom;
|
||||
@ -3117,7 +3118,7 @@ var
|
||||
{$IFDEF VerboseStretchCopyArea}
|
||||
DebugLn('SrcDevBitmapToDrawable Simple copy');
|
||||
{$ENDIF}
|
||||
gdk_window_copy_area(DestDevContext.Drawable, DestDevContext.GC, X, Y,
|
||||
gdk_window_copy_area(DestDevContext.Drawable, DestDevContext.GetGC, X, Y,
|
||||
SrcPixmap, XSrc, YSrc, Width, Height);
|
||||
|
||||
exit;
|
||||
@ -3129,7 +3130,7 @@ var
|
||||
|
||||
// perform raster operation and scaling into Scale and fGC
|
||||
DestDevContext.SelectedColors := dcscCustom;
|
||||
If not ScaleAndROP(DestDevContext.GC, SrcDevContext.Drawable, SrcPixmap,
|
||||
If not ScaleAndROP(DestDevContext.GetGC, SrcDevContext.Drawable, SrcPixmap,
|
||||
MaskPixmap)
|
||||
then begin
|
||||
DebugLn('WARNING: SrcDevBitmapToDrawable: ScaleAndROP failed');
|
||||
@ -3168,20 +3169,20 @@ var
|
||||
{$ENDIF}
|
||||
|
||||
// set clipping mask for transparency
|
||||
MergeClipping(DestDevContext, DestDevContext.GC, X,Y,Width,Height,
|
||||
MergeClipping(DestDevContext, DestDevContext.GetGC, X,Y,Width,Height,
|
||||
MaskPixmap,XMask,YMask,
|
||||
NewClipMask);
|
||||
|
||||
// draw image
|
||||
{$IFDEF DebugGDK}BeginGDKErrorTrap;{$ENDIF}
|
||||
gdk_window_copy_area(DestDevContext.Drawable, DestDevContext.GC, X, Y,
|
||||
gdk_window_copy_area(DestDevContext.Drawable, DestDevContext.GetGC, X, Y,
|
||||
SrcPixmap, XSrc, YSrc, SrcWidth, SrcHeight);
|
||||
{$IFDEF DebugGDK}EndGDKErrorTrap;{$ENDIF}
|
||||
// unset clipping mask for transparency
|
||||
ResetClipping(DestDevContext.GC);
|
||||
ResetClipping(DestDevContext.GetGC);
|
||||
|
||||
// restore raster operation to SRCCOPY
|
||||
GDK_GC_Set_Function(DestDevContext.GC, GDK_Copy);
|
||||
GDK_GC_Set_Function(DestDevContext.GetGC, GDK_Copy);
|
||||
|
||||
Result:=True;
|
||||
end;
|
||||
@ -6130,9 +6131,9 @@ begin
|
||||
|
||||
aDC.SelectedColors := dcscCustom;
|
||||
GDKColor:=AllocGDKColor(AColor);
|
||||
gdk_gc_set_foreground(aDC.GC, @GDKColor);
|
||||
gdk_gc_set_foreground(aDC.GetGC, @GDKColor);
|
||||
{$IFDEF DebugGDK}BeginGDKErrorTrap;{$ENDIF}
|
||||
gdk_draw_point(aDC.Drawable, aDC.GC, X, Y);
|
||||
gdk_draw_point(aDC.Drawable, aDC.GetGC, X, Y);
|
||||
{$IFDEF DebugGDK}EndGDKErrorTrap;{$ENDIF}
|
||||
end;
|
||||
|
||||
@ -6141,7 +6142,6 @@ var
|
||||
fWindow :pGdkWindow;
|
||||
widget : PgtkWIdget;
|
||||
PixMap : pgdkPixMap;
|
||||
//gc : PGDKGc;
|
||||
Child: PGtkWidget;
|
||||
begin
|
||||
Assert(False, 'Trace:In AutoRedraw in GTKObject');
|
||||
@ -6151,7 +6151,6 @@ begin
|
||||
pixmap := gtk_Object_get_data(pgtkobject(Child),'Pixmap');
|
||||
if PixMap = nil then Exit;
|
||||
fWindow := GetControlWindow(widget);
|
||||
//gc := gdk_gc_new(PgdkWindow(fWindow));
|
||||
|
||||
if fWindow<>nil then begin
|
||||
{$IFDEF DebugGDK}BeginGDKErrorTrap;{$ENDIF}
|
||||
@ -6306,8 +6305,8 @@ begin
|
||||
|
||||
If GDIBrushFill <> GDK_Solid then
|
||||
If GDIBrushPixmap <> nil then begin
|
||||
gdk_gc_set_fill(GC, GDIBrushFill);
|
||||
gdk_gc_set_Stipple(GC,GDIBrushPixmap);
|
||||
gdk_gc_set_fill(GetGC, GDIBrushFill);
|
||||
gdk_gc_set_Stipple(GetGC,GDIBrushPixmap);
|
||||
end
|
||||
end;
|
||||
TDeviceContext(DC).SelectedColors:=dcscBrush;
|
||||
@ -6344,7 +6343,7 @@ procedure TGtkWidgetSet.SelectGDKPenProps(DC: HDC);
|
||||
procedure SetDashes(const Dashes: array of gint8);
|
||||
begin
|
||||
{$IFDEF DebugGDK}BeginGDKErrorTrap;{$ENDIF}
|
||||
laz_gdk_gc_set_dashes(TDeviceContext(DC).GC,0,Pgint8(@Dashes[Low(Dashes)]),
|
||||
laz_gdk_gc_set_dashes(TDeviceContext(DC).GetGC,0,Pgint8(@Dashes[Low(Dashes)]),
|
||||
High(Dashes)-Low(Dashes)+1);
|
||||
{$IFDEF DebugGDK}EndGDKErrorTrap;{$ENDIF}
|
||||
end;
|
||||
@ -6360,7 +6359,7 @@ begin
|
||||
|
||||
if (not (dcfPenSelected in TDeviceContext(DC).DCFlags)) then begin
|
||||
Exclude(TDeviceContext(DC).DCFlags,dcfPenInvalid);
|
||||
if TDeviceContext(DC).GC<>nil then begin
|
||||
if TDeviceContext(DC).GetGC<>nil then begin
|
||||
with TDeviceContext(DC), CurrentPen^ do
|
||||
begin
|
||||
IsNullPen := GDIPenStyle = PS_NULL;
|
||||
@ -6447,11 +6446,11 @@ var
|
||||
aDC: TDeviceContext;
|
||||
ClientWidget: PGtkWidget;
|
||||
FontGdiObject: PGdiObject;
|
||||
GCValues: TGdkGCValues;
|
||||
begin
|
||||
aDC := nil;
|
||||
|
||||
aDC := NewDC;
|
||||
aDC.WithChildWindows := WithChildWindows;
|
||||
aDC.DCWidget := TheWidget;
|
||||
|
||||
FontGdiObject := nil;
|
||||
@ -6460,7 +6459,6 @@ begin
|
||||
if TheWidget = nil
|
||||
then begin
|
||||
// screen: ToDo: multiple desktops
|
||||
FillChar(GCValues, SizeOf(GCValues), #0);
|
||||
end
|
||||
else begin
|
||||
// create a new devicecontext for this window
|
||||
@ -6479,29 +6477,19 @@ begin
|
||||
ClientWidget:=TheWidget;
|
||||
aDC.SpecialOrigin:=GtkWidgetIsA(ClientWidget,GTK_LAYOUT_GET_TYPE);
|
||||
aDC.Drawable := TheWindow;
|
||||
// create GC
|
||||
if WithChildWindows then begin
|
||||
//DebugLn('TGtkWidgetSet.CreateDCForWidget A WithChildWindows');
|
||||
FillChar(GCValues, SizeOf(GCValues), #0);
|
||||
GCValues.subwindow_mode := GDK_INCLUDE_INFERIORS;
|
||||
aDC.GC := gdk_gc_new_with_values(aDC.Drawable,
|
||||
@GCValues,GDK_GC_FUNCTION or GDK_GC_SUBWINDOW);
|
||||
end else begin
|
||||
aDC.GC := gdk_gc_new(aDC.Drawable);
|
||||
end;
|
||||
gdk_gc_set_function(aDC.GC, GDK_COPY);
|
||||
|
||||
gdk_gc_get_values(aDC.GC, @GCValues);
|
||||
{$IFDEF Gtk1}
|
||||
aDC.GetGC;
|
||||
{$ENDIF}
|
||||
end;
|
||||
|
||||
if aDC <> nil
|
||||
then begin
|
||||
{$Ifdef GTK1}
|
||||
// ToDo: create font on demand
|
||||
if GCValues.Font <> nil
|
||||
if aDC.GCValues.Font <> nil
|
||||
then begin
|
||||
FontGdiObject:=NewGDIObject(gdiFont);
|
||||
FontGdiObject^.GDIFontObject := GCValues.Font;
|
||||
FontGdiObject^.GDIFontObject := aDC.GCValues.Font;
|
||||
FontCache.Reference(FontGdiObject^.GDIFontObject);
|
||||
end
|
||||
else FontGdiObject := CreateDefaultFont;
|
||||
@ -6524,7 +6512,7 @@ begin
|
||||
end;
|
||||
|
||||
Result := HDC(aDC);
|
||||
Assert(False, Format('trace:< [TGtkWidgetSet.GetDC] Got 0x%x', [Result]));
|
||||
Assert(False, Format('trace:< [TGtkWidgetSet.CreateDCForWidget] Got 0x%x', [Result]));
|
||||
end;
|
||||
|
||||
{------------------------------------------------------------------------------
|
||||
@ -6542,6 +6530,7 @@ var
|
||||
DevContext: TDeviceContext;
|
||||
CaretWasVisible: Boolean;
|
||||
MainWidget: PGtkWidget;
|
||||
GC: PGdkGC;
|
||||
//LCLObject: TObject;
|
||||
//x, y: integer;
|
||||
begin
|
||||
@ -6595,14 +6584,16 @@ begin
|
||||
Include(DevContext.DCFlags,dcfDoubleBuffer);
|
||||
|
||||
if BufferCreated then begin
|
||||
// create GC
|
||||
GC:=DevContext.GetGC;
|
||||
// copy old context to buffer
|
||||
gdk_gc_set_clip_region(DevContext.GC, nil);
|
||||
gdk_gc_set_clip_rectangle(DevContext.GC, nil);
|
||||
gdk_gc_set_clip_region(GC, nil);
|
||||
gdk_gc_set_clip_rectangle(GC, nil);
|
||||
|
||||
// hide caret
|
||||
HideCaretOfWidgetGroup(Widget,MainWidget,CaretWasVisible);
|
||||
// copy
|
||||
gdk_window_copy_area(DoubleBuffer, DevContext.GC,0,0,
|
||||
gdk_window_copy_area(DoubleBuffer, GC,0,0,
|
||||
Widget^.Window,0,0,Width,Height);
|
||||
|
||||
{LCLObject:=GetParentLCLObject(Widget);
|
||||
@ -7418,6 +7409,39 @@ begin
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure TGTKWidgetSet.OnCreateGCForDC(DC: TDeviceContext);
|
||||
var
|
||||
CurWidget: PGtkWidget;
|
||||
CurWindow: PGdkWindow;
|
||||
begin
|
||||
if DC.GC=nil then begin
|
||||
// create GC
|
||||
if DC.Drawable<>nil then begin
|
||||
if DC.WithChildWindows then begin
|
||||
FillChar(DC.GCValues, SizeOf(DC.GCValues), #0);
|
||||
DC.GCValues.subwindow_mode := GDK_INCLUDE_INFERIORS;
|
||||
DC.GC:=gdk_gc_new_with_values(DC.Drawable,
|
||||
@DC.GCValues,GDK_GC_FUNCTION or GDK_GC_SUBWINDOW);
|
||||
end else begin
|
||||
DC.GC:=gdk_gc_new(DC.Drawable);
|
||||
end;
|
||||
end else begin
|
||||
// create default GC
|
||||
{$IFDEF Gtk1}
|
||||
CurWidget:=GetStyleWidget(lgsWindow);
|
||||
CurWindow:=CurWidget^.window;
|
||||
DC.GC:=gdk_gc_new(CurWindow);
|
||||
{$ELSE}
|
||||
DC.GC:=gdk_gc_new(gdk_screen_get_root_window(gdk_screen_get_default));
|
||||
{$ENDIF}
|
||||
end;
|
||||
if DC.GC<>nil then begin
|
||||
gdk_gc_set_function(DC.GC, GDK_COPY);
|
||||
gdk_gc_get_values(DC.GC, @DC.GCValues);
|
||||
end;
|
||||
end;
|
||||
end;
|
||||
|
||||
function TGtkWidgetSet.ForceLineBreaks(DC : hDC; Src: PChar; MaxWidthInPixels : Longint;
|
||||
ProcessAmpersands : Boolean) : PChar;
|
||||
var
|
||||
|
@ -1421,8 +1421,6 @@ end;
|
||||
Creates a copy DC from the given DC
|
||||
------------------------------------------------------------------------------}
|
||||
function CopyDCData(DestinationDC, SourceDC: TDeviceContext): Boolean;
|
||||
var
|
||||
GCValues: TGDKGCValues;
|
||||
begin
|
||||
// Assert(False, Format('Trace:> [CopyDCData] DestDC:0x%x, SourceDC:0x%x', [Integer(DestinationDC), Integer(SourceDC)]));
|
||||
Result := (DestinationDC <> nil) and (SourceDC <> nil);
|
||||
@ -1433,6 +1431,7 @@ begin
|
||||
DCWidget := SourceDC.DCWidget;
|
||||
Drawable := SourceDC.Drawable;
|
||||
if GC<>nil then begin
|
||||
// free old GC
|
||||
BeginGDKErrorTrap;
|
||||
gdk_gc_unref(GC);
|
||||
EndGDKErrorTrap;
|
||||
@ -1515,13 +1514,13 @@ begin
|
||||
{$IFDEF DebugGDK}
|
||||
BeginGDKErrorTrap;
|
||||
{$ENDIF}
|
||||
gdk_gc_set_clip_region(gc, nil);
|
||||
gdk_gc_set_clip_rectangle (gc, nil);
|
||||
gdk_gc_set_clip_region(GetGC, nil);
|
||||
gdk_gc_set_clip_rectangle (GetGC, nil);
|
||||
If (ClipRegion <> 0) then begin
|
||||
Region:=PGDIObject(ClipRegion);
|
||||
RGNType := RegionType(Region^.GDIRegionObject);
|
||||
If (RGNType <> ERROR) and (RGNType <> NULLREGION) then begin
|
||||
gdk_gc_set_clip_region(gc, PGDIObject(ClipRegion)^.GDIRegionObject);
|
||||
gdk_gc_set_clip_region(GetGC, PGDIObject(ClipRegion)^.GDIRegionObject);
|
||||
end;
|
||||
end;
|
||||
{$IFDEF DebugGDK}
|
||||
@ -1685,7 +1684,7 @@ var
|
||||
end;
|
||||
|
||||
begin
|
||||
GC:=TDeviceContext(DC).GC;
|
||||
GC:=TDeviceContext(DC).GetGC;
|
||||
GDIColor:=nil;
|
||||
with TDeviceContext(DC) do
|
||||
begin
|
||||
@ -7330,7 +7329,7 @@ begin
|
||||
GetStyleWithName(WName);
|
||||
// return widget
|
||||
l:=IndexOfStyleWithName(WName);
|
||||
If l>=0 then
|
||||
if l>=0 then
|
||||
Result := PStyleObject(Styles.Objects[l])^.Widget;
|
||||
end;
|
||||
|
||||
|
@ -62,12 +62,6 @@ begin
|
||||
if Result
|
||||
then with TDeviceContext(DC) do
|
||||
begin
|
||||
if GC = nil
|
||||
then begin
|
||||
DebugLn('WARNING: [TGtkWidgetSet.Arc] Uninitialized GC');
|
||||
Result := False;
|
||||
end
|
||||
else begin
|
||||
// Draw outline
|
||||
SelectGDKPenProps(DC);
|
||||
|
||||
@ -81,14 +75,13 @@ begin
|
||||
inc(Right,DCOrigin.X);
|
||||
inc(Bottom,DCOrigin.Y);
|
||||
{$IFDEF DebugGDKTraps}BeginGDKErrorTrap;{$ENDIF}
|
||||
gdk_draw_arc(Drawable, GC, 0, left, top, right - left, bottom - top,
|
||||
gdk_draw_arc(Drawable, GetGC, 0, left, top, right - left, bottom - top,
|
||||
Angle1*4, Angle2*4);
|
||||
{$IFDEF DebugGDKTraps}EndGDKErrorTrap;{$ENDIF}
|
||||
end else
|
||||
Result:=false;
|
||||
end;
|
||||
end;
|
||||
end;
|
||||
|
||||
{------------------------------------------------------------------------------
|
||||
Method: AngleChord
|
||||
@ -105,19 +98,8 @@ end;
|
||||
function TGtkWidgetSet.AngleChord(DC: HDC;
|
||||
x1, y1, x2, y2, angle1, angle2: Integer): Boolean;
|
||||
begin
|
||||
Result := IsValidDC(DC);
|
||||
if Result
|
||||
then with TDeviceContext(DC) do
|
||||
begin
|
||||
if GC = nil
|
||||
then begin
|
||||
DebugLn('WARNING: [TGtkWidgetSet.AngleChord] Uninitialized GC');
|
||||
Result := False;
|
||||
end
|
||||
else
|
||||
Result := Inherited AngleChord(DC, x1, y1, x2, y2, angle1, angle2);
|
||||
end;
|
||||
end;
|
||||
|
||||
{------------------------------------------------------------------------------
|
||||
Function: BeginPaint
|
||||
@ -2775,7 +2757,7 @@ var
|
||||
begin
|
||||
inc(X1,Origin.X);
|
||||
inc(Y1,Origin.Y);
|
||||
gdk_draw_point(TDeviceContext(DC).Drawable, TDeviceContext(DC).GC, X1, Y1);
|
||||
gdk_draw_point(TDeviceContext(DC).Drawable, TDeviceContext(DC).GetGC, X1, Y1);
|
||||
end;
|
||||
|
||||
procedure DrawVertLine(X1,Y1,Y2: integer);
|
||||
@ -2889,12 +2871,6 @@ begin
|
||||
if Result
|
||||
then with TDeviceContext(DC) do
|
||||
begin
|
||||
if GC = nil
|
||||
then begin
|
||||
Assert(False, 'Trace:[TGtkWidgetSet.DrawEdge] Uninitialized GC');
|
||||
Result := False;
|
||||
end
|
||||
else begin
|
||||
R := ARect;
|
||||
DCOrigin:=GetDCOffset(TDeviceContext(DC));
|
||||
OffsetRect(R,DCOrigin.X,DCOrigin.Y);
|
||||
@ -2929,16 +2905,16 @@ begin
|
||||
BOuter := True;
|
||||
end;
|
||||
|
||||
gdk_gc_set_fill(GC, GDK_SOLID);
|
||||
gdk_gc_set_fill(GetGC, GDK_SOLID);
|
||||
SelectedColors := dcscCustom;
|
||||
|
||||
// Draw outer rect
|
||||
if BOuter then
|
||||
DrawEdges(R,GC,Drawable,OuterTL,OuterBR);
|
||||
DrawEdges(R,GetGC,Drawable,OuterTL,OuterBR);
|
||||
|
||||
// Draw inner rect
|
||||
if BInner then
|
||||
DrawEdges(R,GC,Drawable,InnerTL,InnerBR);
|
||||
DrawEdges(R,GetGC,Drawable,InnerTL,InnerBR);
|
||||
|
||||
// gdk_colormap_free_colors(gdk_colormap_get_system, @OuterTL, 1);
|
||||
// gdk_colormap_free_colors(gdk_colormap_get_system, @OuterBR, 1);
|
||||
@ -2956,10 +2932,10 @@ begin
|
||||
if (CurrentBrush^.GDIBrushFill = GDK_SOLID)
|
||||
and (IsBackgroundColor(TColor(CurrentBrush^.GDIBrushColor.ColorRef)))
|
||||
then
|
||||
StyleFillRectangle(Drawable, GC, CurrentBrush^.GDIBrushColor.ColorRef,
|
||||
StyleFillRectangle(Drawable, GetGC, CurrentBrush^.GDIBrushColor.ColorRef,
|
||||
R.Left, R.Top, Width, Height)
|
||||
else
|
||||
gdk_draw_rectangle(Drawable, GC, 1, R.Left, R.Top, Width, Height);
|
||||
gdk_draw_rectangle(Drawable, GetGC, 1, R.Left, R.Top, Width, Height);
|
||||
end;
|
||||
|
||||
// adjust rect if needed
|
||||
@ -2969,7 +2945,6 @@ begin
|
||||
Result := True;
|
||||
end;
|
||||
end;
|
||||
end;
|
||||
|
||||
{------------------------------------------------------------------------------
|
||||
Method: DrawText
|
||||
@ -3170,11 +3145,6 @@ begin
|
||||
if Boolean(Result)
|
||||
then with TDeviceContext(DC) do
|
||||
begin
|
||||
if GC = nil then begin
|
||||
DebugLn('WARNING: [TGtkWidgetSet.DrawText] Uninitialized GC');
|
||||
Result := 0;
|
||||
exit;
|
||||
end;
|
||||
Result := 0;
|
||||
Lines := nil;
|
||||
NumLines := 0;
|
||||
@ -3319,13 +3289,13 @@ begin
|
||||
{$IFDEF VerboseDoubleBuffer}
|
||||
DebugLn('TGtkWidgetSet.EndPaint Copying from buffer to window: ',Width,' ',Height);
|
||||
{$ENDIF}
|
||||
gdk_gc_set_clip_region(DevContext.GC, nil);
|
||||
gdk_gc_set_clip_rectangle(DevContext.GC, nil);
|
||||
gdk_gc_set_clip_region(DevContext.GetGC, nil);
|
||||
gdk_gc_set_clip_rectangle(DevContext.GetGC, nil);
|
||||
|
||||
// hide caret
|
||||
HideCaretOfWidgetGroup(Widget,MainWidget,CaretWasVisible);
|
||||
// draw
|
||||
gdk_window_copy_area(Widget^.Window, DevContext.GC, 0,0,
|
||||
gdk_window_copy_area(Widget^.Window, DevContext.GetGC, 0,0,
|
||||
DCDrawable, 0, 0, Width, Height);
|
||||
|
||||
{LCLObject:=GetParentLCLObject(Widget);
|
||||
@ -3802,12 +3772,6 @@ begin
|
||||
if Result
|
||||
then with TDeviceContext(DC) do
|
||||
begin
|
||||
if GC = nil
|
||||
then begin
|
||||
DebugLn('WARNING: [TGtkWidgetSet.Ellipse] Uninitialized GC');
|
||||
Result := False;
|
||||
end
|
||||
else begin
|
||||
if x1<x2 then begin
|
||||
x:=x1;
|
||||
width:=x2-x1;
|
||||
@ -3832,7 +3796,7 @@ begin
|
||||
{$ENDIF}
|
||||
|
||||
If not CurrentBrush^.IsNullBrush then
|
||||
gdk_draw_arc(Drawable, GC, 1, x+DCOrigin.X, y+DCOrigin.Y, Width, Height,
|
||||
gdk_draw_arc(Drawable, GetGC, 1, x+DCOrigin.X, y+DCOrigin.Y, Width, Height,
|
||||
0, 360 shl 6);
|
||||
|
||||
// Draw outline
|
||||
@ -3841,7 +3805,7 @@ begin
|
||||
If (dcfPenSelected in DCFlags) then begin
|
||||
Result := True;
|
||||
if (CurrentPen^.IsNullPen) then exit;
|
||||
gdk_draw_arc(Drawable, GC, 0, x+DCOrigin.X, y+DCOrigin.Y, Width, Height,
|
||||
gdk_draw_arc(Drawable, GetGC, 0, x+DCOrigin.X, y+DCOrigin.Y, Width, Height,
|
||||
0, 360 shl 6);
|
||||
end else
|
||||
Result := False;
|
||||
@ -3851,7 +3815,6 @@ begin
|
||||
{$ENDIF}
|
||||
end;
|
||||
end;
|
||||
end;
|
||||
|
||||
{------------------------------------------------------------------------------
|
||||
Function: ExcludeClipRect
|
||||
@ -3917,12 +3880,6 @@ begin
|
||||
Result := ERROR
|
||||
else with TDeviceContext(DC) do
|
||||
begin
|
||||
if GC = nil
|
||||
then begin
|
||||
DebugLn('WARNING: [TGtkWidgetSet.ExtSelectClipRGN] Uninitialized GC');
|
||||
Result := ERROR;
|
||||
end
|
||||
else begin
|
||||
//DebugLn('TGtkWidgetSet.ExtSelectClipRGN A ClipRegValid=',dbgs(DCClipRegionValid(DC)),
|
||||
// ' Mode=',dbgs(Mode),' RGN=',GDKRegionAsString(PGdiObject(RGN)^.GDIRegionObject));
|
||||
If ClipRegion=0 then begin
|
||||
@ -3960,7 +3917,6 @@ begin
|
||||
Result := Inherited ExtSelectClipRGN(dc, rgn, mode);
|
||||
end;
|
||||
end;
|
||||
end;
|
||||
|
||||
{------------------------------------------------------------------------------
|
||||
Function: ExtTextOut
|
||||
@ -4003,7 +3959,7 @@ var
|
||||
if (Dx=nil) then begin
|
||||
// no dist array -> write as one block
|
||||
|
||||
gdk_draw_text(Buffer, UseFont, GC, TxtPt.X, TxtPt.Y,
|
||||
gdk_draw_text(Buffer, UseFont, GetGC, TxtPt.X, TxtPt.Y,
|
||||
LineStart, LineLen);
|
||||
end else begin
|
||||
// dist array -> write each char separately
|
||||
@ -4020,7 +3976,7 @@ var
|
||||
i:=1;
|
||||
while (i<=LineLen) do begin
|
||||
//debugln('TGtkWidgetSet.ExtTextOut.DrawTextLine ',dbgs(CharLen),' ',dbgs(ord(LinePos^)));
|
||||
gdk_draw_text(Buffer, UseFont, GC, CurX, TxtPt.Y, LinePos, CharLen);
|
||||
gdk_draw_text(Buffer, UseFont, GetGC, CurX, TxtPt.Y, LinePos, CharLen);
|
||||
inc(LinePos,CharLen);
|
||||
inc(CurX,CurDistX^);
|
||||
inc(CurDistX);
|
||||
@ -4033,7 +3989,7 @@ var
|
||||
else
|
||||
UnderLineLen := gdk_text_width(UseFont,LineStart, LineLen);
|
||||
Y := TxtPt.Y + 1;
|
||||
gdk_draw_line(Buffer, GC, TxtPt.X, Y, TxtPt.X+UnderLineLen, Y);
|
||||
gdk_draw_line(Buffer, GetGC, TxtPt.X, Y, TxtPt.X+UnderLineLen, Y);
|
||||
end;
|
||||
end;
|
||||
{$IFDEF DebugGDKTraps}
|
||||
@ -4047,12 +4003,6 @@ begin
|
||||
if Result
|
||||
then with TDeviceContext(DC) do
|
||||
begin
|
||||
if GC = nil
|
||||
then begin
|
||||
DebugLn('WARNING: [TGtkWidgetSet.ExtTextOut] Uninitialized GC');
|
||||
Result := False;
|
||||
exit;
|
||||
end;
|
||||
if ((Options and (ETO_OPAQUE+ETO_CLIPPED)) <> 0)
|
||||
and (Rect=nil) then begin
|
||||
DebugLn('WARNING: [TGtkWidgetSet.ExtTextOut] Rect=nil');
|
||||
@ -4108,10 +4058,10 @@ begin
|
||||
BeginGDKErrorTrap;
|
||||
{$ENDIF}
|
||||
if IsBackgroundColor(TColor(CurrentBackColor.ColorRef)) then
|
||||
StyleFillRectangle(buffer, GC, CurrentBackColor.ColorRef,
|
||||
StyleFillRectangle(buffer, GetGC, CurrentBackColor.ColorRef,
|
||||
Left, Top, Width, Height)
|
||||
else
|
||||
gdk_draw_rectangle(buffer, GC, 1, Left, Top, Width, Height);
|
||||
gdk_draw_rectangle(buffer, GetGC, 1, Left, Top, Width, Height);
|
||||
{$IFDEF DebugGDKTraps}
|
||||
EndGDKErrorTrap;
|
||||
{$ENDIF}
|
||||
@ -4177,12 +4127,6 @@ begin
|
||||
if not Result then exit;
|
||||
with TDeviceContext(DC) do
|
||||
begin
|
||||
if GC = nil
|
||||
then begin
|
||||
DebugLn('WARNING: [TGtkWidgetSet.FillRect] Uninitialized GC');
|
||||
Result := False;
|
||||
exit;
|
||||
end;
|
||||
if not PGdiObject(Brush)^.IsNullBrush then begin
|
||||
Width := Rect.Right - Rect.Left;
|
||||
Height := Rect.Bottom - Rect.Top;
|
||||
@ -4202,12 +4146,12 @@ begin
|
||||
if (CurrentBrush^.GDIBrushFill = GDK_SOLID)
|
||||
and (IsBackgroundColor(TColor(CurrentBrush^.GDIBrushColor.ColorRef)))
|
||||
then begin
|
||||
StyleFillRectangle(drawable, GC,
|
||||
StyleFillRectangle(drawable, GetGC,
|
||||
CurrentBrush^.GDIBrushColor.ColorRef,
|
||||
Rect.Left+DCOrigin.X, Rect.Top+DCOrigin.Y,
|
||||
Width, Height)
|
||||
end else begin
|
||||
gdk_draw_rectangle(Drawable, GC, 1,
|
||||
gdk_draw_rectangle(Drawable, GetGC, 1,
|
||||
Rect.Left+DCOrigin.X, Rect.Top+DCOrigin.Y,
|
||||
Width, Height);
|
||||
end;
|
||||
@ -4234,7 +4178,7 @@ var
|
||||
DCOrigin: TPoint;
|
||||
begin
|
||||
Result:=0;
|
||||
if IsValidDC(DC) and (TDeviceContext(DC).GC<>nil) then begin
|
||||
if IsValidDC(DC) then begin
|
||||
with TDeviceContext(DC) do
|
||||
begin
|
||||
// Draw outline
|
||||
@ -4243,7 +4187,7 @@ begin
|
||||
Result := 1;
|
||||
if (not CurrentPen^.IsNullPen) then begin
|
||||
DCOrigin:=GetDCOffset(TDeviceContext(DC));
|
||||
gdk_draw_rectangle(Drawable, GC, 0,
|
||||
gdk_draw_rectangle(Drawable, GetGC, 0,
|
||||
ARect.Left+DCOrigin.X, ARect.Top+DCOrigin.Y,
|
||||
ARect.Right-ARect.Left, ARect.Bottom-ARect.Top);
|
||||
end;
|
||||
@ -4285,11 +4229,6 @@ begin
|
||||
|
||||
with TDeviceContext(DC) do
|
||||
begin
|
||||
if GC = nil then begin
|
||||
Result:= False;
|
||||
exit;
|
||||
end;
|
||||
|
||||
Widget:=TDeviceContext(DC).DCWidget;
|
||||
ClientWidget:=Widget;
|
||||
if Widget<>nil then begin
|
||||
@ -4337,8 +4276,7 @@ var
|
||||
DCOrigin: TPoint;
|
||||
begin
|
||||
Result:=0;
|
||||
if IsValidDC(DC) and (TDeviceContext(DC).GC<>nil)
|
||||
and IsValidGDIObject(hBr) then begin
|
||||
if IsValidDC(DC) and IsValidGDIObject(hBr) then begin
|
||||
// Draw outline
|
||||
Result := 1;
|
||||
if (not PGdiObject(hBr)^.IsNullBrush) then begin
|
||||
@ -4347,7 +4285,7 @@ begin
|
||||
SelectedColors:=dcscCustom;
|
||||
EnsureGCColor(DC, dccGDIBrushColor, True, False);//Brush Color
|
||||
DCOrigin:=GetDCOffset(TDeviceContext(DC));
|
||||
gdk_draw_rectangle(Drawable, GC, 0,
|
||||
gdk_draw_rectangle(Drawable, GetGC, 0,
|
||||
ARect.Left+DCOrigin.X, ARect.Top+DCOrigin.Y,
|
||||
ARect.Right-ARect.Left, ARect.Bottom-ARect.Top);
|
||||
end;
|
||||
@ -4785,13 +4723,8 @@ begin
|
||||
result := 0
|
||||
end else
|
||||
with TDeviceContext(DC) do begin
|
||||
if GC = nil then begin
|
||||
Assert(False, 'Trace:[TGtkWidgetSet.GetROP2] Uninitialized GC');
|
||||
Result := 0;
|
||||
end else begin
|
||||
gdk_gc_get_values(GC, @Values);
|
||||
result := GdkFunctionToROP2Mode( Values.{$ifdef gtk1}thefunction{$else}_function{$endif} )
|
||||
end;
|
||||
gdk_gc_get_values(GetGC, @Values);
|
||||
Result := GdkFunctionToROP2Mode(Values.{$ifdef gtk1}thefunction{$else}_function{$endif} )
|
||||
end;
|
||||
end;
|
||||
|
||||
@ -6814,7 +6747,6 @@ begin
|
||||
if Result
|
||||
then with TDeviceContext(DC) do
|
||||
begin
|
||||
if GC <> nil then begin
|
||||
SelectGDKPenProps(DC);
|
||||
|
||||
If (dcfPenSelected in DCFlags) then begin
|
||||
@ -6833,15 +6765,11 @@ begin
|
||||
debugln('TGtkWidgetSet.LineTo SWAPPED ',dbgs(FromX),' ',dbgs(FromY),' ',dbgs(ToX),' ',dbgs(ToY));
|
||||
end;}
|
||||
//gdk_gc_set_line_attributes(gc,1,GDK_LINE_SOLID, GDK_CAP_NOT_LAST, GDK_JOIN_MITER);
|
||||
gdk_draw_line(Drawable, GC, FromX, FromY, ToX, ToY);
|
||||
gdk_draw_line(Drawable, GetGC, FromX, FromY, ToX, ToY);
|
||||
{$IFDEF DebugGDK}EndGDKErrorTrap;{$ENDIF}
|
||||
PenPos:= Point(X, Y);
|
||||
end else
|
||||
Result := False;
|
||||
end else begin
|
||||
DebugLn('WARNING: [TGtkWidgetSet.LineTo] Uninitialized GC');
|
||||
Result := False;
|
||||
end;
|
||||
end;
|
||||
Assert(False, Format('trace:< [TGtkWidgetSet.LineTo] DC:0x%x, X:%d, Y:%d', [DC, X, Y]));
|
||||
end;
|
||||
@ -7056,22 +6984,11 @@ end;
|
||||
then the resulting Poly-Bézier will be drawn as a Polygon.
|
||||
|
||||
------------------------------------------------------------------------------}
|
||||
Function TGtkWidgetSet.PolyBezier(DC: HDC; Points: PPoint; NumPts: Integer;
|
||||
function TGtkWidgetSet.PolyBezier(DC: HDC; Points: PPoint; NumPts: Integer;
|
||||
Filled, Continuous: Boolean): Boolean;
|
||||
Begin
|
||||
Result := IsValidDC(DC);
|
||||
if Result
|
||||
then with TDeviceContext(DC) do
|
||||
begin
|
||||
if GC = nil
|
||||
then begin
|
||||
DebugLn('WARNING: [TGtkWidgetSet.PolyBezier] Uninitialized GC');
|
||||
Result := False;
|
||||
end
|
||||
else
|
||||
Result := Inherited PolyBezier(DC, Points, NumPts, Filled, Continuous);
|
||||
end;
|
||||
End;
|
||||
|
||||
{------------------------------------------------------------------------------
|
||||
Method: TGtkWidgetSet.Polygon
|
||||
@ -7106,12 +7023,6 @@ begin
|
||||
then with TDeviceContext(DC) do
|
||||
begin
|
||||
if NumPts<=0 then exit;
|
||||
if GC = nil
|
||||
then begin
|
||||
DebugLn('WARNING: [TGtkWidgetSet.Polygon] Uninitialized GC');
|
||||
Result := False;
|
||||
end
|
||||
else begin
|
||||
DCOrigin:=GetDCOffset(TDeviceContext(DC));
|
||||
|
||||
// create the PointsArray, which is a copy of Points moved by the DCOrigin
|
||||
@ -7154,7 +7065,7 @@ begin
|
||||
SelectClipRGN(DC, Tmp);
|
||||
DeleteObject(Tmp);
|
||||
end else
|
||||
gdk_draw_polygon(Drawable, GC, 1, PointArray, NumPts);
|
||||
gdk_draw_polygon(Drawable, GetGC, 1, PointArray, NumPts);
|
||||
|
||||
// draw outline
|
||||
|
||||
@ -7163,7 +7074,7 @@ begin
|
||||
If (dcfPenSelected in DCFlags) then begin
|
||||
Result := True;
|
||||
if (not CurrentPen^.IsNullPen) then begin
|
||||
gdk_draw_polygon(Drawable, GC, 0, PointArray, NumPts);
|
||||
gdk_draw_polygon(Drawable, GetGC, 0, PointArray, NumPts);
|
||||
end;
|
||||
end else
|
||||
Result:=false;
|
||||
@ -7175,7 +7086,6 @@ begin
|
||||
Result := True;
|
||||
end;
|
||||
end;
|
||||
end;
|
||||
|
||||
function TGtkWidgetSet.Polyline(DC: HDC; Points: PPoint; NumPts: Integer): boolean;
|
||||
var i: integer;
|
||||
@ -7186,12 +7096,6 @@ begin
|
||||
if Result
|
||||
then with TDeviceContext(DC) do
|
||||
begin
|
||||
if GC = nil
|
||||
then begin
|
||||
DebugLn('WARNING: [TGtkWidgetSet.Polyline] Uninitialized GC');
|
||||
Result := False;
|
||||
end
|
||||
else begin
|
||||
if NumPts<=0 then exit;
|
||||
DCOrigin:=GetDCOffset(TDeviceContext(DC));
|
||||
GetMem(PointArray,SizeOf(TGdkPoint)*NumPts);
|
||||
@ -7207,7 +7111,7 @@ begin
|
||||
Result := True;
|
||||
if (not CurrentPen^.IsNullPen) then begin
|
||||
{$IFDEF DebugGDK}BeginGDKErrorTrap;{$ENDIF}
|
||||
gdk_draw_lines(Drawable, GC, PointArray, NumPts);
|
||||
gdk_draw_lines(Drawable, GetGC, PointArray, NumPts);
|
||||
{$IFDEF DebugGDKTraps}EndGDKErrorTrap;{$ENDIF}
|
||||
end;
|
||||
end else
|
||||
@ -7216,7 +7120,6 @@ begin
|
||||
FreeMem(PointArray);
|
||||
end;
|
||||
end;
|
||||
end;
|
||||
|
||||
{------------------------------------------------------------------------------
|
||||
Function: PostMessage
|
||||
@ -7335,21 +7238,11 @@ end;
|
||||
between which the Arc is drawn.
|
||||
|
||||
------------------------------------------------------------------------------}
|
||||
function TGtkWidgetSet.RadialArc(DC: HDC; left, top, right, bottom, sx, sy, ex, ey: Integer): Boolean;
|
||||
Begin
|
||||
Result := IsValidDC(DC);
|
||||
if Result
|
||||
then with TDeviceContext(DC) do
|
||||
function TGtkWidgetSet.RadialArc(DC: HDC; left, top, right, bottom,
|
||||
sx, sy, ex, ey: Integer): Boolean;
|
||||
begin
|
||||
if GC = nil
|
||||
then begin
|
||||
DebugLn('WARNING: [TGtkWidgetSet.RadialArc] Uninitialized GC');
|
||||
Result := False;
|
||||
end
|
||||
else
|
||||
Result := Inherited RadialArc(DC, left, top, right, bottom, sx, sy, ex, ey);
|
||||
end;
|
||||
End;
|
||||
|
||||
{------------------------------------------------------------------------------
|
||||
Method: RadialChord
|
||||
@ -7361,21 +7254,11 @@ End;
|
||||
the bounding-Arc is drawn.
|
||||
|
||||
------------------------------------------------------------------------------}
|
||||
function TGtkWidgetSet.RadialChord(DC: HDC; x1, y1, x2, y2, sx, sy, ex, ey: Integer): Boolean;
|
||||
function TGtkWidgetSet.RadialChord(DC: HDC; x1, y1, x2, y2,
|
||||
sx, sy, ex, ey: Integer): Boolean;
|
||||
begin
|
||||
Result := IsValidDC(DC);
|
||||
if Result
|
||||
then with TDeviceContext(DC) do
|
||||
begin
|
||||
if GC = nil
|
||||
then begin
|
||||
DebugLn('WARNING: [TGtkWidgetSet.RadialChord] Uninitialized GC');
|
||||
Result := False;
|
||||
end
|
||||
else
|
||||
Result := Inherited RadialChord(DC, x1, y1, x2, y2, sx, sy, ex, ey);
|
||||
end;
|
||||
End;
|
||||
|
||||
{------------------------------------------------------------------------------
|
||||
Function: RealizePalette
|
||||
@ -7413,12 +7296,6 @@ begin
|
||||
if Result
|
||||
then with TDeviceContext(DC) do
|
||||
begin
|
||||
if GC = nil
|
||||
then begin
|
||||
DebugLn('WARNING: [TGtkWidgetSet.Rectangle] Uninitialized GC');
|
||||
Result := False;
|
||||
end
|
||||
else begin
|
||||
CalculateLeftTopWidthHeight(X1,Y1,X2,Y2,Left,Top,Width,Height);
|
||||
// X2, Y2 is not part of the rectangle
|
||||
dec(Width);
|
||||
@ -7430,9 +7307,9 @@ begin
|
||||
If not CurrentBrush^.IsNullBrush then
|
||||
if (CurrentBrush^.GDIBrushFill = GDK_SOLID)
|
||||
and (IsBackgroundColor(TColor(CurrentBrush^.GDIBrushColor.ColorRef))) then
|
||||
StyleFillRectangle(Drawable, GC, CurrentBrush^.GDIBrushColor.ColorRef, Left+DCOrigin.X, Top+DCOrigin.Y, Width, Height)
|
||||
StyleFillRectangle(Drawable, GetGC, CurrentBrush^.GDIBrushColor.ColorRef, Left+DCOrigin.X, Top+DCOrigin.Y, Width, Height)
|
||||
else
|
||||
gdk_draw_rectangle(Drawable, GC, 1, Left+DCOrigin.X, Top+DCOrigin.Y,
|
||||
gdk_draw_rectangle(Drawable, GetGC, 1, Left+DCOrigin.X, Top+DCOrigin.Y,
|
||||
Width, Height);
|
||||
|
||||
// Draw outline
|
||||
@ -7441,14 +7318,13 @@ begin
|
||||
If (dcfPenSelected in DCFlags) then begin
|
||||
Result := True;
|
||||
if (not CurrentPen^.IsNullPen) then
|
||||
gdk_draw_rectangle(Drawable, GC, 0, Left+DCOrigin.X, Top+DCOrigin.Y,
|
||||
gdk_draw_rectangle(Drawable, GetGC, 0, Left+DCOrigin.X, Top+DCOrigin.Y,
|
||||
Width, Height);
|
||||
end else
|
||||
Result:=false;
|
||||
|
||||
{$IFDEF DebugGDKTraps}EndGDKErrorTrap;{$ENDIF}
|
||||
end;
|
||||
end;
|
||||
Assert(False, Format('trace:< [TGtkWidgetSet.Rectangle] DC:0x%x, X1:%d, Y1:%d, X2:%d, Y2:%d', [DC, X1, Y1, X2, Y2]));
|
||||
end;
|
||||
|
||||
@ -7855,23 +7731,11 @@ end;
|
||||
of the corner arcs, RX is the radial width. If either is less than or equal to
|
||||
0, the routine simly calls to standard Rectangle.
|
||||
------------------------------------------------------------------------------}
|
||||
Function TGtkWidgetSet.RoundRect(DC : hDC; X1, Y1, X2, Y2: Integer; RX,RY : Integer): Boolean;
|
||||
function TGtkWidgetSet.RoundRect(DC : hDC; X1, Y1, X2, Y2: Integer;
|
||||
RX,RY : Integer): Boolean;
|
||||
begin
|
||||
Assert(False, Format('trace:> [TGtkWidgetSet.RoundRect] DC:0x%x, X1:%d, Y1:%d, X2:%d, Y2:%d, RX:%d, RY:%d', [DC, X1, Y1, X2, Y2, RX, RY]));
|
||||
Result := IsValidDC(DC);
|
||||
if Result
|
||||
then with TDeviceContext(DC) do
|
||||
begin
|
||||
if GC = nil
|
||||
then begin
|
||||
DebugLn('WARNING: [TGtkWidgetSet.RoundRect] Uninitialized GC');
|
||||
Result := False;
|
||||
end
|
||||
else
|
||||
Result := Inherited RoundRect(DC, X1, Y1, X2, Y2, RX, RY);
|
||||
end;
|
||||
Assert(False, Format('trace:< [TGtkWidgetSet.RoundRect] DC:0x%x, X1:%d, Y1:%d, X2:%d, Y2:%d, RX:%d, RY:%d', [DC, X1, Y1, X2, Y2, RX, RY]));
|
||||
end;
|
||||
|
||||
{------------------------------------------------------------------------------
|
||||
Function: SaveDc
|
||||
@ -7998,24 +7862,16 @@ begin
|
||||
Result := SIMPLEREGION;
|
||||
with TDeviceContext(DC) do
|
||||
begin
|
||||
if (GC = nil) and (RGN <> 0)
|
||||
then begin
|
||||
DebugLn('WARNING: [TGtkWidgetSet.SelectClipRGN] Uninitialized GC');
|
||||
Result := ERROR;
|
||||
end
|
||||
else begin
|
||||
// clear old clipregion
|
||||
if (ClipRegion<>0)
|
||||
and ((SavedContext=nil) or (SavedContext.ClipRegion<>ClipRegion)) then
|
||||
DeleteObject(ClipRegion);
|
||||
ClipRegion := 0;
|
||||
|
||||
If (GC = nil) or (RGN = 0) then begin
|
||||
if GC<>nil then
|
||||
If (RGN = 0) then begin
|
||||
SelectGDIRegion(DC);
|
||||
end
|
||||
else
|
||||
If IsValidGDIObject(RGN) then begin
|
||||
else If IsValidGDIObject(RGN) then begin
|
||||
ClipRegion := CreateRegionCopy(RGN);
|
||||
RegObj:=PGdiObject(ClipRegion)^.GDIRegionObject;
|
||||
DCOrigin:=GetDCOffset(TDeviceContext(DC));
|
||||
@ -8037,7 +7893,6 @@ begin
|
||||
end;
|
||||
end;
|
||||
end;
|
||||
end;
|
||||
|
||||
{------------------------------------------------------------------------------
|
||||
Function: SelectObject
|
||||
@ -8130,13 +7985,10 @@ begin
|
||||
Result := HBRUSH(CurrentBrush);
|
||||
if CurrentBrush<>PGDIObject(GDIObj) then begin
|
||||
CurrentBrush := PGDIObject(GDIObj);
|
||||
if GC <> nil
|
||||
then begin
|
||||
gdk_gc_set_fill(GC, GDIBrushFill);
|
||||
gdk_gc_set_fill(GetGC, GDIBrushFill);
|
||||
case GDIBrushFill of
|
||||
GDK_STIPPLED: gdk_gc_set_stipple(GC, GDIBrushPixMap);
|
||||
GDK_TILED: gdk_gc_set_tile(GC, GDIBrushPixMap);
|
||||
end;
|
||||
GDK_STIPPLED: gdk_gc_set_stipple(GetGC, GDIBrushPixMap);
|
||||
GDK_TILED: gdk_gc_set_tile(GetGC, GDIBrushPixMap);
|
||||
end;
|
||||
SelectedColors := dcscCustom;
|
||||
end;
|
||||
@ -8150,8 +8002,7 @@ begin
|
||||
if CurrentFont<> PGDIObject(GDIObj) then begin
|
||||
CurrentFont := PGDIObject(GDIObj);
|
||||
{$IfDef GTK1}
|
||||
if GC <> nil then
|
||||
gdk_gc_set_font(GC, PGdiObject(GDIObj)^.GDIFontObject);
|
||||
gdk_gc_set_font(GetGC, PGdiObject(GDIObj)^.GDIFontObject);
|
||||
{$ENDIF}
|
||||
Exclude(DCFlags,dcfTextMetricsValid);
|
||||
SelectedColors := dcscCustom;
|
||||
@ -8165,7 +8016,7 @@ begin
|
||||
if CurrentPen<> PGDIObject(GDIObj) then begin
|
||||
CurrentPen := PGDIObject(GDIObj);
|
||||
DCFlags:=DCFlags-[dcfPenSelected];
|
||||
if GC <> nil then SelectGDKPenProps(DC);
|
||||
SelectGDKPenProps(DC);
|
||||
SelectedColors := dcscCustom;
|
||||
end;
|
||||
end;
|
||||
@ -8174,10 +8025,7 @@ begin
|
||||
with TDeviceContext(DC) do
|
||||
begin
|
||||
Result := ClipRegion;
|
||||
if GC <> nil then
|
||||
SelectClipRGN(DC, GDIObj)
|
||||
else
|
||||
ClipRegion:=0;
|
||||
end;
|
||||
|
||||
else
|
||||
@ -8189,8 +8037,7 @@ begin
|
||||
{$ENDIF}
|
||||
end;
|
||||
|
||||
//DebugLn('[TGtkWidgetSet.SelectObject] GDI=',DbgS(GDIObj)
|
||||
// ,' Old=',DbgS(Result));
|
||||
//DebugLn('[TGtkWidgetSet.SelectObject] GDI=',DbgS(GDIObj),' Old=',DbgS(Result));
|
||||
end;
|
||||
|
||||
{------------------------------------------------------------------------------
|
||||
@ -8931,16 +8778,12 @@ end;
|
||||
------------------------------------------------------------------------------}
|
||||
Function TGtkWidgetSet.SetROP2(DC: HDC; Mode: Integer) : Integer;
|
||||
Begin
|
||||
if IsValidDC(DC) then with TDeviceContext(DC) do begin
|
||||
if GC=nil then begin
|
||||
Assert(False, 'Trace:[TGtkWidgetSet.SetROP2] Uninitialized GC');
|
||||
result := 0
|
||||
end else begin
|
||||
if IsValidDC(DC)
|
||||
then with TDeviceContext(DC) do begin
|
||||
Result := GetROP2(DC);
|
||||
gdk_gc_set_function(GC, ROP2ModeToGdkFunction(Mode));
|
||||
end;
|
||||
gdk_gc_set_function(GetGC, ROP2ModeToGdkFunction(Mode));
|
||||
end else begin
|
||||
Assert(False, 'Trace:[TGtkWidgetSet.SetROP2] Invalid GC');
|
||||
Assert(False, 'Trace:[TGtkWidgetSet.SetROP2] Invalid DC');
|
||||
Result := 0;
|
||||
end;
|
||||
end;
|
||||
@ -9668,11 +9511,6 @@ begin
|
||||
if Result and (Count>0)
|
||||
then with TDeviceContext(DC) do
|
||||
begin
|
||||
if GC = nil
|
||||
then begin
|
||||
DebugLn('WARNING: [TGtkWidgetSet.TextOut] Uninitialized GC');
|
||||
end
|
||||
else begin
|
||||
if (CurrentFont = nil) or (CurrentFont^.GDIFontObject = nil)
|
||||
then begin
|
||||
UseFont := GetDefaultGtkFont(false);
|
||||
@ -9713,7 +9551,7 @@ begin
|
||||
SelectGDKTextProps(DC);
|
||||
{$IFDEF DebugGDK}BeginGDKErrorTrap;{$ENDIF}
|
||||
gdk_draw_text(Drawable, UseFont,
|
||||
GC, TxtPt.X+DCOrigin.X, TxtPt.Y+DCOrigin.Y, Str, Count);
|
||||
GetGC, TxtPt.X+DCOrigin.X, TxtPt.Y+DCOrigin.Y, Str, Count);
|
||||
{$IFDEF DebugGDKTraps}EndGDKErrorTrap;{$ENDIF}
|
||||
If Underline or StrikeOut then begin
|
||||
{Create & select pen of font color}
|
||||
@ -9746,7 +9584,6 @@ begin
|
||||
end;
|
||||
end;
|
||||
end;
|
||||
end;
|
||||
{$EndIf}
|
||||
|
||||
{------------------------------------------------------------------------------
|
||||
|
@ -337,7 +337,7 @@ var
|
||||
CharLen:=UTF8CharacterLength(CurStr);
|
||||
//gdk_draw_glyphs(DevCtx.drawable,DevCtx.gc );
|
||||
pango_layout_set_text(UseFont, CurStr, CharLen);
|
||||
gdk_draw_layout_with_colors(DevCtx.drawable, DevCtx.gc, CurScreenX, Y,
|
||||
gdk_draw_layout_with_colors(DevCtx.drawable, DevCtx.GC, CurScreenX, Y,
|
||||
UseFont, Foreground, nil);
|
||||
//gdk_draw_rectangle(DevCtx.Drawable,DevCtx.GC,1,CurScreenX,Y,3,3);
|
||||
inc(CurScreenX,CurDx^);
|
||||
@ -347,7 +347,7 @@ var
|
||||
end;
|
||||
end else begin
|
||||
pango_layout_set_text(UseFont, Str, Count);
|
||||
gdk_draw_layout_with_colors(DevCtx.drawable, DevCtx.gc, X, Y, UseFont,
|
||||
gdk_draw_layout_with_colors(DevCtx.drawable, DevCtx.GC, X, Y, UseFont,
|
||||
Foreground, nil);
|
||||
end;
|
||||
end;
|
||||
@ -359,12 +359,7 @@ begin
|
||||
if Result
|
||||
then with TDeviceContext(DC) do
|
||||
begin
|
||||
if GC = nil
|
||||
then begin
|
||||
DebugLn('WARNING: [TGtk2WidgetSet.ExtTextOut] Uninitialized GC');
|
||||
Result := False;
|
||||
exit;
|
||||
end;
|
||||
GetGC; // create GC
|
||||
if ((Options and (ETO_OPAQUE+ETO_CLIPPED)) <> 0)
|
||||
and (Rect=nil) then begin
|
||||
DebugLn('WARNING: [TGtk2WidgetSet.ExtTextOut] Rect=nil');
|
||||
@ -521,11 +516,6 @@ begin
|
||||
if Result and (Count>0)
|
||||
then with TDeviceContext(DC) do
|
||||
begin
|
||||
if GC = nil
|
||||
then begin
|
||||
DebugLn('WARNING: [TGtk2WidgetSet.TextOut] Uninitialized GC');
|
||||
exit(false);
|
||||
end;
|
||||
if (CurrentFont = nil) or (CurrentFont^.GDIFontObject = nil)
|
||||
then begin
|
||||
UseFont := GetDefaultGtkFont(false);
|
||||
@ -552,7 +542,7 @@ begin
|
||||
EnsureGCColor(DC, dccCurrentTextColor, True, False);
|
||||
|
||||
//DebugLn(['TGtk2WidgetSet.TextOut Str="',copy(Str,1,Count),'" X=',X+DCOrigin.X,',',Y+DCOrigin.Y+yOffset]);
|
||||
gdk_draw_layout_with_colors(drawable, GC,
|
||||
gdk_draw_layout_with_colors(drawable, GetGC,
|
||||
X+DCOrigin.X, Y+DCOrigin.Y+yOffset, UseFont, nil, nil);
|
||||
|
||||
Result := True;
|
||||
|
Loading…
Reference in New Issue
Block a user