diff options
-rw-r--r-- | docs/xml/corelib/gfxbase.xml | 10 | ||||
-rw-r--r-- | examples/apps/docedit/docedit.lpi | 8 | ||||
-rw-r--r-- | examples/apps/docedit/frm_main.pas | 2 | ||||
-rw-r--r-- | examples/apps/uidesigner/uidesigner.lpi | 9 | ||||
-rw-r--r-- | src/corelib/fpgfx.pas | 4 | ||||
-rw-r--r-- | src/corelib/gfxbase.pas | 45 |
6 files changed, 66 insertions, 12 deletions
diff --git a/docs/xml/corelib/gfxbase.xml b/docs/xml/corelib/gfxbase.xml index 7c1ea556..6b41aaa1 100644 --- a/docs/xml/corelib/gfxbase.xml +++ b/docs/xml/corelib/gfxbase.xml @@ -10,8 +10,16 @@ <module name="gfxbase"> <short>The base unit and starting point of fpGUI</short> -<descr>This unit contains all the abstract classes for the CoreLib code +<descr> +<p> +This unit contains all the abstract classes for the CoreLib code of fpGUI. It also defines many types and constants used throughout the toolkit. +</p> +<p> +When implementing support for a completely new windowing system +(eg: Carbon used in Mac OS-X) you would implement all the abstract methods +defined in this unit. +</p> </descr> <!-- unresolved type reference Visibility: default --> diff --git a/examples/apps/docedit/docedit.lpi b/examples/apps/docedit/docedit.lpi index 7d1ca058..ac254e0a 100644 --- a/examples/apps/docedit/docedit.lpi +++ b/examples/apps/docedit/docedit.lpi @@ -2,7 +2,7 @@ <CONFIG> <ProjectOptions> <PathDelim Value="/"/> - <Version Value="5"/> + <Version Value="6"/> <General> <Flags> <SaveOnlyProjectUnits Value="True"/> @@ -28,11 +28,11 @@ </RunParams> <RequiredPackages Count="2"> <Item1> - <PackageName Value="fpgui_package"/> - <MinVersion Minor="5" Valid="True"/> + <PackageName Value="FCL"/> </Item1> <Item2> - <PackageName Value="FCL"/> + <PackageName Value="fpgui_package"/> + <MinVersion Minor="5" Valid="True"/> </Item2> </RequiredPackages> <Units Count="3"> diff --git a/examples/apps/docedit/frm_main.pas b/examples/apps/docedit/frm_main.pas index 93dbe069..5467752e 100644 --- a/examples/apps/docedit/frm_main.pas +++ b/examples/apps/docedit/frm_main.pas @@ -156,7 +156,7 @@ begin ShowMessage(cAppName + #10 + #10 + 'Written by Graeme Geldenhuys - 2007' - + #10 + 'Using the fpGUI toolkit' + + #10 + 'Using the ' + fpGUIName + ' v' + fpGUIVersion ,'About'); end; diff --git a/examples/apps/uidesigner/uidesigner.lpi b/examples/apps/uidesigner/uidesigner.lpi index cd6e7a2d..683e219a 100644 --- a/examples/apps/uidesigner/uidesigner.lpi +++ b/examples/apps/uidesigner/uidesigner.lpi @@ -1,15 +1,15 @@ <?xml version="1.0"?> <CONFIG> <ProjectOptions> - <PathDelim Value="\"/> - <Version Value="5"/> + <PathDelim Value="/"/> + <Version Value="6"/> <General> <Flags> <SaveOnlyProjectUnits Value="True"/> </Flags> <SessionStorage Value="InProjectDir"/> <MainUnit Value="0"/> - <IconPath Value=".\"/> + <IconPath Value="./"/> <TargetFileExt Value=""/> <Title Value="uiDesigner"/> </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"> @@ -108,7 +108,6 @@ </ProjectOptions> <CompilerOptions> <Version Value="5"/> - <PathDelim Value="\"/> <Parsing> <SyntaxOptions> <AllowLabel Value="False"/> diff --git a/src/corelib/fpgfx.pas b/src/corelib/fpgfx.pas index be4254d9..c2c64cfe 100644 --- a/src/corelib/fpgfx.pas +++ b/src/corelib/fpgfx.pas @@ -37,6 +37,10 @@ const // Used for the internal message queue cMessageQueueSize = 512; + + // version and name constants + fpGUIVersion = '0.5.1'; + fpGUIName = 'fpGUI Library'; type diff --git a/src/corelib/gfxbase.pas b/src/corelib/gfxbase.pas index 9ae7f503..173b8017 100644 --- a/src/corelib/gfxbase.pas +++ b/src/corelib/gfxbase.pas @@ -342,6 +342,7 @@ type public // The standard constructor. constructor Create(AOwner: TComponent); override; + procedure AfterConstruction; override; // Make some setup before the window shows. Forms modify the window creation parameters. procedure AdjustWindowStyle; virtual; // Make some setup before the window shows. Invoked after the window is created. @@ -408,7 +409,13 @@ procedure SortRect(var left, top, right, bottom: integer); implementation uses - fpgfx; // needed for fpgApplication + fpgfx, // needed for fpgApplication + typinfo; + + +const + NoDefault = $80000000; + tkPropsWithDefault = [tkInteger, tkChar, tkSet, tkEnumeration]; function KeycodeToText(AKey: Word; AShiftState: TShiftState): string; @@ -660,6 +667,32 @@ begin SortRect(left, top, right, bottom); end; +// This function uses RTTI to automatically set the default values of properties. +// That means we don't have to do it in the constructor anymore! :-) +procedure SetDefaults(Obj: TObject); +var + PropInfos: PPropList; + Count, Loop: Integer; +begin + PropInfos := nil; + { Find out how many properties we'll be considering } + Count := GetPropList(Obj.ClassInfo, tkPropsWithDefault, nil); + { Allocate memory to hold their RTTI data } + GetMem(PropInfos, Count * SizeOf(PPropInfo)); + try + { Get hold of the property list in our new buffer } + GetPropList(Obj.ClassInfo, tkPropsWithDefault, PropInfos); + { Loop through all the selected properties } + for Loop := 0 to Count - 1 do + with PropInfos^[Loop]^ do + { If there is supposed to be a default value... } + if Default <> NoDefault then + { ...then jolly well set it } + SetOrdProp(Obj, PropInfos^[Loop], Default) + finally + FreeMem(PropInfos, Count * SizeOf(PPropInfo)); + end; +end; { TfpgRect } @@ -755,6 +788,16 @@ begin FMouseCursor := mcDefault; end; +procedure TfpgWindowBase.AfterConstruction; +begin + inherited AfterConstruction; + { Here is a neater way by using RTTI to set default property values all + automatically. No need to duplicate the efforts and manually set the + property default values in the constructor. This code is no the same for + each TfpgWindowBase descendant (which includes GUI widgets) } +// SetDefaults(self); +end; + procedure TfpgWindowBase.AdjustWindowStyle; begin // does nothing here |