From ab619c7b0a173682c21ef9e57cad6f88c67e4edd Mon Sep 17 00:00:00 2001 From: mattias Date: Mon, 12 Jun 2006 19:41:12 +0000 Subject: [PATCH] added virtual TCanvas.FreeHandle and extended TControlCanvas to work without control from Darek git-svn-id: trunk@9428 - --- components/popupnotifier/demo/unit1.lrs | 2 -- lcl/controls.pp | 2 +- lcl/graphics.pp | 3 ++- lcl/include/canvas.inc | 9 +++++++-- lcl/include/controlcanvas.inc | 8 ++++---- lcl/include/scrollingwincontrol.inc | 2 +- lcl/interfaces/gtk/gtkproc.inc | 9 +++------ 7 files changed, 18 insertions(+), 17 deletions(-) diff --git a/components/popupnotifier/demo/unit1.lrs b/components/popupnotifier/demo/unit1.lrs index 46687670c9..5f9e611944 100644 --- a/components/popupnotifier/demo/unit1.lrs +++ b/components/popupnotifier/demo/unit1.lrs @@ -1,5 +1,3 @@ -{ This is an automatically generated lazarus resource file } - LazarusResources.Add('TForm1','FORMDATA',[ 'TPF0'#6'TForm1'#5'Form1'#13'ActiveControl'#7#7'Button1'#7'Caption'#6#5'Form1' +#12'ClientHeight'#3#214#0#11'ClientWidth'#3#214#0#13'PixelsPerInch'#2'V'#18 diff --git a/lcl/controls.pp b/lcl/controls.pp index 154a907d80..1963b5e38e 100644 --- a/lcl/controls.pp +++ b/lcl/controls.pp @@ -246,7 +246,7 @@ type public constructor Create; destructor Destroy; override; - procedure FreeHandle; + procedure FreeHandle;override; property Control: TControl read FControl write SetControl; end; diff --git a/lcl/graphics.pp b/lcl/graphics.pp index ffdd7fe1c6..32ee5ee083 100644 --- a/lcl/graphics.pp +++ b/lcl/graphics.pp @@ -923,6 +923,7 @@ type procedure SetHandle(NewHandle: HDC); virtual; procedure SetInternalPenPos(const Value: TPoint); virtual; Procedure SetPixel(X,Y: Integer; Value: TColor); virtual; + procedure FreeHandle;virtual; public constructor Create; destructor Destroy; override; @@ -1879,4 +1880,4 @@ finalization FreeAndNil(PicFileFormats); -end. \ No newline at end of file +end. diff --git a/lcl/include/canvas.inc b/lcl/include/canvas.inc index d92814b6f1..58db54e1e5 100644 --- a/lcl/include/canvas.inc +++ b/lcl/include/canvas.inc @@ -1367,7 +1367,7 @@ end; ------------------------------------------------------------------------------} procedure TCanvas.DeselectHandles; begin - //debugln('TCanvas.DeselectHandles ',ClassName,' Self=',DbgS(Self),' Handle=',DbgS(FHandle),8),' FSavedBrushHandle=',DbgS(Cardinal(FSavedBrushHandle)); + //debugln('TCanvas.DeselectHandles ',ClassName,' Self=',DbgS(Self),' Handle=',DbgS(FHandle),' FSavedBrushHandle=',DbgS(Cardinal(FSavedBrushHandle))); if (FHandle<>0) then begin // select default sub handles in the device context without deleting owns if FSavedBrushHandle<>0 then begin @@ -1395,7 +1395,12 @@ end; ------------------------------------------------------------------------------} procedure TCanvas.CreateHandle; begin -// Plain canvas does nothing + // Plain canvas does nothing +end; + +procedure TCanvas.FreeHandle; +begin + Handle:=0; end; {------------------------------------------------------------------------------ diff --git a/lcl/include/controlcanvas.inc b/lcl/include/controlcanvas.inc index 40f2e8ff8e..4294d849b6 100644 --- a/lcl/include/controlcanvas.inc +++ b/lcl/include/controlcanvas.inc @@ -79,9 +79,9 @@ end; ------------------------------------------------------------------------------} procedure TControlCanvas.CreateHandle; begin -//DebugLn('[TControlCanvas.CreateHandle] ',FControl<>nil,' DC=',DbgS(FDeviceContext,8),' WinHandle=',DbgS(FWindowHandle,8)); - if FControl = nil - then inherited CreateHandle + //DebugLn('[TControlCanvas.CreateHandle] ',FControl<>nil,' DC=',DbgS(FDeviceContext,8),' WinHandle=',DbgS(FWindowHandle,8)); + if FControl = nil then + inherited CreateHandle else begin if FDeviceContext = 0 then begin @@ -102,9 +102,9 @@ end; ------------------------------------------------------------------------------} procedure TControlCanvas.FreeHandle; begin + inherited; if FDeviceContext <> 0 then begin - Handle := 0; ReleaseDC(FWindowHandle, FDeviceContext); FDeviceContext := 0; end; diff --git a/lcl/include/scrollingwincontrol.inc b/lcl/include/scrollingwincontrol.inc index e901281ef1..46d0185b99 100644 --- a/lcl/include/scrollingwincontrol.inc +++ b/lcl/include/scrollingwincontrol.inc @@ -124,7 +124,7 @@ procedure TScrollingWinControl.DestroyWnd; begin inherited DestroyWnd; if Canvas<>nil then - Canvas.Handle:=0; + Canvas.FreeHandle; end; Function TScrollingWinControl.StoreScrollBars : Boolean; diff --git a/lcl/interfaces/gtk/gtkproc.inc b/lcl/interfaces/gtk/gtkproc.inc index 591bead6e0..e82b2ca684 100644 --- a/lcl/interfaces/gtk/gtkproc.inc +++ b/lcl/interfaces/gtk/gtkproc.inc @@ -3908,17 +3908,14 @@ function GetWidgetInfo(const AWidget: Pointer; var MainWidget: PGtkObject; begin - if AWidget <> nil - then begin + if AWidget <> nil then begin MainWidget := GetMainWidget(AWidget); - if MainWidget = nil then MainWidget := AWidget; Result := gtk_object_get_data(MainWidget, 'widgetinfo'); - if (Result = nil) and ACreate - then begin + if (Result = nil) and ACreate then begin Result := CreateWidgetInfo(MainWidget); // use the main widget as default Result^.CoreWidget := PGtkWidget(MainWidget); - end; + end; end else Result := nil; end;