diff options
author | graemeg <graemeg@ae50a9b5-8222-0410-bf8d-8a13f76226bf> | 2007-07-27 15:04:35 +0000 |
---|---|---|
committer | graemeg <graemeg@ae50a9b5-8222-0410-bf8d-8a13f76226bf> | 2007-07-27 15:04:35 +0000 |
commit | 0e2ffba0302d927fa856cbd62f725417714cc74c (patch) | |
tree | 8d51ff8d40cbb2f875bccccfe4b29744ee7d9e64 | |
parent | 79f3d57b899e797fe9acc116146bf64e0327deb9 (diff) | |
download | fpGUI-0e2ffba0302d927fa856cbd62f725417714cc74c.tar.xz |
* Added the new test project I forgot earlier.
* Minor compiler fix for GDI.
-rw-r--r-- | examples/corelib/canvastest/fpgcanvas.lpi | 7 | ||||
-rw-r--r-- | prototypes/fpgui2/tests/drawtest.bmp | bin | 0 -> 7654 bytes | |||
-rw-r--r-- | prototypes/fpgui2/tests/drawtest.lpi | 176 | ||||
-rw-r--r-- | prototypes/fpgui2/tests/drawtest.lpr | 124 | ||||
-rw-r--r-- | prototypes/fpgui2/tests/edittest.lpi | 7 | ||||
-rw-r--r-- | prototypes/fpgui2/tests/square.bmp | bin | 0 -> 7654 bytes | |||
-rw-r--r-- | src/corelib/gdi/gfx_gdi.pas | 19 |
7 files changed, 315 insertions, 18 deletions
diff --git a/examples/corelib/canvastest/fpgcanvas.lpi b/examples/corelib/canvastest/fpgcanvas.lpi index 71f908fb..7f1c6c21 100644 --- a/examples/corelib/canvastest/fpgcanvas.lpi +++ b/examples/corelib/canvastest/fpgcanvas.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=""/> <Title Value="fpcanvas"/> </General> @@ -24,7 +24,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"> @@ -43,6 +43,7 @@ </ProjectOptions> <CompilerOptions> <Version Value="5"/> + <PathDelim Value="\"/> <CodeGeneration> <Generate Value="Faster"/> </CodeGeneration> diff --git a/prototypes/fpgui2/tests/drawtest.bmp b/prototypes/fpgui2/tests/drawtest.bmp Binary files differnew file mode 100644 index 00000000..2a3ec501 --- /dev/null +++ b/prototypes/fpgui2/tests/drawtest.bmp diff --git a/prototypes/fpgui2/tests/drawtest.lpi b/prototypes/fpgui2/tests/drawtest.lpi new file mode 100644 index 00000000..9ae3898f --- /dev/null +++ b/prototypes/fpgui2/tests/drawtest.lpi @@ -0,0 +1,176 @@ +<?xml version="1.0"?> +<CONFIG> + <ProjectOptions> + <PathDelim Value="\"/> + <Version Value="5"/> + <General> + <MainUnit Value="0"/> + <IconPath Value=".\"/> + <TargetFileExt Value=""/> + <ActiveEditorIndexAtStart Value="0"/> + </General> + <VersionInfo> + <ProjectVersion Value=""/> + <Language Value=""/> + <CharSet Value=""/> + </VersionInfo> + <PublishOptions> + <Version Value="2"/> + <DestinationDirectory Value="$(TestDir)\publishedproject\"/> + <IgnoreBinaries Value="False"/> + <IncludeFileFilter Value="*.(pas|pp|inc|lfm|lpr|lrs|lpi|lpk|sh|xml)"/> + <ExcludeFileFilter Value="*.(bak|ppu|ppw|o|so);*~;backup"/> + </PublishOptions> + <RunParams> + <local> + <FormatVersion Value="1"/> + <LaunchingApplication PathPlusParams="\usr\X11R6\bin\xterm -T 'Lazarus Run Output' -e $(LazarusDir)\tools\runwait.sh $(TargetCmdLine)"/> + </local> + </RunParams> + <RequiredPackages Count="1"> + <Item1> + <PackageName Value="fpgui_package"/> + </Item1> + </RequiredPackages> + <Units Count="17"> + <Unit0> + <Filename Value="drawtest.lpr"/> + <IsPartOfProject Value="True"/> + <UnitName Value="drawtest"/> + <CursorPos X="23" Y="37"/> + <TopLine Value="29"/> + <EditorIndex Value="0"/> + <UsageCount Value="24"/> + <Loaded Value="True"/> + </Unit0> + <Unit1> + <Filename Value="..\..\..\src\corelib\gfx_imgfmt_bmp.pas"/> + <UnitName Value="gfx_imgfmt_bmp"/> + <CursorPos X="24" Y="18"/> + <TopLine Value="1"/> + <EditorIndex Value="5"/> + <UsageCount Value="12"/> + <Loaded Value="True"/> + </Unit1> + <Unit2> + <Filename Value="..\..\..\src\corelib\predefinedcolors.inc"/> + <CursorPos X="15" Y="112"/> + <TopLine Value="102"/> + <EditorIndex Value="1"/> + <UsageCount Value="11"/> + <Loaded Value="True"/> + </Unit2> + <Unit3> + <Filename Value="..\..\..\src\corelib\gfxbase.pas"/> + <UnitName Value="gfxbase"/> + <CursorPos X="17" Y="240"/> + <TopLine Value="230"/> + <EditorIndex Value="2"/> + <UsageCount Value="12"/> + <Loaded Value="True"/> + </Unit3> + <Unit4> + <Filename Value="..\..\..\src\corelib\x11\gfx_x11.pas"/> + <UnitName Value="gfx_x11"/> + <CursorPos X="63" Y="1444"/> + <TopLine Value="1432"/> + <EditorIndex Value="3"/> + <UsageCount Value="12"/> + <Loaded Value="True"/> + </Unit4> + <Unit5> + <Filename Value="..\..\..\src\corelib\gdi\gfx_gdi.pas"/> + <UnitName Value="gfx_gdi"/> + <CursorPos X="31" Y="1231"/> + <TopLine Value="1193"/> + <EditorIndex Value="4"/> + <UsageCount Value="12"/> + <Loaded Value="True"/> + </Unit5> + <Unit6> + <Filename Value="..\..\..\..\..\FPC\2.0.x\src\rtl\objpas\classes\classesh.inc"/> + <CursorPos X="14" Y="25"/> + <TopLine Value="15"/> + <UsageCount Value="10"/> + </Unit6> + <Unit7> + <Filename Value="..\..\..\..\..\FPC\2.0.x\src\rtl\objpas\types.pp"/> + <UnitName Value="types"/> + <CursorPos X="13" Y="21"/> + <TopLine Value="5"/> + <UsageCount Value="10"/> + </Unit7> + <Unit8> + <Filename Value="..\..\..\..\..\FPC\2.0.x\src\rtl\win32\windows.pp"/> + <UnitName Value="windows"/> + <CursorPos X="7" Y="33"/> + <TopLine Value="21"/> + <UsageCount Value="10"/> + </Unit8> + <Unit9> + <Filename Value="..\..\..\..\..\FPC\2.0.x\src\rtl\win32\wininc\struct.inc"/> + <CursorPos X="12" Y="220"/> + <TopLine Value="210"/> + <UsageCount Value="10"/> + </Unit9> + <Unit10> + <Filename Value="..\..\..\src\gui\gui_listbox.pas"/> + <UnitName Value="gui_listbox"/> + <CursorPos X="1" Y="516"/> + <TopLine Value="506"/> + <UsageCount Value="10"/> + </Unit10> + <Unit11> + <Filename Value="..\..\..\src\gui\gui_button.pas"/> + <UnitName Value="gui_button"/> + <CursorPos X="1" Y="221"/> + <TopLine Value="210"/> + <UsageCount Value="10"/> + </Unit11> + <Unit12> + <Filename Value="..\..\..\src\gui\gui_combobox.pas"/> + <UnitName Value="gui_combobox"/> + <CursorPos X="11" Y="287"/> + <TopLine Value="269"/> + <UsageCount Value="10"/> + </Unit12> + <Unit13> + <Filename Value="..\..\..\src\gui\gui_edit.pas"/> + <UnitName Value="gui_edit"/> + <CursorPos X="12" Y="215"/> + <TopLine Value="204"/> + <UsageCount Value="10"/> + </Unit13> + <Unit14> + <Filename Value="..\..\..\src\gui\gui_memo.pas"/> + <UnitName Value="gui_memo"/> + <CursorPos X="11" Y="636"/> + <TopLine Value="625"/> + <UsageCount Value="10"/> + </Unit14> + <Unit15> + <Filename Value="..\..\..\..\..\FPC\2.0.x\src\rtl\win32\wininc\func.inc"/> + <CursorPos X="1" Y="753"/> + <TopLine Value="745"/> + <UsageCount Value="10"/> + </Unit15> + <Unit16> + <Filename Value="..\..\..\..\..\FPC\2.0.x\src\rtl\win32\wininc\redef.inc"/> + <CursorPos X="18" Y="692"/> + <TopLine Value="681"/> + <UsageCount Value="10"/> + </Unit16> + </Units> + <JumpHistory Count="0" HistoryIndex="-1"/> + </ProjectOptions> + <CompilerOptions> + <Version Value="5"/> + <PathDelim Value="\"/> + <CodeGeneration> + <Generate Value="Faster"/> + </CodeGeneration> + <Other> + <CompilerPath Value="$(CompPath)"/> + </Other> + </CompilerOptions> +</CONFIG> diff --git a/prototypes/fpgui2/tests/drawtest.lpr b/prototypes/fpgui2/tests/drawtest.lpr new file mode 100644 index 00000000..e7506645 --- /dev/null +++ b/prototypes/fpgui2/tests/drawtest.lpr @@ -0,0 +1,124 @@ +program drawtest; + +{$mode objfpc}{$H+} + +uses + {$IFDEF UNIX}{$IFDEF UseCThreads} + cthreads, + {$ENDIF}{$ENDIF} + Classes, + fpgfx, + gfxbase, + gui_form, + gfx_imgfmt_bmp; + +type + + TMainForm = class(TfpgForm) + private + img: TfpgImage; + finalimg: TfpgImage; + protected + procedure HandlePaint; override; + procedure HandleShow; override; + public + constructor Create(AOwner: TComponent); override; + destructor Destroy; override; + end; + +{ TMainForm } + +procedure TMainForm.HandlePaint; +var + r: TfpgRect; +begin + Canvas.BeginDraw; + inherited HandlePaint; + Canvas.Clear(clSteelBlue); + + Canvas.DrawString(10, 10, 'Original 50x50 image:'); + Canvas.DrawImage(200, 10, img); + Canvas.DrawString(10, 60, 'All line and pixel drawing must only appear'); + Canvas.DrawString(10, 60+Canvas.Font.Height, 'on black rectangles. Watch for line start and'); + Canvas.DrawString(10, 60+(Canvas.Font.Height*2), 'ending points.'); + + // final image + Canvas.DrawString(10, 195-Canvas.Font.Height, 'The final images should look line this:'); + Canvas.DrawImage(100, 200, finalimg); + + // blank rectangle image + Canvas.DrawImage(100, 100, img); + + // rectangle + Canvas.SetColor(clRed); + Canvas.DrawRectangle(102, 102, 147, 147); // (over second outer black rectangle) + Canvas.SetColor(clMagenta); + Canvas.DrawRectangle(104, 104, 145, 145); // (over third outer black rectangle) + + // Point (outer 4 corners) + Canvas.Pixels[100, 100] := clBlue; + Canvas.Pixels[149, 100] := clBlue; + Canvas.Pixels[100, 149] := clBlue; + Canvas.Pixels[149, 149] := clBlue; + + // FillRect + Canvas.SetColor(clYellow); + Canvas.FillRectangle(111, 111, 139, 139); // inner white rectangle + + // line diagonal + Canvas.SetColor(clRed); + Canvas.DrawLine(110, 110, 139, 139); // top/left of inner black rect to bottom/right + Canvas.SetColor(clGreen); + Canvas.DrawLine(139, 110, 110, 139); // top/right of inner black rect to bottom/left + + // line vertical + Canvas.SetColor(clBlue); + Canvas.DrawLine(108, 108, 108, 141); + Canvas.DrawLine(141, 108, 141, 141); + + // line horizontal + Canvas.SetColor(clGreen); + Canvas.DrawLine(106, 106, 143, 106); + Canvas.DrawLine(106, 143, 143, 143); + + + Canvas.EndDraw; +end; + +procedure TMainForm.HandleShow; +begin + img := LoadImage_BMP('square.bmp'); + finalimg := LoadImage_BMP('drawtest.bmp'); + inherited HandleShow; +end; + +constructor TMainForm.Create(AOwner: TComponent); +begin + inherited Create(AOwner); + WindowTitle := 'Draw test'; + SetPosition(100, 100, 300, 300); + +end; + +destructor TMainForm.Destroy; +begin + img.Free; + finalimg.Free; + inherited Destroy; +end; + + +procedure MainProc; +var + frm: TMainForm; +begin + fpgApplication.Initialize; + frm := TMainForm.Create(nil); + frm.Show; + fpgApplication.Run; +end; + +begin + MainProc; +end. + diff --git a/prototypes/fpgui2/tests/edittest.lpi b/prototypes/fpgui2/tests/edittest.lpi index 1ecb384f..b609d403 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"> @@ -42,6 +42,7 @@ </ProjectOptions> <CompilerOptions> <Version Value="5"/> + <PathDelim Value="\"/> <CodeGeneration> <Generate Value="Faster"/> </CodeGeneration> diff --git a/prototypes/fpgui2/tests/square.bmp b/prototypes/fpgui2/tests/square.bmp Binary files differnew file mode 100644 index 00000000..89f68647 --- /dev/null +++ b/prototypes/fpgui2/tests/square.bmp diff --git a/src/corelib/gdi/gfx_gdi.pas b/src/corelib/gdi/gfx_gdi.pas index aad8429e..f9a40f77 100644 --- a/src/corelib/gdi/gfx_gdi.pas +++ b/src/corelib/gdi/gfx_gdi.pas @@ -90,7 +90,7 @@ type procedure DoSetTextColor(cl: TfpgColor); override; procedure DoSetColor(cl: TfpgColor); override; procedure DoSetLineStyle(awidth: integer; astyle: TfpgLineStyle); override; - procedure DoGetWinRect(var r: TfpgRect); override; + procedure DoGetWinRect(out r: TRect); override; procedure DoFillRectangle(x1, y1, x2, y2: TfpgCoord); override; procedure DoXORFillRectangle(col: TfpgColor; x, y, w, h: TfpgCoord); override; procedure DoFillTriangle(x1, y1, x2, y2, x3, y3: TfpgCoord); override; @@ -1080,7 +1080,7 @@ end; procedure TfpgCanvasImpl.DoBeginDraw(awin: TfpgWindowBase; buffered: boolean); var - ARect: TfpgRect; + ARect: TRect; bmsize: Windows.TSIZE; begin if FDrawing and buffered and (FBufferBitmap > 0) then @@ -1089,7 +1089,8 @@ begin GetBitmapDimensionEx(FBufferBitmap, bmsize); FDrawWindow := TfpgWindowImpl(awin); DoGetWinRect(ARect); - if (bmsize.cx <> ARect.Width) or (bmsize.cy <> ARect.Height) then + if (bmsize.cx <> (ARect.Right-ARect.Left+1)) or + (bmsize.cy <> (ARect.Bottom-ARect.Top+1)) then DoEndDraw; end; @@ -1101,7 +1102,7 @@ begin if buffered then begin DoGetWinRect(ARect); - FBufferBitmap := Windows.CreateCompatibleBitmap(FWinGC, ARect.Width, ARect.Height); + FBufferBitmap := Windows.CreateCompatibleBitmap(FWinGC, (ARect.Right-ARect.Left+1), (ARect.Bottom-ARect.Top+1)); Fgc := CreateCompatibleDC(FWinGC); SelectObject(Fgc, FBufferBitmap); end @@ -1272,15 +1273,9 @@ begin Result := FClipRect; end; -procedure TfpgCanvasImpl.DoGetWinRect(var r: TfpgRect); -var - wr: Windows.TRECT; +procedure TfpgCanvasImpl.DoGetWinRect(out r: TRect); begin - GetClientRect(FDrawWindow.FWinHandle, wr); - r.top := wr.Top; - r.left := wr.Left; - r.Width := wr.Right - wr.Left + 1; - r.Height := wr.Bottom - wr.Top + 1; + GetClientRect(FDrawWindow.FWinHandle, r); end; procedure TfpgCanvasImpl.DoSetClipRect(const ARect: TRect); |