summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorgraemeg <graemeg@ae50a9b5-8222-0410-bf8d-8a13f76226bf>2007-10-11 07:55:26 +0000
committergraemeg <graemeg@ae50a9b5-8222-0410-bf8d-8a13f76226bf>2007-10-11 07:55:26 +0000
commitf2c54cab546bb1cc403fc23b04f49f6b0b8b14dc (patch)
treec433c86d204d5f4059902313673d85309e1f8c7c
parent594a6a445ca92fb76f8f971d707f6c4b9901692a (diff)
downloadfpGUI-f2c54cab546bb1cc403fc23b04f49f6b0b8b14dc.tar.xz
Fixed bugs 1803016 and 1798475. When resizing a window a few times the painting goes corrupt under GDI (Windows). This bug was actually introduced in revision 210 - ages ago!
-rw-r--r--prototypes/fpgui2/tests/edittest.dpr3
-rw-r--r--prototypes/fpgui2/tests/edittest.lpi14
-rw-r--r--src/corelib/gdi/gfx_gdi.pas39
3 files changed, 26 insertions, 30 deletions
diff --git a/prototypes/fpgui2/tests/edittest.dpr b/prototypes/fpgui2/tests/edittest.dpr
index e4107d50..29089e93 100644
--- a/prototypes/fpgui2/tests/edittest.dpr
+++ b/prototypes/fpgui2/tests/edittest.dpr
@@ -366,6 +366,7 @@ begin
label1 := CreateLabel(self, 5, 5, 'Hello world!');
label2 := CreateLabel(self, 5, 20, 'Hello world in Bold!');
label2.FontDesc := 'Sans-12:bold:underline';
+ label2.Width := 200;
w := TMyWidget.Create(self);
w.Top := 40;
@@ -408,7 +409,7 @@ begin
memo.Left := 250;
memo.Width := 200;
memo.Height := 80;
- memo.Anchors := [anLeft, anTop, anRight, anBottom];
+// memo.Anchors := [anLeft, anTop, anRight, anBottom];
listbox := TfpgListBox.Create(self);
listbox.Top := 100;
diff --git a/prototypes/fpgui2/tests/edittest.lpi b/prototypes/fpgui2/tests/edittest.lpi
index 1ecb384f..9392cdcb 100644
--- a/prototypes/fpgui2/tests/edittest.lpi
+++ b/prototypes/fpgui2/tests/edittest.lpi
@@ -1,7 +1,7 @@
<?xml version="1.0"?>
<CONFIG>
<ProjectOptions>
- <PathDelim Value="/"/>
+ <PathDelim Value="\"/>
<Version Value="5"/>
<General>
<Flags>
@@ -9,7 +9,7 @@
</Flags>
<SessionStorage Value="InProjectDir"/>
<MainUnit Value="0"/>
- <IconPath Value="./"/>
+ <IconPath Value=".\"/>
<TargetFileExt Value=""/>
</General>
<VersionInfo>
@@ -23,7 +23,7 @@
<RunParams>
<local>
<FormatVersion Value="1"/>
- <LaunchingApplication PathPlusParams="/usr/X11R6/bin/xterm -T 'Lazarus Run Output' -e $(LazarusDir)/tools/runwait.sh $(TargetCmdLine)"/>
+ <LaunchingApplication PathPlusParams="\usr\X11R6\bin\xterm -T 'Lazarus Run Output' -e $(LazarusDir)\tools\runwait.sh $(TargetCmdLine)"/>
</local>
</RunParams>
<RequiredPackages Count="1">
@@ -32,16 +32,22 @@
<MinVersion Minor="5" Valid="True"/>
</Item1>
</RequiredPackages>
- <Units Count="1">
+ <Units Count="2">
<Unit0>
<Filename Value="edittest.dpr"/>
<IsPartOfProject Value="True"/>
<UnitName Value="edittest"/>
</Unit0>
+ <Unit1>
+ <Filename Value="uhelpers.pas"/>
+ <IsPartOfProject Value="True"/>
+ <UnitName Value="uhelpers"/>
+ </Unit1>
</Units>
</ProjectOptions>
<CompilerOptions>
<Version Value="5"/>
+ <PathDelim Value="\"/>
<CodeGeneration>
<Generate Value="Faster"/>
</CodeGeneration>
diff --git a/src/corelib/gdi/gfx_gdi.pas b/src/corelib/gdi/gfx_gdi.pas
index 97b72460..5ee48268 100644
--- a/src/corelib/gdi/gfx_gdi.pas
+++ b/src/corelib/gdi/gfx_gdi.pas
@@ -23,12 +23,10 @@ var
UnicodeEnabledOS: Boolean;
WinVersion: TOSVersionInfo;
-
type
-// TfpgWinHandle = HWND;
- TfpgGContext = HDC;
+ TfpgGContext = HDC;
-type
+ // forward declaration
TfpgWindowImpl = class;
@@ -70,14 +68,12 @@ type
end;
- { TfpgCanvasImpl }
-
TfpgCanvasImpl = class(TfpgCanvasBase)
private
FDrawing: boolean;
FBufferBitmap: HBitmap;
FDrawWindow: TfpgWindowImpl;
- Fgc,
+ Fgc: TfpgGContext;
fBufgc: TfpgGContext;
FWinGC: TfpgGContext;
FBackgroundColor: TfpgColor;
@@ -89,7 +85,7 @@ type
FPen: HPEN;
FClipRegion: HRGN;
FIntLineStyle: integer;
- FBufWidth,
+ FBufWidth: Integer;
FBufHeight: Integer;
procedure TryFreeBackBuffer;
protected
@@ -1359,27 +1355,21 @@ begin
end;
procedure TfpgCanvasImpl.DoSetColor(cl: TfpgColor);
-var
- newBrush, oldBrush: HBRUSH;
- newPen, oldPen: HPEN;
begin
- FWindowsColor := fpgColorToWin(cl);
+ DeleteObject(FBrush);
+ DeleteObject(FPen);
- newBrush := CreateSolidBrush(FWindowsColor);
- newPen := CreatePen(FintLineStyle, FLineWidth, FWindowsColor);
- oldBrush := SelectObject(Fgc, newBrush);
- oldPen := SelectObject(Fgc, newPen);
- FBrush := newBrush;
- FPen := newPen;
+ FWindowsColor := fpgColorToWin(cl);
- DeleteObject(oldBrush);
- DeleteObject(oldPen);
+ FBrush := CreateSolidBrush(FWindowsColor);
+ FPen := CreatePen(FintLineStyle, FLineWidth, FWindowsColor);
+ SelectObject(Fgc, FBrush);
+ SelectObject(Fgc, FPen);
end;
procedure TfpgCanvasImpl.DoSetLineStyle(awidth: integer; astyle: TfpgLineStyle);
var
lw: integer;
- lPen: HPEN;
begin
{ Notes from MSDN: If the value specified by nWidth is greater
than 1, the fnPenStyle parameter must be PS_NULL, PS_SOLID, or
@@ -1408,10 +1398,9 @@ PS_INSIDEFRAME. }
end;
end;
- Windows.DeleteObject(FPen);
- lPen := CreatePen(FintLineStyle, lw, FWindowsColor);
- Windows.SelectObject(Fgc, lPen);
- FPen := lPen;
+ DeleteObject(FPen);
+ FPen := CreatePen(FintLineStyle, lw, FWindowsColor);
+ SelectObject(Fgc, FPen);
end;
procedure TfpgCanvasImpl.DoSetTextColor(cl: TfpgColor);