diff options
author | graemeg <graemeg@ae50a9b5-8222-0410-bf8d-8a13f76226bf> | 2007-08-08 14:26:10 +0000 |
---|---|---|
committer | graemeg <graemeg@ae50a9b5-8222-0410-bf8d-8a13f76226bf> | 2007-08-08 14:26:10 +0000 |
commit | e94ba620f4168468bb3e1826cac641bb4a369c09 (patch) | |
tree | 1fb70141bff75e93e279b498f057d52b6cf90aa2 /prototypes | |
parent | b19a28c30e51a0603560b7d24fc7fae887400790 (diff) | |
download | fpGUI-e94ba620f4168468bb3e1826cac641bb4a369c09.tar.xz |
* Finally fixed all painting issues with rectangles and clipping.
* Reverted the methods back to using TfpgRect instead of TRect. TfpgRect has better
support for Width and Heigh - required by many Canvas methods.
* Implemented helper functions like InflateRect but support TfpgRect
* Fixed all painting issues and rectangle sizes in all components.
* Fixed up all examples and test projects to compile and work correctly.
* Fixes some clip rectangle issues under Linux. TfpgRect was a big help.
* Changed the method signatures of many Canvas methods to rather use x, y, width and height.
This causes much less confusion and actually less coding in widgets.
Diffstat (limited to 'prototypes')
-rw-r--r-- | prototypes/fpgui2/tests/drawtest.lpi | 153 | ||||
-rw-r--r-- | prototypes/fpgui2/tests/edittest.dpr | 62 | ||||
-rw-r--r-- | prototypes/fpgui2/tests/themetest.lpr | 4 |
3 files changed, 62 insertions, 157 deletions
diff --git a/prototypes/fpgui2/tests/drawtest.lpi b/prototypes/fpgui2/tests/drawtest.lpi index 649c24b9..48070ffb 100644 --- a/prototypes/fpgui2/tests/drawtest.lpi +++ b/prototypes/fpgui2/tests/drawtest.lpi @@ -4,15 +4,16 @@ <PathDelim Value="/"/> <Version Value="5"/> <General> + <Flags> + <SaveOnlyProjectUnits Value="True"/> + </Flags> + <SessionStorage Value="InProjectDir"/> <MainUnit Value="0"/> <IconPath Value="./"/> <TargetFileExt Value=""/> - <ActiveEditorIndexAtStart Value="1"/> </General> <VersionInfo> <ProjectVersion Value=""/> - <Language Value=""/> - <CharSet Value=""/> </VersionInfo> <PublishOptions> <Version Value="2"/> @@ -31,157 +32,13 @@ <PackageName Value="fpgui_package"/> </Item1> </RequiredPackages> - <Units Count="21"> + <Units Count="1"> <Unit0> <Filename Value="drawtest.lpr"/> <IsPartOfProject Value="True"/> <UnitName Value="drawtest"/> - <CursorPos X="32" Y="72"/> - <TopLine Value="58"/> - <EditorIndex Value="0"/> - <UsageCount Value="26"/> - <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"/> - <UsageCount Value="12"/> - </Unit1> - <Unit2> - <Filename Value="../../../src/corelib/predefinedcolors.inc"/> - <CursorPos X="15" Y="112"/> - <TopLine Value="102"/> - <UsageCount Value="12"/> - </Unit2> - <Unit3> - <Filename Value="../../../src/corelib/gfxbase.pas"/> - <UnitName Value="gfxbase"/> - <CursorPos X="17" Y="240"/> - <TopLine Value="230"/> - <EditorIndex Value="1"/> - <UsageCount Value="13"/> - <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="2"/> - <UsageCount Value="13"/> - <Loaded Value="True"/> - </Unit4> - <Unit5> - <Filename Value="../../../src/corelib/gdi/gfx_gdi.pas"/> - <UnitName Value="gfx_gdi"/> - <CursorPos X="9" Y="1252"/> - <TopLine Value="1250"/> - <UsageCount Value="12"/> - </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> - <Unit17> - <Filename Value="../../../../3rdParty/tiOPF2/Source/GUI/tiButtons.pas"/> - <UnitName Value="tiButtons"/> - <CursorPos X="7" Y="9"/> - <TopLine Value="1"/> - <UsageCount Value="10"/> - </Unit17> - <Unit18> - <Filename Value="/opt/lazarus/lcl/comctrls.pp"/> - <UnitName Value="ComCtrls"/> - <CursorPos X="1" Y="1"/> - <TopLine Value="1"/> - <UsageCount Value="10"/> - </Unit18> - <Unit19> - <Filename Value="/opt/fpc/src/rtl/unix/classes.pp"/> - <UnitName Value="Classes"/> - <CursorPos X="8" Y="42"/> - <TopLine Value="24"/> - <UsageCount Value="10"/> - </Unit19> - <Unit20> - <Filename Value="/opt/fpc/src/rtl/objpas/classes/classes.inc"/> - <CursorPos X="1" Y="1"/> - <TopLine Value="44"/> - <UsageCount Value="10"/> - </Unit20> </Units> - <JumpHistory Count="0" HistoryIndex="-1"/> </ProjectOptions> <CompilerOptions> <Version Value="5"/> diff --git a/prototypes/fpgui2/tests/edittest.dpr b/prototypes/fpgui2/tests/edittest.dpr index 511cd404..2313dd70 100644 --- a/prototypes/fpgui2/tests/edittest.dpr +++ b/prototypes/fpgui2/tests/edittest.dpr @@ -7,6 +7,7 @@ uses SysUtils, gfxbase, fpgfx, + gfx_widget, gfx_imgfmt_bmp, gui_form, gui_label, @@ -23,8 +24,6 @@ uses type - { TXPButton } - TXPButton = class(TfpgButton) private State: integer; @@ -48,7 +47,14 @@ type property ThemeImage: TfpgImage read image write SetThemeImage; end; - { TMainForm } + + TMyWidget = class(TfpgWidget) + protected + procedure HandlePaint; override; + public + constructor Create(AOwner: TComponent); override; + end; + TMainForm = class(TfpgForm) private @@ -81,9 +87,47 @@ type radiobtn3: TfpgRadioButton; trackbar1: TfpgTrackBar; trackbar2: TfpgTrackBar; + w: TMyWidget; procedure AfterCreate; override; end; +{ TMyWidget } + +procedure TMyWidget.HandlePaint; +var + r: TfpgRect; +begin + Canvas.BeginDraw; + inherited HandlePaint; + Canvas.Clear(clBlue); + + r.SetRect(0, 0, Width, Height); + Canvas.SetColor(clBlack); + Canvas.DrawRectangle(r); + + InflateRect(r, -1, -1); + Canvas.SetColor(clRed); + Canvas.DrawRectangle(r); + + InflateRect(r, -1, -1); +// Canvas.DrawControlFrame(2, 2, Width-4, Height-4); + writeln('000000'); + Canvas.DrawControlFrame(r); + writeln('111111'); +{ + Canvas.SetColor(clGreen); + Canvas.FillRectangle(r); +} + Canvas.EndDraw; +end; + +constructor TMyWidget.Create(AOwner: TComponent); +begin + inherited Create(AOwner); + FWidth := 15; + FHeight := 22; +end; + { TXPButton } procedure TXPButton.SetThemeImage(const AValue: TfpgImage); @@ -97,7 +141,7 @@ end; procedure TXPButton.HandlePaint; var x, i: integer; - r: TRect; + r: TfpgRect; iy, y: integer; w: integer; pofs: integer; @@ -107,7 +151,7 @@ begin Canvas.ClearClipRect; Canvas.Clear(clButtonFace); - r := Rect(0, 0, Width, Height); + r.SetRect(0, 0, Width, Height); if State <> 1 then begin @@ -148,7 +192,7 @@ begin Canvas.SetClipRect(r); Canvas.SetFont(Font); - y := Height div 2 - FFont.Height div 2; + y := (Height div 2) - (FFont.Height div 2); if y < 3 then y := 3; @@ -160,7 +204,7 @@ begin if (ShowImage) and (FImage <> nil) then begin - iy := Height div 2 - FImage.Height div 2; + iy := (Height div 2) - (FImage.Height div 2); if ImageMargin = -1 then // centered begin w := FFont.TextWidth(FText) + FImage.Width; @@ -325,6 +369,10 @@ begin label1 := CreateLabel(self, 5, 5, 'Hello world!'); label2 := CreateLabel(self, 5, 20, 'Hello world in Bold!'); label2.FontDesc := 'Sans-12:bold:underline'; + + w := TMyWidget.Create(self); + w.Top := 40; + w.Left := 140; edit1 := CreateEdit(self, 10, 40, 120, 22); edit1.Text := 'Hello world. Hello world. Hello world.'; diff --git a/prototypes/fpgui2/tests/themetest.lpr b/prototypes/fpgui2/tests/themetest.lpr index da310996..0aa5f251 100644 --- a/prototypes/fpgui2/tests/themetest.lpr +++ b/prototypes/fpgui2/tests/themetest.lpr @@ -224,7 +224,7 @@ end; procedure TThemeButton.HandlePaint; var x, i: integer; - r: TRect; + r: TfpgRect; iy, y: integer; w: integer; pofs: integer; @@ -233,7 +233,7 @@ begin // inherited HandlePaint; Canvas.ClearClipRect; Canvas.Clear(clButtonFace); - r := Rect(0, 0, Width-1, Height-1); + r.SetRect(0, 0, Width, Height); if State <> 1 then begin |