MG: changed PDeviceContext into class TDeviceContext

git-svn-id: trunk@1896 -
This commit is contained in:
lazarus 2002-08-17 23:39:48 +00:00
parent 6db7d55819
commit 2a155205df

View File

@ -63,7 +63,7 @@ var
begin begin
Result := IsValidDC(DC); Result := IsValidDC(DC);
if Result if Result
then with PDeviceContext(DC)^ do then with TDeviceContext(DC) do
begin begin
if GC = nil if GC = nil
then begin then begin
@ -82,7 +82,7 @@ begin
Exit;//Skip out. Exit;//Skip out.
end; end;
DCOrigin:=GetDCOffset(PDeviceContext(DC)); DCOrigin:=GetDCOffset(TDeviceContext(DC));
inc(X,DCOrigin.X); inc(X,DCOrigin.X);
inc(Y,DCOrigin.Y); inc(Y,DCOrigin.Y);
gdk_draw_arc(Drawable, GC, 0, X, Y, Width, Height, gdk_draw_arc(Drawable, GC, 0, X, Y, Width, Height,
@ -109,7 +109,7 @@ function TgtkObject.AngleChord(DC: HDC;
begin begin
Result := IsValidDC(DC); Result := IsValidDC(DC);
if Result if Result
then with PDeviceContext(DC)^ do then with TDeviceContext(DC) do
begin begin
if GC = nil if GC = nil
then begin then begin
@ -959,9 +959,9 @@ begin
Depth := -1; Depth := -1;
if (IsValidDC(DC) and (PDeviceContext(DC)^.Drawable <> nil)) if (IsValidDC(DC) and (TDeviceContext(DC).Drawable <> nil))
then begin then begin
gdk_window_get_geometry(PDeviceContext(DC)^.Drawable, nil, nil, nil, gdk_window_get_geometry(TDeviceContext(DC).Drawable, nil, nil, nil,
nil, @Depth); nil, @Depth);
If Depth = -1 then If Depth = -1 then
Depth := gdk_visual_get_system^.Depth; Depth := gdk_visual_get_system^.Depth;
@ -1189,7 +1189,7 @@ end;
------------------------------------------------------------------------------} ------------------------------------------------------------------------------}
function TgtkObject.CreateCompatibleDC(DC: HDC): HDC; function TgtkObject.CreateCompatibleDC(DC: HDC): HDC;
var var
pNewDC: PDeviceContext; pNewDC: TDeviceContext;
begin begin
Result := 0; Result := 0;
pNewDC := NewDC; pNewDC := NewDC;
@ -1198,7 +1198,7 @@ begin
// In a compatible DC you have to select a bitmap into it // In a compatible DC you have to select a bitmap into it
(* (*
if IsValidDC(DC) then if IsValidDC(DC) then
with PDeviceContext(DC)^ do with TDeviceContext(DC)^ do
begin begin
pNewDC^.hWnd := hWnd; pNewDC^.hWnd := hWnd;
pNewDC^.Drawable := Drawable; pNewDC^.Drawable := Drawable;
@ -1210,9 +1210,9 @@ begin
end; end;
*) *)
pNewDC^.CurrentFont := CreateDefaultFont; pNewDC.CurrentFont := CreateDefaultFont;
pNewDC^.CurrentBrush := CreateDefaultBrush; pNewDC.CurrentBrush := CreateDefaultBrush;
pNewDC^.CurrentPen := CreateDefaultPen; pNewDC.CurrentPen := CreateDefaultPen;
Result := HDC(pNewDC); Result := HDC(pNewDC);
@ -1844,7 +1844,7 @@ begin
If not IsValidDC(DC) then If not IsValidDC(DC) then
Result := ERROR; Result := ERROR;
if Result <> ERROR if Result <> ERROR
then with PDeviceContext(DC)^ do then with TDeviceContext(DC) do
begin begin
if GC = nil if GC = nil
then begin then begin
@ -2019,7 +2019,7 @@ var
State: TGtkStateType; State: TGtkStateType;
Shadow: TGtkShadowType; Shadow: TGtkShadowType;
aStyle : PGTKStyle; aStyle : PGTKStyle;
pDC: PDeviceContext; aDC: TDeviceContext;
DCOrigin: TPoint; DCOrigin: TPoint;
begin begin
//if Widget<>nil then begin //if Widget<>nil then begin
@ -2072,11 +2072,11 @@ var
If State = GTK_STATE_SELECTED then If State = GTK_STATE_SELECTED then
State := GTK_STATE_ACTIVE; State := GTK_STATE_ACTIVE;
pDC:=PDeviceContext(DC); aDC:=TDeviceContext(DC);
DCOrigin:=GetDCOffset(pDC); DCOrigin:=GetDCOffset(aDC);
If (DFCS_FLAT and uState)<>0 then If (DFCS_FLAT and uState)<>0 then
gtk_paint_flat_box(aStyle,pDC^.Drawable, gtk_paint_flat_box(aStyle,aDC.Drawable,
State, State,
Shadow, Shadow,
nil, nil,
@ -2085,7 +2085,7 @@ var
Rect.Left+DCOrigin.X,Rect.Top+DCOrigin.Y, Rect.Left+DCOrigin.X,Rect.Top+DCOrigin.Y,
Rect.Right-Rect.Left,Rect.Bottom-Rect.Top) Rect.Right-Rect.Left,Rect.Bottom-Rect.Top)
else else
gtk_paint_box(aStyle,pDC^.Drawable, gtk_paint_box(aStyle,aDC.Drawable,
State, State,
Shadow, Shadow,
nil, nil,
@ -2100,7 +2100,7 @@ var
var var
State: TGtkStateType; State: TGtkStateType;
Shadow: TGtkShadowType; Shadow: TGtkShadowType;
pDC: PDeviceContext; aDC: TDeviceContext;
DCOrigin: TPoint; DCOrigin: TPoint;
Style : PGTKStyle; Style : PGTKStyle;
Widget : PGTKWidget; Widget : PGTKWidget;
@ -2125,17 +2125,17 @@ var
end; end;
end; end;
pDC:=PDeviceContext(DC); aDC:=TDeviceContext(DC);
DCOrigin:=GetDCOffset(pDC); DCOrigin:=GetDCOffset(aDC);
Style := gtk_style_attach(GetStyle('checkbox'),pDC^.Drawable); Style := gtk_style_attach(GetStyle('checkbox'),aDC.Drawable);
Widget := GetStyleWidget('checkbox'); Widget := GetStyleWidget('checkbox');
// Do we really need to set this? // Do we really need to set this?
GTK_WIDGET_SET_FLAGS (widget, GTK_REALIZED); GTK_WIDGET_SET_FLAGS (widget, GTK_REALIZED);
Widget^.Window := pDC^.Drawable; Widget^.Window := aDC.Drawable;
gtk_paint_check(Style,pDC^.Drawable, State, gtk_paint_check(Style,aDC.Drawable, State,
Shadow, nil, Widget, 'checkbutton', Shadow, nil, Widget, 'checkbutton',
Rect.Left+DCOrigin.X,Rect.Top+DCOrigin.Y, Rect.Left+DCOrigin.X,Rect.Top+DCOrigin.Y,
Rect.Right-Rect.Left, Rect.Bottom-Rect.Top); Rect.Right-Rect.Left, Rect.Bottom-Rect.Top);
@ -2146,7 +2146,7 @@ var ClientWidget: PGtkWidget;
begin begin
Result := False; Result := False;
if IsValidDC(DC) then begin if IsValidDC(DC) then begin
Widget:=PGtkWidget(PDeviceContext(DC)^.hWnd); Widget:=PGtkWidget(TDeviceContext(DC).hWnd);
ClientWidget:=GetFixedWidget(Widget); ClientWidget:=GetFixedWidget(Widget);
if ClientWidget<>nil then if ClientWidget<>nil then
Widget:=ClientWidget; Widget:=ClientWidget;
@ -2225,7 +2225,7 @@ begin
Assert(False, Format('trace:> [TgtkObject.DrawEdge] DC:0x%x, Rect = %d,%d,%d,%d', [DC, Rect.Left, Rect.Top,Rect.Right, Rect.Bottom])); Assert(False, Format('trace:> [TgtkObject.DrawEdge] DC:0x%x, Rect = %d,%d,%d,%d', [DC, Rect.Left, Rect.Top,Rect.Right, Rect.Bottom]));
Result := IsValidDC(DC); Result := IsValidDC(DC);
if Result if Result
then with PDeviceContext(DC)^ do then with TDeviceContext(DC) do
begin begin
if GC = nil if GC = nil
then begin then begin
@ -2326,7 +2326,7 @@ begin
Width := R.Right - R.Left + 1; Width := R.Right - R.Left + 1;
Height := R.Bottom - R.Top + 1; Height := R.Bottom - R.Top + 1;
SelectGDKBrushProps(DC); SelectGDKBrushProps(DC);
DCOrigin:=GetDCOffset(PDeviceContext(DC)); DCOrigin:=GetDCOffset(TDeviceContext(DC));
gdk_draw_rectangle(Drawable, GC, 1, R.Left+DCOrigin.X, R.Top+DCOrigin.Y, gdk_draw_rectangle(Drawable, GC, 1, R.Left+DCOrigin.X, R.Top+DCOrigin.Y,
Width, Height); Width, Height);
end; end;
@ -2353,7 +2353,7 @@ begin
[DC, Str, Count, Rect.Left, Rect.Top, Rect.Right, Rect.Bottom, Flags])); [DC, Str, Count, Rect.Left, Rect.Top, Rect.Right, Rect.Bottom, Flags]));
Result := Longint(IsValidDC(DC)); Result := Longint(IsValidDC(DC));
if Boolean(Result) if Boolean(Result)
then with PDeviceContext(DC)^ do then with TDeviceContext(DC) do
begin begin
If (FLAGS and DT_CalcRect) = DT_CalcRect then If (FLAGS and DT_CalcRect) = DT_CalcRect then
Result := Inherited DrawText(DC, Str, Count, Rect, Flags) Result := Inherited DrawText(DC, Str, Count, Rect, Flags)
@ -2440,7 +2440,7 @@ var
begin begin
Result := IsValidDC(DC); Result := IsValidDC(DC);
if Result if Result
then with PDeviceContext(DC)^ do then with TDeviceContext(DC) do
begin begin
if GC = nil if GC = nil
then begin then begin
@ -2458,7 +2458,7 @@ begin
height:=height shr 1; height:=height shr 1;
// first draw interior in brush color // first draw interior in brush color
SelectGDKBrushProps(DC); SelectGDKBrushProps(DC);
DCOrigin:=GetDCOffset(PDeviceContext(DC)); DCOrigin:=GetDCOffset(TDeviceContext(DC));
gdk_draw_arc(Drawable, GC, 1, x+DCOrigin.X, y+DCOrigin.Y, Width, Height, gdk_draw_arc(Drawable, GC, 1, x+DCOrigin.X, y+DCOrigin.Y, Width, Height,
0, 360 shl 6); 0, 360 shl 6);
// Draw outline // Draw outline
@ -2503,7 +2503,7 @@ begin
If not IsValidDC(DC) then If not IsValidDC(DC) then
Result := ERROR; Result := ERROR;
if Result <> ERROR if Result <> ERROR
then with PDeviceContext(DC)^ do then with TDeviceContext(DC) do
begin begin
if GC = nil if GC = nil
then begin then begin
@ -2538,7 +2538,7 @@ begin
Assert(False, Format('trace:> [TgtkObject.ExtTextOut] DC:0x%x, X:%d, Y:%d, Options:%d, Str:''%s'', Count: %d', [DC, X, Y, Options, Str, Count])); Assert(False, Format('trace:> [TgtkObject.ExtTextOut] DC:0x%x, X:%d, Y:%d, Options:%d, Str:''%s'', Count: %d', [DC, X, Y, Options, Str, Count]));
Result := IsValidDC(DC); Result := IsValidDC(DC);
if Result if Result
then with PDeviceContext(DC)^ do then with TDeviceContext(DC) do
begin begin
if (CurrentFont = nil) or (CurrentFont^.GDIFontObject = nil) if (CurrentFont = nil) or (CurrentFont^.GDIFontObject = nil)
then begin then begin
@ -2565,7 +2565,7 @@ begin
end else begin end else begin
// TODO: implement other parameters. // TODO: implement other parameters.
//ADC := SaveDC(DC); //ADC := SaveDC(DC);
DCOrigin:=GetDCOffset(PDeviceContext(DC)); DCOrigin:=GetDCOffset(TDeviceContext(DC));
if ((Options and ETO_OPAQUE) <> 0) then if ((Options and ETO_OPAQUE) <> 0) then
begin begin
Width := Rect^.Right - Rect^.Left; Width := Rect^.Right - Rect^.Left;
@ -2646,7 +2646,7 @@ begin
Assert(False, Format('trace:> [TgtkObject.FillRect] DC:0x%x; Rect: ((%d,%d)(%d,%d)); brush: %x', [Integer(DC), Rect.left, rect.top, rect.right, rect.bottom, brush])); Assert(False, Format('trace:> [TgtkObject.FillRect] DC:0x%x; Rect: ((%d,%d)(%d,%d)); brush: %x', [Integer(DC), Rect.left, rect.top, rect.right, rect.bottom, brush]));
Result := IsValidDC(DC) and IsValidGDIObject(Brush); Result := IsValidDC(DC) and IsValidGDIObject(Brush);
if Result if Result
then with PDeviceContext(DC)^ do then with TDeviceContext(DC) do
begin begin
if GC = nil if GC = nil
then begin then begin
@ -2661,7 +2661,7 @@ begin
OldCurrentBrush := CurrentBrush; OldCurrentBrush := CurrentBrush;
CurrentBrush := PGdiObject(Brush); CurrentBrush := PGdiObject(Brush);
SelectGDKBrushProps(DC); SelectGDKBrushProps(DC);
DCOrigin:=GetDCOffset(PDeviceContext(DC)); DCOrigin:=GetDCOffset(TDeviceContext(DC));
gdk_draw_rectangle(Drawable, GC, 1, gdk_draw_rectangle(Drawable, GC, 1,
Rect.Left+DCOrigin.X, Rect.Top+DCOrigin.Y, Rect.Left+DCOrigin.X, Rect.Top+DCOrigin.Y,
Width, Height); Width, Height);
@ -2694,17 +2694,17 @@ var
begin begin
Result := IsValidDC(DC); Result := IsValidDC(DC);
if Result then if Result then
with PDeviceContext(DC)^ do with TDeviceContext(DC) do
begin begin
if GC = nil then begin if GC = nil then begin
Result:= False; Result:= False;
end end
else begin else begin
Widget:=PGtkWidget(PDeviceContext(DC)^.hWnd); Widget:=PGtkWidget(TDeviceContext(DC).hWnd);
ClientWidget:=GetFixedWidget(Widget); ClientWidget:=GetFixedWidget(Widget);
if ClientWidget=nil then if ClientWidget=nil then
ClientWidget:=Widget; ClientWidget:=Widget;
DCOrigin:=GetDCOffset(PDeviceContext(DC)); DCOrigin:=GetDCOffset(TDeviceContext(DC));
for i:= 1 to FrameWidth do begin for i:= 1 to FrameWidth do begin
gtk_draw_shadow(ClientWidget^.thestyle, gtk_draw_shadow(ClientWidget^.thestyle,
GetControlWindow(ClientWidget), GTK_STATE_NORMAL, GetControlWindow(ClientWidget), GTK_STATE_NORMAL,
@ -2948,9 +2948,9 @@ begin
If lpRect <> nil then If lpRect <> nil then
lpRect^ := Rect(0,0,0,0); lpRect^ := Rect(0,0,0,0);
if Result <> ERROR if Result <> ERROR
then with PDeviceContext(DC)^ do then with TDeviceContext(DC) do
begin begin
DCOrigin:=GetDCOffset(PDeviceContext(DC)); DCOrigin:=GetDCOffset(TDeviceContext(DC));
If Not IsValidGDIObject(ClipRegion) then begin If Not IsValidGDIObject(ClipRegion) then begin
gdk_window_get_size(Drawable, @X, @Y); gdk_window_get_size(Drawable, @X, @Y);
lpRect^ := Rect(-DCOrigin.X, -DCOrigin.Y, X, Y); lpRect^ := Rect(-DCOrigin.X, -DCOrigin.Y, X, Y);
@ -3029,7 +3029,7 @@ begin
If not IsValidDC(DC) then If not IsValidDC(DC) then
Result := ERROR; Result := ERROR;
if Result <> ERROR if Result <> ERROR
then with PDeviceContext(DC)^ do then with TDeviceContext(DC) do
begin begin
If Not IsValidGDIObject(RGN) then begin If Not IsValidGDIObject(RGN) then begin
Result := ERROR; Result := ERROR;
@ -3116,19 +3116,20 @@ end;
------------------------------------------------------------------------------} ------------------------------------------------------------------------------}
function TgtkObject.GetDC(hWnd: HWND): HDC; function TgtkObject.GetDC(hWnd: HWND): HDC;
var var
p: PDeviceContext; aDC: TDeviceContext;
ClientWidget: PGtkWidget; ClientWidget: PGtkWidget;
GdiObject: PGdiObject; GdiObject: PGdiObject;
Values: TGdkGCValues; Values: TGdkGCValues;
X,Y : Longint; X,Y : Longint;
begin begin
Assert(False, Format('trace:> [TgtkObject.GetDC] hWND: 0x%x', [hWnd])); Assert(False, Format('trace:> [TgtkObject.GetDC] hWND: 0x%x', [hWnd]));
p := nil; aDC := nil;
aDC := NewDC;
aDC.hWnd := hWnd;
if hWnd = 0 if hWnd = 0
then begin then begin
P := NewDC;
p^.hWnd := hWnd;
FillChar(Values, SizeOf(Values), #0); FillChar(Values, SizeOf(Values), #0);
end end
else begin else begin
@ -3140,24 +3141,22 @@ begin
end; end;
// create a new devicecontext for this window // create a new devicecontext for this window
P := NewDC; aDC.SpecialOrigin:=GtkWidgetIsA(ClientWidget,GTK_LAYOUT_GET_TYPE);
p^.hWnd := hWnd;
p^.SpecialOrigin:=GtkWidgetIsA(ClientWidget,GTK_LAYOUT_GET_TYPE);
if GetControlWindow(ClientWidget) = nil if GetControlWindow(ClientWidget) = nil
then begin then begin
Assert(False, 'Trace:[TgtkObject.GetDC] Force widget creation'); Assert(False, 'Trace:[TgtkObject.GetDC] Force widget creation');
//force creation //force creation
gtk_widget_realize(ClientWidget); gtk_widget_realize(ClientWidget);
end; end;
p^.Drawable := GetControlWindow(ClientWidget); aDC.Drawable := GetControlWindow(ClientWidget);
p^.GC := gdk_gc_new(p^.Drawable); aDC.GC := gdk_gc_new(aDC.Drawable);
gdk_window_get_size(P^.Drawable, @X, @Y); gdk_window_get_size(aDC.Drawable, @X, @Y);
gdk_gc_set_function(p^.GC, GDK_COPY); gdk_gc_set_function(aDC.GC, GDK_COPY);
gdk_gc_get_values(p^.GC, @Values); gdk_gc_get_values(aDC.GC, @Values);
end; end;
if p <> nil if aDC <> nil
then begin then begin
if Values.Font <> nil if Values.Font <> nil
then begin then begin
@ -3167,13 +3166,13 @@ begin
end end
else GdiObject := CreateDefaultFont; else GdiObject := CreateDefaultFont;
p^.CurrentFont := GdiObject; aDC.CurrentFont := GdiObject;
p^.CurrentBrush := CreateDefaultBrush; aDC.CurrentBrush := CreateDefaultBrush;
p^.CurrentPen := CreateDefaultPen; aDC.CurrentPen := CreateDefaultPen;
end; end;
Result := HDC(p); Result := HDC(aDC);
Assert(False, Format('trace:< [TgtkObject.GetDC] Got 0x%x', [Result])); Assert(False, Format('trace:< [TgtkObject.GetDC] Got 0x%x', [Result]));
end; end;
@ -3188,7 +3187,7 @@ begin
ReleaseDC(0, DC); ReleaseDC(0, DC);
end; end;
if IsValidDC(DC) if IsValidDC(DC)
then with PDeviceContext(DC)^ do then with TDeviceContext(DC) do
begin begin
Case Index of Case Index of
//The important ones I know how to do //The important ones I know how to do
@ -3243,7 +3242,7 @@ begin
Result := false; Result := false;
P := Point(0,0); P := Point(0,0);
If IsValidDC(DC) then If IsValidDC(DC) then
with PDeviceContext(DC)^ do begin with TDeviceContext(DC) do begin
if Drawable<>nil then begin if Drawable<>nil then begin
gdk_window_get_size(PGdkWindow(Drawable), @P.X, @P.Y); gdk_window_get_size(PGdkWindow(Drawable), @P.X, @P.Y);
Result := true; Result := true;
@ -3938,7 +3937,7 @@ function TgtkObject.GetTextColor(DC: HDC) : TColorRef;
begin begin
Result := 0; Result := 0;
if IsValidDC(DC) then if IsValidDC(DC) then
with PDeviceContext(DC)^ do with TDeviceContext(DC) do
begin begin
Result := CurrentTextColor.ColorRef; Result := CurrentTextColor.ColorRef;
end; end;
@ -3961,7 +3960,7 @@ begin
Assert(False, 'trace:> [TgtkObject.GetTextExtentPoint]'); Assert(False, 'trace:> [TgtkObject.GetTextExtentPoint]');
Result := IsValidDC(DC); Result := IsValidDC(DC);
if Result if Result
then with PDeviceContext(DC)^ do then with TDeviceContext(DC) do
begin begin
if (CurrentFont = nil) or (CurrentFont^.GDIFontObject = nil) if (CurrentFont = nil) or (CurrentFont^.GDIFontObject = nil)
then begin then begin
@ -4010,7 +4009,7 @@ begin
Result := IsValidDC(DC); Result := IsValidDC(DC);
if Result then if Result then
with PDeviceContext(DC)^ do begin with TDeviceContext(DC) do begin
if (CurrentFont = nil) or (CurrentFont^.GDIFontObject = nil) if (CurrentFont = nil) or (CurrentFont^.GDIFontObject = nil)
then begin then begin
UseFont := GetDefaultFont; UseFont := GetDefaultFont;
@ -4122,16 +4121,16 @@ function TgtkObject.GetWindowOrgEx(dc : hdc; var P : TPoint): Integer;
var var
DCOrigin: TPoint; DCOrigin: TPoint;
begin begin
// gdk_window_get_deskrelative_origin(pgtkwidget(PdeviceContext(dc)^.hwnd)^.window, @P.X, @P.Y); // gdk_window_get_deskrelative_origin(pgtkwidget(TDeviceContext(DC).hwnd)^.window, @P.X, @P.Y);
//write('[TgtkObject.GetWindowOrgEx] ',p.x,' ',p.y); //write('[TgtkObject.GetWindowOrgEx] ',p.x,' ',p.y);
// gdk_window_get_root_origin(pgtkwidget(PdeviceContext(dc)^.hwnd)^.window, @P.X, @P.Y); // gdk_window_get_root_origin(pgtkwidget(TDeviceContext(DC).hwnd)^.window, @P.X, @P.Y);
//write(' / ',p.x,' ',p.y); //write(' / ',p.x,' ',p.y);
Result := 0; Result := 0;
P := Point(0,0); P := Point(0,0);
// ToDo: fix this, when Designer is ready // ToDo: fix this, when Designer is ready
If IsValidDC(DC) then If IsValidDC(DC) then
with PDeviceContext(DC)^ do begin with TDeviceContext(DC) do begin
DCOrigin:=GetDCOffset(PDeviceContext(DC)); DCOrigin:=GetDCOffset(TDeviceContext(DC));
if Drawable<>nil then begin if Drawable<>nil then begin
gdk_window_get_origin(PGdkWindow(Drawable), @P.X, @P.Y); gdk_window_get_origin(PGdkWindow(Drawable), @P.X, @P.Y);
inc(P.X,DCOrigin.X); inc(P.X,DCOrigin.X);
@ -4437,7 +4436,7 @@ begin
If not IsValidDC(DC) then If not IsValidDC(DC) then
Result := ERROR; Result := ERROR;
if Result <> ERROR if Result <> ERROR
then with PDeviceContext(DC)^ do then with TDeviceContext(DC) do
begin begin
if GC = nil if GC = nil
then begin then begin
@ -4534,7 +4533,7 @@ begin
Assert(False, Format('trace:> [TgtkObject.LineTo] DC:0x%x, X:%d, Y:%d', [DC, X, Y])); Assert(False, Format('trace:> [TgtkObject.LineTo] DC:0x%x, X:%d, Y:%d', [DC, X, Y]));
Result := IsValidDC(DC); Result := IsValidDC(DC);
if Result if Result
then with PDeviceContext(DC)^ do then with TDeviceContext(DC) do
begin begin
if GC = nil if GC = nil
then begin then begin
@ -4542,7 +4541,7 @@ begin
Result := False; Result := False;
end end
else begin else begin
DCOrigin:=GetDCOffset(PDeviceContext(DC)); DCOrigin:=GetDCOffset(TDeviceContext(DC));
SelectGDKPenProps(DC); SelectGDKPenProps(DC);
If not IsValidGDIObject(hPen(CurrentPen)) then If not IsValidGDIObject(hPen(CurrentPen)) then
@ -4713,7 +4712,7 @@ begin
Assert(False, Format('trace:> [TgtkObject.MoveToEx] DC:0x%x, X:%d, Y:%d', [DC, X, Y])); Assert(False, Format('trace:> [TgtkObject.MoveToEx] DC:0x%x, X:%d, Y:%d', [DC, X, Y]));
Result := IsValidDC(DC); Result := IsValidDC(DC);
if Result if Result
then with PDeviceContext(DC)^ do then with TDeviceContext(DC) do
begin begin
if OldPoint <> nil then OldPoint^ := PenPos; if OldPoint <> nil then OldPoint^ := PenPos;
PenPos := Point(X, Y); PenPos := Point(X, Y);
@ -4733,7 +4732,7 @@ function TgtkObject.MoveWindowOrgEx(DC: HDC; dX, dY: Integer): Boolean;
begin begin
Result:=IsValidDC(DC); Result:=IsValidDC(DC);
if Result then if Result then
with PDeviceContext(DC)^ do begin with TDeviceContext(DC) do begin
//writeln('[TgtkObject.MoveWindowOrgEx] B DC=',HexStr(Cardinal(DC),8), //writeln('[TgtkObject.MoveWindowOrgEx] B DC=',HexStr(Cardinal(DC),8),
// ' Old=',Origin.X,',',Origin.Y,' d=',dX,',',dY,' '); // ' Old=',Origin.X,',',Origin.Y,' d=',dX,',',dY,' ');
inc(Origin.X,dX); inc(Origin.X,dX);
@ -4792,7 +4791,7 @@ function TgtkObject.Pie(DC: HDC;
begin begin
Result := IsValidDC(DC); Result := IsValidDC(DC);
if Result if Result
then with PDeviceContext(DC)^ do then with TDeviceContext(DC) do
begin begin
if GC = nil if GC = nil
then begin then begin
@ -4827,7 +4826,7 @@ Function TgtkObject.PolyBezier(DC: HDC; Points: PPoint; NumPts: Integer;
Begin Begin
Result := IsValidDC(DC); Result := IsValidDC(DC);
if Result if Result
then with PDeviceContext(DC)^ do then with TDeviceContext(DC) do
begin begin
if GC = nil if GC = nil
then begin then begin
@ -4868,7 +4867,7 @@ var
begin begin
Result := IsValidDC(DC); Result := IsValidDC(DC);
if Result if Result
then with PDeviceContext(DC)^ do then with TDeviceContext(DC) do
begin begin
if GC = nil if GC = nil
then begin then begin
@ -4876,7 +4875,7 @@ begin
Result := False; Result := False;
end end
else begin else begin
DCOrigin:=GetDCOffset(PDeviceContext(DC)); DCOrigin:=GetDCOffset(TDeviceContext(DC));
if NumPts<=0 then exit; if NumPts<=0 then exit;
GetMem(PointArray,SizeOf(TGdkPoint)*(NumPts+1)); // +1 for return line GetMem(PointArray,SizeOf(TGdkPoint)*(NumPts+1)); // +1 for return line
@ -4940,7 +4939,7 @@ var i: integer;
begin begin
Result := IsValidDC(DC); Result := IsValidDC(DC);
if Result if Result
then with PDeviceContext(DC)^ do then with TDeviceContext(DC) do
begin begin
if GC = nil if GC = nil
then begin then begin
@ -4949,7 +4948,7 @@ begin
end end
else begin else begin
if NumPts<=0 then exit; if NumPts<=0 then exit;
DCOrigin:=GetDCOffset(PDeviceContext(DC)); DCOrigin:=GetDCOffset(TDeviceContext(DC));
GetMem(PointArray,SizeOf(TGdkPoint)*NumPts); GetMem(PointArray,SizeOf(TGdkPoint)*NumPts);
for i:=0 to NumPts-1 do begin for i:=0 to NumPts-1 do begin
PointArray[i].x:=Points[i].x+DCOrigin.X; PointArray[i].x:=Points[i].x+DCOrigin.X;
@ -5080,7 +5079,7 @@ function TgtkObject.RadialArc(DC: HDC; x,y,width,height,sx,sy,ex,ey : Integer):
Begin Begin
Result := IsValidDC(DC); Result := IsValidDC(DC);
if Result if Result
then with PDeviceContext(DC)^ do then with TDeviceContext(DC) do
begin begin
if GC = nil if GC = nil
then begin then begin
@ -5106,7 +5105,7 @@ function TgtkObject.RadialChord(DC: HDC; x,y,width,height,sx,sy,ex,ey : Integer)
begin begin
Result := IsValidDC(DC); Result := IsValidDC(DC);
if Result if Result
then with PDeviceContext(DC)^ do then with TDeviceContext(DC) do
begin begin
if GC = nil if GC = nil
then begin then begin
@ -5132,7 +5131,7 @@ function TgtkObject.RadialPie(DC: HDC; x,y,width,height,sx,sy,ex,ey : Integer):
begin begin
Result := IsValidDC(DC); Result := IsValidDC(DC);
if Result if Result
then with PDeviceContext(DC)^ do then with TDeviceContext(DC) do
begin begin
if GC = nil if GC = nil
then begin then begin
@ -5175,7 +5174,7 @@ begin
Assert(False, 'Trace:FINISH: [TgtkObject.RealizePalette]'); Assert(False, 'Trace:FINISH: [TgtkObject.RealizePalette]');
Result := 0; Result := 0;
if IsValidDC(DC) if IsValidDC(DC)
then with PDeviceContext(DC)^ do then with TDeviceContext(DC) do
begin begin
end; end;
@ -5197,7 +5196,7 @@ begin
Assert(False, Format('trace:> [TgtkObject.Rectangle] DC:0x%x, X1:%d, Y1:%d, X2:%d, Y2:%d', [DC, X1, Y1, X2, Y2])); Assert(False, Format('trace:> [TgtkObject.Rectangle] DC:0x%x, X1:%d, Y1:%d, X2:%d, Y2:%d', [DC, X1, Y1, X2, Y2]));
Result := IsValidDC(DC); Result := IsValidDC(DC);
if Result if Result
then with PDeviceContext(DC)^ do then with TDeviceContext(DC) do
begin begin
if GC = nil if GC = nil
then begin then begin
@ -5221,7 +5220,7 @@ begin
end; end;
// first draw interior in brush color // first draw interior in brush color
SelectGDKBrushProps(DC); SelectGDKBrushProps(DC);
DCOrigin:=GetDCOffset(PDeviceContext(DC)); DCOrigin:=GetDCOffset(TDeviceContext(DC));
gdk_draw_rectangle(Drawable, GC, 1, Left+DCOrigin.X, Top+DCOrigin.Y, gdk_draw_rectangle(Drawable, GC, 1, Left+DCOrigin.X, Top+DCOrigin.Y,
Width, Height); Width, Height);
@ -5300,7 +5299,7 @@ end;
------------------------------------------------------------------------------} ------------------------------------------------------------------------------}
function TgtkObject.ReleaseDC(hWnd: HWND; DC: HDC): Integer; function TgtkObject.ReleaseDC(hWnd: HWND; DC: HDC): Integer;
var var
pDC, pSavedDC: PDeviceContext; aDC, pSavedDC: TDeviceContext;
begin begin
//writeln('[TgtkObject.ReleaseDC] ',HexStr(DC,8),' ',FDeviceContexts.Count); //writeln('[TgtkObject.ReleaseDC] ',HexStr(DC,8),' ',FDeviceContexts.Count);
Assert(False, Format('trace:> [TgtkObject.ReleaseDC] DC:0x%x', [DC])); Assert(False, Format('trace:> [TgtkObject.ReleaseDC] DC:0x%x', [DC]));
@ -5310,40 +5309,40 @@ begin
then begin then begin
if FDeviceContexts.Contains(Pointer(DC)) if FDeviceContexts.Contains(Pointer(DC))
then begin then begin
pDC := PDeviceContext(DC); aDC := TDeviceContext(DC);
{ Release all saved device contexts } { Release all saved device contexts }
pSavedDC:=pDC^.SavedContext; pSavedDC:=aDC.SavedContext;
if pSavedDC<>nil then begin if pSavedDC<>nil then begin
if pSavedDC^.CurrentBitmap = pDC^.CurrentBitmap if pSavedDC.CurrentBitmap = aDC.CurrentBitmap
then pDC^.CurrentBitmap := nil; then aDC.CurrentBitmap := nil;
if pSavedDC^.CurrentFont = pDC^.CurrentFont if pSavedDC.CurrentFont = aDC.CurrentFont
then pDC^.CurrentFont := nil; then aDC.CurrentFont := nil;
if pSavedDC^.CurrentPen = pDC^.CurrentPen if pSavedDC.CurrentPen = aDC.CurrentPen
then pDC^.CurrentPen := nil; then aDC.CurrentPen := nil;
if pSavedDC^.CurrentBrush = pDC^.CurrentBrush if pSavedDC.CurrentBrush = aDC.CurrentBrush
then pDC^.CurrentBrush := nil; then aDC.CurrentBrush := nil;
{if pSavedDC^.CurrentPalette = pDC^.CurrentPalette {if pSavedDC.CurrentPalette = aDC.CurrentPalette
then pDC^.CurrentPalette := nil;} then aDC.CurrentPalette := nil;}
if pSavedDC^.ClipRegion = pDC^.ClipRegion if pSavedDC.ClipRegion = aDC.ClipRegion
then pSavedDC^.ClipRegion := 0; then pSavedDC.ClipRegion := 0;
ReleaseDC(0,HDC(pSavedDC)); ReleaseDC(0,HDC(pSavedDC));
pDC^.SavedContext:=nil; aDC.SavedContext:=nil;
end; end;
{ Release all graphic objects } { Release all graphic objects }
DeleteObject(HGDIObj(pDC^.CurrentBrush)); DeleteObject(HGDIObj(aDC.CurrentBrush));
DeleteObject(HGDIObj(pDC^.CurrentPen)); DeleteObject(HGDIObj(aDC.CurrentPen));
DeleteObject(HGDIObj(pDC^.CurrentFont)); DeleteObject(HGDIObj(aDC.CurrentFont));
DeleteObject(HGDIObj(pDC^.CurrentBitmap)); DeleteObject(HGDIObj(aDC.CurrentBitmap));
//DeleteObject(HGDIObj(pDC^.CurrentPalette)); //DeleteObject(HGDIObj(aDC.CurrentPalette));
DeleteObject(HGDIObj(pDC^.ClipRegion)); DeleteObject(HGDIObj(aDC.ClipRegion));
{FreeGDIColor(pDC^.CurrentTextColor); {FreeGDIColor(aDC.CurrentTextColor);
FreeGDIColor(pDC^.CurrentBackColor);} FreeGDIColor(aDC.CurrentBackColor);}
try try
{ On root window, we don't allocate a graphics context and so we dont free} { On root window, we don't allocate a graphics context and so we dont free}
if pDC^.GC <> nil then begin if aDC.GC <> nil then begin
gdk_gc_unref(pDC^.GC); gdk_gc_unref(aDC.GC);
pDC^.GC:=nil; aDC.GC:=nil;
end; end;
except except
on E:Exception do begin on E:Exception do begin
@ -5353,7 +5352,7 @@ begin
end; end;
end; end;
DisposeDC(pDC); DisposeDC(aDC);
Result := 1; Result := 1;
end; end;
end; end;
@ -5369,57 +5368,57 @@ end;
-------------------------------------------------------------------------------} -------------------------------------------------------------------------------}
function TgtkObject.RestoreDC(DC: HDC; SavedDC: Integer): Boolean; function TgtkObject.RestoreDC(DC: HDC; SavedDC: Integer): Boolean;
var var
pDC, pSavedDC: PDeviceContext; aDC, pSavedDC: TDeviceContext;
Count: Integer; Count: Integer;
begin begin
Assert(False, Format('Trace:> [TgtkObject.RestoreDC] DC:0x%x, SavedDC: %d', [DC, SavedDC])); Assert(False, Format('Trace:> [TgtkObject.RestoreDC] DC:0x%x, SavedDC: %d', [DC, SavedDC]));
Result := IsValidDC(DC) and (SavedDC <> 0); Result := IsValidDC(DC) and (SavedDC <> 0);
if Result if Result
then begin then begin
pSavedDC := PDeviceContext(DC); pSavedDC := TDeviceContext(DC);
Count:=Abs(SavedDC); Count:=Abs(SavedDC);
while (Count>0) and (pSavedDC<>nil) do begin while (Count>0) and (pSavedDC<>nil) do begin
pDC:=pSavedDC; aDC:=pSavedDC;
pSavedDC:=pDC^.SavedContext; pSavedDC:=aDC.SavedContext;
dec(Count); dec(Count);
end; end;
// TODO copy bitmap also // TODO copy bitmap also
if (pDC^.ClipRegion<>0) and (pSavedDC^.ClipRegion <> pDC^.ClipRegion) then if (aDC.ClipRegion<>0) and (pSavedDC.ClipRegion <> aDC.ClipRegion) then
begin begin
// clipping region has changed // clipping region has changed
// clipping regions are extraordinary gdiobjects. Users can not set them // clipping regions are extraordinary gdiobjects. Users can not set them
// or read them. If a clipping region is changed, it is always created new // or read them. If a clipping region is changed, it is always created new
// -> destroy the current clipping region // -> destroy the current clipping region
DeleteObject(pDC^.ClipRegion); DeleteObject(aDC.ClipRegion);
pDC^.ClipRegion := 0; aDC.ClipRegion := 0;
end; end;
if pDC^.GC<>nil then begin if aDC.GC<>nil then begin
gdk_gc_unref(pDC^.GC); gdk_gc_unref(aDC.GC);
pDC^.GC:=nil; aDC.GC:=nil;
end; end;
Result := CopyDCData(pDC, pSavedDC); Result := CopyDCData(aDC, pSavedDC);
pDC^.SavedContext := pSavedDC^.SavedContext; aDC.SavedContext := pSavedDC.SavedContext;
pSavedDC^.SavedContext := nil; pSavedDC.SavedContext := nil;
//prevent deleting of copied objects: //prevent deleting of copied objects:
if pSavedDC^.CurrentBitmap = pDC^.CurrentBitmap if pSavedDC.CurrentBitmap = aDC.CurrentBitmap
then pSavedDC^.CurrentBitmap := nil; then pSavedDC.CurrentBitmap := nil;
if pSavedDC^.CurrentFont = pDC^.CurrentFont if pSavedDC.CurrentFont = aDC.CurrentFont
then pSavedDC^.CurrentFont := nil; then pSavedDC.CurrentFont := nil;
if pSavedDC^.CurrentPen = pDC^.CurrentPen if pSavedDC.CurrentPen = aDC.CurrentPen
then pSavedDC^.CurrentPen := nil; then pSavedDC.CurrentPen := nil;
if pSavedDC^.CurrentBrush = pDC^.CurrentBrush if pSavedDC.CurrentBrush = aDC.CurrentBrush
then pSavedDC^.CurrentBrush := nil; then pSavedDC.CurrentBrush := nil;
if pSavedDC^.CurrentBrush = pDC^.CurrentBrush if pSavedDC.CurrentBrush = aDC.CurrentBrush
then pSavedDC^.CurrentBrush := nil; then pSavedDC.CurrentBrush := nil;
{if pSavedDC^.CurrentPalette = pDC^.CurrentPalette {if pSavedDC.CurrentPalette = aDC.CurrentPalette
then pSavedDC^.CurrentPalette := nil;} then pSavedDC.CurrentPalette := nil;}
if pSavedDC^.ClipRegion = pDC^.ClipRegion if pSavedDC.ClipRegion = aDC.ClipRegion
then pSavedDC^.ClipRegion := 0; then pSavedDC.ClipRegion := 0;
DeleteDC(HGDIOBJ(pSavedDC)); DeleteDC(HGDIOBJ(pSavedDC));
end; end;
@ -5461,7 +5460,7 @@ begin
Assert(False, Format('trace:> [TgtkObject.RoundRect] DC:0x%x, X1:%d, Y1:%d, X2:%d, Y2:%d, RX:%d, RY:%d', [DC, X1, Y1, X2, Y2, RX, RY])); Assert(False, Format('trace:> [TgtkObject.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); Result := IsValidDC(DC);
if Result if Result
then with PDeviceContext(DC)^ do then with TDeviceContext(DC) do
begin begin
if GC = nil if GC = nil
then begin then begin
@ -5485,18 +5484,18 @@ end;
-------------------------------------------------------------------------------} -------------------------------------------------------------------------------}
function TgtkObject.SaveDC(DC: HDC): Integer; function TgtkObject.SaveDC(DC: HDC): Integer;
var var
pDC, pSavedDC: PDeviceContext; aDC, aSavedDC: TDeviceContext;
begin begin
Assert(False, Format('Trace:> [TgtkObject.SaveDC] 0x%x', [Integer(DC)])); Assert(False, Format('Trace:> [TgtkObject.SaveDC] 0x%x', [Integer(DC)]));
Result := 0; Result := 0;
if IsValidDC(DC) if IsValidDC(DC)
then begin then begin
pDC := PDeviceContext(DC); aDC := TDeviceContext(DC);
pSavedDC := NewDC; aSavedDC := NewDC;
CopyDCData(pSavedDC, pDC); CopyDCData(aSavedDC, aDC);
pSavedDC^.SavedContext:=pDC^.SavedContext; aSavedDC.SavedContext:=aDC.SavedContext;
pDC^.SavedContext:= pSavedDC; aDC.SavedContext:= aSavedDC;
Result:=1; Result:=1;
end; end;
@ -5590,7 +5589,7 @@ begin
If not IsValidDC(DC) then If not IsValidDC(DC) then
Result := ERROR; Result := ERROR;
if Result <> ERROR then if Result <> ERROR then
with PDeviceContext(DC)^ do with TDeviceContext(DC) do
begin begin
if (GC = nil) and (RGN <> 0) if (GC = nil) and (RGN <> 0)
then begin then begin
@ -5638,7 +5637,7 @@ begin
then begin then begin
case PGdiObject(GDIObj)^.GDIType of case PGdiObject(GDIObj)^.GDIType of
gdiBitmap: gdiBitmap:
with PDeviceContext(DC)^ do with TDeviceContext(DC) do
begin begin
Assert(False, Format('trace: [TgtkObject.SelectObject] DC: 0x%x, Type: Bitmap', [DC])); Assert(False, Format('trace: [TgtkObject.SelectObject] DC: 0x%x, Type: Bitmap', [DC]));
Result := HBITMAP(CurrentBitmap); Result := HBITMAP(CurrentBitmap);
@ -5658,7 +5657,7 @@ begin
end; end;
gdiBrush: gdiBrush:
with PDeviceContext(DC)^, PGdiObject(GDIObj)^ do with TDeviceContext(DC), PGdiObject(GDIObj)^ do
begin begin
Assert(False, Format('trace: [TgtkObject.SelectObject] DC: 0x%x, Type: Brush', [DC])); Assert(False, Format('trace: [TgtkObject.SelectObject] DC: 0x%x, Type: Brush', [DC]));
Result := HBRUSH(CurrentBrush); Result := HBRUSH(CurrentBrush);
@ -5673,7 +5672,7 @@ begin
end; end;
end; end;
gdiFont: gdiFont:
with PDeviceContext(DC)^ do with TDeviceContext(DC) do
begin begin
Assert(False, Format('trace: [TgtkObject.SelectObject] DC: 0x%x, Type: Font', [DC])); Assert(False, Format('trace: [TgtkObject.SelectObject] DC: 0x%x, Type: Font', [DC]));
Result := HFONT(CurrentFont); Result := HFONT(CurrentFont);
@ -5684,7 +5683,7 @@ begin
end; end;
end; end;
gdiPen: gdiPen:
with PDeviceContext(DC)^ do with TDeviceContext(DC) do
begin begin
Result := HPEN(CurrentPen); Result := HPEN(CurrentPen);
CurrentPen := PGDIObject(GDIObj); CurrentPen := PGDIObject(GDIObj);
@ -5692,7 +5691,7 @@ begin
end; end;
gdiRegion: gdiRegion:
begin begin
with PDeviceContext(DC)^ do with TDeviceContext(DC) do
begin begin
Result := ClipRegion; Result := ClipRegion;
ClipRegion := 0; ClipRegion := 0;
@ -5807,7 +5806,7 @@ begin
Result := CLR_INVALID; Result := CLR_INVALID;
if IsValidDC(DC) if IsValidDC(DC)
then begin then begin
with PDeviceContext(DC)^ do with TDeviceContext(DC) do
begin begin
Result := CurrentBackColor.ColorRef; Result := CurrentBackColor.ColorRef;
CurrentBackColor.ColorRef := Color; CurrentBackColor.ColorRef := Color;
@ -6270,7 +6269,7 @@ begin
Result := CLR_INVALID; Result := CLR_INVALID;
if IsValidDC(DC) if IsValidDC(DC)
then begin then begin
with PDeviceContext(DC)^ do with TDeviceContext(DC) do
begin begin
Result := CurrentTextColor.ColorRef; Result := CurrentTextColor.ColorRef;
CurrentTextColor.ColorRef := Color; CurrentTextColor.ColorRef := Color;
@ -6483,7 +6482,7 @@ type
TBltFunction = function: Boolean; TBltFunction = function: Boolean;
var var
fGC : PGDKGC; fGC : PGDKGC;
SrcDevContext, DestDevContext: PDeviceContext; SrcDevContext, DestDevContext: TDeviceContext;
SrcGDIBitmap: PGdiObject; SrcGDIBitmap: PGdiObject;
ScaleBMP : hBITMAP; ScaleBMP : hBITMAP;
Scale : PGdiObject; Scale : PGdiObject;
@ -6659,7 +6658,7 @@ var
OldCurrentBrush: PGdiObject; OldCurrentBrush: PGdiObject;
Brush : hBrush; Brush : hBrush;
begin begin
with PDeviceContext(DC)^ do with TDeviceContext(DC) do
begin begin
// Temporarily hold the old brush to // Temporarily hold the old brush to
// replace it with the given brush // replace it with the given brush
@ -6678,15 +6677,15 @@ var
function DrawableToDrawable: Boolean; function DrawableToDrawable: Boolean;
begin begin
SrcDevContext:=PDeviceContext(SrcDC); SrcDevContext:=TDeviceContext(SrcDC);
DestDevContext:=PDeviceContext(DestDC); DestDevContext:=TDeviceContext(DestDC);
SrcGDIBitmap:=SrcDevContext^.CurrentBitmap; SrcGDIBitmap:=SrcDevContext.CurrentBitmap;
fGC := GDK_GC_New(DestDevContext^.Drawable); fGC := GDK_GC_New(DestDevContext.Drawable);
// perform raster operation and scaling in a buffer // perform raster operation and scaling in a buffer
If not ScaleAndROP(DestDevContext^.GC, If not ScaleAndROP(DestDevContext.GC,
SrcDevContext^.Drawable, SrcGDIBitmap) SrcDevContext.Drawable, SrcGDIBitmap)
then then
exit; exit;
@ -6698,18 +6697,18 @@ var
end; end;
// set clipping mask for transparency // set clipping mask for transparency
SetClipping(DestDevContext^.GC, Scale); SetClipping(DestDevContext.GC, Scale);
// draw image // draw image
gdk_window_copy_area(DestDevContext^.Drawable, gdk_window_copy_area(DestDevContext.Drawable,
DestDevContext^.GC,X, Y, Scale^.GDIPixmapObject, DestDevContext.GC,X, Y, Scale^.GDIPixmapObject,
0, 0, Width, Height); 0, 0, Width, Height);
// unset clipping mask for transparency // unset clipping mask for transparency
ResetClipping(DestDevContext^.GC); ResetClipping(DestDevContext.GC);
// restore raster operation to SRCCOPY // restore raster operation to SRCCOPY
GDK_GC_Set_Function(DestDevContext^.GC, GDK_Copy); GDK_GC_Set_Function(DestDevContext.GC, GDK_Copy);
// Delete buffer // Delete buffer
DeleteObject(ScaleBMP); DeleteObject(ScaleBMP);
@ -6719,14 +6718,14 @@ var
function PixmapToDrawable: Boolean; function PixmapToDrawable: Boolean;
begin begin
SrcDevContext:=PDeviceContext(SrcDC); SrcDevContext:=TDeviceContext(SrcDC);
DestDevContext:=PDeviceContext(DestDC); DestDevContext:=TDeviceContext(DestDC);
SrcGDIBitmap:=SrcDevContext^.CurrentBitmap; SrcGDIBitmap:=SrcDevContext.CurrentBitmap;
fGC := GDK_GC_New(SrcDevContext^.Drawable); fGC := GDK_GC_New(SrcDevContext.Drawable);
// perform raster operation and scaling in a buffer // perform raster operation and scaling in a buffer
If not ScaleAndROP(DestDevContext^.GC, SrcDevContext^.Drawable, If not ScaleAndROP(DestDevContext.GC, SrcDevContext.Drawable,
SrcGDIBitmap) SrcGDIBitmap)
then then
exit; exit;
@ -6739,18 +6738,18 @@ var
end; end;
// set clipping mask for transparency // set clipping mask for transparency
SetClipping(DestDevContext^.GC, Scale); SetClipping(DestDevContext.GC, Scale);
// draw image // draw image
gdk_window_copy_area(DestDevContext^.Drawable, gdk_window_copy_area(DestDevContext.Drawable,
DestDevContext^.GC,X, Y, Scale^.GDIPixmapObject, DestDevContext.GC,X, Y, Scale^.GDIPixmapObject,
0, 0, Width, Height); 0, 0, Width, Height);
// unset clipping mask for transparency // unset clipping mask for transparency
ResetClipping(DestDevContext^.GC); ResetClipping(DestDevContext.GC);
// restore raster operation to SRCCOPY // restore raster operation to SRCCOPY
GDK_GC_Set_Function(DestDevContext^.GC, GDK_Copy); GDK_GC_Set_Function(DestDevContext.GC, GDK_Copy);
// Delete buffer // Delete buffer
DeleteObject(ScaleBMP); DeleteObject(ScaleBMP);
@ -6816,12 +6815,12 @@ var
(@ImageToBitmap, @ImageToDrawable, @ImageToImage) (@ImageToBitmap, @ImageToDrawable, @ImageToImage)
); );
begin begin
If (PDeviceContext(SrcDC)^.CurrentBitmap <> nil) and If (TDeviceContext(SrcDC).CurrentBitmap <> nil) and
(PDeviceContext(DestDC)^.CurrentBitmap <> nil) (TDeviceContext(DestDC).CurrentBitmap <> nil)
then then
Result := BLT_MATRIX[ Result := BLT_MATRIX[
PDeviceContext(SrcDC)^.CurrentBitmap^.GDIBitmapType, TDeviceContext(SrcDC).CurrentBitmap^.GDIBitmapType,
PDeviceContext(DestDC)^.CurrentBitmap^.GDIBitmapType TDeviceContext(DestDC).CurrentBitmap^.GDIBitmapType
]() ]()
else else
Result := Unsupported; Result := Unsupported;
@ -6833,9 +6832,9 @@ var
@PixmapToDrawable, @PixmapToDrawable, @ImageToDrawable @PixmapToDrawable, @PixmapToDrawable, @ImageToDrawable
); );
begin begin
If PDeviceContext(SrcDC)^.CurrentBitmap <> nil then If TDeviceContext(SrcDC).CurrentBitmap <> nil then
Result := BLT_FUNCTION[ Result := BLT_FUNCTION[
PDeviceContext(SrcDC)^.CurrentBitmap^.GDIBitmapType TDeviceContext(SrcDC).CurrentBitmap^.GDIBitmapType
]() ]()
else else
Result := Unsupported; Result := Unsupported;
@ -6847,9 +6846,9 @@ var
@Unsupported, @Unsupported, @Unsupported @Unsupported, @Unsupported, @Unsupported
); );
begin begin
If PDeviceContext(DestDC)^.CurrentBitmap <> nil then If TDeviceContext(DestDC).CurrentBitmap <> nil then
Result := BLT_FUNCTION[ Result := BLT_FUNCTION[
PDeviceContext(DestDC)^.CurrentBitmap^.GDIBitmapType TDeviceContext(DestDC).CurrentBitmap^.GDIBitmapType
]() ]()
else else
Result := Unsupported; Result := Unsupported;
@ -6867,13 +6866,13 @@ begin
Result := IsValidDC(DestDC) and IsValidDC(SrcDC); Result := IsValidDC(DestDC) and IsValidDC(SrcDC);
if Result if Result
then begin then begin
with PDeviceContext(DestDC)^ do begin with TDeviceContext(DestDC) do begin
DCOrigin:=GetDCOffset(PDeviceContext(DestDC)); DCOrigin:=GetDCOffset(TDeviceContext(DestDC));
Inc(X,DCOrigin.X); Inc(X,DCOrigin.X);
Inc(Y,DCOrigin.Y); Inc(Y,DCOrigin.Y);
end; end;
with PDeviceContext(SrcDC)^ do begin with TDeviceContext(SrcDC) do begin
DCOrigin:=GetDCOffset(PDeviceContext(SrcDC)); DCOrigin:=GetDCOffset(TDeviceContext(SrcDC));
Inc(XSrc,DCOrigin.X); Inc(XSrc,DCOrigin.X);
Inc(YSrc,DCOrigin.Y); Inc(YSrc,DCOrigin.Y);
end; end;
@ -6881,14 +6880,14 @@ begin
//writeln('TgtkObject.StretchBlt X=',X,' Y=',Y,' Width=',Width,' Height=',Height, //writeln('TgtkObject.StretchBlt X=',X,' Y=',Y,' Width=',Width,' Height=',Height,
// ' XSrc=',XSrc,' YSrc=',YSrc,' SrcWidth=',SrcWidth,' SrcHeight=',SrcHeight); // ' XSrc=',XSrc,' YSrc=',YSrc,' SrcWidth=',SrcWidth,' SrcHeight=',SrcHeight);
If PDeviceContext(SrcDC)^.Drawable = nil then begin If TDeviceContext(SrcDC).Drawable = nil then begin
If PDeviceContext(DestDC)^.Drawable = nil then If TDeviceContext(DestDC).Drawable = nil then
Result := NoDrawableToNoDrawable Result := NoDrawableToNoDrawable
else else
Result := NoDrawableToDrawable; Result := NoDrawableToDrawable;
end end
else begin else begin
If PDeviceContext(DestDC)^.Drawable = nil then If TDeviceContext(DestDC).Drawable = nil then
Result := DrawableToNoDrawable Result := DrawableToNoDrawable
else else
Result := DrawableToDrawable; Result := DrawableToDrawable;
@ -6946,7 +6945,7 @@ var
begin begin
Result := IsValidDC(DC); Result := IsValidDC(DC);
if Result if Result
then with PDeviceContext(DC)^ do then with TDeviceContext(DC) do
begin begin
if GC = nil if GC = nil
then begin then begin
@ -6965,7 +6964,7 @@ begin
If UseFont = nil then If UseFont = nil then
WriteLn('WARNING: [TgtkObject.TextOut] Missing Font') WriteLn('WARNING: [TgtkObject.TextOut] Missing Font')
else begin else begin
DCOrigin:=GetDCOffset(PDeviceContext(DC)); DCOrigin:=GetDCOffset(TDeviceContext(DC));
GetTextExtentPoint(DC, Str, Count, Sz); GetTextExtentPoint(DC, Str, Count, Sz);
aRect := Rect(X+DCOrigin.X,Y+DCOrigin.Y,X + Sz.CX, Sz.CY); aRect := Rect(X+DCOrigin.X,Y+DCOrigin.Y,X + Sz.CX, Sz.CY);
FillRect(DC,aRect,hBrush(CurrentBrush)); FillRect(DC,aRect,hBrush(CurrentBrush));
@ -7168,6 +7167,9 @@ end;
{ ============================================================================= { =============================================================================
$Log$ $Log$
Revision 1.140 2002/10/01 10:05:50 lazarus
MG: changed PDeviceContext into class TDeviceContext
Revision 1.139 2002/09/30 20:19:14 lazarus Revision 1.139 2002/09/30 20:19:14 lazarus
MG: fixed flickering of modal forms MG: fixed flickering of modal forms