diff options
author | Graeme Geldenhuys <graemeg@users.sourceforge.net> | 2006-11-18 18:11:20 +0000 |
---|---|---|
committer | Graeme Geldenhuys <graemeg@users.sourceforge.net> | 2006-11-18 18:11:20 +0000 |
commit | 8fe7ea95a343a35dc286bd9a13d257d285e9c4e1 (patch) | |
tree | ea9f9317f46f4c320a2667e0e0d4362c4f0980a3 /examples/gui | |
parent | 546dce65494ea4e5f654e2840cc67307101e06f7 (diff) | |
download | fpGUI-8fe7ea95a343a35dc286bd9a13d257d285e9c4e1.tar.xz |
Initial checkin. Merged fpGUI, fpGFX and fpIMG from the OpenSoft sever.
Diffstat (limited to 'examples/gui')
47 files changed, 10915 insertions, 0 deletions
diff --git a/examples/gui/concepttest/OpenSoftStyle.pas b/examples/gui/concepttest/OpenSoftStyle.pas new file mode 100644 index 00000000..6d2b65f8 --- /dev/null +++ b/examples/gui/concepttest/OpenSoftStyle.pas @@ -0,0 +1,254 @@ +unit OpenSoftStyle; + +{$mode objfpc}{$H+} + +interface + +uses + Classes, fpgui, gfxbase; + +type + + TGradientDirection = (gdTopToBottom, gdBottomToTop, gdLeftToRight, gdRightToLeft); + TCalcGradientEndX = function(Y, H: Integer): Integer; + + + TOpenSoftStyle = class(TDefaultStyle) + private + procedure PaintGradient(pCanvas: TGfxCanvas; const R: TRect; StartColor, EndColor: TColor; Direction: TGradientDirection; GradLines: Integer = -1); + public + // Colors + function GetGUIColor(Color: TColor): TGfxColor; override; + // Buttons (todo) + procedure DrawButtonFace(Canvas: TGfxCanvas; const ARect: TRect; Flags: TButtonFlags); override; + // GroupBox + procedure DrawGroupBox(Canvas: TGfxCanvas; const ARect: TRect; const ALabel: String; WidgetState: TWidgetState); override; + end; + + +var + FOpenSoftStyle: TOpenSoftStyle; + +implementation + + +const + // Some predefined colors: + rgbaDkBlue: TGfxColor = (Red: $0000; Green: $0000; Blue: $8000; Alpha: $0000); + rgbaLtYellow: TGfxColor = (Red: $ffff; Green: $ffff; Blue: $e100; Alpha: $0000); + + rgbaWindowText: TGfxColor = (Red: $0000; Green: $0000; Blue: $0000; Alpha: $0000); + rgbaWindow: TGfxColor = (Red: $efef; Green: $efef; Blue: $efef; Alpha: $0000); + rgbaDkGrey: TGfxColor = (Red: $8686; Green: $8686; Blue: $8686; Alpha: $0000); + rgbaGbAALtGrey: TGfxColor = (Red: $baba; Green: $baba; Blue: $baba; Alpha: $0000); + rgbaGbAADkGrey: TGfxColor = (Red: $7878; Green: $7878; Blue: $7878; Alpha: $0000); + + +{ +procedure DrawGradient(Canvas: TCanvas; const R: TRect; StartColor, EndColor: TColor; + Direction: TGradientDirection; GradLines: Integer = -1; CalcEndX: TCalcGradientEndX = nil); +procedure DrawGradientEx(Canvas: TCanvas; const R: TRect; StartColor: TColor; + StartToMidHeight: Integer; MidColor, EndColor: TColor; + Direction: TGradientDirection; CalcEndX: TCalcGradientEndX = nil); + + +procedure ToRGB(c: TColor; out rgb: TRGB); +var + l: TColorRef; +begin + c := ColorFromColormap(c); + l := ColorToRGB(c); + rgb.r := TRGBValue(l).r; + rgb.g := TRGBValue(l).g; + rgb.b := TRGBValue(l).b; +end; +} + + +{ TOpenSoftStyle } + +procedure TOpenSoftStyle.PaintGradient(pCanvas: TGfxCanvas; const R: TRect; StartColor, EndColor: TColor; Direction: TGradientDirection; GradLines: Integer = -1); +var + X, i, w, h, Count: Integer; + EndCol, StartCol, AddCol, Tmp: TGfxColor; +begin + w := R.Right - R.Left - 1; + h := R.Bottom - R.Top - 1; + if (w <= 0) or (h <= 0) then + Exit; //==> + + StartCol := GetGUIColor(StartColor); + EndCol := GetGUIColor(EndColor); + + case Direction of + gdTopToBottom: + Count := h; + gdLeftToRight: + Count := w; + gdBottomToTop: + begin + Count := h; + Tmp := EndCol; + EndCol := StartCol; + StartCol := Tmp; + end; + gdRightToLeft: + begin + Count := w; + Tmp := EndCol; + EndCol := StartCol; + StartCol := Tmp; + end; + else + Exit; //==> + end; + if GradLines < 0 then + GradLines := Count; + + AddCol.r := (EndCol.r - StartCol.r) / GradLines; + AddCol.g := (EndCol.g - StartCol.g) / GradLines; + AddCol.b := (EndCol.b - StartCol.b) / GradLines; + +// Canvas.Pen.Style := psSolid; + pCanvas.SaveState; +// Canvas.Start; + try + StartColor := TColor(Round(StartCol.r), Round(StartCol.g), Round(StartCol.b)); +// Canvas.Pen.Color := StartColor; + pCanvas.SetColor(GetGUIColor(StartColor)); + for i := 0 to Count - 1 do + begin + if Direction in [gdTopToBottom, gdBottomToTop] then + begin + Canvas.MoveTo(R.Left, R.Top + i); + if Assigned(CalcEndX) then + X := CalcEndX(i, Count) + else + X := 0; + Canvas.LineTo(R.Right + X, R.Top + i); + end + else + begin + Canvas.MoveTo(R.Left + i, R.Top); + Canvas.LineTo(R.Left + i, R.Bottom); + end; + StartCol.r := StartCol.r + AddCol.r; + StartCol.g := StartCol.g + AddCol.g; + StartCol.b := StartCol.b + AddCol.b; + EndColor := RGB(Round(StartCol.r), Round(StartCol.g), Round(StartCol.b)); + if StartColor <> EndColor then + begin +// Canvas.Pen.Color := EndColor; + pCanvas.SetColor(GetGUIColor(EndColor)); + StartColor := EndColor; + end; + end; // for + finally +// Canvas.Stop; + pCanvas.RestoreState; + end; +end; + + +function TOpenSoftStyle.GetGUIColor(Color: TColor): TGfxColor; +begin + Result := inherited GetGUIColor(Color); + case Color of + // UI element colors + clScrollBar: Result := rgbaWindow; + clMenu: Result := rgbaWindow; +// clWindow: Result := GetUIColor(clWhite); +// clMenuText: Result := GetUIColor(clBlack); +// clWindowText: Result := GetUIColor(clBlack); +// clAppWorkSpace: Result := GetUIColor(clGray); +// clHighlight: Result := GetUIColor(clNavy); +// clHighlightText: Result := GetUIColor(clWhite); + cl3DFace: Result := rgbaWindow; +// cl3DShadow: Result := rgbaDkWhite; +// clGrayText: Result := GetUIColor(clGray); +// clBtnText: Result := GetUIColor(clBlack); +// cl3DHighlight: Result := GetUIColor(clWhite); + cl3DDkShadow: Result := GetUIColor(clMidnightBlue); +// cl3DLight: Result := GetUIColor(clDarkWhite); +// clInfoText: Result := GetUIColor(clBlack); +// clInfoBk: Result := GetUIColor(clLightYellow); +// +// else Result := GetUIColor(clWhite); + end; + +end; + + +procedure TOpenSoftStyle.DrawButtonFace(Canvas: TGfxCanvas; const ARect: TRect; + Flags: TButtonFlags); +begin +// inherited DrawButtonFace(Canvas, ARect, Flags); + PaintGradient(Canvas, ARect, Flags); + Draw3DFrame(Canvas, ARect, cl3DHighlight, cl3DLight, cl3DDkShadow, cl3DShadow); +end; + + +procedure TOpenSoftStyle.DrawGroupBox(Canvas: TGfxCanvas; const ARect: TRect; + const ALabel: String; WidgetState: TWidgetState); +var + TitleWidth, TitleHeight, TopLine: Integer; +begin + TitleWidth := Canvas.TextWidth(ALabel); + TitleHeight := Canvas.FontCellHeight; + TopLine := ARect.Top + TitleHeight div 3; + + Canvas.SetColor(rgbaDkGrey); + // box outline + with ARect do + begin + // top + Canvas.DrawLine(Point(Left + 2, TopLine), Point(Left + 12, TopLine)); + Canvas.DrawLine(Point(Left + TitleWidth + 16, TopLine), Point(Right - 2, TopLine)); + // right + Canvas.DrawLine(Point(Right-1, TopLine + 2), Point(Right-1, Bottom - 2)); + // bottom + Canvas.DrawLine(Point(Right - 3, Bottom-1), Point(Left + 1, Bottom-1)); + // left + Canvas.DrawLine(Point(Left, Bottom - 3), Point(Left, TopLine + 1)); + end; + + // Text caption + SetUIColor(Canvas, clWindowText); + DrawText(Canvas, ARect.TopLeft + Point(14, 0), ALabel, WidgetState); + + { Anti-Aliasing - Top/Left } + Canvas.SetColor(rgbaGbAALtGrey); + Canvas.DrawPoint(ARect.TopLeft + Point(0, TopLine+1)); + Canvas.DrawPoint(ARect.TopLeft + Point(1, TopLine)); + Canvas.SetColor(rgbaGbAADkGrey); + Canvas.DrawPoint(ARect.TopLeft + Point(1, TopLine+1)); + { Anti-Aliasing - Top/Right } + Canvas.SetColor(rgbaGbAALtGrey); + Canvas.DrawPoint(ARect.TopLeft + Point(ARect.Right-1, TopLine+1)); + Canvas.DrawPoint(ARect.TopLeft + Point(ARect.Right-2, TopLine)); + Canvas.SetColor(rgbaGbAADkGrey); + Canvas.DrawPoint(ARect.TopLeft + Point(ARect.Right-2, TopLine+1)); + { Anti-Aliasing - Bottom/Right } + Canvas.SetColor(rgbaGbAALtGrey); + Canvas.DrawPoint(ARect.TopLeft + Point(ARect.Right-1, ARect.Bottom-2)); + Canvas.DrawPoint(ARect.TopLeft + Point(ARect.Right-2, ARect.Bottom-1)); + Canvas.SetColor(rgbaGbAADkGrey); + Canvas.DrawPoint(ARect.TopLeft + Point(ARect.Right-2, ARect.Bottom-2)); + { Anti-Aliasing - Bottom/Left } + Canvas.SetColor(rgbaGbAALtGrey); + Canvas.DrawPoint(ARect.TopLeft + Point(0, ARect.Bottom-2)); + Canvas.DrawPoint(ARect.TopLeft + Point(1, ARect.Bottom-1)); + Canvas.SetColor(rgbaGbAADkGrey); + Canvas.DrawPoint(ARect.TopLeft + Point(1, ARect.Bottom-2)); +end; + + +initialization + FOpenSoftStyle := TOpenSoftStyle.Create(Application.Display); + +finalization + if Assigned(FOpenSoftStyle) then + FOpenSoftStyle.Free; + +end. + diff --git a/examples/gui/concepttest/compileroptform.frm b/examples/gui/concepttest/compileroptform.frm new file mode 100644 index 00000000..1aae5daa --- /dev/null +++ b/examples/gui/concepttest/compileroptform.frm @@ -0,0 +1,137 @@ +object CompilerOptForm: TCompilerOptForm + Text = 'Compiler Options - Code' + BorderWidth = 5 + object Box1: TBoxLayout + Spacing = 8 + Orientation = Vertical + object Box2: TBoxLayout + Orientation = Vertical + Spacing = 4 + object Box4: TBoxLayout + object grpBox1: TGroupBox + Text = 'Unit Style:' + object grpBox1VBox1: TBoxLayout + Orientation = Vertical + object cbSmartLink: TCheckbox + Checked = True + Text = 'Smart Linkable (-CX)' + end + end + end + object grpBox2: TGroupBox + Text = 'Checks:' + object grpBox2VBox1: TBoxLayout + Orientation = Vertical + object rbIO: TRadioButton + Checked = True + Text = 'I/O (-Ci)' + end + object rbOverflow: TRadioButton + Checked = True + Text = 'Overflow (-Co)' + end + object rbRange: TRadioButton + Checked = True + Text = 'Range (-Cr)' + end + object rbStack: TRadioButton + Checked = True + Text = 'Stack (-Ct)' + end + end + end + object grpBox3: TGroupBox + Text = 'Heap Size (-Ch):' + object grpBox3VBox1: TBoxLayout + Orientation = Vertical + object edHeapSize: TEdit + Text = '0' + CanExpandWidth = False + end + end + end + end + object Box5: TBoxLayout + object grpBox4: TGroupBox + Text = 'Generate:' + object grpBox4VBox1: TBoxLayout + Orientation = Vertical + object rbNormal: TRadioButton + Text = 'Normal Code (none)' + end + object rbFaster: TRadioButton + Checked = True + Text = 'Faster Code (-OG)' + end + object rbSmaller: TRadioButton + Text = 'Smaller Code (-Og)' + end + end + end + object grpBox5: TGroupBox + Text = 'Target Platform:' + CanExpandHeight = True + object grpBox5VBox1: TBoxLayout + Orientation = Vertical + VertAlign = vertTop + object lblTarget1: TLabel + Text = 'Target OS (-T)' + end + object lblTarget2: TLabel + Text = 'Target CPU (-P)' + end + object lblTarget3: TLabel + Text = 'Target i386' + end + end + end + end + object Box6: TBoxLayout + object grpBox6: TGroupBox + Text = 'Optimizations:' + object grpBox6VBox1: TBoxLayout + Orientation = Vertical + CanExpandWidth = True + object rbLevel0: TRadioButton + Text = 'Level 0 (no extra Optimizations) (none)' + end + object rbLevel1: TRadioButton + Checked = True + Text = 'Level 1 (Quick Optimizations) (-O1)' + end + object rbLevel2: TRadioButton + Text = 'Level 2 (Level 1 + Slower Optimizations) (-O2)' + end + object rbLevel3: TRadioButton + Text = 'Level 3 (Level 2 + Uncertain) (-O3)' + end + object rbKeepVarReg: TCheckbox + Text = 'Keep certain variables in registers (-Or)' + end + object rbUncOpt: TCheckbox + Text = 'Uncertain Optimizations (-Ou)' + end + end + end + end + end + object Box3: TBoxLayout + object btnOK: TButton + Text = 'OK' + OnClick = btnCloseClick + end + object btnCancel: TButton + Text = 'Cancel' + end + object btnShowOpt: TButton + Text = 'Show Options' + end + object btnTest: TButton + Text = 'Test' + end + object btnLoadSave: TButton + Text = 'Load/Save' + end + end + end +end diff --git a/examples/gui/concepttest/frmCompilerOpt.pas b/examples/gui/concepttest/frmCompilerOpt.pas new file mode 100644 index 00000000..b2f84a6f --- /dev/null +++ b/examples/gui/concepttest/frmCompilerOpt.pas @@ -0,0 +1,132 @@ +unit frmCompilerOpt; + +{$mode objfpc}{$H+} + +interface +uses + Classes, SysUtils, fpgui; + + +type + + { TCompilerOptForm } + + TCompilerOptForm = Class(TForm) + private + FGroupBoxStyle: TStyle; + public + constructor Create(AOwner: TComponent); override; + destructor Destroy; override; + procedure CompOptFormOnActivate(Sender: TObject); + procedure SmartLinkClick(Sender: TObject); + published + procedure btnCloseClick(Sender: TObject); + Box1: TBoxLayout; + Box2: TBoxLayout; + Box3: TBoxLayout; + Box4: TBoxLayout; + Box5: TBoxLayout; + Box6: TBoxLayout; + btnOK, btnCancel, btnShowOp, btnTest, btnLoadSave : TButton; + grpBox1: TGroupBox; + grpBox1VBox1: TBoxLayout; + cbSmartLink: TCheckbox; + grpBox2: TGroupBox; + grpBox2VBox1: TBoxLayout; + rbIO: TRadioButton; + rbOverflow: TRadioButton; + rbRange: TRadioButton; + rbStack: TRadioButton; + grpBox3: TGroupBox; + grpBox3VBox1: TBoxLayout; + edHeapSize: TEdit; + grpBox4: TGroupBox; + grpBox4VBox1: TBoxLayout; + rbNormal: TRadioButton; + rbFaster: TRadioButton; + rbSmaller: TRadioButton; + grpBox5: TGroupBox; + grpBox5VBox1: TBoxLayout; + lblTarget1: TLabel; + lblTarget2: TLabel; + lblTarget3: TLabel; + grpBox6: TGroupBox; + grpBox6VBox1: TBoxLayout; + rbLevel0: TRadioButton; + rbLevel1: TRadioButton; + rbLevel2: TRadioButton; + rbLevel3: TRadioButton; + rbKeepVarReg: TCheckbox; + rbUncOpt: TCheckbox; + end; + +var + CompOpt: TCompilerOptForm; + +implementation +uses + OpenSoftStyle; + +{ TCompilerOptForm } + + + +constructor TCompilerOptForm.Create(AOwner: TComponent); +begin + inherited Create(AOwner); +// FGroupBoxStyle := TOpenSoftStyle.Create(Application.Display); +// Style := FGroupBoxStyle; +// Style := FOpenSoftStyle; + OnActivate := @CompOptFormOnActivate; +end; + + +destructor TCompilerOptForm.Destroy; +begin + FGroupBoxStyle.Free; + inherited Destroy; +end; + + +procedure TCompilerOptForm.CompOptFormOnActivate(Sender: TObject); +begin + cbSmartLink.OnClick := @SmartLinkClick; + +{ + grpBox1.CanExpandHeight := True; + grpBox1VBox1.CanExpandHeight := True; + grpBox1.CanExpandWidth := True; + grpBox2.CanExpandWidth := True; + grpBox3.CanExpandWidth := True; + grpBox4.CanExpandWidth := True; + grpBox5.CanExpandWidth := True; + grpBox6.CanExpandWidth := True; + + grpBox6VBox1.CanExpandWidth := True; +} + grpBox5VBox1.VertAlign := vertFill; +// grpBox1.Style := FGroupBoxStyle; +// grpBox6.Style := FGroupBoxStyle; +end; + + +procedure TCompilerOptForm.SmartLinkClick(Sender: TObject); +begin + grpBox1.Style := nil; + self.Redraw; +// grpBox1.Redraw; +end; + + +procedure TCompilerOptForm.btnCloseClick(Sender: TObject); +begin + Close; +end; + + +initialization +finalization + CompOpt.Free; + +end. + diff --git a/examples/gui/concepttest/hello.lpi b/examples/gui/concepttest/hello.lpi new file mode 100644 index 00000000..be68c070 --- /dev/null +++ b/examples/gui/concepttest/hello.lpi @@ -0,0 +1,458 @@ +<?xml version="1.0"?> +<CONFIG> + <ProjectOptions> + <PathDelim Value="\"/> + <Version Value="5"/> + <General> + <MainUnit Value="0"/> + <IconPath Value="./"/> + <TargetFileExt Value=""/> + <ActiveEditorIndexAtStart Value="1"/> + </General> + <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_laz"/> + </Item1> + </RequiredPackages> + <Units Count="59"> + <Unit0> + <Filename Value="hello.lpr"/> + <IsPartOfProject Value="True"/> + <UnitName Value="hello"/> + <CursorPos X="25" Y="286"/> + <TopLine Value="270"/> + <EditorIndex Value="0"/> + <UsageCount Value="136"/> + <Loaded Value="True"/> + </Unit0> + <Unit1> + <Filename Value="..\..\src\applicationh.inc"/> + <CursorPos X="18" Y="27"/> + <TopLine Value="1"/> + <UsageCount Value="13"/> + </Unit1> + <Unit2> + <Filename Value="..\..\src\application.inc"/> + <CursorPos X="17" Y="37"/> + <TopLine Value="73"/> + <EditorIndex Value="4"/> + <UsageCount Value="29"/> + <Loaded Value="True"/> + </Unit2> + <Unit3> + <Filename Value="..\..\src\formh.inc"/> + <CursorPos X="1" Y="83"/> + <TopLine Value="50"/> + <UsageCount Value="19"/> + </Unit3> + <Unit4> + <Filename Value="..\..\src\fpgui.pp"/> + <UnitName Value="fpGUI"/> + <CursorPos X="18" Y="136"/> + <TopLine Value="233"/> + <UsageCount Value="55"/> + </Unit4> + <Unit5> + <Filename Value="..\..\src\form.inc"/> + <CursorPos X="31" Y="112"/> + <TopLine Value="97"/> + <EditorIndex Value="5"/> + <UsageCount Value="24"/> + <Loaded Value="True"/> + </Unit5> + <Unit6> + <Filename Value="..\..\..\fpgfx\src\gfxbase.pp"/> + <UnitName Value="GfxBase"/> + <CursorPos X="3" Y="41"/> + <TopLine Value="24"/> + <UsageCount Value="6"/> + </Unit6> + <Unit7> + <Filename Value="..\layouttest\layouttest.pp"/> + <UnitName Value="LayoutTest"/> + <CursorPos X="16" Y="7"/> + <TopLine Value="1"/> + <UsageCount Value="10"/> + </Unit7> + <Unit8> + <Filename Value="..\layouttest\mainform.frm"/> + <CursorPos X="1" Y="1"/> + <TopLine Value="1"/> + <UsageCount Value="10"/> + <SyntaxHighlighter Value="None"/> + </Unit8> + <Unit9> + <Filename Value="..\..\src\layoutsh.inc"/> + <CursorPos X="15" Y="156"/> + <TopLine Value="131"/> + <UsageCount Value="23"/> + </Unit9> + <Unit10> + <Filename Value="..\..\src\widgeth.inc"/> + <CursorPos X="1" Y="264"/> + <TopLine Value="219"/> + <UsageCount Value="21"/> + </Unit10> + <Unit11> + <Filename Value="..\..\src\widget.inc"/> + <CursorPos X="9" Y="1356"/> + <TopLine Value="1311"/> + <EditorIndex Value="6"/> + <UsageCount Value="45"/> + <Loaded Value="True"/> + </Unit11> + <Unit12> + <Filename Value="..\..\src\buttonsh.inc"/> + <CursorPos X="19" Y="39"/> + <TopLine Value="11"/> + <UsageCount Value="1"/> + </Unit12> + <Unit13> + <Filename Value="..\..\src\buttons.inc"/> + <CursorPos X="3" Y="77"/> + <TopLine Value="56"/> + <UsageCount Value="10"/> + </Unit13> + <Unit14> + <Filename Value="frmCompilerOpt.pas"/> + <IsPartOfProject Value="True"/> + <UnitName Value="frmCompilerOpt"/> + <CursorPos X="35" Y="107"/> + <TopLine Value="1"/> + <EditorIndex Value="2"/> + <UsageCount Value="135"/> + <Loaded Value="True"/> + </Unit14> + <Unit15> + <Filename Value="..\..\src\groupboxh.inc"/> + <CursorPos X="15" Y="21"/> + <TopLine Value="1"/> + <UsageCount Value="19"/> + </Unit15> + <Unit16> + <Filename Value="compileroptform.frm"/> + <IsPartOfProject Value="True"/> + <CursorPos X="43" Y="66"/> + <TopLine Value="1"/> + <UsageCount Value="135"/> + <SyntaxHighlighter Value="None"/> + </Unit16> + <Unit17> + <Filename Value="..\layouttest\boxform.frm"/> + <CursorPos X="27" Y="6"/> + <TopLine Value="1"/> + <UsageCount Value="33"/> + <SyntaxHighlighter Value="None"/> + </Unit17> + <Unit18> + <Filename Value="..\widgettest\groupboxform.frm"/> + <CursorPos X="9" Y="18"/> + <TopLine Value="1"/> + <UsageCount Value="18"/> + <SyntaxHighlighter Value="None"/> + </Unit18> + <Unit19> + <Filename Value="..\..\src\binh.inc"/> + <CursorPos X="1" Y="18"/> + <TopLine Value="1"/> + <UsageCount Value="6"/> + </Unit19> + <Unit20> + <Filename Value="..\..\src\containerh.inc"/> + <CursorPos X="1" Y="3"/> + <TopLine Value="1"/> + <UsageCount Value="6"/> + </Unit20> + <Unit21> + <Filename Value="opt\fpc-2.1.1\src\rtl\objpas\classes\classesh.inc"/> + <CursorPos X="3" Y="104"/> + <TopLine Value="81"/> + <UsageCount Value="1"/> + </Unit21> + <Unit22> + <Filename Value="..\..\src\checkboxh.inc"/> + <CursorPos X="1" Y="42"/> + <TopLine Value="20"/> + <UsageCount Value="13"/> + </Unit22> + <Unit23> + <Filename Value="..\..\src\groupbox.inc"/> + <CursorPos X="32" Y="26"/> + <TopLine Value="12"/> + <UsageCount Value="16"/> + </Unit23> + <Unit24> + <Filename Value="..\..\src\styleh.inc"/> + <CursorPos X="20" Y="86"/> + <TopLine Value="68"/> + <UsageCount Value="19"/> + </Unit24> + <Unit25> + <Filename Value="..\..\src\style.inc"/> + <CursorPos X="17" Y="103"/> + <TopLine Value="80"/> + <UsageCount Value="25"/> + </Unit25> + <Unit26> + <Filename Value="OpenSoftStyle.pas"/> + <IsPartOfProject Value="True"/> + <UnitName Value="OpenSoftStyle"/> + <CursorPos X="10" Y="108"/> + <TopLine Value="95"/> + <EditorIndex Value="1"/> + <UsageCount Value="122"/> + <Loaded Value="True"/> + </Unit26> + <Unit27> + <Filename Value="..\..\src\bin.inc"/> + <CursorPos X="29" Y="25"/> + <TopLine Value="2"/> + <UsageCount Value="7"/> + </Unit27> + <Unit28> + <Filename Value="..\widgettest\editform.frm"/> + <CursorPos X="1" Y="1"/> + <TopLine Value="1"/> + <UsageCount Value="4"/> + <SyntaxHighlighter Value="None"/> + </Unit28> + <Unit29> + <Filename Value="..\widgettest\widgettest.pp"/> + <UnitName Value="WidgetTest"/> + <CursorPos X="1" Y="497"/> + <TopLine Value="461"/> + <UsageCount Value="6"/> + </Unit29> + <Unit30> + <Filename Value="..\..\src\separatorh.inc"/> + <CursorPos X="15" Y="26"/> + <TopLine Value="3"/> + <UsageCount Value="4"/> + </Unit30> + <Unit31> + <Filename Value="..\..\src\separator.inc"/> + <CursorPos X="19" Y="32"/> + <TopLine Value="30"/> + <UsageCount Value="4"/> + </Unit31> + <Unit32> + <Filename Value="..\..\src\layouts.inc"/> + <CursorPos X="17" Y="871"/> + <TopLine Value="613"/> + <EditorIndex Value="3"/> + <UsageCount Value="29"/> + <Loaded Value="True"/> + </Unit32> + <Unit33> + <Filename Value="..\..\src\win32\defstyle.inc"/> + <CursorPos X="1" Y="1"/> + <TopLine Value="1"/> + <UsageCount Value="4"/> + </Unit33> + <Unit34> + <Filename Value="..\..\src\defimpl\defstyle.inc"/> + <CursorPos X="42" Y="57"/> + <TopLine Value="23"/> + <UsageCount Value="12"/> + </Unit34> + <Unit35> + <Filename Value="..\..\..\fpGFX\src\x11\gfx_x11.pp"/> + <UnitName Value="GFX_X11"/> + <CursorPos X="14" Y="499"/> + <TopLine Value="470"/> + <UsageCount Value="5"/> + </Unit35> + <Unit36> + <Filename Value="..\..\..\lptk\src\gfxstyle.pas"/> + <UnitName Value="gfxstyle"/> + <CursorPos X="39" Y="7"/> + <TopLine Value="93"/> + <UsageCount Value="5"/> + </Unit36> + <Unit37> + <Filename Value="..\..\..\lptk\src\gfxwidget.pas"/> + <UnitName Value="gfxwidget"/> + <CursorPos X="1" Y="1"/> + <TopLine Value="737"/> + <UsageCount Value="25"/> + </Unit37> + <Unit38> + <Filename Value="..\..\src\container.inc"/> + <CursorPos X="31" Y="25"/> + <TopLine Value="2"/> + <UsageCount Value="15"/> + </Unit38> + <Unit39> + <Filename Value="..\..\src\gridh.inc"/> + <CursorPos X="1" Y="137"/> + <TopLine Value="103"/> + <UsageCount Value="6"/> + </Unit39> + <Unit40> + <Filename Value="..\..\src\grid.inc"/> + <CursorPos X="3" Y="18"/> + <TopLine Value="1"/> + <UsageCount Value="7"/> + </Unit40> + <Unit41> + <Filename Value="media\sda5\Programming\MasterMaths\M2Browser_v3\3rdParty\Gauge\TGauge.pas"/> + <UnitName Value="TGauge"/> + <CursorPos X="39" Y="3"/> + <TopLine Value="90"/> + <UsageCount Value="7"/> + </Unit41> + <Unit42> + <Filename Value="..\..\src\checkbox.inc"/> + <CursorPos X="3" Y="89"/> + <TopLine Value="83"/> + <UsageCount Value="12"/> + </Unit42> + <Unit43> + <Filename Value="..\..\src\combobox.inc"/> + <CursorPos X="24" Y="171"/> + <TopLine Value="148"/> + <UsageCount Value="6"/> + </Unit43> + <Unit44> + <Filename Value="..\..\..\personal\fpgui\src\form.inc"/> + <CursorPos X="27" Y="121"/> + <TopLine Value="101"/> + <UsageCount Value="6"/> + </Unit44> + <Unit45> + <Filename Value="..\..\src\radiobutton.inc"/> + <CursorPos X="19" Y="107"/> + <TopLine Value="85"/> + <UsageCount Value="12"/> + </Unit45> + <Unit46> + <Filename Value="..\..\..\lptk\src\gfxbase.pas"/> + <UnitName Value="gfxbase"/> + <CursorPos X="38" Y="2355"/> + <TopLine Value="3421"/> + <UsageCount Value="25"/> + </Unit46> + <Unit47> + <Filename Value="..\..\..\lptk\src\schar16.pas"/> + <UnitName Value="schar16"/> + <CursorPos X="10" Y="35"/> + <TopLine Value="1"/> + <UsageCount Value="7"/> + </Unit47> + <Unit48> + <Filename Value="..\..\..\lptk\src\unitkeys.pas"/> + <UnitName Value="unitkeys"/> + <CursorPos X="1" Y="1"/> + <TopLine Value="302"/> + <UsageCount Value="7"/> + </Unit48> + <Unit49> + <Filename Value="..\..\..\lptk\src\wgbutton.pas"/> + <UnitName Value="wgbutton"/> + <CursorPos X="15" Y="34"/> + <TopLine Value="11"/> + <UsageCount Value="7"/> + </Unit49> + <Unit50> + <Filename Value="..\..\..\lptk\src\wglabel.pas"/> + <UnitName Value="wglabel"/> + <CursorPos X="1" Y="1"/> + <TopLine Value="1"/> + <UsageCount Value="7"/> + </Unit50> + <Unit51> + <Filename Value="..\..\src\colors.inc"/> + <CursorPos X="1" Y="1"/> + <TopLine Value="39"/> + <EditorIndex Value="7"/> + <UsageCount Value="24"/> + <Loaded Value="True"/> + </Unit51> + <Unit52> + <Filename Value="..\..\..\fpgfx.trunk\src\gfxbase.pp"/> + <UnitName Value="GfxBase"/> + <CursorPos X="19" Y="402"/> + <TopLine Value="507"/> + <UsageCount Value="8"/> + </Unit52> + <Unit53> + <Filename Value="\opt\lazarus\ide\editoroptions.pp"/> + <ComponentName Value="EditorOptionsForm"/> + <HasResources Value="True"/> + <ResourceFilename Value="\opt\lazarus\ide\editoroptions.lrs"/> + <UnitName Value="EditorOptions"/> + <CursorPos X="28" Y="2302"/> + <TopLine Value="2595"/> + <UsageCount Value="21"/> + </Unit53> + <Unit54> + <Filename Value="\opt\lazarus\components\synedit\synedit.pp"/> + <UnitName Value="SynEdit"/> + <CursorPos X="28" Y="6001"/> + <TopLine Value="5978"/> + <UsageCount Value="21"/> + </Unit54> + <Unit55> + <Filename Value="\opt\lazarus\components\synedit\synedittextbuffer.pp"/> + <UnitName Value="SynEditTextBuffer"/> + <CursorPos X="15" Y="135"/> + <TopLine Value="181"/> + <UsageCount Value="21"/> + </Unit55> + <Unit56> + <Filename Value="\opt\lazarus\components\synedit\synedithighlighter.pp"/> + <UnitName Value="SynEditHighlighter"/> + <CursorPos X="34" Y="145"/> + <TopLine Value="766"/> + <UsageCount Value="21"/> + </Unit56> + <Unit57> + <Filename Value="\opt\lazarus\components\synedit\synhighlighterpas.pp"/> + <UnitName Value="SynHighlighterPas"/> + <CursorPos X="3" Y="83"/> + <TopLine Value="658"/> + <UsageCount Value="21"/> + </Unit57> + <Unit58> + <Filename Value="..\..\..\tiOPF2\Source\Core\tiObject.pas"/> + <UnitName Value="tiObject"/> + <CursorPos X="1" Y="1756"/> + <TopLine Value="1933"/> + <UsageCount Value="19"/> + </Unit58> + </Units> + <JumpHistory Count="2" HistoryIndex="1"> + <Position1> + <Filename Value="OpenSoftStyle.pas"/> + <Caret Line="34" Column="1" TopLine="1"/> + </Position1> + <Position2> + <Filename Value="OpenSoftStyle.pas"/> + <Caret Line="108" Column="10" TopLine="95"/> + </Position2> + </JumpHistory> + </ProjectOptions> + <CompilerOptions> + <Version Value="5"/> + <PathDelim Value="\"/> + <CodeGeneration> + <Generate Value="Faster"/> + </CodeGeneration> + <Other> + <CompilerPath Value="$(CompPath)"/> + </Other> + </CompilerOptions> +</CONFIG> diff --git a/examples/gui/concepttest/hello.lpr b/examples/gui/concepttest/hello.lpr new file mode 100644 index 00000000..0ac8138a --- /dev/null +++ b/examples/gui/concepttest/hello.lpr @@ -0,0 +1,334 @@ +program hello; + +{$mode objfpc}{$H+} + +uses + {$IFDEF UNIX}{$IFDEF UseCThreads} + cthreads, + {$ENDIF}{$ENDIF} + Classes, + fpgui, gfxbase, frmCompilerOpt, OpenSoftStyle; + +type + + { TMainForm } + + TMainForm = class(TForm) + procedure Button3Clicked(Sender: TObject); + private + procedure btnCloseClick(Sender: TObject); + procedure btnGridFormClick(Sender: TObject); + procedure btnCompOptClick(Sender: TObject); + procedure btnTopClick(Sender: TObject); + procedure MainFormActivate(Sender: TObject); + public + constructor Create(AOwner: TComponent); override; + published + HBox: TBoxLayout; + VBox: TBoxLayout; + TextLabel: TLabel; + Button: TButton; + btnGridForm: TButton; + btnCompOpt: TButton; + Button1: TButton; + Button2: TButton; + Button3: TButton; + end; + + + { TGridForm } + + TGridForm = Class(TForm) + Layout : TGridLayout; + Button1,Button2,Button3,Button4,Button5 : TButton; + public + constructor Create(AOwner: TComponent); override; + end; + + + { TFindDialog } + + TFindDialog = class(TForm) + private + procedure btnCloseClick(Sender: TObject); + public + constructor Create(AOwner: TComponent); override; + published + lblFind: TLabel; + btnFindNext, btnClose: TButton; + edFind: TEdit; + GroupBox1: TGroupBox; + grpBox1Layout: TBoxLayout; + Radio1, Radio2: TRadioButton; + cbCase: TCheckBox; + leftLayout, rightLayout: TBoxLayout; + topLeftLayout: TBoxLayout; + mainLayout: TBoxLayout; + end; + + +{ TFindDialog } + +procedure TFindDialog.btnCloseClick(Sender: TObject); +begin + Close; +end; + + +constructor TFindDialog.Create(AOwner: TComponent); +begin + inherited Create(AOwner); + Text := 'Find Dialog'; + BorderWidth := 8; + WindowType := wtWindow; + + topLeftLayout := TBoxLayout.Create(self); + lblFind := TLabel.Create(self); + lblFind.Text := 'Find what'; + edFind := TEdit.Create(self); + topLeftLayout.InsertChild(lblFind); + topLeftLayout.InsertChild(edFind); + + leftLayout := TBoxLayout.Create(self); + leftLayout.Orientation := Vertical; + leftLayout.CanExpandHeight := True; + GroupBox1 := TGroupBox.Create(self); + GroupBox1.Text := 'Direction'; + grpBox1Layout := TBoxLayout.Create(self); +// grpBox1Layout.Orientation := Vertical; + GroupBox1.InsertChild(grpBox1Layout); + Radio1 := TRadioButton.Create(self); + Radio1.Text := 'Up'; + Radio2 := TRadioButton.Create(self); + Radio2.Text := 'Down'; + grpBox1Layout.InsertChild(Radio1); + grpBox1Layout.InsertChild(Radio2); + + cbCase := TCheckBox.Create(self); + cbCase.Text := 'Case sensitive'; + leftLayout.InsertChild(topLeftLayout); + leftLayout.InsertChild(GroupBox1); + leftLayout.InsertChild(cbCase); + + rightLayout := TBoxLayout.Create(self); + rightLayout.Orientation := Vertical; + rightLayout.VertAlign := vertTop; + btnFindNext := TButton.Create(self); + btnFindNext.Text := 'Find Next'; + btnClose := TButton.Create(self); + btnClose.Text := 'Close'; + btnClose.CanExpandWidth := True; + btnClose.OnClick := @btnCloseClick; + rightLayout.InsertChild(btnFindNext); + rightLayout.InsertChild(btnClose); + + mainLayout := TBoxLayout.Create(self); + mainLayout.InsertChild(leftLayout); + mainLayout.InsertChild(rightLayout); + + Child := mainLayout; +end; + +{ +QHBoxLayout *topLeftLayout = new QHBoxLayout; +topLeftLayout->addWidget(label); +topLeftLayout->addWidget(lineEdit); + +QVBoxLayout *leftLayout = new QVBoxLayout; +leftLayout->addLayout(topLeftLayout); +leftLayout->addWidget(buttonGroup); +leftLayout->addWidget(caseCheckBox); + +QVBoxLayout *rightLayout = new QVBoxLayout; +rightLayout->addWidget(findNextButton); +rightLayout->addWidget(closeButton); +rightLayout->addStretch(1); + +QHBoxLayout *mainLayout = new QHBoxLayout(this); +mainLayout->setMargin(11); +mainLayout->setSpacing(6); +mainLayout->addLayout(leftLayout); +mainLayout->addLayout(rightLayout); +} + + +var + GridForm: TGridForm; + FindDialog: TFindDialog; + +{ TGridForm } + +constructor TGridForm.Create(AOwner: TComponent); +begin + inherited Create(AOwner); + + Text := 'Grid Layout'; + BorderWidth := 8; + self.BorderWidth := 11; + + Layout := TGridLayout.Create(Self); + Layout.Name := 'Layout'; + Layout.RowCount := 3; + Layout.ColCount := 3; + + Button1 := TButton.Create(Self); + Button1.Name := 'TopLeft'; + Button1.Text := 'Top Left'; + Layout.AddWidget(Button1, 0, 0, 1, 1); + Button2 := TButton.Create(Self); + Button2.Name := 'TopRight'; + Button2.Text := 'Top Right'; + Layout.AddWidget(Button2, 2,0,1,1); + Button3 := TButton.Create(Self); + Button3.Name := 'CenterCenter'; + Button3.Text := 'Center Center'; + // Button3.CanExpandWidth := False; + // Button3.CanExpandHeight := False; + Layout.AddWidget(Button3, 1,1,1,1); + Button4 := TButton.Create(Self); + Button4.Name := 'BottomLeft'; + Button4.Text := 'Bottom Left'; + Layout.AddWidget(Button4,0,2,1,1); + Button5 := TButton.Create(Self); + Button5.Name := 'BottomRight'; + Button5.Text := 'Bottom Right'; + Layout.AddWidget(Button5, 2,2,1,1); + Child := Layout; +end; + + +{ TMainForm } + +procedure TMainForm.Button3Clicked(Sender: TObject); +begin + Button.SetBounds(100, 50, 100, 45); + Redraw; +end; + +procedure TMainForm.btnCloseClick(Sender: TObject); +begin + Close; +end; + + +procedure TMainForm.btnGridFormClick(Sender: TObject); +begin + if not Assigned(GridForm) then + begin + GridForm := TGridForm.Create(self); +// Application.AddForm(GridForm); + end; + + GridForm.Show; +end; + + +procedure TMainForm.btnCompOptClick(Sender: TObject); +begin + if not Assigned(CompOpt) then + Application.CreateForm(TCompilerOptForm, CompOpt) + else + CompOpt.Show; +end; + + +procedure TMainForm.btnTopClick(Sender: TObject); +begin + if not Assigned(FindDialog) then + FindDialog := TFindDialog.Create(self); + FindDialog.Show; +end; + + +procedure TMainForm.MainFormActivate(Sender: TObject); +var + max: TSize; +begin + max.cx := 600; + max.cy := 400; + self.Wnd.SetMinMaxClientSize(MinSize, max); +end; + + +constructor TMainForm.Create(AOwner: TComponent); +begin + inherited Create(AOwner); + Name := 'frmMain'; + BorderWidth := 8; + WindowType := wtWindow; + OnActivate := @MainFormActivate; + + HBox := TBoxLayout.Create(self); + HBox.Name := 'HBox'; + HBox.Parent := self; + HBox.Spacing := 3; + HBox.Orientation := Horizontal; + + TextLabel := TLabel.Create(self); + TextLabel.Name := 'TextLabel'; + TextLabel.Text := 'Hello'; + TextLabel.Parent := HBox; + + Button := TButton.Create(self); + Button.Parent := HBox; + Button.Text := 'Close'; + Button.OnClick := @btnCloseClick; + + btnGridForm := TButton.Create(self); + btnGridForm.Parent := HBox; + btnGridForm.Text := 'Grid Form'; + btnGridForm.OnClick := @btnGridFormClick; + + btnCompOpt := TButton.Create(Self); + btnCompOpt.Parent := HBox; + btnCompOpt.Name := 'btnCompOpt'; + btnCompOpt.Text := 'Compiler Options'; + btnCompOpt.OnClick := @btnCompOptClick; +// btnCompOpt.FCanExpandWidth := True; // if not used, button is smaller than others + + VBox := TBoxLayout.Create(self); + VBox.Orientation := Vertical; + Button1 := TButton.Create(Self); + Button1.Name := 'Top'; + Button1.Text := 'Top'; + Button1.CanExpandWidth := True; // if not used, button is smaller than others + Button1.OnClick := @btnTopClick; + VBox.InsertChild(Button1); + Button2 := TButton.Create(Self); + Button2.Name := 'Centre'; + Button2.Text := 'Centre'; + Button2.CanExpandWidth := True; + VBox.InsertChild(Button2); + Button3 := TButton.Create(Self); + Button3.Name := 'Bottom'; + Button3.Text := 'Bottom (SetBounds)'; + Button3.OnClick :=@Button3Clicked; + VBox.InsertChild(Button3); + + HBox.InsertChild(VBox); + + + Child := HBox; +end; + + +var + MainForm: TMainForm; + +begin + MainForm := nil; + { set application wide style } + + Application.SetStyle(FOpenSoftStyle); + + MainForm := TMainForm.Create(Application); +// MainForm.SetBounds(Point(100, 300), Size(300,200)); + try + MainForm.Show; + Application.Run; + finally + MainForm.Free; + end; + +end. + diff --git a/examples/gui/dbftest/Makefile b/examples/gui/dbftest/Makefile new file mode 100644 index 00000000..32ad7c72 --- /dev/null +++ b/examples/gui/dbftest/Makefile @@ -0,0 +1,1366 @@ +# +# Makefile generated by fpcmake v1.00 [2001/01/17] +# + +defaultrule: all + +##################################################################### +# Autodetect OS (Linux or Dos or Windows NT or OS/2) +# define inUnix when running under Unix (Linux,FreeBSD) +# define inWinNT when running under WinNT +# define inOS2 when running under OS/2 +##################################################################### + +# We need only / in the path +override PATH:=$(subst \,/,$(PATH)) + +# Search for PWD and determine also if we are under linux +PWD:=$(strip $(wildcard $(addsuffix /pwd.exe,$(subst ;, ,$(PATH))))) +ifeq ($(PWD),) +PWD:=$(strip $(wildcard $(addsuffix /pwd,$(subst :, ,$(PATH))))) +ifeq ($(PWD),) +nopwd: + @echo You need the GNU utils package to use this Makefile! + @echo Get ftp://ftp.freepascal.org/pub/fpc/dist/go32v2/utilgo32.zip + @exit +else +inUnix=1 +PWD:=$(firstword $(PWD)) +endif +else +PWD:=$(firstword $(PWD)) +endif + +# Detect NT - NT sets OS to Windows_NT +# Detect OS/2 - OS/2 has OS2_SHELL defined +ifndef inUnix +ifeq ($(OS),Windows_NT) +inWinNT=1 +else +ifdef OS2_SHELL +inOS2=1 +endif +endif +endif + +# The extension of executables +ifdef inUnix +SRCEXEEXT= +else +SRCEXEEXT=.exe +endif + +# The extension of batch files / scripts +ifdef inUnix +BATCHEXT=.sh +else +ifdef inOS2 +BATCHEXT=.cmd +else +BATCHEXT=.bat +endif +endif + +# Path Separator, the subst trick is necessary for the \ that can't exists +# at the end of a line +ifdef inUnix +PATHSEP=/ +else +PATHSEP=$(subst /,\,/) +endif + +# The path which is searched separated by spaces +ifdef inUnix +SEARCHPATH=$(subst :, ,$(PATH)) +else +SEARCHPATH=$(subst ;, ,$(PATH)) +endif + +# Base dir +ifdef PWD +BASEDIR:=$(shell $(PWD)) +else +BASEDIR=. +endif + +##################################################################### +# FPC version/target Detection +##################################################################### + +# What compiler to use ? +ifndef FPC +# Compatibility with old makefiles +ifdef PP +FPC=$(PP) +else +FPC=ppc386 +endif +endif +override FPC:=$(subst $(SRCEXEEXT),,$(FPC)) +override FPC:=$(subst \,/,$(FPC))$(SRCEXEEXT) + +# Target OS +ifndef OS_TARGET +OS_TARGET:=$(shell $(FPC) -iTO) +endif + +# Source OS +ifndef OS_SOURCE +OS_SOURCE:=$(shell $(FPC) -iSO) +endif + +# Target CPU +ifndef CPU_TARGET +CPU_TARGET:=$(shell $(FPC) -iTP) +endif + +# Source CPU +ifndef CPU_SOURCE +CPU_SOURCE:=$(shell $(FPC) -iSP) +endif + +# FPC version +ifndef FPC_VERSION +FPC_VERSION:=$(shell $(FPC) -iV) +endif + +export FPC OS_TARGET OS_SOURCE CPU_TARGET CPU_SOURCE FPC_VERSION + +##################################################################### +# FPCDIR Setting +##################################################################### + +# Test FPCDIR to look if the RTL dir exists +ifdef FPCDIR +override FPCDIR:=$(subst \,/,$(FPCDIR)) +ifeq ($(wildcard $(FPCDIR)/rtl),) +ifeq ($(wildcard $(FPCDIR)/units),) +override FPCDIR=wrong +endif +endif +else +override FPCDIR=wrong +endif + +# Detect FPCDIR +ifeq ($(FPCDIR),wrong) +ifdef inUnix +override FPCDIR=/usr/local/lib/fpc/$(FPC_VERSION) +ifeq ($(wildcard $(FPCDIR)/units),) +override FPCDIR=/usr/lib/fpc/$(FPC_VERSION) +endif +else +override FPCDIR:=$(subst /$(FPC),,$(firstword $(strip $(wildcard $(addsuffix /$(FPC),$(SEARCHPATH)))))) +override FPCDIR:=$(FPCDIR)/.. +ifeq ($(wildcard $(FPCDIR)/rtl),) +ifeq ($(wildcard $(FPCDIR)/units),) +override FPCDIR:=$(FPCDIR)/.. +ifeq ($(wildcard $(FPCDIR)/rtl),) +ifeq ($(wildcard $(FPCDIR)/units),) +override FPCDIR=c:/pp +endif +endif +endif +endif +endif +endif + +ifndef PACKAGESDIR +PACKAGESDIR=$(FPCDIR)/packages +endif +ifndef TOOLKITSDIR +TOOLKITSDIR= +endif +ifndef COMPONENTSDIR +COMPONENTSDIR= +endif + +# Create units dir +ifneq ($(FPCDIR),.) +UNITSDIR=$(FPCDIR)/units/$(OS_TARGET) +endif + +##################################################################### +# User Settings +##################################################################### + + +# Targets + +override EXEOBJECTS+=dbftest + +# Clean + + +# Install + +ZIPTARGET=install + +# Defaults + +override NEEDOPT=-S2h + +# Directories + + +# Packages + +override PACKAGES+=rtl fcl fpgfx fpgui + +# Libraries + + +# Info + +INFOTARGET=fpc_infocfg fpc_infoobjects fpc_infoinstall + +##################################################################### +# Shell tools +##################################################################### + +# echo +ifndef ECHO +ECHO:=$(strip $(wildcard $(addsuffix /gecho$(EXEEXT),$(SEARCHPATH)))) +ifeq ($(ECHO),) +ECHO:=$(strip $(wildcard $(addsuffix /echo$(SRCEXEEXT),$(SEARCHPATH)))) +ifeq ($(ECHO),) +ECHO:=echo +ECHOE:=echo +else +ECHO:=$(firstword $(ECHO)) +ECHOE=$(ECHO) -E +endif +else +ECHO:=$(firstword $(ECHO)) +ECHOE=$(ECHO) -E +endif +endif + +# To copy pograms +ifndef COPY +COPY:=cp -fp +endif + +# Copy a whole tree +ifndef COPYTREE +COPYTREE:=cp -rfp +endif + +# To move pograms +ifndef MOVE +MOVE:=mv -f +endif + +# Check delete program +ifndef DEL +DEL:=rm -f +endif + +# Check deltree program +ifndef DELTREE +DELTREE:=rm -rf +endif + +# To install files +ifndef INSTALL +ifdef inUnix +INSTALL:=install -c -m 644 +else +INSTALL:=$(COPY) +endif +endif + +# To install programs +ifndef INSTALLEXE +ifdef inUnix +INSTALLEXE:=install -c -m 755 +else +INSTALLEXE:=$(COPY) +endif +endif + +# To make a directory. +ifndef MKDIR +ifdef inUnix +MKDIR:=install -m 755 -d +else +MKDIR:=ginstall -m 755 -d +endif +endif + +export ECHO ECHOE COPY COPYTREE MOVE DEL DELTREE INSTALL INSTALLEXE MKDIR + +##################################################################### +# Default Tools +##################################################################### + +# assembler, redefine it if cross compiling +ifndef AS +AS=as +endif + +# linker, but probably not used +ifndef LD +LD=ld +endif + +# ppas.bat / ppas.sh +PPAS=ppas$(BATCHEXT) + +# ldconfig to rebuild .so cache +ifdef inUnix +LDCONFIG=ldconfig +else +LDCONFIG= +endif + +# ppumove +ifndef PPUMOVE +PPUMOVE:=$(strip $(wildcard $(addsuffix /ppumove$(SRCEXEEXT),$(SEARCHPATH)))) +ifeq ($(PPUMOVE),) +PPUMOVE= +else +PPUMOVE:=$(firstword $(PPUMOVE)) +endif +endif +export PPUMOVE + +# ppufiles +ifndef PPUFILES +PPUFILES:=$(strip $(wildcard $(addsuffix /ppufiles$(SRCEXEEXT),$(SEARCHPATH)))) +ifeq ($(PPUFILES),) +PPUFILES= +else +PPUFILES:=$(firstword $(PPUFILES)) +endif +endif +export PPUFILES + +# Look if UPX is found for go32v2 and win32. We can't use $UPX becuase +# upx uses that one itself (PFV) +ifndef UPXPROG +ifeq ($(OS_TARGET),go32v2) +UPXPROG:=1 +endif +ifeq ($(OS_TARGET),win32) +UPXPROG:=1 +endif +ifdef UPXPROG +UPXPROG:=$(strip $(wildcard $(addsuffix /upx$(SRCEXEEXT),$(SEARCHPATH)))) +ifeq ($(UPXPROG),) +UPXPROG= +else +UPXPROG:=$(firstword $(UPXPROG)) +endif +else +UPXPROG= +endif +endif +export UPXPROG + +# ZipProg, you can't use Zip as the var name (PFV) +ifndef ZIPPROG +ZIPPROG:=$(strip $(wildcard $(addsuffix /zip$(SRCEXEEXT),$(SEARCHPATH)))) +ifeq ($(ZIPPROG),) +ZIPPROG= +else +ZIPPROG:=$(firstword $(ZIPPROG)) +endif +endif +export ZIPPROG + +ZIPOPT=-9 +ZIPEXT=.zip + +# Tar +ifndef TARPROG +TARPROG:=$(strip $(wildcard $(addsuffix /tar$(SRCEXEEXT),$(SEARCHPATH)))) +ifeq ($(TARPROG),) +TARPROG= +else +TARPROG:=$(firstword $(TARPROG)) +endif +endif +export TARPROG + +ifeq ($(USETAR),bz2) +TAROPT=vI +TAREXT=.tar.bz2 +else +TAROPT=vz +TAREXT=.tar.gz +endif + +##################################################################### +# Default extensions +##################################################################### + +# Default needed extensions (Go32v2,Linux) +LOADEREXT=.as +EXEEXT=.exe +PPLEXT=.ppl +PPUEXT=.ppu +OEXT=.o +ASMEXT=.s +SMARTEXT=.sl +STATICLIBEXT=.a +SHAREDLIBEXT=.so +RSTEXT=.rst +FPCMADE=fpcmade + +# Go32v1 +ifeq ($(OS_TARGET),go32v1) +PPUEXT=.pp1 +OEXT=.o1 +ASMEXT=.s1 +SMARTEXT=.sl1 +STATICLIBEXT=.a1 +SHAREDLIBEXT=.so1 +FPCMADE=fpcmade.v1 +endif + +# Go32v2 +ifeq ($(OS_TARGET),go32v2) +FPCMADE=fpcmade.dos +endif + +# Linux +ifeq ($(OS_TARGET),linux) +EXEEXT= +HASSHAREDLIB=1 +FPCMADE=fpcmade.lnx +endif + +# Linux +ifeq ($(OS_TARGET),freebsd) +EXEEXT= +HASSHAREDLIB=1 +FPCMADE=fpcmade.freebsd +endif + +# Win32 +ifeq ($(OS_TARGET),win32) +PPUEXT=.ppw +OEXT=.ow +ASMEXT=.sw +SMARTEXT=.slw +STATICLIBEXT=.aw +SHAREDLIBEXT=.dll +FPCMADE=fpcmade.w32 +endif + +# OS/2 +ifeq ($(OS_TARGET),os2) +PPUEXT=.ppo +ASMEXT=.so2 +OEXT=.oo2 +SMARTEXT=.so +STATICLIBEXT=.ao2 +SHAREDLIBEXT=.dll +FPCMADE=fpcmade.os2 +endif + +# library prefix +LIBPREFIX=lib +ifeq ($(OS_TARGET),go32v2) +LIBPREFIX= +endif +ifeq ($(OS_TARGET),go32v1) +LIBPREFIX= +endif + +# determine which .pas extension is used +ifndef PASEXT +ifdef EXEOBJECTS +override TESTPAS:=$(strip $(wildcard $(addsuffix .pas,$(firstword $(EXEOBJECTS))))) +else +override TESTPAS:=$(strip $(wildcard $(addsuffix .pas,$(firstword $(UNITOBJECTS))))) +endif +ifeq ($(TESTPAS),) +PASEXT=.pp +else +PASEXT=.pas +endif +endif + + +# Check if the dirs really exists, else turn it off +ifeq ($(wildcard $(UNITSDIR)),) +UNITSDIR= +endif +ifeq ($(wildcard $(TOOLKITSDIR)),) +TOOLKITSDIR= +endif +ifeq ($(wildcard $(PACKAGESDIR)),) +PACKAGESDIR= +endif +ifeq ($(wildcard $(COMPONENTSDIR)),) +COMPONENTSDIR= +endif + + +# PACKAGESDIR packages + +PACKAGERTL=1 +PACKAGEFCL=1 +PACKAGEFPGFX=1 +PACKAGEFPGUI=1 + +ifdef PACKAGERTL +ifneq ($(wildcard $(FPCDIR)/rtl),) +ifneq ($(wildcard $(FPCDIR)/rtl/$(OS_TARGET)),) +PACKAGEDIR_RTL=$(FPCDIR)/rtl/$(OS_TARGET) +else +PACKAGEDIR_RTL=$(FPCDIR)/rtl +endif +ifeq ($(wildcard $(PACKAGEDIR_RTL)/$(FPCMADE)),) +override COMPILEPACKAGES+=package_rtl +package_rtl: + $(MAKE) -C $(PACKAGEDIR_RTL) all +endif +UNITDIR_RTL=$(PACKAGEDIR_RTL) +else +PACKAGEDIR_RTL= +ifneq ($(wildcard $(UNITSDIR)/rtl),) +ifneq ($(wildcard $(UNITSDIR)/rtl/$(OS_TARGET)),) +UNITDIR_RTL=$(UNITSDIR)/rtl/$(OS_TARGET) +else +UNITDIR_RTL=$(UNITSDIR)/rtl +endif +else +UNITDIR_RTL= +endif +endif +ifdef UNITDIR_RTL +override NEEDUNITDIR+=$(UNITDIR_RTL) +endif +endif +ifdef PACKAGEFCL +ifneq ($(wildcard $(FPCDIR)/fcl),) +ifneq ($(wildcard $(FPCDIR)/fcl/$(OS_TARGET)),) +PACKAGEDIR_FCL=$(FPCDIR)/fcl/$(OS_TARGET) +else +PACKAGEDIR_FCL=$(FPCDIR)/fcl +endif +ifeq ($(wildcard $(PACKAGEDIR_FCL)/$(FPCMADE)),) +override COMPILEPACKAGES+=package_fcl +package_fcl: + $(MAKE) -C $(PACKAGEDIR_FCL) all +endif +UNITDIR_FCL=$(PACKAGEDIR_FCL) +else +PACKAGEDIR_FCL= +ifneq ($(wildcard $(UNITSDIR)/fcl),) +ifneq ($(wildcard $(UNITSDIR)/fcl/$(OS_TARGET)),) +UNITDIR_FCL=$(UNITSDIR)/fcl/$(OS_TARGET) +else +UNITDIR_FCL=$(UNITSDIR)/fcl +endif +else +UNITDIR_FCL= +endif +endif +ifdef UNITDIR_FCL +override NEEDUNITDIR+=$(UNITDIR_FCL) +endif +endif +ifdef PACKAGEFPGFX +ifneq ($(wildcard $(PACKAGESDIR)/fpgfx),) +ifneq ($(wildcard $(PACKAGESDIR)/fpgfx/$(OS_TARGET)),) +PACKAGEDIR_FPGFX=$(PACKAGESDIR)/fpgfx/$(OS_TARGET) +else +PACKAGEDIR_FPGFX=$(PACKAGESDIR)/fpgfx +endif +ifeq ($(wildcard $(PACKAGEDIR_FPGFX)/$(FPCMADE)),) +override COMPILEPACKAGES+=package_fpgfx +package_fpgfx: + $(MAKE) -C $(PACKAGEDIR_FPGFX) all +endif +UNITDIR_FPGFX=$(PACKAGEDIR_FPGFX) +else +PACKAGEDIR_FPGFX= +ifneq ($(wildcard $(UNITSDIR)/fpgfx),) +ifneq ($(wildcard $(UNITSDIR)/fpgfx/$(OS_TARGET)),) +UNITDIR_FPGFX=$(UNITSDIR)/fpgfx/$(OS_TARGET) +else +UNITDIR_FPGFX=$(UNITSDIR)/fpgfx +endif +else +UNITDIR_FPGFX= +endif +endif +ifdef UNITDIR_FPGFX +override NEEDUNITDIR+=$(UNITDIR_FPGFX) +endif +endif +ifdef PACKAGEFPGUI +ifneq ($(wildcard $(PACKAGESDIR)/fpgui),) +ifneq ($(wildcard $(PACKAGESDIR)/fpgui/$(OS_TARGET)),) +PACKAGEDIR_FPGUI=$(PACKAGESDIR)/fpgui/$(OS_TARGET) +else +PACKAGEDIR_FPGUI=$(PACKAGESDIR)/fpgui +endif +ifeq ($(wildcard $(PACKAGEDIR_FPGUI)/$(FPCMADE)),) +override COMPILEPACKAGES+=package_fpgui +package_fpgui: + $(MAKE) -C $(PACKAGEDIR_FPGUI) all +endif +UNITDIR_FPGUI=$(PACKAGEDIR_FPGUI) +else +PACKAGEDIR_FPGUI= +ifneq ($(wildcard $(UNITSDIR)/fpgui),) +ifneq ($(wildcard $(UNITSDIR)/fpgui/$(OS_TARGET)),) +UNITDIR_FPGUI=$(UNITSDIR)/fpgui/$(OS_TARGET) +else +UNITDIR_FPGUI=$(UNITSDIR)/fpgui +endif +else +UNITDIR_FPGUI= +endif +endif +ifdef UNITDIR_FPGUI +override NEEDUNITDIR+=$(UNITDIR_FPGUI) +endif +endif + + +##################################################################### +# Default Directories +##################################################################### + +# Linux and freebsd use unix dirs with /usr/bin, /usr/lib +# When zipping use the target as default, when normal install then +# use the source os as default +ifdef ZIPNAME +# Zipinstall +ifeq ($(OS_TARGET),linux) +UNIXINSTALLDIR=1 +endif +ifeq ($(OS_TARGET),freebsd) +UNIXINSTALLDIR=1 +endif +else +# Normal install +ifeq ($(OS_SOURCE),linux) +UNIXINSTALLDIR=1 +endif +ifeq ($(OS_SOURCE),freebsd) +UNIXINSTALLDIR=1 +endif +endif + +# set the prefix directory where to install everything +ifndef PREFIXINSTALLDIR +ifdef UNIXINSTALLDIR +PREFIXINSTALLDIR=/usr +else +PREFIXINSTALLDIR=/pp +endif +endif +export PREFIXINSTALLDIR + +# Where to place the resulting zip files +ifndef DESTZIPDIR +DESTZIPDIR:=$(BASEDIR) +endif +export DESTZIPDIR + +##################################################################### +# Install Directories +##################################################################### + +# set the base directory where to install everything +ifndef BASEINSTALLDIR +ifdef UNIXINSTALLDIR +BASEINSTALLDIR=$(PREFIXINSTALLDIR)/lib/fpc/$(FPC_VERSION) +else +BASEINSTALLDIR=$(PREFIXINSTALLDIR) +endif +endif + +# set the directory where to install the binaries +ifndef BININSTALLDIR +ifdef UNIXINSTALLDIR +BININSTALLDIR=$(PREFIXINSTALLDIR)/bin +else +BININSTALLDIR=$(BASEINSTALLDIR)/bin/$(OS_TARGET) +endif +endif + +# set the directory where to install the units. +ifndef UNITINSTALLDIR +UNITINSTALLDIR=$(BASEINSTALLDIR)/units/$(OS_TARGET) +ifdef UNITSUBDIR +UNITINSTALLDIR:=$(UNITINSTALLDIR)/$(UNITSUBDIR) +endif +endif + +# Where to install shared libraries +ifndef LIBINSTALLDIR +ifdef UNIXINSTALLDIR +LIBINSTALLDIR=$(PREFIXINSTALLDIR)/lib +else +LIBINSTALLDIR=$(UNITINSTALLDIR) +endif +endif + +# Where the source files will be stored +ifndef SOURCEINSTALLDIR +ifdef UNIXINSTALLDIR +SOURCEINSTALLDIR=$(PREFIXINSTALLDIR)/src/fpc-$(FPC_VERSION) +else +SOURCEINSTALLDIR=$(BASEINSTALLDIR)/source +endif +ifdef SOURCESUBDIR +SOURCEINSTALLDIR:=$(SOURCEINSTALLDIR)/$(SOURCESUBDIR) +endif +endif + +# Where the doc files will be stored +ifndef DOCINSTALLDIR +ifdef UNIXINSTALLDIR +DOCINSTALLDIR=$(PREFIXINSTALLDIR)/doc/fpc-$(FPC_VERSION) +else +DOCINSTALLDIR=$(BASEINSTALLDIR)/doc +endif +endif + +# Where to install the examples, under linux we use the doc dir +# because the copytree command will create a subdir itself +ifndef EXAMPLEINSTALLDIR +ifdef UNIXINSTALLDIR +EXAMPLEINSTALLDIR=$(DOCINSTALLDIR)/examples +else +EXAMPLEINSTALLDIR=$(BASEINSTALLDIR)/examples +endif +ifdef EXAMPLESUBDIR +EXAMPLEINSTALLDIR:=$(EXAMPLEINSTALLDIR)/$(EXAMPLESUBDIR) +endif +endif + +# Where the some extra (data)files will be stored +ifndef DATAINSTALLDIR +DATAINSTALLDIR=$(BASEINSTALLDIR) +endif + +##################################################################### +# Redirection +##################################################################### + +ifndef REDIRFILE +REDIRFILE=log +endif + +ifdef REDIR +ifndef inUnix +override FPC=redir -eo $(FPC) +endif +# set the verbosity to max +override FPCOPT+=-va +override REDIR:= >> $(REDIRFILE) +endif + + +##################################################################### +# Compiler Command Line +##################################################################### + +# Load commandline OPTDEF and add FPC_CPU define +override FPCOPTDEF:=-d$(CPU_TARGET) + +# Load commandline OPT and add target and unit dir to be sure +ifneq ($(OS_TARGET),$(OS_SOURCE)) +override FPCOPT+=-T$(OS_TARGET) +endif + +# User dirs should be first, so they are looked at first +ifdef UNITDIR +override FPCOPT+=$(addprefix -Fu,$(UNITDIR)) +endif +ifdef LIBDIR +override FPCOPT+=$(addprefix -Fl,$(LIBDIR)) +endif +ifdef OBJDIR +override FPCOPT+=$(addprefix -Fo,$(OBJDIR)) +endif +ifdef INCDIR +override FPCOPT+=$(addprefix -Fi,$(INCDIR)) +endif + +# Smartlinking +ifdef LINKSMART +override FPCOPT+=-XX +endif + +# Smartlinking creation +ifdef CREATESMART +override FPCOPT+=-CX +endif + +# Debug +ifdef DEBUG +override FPCOPT+=-gl -dDEBUG +endif + +# Release mode (strip, optimize and don't load ppc386.cfg) +# 0.99.12b has a bug in the optimizer so don't use it by default +ifdef RELEASE +ifeq ($(FPC_VERSION),0.99.12) +override FPCOPT+=-Xs -OGp3 -n +else +override FPCOPT+=-Xs -OG2p3 -n +endif +endif + +# Strip +ifdef STRIP +override FPCOPT+=-Xs +endif + +# Optimizer +ifdef OPTIMIZE +override FPCOPT+=-OG2p3 +endif + +# Verbose settings (warning,note,info) +ifdef VERBOSE +override FPCOPT+=-vwni +endif + +ifdef NEEDOPT +override FPCOPT+=$(NEEDOPT) +endif + +ifdef NEEDUNITDIR +override FPCOPT+=$(addprefix -Fu,$(NEEDUNITDIR)) +endif + +ifdef UNITSDIR +override FPCOPT+=-Fu$(UNITSDIR) +endif + +# Target dirs and the prefix to use for clean/install +ifdef TARGETDIR +override FPCOPT+=-FE$(TARGETDIR) +ifeq ($(TARGETDIR),.) +override TARGETDIRPREFIX= +else +override TARGETDIRPREFIX=$(TARGETDIR)/ +endif +endif +ifdef UNITTARGETDIR +override FPCOPT+=-FU$(UNITTARGETDIR) +ifeq ($(UNITTARGETDIR),.) +override UNITTARGETDIRPREFIX= +else +override UNITTARGETDIRPREFIX=$(TARGETDIR)/ +endif +else +ifdef TARGETDIR +override UNITTARGETDIR=$(TARGETDIR) +override UNITTARGETDIRPREFIX=$(TARGETDIRPREFIX) +endif +endif + +# Add commandline options last so they can override +ifdef OPT +override FPCOPT+=$(OPT) +endif + +# Add defines from FPCOPTDEF to FPCOPT +ifdef FPCOPTDEF +override FPCOPT+=$(FPCOPTDEF) +endif + +# Error file ? +ifdef ERRORFILE +override FPCOPT+=-Fr$(ERRORFILE) +endif + +# Was a config file specified ? +ifdef CFGFILE +override FPCOPT+=@$(CFGFILE) +endif + +# For win32 the options are passed using the environment FPCEXTCMD +ifeq ($(OS_SOURCE),win32) +override FPCEXTCMD:=$(FPCOPT) +override FPCOPT:=!FPCEXTCMD +export FPCEXTCMD +endif + +# Compiler commandline +override COMPILER:=$(FPC) $(FPCOPT) + +# also call ppas if with command option -s +# but only if the OS_SOURCE and OS_TARGE are equal +ifeq (,$(findstring -s ,$(COMPILER))) +EXECPPAS= +else +ifeq ($(OS_SOURCE),$(OS_TARGET)) +EXECPPAS:=@$(PPAS) +endif +endif + +##################################################################### +# Standard rules +##################################################################### + +all: fpc_all + +debug: fpc_debug + +smart: fpc_smart + +shared: fpc_shared + +showinstall: fpc_showinstall + +install: fpc_install + +sourceinstall: fpc_sourceinstall + +exampleinstall: fpc_exampleinstall + +zipinstall: fpc_zipinstall + +zipsourceinstall: fpc_zipsourceinstall + +zipexampleinstall: fpc_zipexampleinstall + +clean: fpc_clean + +distclean: fpc_distclean + +cleanall: fpc_cleanall + +info: fpc_info + +.PHONY: all debug smart shared showinstall install sourceinstall exampleinstall zipinstall zipsourceinstall zipexampleinstall clean distclean cleanall info + +##################################################################### +# Exes +##################################################################### + +.PHONY: fpc_exes + +ifdef EXEOBJECTS +override EXEFILES=$(addsuffix $(EXEEXT),$(EXEOBJECTS)) +override EXEOFILES:=$(addsuffix $(OEXT),$(EXEOBJECTS)) $(addprefix $(LIBPREFIX),$(addsuffix $(STATICLIBEXT),$(EXEOBJECTS))) + +override ALLTARGET+=fpc_exes +override INSTALLEXEFILES+=$(EXEFILES) +override CLEANEXEFILES+=$(EXEFILES) $(EXEOFILES) + +endif + +fpc_exes: $(EXEFILES) + +##################################################################### +# General compile rules +##################################################################### + +.PHONY: fpc_packages fpc_all fpc_debug + +$(FPCMADE): $(ALLTARGET) + @$(ECHO) Compiled > $(FPCMADE) + +fpc_packages: $(COMPILEPACKAGES) + +fpc_all: fpc_packages $(FPCMADE) + +fpc_debug: + $(MAKE) all DEBUG=1 + +# Search paths for .ppu if targetdir is set +ifdef UNITTARGETDIR +vpath %$(PPUEXT) $(UNITTARGETDIR) +endif + +# General compile rules, available for both possible PASEXT + +.SUFFIXES: $(EXEEXT) $(PPUEXT) $(OEXT) .pas .pp + +%$(PPUEXT): %.pp + $(COMPILER) $< $(REDIR) + $(EXECPPAS) + +%$(PPUEXT): %.pas + $(COMPILER) $< $(REDIR) + $(EXECPPAS) + +%$(EXEEXT): %.pp + $(COMPILER) $< $(REDIR) + $(EXECPPAS) + +%$(EXEEXT): %.pas + $(COMPILER) $< $(REDIR) + $(EXECPPAS) + +##################################################################### +# Library +##################################################################### + +.PHONY: fpc_smart fpc_shared + +ifdef LIBVERSION +LIBFULLNAME=$(LIBNAME).$(LIBVERSION) +else +LIBFULLNAME=$(LIBNAME) +endif + +# Default sharedlib units are all unit objects +ifndef SHAREDLIBUNITOBJECTS +SHAREDLIBUNITOBJECTS:=$(UNITOBJECTS) +endif + +fpc_smart: + $(MAKE) all LINKSMART=1 CREATESMART=1 + +fpc_shared: all +ifdef HASSHAREDLIB +ifndef LIBNAME + @$(ECHO) "LIBNAME not set" +else + $(PPUMOVE) $(SHAREDLIBUNITOBJECTS) -o$(LIBFULLNAME) +endif +else + @$(ECHO) "Shared Libraries not supported" +endif + +##################################################################### +# Install rules +##################################################################### + +.PHONY: fpc_showinstall fpc_install + +ifdef EXTRAINSTALLUNITS +override INSTALLPPUFILES+=$(addsuffix $(PPUEXT),$(EXTRAINSTALLUNITS)) +endif + +ifdef INSTALLPPUFILES +override INSTALLPPUFILES:=$(addprefix $(UNITTARGETDIRPREFIX),$(INSTALLPPUFILES)) +ifdef PPUFILES +INSTALLPPULINKFILES:=$(shell $(PPUFILES) -S -O $(INSTALLPPUFILES)) +else +INSTALLPPULINKFILES:=$(wildcard $(subst $(PPUEXT),$(OEXT),$(INSTALLPPUFILES)) $(addprefix $(LIBPREFIX),$(subst $(PPUEXT),$(STATICLIBEXT),$(INSTALLPPUFILES)))) +endif +override INSTALLPPULINKFILES:=$(addprefix $(UNITTARGETDIRPREFIX),$(INSTALLPPULINKFILES)) +endif + +ifdef INSTALLEXEFILES +override INSTALLEXEFILES:=$(addprefix $(TARGETDIRPREFIX),$(INSTALLEXEFILES)) +endif + +fpc_showinstall: $(SHOWINSTALLTARGET) +ifdef INSTALLEXEFILES + @$(ECHO) -e $(addprefix "\n"$(BININSTALLDIR)/,$(INSTALLEXEFILES)) +endif +ifdef INSTALLPPUFILES + @$(ECHO) -e $(addprefix "\n"$(UNITINSTALLDIR)/,$(INSTALLPPUFILES)) +ifneq ($(INSTALLPPULINKFILES),) + @$(ECHO) -e $(addprefix "\n"$(UNITINSTALLDIR)/,$(INSTALLPPULINKFILES)) +endif +ifneq ($(wildcard $(LIBFULLNAME)),) + @$(ECHO) $(LIBINSTALLDIR)/$(LIBFULLNAME) +ifdef HASSHAREDLIB + @$(ECHO) $(LIBINSTALLDIR)/$(LIBNAME) +endif +endif +endif +ifdef EXTRAINSTALLFILES + @$(ECHO) -e $(addprefix "\n"$(DATAINSTALLDIR)/,$(EXTRAINSTALLFILES)) +endif + +fpc_install: $(INSTALLTARGET) +# Create UnitInstallFiles +ifdef INSTALLEXEFILES + $(MKDIR) $(BININSTALLDIR) +# Compress the exes if upx is defined +ifdef UPXPROG + -$(UPXPROG) $(INSTALLEXEFILES) +endif + $(INSTALLEXE) $(INSTALLEXEFILES) $(BININSTALLDIR) +endif +ifdef INSTALLPPUFILES + $(MKDIR) $(UNITINSTALLDIR) + $(INSTALL) $(INSTALLPPUFILES) $(UNITINSTALLDIR) +ifneq ($(INSTALLPPULINKFILES),) + $(INSTALL) $(INSTALLPPULINKFILES) $(UNITINSTALLDIR) +endif +ifneq ($(wildcard $(LIBFULLNAME)),) + $(MKDIR) $(LIBINSTALLDIR) + $(INSTALL) $(LIBFULLNAME) $(LIBINSTALLDIR) +ifdef inUnix + ln -sf $(LIBFULLNAME) $(LIBINSTALLDIR)/$(LIBNAME) +endif +endif +endif +ifdef EXTRAINSTALLFILES + $(MKDIR) $(DATAINSTALLDIR) + $(INSTALL) $(EXTRAINSTALLFILES) $(DATAINSTALLDIR) +endif + +##################################################################### +# SourceInstall rules +##################################################################### + +.PHONY: fpc_sourceinstall + +ifndef SOURCETOPDIR +SOURCETOPDIR=$(BASEDIR) +endif + +fpc_sourceinstall: clean + $(MKDIR) $(SOURCEINSTALLDIR) + $(COPYTREE) $(SOURCETOPDIR) $(SOURCEINSTALLDIR) + +##################################################################### +# exampleinstall rules +##################################################################### + +.PHONY: fpc_exampleinstall + +fpc_exampleinstall: $(addsuffix _clean,$(EXAMPLEDIROBJECTS)) +ifdef EXAMPLESOURCEFILES + $(MKDIR) $(EXAMPLEINSTALLDIR) + $(COPY) $(EXAMPLESOURCEFILES) $(EXAMPLEINSTALLDIR) +endif +ifdef EXAMPLEDIROBJECTS +ifndef EXAMPLESOURCEFILES + $(MKDIR) $(EXAMPLEINSTALLDIR) +endif + $(COPYTREE) $(addsuffix /*,$(EXAMPLEDIROBJECTS)) $(EXAMPLEINSTALLDIR) +endif + +##################################################################### +# Zip +##################################################################### + +.PHONY: fpc_zipinstall + +# Create suffix to add +ifndef PACKAGESUFFIX +PACKAGESUFFIX=$(OS_TARGET) +ifeq ($(OS_TARGET),go32v2) +PACKAGESUFFIX=go32 +endif +ifeq ($(OS_TARGET),win32) +PACKAGESUFFIX=w32 +endif +ifeq ($(OS_TARGET),os2) +PACKAGESUFFIX=emx +endif +endif + +# Temporary path to pack a file +ifndef PACKDIR +ifndef inUnix +PACKDIR=$(BASEDIR)/pack_tmp +else +PACKDIR=/tmp/fpc-pack +endif +endif + +# Maybe create default zipname from packagename +ifndef ZIPNAME +ifdef PACKAGENAME +ZIPNAME=$(PACKAGEPREFIX)$(PACKAGENAME)$(PACKAGESUFFIX) +endif +endif + +# Use tar by default under linux +ifndef USEZIP +ifdef inUnix +USETAR=1 +endif +endif + +# Use a wrapper script by default for OS/2 +ifdef inOS2 +USEZIPWRAPPER=1 +endif + +# Create commands to create the zip/tar file +ZIPWRAPPER=$(DESTZIPDIR)/fpczip$(BATCHEXT) +ZIPCMD_CDPACK:=cd $(subst /,$(PATHSEP),$(PACKDIR)) +ZIPCMD_CDBASE:=cd $(subst /,$(PATHSEP),$(BASEDIR)) +ifdef USETAR +ZIPDESTFILE:=$(DESTZIPDIR)/$(ZIPNAME)$(TAREXT) +ZIPCMD_ZIP:=$(TARPROG) cf$(TAROPT) $(ZIPDESTFILE) * +else +ZIPDESTFILE:=$(DESTZIPDIR)/$(ZIPNAME)$(ZIPEXT) +ZIPCMD_ZIP:=$(subst /,$(PATHSEP),$(ZIPPROG)) -Dr $(ZIPOPT) $(ZIPDESTFILE) * +endif + +fpc_zipinstall: +ifndef ZIPNAME + @$(ECHO) "Please specify ZIPNAME!" + @exit 1 +else + $(MAKE) $(ZIPTARGET) PREFIXINSTALLDIR=$(PACKDIR) + $(DEL) $(ZIPDESTFILE) +ifdef USEZIPWRAPPER +ifneq ($(ECHO),echo) + $(ECHO) "$(ZIPCMD_CDPACK)" > $(ZIPWRAPPER) + $(ECHO) "$(ZIPCMD_ZIP)" >> $(ZIPWRAPPER) + $(ECHO) "$(ZIPCMD_CDBASE)" >> $(ZIPWRAPPER) +else + $(ECHO) $(ZIPCMD_CDPACK) > $(ZIPWRAPPER) + $(ECHO) $(ZIPCMD_ZIP) >> $(ZIPWRAPPER) + $(ECHO) $(ZIPCMD_CDBASE) >> $(ZIPWRAPPER) +endif +ifdef inUnix + /bin/sh $(ZIPWRAPPER) +else + $(ZIPWRAPPER) +endif + $(DEL) $(ZIPWRAPPER) +else + $(ZIPCMD_CDPACK) ; $(ZIPCMD_ZIP) ; $(ZIPCMD_CDBASE) +endif + $(DELTREE) $(PACKDIR) +endif + +.PHONY: fpc_zipsourceinstall + +fpc_zipsourceinstall: + $(MAKE) fpc_zipinstall ZIPTARGET=sourceinstall PACKAGESUFFIX=src + +.PHONY: fpc_zipexampleinstall + +fpc_zipexampleinstall: + $(MAKE) fpc_zipinstall ZIPTARGET=exampleinstall PACKAGESUFFIX=exm + +##################################################################### +# Clean rules +##################################################################### + +.PHONY: fpc_clean fpc_cleanall fpc_distclean + +ifdef EXEFILES +override CLEANEXEFILES:=$(addprefix $(TARGETDIRPREFIX),$(CLEANEXEFILES)) +endif + +ifdef EXTRACLEANUNITS +override CLEANPPUFILES+=$(addsuffix $(PPUEXT),$(EXTRACLEANUNITS)) +endif + +ifdef CLEANPPUFILES +override CLEANPPUFILES:=$(addprefix $(UNITTARGETDIRPREFIX),$(CLEANPPUFILES)) +# Get the .o and .a files created for the units +ifdef PPUFILES +CLEANPPULINKFILES:=$(shell $(PPUFILES) $(CLEANPPUFILES)) +else +CLEANPPULINKFILES:=$(wildcard $(subst $(PPUEXT),$(OEXT),$(CLEANPPUFILES)) $(addprefix $(LIBPREFIX),$(subst $(PPUEXT),$(STATICLIBEXT),$(CLEANPPUFILES)))) +endif +override CLEANPPULINKFILES:=$(addprefix $(UNITTARGETDIRPREFIX),$(CLEANPPULINKFILES)) +endif + +fpc_clean: $(CLEANTARGET) +ifdef CLEANEXEFILES + -$(DEL) $(CLEANEXEFILES) +endif +ifdef CLEANPPUFILES + -$(DEL) $(CLEANPPUFILES) +endif +ifneq ($(CLEANPPULINKFILES),) + -$(DEL) $(CLEANPPULINKFILES) +endif +ifdef CLEANRSTFILES + -$(DEL) $(addprefix $(UNITTARGETDIRPREFIX),$(CLEANRSTFILES)) +endif +ifdef EXTRACLEANFILES + -$(DEL) $(EXTRACLEANFILES) +endif +ifdef LIBNAME + -$(DEL) $(LIBNAME) $(LIBFULLNAME) +endif + -$(DEL) $(FPCMADE) $(PPAS) link.res $(FPCEXTFILE) $(REDIRFILE) + +fpc_distclean: fpc_clean + +# Also run clean first if targetdir is set. Unittargetdir is always +# set if targetdir or unittargetdir is specified +ifdef UNITTARGETDIR +TARGETDIRCLEAN=fpc_clean +endif + +fpc_cleanall: $(CLEANTARGET) $(TARGETDIRCLEAN) +ifdef CLEANEXEFILES + -$(DEL) $(CLEANEXEFILES) +endif + -$(DEL) *$(OEXT) *$(PPUEXT) *$(RSTEXT) *$(ASMEXT) *$(STATICLIBEXT) *$(SHAREDLIBEXT) *$(PPLEXT) + -$(DELTREE) *$(SMARTEXT) + -$(DEL) $(FPCMADE) $(PPAS) link.res $(FPCEXTFILE) $(REDIRFILE) + +##################################################################### +# Info rules +##################################################################### + +.PHONY: fpc_info fpc_cfginfo fpc_objectinfo fpc_toolsinfo fpc_installinfo \ + fpc_dirinfo + +fpc_info: $(INFOTARGET) + +fpc_infocfg: + @$(ECHO) + @$(ECHO) == Configuration info == + @$(ECHO) + @$(ECHO) FPC....... $(FPC) + @$(ECHO) Version... $(FPC_VERSION) + @$(ECHO) CPU....... $(CPU_TARGET) + @$(ECHO) Source.... $(OS_SOURCE) + @$(ECHO) Target.... $(OS_TARGET) + @$(ECHO) + +fpc_infoobjects: + @$(ECHO) + @$(ECHO) == Object info == + @$(ECHO) + @$(ECHO) LoaderObjects..... $(LOADEROBJECTS) + @$(ECHO) UnitObjects....... $(UNITOBJECTS) + @$(ECHO) ExeObjects........ $(EXEOBJECTS) + @$(ECHO) + @$(ECHO) ExtraCleanUnits... $(EXTRACLEANUNITS) + @$(ECHO) ExtraCleanFiles... $(EXTRACLEANFILES) + @$(ECHO) + @$(ECHO) ExtraInstallUnits. $(EXTRAINSTALLUNITS) + @$(ECHO) ExtraInstallFiles. $(EXTRAINSTALLFILES) + @$(ECHO) + +fpc_infoinstall: + @$(ECHO) + @$(ECHO) == Install info == + @$(ECHO) +ifdef DATE + @$(ECHO) DateStr.............. $(DATESTR) +endif +ifdef PACKAGEPREFIX + @$(ECHO) PackagePrefix........ $(PACKAGEPREFIX) +endif +ifdef PACKAGENAME + @$(ECHO) PackageName.......... $(PACKAGENAME) +endif + @$(ECHO) PackageSuffix........ $(PACKAGESUFFIX) + @$(ECHO) + @$(ECHO) BaseInstallDir....... $(BASEINSTALLDIR) + @$(ECHO) BinInstallDir........ $(BININSTALLDIR) + @$(ECHO) LibInstallDir........ $(LIBINSTALLDIR) + @$(ECHO) UnitInstallDir....... $(UNITINSTALLDIR) + @$(ECHO) SourceInstallDir..... $(SOURCEINSTALLDIR) + @$(ECHO) DocInstallDir........ $(DOCINSTALLDIR) + @$(ECHO) DataInstallDir....... $(DATAINSTALLDIR) + @$(ECHO) + @$(ECHO) DestZipDir........... $(DESTZIPDIR) + @$(ECHO) ZipName.............. $(ZIPNAME) + @$(ECHO) + +##################################################################### +# Local Makefile +##################################################################### + +ifneq ($(wildcard fpcmake.loc),) +include fpcmake.loc +endif + diff --git a/examples/gui/dbftest/Makefile.fpc b/examples/gui/dbftest/Makefile.fpc new file mode 100644 index 00000000..c3024e8b --- /dev/null +++ b/examples/gui/dbftest/Makefile.fpc @@ -0,0 +1,10 @@ +# +# Makefile.fpc for fpGUI DBFTest example +# + +[targets] +programs=dbftest + +[require] +options=-S2h +packages=fcl fpgfx fpgui diff --git a/examples/gui/dbftest/dbftest.pas b/examples/gui/dbftest/dbftest.pas new file mode 100644 index 00000000..32c70484 --- /dev/null +++ b/examples/gui/dbftest/dbftest.pas @@ -0,0 +1,114 @@ +{ + $Id: dbftest.pp,v 1.2 2001/01/18 12:40:41 sg Exp $ + + fpGUI - Free Pascal Graphical User Interface + Copyright (C) 2001 by + Areca Systems GmbH / Sebastian Guenther, sg@freepascal.org + + DBF database test + + See the file COPYING.FPC, included in this distribution, + for details about the copyright. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +} + + +program DBFTest; + +uses SysUtils, Classes, fpGUI, fpGUI_DB, DB, DBF; + +type + + TMainForm = class(TForm) + DataSet: TDBF; + DataSource: TDataSource; + Box: TBoxLayout; + ListBox: TListBox; + CurDatasetLabel: TLabel; + CurNameText, CurEMailText: TDBText; + Navi: TBoxLayout; + FirstDataset, PrevDataset, NextDataset, LastDataset: TButton; + procedure FormCreate(Sender: TObject); + procedure FirstDatasetClick(Sender: TObject); + procedure PrevDatasetClick(Sender: TObject); + procedure NextDatasetClick(Sender: TObject); + procedure LastDatasetClick(Sender: TObject); + end; + + +// ------------------------------------------------------------------- +// TMainForm +// ------------------------------------------------------------------- + +procedure TMainForm.FormCreate(Sender: TObject); +var + x: Integer; + s: String; +begin + DataSet := TDBF.Create(Self); + DataSet.TableName := 'test.dbf'; + DataSource := TDataSource.Create(Self); + DataSource.DataSet := DataSet; + + CurNameText.DataSource := DataSource; + CurNameText.DataField := 'Name'; + CurEMailText.DataSource := DataSource; + CurEMailText.DataField := 'Address'; + + DataSet.Open; + + while not DataSet.EOF do + begin + SetLength(s, 0); + for x := 0 to DataSet.FieldCount - 2 do + s := s + DataSet.Fields[x].AsString + ', '; + s := s + DataSet.Fields[DataSet.FieldCount - 1].AsString; + ListBox.Items.Add(s); + DataSet.Next; + end; + + DataSet.First; +end; + +procedure TMainForm.FirstDatasetClick(Sender: TObject); +begin + DataSet.First; +end; + +procedure TMainForm.PrevDatasetClick(Sender: TObject); +begin + DataSet.Prior; +end; + +procedure TMainForm.NextDatasetClick(Sender: TObject); +begin + DataSet.Next; +end; + +procedure TMainForm.LastDatasetClick(Sender: TObject); +begin + DataSet.Last; +end; + + +var + MainForm: TMainForm; +begin + Application.Title := 'Interbase Test'; + Application.CreateForm(TMainForm, MainForm); + Application.Run; +end. + + +{ + $Log: dbftest.pp,v $ + Revision 1.2 2001/01/18 12:40:41 sg + * Now uses the correct field names for the data links ;) + + Revision 1.1 2001/01/17 21:33:28 sg + * First version + +} diff --git a/examples/gui/dbftest/mainform.frm b/examples/gui/dbftest/mainform.frm new file mode 100644 index 00000000..9508c21e --- /dev/null +++ b/examples/gui/dbftest/mainform.frm @@ -0,0 +1,38 @@ +object MainForm: TMainForm + Text = 'DBF test' + BorderWidth = 8 + OnCreate = FormCreate + object Box: TBoxLayout + Spacing = 8 + Orientation = Vertical + object ListBox: TListBox + end + object CurDatasetLabel: TLabel + Text = 'Current dataset:' + end + object CurNameText: TDBText + Text = '<name>' + end + object CurEMailText: TDBText + Text = '<e-mail>' + end + object Navi: TBoxLayout + object FirstDataset: TButton + Text = 'First' + OnClick = FirstDatasetClick + end + object PrevDataset: TButton + Text = 'Previous' + OnClick = PrevDatasetClick + end + object NextDataset: TButton + Text = 'Next' + OnClick = NextDatasetClick + end + object LastDataset: TButton + Text = 'Last' + OnClick = LastDatasetClick + end + end + end +end diff --git a/examples/gui/dbftest/test.dbf b/examples/gui/dbftest/test.dbf Binary files differnew file mode 100644 index 00000000..cebd1384 --- /dev/null +++ b/examples/gui/dbftest/test.dbf diff --git a/examples/gui/helloworld/Makefile b/examples/gui/helloworld/Makefile new file mode 100644 index 00000000..c2e4e873 --- /dev/null +++ b/examples/gui/helloworld/Makefile @@ -0,0 +1,1320 @@ +# +# Makefile generated by fpcmake v1.00 [2000/12/14] +# + +defaultrule: all + +##################################################################### +# Autodetect OS (Linux or Dos or Windows NT) +# define inUnix when running under Unix (Linux,FreeBSD) +# define inWinNT when running under WinNT +##################################################################### + +# We need only / in the path +override PATH:=$(subst \,/,$(PATH)) + +# Search for PWD and determine also if we are under linux +PWD:=$(strip $(wildcard $(addsuffix /pwd.exe,$(subst ;, ,$(PATH))))) +ifeq ($(PWD),) +PWD:=$(strip $(wildcard $(addsuffix /pwd,$(subst :, ,$(PATH))))) +ifeq ($(PWD),) +nopwd: + @echo You need the GNU utils package to use this Makefile! + @echo Get ftp://ftp.freepascal.org/pub/fpc/dist/go32v2/utilgo32.zip + @exit +else +inUnix=1 +endif +else +PWD:=$(firstword $(PWD)) +endif + +# Detect NT - NT sets OS to Windows_NT +# Detect OS/2 - OS/2 has OS2_SHELL defined +ifndef inUnix +ifeq ($(OS),Windows_NT) +inWinNT=1 +else +ifdef OS2_SHELL +inOS2=1 +endif +endif +endif + +# The extension of executables +ifdef inUnix +SRCEXEEXT= +else +SRCEXEEXT=.exe +endif + +# The path which is searched separated by spaces +ifdef inUnix +SEARCHPATH=$(subst :, ,$(PATH)) +else +SEARCHPATH=$(subst ;, ,$(PATH)) +endif + +# Base dir +ifdef PWD +BASEDIR:=$(shell $(PWD)) +else +BASEDIR=. +endif + +##################################################################### +# FPC version/target Detection +##################################################################### + +# What compiler to use ? +ifndef FPC +# Compatibility with old makefiles +ifdef PP +FPC=$(PP) +else +FPC=ppc386 +endif +endif +override FPC:=$(subst $(SRCEXEEXT),,$(FPC)) +override FPC:=$(subst \,/,$(FPC))$(SRCEXEEXT) + +# Target OS +ifndef OS_TARGET +OS_TARGET:=$(shell $(FPC) -iTO) +endif + +# Source OS +ifndef OS_SOURCE +OS_SOURCE:=$(shell $(FPC) -iSO) +endif + +# Target CPU +ifndef CPU_TARGET +CPU_TARGET:=$(shell $(FPC) -iTP) +endif + +# Source CPU +ifndef CPU_SOURCE +CPU_SOURCE:=$(shell $(FPC) -iSP) +endif + +# FPC version +ifndef FPC_VERSION +FPC_VERSION:=$(shell $(FPC) -iV) +endif + +export FPC OS_TARGET OS_SOURCE CPU_TARGET CPU_SOURCE FPC_VERSION FPCOPT + +##################################################################### +# FPCDIR Setting +##################################################################### + +# Test FPCDIR to look if the RTL dir exists +ifdef FPCDIR +override FPCDIR:=$(subst \,/,$(FPCDIR)) +ifeq ($(wildcard $(FPCDIR)/rtl),) +ifeq ($(wildcard $(FPCDIR)/units),) +override FPCDIR=wrong +endif +endif +else +override FPCDIR=wrong +endif + +# Detect FPCDIR +ifeq ($(FPCDIR),wrong) +ifdef inUnix +override FPCDIR=/usr/local/lib/fpc/$(FPC_VERSION) +ifeq ($(wildcard $(FPCDIR)/units),) +override FPCDIR=/usr/lib/fpc/$(FPC_VERSION) +endif +else +override FPCDIR:=$(subst /$(FPC),,$(firstword $(strip $(wildcard $(addsuffix /$(FPC),$(SEARCHPATH)))))) +override FPCDIR:=$(FPCDIR)/.. +ifeq ($(wildcard $(FPCDIR)/rtl),) +ifeq ($(wildcard $(FPCDIR)/units),) +override FPCDIR:=$(FPCDIR)/.. +ifeq ($(wildcard $(FPCDIR)/rtl),) +ifeq ($(wildcard $(FPCDIR)/units),) +override FPCDIR=c:/pp +endif +endif +endif +endif +endif +endif + +ifndef PACKAGESDIR +PACKAGESDIR=$(FPCDIR)/packages +endif +ifndef TOOLKITSDIR +TOOLKITSDIR= +endif +ifndef COMPONENTSDIR +COMPONENTSDIR= +endif + +# Create units dir +ifneq ($(FPCDIR),.) +UNITSDIR=$(FPCDIR)/units/$(OS_TARGET) +endif + +##################################################################### +# User Settings +##################################################################### + + +# Targets + +override EXEOBJECTS+=helloworld + +# Clean + + +# Install + +ZIPTARGET=install + +# Defaults + +override NEEDOPT=-S2h + +# Directories + + +# Packages + +override PACKAGES+=rtl fcl fpgfx fpgui + +# Libraries + + +# Info + +INFOTARGET=fpc_infocfg fpc_infoobjects fpc_infoinstall + +##################################################################### +# Shell tools +##################################################################### + +# echo +ifndef ECHO +ECHO:=$(strip $(wildcard $(addsuffix /gecho$(EXEEXT),$(SEARCHPATH)))) +ifeq ($(ECHO),) +ECHO:=$(strip $(wildcard $(addsuffix /echo$(SRCEXEEXT),$(SEARCHPATH)))) +ifeq ($(ECHO),) +ECHO:=echo +ECHOE:=echo +else +ECHO:=$(firstword $(ECHO)) +ECHOE=$(ECHO) -E +endif +else +ECHO:=$(firstword $(ECHO)) +ECHOE=$(ECHO) -E +endif +endif + +# To copy pograms +ifndef COPY +COPY:=cp -fp +endif + +# Copy a whole tree +ifndef COPYTREE +COPYTREE:=cp -rfp +endif + +# To move pograms +ifndef MOVE +MOVE:=mv -f +endif + +# Check delete program +ifndef DEL +DEL:=rm -f +endif + +# Check deltree program +ifndef DELTREE +DELTREE:=rm -rf +endif + +# To install files +ifndef INSTALL +ifdef inUnix +INSTALL:=install -c -m 644 +else +INSTALL:=$(COPY) +endif +endif + +# To install programs +ifndef INSTALLEXE +ifdef inUnix +INSTALLEXE:=install -c -m 755 +else +INSTALLEXE:=$(COPY) +endif +endif + +# To make a directory. +ifndef MKDIR +ifdef inUnix +MKDIR:=install -m 755 -d +else +MKDIR:=ginstall -m 755 -d +endif +endif + +export ECHO ECHOE COPY COPYTREE MOVE DEL DELTREE INSTALL INSTALLEXE MKDIR + +##################################################################### +# Default Tools +##################################################################### + +# assembler, redefine it if cross compiling +ifndef AS +AS=as +endif + +# linker, but probably not used +ifndef LD +LD=ld +endif + +# ppas.bat / ppas.sh +ifdef inUnix +PPAS=ppas.sh +else +ifdef inOS2 +PPAS=ppas.cmd +else +PPAS=ppas.bat +endif +endif + +# ldconfig to rebuild .so cache +ifdef inUnix +LDCONFIG=ldconfig +else +LDCONFIG= +endif + +# ppumove +ifndef PPUMOVE +PPUMOVE:=$(strip $(wildcard $(addsuffix /ppumove$(SRCEXEEXT),$(SEARCHPATH)))) +ifeq ($(PPUMOVE),) +PPUMOVE= +else +PPUMOVE:=$(firstword $(PPUMOVE)) +endif +endif +export PPUMOVE + +# ppufiles +ifndef PPUFILES +PPUFILES:=$(strip $(wildcard $(addsuffix /ppufiles$(SRCEXEEXT),$(SEARCHPATH)))) +ifeq ($(PPUFILES),) +PPUFILES= +else +PPUFILES:=$(firstword $(PPUFILES)) +endif +endif +export PPUFILES + +# Look if UPX is found for go32v2 and win32. We can't use $UPX becuase +# upx uses that one itself (PFV) +ifndef UPXPROG +ifeq ($(OS_TARGET),go32v2) +UPXPROG:=1 +endif +ifeq ($(OS_TARGET),win32) +UPXPROG:=1 +endif +ifdef UPXPROG +UPXPROG:=$(strip $(wildcard $(addsuffix /upx$(SRCEXEEXT),$(SEARCHPATH)))) +ifeq ($(UPXPROG),) +UPXPROG= +else +UPXPROG:=$(firstword $(UPXPROG)) +endif +else +UPXPROG= +endif +endif +export UPXPROG + +# ZipProg, you can't use Zip as the var name (PFV) +ifndef ZIPPROG +ZIPPROG:=$(strip $(wildcard $(addsuffix /zip$(SRCEXEEXT),$(SEARCHPATH)))) +ifeq ($(ZIPPROG),) +ZIPPROG= +else +ZIPPROG:=$(firstword $(ZIPPROG)) +endif +endif +export ZIPPROG + +ZIPOPT=-9 +ZIPEXT=.zip + +# Tar +ifndef TARPROG +TARPROG:=$(strip $(wildcard $(addsuffix /tar$(SRCEXEEXT),$(SEARCHPATH)))) +ifeq ($(TARPROG),) +TARPROG= +else +TARPROG:=$(firstword $(TARPROG)) +endif +endif +export TARPROG + +ifeq ($(USETAR),bz2) +TAROPT=vI +TAREXT=.tar.bz2 +else +TAROPT=vz +TAREXT=.tar.gz +endif + +##################################################################### +# Default extensions +##################################################################### + +# Default needed extensions (Go32v2,Linux) +LOADEREXT=.as +EXEEXT=.exe +PPLEXT=.ppl +PPUEXT=.ppu +OEXT=.o +ASMEXT=.s +SMARTEXT=.sl +STATICLIBEXT=.a +SHAREDLIBEXT=.so +RSTEXT=.rst +FPCMADE=fpcmade + +# Go32v1 +ifeq ($(OS_TARGET),go32v1) +PPUEXT=.pp1 +OEXT=.o1 +ASMEXT=.s1 +SMARTEXT=.sl1 +STATICLIBEXT=.a1 +SHAREDLIBEXT=.so1 +FPCMADE=fpcmade.v1 +endif + +# Go32v2 +ifeq ($(OS_TARGET),go32v2) +FPCMADE=fpcmade.dos +endif + +# Linux +ifeq ($(OS_TARGET),linux) +EXEEXT= +HASSHAREDLIB=1 +FPCMADE=fpcmade.lnx +endif + +# Linux +ifeq ($(OS_TARGET),freebsd) +EXEEXT= +HASSHAREDLIB=1 +FPCMADE=fpcmade.freebsd +endif + +# Win32 +ifeq ($(OS_TARGET),win32) +PPUEXT=.ppw +OEXT=.ow +ASMEXT=.sw +SMARTEXT=.slw +STATICLIBEXT=.aw +SHAREDLIBEXT=.dll +FPCMADE=fpcmade.w32 +endif + +# OS/2 +ifeq ($(OS_TARGET),os2) +PPUEXT=.ppo +ASMEXT=.so2 +OEXT=.oo2 +SMARTEXT=.so +STATICLIBEXT=.ao2 +SHAREDLIBEXT=.dll +FPCMADE=fpcmade.os2 +endif + +# library prefix +LIBPREFIX=lib +ifeq ($(OS_TARGET),go32v2) +LIBPREFIX= +endif +ifeq ($(OS_TARGET),go32v1) +LIBPREFIX= +endif + +# determine which .pas extension is used +ifndef PASEXT +ifdef EXEOBJECTS +override TESTPAS:=$(strip $(wildcard $(addsuffix .pas,$(firstword $(EXEOBJECTS))))) +else +override TESTPAS:=$(strip $(wildcard $(addsuffix .pas,$(firstword $(UNITOBJECTS))))) +endif +ifeq ($(TESTPAS),) +PASEXT=.pp +else +PASEXT=.pas +endif +endif + + +# Check if the dirs really exists, else turn it off +ifeq ($(wildcard $(UNITSDIR)),) +UNITSDIR= +endif +ifeq ($(wildcard $(TOOLKITSDIR)),) +TOOLKITSDIR= +endif +ifeq ($(wildcard $(PACKAGESDIR)),) +PACKAGESDIR= +endif +ifeq ($(wildcard $(COMPONENTSDIR)),) +COMPONENTSDIR= +endif + + +# PACKAGESDIR packages + +PACKAGERTL=1 +PACKAGEFCL=1 +PACKAGEFPGFX=1 +PACKAGEFPGUI=1 + +ifdef PACKAGERTL +ifneq ($(wildcard $(FPCDIR)/rtl),) +ifneq ($(wildcard $(FPCDIR)/rtl/$(OS_TARGET)),) +PACKAGEDIR_RTL=$(FPCDIR)/rtl/$(OS_TARGET) +else +PACKAGEDIR_RTL=$(FPCDIR)/rtl +endif +ifeq ($(wildcard $(PACKAGEDIR_RTL)/$(FPCMADE)),) +override COMPILEPACKAGES+=package_rtl +package_rtl: + $(MAKE) -C $(PACKAGEDIR_RTL) all +endif +UNITDIR_RTL=$(PACKAGEDIR_RTL) +else +PACKAGEDIR_RTL= +ifneq ($(wildcard $(UNITSDIR)/rtl),) +ifneq ($(wildcard $(UNITSDIR)/rtl/$(OS_TARGET)),) +UNITDIR_RTL=$(UNITSDIR)/rtl/$(OS_TARGET) +else +UNITDIR_RTL=$(UNITSDIR)/rtl +endif +else +UNITDIR_RTL= +endif +endif +ifdef UNITDIR_RTL +override NEEDUNITDIR+=$(UNITDIR_RTL) +endif +endif +ifdef PACKAGEFCL +ifneq ($(wildcard $(FPCDIR)/fcl),) +ifneq ($(wildcard $(FPCDIR)/fcl/$(OS_TARGET)),) +PACKAGEDIR_FCL=$(FPCDIR)/fcl/$(OS_TARGET) +else +PACKAGEDIR_FCL=$(FPCDIR)/fcl +endif +ifeq ($(wildcard $(PACKAGEDIR_FCL)/$(FPCMADE)),) +override COMPILEPACKAGES+=package_fcl +package_fcl: + $(MAKE) -C $(PACKAGEDIR_FCL) all +endif +UNITDIR_FCL=$(PACKAGEDIR_FCL) +else +PACKAGEDIR_FCL= +ifneq ($(wildcard $(UNITSDIR)/fcl),) +ifneq ($(wildcard $(UNITSDIR)/fcl/$(OS_TARGET)),) +UNITDIR_FCL=$(UNITSDIR)/fcl/$(OS_TARGET) +else +UNITDIR_FCL=$(UNITSDIR)/fcl +endif +else +UNITDIR_FCL= +endif +endif +ifdef UNITDIR_FCL +override NEEDUNITDIR+=$(UNITDIR_FCL) +endif +endif +ifdef PACKAGEFPGFX +ifneq ($(wildcard $(PACKAGESDIR)/fpgfx),) +ifneq ($(wildcard $(PACKAGESDIR)/fpgfx/$(OS_TARGET)),) +PACKAGEDIR_FPGFX=$(PACKAGESDIR)/fpgfx/$(OS_TARGET) +else +PACKAGEDIR_FPGFX=$(PACKAGESDIR)/fpgfx +endif +ifeq ($(wildcard $(PACKAGEDIR_FPGFX)/$(FPCMADE)),) +override COMPILEPACKAGES+=package_fpgfx +package_fpgfx: + $(MAKE) -C $(PACKAGEDIR_FPGFX) all +endif +UNITDIR_FPGFX=$(PACKAGEDIR_FPGFX) +else +PACKAGEDIR_FPGFX= +ifneq ($(wildcard $(UNITSDIR)/fpgfx),) +ifneq ($(wildcard $(UNITSDIR)/fpgfx/$(OS_TARGET)),) +UNITDIR_FPGFX=$(UNITSDIR)/fpgfx/$(OS_TARGET) +else +UNITDIR_FPGFX=$(UNITSDIR)/fpgfx +endif +else +UNITDIR_FPGFX= +endif +endif +ifdef UNITDIR_FPGFX +override NEEDUNITDIR+=$(UNITDIR_FPGFX) +endif +endif +ifdef PACKAGEFPGUI +ifneq ($(wildcard $(PACKAGESDIR)/fpgui),) +ifneq ($(wildcard $(PACKAGESDIR)/fpgui/$(OS_TARGET)),) +PACKAGEDIR_FPGUI=$(PACKAGESDIR)/fpgui/$(OS_TARGET) +else +PACKAGEDIR_FPGUI=$(PACKAGESDIR)/fpgui +endif +ifeq ($(wildcard $(PACKAGEDIR_FPGUI)/$(FPCMADE)),) +override COMPILEPACKAGES+=package_fpgui +package_fpgui: + $(MAKE) -C $(PACKAGEDIR_FPGUI) all +endif +UNITDIR_FPGUI=$(PACKAGEDIR_FPGUI) +else +PACKAGEDIR_FPGUI= +ifneq ($(wildcard $(UNITSDIR)/fpgui),) +ifneq ($(wildcard $(UNITSDIR)/fpgui/$(OS_TARGET)),) +UNITDIR_FPGUI=$(UNITSDIR)/fpgui/$(OS_TARGET) +else +UNITDIR_FPGUI=$(UNITSDIR)/fpgui +endif +else +UNITDIR_FPGUI= +endif +endif +ifdef UNITDIR_FPGUI +override NEEDUNITDIR+=$(UNITDIR_FPGUI) +endif +endif + + +##################################################################### +# Default Directories +##################################################################### + +# Linux and freebsd use unix dirs with /usr/bin, /usr/lib +# When zipping use the target as default, when normal install then +# use the source os as default +ifdef ZIPNAME +# Zipinstall +ifeq ($(OS_TARGET),linux) +UNIXINSTALLDIR=1 +endif +ifeq ($(OS_TARGET),freebsd) +UNIXINSTALLDIR=1 +endif +else +# Normal install +ifeq ($(OS_SOURCE),linux) +UNIXINSTALLDIR=1 +endif +ifeq ($(OS_SOURCE),freebsd) +UNIXINSTALLDIR=1 +endif +endif + +# set the prefix directory where to install everything +ifndef PREFIXINSTALLDIR +ifdef UNIXINSTALLDIR +PREFIXINSTALLDIR=/usr +else +PREFIXINSTALLDIR=/pp +endif +endif +export PREFIXINSTALLDIR + +# Where to place the resulting zip files +ifndef DESTZIPDIR +DESTZIPDIR:=$(BASEDIR) +endif +export DESTZIPDIR + +##################################################################### +# Install Directories +##################################################################### + +# set the base directory where to install everything +ifndef BASEINSTALLDIR +ifdef UNIXINSTALLDIR +BASEINSTALLDIR=$(PREFIXINSTALLDIR)/lib/fpc/$(FPC_VERSION) +else +BASEINSTALLDIR=$(PREFIXINSTALLDIR) +endif +endif + +# set the directory where to install the binaries +ifndef BININSTALLDIR +ifdef UNIXINSTALLDIR +BININSTALLDIR=$(PREFIXINSTALLDIR)/bin +else +BININSTALLDIR=$(BASEINSTALLDIR)/bin/$(OS_TARGET) +endif +endif + +# set the directory where to install the units. +ifndef UNITINSTALLDIR +UNITINSTALLDIR=$(BASEINSTALLDIR)/units/$(OS_TARGET) +ifdef UNITSUBDIR +UNITINSTALLDIR:=$(UNITINSTALLDIR)/$(UNITSUBDIR) +endif +endif + +# Where to install shared libraries +ifndef LIBINSTALLDIR +ifdef UNIXINSTALLDIR +LIBINSTALLDIR=$(PREFIXINSTALLDIR)/lib +else +LIBINSTALLDIR=$(UNITINSTALLDIR) +endif +endif + +# Where the source files will be stored +ifndef SOURCEINSTALLDIR +ifdef UNIXINSTALLDIR +SOURCEINSTALLDIR=$(PREFIXINSTALLDIR)/src/fpc-$(FPC_VERSION) +else +SOURCEINSTALLDIR=$(BASEINSTALLDIR)/source +endif +ifdef SOURCESUBDIR +SOURCEINSTALLDIR:=$(SOURCEINSTALLDIR)/$(SOURCESUBDIR) +endif +endif + +# Where the doc files will be stored +ifndef DOCINSTALLDIR +ifdef UNIXINSTALLDIR +DOCINSTALLDIR=$(PREFIXINSTALLDIR)/doc/fpc-$(FPC_VERSION) +else +DOCINSTALLDIR=$(BASEINSTALLDIR)/doc +endif +endif + +# Where to install the examples, under linux we use the doc dir +# because the copytree command will create a subdir itself +ifndef EXAMPLEINSTALLDIR +ifdef UNIXINSTALLDIR +EXAMPLEINSTALLDIR=$(DOCINSTALLDIR)/examples +else +EXAMPLEINSTALLDIR=$(BASEINSTALLDIR)/examples +endif +ifdef EXAMPLESUBDIR +EXAMPLEINSTALLDIR:=$(EXAMPLEINSTALLDIR)/$(EXAMPLESUBDIR) +endif +endif + +# Where the some extra (data)files will be stored +ifndef DATAINSTALLDIR +DATAINSTALLDIR=$(BASEINSTALLDIR) +endif + +##################################################################### +# Redirection +##################################################################### + +ifndef REDIRFILE +REDIRFILE=log +endif + +ifdef REDIR +ifndef inUnix +override FPC=redir -eo $(FPC) +endif +# set the verbosity to max +override FPCOPT+=-va +override REDIR:= >> $(REDIRFILE) +endif + + +##################################################################### +# Compiler Command Line +##################################################################### + +# Load commandline OPTDEF and add FPC_CPU define +override FPCOPTDEF:=-d$(CPU_TARGET) + +# Load commandline OPT and add target and unit dir to be sure +ifneq ($(OS_TARGET),$(OS_SOURCE)) +override FPCOPT+=-T$(OS_TARGET) +endif + +# User dirs should be first, so they are looked at first +ifdef UNITDIR +override FPCOPT+=$(addprefix -Fu,$(UNITDIR)) +endif +ifdef LIBDIR +override FPCOPT+=$(addprefix -Fl,$(LIBDIR)) +endif +ifdef OBJDIR +override FPCOPT+=$(addprefix -Fo,$(OBJDIR)) +endif +ifdef INCDIR +override FPCOPT+=$(addprefix -Fi,$(INCDIR)) +endif + +# Smartlinking +ifdef LINKSMART +override FPCOPT+=-XX +endif + +# Smartlinking creation +ifdef CREATESMART +override FPCOPT+=-CX +endif + +# Debug +ifdef DEBUG +override FPCOPT+=-gl -dDEBUG +endif + +# Release mode (strip, optimize and don't load ppc386.cfg) +# 0.99.12b has a bug in the optimizer so don't use it by default +ifdef RELEASE +ifeq ($(FPC_VERSION),0.99.12) +override FPCOPT+=-Xs -OGp3 -n +else +override FPCOPT+=-Xs -OG2p3 -n +endif +endif + +# Strip +ifdef STRIP +override FPCOPT+=-Xs +endif + +# Optimizer +ifdef OPTIMIZE +override FPCOPT+=-OG2p3 +endif + +# Verbose settings (warning,note,info) +ifdef VERBOSE +override FPCOPT+=-vwni +endif + +ifdef NEEDOPT +override FPCOPT+=$(NEEDOPT) +endif + +ifdef NEEDUNITDIR +override FPCOPT+=$(addprefix -Fu,$(NEEDUNITDIR)) +endif + +ifdef UNITSDIR +override FPCOPT+=-Fu$(UNITSDIR) +endif + +# Target dirs and the prefix to use for clean/install +ifdef TARGETDIR +override FPCOPT+=-FE$(TARGETDIR) +ifeq ($(TARGETDIR),.) +override TARGETDIRPREFIX= +else +override TARGETDIRPREFIX=$(TARGETDIR)/ +endif +endif +ifdef UNITTARGETDIR +override FPCOPT+=-FU$(UNITTARGETDIR) +ifeq ($(UNITTARGETDIR),.) +override UNITTARGETDIRPREFIX= +else +override UNITTARGETDIRPREFIX=$(TARGETDIR)/ +endif +else +ifdef TARGETDIR +override UNITTARGETDIR=$(TARGETDIR) +override UNITTARGETDIRPREFIX=$(TARGETDIRPREFIX) +endif +endif + +# Add commandline options last so they can override +ifdef OPT +override FPCOPT+=$(OPT) +endif + +# Add defines from FPCOPTDEF to FPCOPT +ifdef FPCOPTDEF +override FPCOPT+=$(FPCOPTDEF) +endif + +# Error file ? +ifdef ERRORFILE +override FPCOPT+=-Fr$(ERRORFILE) +endif + +# Was a config file specified ? +ifdef CFGFILE +override FPCOPT+=@$(CFGFILE) +endif + +# For win32 the options are passed using the environment FPCEXTCMD +ifeq ($(OS_SOURCE),win32) +override FPCEXTCMD:=$(FPCOPT) +override FPCOPT:=!FPCEXTCMD +export FPCEXTCMD +endif + +# Compiler commandline +override COMPILER:=$(FPC) $(FPCOPT) + +# also call ppas if with command option -s +# but only if the OS_SOURCE and OS_TARGE are equal +ifeq (,$(findstring -s ,$(COMPILER))) +EXECPPAS= +else +ifeq ($(OS_SOURCE),$(OS_TARGET)) +EXECPPAS:=@$(PPAS) +endif +endif + +##################################################################### +# Standard rules +##################################################################### + +all: fpc_all + +debug: fpc_debug + +smart: fpc_smart + +shared: fpc_shared + +showinstall: fpc_showinstall + +install: fpc_install + +sourceinstall: fpc_sourceinstall + +exampleinstall: fpc_exampleinstall + +zipinstall: fpc_zipinstall + +zipsourceinstall: fpc_zipsourceinstall + +zipexampleinstall: fpc_zipexampleinstall + +clean: fpc_clean + +distclean: fpc_distclean + +cleanall: fpc_cleanall + +info: fpc_info + +.PHONY: all debug smart shared showinstall install sourceinstall exampleinstall zipinstall zipsourceinstall zipexampleinstall clean distclean cleanall info + +##################################################################### +# Exes +##################################################################### + +.PHONY: fpc_exes + +ifdef EXEOBJECTS +override EXEFILES=$(addsuffix $(EXEEXT),$(EXEOBJECTS)) +override EXEOFILES:=$(addsuffix $(OEXT),$(EXEOBJECTS)) $(addprefix $(LIBPREFIX),$(addsuffix $(STATICLIBEXT),$(EXEOBJECTS))) + +override ALLTARGET+=fpc_exes +override INSTALLEXEFILES+=$(EXEFILES) +override CLEANEXEFILES+=$(EXEFILES) $(EXEOFILES) + +endif + +fpc_exes: $(EXEFILES) + +##################################################################### +# General compile rules +##################################################################### + +.PHONY: fpc_packages fpc_all fpc_debug + +$(FPCMADE): $(ALLTARGET) + @$(ECHO) Compiled > $(FPCMADE) + +fpc_packages: $(COMPILEPACKAGES) + +fpc_all: fpc_packages $(FPCMADE) + +fpc_debug: + $(MAKE) all DEBUG=1 + +# Search paths for .ppu if targetdir is set +ifdef UNITTARGETDIR +vpath %$(PPUEXT) $(UNITTARGETDIR) +endif + +# General compile rules, available for both possible PASEXT + +.SUFFIXES: $(EXEEXT) $(PPUEXT) $(OEXT) .pas .pp + +%$(PPUEXT): %.pp + $(COMPILER) $< $(REDIR) + $(EXECPPAS) + +%$(PPUEXT): %.pas + $(COMPILER) $< $(REDIR) + $(EXECPPAS) + +%$(EXEEXT): %.pp + $(COMPILER) $< $(REDIR) + $(EXECPPAS) + +%$(EXEEXT): %.pas + $(COMPILER) $< $(REDIR) + $(EXECPPAS) + +##################################################################### +# Library +##################################################################### + +.PHONY: fpc_smart fpc_shared + +ifdef LIBVERSION +LIBFULLNAME=$(LIBNAME).$(LIBVERSION) +else +LIBFULLNAME=$(LIBNAME) +endif + +# Default sharedlib units are all unit objects +ifndef SHAREDLIBUNITOBJECTS +SHAREDLIBUNITOBJECTS:=$(UNITOBJECTS) +endif + +fpc_smart: + $(MAKE) all LINKSMART=1 CREATESMART=1 + +fpc_shared: all +ifdef HASSHAREDLIB +ifndef LIBNAME + @$(ECHO) "LIBNAME not set" +else + $(PPUMOVE) $(SHAREDLIBUNITOBJECTS) -o$(LIBFULLNAME) +endif +else + @$(ECHO) "Shared Libraries not supported" +endif + +##################################################################### +# Install rules +##################################################################### + +.PHONY: fpc_showinstall fpc_install + +ifdef EXTRAINSTALLUNITS +override INSTALLPPUFILES+=$(addsuffix $(PPUEXT),$(EXTRAINSTALLUNITS)) +endif + +ifdef INSTALLPPUFILES +override INSTALLPPUFILES:=$(addprefix $(UNITTARGETDIRPREFIX),$(INSTALLPPUFILES)) +ifdef PPUFILES +INSTALLPPULINKFILES:=$(shell $(PPUFILES) -S -O $(INSTALLPPUFILES)) +else +INSTALLPPULINKFILES:=$(wildcard $(subst $(PPUEXT),$(OEXT),$(INSTALLPPUFILES)) $(addprefix $(LIBPREFIX),$(subst $(PPUEXT),$(STATICLIBEXT),$(INSTALLPPUFILES)))) +endif +override INSTALLPPULINKFILES:=$(addprefix $(UNITTARGETDIRPREFIX),$(INSTALLPPULINKFILES)) +endif + +ifdef INSTALLEXEFILES +override INSTALLEXEFILES:=$(addprefix $(TARGETDIRPREFIX),$(INSTALLEXEFILES)) +endif + +fpc_showinstall: $(SHOWINSTALLTARGET) +ifdef INSTALLEXEFILES + @$(ECHO) -e $(addprefix "\n"$(BININSTALLDIR)/,$(INSTALLEXEFILES)) +endif +ifdef INSTALLPPUFILES + @$(ECHO) -e $(addprefix "\n"$(UNITINSTALLDIR)/,$(INSTALLPPUFILES)) +ifneq ($(INSTALLPPULINKFILES),) + @$(ECHO) -e $(addprefix "\n"$(UNITINSTALLDIR)/,$(INSTALLPPULINKFILES)) +endif +ifneq ($(wildcard $(LIBFULLNAME)),) + @$(ECHO) $(LIBINSTALLDIR)/$(LIBFULLNAME) +ifdef HASSHAREDLIB + @$(ECHO) $(LIBINSTALLDIR)/$(LIBNAME) +endif +endif +endif +ifdef EXTRAINSTALLFILES + @$(ECHO) -e $(addprefix "\n"$(DATAINSTALLDIR)/,$(EXTRAINSTALLFILES)) +endif + +fpc_install: $(INSTALLTARGET) +# Create UnitInstallFiles +ifdef INSTALLEXEFILES + $(MKDIR) $(BININSTALLDIR) +# Compress the exes if upx is defined +ifdef UPXPROG + -$(UPXPROG) $(INSTALLEXEFILES) +endif + $(INSTALLEXE) $(INSTALLEXEFILES) $(BININSTALLDIR) +endif +ifdef INSTALLPPUFILES + $(MKDIR) $(UNITINSTALLDIR) + $(INSTALL) $(INSTALLPPUFILES) $(UNITINSTALLDIR) +ifneq ($(INSTALLPPULINKFILES),) + $(INSTALL) $(INSTALLPPULINKFILES) $(UNITINSTALLDIR) +endif +ifneq ($(wildcard $(LIBFULLNAME)),) + $(MKDIR) $(LIBINSTALLDIR) + $(INSTALL) $(LIBFULLNAME) $(LIBINSTALLDIR) +ifdef inUnix + ln -sf $(LIBFULLNAME) $(LIBINSTALLDIR)/$(LIBNAME) +endif +endif +endif +ifdef EXTRAINSTALLFILES + $(MKDIR) $(DATAINSTALLDIR) + $(INSTALL) $(EXTRAINSTALLFILES) $(DATAINSTALLDIR) +endif + +##################################################################### +# SourceInstall rules +##################################################################### + +.PHONY: fpc_sourceinstall + +ifndef SOURCETOPDIR +SOURCETOPDIR=$(BASEDIR) +endif + +fpc_sourceinstall: clean + $(MKDIR) $(SOURCEINSTALLDIR) + $(COPYTREE) $(SOURCETOPDIR) $(SOURCEINSTALLDIR) + +##################################################################### +# exampleinstall rules +##################################################################### + +.PHONY: fpc_exampleinstall + +fpc_exampleinstall: $(addsuffix _clean,$(EXAMPLEDIROBJECTS)) +ifdef EXAMPLESOURCEFILES + $(MKDIR) $(EXAMPLEINSTALLDIR) + $(COPY) $(EXAMPLESOURCEFILES) $(EXAMPLEINSTALLDIR) +endif +ifdef EXAMPLEDIROBJECTS +ifndef EXAMPLESOURCEFILES + $(MKDIR) $(EXAMPLEINSTALLDIR) +endif + $(COPYTREE) $(addsuffix /*,$(EXAMPLEDIROBJECTS)) $(EXAMPLEINSTALLDIR) +endif + +##################################################################### +# Zip +##################################################################### + +.PHONY: fpc_zipinstall + +# Create suffix to add +ifndef PACKAGESUFFIX +PACKAGESUFFIX=$(OS_TARGET) +ifeq ($(OS_TARGET),go32v2) +PACKAGESUFFIX=go32 +endif +ifeq ($(OS_TARGET),win32) +PACKAGESUFFIX=w32 +endif +endif + +# Temporary path to pack a file +ifndef PACKDIR +ifndef inUnix +PACKDIR=$(BASEDIR)/pack_tmp +else +PACKDIR=/tmp/fpc-pack +endif +endif + +# Maybe create default zipname from packagename +ifndef ZIPNAME +ifdef PACKAGENAME +ZIPNAME=$(PACKAGEPREFIX)$(PACKAGENAME)$(PACKAGESUFFIX) +endif +endif + +# Use tar by default under linux +ifndef USEZIP +ifdef inUnix +USETAR=1 +endif +endif + +fpc_zipinstall: +ifndef ZIPNAME + @$(ECHO) "Please specify ZIPNAME!" + @exit 1 +else + $(MAKE) $(ZIPTARGET) PREFIXINSTALLDIR=$(PACKDIR) +ifdef USETAR + $(DEL) $(DESTZIPDIR)/$(ZIPNAME)$(TAREXT) + cd $(PACKDIR) ; $(TARPROG) cf$(TAROPT) $(DESTZIPDIR)/$(ZIPNAME)$(TAREXT) * ; cd $(BASEDIR) +else + $(DEL) $(DESTZIPDIR)/$(ZIPNAME)$(ZIPEXT) + cd $(PACKDIR) ; $(ZIPPROG) -Dr $(ZIPOPT) $(DESTZIPDIR)/$(ZIPNAME)$(ZIPEXT) * ; cd $(BASEDIR) +endif + $(DELTREE) $(PACKDIR) +endif + +.PHONY: fpc_zipsourceinstall + +fpc_zipsourceinstall: + $(MAKE) fpc_zipinstall ZIPTARGET=sourceinstall PACKAGESUFFIX=src + +.PHONY: fpc_zipexampleinstall + +fpc_zipexampleinstall: + $(MAKE) fpc_zipinstall ZIPTARGET=exampleinstall PACKAGESUFFIX=exm + +##################################################################### +# Clean rules +##################################################################### + +.PHONY: fpc_clean fpc_cleanall fpc_distclean + +ifdef EXEFILES +override CLEANEXEFILES:=$(addprefix $(TARGETDIRPREFIX),$(CLEANEXEFILES)) +endif + +ifdef EXTRACLEANUNITS +override CLEANPPUFILES+=$(addsuffix $(PPUEXT),$(EXTRACLEANUNITS)) +endif + +ifdef CLEANPPUFILES +override CLEANPPUFILES:=$(addprefix $(UNITTARGETDIRPREFIX),$(CLEANPPUFILES)) +# Get the .o and .a files created for the units +ifdef PPUFILES +CLEANPPULINKFILES:=$(shell $(PPUFILES) $(CLEANPPUFILES)) +else +CLEANPPULINKFILES:=$(wildcard $(subst $(PPUEXT),$(OEXT),$(CLEANPPUFILES)) $(addprefix $(LIBPREFIX),$(subst $(PPUEXT),$(STATICLIBEXT),$(CLEANPPUFILES)))) +endif +override CLEANPPULINKFILES:=$(addprefix $(UNITTARGETDIRPREFIX),$(CLEANPPULINKFILES)) +endif + +fpc_clean: $(CLEANTARGET) +ifdef CLEANEXEFILES + -$(DEL) $(CLEANEXEFILES) +endif +ifdef CLEANPPUFILES + -$(DEL) $(CLEANPPUFILES) +endif +ifneq ($(CLEANPPULINKFILES),) + -$(DEL) $(CLEANPPULINKFILES) +endif +ifdef CLEANRSTFILES + -$(DEL) $(addprefix $(UNITTARGETDIRPREFIX),$(CLEANRSTFILES)) +endif +ifdef EXTRACLEANFILES + -$(DEL) $(EXTRACLEANFILES) +endif +ifdef LIBNAME + -$(DEL) $(LIBNAME) $(LIBFULLNAME) +endif + -$(DEL) $(FPCMADE) $(PPAS) link.res $(FPCEXTFILE) $(REDIRFILE) + +fpc_distclean: fpc_clean + +# Also run clean first if targetdir is set. Unittargetdir is always +# set if targetdir or unittargetdir is specified +ifdef UNITTARGETDIR +TARGETDIRCLEAN=fpc_clean +endif + +fpc_cleanall: $(CLEANTARGET) $(TARGETDIRCLEAN) +ifdef CLEANEXEFILES + -$(DEL) $(CLEANEXEFILES) +endif + -$(DEL) *$(OEXT) *$(PPUEXT) *$(RSTEXT) *$(ASMEXT) *$(STATICLIBEXT) *$(SHAREDLIBEXT) *$(PPLEXT) + -$(DELTREE) *$(SMARTEXT) + -$(DEL) $(FPCMADE) $(PPAS) link.res $(FPCEXTFILE) $(REDIRFILE) + +##################################################################### +# Info rules +##################################################################### + +.PHONY: fpc_info fpc_cfginfo fpc_objectinfo fpc_toolsinfo fpc_installinfo \ + fpc_dirinfo + +fpc_info: $(INFOTARGET) + +fpc_infocfg: + @$(ECHO) + @$(ECHO) == Configuration info == + @$(ECHO) + @$(ECHO) FPC....... $(FPC) + @$(ECHO) Version... $(FPC_VERSION) + @$(ECHO) CPU....... $(CPU_TARGET) + @$(ECHO) Source.... $(OS_SOURCE) + @$(ECHO) Target.... $(OS_TARGET) + @$(ECHO) + +fpc_infoobjects: + @$(ECHO) + @$(ECHO) == Object info == + @$(ECHO) + @$(ECHO) LoaderObjects..... $(LOADEROBJECTS) + @$(ECHO) UnitObjects....... $(UNITOBJECTS) + @$(ECHO) ExeObjects........ $(EXEOBJECTS) + @$(ECHO) + @$(ECHO) ExtraCleanUnits... $(EXTRACLEANUNITS) + @$(ECHO) ExtraCleanFiles... $(EXTRACLEANFILES) + @$(ECHO) + @$(ECHO) ExtraInstallUnits. $(EXTRAINSTALLUNITS) + @$(ECHO) ExtraInstallFiles. $(EXTRAINSTALLFILES) + @$(ECHO) + +fpc_infoinstall: + @$(ECHO) + @$(ECHO) == Install info == + @$(ECHO) +ifdef DATE + @$(ECHO) DateStr.............. $(DATESTR) +endif +ifdef PACKAGEPREFIX + @$(ECHO) PackagePrefix........ $(PACKAGEPREFIX) +endif +ifdef PACKAGENAME + @$(ECHO) PackageName.......... $(PACKAGENAME) +endif + @$(ECHO) PackageSuffix........ $(PACKAGESUFFIX) + @$(ECHO) + @$(ECHO) BaseInstallDir....... $(BASEINSTALLDIR) + @$(ECHO) BinInstallDir........ $(BININSTALLDIR) + @$(ECHO) LibInstallDir........ $(LIBINSTALLDIR) + @$(ECHO) UnitInstallDir....... $(UNITINSTALLDIR) + @$(ECHO) SourceInstallDir..... $(SOURCEINSTALLDIR) + @$(ECHO) DocInstallDir........ $(DOCINSTALLDIR) + @$(ECHO) DataInstallDir....... $(DATAINSTALLDIR) + @$(ECHO) + @$(ECHO) DestZipDir........... $(DESTZIPDIR) + @$(ECHO) ZipName.............. $(ZIPNAME) + @$(ECHO) + +##################################################################### +# Local Makefile +##################################################################### + +ifneq ($(wildcard fpcmake.loc),) +include fpcmake.loc +endif + diff --git a/examples/gui/helloworld/Makefile.fpc b/examples/gui/helloworld/Makefile.fpc new file mode 100644 index 00000000..03d81490 --- /dev/null +++ b/examples/gui/helloworld/Makefile.fpc @@ -0,0 +1,10 @@ +# +# Makefile.fpc for fpGUI HelloWorld example +# + +[targets] +programs=helloworld + +[require] +options=-S2h +packages=fcl fpgfx fpgui diff --git a/examples/gui/helloworld/helloworld.lpi b/examples/gui/helloworld/helloworld.lpi new file mode 100644 index 00000000..f9e413e9 --- /dev/null +++ b/examples/gui/helloworld/helloworld.lpi @@ -0,0 +1,57 @@ +<?xml version="1.0"?> +<CONFIG> + <ProjectOptions> + <PathDelim Value="/"/> + <Version Value="5"/> + <General> + <Flags> + <SaveOnlyProjectUnits Value="True"/> + </Flags> + <SessionStorage Value="InProjectDir"/> + <MainUnit Value="0"/> + <IconPath Value="./"/> + <TargetFileExt Value=""/> + </General> + <PublishOptions> + <Version Value="2"/> + <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_laz"/> + </Item1> + </RequiredPackages> + <Units Count="1"> + <Unit0> + <Filename Value="helloworld.pas"/> + <IsPartOfProject Value="True"/> + <UnitName Value="HelloWorld"/> + </Unit0> + </Units> + </ProjectOptions> + <CompilerOptions> + <Version Value="5"/> + <SearchPaths> + <OtherUnitFiles Value="../../src/"/> + </SearchPaths> + <Parsing> + <SyntaxOptions> + <AllowLabel Value="False"/> + </SyntaxOptions> + </Parsing> + <CodeGeneration> + <Generate Value="Faster"/> + </CodeGeneration> + <Other> + <CompilerPath Value="$(CompPath)"/> + </Other> + </CompilerOptions> +</CONFIG> diff --git a/examples/gui/helloworld/helloworld.pas b/examples/gui/helloworld/helloworld.pas new file mode 100644 index 00000000..8151291a --- /dev/null +++ b/examples/gui/helloworld/helloworld.pas @@ -0,0 +1,22 @@ +program HelloWorld; + +{$mode objfpc}{$h+} + +uses + fpGUI, fpGUI_laz; + +type + TMainForm = class(TForm) + TextLabel: TLabel; + lblClose: TLabel; + end; + +var + MainForm: TMainForm; + +begin + Application.CreateForm(TMainForm, MainForm); + + Application.Run; + MainForm.Free; +end. diff --git a/examples/gui/helloworld/mainform.frm b/examples/gui/helloworld/mainform.frm new file mode 100644 index 00000000..f7bc0544 --- /dev/null +++ b/examples/gui/helloworld/mainform.frm @@ -0,0 +1,11 @@ +object MainWindow: TMainWindow
+ BorderWidth = 8
+ WindowOptions = [woWindow]
+ object TextLabel: TLabel
+ Text = 'Hello, world!'
+ end
+ object lblClose: TLabel
+ Text = '&Close'
+ end
+end
+
diff --git a/examples/gui/interbasetest/Makefile b/examples/gui/interbasetest/Makefile new file mode 100644 index 00000000..94d80579 --- /dev/null +++ b/examples/gui/interbasetest/Makefile @@ -0,0 +1,1320 @@ +# +# Makefile generated by fpcmake v1.00 [2000/12/14] +# + +defaultrule: all + +##################################################################### +# Autodetect OS (Linux or Dos or Windows NT) +# define inUnix when running under Unix (Linux,FreeBSD) +# define inWinNT when running under WinNT +##################################################################### + +# We need only / in the path +override PATH:=$(subst \,/,$(PATH)) + +# Search for PWD and determine also if we are under linux +PWD:=$(strip $(wildcard $(addsuffix /pwd.exe,$(subst ;, ,$(PATH))))) +ifeq ($(PWD),) +PWD:=$(strip $(wildcard $(addsuffix /pwd,$(subst :, ,$(PATH))))) +ifeq ($(PWD),) +nopwd: + @echo You need the GNU utils package to use this Makefile! + @echo Get ftp://ftp.freepascal.org/pub/fpc/dist/go32v2/utilgo32.zip + @exit +else +inUnix=1 +endif +else +PWD:=$(firstword $(PWD)) +endif + +# Detect NT - NT sets OS to Windows_NT +# Detect OS/2 - OS/2 has OS2_SHELL defined +ifndef inUnix +ifeq ($(OS),Windows_NT) +inWinNT=1 +else +ifdef OS2_SHELL +inOS2=1 +endif +endif +endif + +# The extension of executables +ifdef inUnix +SRCEXEEXT= +else +SRCEXEEXT=.exe +endif + +# The path which is searched separated by spaces +ifdef inUnix +SEARCHPATH=$(subst :, ,$(PATH)) +else +SEARCHPATH=$(subst ;, ,$(PATH)) +endif + +# Base dir +ifdef PWD +BASEDIR:=$(shell $(PWD)) +else +BASEDIR=. +endif + +##################################################################### +# FPC version/target Detection +##################################################################### + +# What compiler to use ? +ifndef FPC +# Compatibility with old makefiles +ifdef PP +FPC=$(PP) +else +FPC=ppc386 +endif +endif +override FPC:=$(subst $(SRCEXEEXT),,$(FPC)) +override FPC:=$(subst \,/,$(FPC))$(SRCEXEEXT) + +# Target OS +ifndef OS_TARGET +OS_TARGET:=$(shell $(FPC) -iTO) +endif + +# Source OS +ifndef OS_SOURCE +OS_SOURCE:=$(shell $(FPC) -iSO) +endif + +# Target CPU +ifndef CPU_TARGET +CPU_TARGET:=$(shell $(FPC) -iTP) +endif + +# Source CPU +ifndef CPU_SOURCE +CPU_SOURCE:=$(shell $(FPC) -iSP) +endif + +# FPC version +ifndef FPC_VERSION +FPC_VERSION:=$(shell $(FPC) -iV) +endif + +export FPC OS_TARGET OS_SOURCE CPU_TARGET CPU_SOURCE FPC_VERSION FPCOPT + +##################################################################### +# FPCDIR Setting +##################################################################### + +# Test FPCDIR to look if the RTL dir exists +ifdef FPCDIR +override FPCDIR:=$(subst \,/,$(FPCDIR)) +ifeq ($(wildcard $(FPCDIR)/rtl),) +ifeq ($(wildcard $(FPCDIR)/units),) +override FPCDIR=wrong +endif +endif +else +override FPCDIR=wrong +endif + +# Detect FPCDIR +ifeq ($(FPCDIR),wrong) +ifdef inUnix +override FPCDIR=/usr/local/lib/fpc/$(FPC_VERSION) +ifeq ($(wildcard $(FPCDIR)/units),) +override FPCDIR=/usr/lib/fpc/$(FPC_VERSION) +endif +else +override FPCDIR:=$(subst /$(FPC),,$(firstword $(strip $(wildcard $(addsuffix /$(FPC),$(SEARCHPATH)))))) +override FPCDIR:=$(FPCDIR)/.. +ifeq ($(wildcard $(FPCDIR)/rtl),) +ifeq ($(wildcard $(FPCDIR)/units),) +override FPCDIR:=$(FPCDIR)/.. +ifeq ($(wildcard $(FPCDIR)/rtl),) +ifeq ($(wildcard $(FPCDIR)/units),) +override FPCDIR=c:/pp +endif +endif +endif +endif +endif +endif + +ifndef PACKAGESDIR +PACKAGESDIR=$(FPCDIR)/packages +endif +ifndef TOOLKITSDIR +TOOLKITSDIR= +endif +ifndef COMPONENTSDIR +COMPONENTSDIR= +endif + +# Create units dir +ifneq ($(FPCDIR),.) +UNITSDIR=$(FPCDIR)/units/$(OS_TARGET) +endif + +##################################################################### +# User Settings +##################################################################### + + +# Targets + +override EXEOBJECTS+=interbasetest + +# Clean + + +# Install + +ZIPTARGET=install + +# Defaults + +override NEEDOPT=-S2h + +# Directories + + +# Packages + +override PACKAGES+=rtl fcl fpgfx fpgui + +# Libraries + + +# Info + +INFOTARGET=fpc_infocfg fpc_infoobjects fpc_infoinstall + +##################################################################### +# Shell tools +##################################################################### + +# echo +ifndef ECHO +ECHO:=$(strip $(wildcard $(addsuffix /gecho$(EXEEXT),$(SEARCHPATH)))) +ifeq ($(ECHO),) +ECHO:=$(strip $(wildcard $(addsuffix /echo$(SRCEXEEXT),$(SEARCHPATH)))) +ifeq ($(ECHO),) +ECHO:=echo +ECHOE:=echo +else +ECHO:=$(firstword $(ECHO)) +ECHOE=$(ECHO) -E +endif +else +ECHO:=$(firstword $(ECHO)) +ECHOE=$(ECHO) -E +endif +endif + +# To copy pograms +ifndef COPY +COPY:=cp -fp +endif + +# Copy a whole tree +ifndef COPYTREE +COPYTREE:=cp -rfp +endif + +# To move pograms +ifndef MOVE +MOVE:=mv -f +endif + +# Check delete program +ifndef DEL +DEL:=rm -f +endif + +# Check deltree program +ifndef DELTREE +DELTREE:=rm -rf +endif + +# To install files +ifndef INSTALL +ifdef inUnix +INSTALL:=install -c -m 644 +else +INSTALL:=$(COPY) +endif +endif + +# To install programs +ifndef INSTALLEXE +ifdef inUnix +INSTALLEXE:=install -c -m 755 +else +INSTALLEXE:=$(COPY) +endif +endif + +# To make a directory. +ifndef MKDIR +ifdef inUnix +MKDIR:=install -m 755 -d +else +MKDIR:=ginstall -m 755 -d +endif +endif + +export ECHO ECHOE COPY COPYTREE MOVE DEL DELTREE INSTALL INSTALLEXE MKDIR + +##################################################################### +# Default Tools +##################################################################### + +# assembler, redefine it if cross compiling +ifndef AS +AS=as +endif + +# linker, but probably not used +ifndef LD +LD=ld +endif + +# ppas.bat / ppas.sh +ifdef inUnix +PPAS=ppas.sh +else +ifdef inOS2 +PPAS=ppas.cmd +else +PPAS=ppas.bat +endif +endif + +# ldconfig to rebuild .so cache +ifdef inUnix +LDCONFIG=ldconfig +else +LDCONFIG= +endif + +# ppumove +ifndef PPUMOVE +PPUMOVE:=$(strip $(wildcard $(addsuffix /ppumove$(SRCEXEEXT),$(SEARCHPATH)))) +ifeq ($(PPUMOVE),) +PPUMOVE= +else +PPUMOVE:=$(firstword $(PPUMOVE)) +endif +endif +export PPUMOVE + +# ppufiles +ifndef PPUFILES +PPUFILES:=$(strip $(wildcard $(addsuffix /ppufiles$(SRCEXEEXT),$(SEARCHPATH)))) +ifeq ($(PPUFILES),) +PPUFILES= +else +PPUFILES:=$(firstword $(PPUFILES)) +endif +endif +export PPUFILES + +# Look if UPX is found for go32v2 and win32. We can't use $UPX becuase +# upx uses that one itself (PFV) +ifndef UPXPROG +ifeq ($(OS_TARGET),go32v2) +UPXPROG:=1 +endif +ifeq ($(OS_TARGET),win32) +UPXPROG:=1 +endif +ifdef UPXPROG +UPXPROG:=$(strip $(wildcard $(addsuffix /upx$(SRCEXEEXT),$(SEARCHPATH)))) +ifeq ($(UPXPROG),) +UPXPROG= +else +UPXPROG:=$(firstword $(UPXPROG)) +endif +else +UPXPROG= +endif +endif +export UPXPROG + +# ZipProg, you can't use Zip as the var name (PFV) +ifndef ZIPPROG +ZIPPROG:=$(strip $(wildcard $(addsuffix /zip$(SRCEXEEXT),$(SEARCHPATH)))) +ifeq ($(ZIPPROG),) +ZIPPROG= +else +ZIPPROG:=$(firstword $(ZIPPROG)) +endif +endif +export ZIPPROG + +ZIPOPT=-9 +ZIPEXT=.zip + +# Tar +ifndef TARPROG +TARPROG:=$(strip $(wildcard $(addsuffix /tar$(SRCEXEEXT),$(SEARCHPATH)))) +ifeq ($(TARPROG),) +TARPROG= +else +TARPROG:=$(firstword $(TARPROG)) +endif +endif +export TARPROG + +ifeq ($(USETAR),bz2) +TAROPT=vI +TAREXT=.tar.bz2 +else +TAROPT=vz +TAREXT=.tar.gz +endif + +##################################################################### +# Default extensions +##################################################################### + +# Default needed extensions (Go32v2,Linux) +LOADEREXT=.as +EXEEXT=.exe +PPLEXT=.ppl +PPUEXT=.ppu +OEXT=.o +ASMEXT=.s +SMARTEXT=.sl +STATICLIBEXT=.a +SHAREDLIBEXT=.so +RSTEXT=.rst +FPCMADE=fpcmade + +# Go32v1 +ifeq ($(OS_TARGET),go32v1) +PPUEXT=.pp1 +OEXT=.o1 +ASMEXT=.s1 +SMARTEXT=.sl1 +STATICLIBEXT=.a1 +SHAREDLIBEXT=.so1 +FPCMADE=fpcmade.v1 +endif + +# Go32v2 +ifeq ($(OS_TARGET),go32v2) +FPCMADE=fpcmade.dos +endif + +# Linux +ifeq ($(OS_TARGET),linux) +EXEEXT= +HASSHAREDLIB=1 +FPCMADE=fpcmade.lnx +endif + +# Linux +ifeq ($(OS_TARGET),freebsd) +EXEEXT= +HASSHAREDLIB=1 +FPCMADE=fpcmade.freebsd +endif + +# Win32 +ifeq ($(OS_TARGET),win32) +PPUEXT=.ppw +OEXT=.ow +ASMEXT=.sw +SMARTEXT=.slw +STATICLIBEXT=.aw +SHAREDLIBEXT=.dll +FPCMADE=fpcmade.w32 +endif + +# OS/2 +ifeq ($(OS_TARGET),os2) +PPUEXT=.ppo +ASMEXT=.so2 +OEXT=.oo2 +SMARTEXT=.so +STATICLIBEXT=.ao2 +SHAREDLIBEXT=.dll +FPCMADE=fpcmade.os2 +endif + +# library prefix +LIBPREFIX=lib +ifeq ($(OS_TARGET),go32v2) +LIBPREFIX= +endif +ifeq ($(OS_TARGET),go32v1) +LIBPREFIX= +endif + +# determine which .pas extension is used +ifndef PASEXT +ifdef EXEOBJECTS +override TESTPAS:=$(strip $(wildcard $(addsuffix .pas,$(firstword $(EXEOBJECTS))))) +else +override TESTPAS:=$(strip $(wildcard $(addsuffix .pas,$(firstword $(UNITOBJECTS))))) +endif +ifeq ($(TESTPAS),) +PASEXT=.pp +else +PASEXT=.pas +endif +endif + + +# Check if the dirs really exists, else turn it off +ifeq ($(wildcard $(UNITSDIR)),) +UNITSDIR= +endif +ifeq ($(wildcard $(TOOLKITSDIR)),) +TOOLKITSDIR= +endif +ifeq ($(wildcard $(PACKAGESDIR)),) +PACKAGESDIR= +endif +ifeq ($(wildcard $(COMPONENTSDIR)),) +COMPONENTSDIR= +endif + + +# PACKAGESDIR packages + +PACKAGERTL=1 +PACKAGEFCL=1 +PACKAGEFPGFX=1 +PACKAGEFPGUI=1 + +ifdef PACKAGERTL +ifneq ($(wildcard $(FPCDIR)/rtl),) +ifneq ($(wildcard $(FPCDIR)/rtl/$(OS_TARGET)),) +PACKAGEDIR_RTL=$(FPCDIR)/rtl/$(OS_TARGET) +else +PACKAGEDIR_RTL=$(FPCDIR)/rtl +endif +ifeq ($(wildcard $(PACKAGEDIR_RTL)/$(FPCMADE)),) +override COMPILEPACKAGES+=package_rtl +package_rtl: + $(MAKE) -C $(PACKAGEDIR_RTL) all +endif +UNITDIR_RTL=$(PACKAGEDIR_RTL) +else +PACKAGEDIR_RTL= +ifneq ($(wildcard $(UNITSDIR)/rtl),) +ifneq ($(wildcard $(UNITSDIR)/rtl/$(OS_TARGET)),) +UNITDIR_RTL=$(UNITSDIR)/rtl/$(OS_TARGET) +else +UNITDIR_RTL=$(UNITSDIR)/rtl +endif +else +UNITDIR_RTL= +endif +endif +ifdef UNITDIR_RTL +override NEEDUNITDIR+=$(UNITDIR_RTL) +endif +endif +ifdef PACKAGEFCL +ifneq ($(wildcard $(FPCDIR)/fcl),) +ifneq ($(wildcard $(FPCDIR)/fcl/$(OS_TARGET)),) +PACKAGEDIR_FCL=$(FPCDIR)/fcl/$(OS_TARGET) +else +PACKAGEDIR_FCL=$(FPCDIR)/fcl +endif +ifeq ($(wildcard $(PACKAGEDIR_FCL)/$(FPCMADE)),) +override COMPILEPACKAGES+=package_fcl +package_fcl: + $(MAKE) -C $(PACKAGEDIR_FCL) all +endif +UNITDIR_FCL=$(PACKAGEDIR_FCL) +else +PACKAGEDIR_FCL= +ifneq ($(wildcard $(UNITSDIR)/fcl),) +ifneq ($(wildcard $(UNITSDIR)/fcl/$(OS_TARGET)),) +UNITDIR_FCL=$(UNITSDIR)/fcl/$(OS_TARGET) +else +UNITDIR_FCL=$(UNITSDIR)/fcl +endif +else +UNITDIR_FCL= +endif +endif +ifdef UNITDIR_FCL +override NEEDUNITDIR+=$(UNITDIR_FCL) +endif +endif +ifdef PACKAGEFPGFX +ifneq ($(wildcard $(PACKAGESDIR)/fpgfx),) +ifneq ($(wildcard $(PACKAGESDIR)/fpgfx/$(OS_TARGET)),) +PACKAGEDIR_FPGFX=$(PACKAGESDIR)/fpgfx/$(OS_TARGET) +else +PACKAGEDIR_FPGFX=$(PACKAGESDIR)/fpgfx +endif +ifeq ($(wildcard $(PACKAGEDIR_FPGFX)/$(FPCMADE)),) +override COMPILEPACKAGES+=package_fpgfx +package_fpgfx: + $(MAKE) -C $(PACKAGEDIR_FPGFX) all +endif +UNITDIR_FPGFX=$(PACKAGEDIR_FPGFX) +else +PACKAGEDIR_FPGFX= +ifneq ($(wildcard $(UNITSDIR)/fpgfx),) +ifneq ($(wildcard $(UNITSDIR)/fpgfx/$(OS_TARGET)),) +UNITDIR_FPGFX=$(UNITSDIR)/fpgfx/$(OS_TARGET) +else +UNITDIR_FPGFX=$(UNITSDIR)/fpgfx +endif +else +UNITDIR_FPGFX= +endif +endif +ifdef UNITDIR_FPGFX +override NEEDUNITDIR+=$(UNITDIR_FPGFX) +endif +endif +ifdef PACKAGEFPGUI +ifneq ($(wildcard $(PACKAGESDIR)/fpgui),) +ifneq ($(wildcard $(PACKAGESDIR)/fpgui/$(OS_TARGET)),) +PACKAGEDIR_FPGUI=$(PACKAGESDIR)/fpgui/$(OS_TARGET) +else +PACKAGEDIR_FPGUI=$(PACKAGESDIR)/fpgui +endif +ifeq ($(wildcard $(PACKAGEDIR_FPGUI)/$(FPCMADE)),) +override COMPILEPACKAGES+=package_fpgui +package_fpgui: + $(MAKE) -C $(PACKAGEDIR_FPGUI) all +endif +UNITDIR_FPGUI=$(PACKAGEDIR_FPGUI) +else +PACKAGEDIR_FPGUI= +ifneq ($(wildcard $(UNITSDIR)/fpgui),) +ifneq ($(wildcard $(UNITSDIR)/fpgui/$(OS_TARGET)),) +UNITDIR_FPGUI=$(UNITSDIR)/fpgui/$(OS_TARGET) +else +UNITDIR_FPGUI=$(UNITSDIR)/fpgui +endif +else +UNITDIR_FPGUI= +endif +endif +ifdef UNITDIR_FPGUI +override NEEDUNITDIR+=$(UNITDIR_FPGUI) +endif +endif + + +##################################################################### +# Default Directories +##################################################################### + +# Linux and freebsd use unix dirs with /usr/bin, /usr/lib +# When zipping use the target as default, when normal install then +# use the source os as default +ifdef ZIPNAME +# Zipinstall +ifeq ($(OS_TARGET),linux) +UNIXINSTALLDIR=1 +endif +ifeq ($(OS_TARGET),freebsd) +UNIXINSTALLDIR=1 +endif +else +# Normal install +ifeq ($(OS_SOURCE),linux) +UNIXINSTALLDIR=1 +endif +ifeq ($(OS_SOURCE),freebsd) +UNIXINSTALLDIR=1 +endif +endif + +# set the prefix directory where to install everything +ifndef PREFIXINSTALLDIR +ifdef UNIXINSTALLDIR +PREFIXINSTALLDIR=/usr +else +PREFIXINSTALLDIR=/pp +endif +endif +export PREFIXINSTALLDIR + +# Where to place the resulting zip files +ifndef DESTZIPDIR +DESTZIPDIR:=$(BASEDIR) +endif +export DESTZIPDIR + +##################################################################### +# Install Directories +##################################################################### + +# set the base directory where to install everything +ifndef BASEINSTALLDIR +ifdef UNIXINSTALLDIR +BASEINSTALLDIR=$(PREFIXINSTALLDIR)/lib/fpc/$(FPC_VERSION) +else +BASEINSTALLDIR=$(PREFIXINSTALLDIR) +endif +endif + +# set the directory where to install the binaries +ifndef BININSTALLDIR +ifdef UNIXINSTALLDIR +BININSTALLDIR=$(PREFIXINSTALLDIR)/bin +else +BININSTALLDIR=$(BASEINSTALLDIR)/bin/$(OS_TARGET) +endif +endif + +# set the directory where to install the units. +ifndef UNITINSTALLDIR +UNITINSTALLDIR=$(BASEINSTALLDIR)/units/$(OS_TARGET) +ifdef UNITSUBDIR +UNITINSTALLDIR:=$(UNITINSTALLDIR)/$(UNITSUBDIR) +endif +endif + +# Where to install shared libraries +ifndef LIBINSTALLDIR +ifdef UNIXINSTALLDIR +LIBINSTALLDIR=$(PREFIXINSTALLDIR)/lib +else +LIBINSTALLDIR=$(UNITINSTALLDIR) +endif +endif + +# Where the source files will be stored +ifndef SOURCEINSTALLDIR +ifdef UNIXINSTALLDIR +SOURCEINSTALLDIR=$(PREFIXINSTALLDIR)/src/fpc-$(FPC_VERSION) +else +SOURCEINSTALLDIR=$(BASEINSTALLDIR)/source +endif +ifdef SOURCESUBDIR +SOURCEINSTALLDIR:=$(SOURCEINSTALLDIR)/$(SOURCESUBDIR) +endif +endif + +# Where the doc files will be stored +ifndef DOCINSTALLDIR +ifdef UNIXINSTALLDIR +DOCINSTALLDIR=$(PREFIXINSTALLDIR)/doc/fpc-$(FPC_VERSION) +else +DOCINSTALLDIR=$(BASEINSTALLDIR)/doc +endif +endif + +# Where to install the examples, under linux we use the doc dir +# because the copytree command will create a subdir itself +ifndef EXAMPLEINSTALLDIR +ifdef UNIXINSTALLDIR +EXAMPLEINSTALLDIR=$(DOCINSTALLDIR)/examples +else +EXAMPLEINSTALLDIR=$(BASEINSTALLDIR)/examples +endif +ifdef EXAMPLESUBDIR +EXAMPLEINSTALLDIR:=$(EXAMPLEINSTALLDIR)/$(EXAMPLESUBDIR) +endif +endif + +# Where the some extra (data)files will be stored +ifndef DATAINSTALLDIR +DATAINSTALLDIR=$(BASEINSTALLDIR) +endif + +##################################################################### +# Redirection +##################################################################### + +ifndef REDIRFILE +REDIRFILE=log +endif + +ifdef REDIR +ifndef inUnix +override FPC=redir -eo $(FPC) +endif +# set the verbosity to max +override FPCOPT+=-va +override REDIR:= >> $(REDIRFILE) +endif + + +##################################################################### +# Compiler Command Line +##################################################################### + +# Load commandline OPTDEF and add FPC_CPU define +override FPCOPTDEF:=-d$(CPU_TARGET) + +# Load commandline OPT and add target and unit dir to be sure +ifneq ($(OS_TARGET),$(OS_SOURCE)) +override FPCOPT+=-T$(OS_TARGET) +endif + +# User dirs should be first, so they are looked at first +ifdef UNITDIR +override FPCOPT+=$(addprefix -Fu,$(UNITDIR)) +endif +ifdef LIBDIR +override FPCOPT+=$(addprefix -Fl,$(LIBDIR)) +endif +ifdef OBJDIR +override FPCOPT+=$(addprefix -Fo,$(OBJDIR)) +endif +ifdef INCDIR +override FPCOPT+=$(addprefix -Fi,$(INCDIR)) +endif + +# Smartlinking +ifdef LINKSMART +override FPCOPT+=-XX +endif + +# Smartlinking creation +ifdef CREATESMART +override FPCOPT+=-CX +endif + +# Debug +ifdef DEBUG +override FPCOPT+=-gl -dDEBUG +endif + +# Release mode (strip, optimize and don't load ppc386.cfg) +# 0.99.12b has a bug in the optimizer so don't use it by default +ifdef RELEASE +ifeq ($(FPC_VERSION),0.99.12) +override FPCOPT+=-Xs -OGp3 -n +else +override FPCOPT+=-Xs -OG2p3 -n +endif +endif + +# Strip +ifdef STRIP +override FPCOPT+=-Xs +endif + +# Optimizer +ifdef OPTIMIZE +override FPCOPT+=-OG2p3 +endif + +# Verbose settings (warning,note,info) +ifdef VERBOSE +override FPCOPT+=-vwni +endif + +ifdef NEEDOPT +override FPCOPT+=$(NEEDOPT) +endif + +ifdef NEEDUNITDIR +override FPCOPT+=$(addprefix -Fu,$(NEEDUNITDIR)) +endif + +ifdef UNITSDIR +override FPCOPT+=-Fu$(UNITSDIR) +endif + +# Target dirs and the prefix to use for clean/install +ifdef TARGETDIR +override FPCOPT+=-FE$(TARGETDIR) +ifeq ($(TARGETDIR),.) +override TARGETDIRPREFIX= +else +override TARGETDIRPREFIX=$(TARGETDIR)/ +endif +endif +ifdef UNITTARGETDIR +override FPCOPT+=-FU$(UNITTARGETDIR) +ifeq ($(UNITTARGETDIR),.) +override UNITTARGETDIRPREFIX= +else +override UNITTARGETDIRPREFIX=$(TARGETDIR)/ +endif +else +ifdef TARGETDIR +override UNITTARGETDIR=$(TARGETDIR) +override UNITTARGETDIRPREFIX=$(TARGETDIRPREFIX) +endif +endif + +# Add commandline options last so they can override +ifdef OPT +override FPCOPT+=$(OPT) +endif + +# Add defines from FPCOPTDEF to FPCOPT +ifdef FPCOPTDEF +override FPCOPT+=$(FPCOPTDEF) +endif + +# Error file ? +ifdef ERRORFILE +override FPCOPT+=-Fr$(ERRORFILE) +endif + +# Was a config file specified ? +ifdef CFGFILE +override FPCOPT+=@$(CFGFILE) +endif + +# For win32 the options are passed using the environment FPCEXTCMD +ifeq ($(OS_SOURCE),win32) +override FPCEXTCMD:=$(FPCOPT) +override FPCOPT:=!FPCEXTCMD +export FPCEXTCMD +endif + +# Compiler commandline +override COMPILER:=$(FPC) $(FPCOPT) + +# also call ppas if with command option -s +# but only if the OS_SOURCE and OS_TARGE are equal +ifeq (,$(findstring -s ,$(COMPILER))) +EXECPPAS= +else +ifeq ($(OS_SOURCE),$(OS_TARGET)) +EXECPPAS:=@$(PPAS) +endif +endif + +##################################################################### +# Standard rules +##################################################################### + +all: fpc_all + +debug: fpc_debug + +smart: fpc_smart + +shared: fpc_shared + +showinstall: fpc_showinstall + +install: fpc_install + +sourceinstall: fpc_sourceinstall + +exampleinstall: fpc_exampleinstall + +zipinstall: fpc_zipinstall + +zipsourceinstall: fpc_zipsourceinstall + +zipexampleinstall: fpc_zipexampleinstall + +clean: fpc_clean + +distclean: fpc_distclean + +cleanall: fpc_cleanall + +info: fpc_info + +.PHONY: all debug smart shared showinstall install sourceinstall exampleinstall zipinstall zipsourceinstall zipexampleinstall clean distclean cleanall info + +##################################################################### +# Exes +##################################################################### + +.PHONY: fpc_exes + +ifdef EXEOBJECTS +override EXEFILES=$(addsuffix $(EXEEXT),$(EXEOBJECTS)) +override EXEOFILES:=$(addsuffix $(OEXT),$(EXEOBJECTS)) $(addprefix $(LIBPREFIX),$(addsuffix $(STATICLIBEXT),$(EXEOBJECTS))) + +override ALLTARGET+=fpc_exes +override INSTALLEXEFILES+=$(EXEFILES) +override CLEANEXEFILES+=$(EXEFILES) $(EXEOFILES) + +endif + +fpc_exes: $(EXEFILES) + +##################################################################### +# General compile rules +##################################################################### + +.PHONY: fpc_packages fpc_all fpc_debug + +$(FPCMADE): $(ALLTARGET) + @$(ECHO) Compiled > $(FPCMADE) + +fpc_packages: $(COMPILEPACKAGES) + +fpc_all: fpc_packages $(FPCMADE) + +fpc_debug: + $(MAKE) all DEBUG=1 + +# Search paths for .ppu if targetdir is set +ifdef UNITTARGETDIR +vpath %$(PPUEXT) $(UNITTARGETDIR) +endif + +# General compile rules, available for both possible PASEXT + +.SUFFIXES: $(EXEEXT) $(PPUEXT) $(OEXT) .pas .pp + +%$(PPUEXT): %.pp + $(COMPILER) $< $(REDIR) + $(EXECPPAS) + +%$(PPUEXT): %.pas + $(COMPILER) $< $(REDIR) + $(EXECPPAS) + +%$(EXEEXT): %.pp + $(COMPILER) $< $(REDIR) + $(EXECPPAS) + +%$(EXEEXT): %.pas + $(COMPILER) $< $(REDIR) + $(EXECPPAS) + +##################################################################### +# Library +##################################################################### + +.PHONY: fpc_smart fpc_shared + +ifdef LIBVERSION +LIBFULLNAME=$(LIBNAME).$(LIBVERSION) +else +LIBFULLNAME=$(LIBNAME) +endif + +# Default sharedlib units are all unit objects +ifndef SHAREDLIBUNITOBJECTS +SHAREDLIBUNITOBJECTS:=$(UNITOBJECTS) +endif + +fpc_smart: + $(MAKE) all LINKSMART=1 CREATESMART=1 + +fpc_shared: all +ifdef HASSHAREDLIB +ifndef LIBNAME + @$(ECHO) "LIBNAME not set" +else + $(PPUMOVE) $(SHAREDLIBUNITOBJECTS) -o$(LIBFULLNAME) +endif +else + @$(ECHO) "Shared Libraries not supported" +endif + +##################################################################### +# Install rules +##################################################################### + +.PHONY: fpc_showinstall fpc_install + +ifdef EXTRAINSTALLUNITS +override INSTALLPPUFILES+=$(addsuffix $(PPUEXT),$(EXTRAINSTALLUNITS)) +endif + +ifdef INSTALLPPUFILES +override INSTALLPPUFILES:=$(addprefix $(UNITTARGETDIRPREFIX),$(INSTALLPPUFILES)) +ifdef PPUFILES +INSTALLPPULINKFILES:=$(shell $(PPUFILES) -S -O $(INSTALLPPUFILES)) +else +INSTALLPPULINKFILES:=$(wildcard $(subst $(PPUEXT),$(OEXT),$(INSTALLPPUFILES)) $(addprefix $(LIBPREFIX),$(subst $(PPUEXT),$(STATICLIBEXT),$(INSTALLPPUFILES)))) +endif +override INSTALLPPULINKFILES:=$(addprefix $(UNITTARGETDIRPREFIX),$(INSTALLPPULINKFILES)) +endif + +ifdef INSTALLEXEFILES +override INSTALLEXEFILES:=$(addprefix $(TARGETDIRPREFIX),$(INSTALLEXEFILES)) +endif + +fpc_showinstall: $(SHOWINSTALLTARGET) +ifdef INSTALLEXEFILES + @$(ECHO) -e $(addprefix "\n"$(BININSTALLDIR)/,$(INSTALLEXEFILES)) +endif +ifdef INSTALLPPUFILES + @$(ECHO) -e $(addprefix "\n"$(UNITINSTALLDIR)/,$(INSTALLPPUFILES)) +ifneq ($(INSTALLPPULINKFILES),) + @$(ECHO) -e $(addprefix "\n"$(UNITINSTALLDIR)/,$(INSTALLPPULINKFILES)) +endif +ifneq ($(wildcard $(LIBFULLNAME)),) + @$(ECHO) $(LIBINSTALLDIR)/$(LIBFULLNAME) +ifdef HASSHAREDLIB + @$(ECHO) $(LIBINSTALLDIR)/$(LIBNAME) +endif +endif +endif +ifdef EXTRAINSTALLFILES + @$(ECHO) -e $(addprefix "\n"$(DATAINSTALLDIR)/,$(EXTRAINSTALLFILES)) +endif + +fpc_install: $(INSTALLTARGET) +# Create UnitInstallFiles +ifdef INSTALLEXEFILES + $(MKDIR) $(BININSTALLDIR) +# Compress the exes if upx is defined +ifdef UPXPROG + -$(UPXPROG) $(INSTALLEXEFILES) +endif + $(INSTALLEXE) $(INSTALLEXEFILES) $(BININSTALLDIR) +endif +ifdef INSTALLPPUFILES + $(MKDIR) $(UNITINSTALLDIR) + $(INSTALL) $(INSTALLPPUFILES) $(UNITINSTALLDIR) +ifneq ($(INSTALLPPULINKFILES),) + $(INSTALL) $(INSTALLPPULINKFILES) $(UNITINSTALLDIR) +endif +ifneq ($(wildcard $(LIBFULLNAME)),) + $(MKDIR) $(LIBINSTALLDIR) + $(INSTALL) $(LIBFULLNAME) $(LIBINSTALLDIR) +ifdef inUnix + ln -sf $(LIBFULLNAME) $(LIBINSTALLDIR)/$(LIBNAME) +endif +endif +endif +ifdef EXTRAINSTALLFILES + $(MKDIR) $(DATAINSTALLDIR) + $(INSTALL) $(EXTRAINSTALLFILES) $(DATAINSTALLDIR) +endif + +##################################################################### +# SourceInstall rules +##################################################################### + +.PHONY: fpc_sourceinstall + +ifndef SOURCETOPDIR +SOURCETOPDIR=$(BASEDIR) +endif + +fpc_sourceinstall: clean + $(MKDIR) $(SOURCEINSTALLDIR) + $(COPYTREE) $(SOURCETOPDIR) $(SOURCEINSTALLDIR) + +##################################################################### +# exampleinstall rules +##################################################################### + +.PHONY: fpc_exampleinstall + +fpc_exampleinstall: $(addsuffix _clean,$(EXAMPLEDIROBJECTS)) +ifdef EXAMPLESOURCEFILES + $(MKDIR) $(EXAMPLEINSTALLDIR) + $(COPY) $(EXAMPLESOURCEFILES) $(EXAMPLEINSTALLDIR) +endif +ifdef EXAMPLEDIROBJECTS +ifndef EXAMPLESOURCEFILES + $(MKDIR) $(EXAMPLEINSTALLDIR) +endif + $(COPYTREE) $(addsuffix /*,$(EXAMPLEDIROBJECTS)) $(EXAMPLEINSTALLDIR) +endif + +##################################################################### +# Zip +##################################################################### + +.PHONY: fpc_zipinstall + +# Create suffix to add +ifndef PACKAGESUFFIX +PACKAGESUFFIX=$(OS_TARGET) +ifeq ($(OS_TARGET),go32v2) +PACKAGESUFFIX=go32 +endif +ifeq ($(OS_TARGET),win32) +PACKAGESUFFIX=w32 +endif +endif + +# Temporary path to pack a file +ifndef PACKDIR +ifndef inUnix +PACKDIR=$(BASEDIR)/pack_tmp +else +PACKDIR=/tmp/fpc-pack +endif +endif + +# Maybe create default zipname from packagename +ifndef ZIPNAME +ifdef PACKAGENAME +ZIPNAME=$(PACKAGEPREFIX)$(PACKAGENAME)$(PACKAGESUFFIX) +endif +endif + +# Use tar by default under linux +ifndef USEZIP +ifdef inUnix +USETAR=1 +endif +endif + +fpc_zipinstall: +ifndef ZIPNAME + @$(ECHO) "Please specify ZIPNAME!" + @exit 1 +else + $(MAKE) $(ZIPTARGET) PREFIXINSTALLDIR=$(PACKDIR) +ifdef USETAR + $(DEL) $(DESTZIPDIR)/$(ZIPNAME)$(TAREXT) + cd $(PACKDIR) ; $(TARPROG) cf$(TAROPT) $(DESTZIPDIR)/$(ZIPNAME)$(TAREXT) * ; cd $(BASEDIR) +else + $(DEL) $(DESTZIPDIR)/$(ZIPNAME)$(ZIPEXT) + cd $(PACKDIR) ; $(ZIPPROG) -Dr $(ZIPOPT) $(DESTZIPDIR)/$(ZIPNAME)$(ZIPEXT) * ; cd $(BASEDIR) +endif + $(DELTREE) $(PACKDIR) +endif + +.PHONY: fpc_zipsourceinstall + +fpc_zipsourceinstall: + $(MAKE) fpc_zipinstall ZIPTARGET=sourceinstall PACKAGESUFFIX=src + +.PHONY: fpc_zipexampleinstall + +fpc_zipexampleinstall: + $(MAKE) fpc_zipinstall ZIPTARGET=exampleinstall PACKAGESUFFIX=exm + +##################################################################### +# Clean rules +##################################################################### + +.PHONY: fpc_clean fpc_cleanall fpc_distclean + +ifdef EXEFILES +override CLEANEXEFILES:=$(addprefix $(TARGETDIRPREFIX),$(CLEANEXEFILES)) +endif + +ifdef EXTRACLEANUNITS +override CLEANPPUFILES+=$(addsuffix $(PPUEXT),$(EXTRACLEANUNITS)) +endif + +ifdef CLEANPPUFILES +override CLEANPPUFILES:=$(addprefix $(UNITTARGETDIRPREFIX),$(CLEANPPUFILES)) +# Get the .o and .a files created for the units +ifdef PPUFILES +CLEANPPULINKFILES:=$(shell $(PPUFILES) $(CLEANPPUFILES)) +else +CLEANPPULINKFILES:=$(wildcard $(subst $(PPUEXT),$(OEXT),$(CLEANPPUFILES)) $(addprefix $(LIBPREFIX),$(subst $(PPUEXT),$(STATICLIBEXT),$(CLEANPPUFILES)))) +endif +override CLEANPPULINKFILES:=$(addprefix $(UNITTARGETDIRPREFIX),$(CLEANPPULINKFILES)) +endif + +fpc_clean: $(CLEANTARGET) +ifdef CLEANEXEFILES + -$(DEL) $(CLEANEXEFILES) +endif +ifdef CLEANPPUFILES + -$(DEL) $(CLEANPPUFILES) +endif +ifneq ($(CLEANPPULINKFILES),) + -$(DEL) $(CLEANPPULINKFILES) +endif +ifdef CLEANRSTFILES + -$(DEL) $(addprefix $(UNITTARGETDIRPREFIX),$(CLEANRSTFILES)) +endif +ifdef EXTRACLEANFILES + -$(DEL) $(EXTRACLEANFILES) +endif +ifdef LIBNAME + -$(DEL) $(LIBNAME) $(LIBFULLNAME) +endif + -$(DEL) $(FPCMADE) $(PPAS) link.res $(FPCEXTFILE) $(REDIRFILE) + +fpc_distclean: fpc_clean + +# Also run clean first if targetdir is set. Unittargetdir is always +# set if targetdir or unittargetdir is specified +ifdef UNITTARGETDIR +TARGETDIRCLEAN=fpc_clean +endif + +fpc_cleanall: $(CLEANTARGET) $(TARGETDIRCLEAN) +ifdef CLEANEXEFILES + -$(DEL) $(CLEANEXEFILES) +endif + -$(DEL) *$(OEXT) *$(PPUEXT) *$(RSTEXT) *$(ASMEXT) *$(STATICLIBEXT) *$(SHAREDLIBEXT) *$(PPLEXT) + -$(DELTREE) *$(SMARTEXT) + -$(DEL) $(FPCMADE) $(PPAS) link.res $(FPCEXTFILE) $(REDIRFILE) + +##################################################################### +# Info rules +##################################################################### + +.PHONY: fpc_info fpc_cfginfo fpc_objectinfo fpc_toolsinfo fpc_installinfo \ + fpc_dirinfo + +fpc_info: $(INFOTARGET) + +fpc_infocfg: + @$(ECHO) + @$(ECHO) == Configuration info == + @$(ECHO) + @$(ECHO) FPC....... $(FPC) + @$(ECHO) Version... $(FPC_VERSION) + @$(ECHO) CPU....... $(CPU_TARGET) + @$(ECHO) Source.... $(OS_SOURCE) + @$(ECHO) Target.... $(OS_TARGET) + @$(ECHO) + +fpc_infoobjects: + @$(ECHO) + @$(ECHO) == Object info == + @$(ECHO) + @$(ECHO) LoaderObjects..... $(LOADEROBJECTS) + @$(ECHO) UnitObjects....... $(UNITOBJECTS) + @$(ECHO) ExeObjects........ $(EXEOBJECTS) + @$(ECHO) + @$(ECHO) ExtraCleanUnits... $(EXTRACLEANUNITS) + @$(ECHO) ExtraCleanFiles... $(EXTRACLEANFILES) + @$(ECHO) + @$(ECHO) ExtraInstallUnits. $(EXTRAINSTALLUNITS) + @$(ECHO) ExtraInstallFiles. $(EXTRAINSTALLFILES) + @$(ECHO) + +fpc_infoinstall: + @$(ECHO) + @$(ECHO) == Install info == + @$(ECHO) +ifdef DATE + @$(ECHO) DateStr.............. $(DATESTR) +endif +ifdef PACKAGEPREFIX + @$(ECHO) PackagePrefix........ $(PACKAGEPREFIX) +endif +ifdef PACKAGENAME + @$(ECHO) PackageName.......... $(PACKAGENAME) +endif + @$(ECHO) PackageSuffix........ $(PACKAGESUFFIX) + @$(ECHO) + @$(ECHO) BaseInstallDir....... $(BASEINSTALLDIR) + @$(ECHO) BinInstallDir........ $(BININSTALLDIR) + @$(ECHO) LibInstallDir........ $(LIBINSTALLDIR) + @$(ECHO) UnitInstallDir....... $(UNITINSTALLDIR) + @$(ECHO) SourceInstallDir..... $(SOURCEINSTALLDIR) + @$(ECHO) DocInstallDir........ $(DOCINSTALLDIR) + @$(ECHO) DataInstallDir....... $(DATAINSTALLDIR) + @$(ECHO) + @$(ECHO) DestZipDir........... $(DESTZIPDIR) + @$(ECHO) ZipName.............. $(ZIPNAME) + @$(ECHO) + +##################################################################### +# Local Makefile +##################################################################### + +ifneq ($(wildcard fpcmake.loc),) +include fpcmake.loc +endif + diff --git a/examples/gui/interbasetest/Makefile.fpc b/examples/gui/interbasetest/Makefile.fpc new file mode 100644 index 00000000..7d8d31ff --- /dev/null +++ b/examples/gui/interbasetest/Makefile.fpc @@ -0,0 +1,10 @@ +# +# Makefile.fpc for fpGUI InterbaseTest example +# + +[targets] +programs=interbasetest + +[require] +options=-S2h +packages=fcl fpgfx fpgui diff --git a/examples/gui/interbasetest/interbasetest.pas b/examples/gui/interbasetest/interbasetest.pas new file mode 100644 index 00000000..18f67c83 --- /dev/null +++ b/examples/gui/interbasetest/interbasetest.pas @@ -0,0 +1,131 @@ +{ + $Id: interbasetest.pp,v 1.2 2001/01/17 21:35:45 sg Exp $ + + fpGUI - Free Pascal Graphical User Interface + Copyright (C) 2001 by + Areca Systems GmbH / Sebastian Guenther, sg@freepascal.org + + InterBase database test + + See the file COPYING.FPC, included in this distribution, + for details about the copyright. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +} + + +program InterBaseTest; + +{$linklib dl} +{$linklib crypt} + +uses SysUtils, Classes, fpGUI, fpGUI_DB, DB, InterBase; + +type + + TMainForm = class(TForm) + Database: TIBDatabase; + Transaction: TIBTransaction; + Query: TIBQuery; + DataSource: TDataSource; + Box, ConnectionBox: TBoxLayout; + ConnectionLabel, ConnectionStateLabel: TLabel; + ListBox: TListBox; + CurDatasetLabel: TLabel; + CurNameText, CurEMailText: TDBText; + Navi: TBoxLayout; + FirstDataset, PrevDataset, NextDataset, LastDataset: TButton; + procedure FormCreate(Sender: TObject); + procedure FirstDatasetClick(Sender: TObject); + procedure PrevDatasetClick(Sender: TObject); + procedure NextDatasetClick(Sender: TObject); + procedure LastDatasetClick(Sender: TObject); + end; + + +// ------------------------------------------------------------------- +// TMainForm +// ------------------------------------------------------------------- + +procedure TMainForm.FormCreate(Sender: TObject); +var + x: Integer; + s: String; +begin + Query := TIBQuery.Create(Self); + + Database.Connected := True; + Database.Transaction := Transaction; + Query.Database := Database; + DataSource.DataSet := Query; + Transaction.Action := caRollback; + Transaction.Active := True; + + if Database.Connected then + ConnectionStateLabel.Text := 'Yes' + else + ConnectionStateLabel.Text := 'No'; + + CurNameText.DataSource := DataSource; + CurNameText.DataField := 'UserName'; + CurEMailText.DataSource := DataSource; + CurEMailText.DataField := 'InstEmail'; + + Query.SQL.Add('select * from fpdev'); +WriteLn('Query.Active? ', Query.Active); + Query.Open; + +WriteLn('Query.Active? ', Query.Active); + + while not Query.EOF do + begin + SetLength(s, 0); + for x := 0 to Query.FieldCount - 2 do + s := s + Query.Fields[x].AsString + ', '; + s := s + Query.Fields[Query.FieldCount - 1].AsString; + ListBox.Items.Add(s); + Query.Next; + end; + + Query.First; +end; + +procedure TMainForm.FirstDatasetClick(Sender: TObject); +begin + Query.First; +end; + +procedure TMainForm.PrevDatasetClick(Sender: TObject); +begin + Query.Prior; +end; + +procedure TMainForm.NextDatasetClick(Sender: TObject); +begin + Query.Next; +end; + +procedure TMainForm.LastDatasetClick(Sender: TObject); +begin + Query.Last; +end; + + + +var + MainForm: TMainForm; +begin + Application.Title := 'InterBase Test'; + Application.CreateForm(TMainForm, MainForm); + Application.Run; +end. + + +{ + $Log: interbasetest.pp,v $ + Revision 1.2 2001/01/17 21:35:45 sg + * Now uses fpGUI_DB unit + +} diff --git a/examples/gui/interbasetest/mainform.frm b/examples/gui/interbasetest/mainform.frm new file mode 100644 index 00000000..354c5b6e --- /dev/null +++ b/examples/gui/interbasetest/mainform.frm @@ -0,0 +1,55 @@ +object MainForm: TMainForm + Text = 'Interbase test' + BorderWidth = 8 + OnCreate = FormCreate + object Database: TIBDatabase + DatabaseName = 'test.gdb' + UserName = 'sysdba' + Password = 'masterkey' + end + object Transaction: TIBTransaction + end + object DataSource: TDataSource + end + object Box: TBoxLayout + Spacing = 8 + Orientation = Vertical + object ConnectionBox: TBoxLayout + object ConnectionLabel: TLabel + Text = 'Connected to database? ' + end + object ConnectionStateLabel: TLabel + Text = 'unknown' + end + end + object ListBox: TListBox + end + object CurDatasetLabel: TLabel + Text = 'Current dataset:' + end + object CurNameText: TDBText + Text = '<name>' + end + object CurEMailText: TDBText + Text = '<e-mail>' + end + object Navi: TBoxLayout + object FirstDataset: TButton + Text = 'First' + OnClick = FirstDatasetClick + end + object PrevDataset: TButton + Text = 'Previous' + OnClick = PrevDatasetClick + end + object NextDataset: TButton + Text = 'Next' + OnClick = NextDatasetClick + end + object LastDataset: TButton + Text = 'Last' + OnClick = LastDatasetClick + end + end + end +end diff --git a/examples/gui/interbasetest/mkdb b/examples/gui/interbasetest/mkdb new file mode 100644 index 00000000..b4142314 --- /dev/null +++ b/examples/gui/interbasetest/mkdb @@ -0,0 +1,53 @@ +#!/bin/sh +# +# Script to create a table 'FPdev' and to fill it with data. +# The script accepts an optional argument : +# A database to connect to. (default 'testdb') +# +# Collect the database +DATABASE=test.gdb +# Choose one of the following: +# ISQL=isql +ISQL=/opt/interbase/bin/isql +# +# Don't edit after this. +# +echo -n "Creating and filling table FPdev in database $DATABASE..." +# >/dev/null 2>&1 +${ISQL} << EOF +set sql dialect 3; +CREATE DATABASE "$DATABASE"; +create table FPDEV ( +id INT NOT NULL, +UserName varchar(50), +InstEmail CHAR(50), +PRIMARY KEY (id)); +insert into FPdev values ('1','Michael Van Canneyt','Michael@tfdec1.fys.kuleuven.ac.be'); +insert into FPdev values ('2','Florian Klaempfl','ba2395@fen.baynet.de'); +insert into FPdev values ('3','Carl-Eric Codere','codc01@gel.usherb.ca'); +insert into FPdev values ('4','Daniel Mantione','d.s.p.mantione@twi.tudelft.nl'); +insert into FPdev values ('5','Pierre Muller','muller@europe.u-strasbg.fr'); +insert into FPdev values ('6','Jonas Maebe','jmaebe@mail.dma.be'); +insert into FPdev values ('7','Peter Vreman','pfv@worldonline.nl'); +insert into FPdev values ('8','Gerry Dubois','gerry@webworks.ml.org'); +insert into FPdev values ('9','name9','mail9'); +insert into FPdev values ('10','name10','mail10'); +insert into FPdev values ('11','name11','mail11'); +insert into FPdev values ('12','name12','mail12'); +create table test ( +timestamp_fld timestamp, +smallint_fld smallint, +integer_fld integer, +float_fld float, +double_fld double precision, +char_fld char(10), +varchar_fld varchar(50)); +insert into test values ('12.1.2000 00:30',10,70000,12.5,20.5,'testchar','testvarchar'); +commit; +EOF +if [ ! $? = 0 ]; then + echo "Failed." +else + echo "Done." +fi +# Ready diff --git a/examples/gui/layouttest/Makefile b/examples/gui/layouttest/Makefile new file mode 100644 index 00000000..2ccf237e --- /dev/null +++ b/examples/gui/layouttest/Makefile @@ -0,0 +1,1320 @@ +# +# Makefile generated by fpcmake v1.00 [2000/12/14] +# + +defaultrule: all + +##################################################################### +# Autodetect OS (Linux or Dos or Windows NT) +# define inUnix when running under Unix (Linux,FreeBSD) +# define inWinNT when running under WinNT +##################################################################### + +# We need only / in the path +override PATH:=$(subst \,/,$(PATH)) + +# Search for PWD and determine also if we are under linux +PWD:=$(strip $(wildcard $(addsuffix /pwd.exe,$(subst ;, ,$(PATH))))) +ifeq ($(PWD),) +PWD:=$(strip $(wildcard $(addsuffix /pwd,$(subst :, ,$(PATH))))) +ifeq ($(PWD),) +nopwd: + @echo You need the GNU utils package to use this Makefile! + @echo Get ftp://ftp.freepascal.org/pub/fpc/dist/go32v2/utilgo32.zip + @exit +else +inUnix=1 +endif +else +PWD:=$(firstword $(PWD)) +endif + +# Detect NT - NT sets OS to Windows_NT +# Detect OS/2 - OS/2 has OS2_SHELL defined +ifndef inUnix +ifeq ($(OS),Windows_NT) +inWinNT=1 +else +ifdef OS2_SHELL +inOS2=1 +endif +endif +endif + +# The extension of executables +ifdef inUnix +SRCEXEEXT= +else +SRCEXEEXT=.exe +endif + +# The path which is searched separated by spaces +ifdef inUnix +SEARCHPATH=$(subst :, ,$(PATH)) +else +SEARCHPATH=$(subst ;, ,$(PATH)) +endif + +# Base dir +ifdef PWD +BASEDIR:=$(shell $(PWD)) +else +BASEDIR=. +endif + +##################################################################### +# FPC version/target Detection +##################################################################### + +# What compiler to use ? +ifndef FPC +# Compatibility with old makefiles +ifdef PP +FPC=$(PP) +else +FPC=ppc386 +endif +endif +override FPC:=$(subst $(SRCEXEEXT),,$(FPC)) +override FPC:=$(subst \,/,$(FPC))$(SRCEXEEXT) + +# Target OS +ifndef OS_TARGET +OS_TARGET:=$(shell $(FPC) -iTO) +endif + +# Source OS +ifndef OS_SOURCE +OS_SOURCE:=$(shell $(FPC) -iSO) +endif + +# Target CPU +ifndef CPU_TARGET +CPU_TARGET:=$(shell $(FPC) -iTP) +endif + +# Source CPU +ifndef CPU_SOURCE +CPU_SOURCE:=$(shell $(FPC) -iSP) +endif + +# FPC version +ifndef FPC_VERSION +FPC_VERSION:=$(shell $(FPC) -iV) +endif + +export FPC OS_TARGET OS_SOURCE CPU_TARGET CPU_SOURCE FPC_VERSION FPCOPT + +##################################################################### +# FPCDIR Setting +##################################################################### + +# Test FPCDIR to look if the RTL dir exists +ifdef FPCDIR +override FPCDIR:=$(subst \,/,$(FPCDIR)) +ifeq ($(wildcard $(FPCDIR)/rtl),) +ifeq ($(wildcard $(FPCDIR)/units),) +override FPCDIR=wrong +endif +endif +else +override FPCDIR=wrong +endif + +# Detect FPCDIR +ifeq ($(FPCDIR),wrong) +ifdef inUnix +override FPCDIR=/usr/local/lib/fpc/$(FPC_VERSION) +ifeq ($(wildcard $(FPCDIR)/units),) +override FPCDIR=/usr/lib/fpc/$(FPC_VERSION) +endif +else +override FPCDIR:=$(subst /$(FPC),,$(firstword $(strip $(wildcard $(addsuffix /$(FPC),$(SEARCHPATH)))))) +override FPCDIR:=$(FPCDIR)/.. +ifeq ($(wildcard $(FPCDIR)/rtl),) +ifeq ($(wildcard $(FPCDIR)/units),) +override FPCDIR:=$(FPCDIR)/.. +ifeq ($(wildcard $(FPCDIR)/rtl),) +ifeq ($(wildcard $(FPCDIR)/units),) +override FPCDIR=c:/pp +endif +endif +endif +endif +endif +endif + +ifndef PACKAGESDIR +PACKAGESDIR=$(FPCDIR)/packages +endif +ifndef TOOLKITSDIR +TOOLKITSDIR= +endif +ifndef COMPONENTSDIR +COMPONENTSDIR= +endif + +# Create units dir +ifneq ($(FPCDIR),.) +UNITSDIR=$(FPCDIR)/units/$(OS_TARGET) +endif + +##################################################################### +# User Settings +##################################################################### + + +# Targets + +override EXEOBJECTS+=layouttest + +# Clean + + +# Install + +ZIPTARGET=install + +# Defaults + +override NEEDOPT=-S2h + +# Directories + + +# Packages + +override PACKAGES+=rtl fcl fpgfx fpgui + +# Libraries + + +# Info + +INFOTARGET=fpc_infocfg fpc_infoobjects fpc_infoinstall + +##################################################################### +# Shell tools +##################################################################### + +# echo +ifndef ECHO +ECHO:=$(strip $(wildcard $(addsuffix /gecho$(EXEEXT),$(SEARCHPATH)))) +ifeq ($(ECHO),) +ECHO:=$(strip $(wildcard $(addsuffix /echo$(SRCEXEEXT),$(SEARCHPATH)))) +ifeq ($(ECHO),) +ECHO:=echo +ECHOE:=echo +else +ECHO:=$(firstword $(ECHO)) +ECHOE=$(ECHO) -E +endif +else +ECHO:=$(firstword $(ECHO)) +ECHOE=$(ECHO) -E +endif +endif + +# To copy pograms +ifndef COPY +COPY:=cp -fp +endif + +# Copy a whole tree +ifndef COPYTREE +COPYTREE:=cp -rfp +endif + +# To move pograms +ifndef MOVE +MOVE:=mv -f +endif + +# Check delete program +ifndef DEL +DEL:=rm -f +endif + +# Check deltree program +ifndef DELTREE +DELTREE:=rm -rf +endif + +# To install files +ifndef INSTALL +ifdef inUnix +INSTALL:=install -c -m 644 +else +INSTALL:=$(COPY) +endif +endif + +# To install programs +ifndef INSTALLEXE +ifdef inUnix +INSTALLEXE:=install -c -m 755 +else +INSTALLEXE:=$(COPY) +endif +endif + +# To make a directory. +ifndef MKDIR +ifdef inUnix +MKDIR:=install -m 755 -d +else +MKDIR:=ginstall -m 755 -d +endif +endif + +export ECHO ECHOE COPY COPYTREE MOVE DEL DELTREE INSTALL INSTALLEXE MKDIR + +##################################################################### +# Default Tools +##################################################################### + +# assembler, redefine it if cross compiling +ifndef AS +AS=as +endif + +# linker, but probably not used +ifndef LD +LD=ld +endif + +# ppas.bat / ppas.sh +ifdef inUnix +PPAS=ppas.sh +else +ifdef inOS2 +PPAS=ppas.cmd +else +PPAS=ppas.bat +endif +endif + +# ldconfig to rebuild .so cache +ifdef inUnix +LDCONFIG=ldconfig +else +LDCONFIG= +endif + +# ppumove +ifndef PPUMOVE +PPUMOVE:=$(strip $(wildcard $(addsuffix /ppumove$(SRCEXEEXT),$(SEARCHPATH)))) +ifeq ($(PPUMOVE),) +PPUMOVE= +else +PPUMOVE:=$(firstword $(PPUMOVE)) +endif +endif +export PPUMOVE + +# ppufiles +ifndef PPUFILES +PPUFILES:=$(strip $(wildcard $(addsuffix /ppufiles$(SRCEXEEXT),$(SEARCHPATH)))) +ifeq ($(PPUFILES),) +PPUFILES= +else +PPUFILES:=$(firstword $(PPUFILES)) +endif +endif +export PPUFILES + +# Look if UPX is found for go32v2 and win32. We can't use $UPX becuase +# upx uses that one itself (PFV) +ifndef UPXPROG +ifeq ($(OS_TARGET),go32v2) +UPXPROG:=1 +endif +ifeq ($(OS_TARGET),win32) +UPXPROG:=1 +endif +ifdef UPXPROG +UPXPROG:=$(strip $(wildcard $(addsuffix /upx$(SRCEXEEXT),$(SEARCHPATH)))) +ifeq ($(UPXPROG),) +UPXPROG= +else +UPXPROG:=$(firstword $(UPXPROG)) +endif +else +UPXPROG= +endif +endif +export UPXPROG + +# ZipProg, you can't use Zip as the var name (PFV) +ifndef ZIPPROG +ZIPPROG:=$(strip $(wildcard $(addsuffix /zip$(SRCEXEEXT),$(SEARCHPATH)))) +ifeq ($(ZIPPROG),) +ZIPPROG= +else +ZIPPROG:=$(firstword $(ZIPPROG)) +endif +endif +export ZIPPROG + +ZIPOPT=-9 +ZIPEXT=.zip + +# Tar +ifndef TARPROG +TARPROG:=$(strip $(wildcard $(addsuffix /tar$(SRCEXEEXT),$(SEARCHPATH)))) +ifeq ($(TARPROG),) +TARPROG= +else +TARPROG:=$(firstword $(TARPROG)) +endif +endif +export TARPROG + +ifeq ($(USETAR),bz2) +TAROPT=vI +TAREXT=.tar.bz2 +else +TAROPT=vz +TAREXT=.tar.gz +endif + +##################################################################### +# Default extensions +##################################################################### + +# Default needed extensions (Go32v2,Linux) +LOADEREXT=.as +EXEEXT=.exe +PPLEXT=.ppl +PPUEXT=.ppu +OEXT=.o +ASMEXT=.s +SMARTEXT=.sl +STATICLIBEXT=.a +SHAREDLIBEXT=.so +RSTEXT=.rst +FPCMADE=fpcmade + +# Go32v1 +ifeq ($(OS_TARGET),go32v1) +PPUEXT=.pp1 +OEXT=.o1 +ASMEXT=.s1 +SMARTEXT=.sl1 +STATICLIBEXT=.a1 +SHAREDLIBEXT=.so1 +FPCMADE=fpcmade.v1 +endif + +# Go32v2 +ifeq ($(OS_TARGET),go32v2) +FPCMADE=fpcmade.dos +endif + +# Linux +ifeq ($(OS_TARGET),linux) +EXEEXT= +HASSHAREDLIB=1 +FPCMADE=fpcmade.lnx +endif + +# Linux +ifeq ($(OS_TARGET),freebsd) +EXEEXT= +HASSHAREDLIB=1 +FPCMADE=fpcmade.freebsd +endif + +# Win32 +ifeq ($(OS_TARGET),win32) +PPUEXT=.ppw +OEXT=.ow +ASMEXT=.sw +SMARTEXT=.slw +STATICLIBEXT=.aw +SHAREDLIBEXT=.dll +FPCMADE=fpcmade.w32 +endif + +# OS/2 +ifeq ($(OS_TARGET),os2) +PPUEXT=.ppo +ASMEXT=.so2 +OEXT=.oo2 +SMARTEXT=.so +STATICLIBEXT=.ao2 +SHAREDLIBEXT=.dll +FPCMADE=fpcmade.os2 +endif + +# library prefix +LIBPREFIX=lib +ifeq ($(OS_TARGET),go32v2) +LIBPREFIX= +endif +ifeq ($(OS_TARGET),go32v1) +LIBPREFIX= +endif + +# determine which .pas extension is used +ifndef PASEXT +ifdef EXEOBJECTS +override TESTPAS:=$(strip $(wildcard $(addsuffix .pas,$(firstword $(EXEOBJECTS))))) +else +override TESTPAS:=$(strip $(wildcard $(addsuffix .pas,$(firstword $(UNITOBJECTS))))) +endif +ifeq ($(TESTPAS),) +PASEXT=.pp +else +PASEXT=.pas +endif +endif + + +# Check if the dirs really exists, else turn it off +ifeq ($(wildcard $(UNITSDIR)),) +UNITSDIR= +endif +ifeq ($(wildcard $(TOOLKITSDIR)),) +TOOLKITSDIR= +endif +ifeq ($(wildcard $(PACKAGESDIR)),) +PACKAGESDIR= +endif +ifeq ($(wildcard $(COMPONENTSDIR)),) +COMPONENTSDIR= +endif + + +# PACKAGESDIR packages + +PACKAGERTL=1 +PACKAGEFCL=1 +PACKAGEFPGFX=1 +PACKAGEFPGUI=1 + +ifdef PACKAGERTL +ifneq ($(wildcard $(FPCDIR)/rtl),) +ifneq ($(wildcard $(FPCDIR)/rtl/$(OS_TARGET)),) +PACKAGEDIR_RTL=$(FPCDIR)/rtl/$(OS_TARGET) +else +PACKAGEDIR_RTL=$(FPCDIR)/rtl +endif +ifeq ($(wildcard $(PACKAGEDIR_RTL)/$(FPCMADE)),) +override COMPILEPACKAGES+=package_rtl +package_rtl: + $(MAKE) -C $(PACKAGEDIR_RTL) all +endif +UNITDIR_RTL=$(PACKAGEDIR_RTL) +else +PACKAGEDIR_RTL= +ifneq ($(wildcard $(UNITSDIR)/rtl),) +ifneq ($(wildcard $(UNITSDIR)/rtl/$(OS_TARGET)),) +UNITDIR_RTL=$(UNITSDIR)/rtl/$(OS_TARGET) +else +UNITDIR_RTL=$(UNITSDIR)/rtl +endif +else +UNITDIR_RTL= +endif +endif +ifdef UNITDIR_RTL +override NEEDUNITDIR+=$(UNITDIR_RTL) +endif +endif +ifdef PACKAGEFCL +ifneq ($(wildcard $(FPCDIR)/fcl),) +ifneq ($(wildcard $(FPCDIR)/fcl/$(OS_TARGET)),) +PACKAGEDIR_FCL=$(FPCDIR)/fcl/$(OS_TARGET) +else +PACKAGEDIR_FCL=$(FPCDIR)/fcl +endif +ifeq ($(wildcard $(PACKAGEDIR_FCL)/$(FPCMADE)),) +override COMPILEPACKAGES+=package_fcl +package_fcl: + $(MAKE) -C $(PACKAGEDIR_FCL) all +endif +UNITDIR_FCL=$(PACKAGEDIR_FCL) +else +PACKAGEDIR_FCL= +ifneq ($(wildcard $(UNITSDIR)/fcl),) +ifneq ($(wildcard $(UNITSDIR)/fcl/$(OS_TARGET)),) +UNITDIR_FCL=$(UNITSDIR)/fcl/$(OS_TARGET) +else +UNITDIR_FCL=$(UNITSDIR)/fcl +endif +else +UNITDIR_FCL= +endif +endif +ifdef UNITDIR_FCL +override NEEDUNITDIR+=$(UNITDIR_FCL) +endif +endif +ifdef PACKAGEFPGFX +ifneq ($(wildcard $(PACKAGESDIR)/fpgfx),) +ifneq ($(wildcard $(PACKAGESDIR)/fpgfx/$(OS_TARGET)),) +PACKAGEDIR_FPGFX=$(PACKAGESDIR)/fpgfx/$(OS_TARGET) +else +PACKAGEDIR_FPGFX=$(PACKAGESDIR)/fpgfx +endif +ifeq ($(wildcard $(PACKAGEDIR_FPGFX)/$(FPCMADE)),) +override COMPILEPACKAGES+=package_fpgfx +package_fpgfx: + $(MAKE) -C $(PACKAGEDIR_FPGFX) all +endif +UNITDIR_FPGFX=$(PACKAGEDIR_FPGFX) +else +PACKAGEDIR_FPGFX= +ifneq ($(wildcard $(UNITSDIR)/fpgfx),) +ifneq ($(wildcard $(UNITSDIR)/fpgfx/$(OS_TARGET)),) +UNITDIR_FPGFX=$(UNITSDIR)/fpgfx/$(OS_TARGET) +else +UNITDIR_FPGFX=$(UNITSDIR)/fpgfx +endif +else +UNITDIR_FPGFX= +endif +endif +ifdef UNITDIR_FPGFX +override NEEDUNITDIR+=$(UNITDIR_FPGFX) +endif +endif +ifdef PACKAGEFPGUI +ifneq ($(wildcard $(PACKAGESDIR)/fpgui),) +ifneq ($(wildcard $(PACKAGESDIR)/fpgui/$(OS_TARGET)),) +PACKAGEDIR_FPGUI=$(PACKAGESDIR)/fpgui/$(OS_TARGET) +else +PACKAGEDIR_FPGUI=$(PACKAGESDIR)/fpgui +endif +ifeq ($(wildcard $(PACKAGEDIR_FPGUI)/$(FPCMADE)),) +override COMPILEPACKAGES+=package_fpgui +package_fpgui: + $(MAKE) -C $(PACKAGEDIR_FPGUI) all +endif +UNITDIR_FPGUI=$(PACKAGEDIR_FPGUI) +else +PACKAGEDIR_FPGUI= +ifneq ($(wildcard $(UNITSDIR)/fpgui),) +ifneq ($(wildcard $(UNITSDIR)/fpgui/$(OS_TARGET)),) +UNITDIR_FPGUI=$(UNITSDIR)/fpgui/$(OS_TARGET) +else +UNITDIR_FPGUI=$(UNITSDIR)/fpgui +endif +else +UNITDIR_FPGUI= +endif +endif +ifdef UNITDIR_FPGUI +override NEEDUNITDIR+=$(UNITDIR_FPGUI) +endif +endif + + +##################################################################### +# Default Directories +##################################################################### + +# Linux and freebsd use unix dirs with /usr/bin, /usr/lib +# When zipping use the target as default, when normal install then +# use the source os as default +ifdef ZIPNAME +# Zipinstall +ifeq ($(OS_TARGET),linux) +UNIXINSTALLDIR=1 +endif +ifeq ($(OS_TARGET),freebsd) +UNIXINSTALLDIR=1 +endif +else +# Normal install +ifeq ($(OS_SOURCE),linux) +UNIXINSTALLDIR=1 +endif +ifeq ($(OS_SOURCE),freebsd) +UNIXINSTALLDIR=1 +endif +endif + +# set the prefix directory where to install everything +ifndef PREFIXINSTALLDIR +ifdef UNIXINSTALLDIR +PREFIXINSTALLDIR=/usr +else +PREFIXINSTALLDIR=/pp +endif +endif +export PREFIXINSTALLDIR + +# Where to place the resulting zip files +ifndef DESTZIPDIR +DESTZIPDIR:=$(BASEDIR) +endif +export DESTZIPDIR + +##################################################################### +# Install Directories +##################################################################### + +# set the base directory where to install everything +ifndef BASEINSTALLDIR +ifdef UNIXINSTALLDIR +BASEINSTALLDIR=$(PREFIXINSTALLDIR)/lib/fpc/$(FPC_VERSION) +else +BASEINSTALLDIR=$(PREFIXINSTALLDIR) +endif +endif + +# set the directory where to install the binaries +ifndef BININSTALLDIR +ifdef UNIXINSTALLDIR +BININSTALLDIR=$(PREFIXINSTALLDIR)/bin +else +BININSTALLDIR=$(BASEINSTALLDIR)/bin/$(OS_TARGET) +endif +endif + +# set the directory where to install the units. +ifndef UNITINSTALLDIR +UNITINSTALLDIR=$(BASEINSTALLDIR)/units/$(OS_TARGET) +ifdef UNITSUBDIR +UNITINSTALLDIR:=$(UNITINSTALLDIR)/$(UNITSUBDIR) +endif +endif + +# Where to install shared libraries +ifndef LIBINSTALLDIR +ifdef UNIXINSTALLDIR +LIBINSTALLDIR=$(PREFIXINSTALLDIR)/lib +else +LIBINSTALLDIR=$(UNITINSTALLDIR) +endif +endif + +# Where the source files will be stored +ifndef SOURCEINSTALLDIR +ifdef UNIXINSTALLDIR +SOURCEINSTALLDIR=$(PREFIXINSTALLDIR)/src/fpc-$(FPC_VERSION) +else +SOURCEINSTALLDIR=$(BASEINSTALLDIR)/source +endif +ifdef SOURCESUBDIR +SOURCEINSTALLDIR:=$(SOURCEINSTALLDIR)/$(SOURCESUBDIR) +endif +endif + +# Where the doc files will be stored +ifndef DOCINSTALLDIR +ifdef UNIXINSTALLDIR +DOCINSTALLDIR=$(PREFIXINSTALLDIR)/doc/fpc-$(FPC_VERSION) +else +DOCINSTALLDIR=$(BASEINSTALLDIR)/doc +endif +endif + +# Where to install the examples, under linux we use the doc dir +# because the copytree command will create a subdir itself +ifndef EXAMPLEINSTALLDIR +ifdef UNIXINSTALLDIR +EXAMPLEINSTALLDIR=$(DOCINSTALLDIR)/examples +else +EXAMPLEINSTALLDIR=$(BASEINSTALLDIR)/examples +endif +ifdef EXAMPLESUBDIR +EXAMPLEINSTALLDIR:=$(EXAMPLEINSTALLDIR)/$(EXAMPLESUBDIR) +endif +endif + +# Where the some extra (data)files will be stored +ifndef DATAINSTALLDIR +DATAINSTALLDIR=$(BASEINSTALLDIR) +endif + +##################################################################### +# Redirection +##################################################################### + +ifndef REDIRFILE +REDIRFILE=log +endif + +ifdef REDIR +ifndef inUnix +override FPC=redir -eo $(FPC) +endif +# set the verbosity to max +override FPCOPT+=-va +override REDIR:= >> $(REDIRFILE) +endif + + +##################################################################### +# Compiler Command Line +##################################################################### + +# Load commandline OPTDEF and add FPC_CPU define +override FPCOPTDEF:=-d$(CPU_TARGET) + +# Load commandline OPT and add target and unit dir to be sure +ifneq ($(OS_TARGET),$(OS_SOURCE)) +override FPCOPT+=-T$(OS_TARGET) +endif + +# User dirs should be first, so they are looked at first +ifdef UNITDIR +override FPCOPT+=$(addprefix -Fu,$(UNITDIR)) +endif +ifdef LIBDIR +override FPCOPT+=$(addprefix -Fl,$(LIBDIR)) +endif +ifdef OBJDIR +override FPCOPT+=$(addprefix -Fo,$(OBJDIR)) +endif +ifdef INCDIR +override FPCOPT+=$(addprefix -Fi,$(INCDIR)) +endif + +# Smartlinking +ifdef LINKSMART +override FPCOPT+=-XX +endif + +# Smartlinking creation +ifdef CREATESMART +override FPCOPT+=-CX +endif + +# Debug +ifdef DEBUG +override FPCOPT+=-gl -dDEBUG +endif + +# Release mode (strip, optimize and don't load ppc386.cfg) +# 0.99.12b has a bug in the optimizer so don't use it by default +ifdef RELEASE +ifeq ($(FPC_VERSION),0.99.12) +override FPCOPT+=-Xs -OGp3 -n +else +override FPCOPT+=-Xs -OG2p3 -n +endif +endif + +# Strip +ifdef STRIP +override FPCOPT+=-Xs +endif + +# Optimizer +ifdef OPTIMIZE +override FPCOPT+=-OG2p3 +endif + +# Verbose settings (warning,note,info) +ifdef VERBOSE +override FPCOPT+=-vwni +endif + +ifdef NEEDOPT +override FPCOPT+=$(NEEDOPT) +endif + +ifdef NEEDUNITDIR +override FPCOPT+=$(addprefix -Fu,$(NEEDUNITDIR)) +endif + +ifdef UNITSDIR +override FPCOPT+=-Fu$(UNITSDIR) +endif + +# Target dirs and the prefix to use for clean/install +ifdef TARGETDIR +override FPCOPT+=-FE$(TARGETDIR) +ifeq ($(TARGETDIR),.) +override TARGETDIRPREFIX= +else +override TARGETDIRPREFIX=$(TARGETDIR)/ +endif +endif +ifdef UNITTARGETDIR +override FPCOPT+=-FU$(UNITTARGETDIR) +ifeq ($(UNITTARGETDIR),.) +override UNITTARGETDIRPREFIX= +else +override UNITTARGETDIRPREFIX=$(TARGETDIR)/ +endif +else +ifdef TARGETDIR +override UNITTARGETDIR=$(TARGETDIR) +override UNITTARGETDIRPREFIX=$(TARGETDIRPREFIX) +endif +endif + +# Add commandline options last so they can override +ifdef OPT +override FPCOPT+=$(OPT) +endif + +# Add defines from FPCOPTDEF to FPCOPT +ifdef FPCOPTDEF +override FPCOPT+=$(FPCOPTDEF) +endif + +# Error file ? +ifdef ERRORFILE +override FPCOPT+=-Fr$(ERRORFILE) +endif + +# Was a config file specified ? +ifdef CFGFILE +override FPCOPT+=@$(CFGFILE) +endif + +# For win32 the options are passed using the environment FPCEXTCMD +ifeq ($(OS_SOURCE),win32) +override FPCEXTCMD:=$(FPCOPT) +override FPCOPT:=!FPCEXTCMD +export FPCEXTCMD +endif + +# Compiler commandline +override COMPILER:=$(FPC) $(FPCOPT) + +# also call ppas if with command option -s +# but only if the OS_SOURCE and OS_TARGE are equal +ifeq (,$(findstring -s ,$(COMPILER))) +EXECPPAS= +else +ifeq ($(OS_SOURCE),$(OS_TARGET)) +EXECPPAS:=@$(PPAS) +endif +endif + +##################################################################### +# Standard rules +##################################################################### + +all: fpc_all + +debug: fpc_debug + +smart: fpc_smart + +shared: fpc_shared + +showinstall: fpc_showinstall + +install: fpc_install + +sourceinstall: fpc_sourceinstall + +exampleinstall: fpc_exampleinstall + +zipinstall: fpc_zipinstall + +zipsourceinstall: fpc_zipsourceinstall + +zipexampleinstall: fpc_zipexampleinstall + +clean: fpc_clean + +distclean: fpc_distclean + +cleanall: fpc_cleanall + +info: fpc_info + +.PHONY: all debug smart shared showinstall install sourceinstall exampleinstall zipinstall zipsourceinstall zipexampleinstall clean distclean cleanall info + +##################################################################### +# Exes +##################################################################### + +.PHONY: fpc_exes + +ifdef EXEOBJECTS +override EXEFILES=$(addsuffix $(EXEEXT),$(EXEOBJECTS)) +override EXEOFILES:=$(addsuffix $(OEXT),$(EXEOBJECTS)) $(addprefix $(LIBPREFIX),$(addsuffix $(STATICLIBEXT),$(EXEOBJECTS))) + +override ALLTARGET+=fpc_exes +override INSTALLEXEFILES+=$(EXEFILES) +override CLEANEXEFILES+=$(EXEFILES) $(EXEOFILES) + +endif + +fpc_exes: $(EXEFILES) + +##################################################################### +# General compile rules +##################################################################### + +.PHONY: fpc_packages fpc_all fpc_debug + +$(FPCMADE): $(ALLTARGET) + @$(ECHO) Compiled > $(FPCMADE) + +fpc_packages: $(COMPILEPACKAGES) + +fpc_all: fpc_packages $(FPCMADE) + +fpc_debug: + $(MAKE) all DEBUG=1 + +# Search paths for .ppu if targetdir is set +ifdef UNITTARGETDIR +vpath %$(PPUEXT) $(UNITTARGETDIR) +endif + +# General compile rules, available for both possible PASEXT + +.SUFFIXES: $(EXEEXT) $(PPUEXT) $(OEXT) .pas .pp + +%$(PPUEXT): %.pp + $(COMPILER) $< $(REDIR) + $(EXECPPAS) + +%$(PPUEXT): %.pas + $(COMPILER) $< $(REDIR) + $(EXECPPAS) + +%$(EXEEXT): %.pp + $(COMPILER) $< $(REDIR) + $(EXECPPAS) + +%$(EXEEXT): %.pas + $(COMPILER) $< $(REDIR) + $(EXECPPAS) + +##################################################################### +# Library +##################################################################### + +.PHONY: fpc_smart fpc_shared + +ifdef LIBVERSION +LIBFULLNAME=$(LIBNAME).$(LIBVERSION) +else +LIBFULLNAME=$(LIBNAME) +endif + +# Default sharedlib units are all unit objects +ifndef SHAREDLIBUNITOBJECTS +SHAREDLIBUNITOBJECTS:=$(UNITOBJECTS) +endif + +fpc_smart: + $(MAKE) all LINKSMART=1 CREATESMART=1 + +fpc_shared: all +ifdef HASSHAREDLIB +ifndef LIBNAME + @$(ECHO) "LIBNAME not set" +else + $(PPUMOVE) $(SHAREDLIBUNITOBJECTS) -o$(LIBFULLNAME) +endif +else + @$(ECHO) "Shared Libraries not supported" +endif + +##################################################################### +# Install rules +##################################################################### + +.PHONY: fpc_showinstall fpc_install + +ifdef EXTRAINSTALLUNITS +override INSTALLPPUFILES+=$(addsuffix $(PPUEXT),$(EXTRAINSTALLUNITS)) +endif + +ifdef INSTALLPPUFILES +override INSTALLPPUFILES:=$(addprefix $(UNITTARGETDIRPREFIX),$(INSTALLPPUFILES)) +ifdef PPUFILES +INSTALLPPULINKFILES:=$(shell $(PPUFILES) -S -O $(INSTALLPPUFILES)) +else +INSTALLPPULINKFILES:=$(wildcard $(subst $(PPUEXT),$(OEXT),$(INSTALLPPUFILES)) $(addprefix $(LIBPREFIX),$(subst $(PPUEXT),$(STATICLIBEXT),$(INSTALLPPUFILES)))) +endif +override INSTALLPPULINKFILES:=$(addprefix $(UNITTARGETDIRPREFIX),$(INSTALLPPULINKFILES)) +endif + +ifdef INSTALLEXEFILES +override INSTALLEXEFILES:=$(addprefix $(TARGETDIRPREFIX),$(INSTALLEXEFILES)) +endif + +fpc_showinstall: $(SHOWINSTALLTARGET) +ifdef INSTALLEXEFILES + @$(ECHO) -e $(addprefix "\n"$(BININSTALLDIR)/,$(INSTALLEXEFILES)) +endif +ifdef INSTALLPPUFILES + @$(ECHO) -e $(addprefix "\n"$(UNITINSTALLDIR)/,$(INSTALLPPUFILES)) +ifneq ($(INSTALLPPULINKFILES),) + @$(ECHO) -e $(addprefix "\n"$(UNITINSTALLDIR)/,$(INSTALLPPULINKFILES)) +endif +ifneq ($(wildcard $(LIBFULLNAME)),) + @$(ECHO) $(LIBINSTALLDIR)/$(LIBFULLNAME) +ifdef HASSHAREDLIB + @$(ECHO) $(LIBINSTALLDIR)/$(LIBNAME) +endif +endif +endif +ifdef EXTRAINSTALLFILES + @$(ECHO) -e $(addprefix "\n"$(DATAINSTALLDIR)/,$(EXTRAINSTALLFILES)) +endif + +fpc_install: $(INSTALLTARGET) +# Create UnitInstallFiles +ifdef INSTALLEXEFILES + $(MKDIR) $(BININSTALLDIR) +# Compress the exes if upx is defined +ifdef UPXPROG + -$(UPXPROG) $(INSTALLEXEFILES) +endif + $(INSTALLEXE) $(INSTALLEXEFILES) $(BININSTALLDIR) +endif +ifdef INSTALLPPUFILES + $(MKDIR) $(UNITINSTALLDIR) + $(INSTALL) $(INSTALLPPUFILES) $(UNITINSTALLDIR) +ifneq ($(INSTALLPPULINKFILES),) + $(INSTALL) $(INSTALLPPULINKFILES) $(UNITINSTALLDIR) +endif +ifneq ($(wildcard $(LIBFULLNAME)),) + $(MKDIR) $(LIBINSTALLDIR) + $(INSTALL) $(LIBFULLNAME) $(LIBINSTALLDIR) +ifdef inUnix + ln -sf $(LIBFULLNAME) $(LIBINSTALLDIR)/$(LIBNAME) +endif +endif +endif +ifdef EXTRAINSTALLFILES + $(MKDIR) $(DATAINSTALLDIR) + $(INSTALL) $(EXTRAINSTALLFILES) $(DATAINSTALLDIR) +endif + +##################################################################### +# SourceInstall rules +##################################################################### + +.PHONY: fpc_sourceinstall + +ifndef SOURCETOPDIR +SOURCETOPDIR=$(BASEDIR) +endif + +fpc_sourceinstall: clean + $(MKDIR) $(SOURCEINSTALLDIR) + $(COPYTREE) $(SOURCETOPDIR) $(SOURCEINSTALLDIR) + +##################################################################### +# exampleinstall rules +##################################################################### + +.PHONY: fpc_exampleinstall + +fpc_exampleinstall: $(addsuffix _clean,$(EXAMPLEDIROBJECTS)) +ifdef EXAMPLESOURCEFILES + $(MKDIR) $(EXAMPLEINSTALLDIR) + $(COPY) $(EXAMPLESOURCEFILES) $(EXAMPLEINSTALLDIR) +endif +ifdef EXAMPLEDIROBJECTS +ifndef EXAMPLESOURCEFILES + $(MKDIR) $(EXAMPLEINSTALLDIR) +endif + $(COPYTREE) $(addsuffix /*,$(EXAMPLEDIROBJECTS)) $(EXAMPLEINSTALLDIR) +endif + +##################################################################### +# Zip +##################################################################### + +.PHONY: fpc_zipinstall + +# Create suffix to add +ifndef PACKAGESUFFIX +PACKAGESUFFIX=$(OS_TARGET) +ifeq ($(OS_TARGET),go32v2) +PACKAGESUFFIX=go32 +endif +ifeq ($(OS_TARGET),win32) +PACKAGESUFFIX=w32 +endif +endif + +# Temporary path to pack a file +ifndef PACKDIR +ifndef inUnix +PACKDIR=$(BASEDIR)/pack_tmp +else +PACKDIR=/tmp/fpc-pack +endif +endif + +# Maybe create default zipname from packagename +ifndef ZIPNAME +ifdef PACKAGENAME +ZIPNAME=$(PACKAGEPREFIX)$(PACKAGENAME)$(PACKAGESUFFIX) +endif +endif + +# Use tar by default under linux +ifndef USEZIP +ifdef inUnix +USETAR=1 +endif +endif + +fpc_zipinstall: +ifndef ZIPNAME + @$(ECHO) "Please specify ZIPNAME!" + @exit 1 +else + $(MAKE) $(ZIPTARGET) PREFIXINSTALLDIR=$(PACKDIR) +ifdef USETAR + $(DEL) $(DESTZIPDIR)/$(ZIPNAME)$(TAREXT) + cd $(PACKDIR) ; $(TARPROG) cf$(TAROPT) $(DESTZIPDIR)/$(ZIPNAME)$(TAREXT) * ; cd $(BASEDIR) +else + $(DEL) $(DESTZIPDIR)/$(ZIPNAME)$(ZIPEXT) + cd $(PACKDIR) ; $(ZIPPROG) -Dr $(ZIPOPT) $(DESTZIPDIR)/$(ZIPNAME)$(ZIPEXT) * ; cd $(BASEDIR) +endif + $(DELTREE) $(PACKDIR) +endif + +.PHONY: fpc_zipsourceinstall + +fpc_zipsourceinstall: + $(MAKE) fpc_zipinstall ZIPTARGET=sourceinstall PACKAGESUFFIX=src + +.PHONY: fpc_zipexampleinstall + +fpc_zipexampleinstall: + $(MAKE) fpc_zipinstall ZIPTARGET=exampleinstall PACKAGESUFFIX=exm + +##################################################################### +# Clean rules +##################################################################### + +.PHONY: fpc_clean fpc_cleanall fpc_distclean + +ifdef EXEFILES +override CLEANEXEFILES:=$(addprefix $(TARGETDIRPREFIX),$(CLEANEXEFILES)) +endif + +ifdef EXTRACLEANUNITS +override CLEANPPUFILES+=$(addsuffix $(PPUEXT),$(EXTRACLEANUNITS)) +endif + +ifdef CLEANPPUFILES +override CLEANPPUFILES:=$(addprefix $(UNITTARGETDIRPREFIX),$(CLEANPPUFILES)) +# Get the .o and .a files created for the units +ifdef PPUFILES +CLEANPPULINKFILES:=$(shell $(PPUFILES) $(CLEANPPUFILES)) +else +CLEANPPULINKFILES:=$(wildcard $(subst $(PPUEXT),$(OEXT),$(CLEANPPUFILES)) $(addprefix $(LIBPREFIX),$(subst $(PPUEXT),$(STATICLIBEXT),$(CLEANPPUFILES)))) +endif +override CLEANPPULINKFILES:=$(addprefix $(UNITTARGETDIRPREFIX),$(CLEANPPULINKFILES)) +endif + +fpc_clean: $(CLEANTARGET) +ifdef CLEANEXEFILES + -$(DEL) $(CLEANEXEFILES) +endif +ifdef CLEANPPUFILES + -$(DEL) $(CLEANPPUFILES) +endif +ifneq ($(CLEANPPULINKFILES),) + -$(DEL) $(CLEANPPULINKFILES) +endif +ifdef CLEANRSTFILES + -$(DEL) $(addprefix $(UNITTARGETDIRPREFIX),$(CLEANRSTFILES)) +endif +ifdef EXTRACLEANFILES + -$(DEL) $(EXTRACLEANFILES) +endif +ifdef LIBNAME + -$(DEL) $(LIBNAME) $(LIBFULLNAME) +endif + -$(DEL) $(FPCMADE) $(PPAS) link.res $(FPCEXTFILE) $(REDIRFILE) + +fpc_distclean: fpc_clean + +# Also run clean first if targetdir is set. Unittargetdir is always +# set if targetdir or unittargetdir is specified +ifdef UNITTARGETDIR +TARGETDIRCLEAN=fpc_clean +endif + +fpc_cleanall: $(CLEANTARGET) $(TARGETDIRCLEAN) +ifdef CLEANEXEFILES + -$(DEL) $(CLEANEXEFILES) +endif + -$(DEL) *$(OEXT) *$(PPUEXT) *$(RSTEXT) *$(ASMEXT) *$(STATICLIBEXT) *$(SHAREDLIBEXT) *$(PPLEXT) + -$(DELTREE) *$(SMARTEXT) + -$(DEL) $(FPCMADE) $(PPAS) link.res $(FPCEXTFILE) $(REDIRFILE) + +##################################################################### +# Info rules +##################################################################### + +.PHONY: fpc_info fpc_cfginfo fpc_objectinfo fpc_toolsinfo fpc_installinfo \ + fpc_dirinfo + +fpc_info: $(INFOTARGET) + +fpc_infocfg: + @$(ECHO) + @$(ECHO) == Configuration info == + @$(ECHO) + @$(ECHO) FPC....... $(FPC) + @$(ECHO) Version... $(FPC_VERSION) + @$(ECHO) CPU....... $(CPU_TARGET) + @$(ECHO) Source.... $(OS_SOURCE) + @$(ECHO) Target.... $(OS_TARGET) + @$(ECHO) + +fpc_infoobjects: + @$(ECHO) + @$(ECHO) == Object info == + @$(ECHO) + @$(ECHO) LoaderObjects..... $(LOADEROBJECTS) + @$(ECHO) UnitObjects....... $(UNITOBJECTS) + @$(ECHO) ExeObjects........ $(EXEOBJECTS) + @$(ECHO) + @$(ECHO) ExtraCleanUnits... $(EXTRACLEANUNITS) + @$(ECHO) ExtraCleanFiles... $(EXTRACLEANFILES) + @$(ECHO) + @$(ECHO) ExtraInstallUnits. $(EXTRAINSTALLUNITS) + @$(ECHO) ExtraInstallFiles. $(EXTRAINSTALLFILES) + @$(ECHO) + +fpc_infoinstall: + @$(ECHO) + @$(ECHO) == Install info == + @$(ECHO) +ifdef DATE + @$(ECHO) DateStr.............. $(DATESTR) +endif +ifdef PACKAGEPREFIX + @$(ECHO) PackagePrefix........ $(PACKAGEPREFIX) +endif +ifdef PACKAGENAME + @$(ECHO) PackageName.......... $(PACKAGENAME) +endif + @$(ECHO) PackageSuffix........ $(PACKAGESUFFIX) + @$(ECHO) + @$(ECHO) BaseInstallDir....... $(BASEINSTALLDIR) + @$(ECHO) BinInstallDir........ $(BININSTALLDIR) + @$(ECHO) LibInstallDir........ $(LIBINSTALLDIR) + @$(ECHO) UnitInstallDir....... $(UNITINSTALLDIR) + @$(ECHO) SourceInstallDir..... $(SOURCEINSTALLDIR) + @$(ECHO) DocInstallDir........ $(DOCINSTALLDIR) + @$(ECHO) DataInstallDir....... $(DATAINSTALLDIR) + @$(ECHO) + @$(ECHO) DestZipDir........... $(DESTZIPDIR) + @$(ECHO) ZipName.............. $(ZIPNAME) + @$(ECHO) + +##################################################################### +# Local Makefile +##################################################################### + +ifneq ($(wildcard fpcmake.loc),) +include fpcmake.loc +endif + diff --git a/examples/gui/layouttest/Makefile.fpc b/examples/gui/layouttest/Makefile.fpc new file mode 100644 index 00000000..f779ccca --- /dev/null +++ b/examples/gui/layouttest/Makefile.fpc @@ -0,0 +1,10 @@ +# +# Makefile.fpc for fpGUI LayoutTest example +# + +[targets] +programs=layouttest + +[require] +options=-S2h +packages=fcl fpgfx fpgui diff --git a/examples/gui/layouttest/boxform.frm b/examples/gui/layouttest/boxform.frm new file mode 100644 index 00000000..2e03f217 --- /dev/null +++ b/examples/gui/layouttest/boxform.frm @@ -0,0 +1,24 @@ +object BoxWindow: TBoxWindow + Text = 'Box layout' + BorderWidth = 8 + object Layout: TBoxLayout + Spacing = 8 + Orientation = Vertical + object BoxLayout: TBoxLayout + Spacing = 4 + object Button1: TButton + Text = 'Button 1' + end + object Button2: TButton + Text = 'Button 2' + end + object Button3: TButton + Text = 'Button 3' + end + end + object FlipButton: TButton + Text = 'Switch to vertical' + OnClick = FlipOrientation + end + end +end diff --git a/examples/gui/layouttest/layouttest.lpi b/examples/gui/layouttest/layouttest.lpi new file mode 100644 index 00000000..2f6d428d --- /dev/null +++ b/examples/gui/layouttest/layouttest.lpi @@ -0,0 +1,63 @@ +<?xml version="1.0"?> +<CONFIG> + <ProjectOptions> + <PathDelim Value="/"/> + <Version Value="5"/> + <General> + <Flags> + <SaveOnlyProjectUnits Value="True"/> + </Flags> + <SessionStorage Value="InProjectDir"/> + <MainUnit Value="0"/> + <IconPath Value="./"/> + <TargetFileExt Value=""/> + </General> + <PublishOptions> + <Version Value="2"/> + <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="2"> + <Item1> + <PackageName Value="LCL"/> + <MinVersion Major="1" Valid="True"/> + </Item1> + <Item2> + <PackageName Value="fpGUI_laz"/> + </Item2> + </RequiredPackages> + <Units Count="1"> + <Unit0> + <Filename Value="layouttest.pas"/> + <IsPartOfProject Value="True"/> + <UnitName Value="LayoutTest"/> + </Unit0> + </Units> + </ProjectOptions> + <CompilerOptions> + <Version Value="5"/> + <SearchPaths> + <SrcPath Value="../../src/"/> + </SearchPaths> + <Parsing> + <SyntaxOptions> + <AllowLabel Value="False"/> + </SyntaxOptions> + </Parsing> + <CodeGeneration> + <Generate Value="Faster"/> + </CodeGeneration> + <Other> + <CustomOptions Value="-FUunits +"/> + <CompilerPath Value="$(CompPath)"/> + </Other> + </CompilerOptions> +</CONFIG> diff --git a/examples/gui/layouttest/layouttest.pas b/examples/gui/layouttest/layouttest.pas new file mode 100644 index 00000000..6cf90662 --- /dev/null +++ b/examples/gui/layouttest/layouttest.pas @@ -0,0 +1,294 @@ +program LayoutTest; + +uses Classes, fpGUI; + +type + TDockingForm = class; + TGridForm = class; + TBoxForm = class; + TSimpleForm = class; + + { TMainForm } + + TMainForm = class(TForm) + private + DockingForm: TDockingForm; + GridForm: TGridForm; + BoxForm: TBoxForm; + SimpleForm: TSimpleForm; + public + destructor Destroy; override; + published + Box: TBoxLayout; + Title: TLabel; + SimpleBtn, FixedBtn, BoxBtn, GridBtn, DockingBtn, ExitBtn: TButton; + //Separator: TSeparator; + procedure SimpleBtnClicked(Sender: TObject); + procedure FixedBtnClicked(Sender: TObject); + procedure DockingBtnClicked(Sender: TObject); + procedure GridBtnClicked(Sender: TObject); + procedure BoxBtnClicked(Sender: TObject); + procedure ExitBtnClicked(Sender: TObject); + end; + + TSimpleForm = class(TForm) + Button: TButton; + public + constructor Create(AOwner: TComponent); override; + end; + +{ TFixedForm = class(TForm) + Layout: TFixedLayout; + Button1, Button2: TButton; + public + constructor Create(AOwner: TComponent); override; + end; } + + TDockingForm = Class(TForm) + Layout : TDockingLayout; + Button1,Button2,Button3,Button4,Button5 : TButton; + public + constructor Create(AOwner: TComponent); override; + end; + + + TGridForm = Class(TForm) + Layout : TGridLayout; + Button1,Button2,Button3,Button4,Button5, Button6 : TButton; + public + constructor Create(AOwner: TComponent); override; + end; + + TBoxForm = Class(TForm) + Layout, BoxLayout: TBoxLayout; + Button1, Button2, Button3, FlipButton: TButton; + procedure FlipOrientation(Sender: TObject); + end; + + +// ------------------------------------------------------------------- +// TMainForm +// ------------------------------------------------------------------- + +destructor TMainForm.Destroy; +begin + GridForm.Free; + BoxForm.Free; + DockingForm.Free; + SimpleForm.Free; + inherited Destroy; +end; + + +procedure TMainForm.SimpleBtnClicked(Sender: TObject); +begin + if not Assigned(SimpleForm) then + SimpleForm := TSimpleForm.Create(self); + SimpleForm.Show; +end; + + +procedure TMainForm.FixedBtnClicked(Sender: TObject); +begin +// Application.AddForm(TFixedForm.Create(Application)); +end; + + +procedure TMainForm.DockingBtnClicked(Sender: TObject); +begin + Exit; //==> + +{ if not Assigned(DockingForm) then + DockingForm := TDockingForm.Create(self); + DockingForm.Show; +} + Application.AddForm(TDockingForm.Create(self)); +end; + + +procedure TMainForm.GridBtnClicked(Sender: TObject); +var + f, f2: TStream; +begin + if not Assigned(GridForm) then + GridForm := TGridForm.Create(self); + GridForm.Show; + { Output the structure of GridForm.Layout } + f := TMemoryStream.Create; + f.WriteComponent(GridForm.Layout); + f2 := THandleStream.Create(StdOutputHandle); + f.Position := 0; + ObjectBinaryToText(f, f2); + f2.Free; + f.Free; +end; + + +procedure TMainForm.BoxBtnClicked(Sender: TObject); +begin + if not Assigned(BoxForm) then + Application.CreateForm(TBoxForm, BoxForm); + BoxForm.Show; +end; + + +procedure TMainForm.ExitBtnClicked(Sender: TObject); +begin + Close; +end; + + +// ------------------------------------------------------------------- +// TSimpleForm +// ------------------------------------------------------------------- + +constructor TSimpleForm.Create(AOwner: TComponent); +begin + inherited Create(AOwner); + + Text := 'Simple Layout'; + BorderWidth := 8; + + Button := TButton.Create(Self); + Button.Text := 'A button...'; + Child := Button; +end; + + +// ------------------------------------------------------------------- +// TFixedForm +// ------------------------------------------------------------------- +{ +constructor TFixedForm.Create(AOwner: TComponent); +begin + inherited Create(AOwner); + + Text := 'Fixed Layout'; + BorderWidth := 8; + + Layout := TFixedLayout.Create(Self); + Layout.Name := 'Layout'; + Button1 := TButton.Create(Self); + Button1.Name := 'Button1'; + Button1.Text := 'A button'; + Layout.AddControl(Button1, 20, 20); + Button2 := TButton.Create(Self); + Button2.Name := 'Button2'; + Button2.Text := 'Another button'; + Layout.AddControl(Button2, 50, 100); + Child := Layout; +end; + +} +// ------------------------------------------------------------------- +// TDockingForm +// ------------------------------------------------------------------- + + +constructor TDockingForm.Create(AOwner: TComponent); +begin + inherited Create(AOwner); + + Text := 'Docking Layout'; + BorderWidth := 8; + + Layout := TDockingLayout.Create(Self); + Layout.Name := 'Layout'; + Button1 := TButton.Create(Self); + Button1.Name := 'BTop'; + Button1.Text := 'Top Alignment'; + Layout.AddWidget(Button1, dmTop); + Button2 := TButton.Create(Self); + Button2.Name := 'BBottom'; + Button2.Text := 'Bottom Alignment'; + Layout.AddWidget(Button2, dmBottom); + Button3 := TButton.Create(Self); + Button3.Name := 'BLeft'; + Button3.Text := 'Left Alignment'; + Layout.AddWidget(Button3, dmLeft); + Button4 := TButton.Create(Self); + Button4.Name := 'BRight'; + Button4.Text := 'Right Alignment'; + Layout.AddWidget(Button4, dmRight); + Button5 := TButton.Create(Self); + Button5.Name := 'BCLient'; + Button5.Text := 'Client Alignment'; + Layout.AddWidget(Button5, dmClient); + Child := Layout; +end; + + +// ------------------------------------------------------------------- +// TGridForm +// ------------------------------------------------------------------- + +constructor TGridForm.Create(AOwner: TComponent); +begin + inherited Create(AOwner); + + Text := 'Grid Layout'; + BorderWidth := 8; + + Layout := TGridLayout.Create(Self); + Layout.Name := 'Layout'; + Layout.RowCount := 4; + Layout.ColCount := 3; + + Button1 := TButton.Create(Self); + Button1.Name := 'TopLeft'; + Button1.Text := 'Top Left'; + Layout.AddWidget(Button1, 0, 0, 1, 1); + Button2 := TButton.Create(Self); + Button2.Name := 'TopRight'; + Button2.Text := 'Top Right'; + Layout.AddWidget(Button2, 2,0,1,1); + Button3 := TButton.Create(Self); + Button3.Name := 'CenterCenter'; + Button3.Text := 'Center Center'; + // Button3.CanExpandWidth := False; + // Button3.CanExpandHeight := False; + Layout.AddWidget(Button3, 1,1,1,1); + Button4 := TButton.Create(Self); + Button4.Name := 'BottomLeft'; + Button4.Text := 'Bottom Left'; + Layout.AddWidget(Button4,0,2,1,1); + Button5 := TButton.Create(Self); + Button5.Name := 'BottomRight'; + Button5.Text := 'Bottom Right'; + Layout.AddWidget(Button5, 2,2,1,1); + Button6 := TButton.Create(Self); + Button6.Name := 'BottomSpan'; + Button6.Text := 'Span Columns'; + Layout.AddWidget(Button6, 0,3,3,1); + Child := Layout; +end; + + +// ------------------------------------------------------------------- +// TBoxForm +// ------------------------------------------------------------------- + +procedure TBoxForm.FlipOrientation (Sender : TObject); +begin + with BoxLayout do + if Orientation = Horizontal then + begin + Orientation := Vertical; + FlipButton.Text:='Switch to horizontal'; + end + else + begin + Orientation := Horizontal; + FlipButton.text:='Switch to vertical'; + end; +end; + + +var + MainForm: TMainForm; +begin + MainForm := nil; + Application.CreateForm(TMainForm, MainForm); + Application.Run; + MainForm.Free; +end. diff --git a/examples/gui/layouttest/mainform.frm b/examples/gui/layouttest/mainform.frm new file mode 100644 index 00000000..ecad852b --- /dev/null +++ b/examples/gui/layouttest/mainform.frm @@ -0,0 +1,33 @@ +object MainWindow: TMainWindow + BorderWidth = 8 + object Box: TBoxLayout + Spacing = 8 + Orientation = Vertical + object Label: TLabel + Text = 'Choose a test Window:' + end + object SimpleBtn: TButton + Text = 'Simple layout' + OnClick = SimpleBtnClicked + end + object FixedBtn: TButton + Text = 'Fixed layout' + end + object BoxBtn: TButton + Text = 'Box layout' + OnClick = BoxBtnClicked + end + object GridBtn: TButton + Text = 'Grid layout' + OnClick = GridBtnClicked + end + object DockingBtn: TButton + Text = 'Docking layout' + OnClick = DockingBtnClicked + end + object ExitBtn: TButton + Text = 'Exit' + OnClick = ExitBtnClicked + end + end +end diff --git a/examples/gui/layouttest/simpleform.frm b/examples/gui/layouttest/simpleform.frm new file mode 100644 index 00000000..390106f0 --- /dev/null +++ b/examples/gui/layouttest/simpleform.frm @@ -0,0 +1,7 @@ +object SimpleWindow: TSimpleWindow + Text = 'Simple layout' + BorderWidth = 8 + object Button: TButton + Text = 'A button...' + end +end diff --git a/examples/gui/utfdemo/test.pas b/examples/gui/utfdemo/test.pas new file mode 100644 index 00000000..6c551cb1 --- /dev/null +++ b/examples/gui/utfdemo/test.pas @@ -0,0 +1,4 @@ +╔══════════════╕ +╠══════════════╡ +║ │ +╚══════════════╛ diff --git a/examples/gui/utfdemo/utfdemo.lpi b/examples/gui/utfdemo/utfdemo.lpi new file mode 100644 index 00000000..aa97adce --- /dev/null +++ b/examples/gui/utfdemo/utfdemo.lpi @@ -0,0 +1,49 @@ +<?xml version="1.0"?> +<CONFIG> + <ProjectOptions> + <PathDelim Value="/"/> + <Version Value="5"/> + <General> + <Flags> + <SaveOnlyProjectUnits Value="True"/> + </Flags> + <SessionStorage Value="InProjectDir"/> + <MainUnit Value="0"/> + <IconPath Value="./"/> + <TargetFileExt Value=".exe"/> + </General> + <PublishOptions> + <Version Value="2"/> + <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_laz"/> + <MinVersion Minor="3" Valid="True"/> + </Item1> + </RequiredPackages> + <Units Count="1"> + <Unit0> + <Filename Value="utfdemo.lpr"/> + <IsPartOfProject Value="True"/> + <UnitName Value="utfdemo"/> + </Unit0> + </Units> + </ProjectOptions> + <CompilerOptions> + <Version Value="5"/> + <CodeGeneration> + <Generate Value="Faster"/> + </CodeGeneration> + <Other> + <CompilerPath Value="$(CompPath)"/> + </Other> + </CompilerOptions> +</CONFIG> diff --git a/examples/gui/utfdemo/utfdemo.lpr b/examples/gui/utfdemo/utfdemo.lpr new file mode 100644 index 00000000..3d047bec --- /dev/null +++ b/examples/gui/utfdemo/utfdemo.lpr @@ -0,0 +1,71 @@ +program utfdemo; + +{$mode objfpc}{$H+} + +uses + {$IFDEF UNIX}{$IFDEF UseCThreads} + cthreads, + {$ENDIF}{$ENDIF} + Classes, + gfxbase, + fpgui, fpGUI_laz; + +type + + { TMainForm } + + TMainForm = class(TForm) + private + FLayout: TBoxLayout; + procedure MainFormActivate(Sender: TObject); + public + constructor Create(AOwner: TComponent); override; + published + TextLabel: TLabel; + end; + + +{ TMainForm } + +procedure TMainForm.MainFormActivate(Sender: TObject); +var + max: TSize; +begin + max.cx := 320; + max.cy := 200; + Wnd.SetMinMaxClientSize(MinSize, max); +end; + + +constructor TMainForm.Create(AOwner: TComponent); +begin + inherited Create(AOwner); + Name := 'frmMain'; + BorderWidth := 8; +// WindowType := wtWindow; + Text := 'UTF Demo'; + OnActivate := @MainFormActivate; + + FLayout := TBoxLayout.Create(self); + FLayout.Parent := self; + InsertChild(FLayout); + + TextLabel := TLabel.Create(self); + TextLabel.Text := '&Gráficas Magnificacion! Teste'; + FLayout.InsertChild(TextLabel); +end; + + +var + MainForm: TMainForm; +begin + MainForm := TMainForm.Create(Application); + try + MainForm.Show; + Application.Run; + finally + MainForm.Free; + end; +end. + + diff --git a/examples/gui/widgetdemo/OpenSoftStyle.pas b/examples/gui/widgetdemo/OpenSoftStyle.pas new file mode 100644 index 00000000..d0bb2b12 --- /dev/null +++ b/examples/gui/widgetdemo/OpenSoftStyle.pas @@ -0,0 +1,137 @@ +unit OpenSoftStyle; + +{$mode objfpc}{$H+} + +interface + +uses + Classes, fpgui, gfxbase; + +type + + { TOpenSoftStyle } + + TOpenSoftStyle = class(TDefaultStyle) + public + // Colors + function GetGUIColor(Color: TColor): TGfxColor; override; + // Buttons (todo) +// procedure DrawButtonFace(Canvas: TGfxCanvas; const ARect: TRect; Flags: TButtonFlags); override; + // GroupBox + procedure DrawGroupBox(Canvas: TGfxCanvas; const ARect: TRect; const ALabel: String; WidgetState: TWidgetState); override; + end; + + +var + FOpenSoftStyle: TOpenSoftStyle; + +implementation + + +const + // Some predefined colors: + rgbaDkBlue: TGfxColor = (Red: $0000; Green: $0000; Blue: $8000; Alpha: $0000); + rgbaLtYellow: TGfxColor = (Red: $ffff; Green: $ffff; Blue: $e100; Alpha: $0000); + + rgbaWindowText: TGfxColor = (Red: $0000; Green: $0000; Blue: $0000; Alpha: $0000); + rgbaWindow: TGfxColor = (Red: $efef; Green: $efef; Blue: $efef; Alpha: $0000); + rgbaDkGrey: TGfxColor = (Red: $8686; Green: $8686; Blue: $8686; Alpha: $0000); + rgbaGbAALtGrey: TGfxColor = (Red: $baba; Green: $baba; Blue: $baba; Alpha: $0000); + rgbaGbAADkGrey: TGfxColor = (Red: $7878; Green: $7878; Blue: $7878; Alpha: $0000); + + +{ TOpenSoftStyle } + +function TOpenSoftStyle.GetGUIColor(Color: TColor): TGfxColor; +begin + Result := inherited GetGUIColor(Color); + case Color of + // UI element colors + clScrollBar: Result := rgbaWindow; + clMenu: Result := rgbaWindow; +// clWindow: Result := GetUIColor(clWhite); +// clMenuText: Result := GetUIColor(clBlack); +// clWindowText: Result := GetUIColor(clBlack); +// clAppWorkSpace: Result := GetUIColor(clGray); +// clHighlight: Result := GetUIColor(clNavy); +// clHighlightText: Result := GetUIColor(clWhite); + cl3DFace: Result := rgbaWindow; +// cl3DShadow: Result := rgbaDkWhite; +// clGrayText: Result := GetUIColor(clGray); +// clBtnText: Result := GetUIColor(clBlack); +// cl3DHighlight: Result := GetUIColor(clWhite); + cl3DDkShadow: Result := GetUIColor(clMidnightBlue); +// cl3DLight: Result := GetUIColor(clDarkWhite); +// clInfoText: Result := GetUIColor(clBlack); +// clInfoBk: Result := GetUIColor(clLightYellow); +// +// else Result := GetUIColor(clWhite); + end; + +end; + + +procedure TOpenSoftStyle.DrawGroupBox(Canvas: TGfxCanvas; const ARect: TRect; + const ALabel: String; WidgetState: TWidgetState); +var + TitleWidth, TitleHeight, TopLine: Integer; +begin + TitleWidth := Canvas.TextWidth(ALabel); + TitleHeight := Canvas.FontCellHeight; + TopLine := ARect.Top + TitleHeight div 3; + + Canvas.SetColor(rgbaDkGrey); + // box outline + with ARect do + begin + // top + Canvas.DrawLine(Point(Left + 2, TopLine), Point(Left + 12, TopLine)); + Canvas.DrawLine(Point(Left + TitleWidth + 16, TopLine), Point(Right - 2, TopLine)); + // right + Canvas.DrawLine(Point(Right-1, TopLine + 2), Point(Right-1, Bottom - 2)); + // bottom + Canvas.DrawLine(Point(Right - 3, Bottom-1), Point(Left + 1, Bottom-1)); + // left + Canvas.DrawLine(Point(Left, Bottom - 3), Point(Left, TopLine + 1)); + end; + + // Text caption + SetUIColor(Canvas, clWindowText); + DrawText(Canvas, ARect.TopLeft + Point(14, 0), ALabel, WidgetState); + + { Anti-Aliasing - Top/Left } + Canvas.SetColor(rgbaGbAALtGrey); + Canvas.DrawPoint(ARect.TopLeft + Point(0, TopLine+1)); + Canvas.DrawPoint(ARect.TopLeft + Point(1, TopLine)); + Canvas.SetColor(rgbaGbAADkGrey); + Canvas.DrawPoint(ARect.TopLeft + Point(1, TopLine+1)); + { Anti-Aliasing - Top/Right } + Canvas.SetColor(rgbaGbAALtGrey); + Canvas.DrawPoint(ARect.TopLeft + Point(ARect.Right-1, TopLine+1)); + Canvas.DrawPoint(ARect.TopLeft + Point(ARect.Right-2, TopLine)); + Canvas.SetColor(rgbaGbAADkGrey); + Canvas.DrawPoint(ARect.TopLeft + Point(ARect.Right-2, TopLine+1)); + { Anti-Aliasing - Bottom/Right } + Canvas.SetColor(rgbaGbAALtGrey); + Canvas.DrawPoint(ARect.TopLeft + Point(ARect.Right-1, ARect.Bottom-2)); + Canvas.DrawPoint(ARect.TopLeft + Point(ARect.Right-2, ARect.Bottom-1)); + Canvas.SetColor(rgbaGbAADkGrey); + Canvas.DrawPoint(ARect.TopLeft + Point(ARect.Right-2, ARect.Bottom-2)); + { Anti-Aliasing - Bottom/Left } + Canvas.SetColor(rgbaGbAALtGrey); + Canvas.DrawPoint(ARect.TopLeft + Point(0, ARect.Bottom-2)); + Canvas.DrawPoint(ARect.TopLeft + Point(1, ARect.Bottom-1)); + Canvas.SetColor(rgbaGbAADkGrey); + Canvas.DrawPoint(ARect.TopLeft + Point(1, ARect.Bottom-2)); +end; + + +initialization + FOpenSoftStyle := TOpenSoftStyle.Create(Application.Display); + +finalization + if Assigned(FOpenSoftStyle) then + FOpenSoftStyle.Free; + +end. + diff --git a/examples/gui/widgetdemo/WidgetDemo.lpi b/examples/gui/widgetdemo/WidgetDemo.lpi new file mode 100644 index 00000000..b4f7bb7d --- /dev/null +++ b/examples/gui/widgetdemo/WidgetDemo.lpi @@ -0,0 +1,71 @@ +<?xml version="1.0"?> +<CONFIG> + <ProjectOptions> + <PathDelim Value="/"/> + <Version Value="5"/> + <General> + <Flags> + <SaveOnlyProjectUnits Value="True"/> + </Flags> + <SessionStorage Value="InProjectDir"/> + <MainUnit Value="0"/> + <IconPath Value="./"/> + <TargetFileExt Value=""/> + </General> + <PublishOptions> + <Version Value="2"/> + <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_laz"/> + </Item1> + </RequiredPackages> + <Units Count="4"> + <Unit0> + <Filename Value="WidgetDemo.lpr"/> + <IsPartOfProject Value="True"/> + <UnitName Value="WidgetDemo"/> + </Unit0> + <Unit1> + <Filename Value="OpenSoftStyle.pas"/> + <IsPartOfProject Value="True"/> + <UnitName Value="OpenSoftStyle"/> + </Unit1> + <Unit2> + <Filename Value="../../src/fpgui.pp"/> + <IsPartOfProject Value="True"/> + <UnitName Value="fpGUI"/> + </Unit2> + <Unit3> + <Filename Value="../../../fpGFX/src/gfxbase.pp"/> + <IsPartOfProject Value="True"/> + <UnitName Value="GfxBase"/> + </Unit3> + </Units> + </ProjectOptions> + <CompilerOptions> + <Version Value="5"/> + <Parsing> + <SyntaxOptions> + <IncludeAssertionCode Value="True"/> + <AllowLabel Value="False"/> + </SyntaxOptions> + </Parsing> + <CodeGeneration> + <Generate Value="Faster"/> + </CodeGeneration> + <Other> + <CustomOptions Value="-FUunits +"/> + <CompilerPath Value="$(CompPath)"/> + </Other> + </CompilerOptions> +</CONFIG> diff --git a/examples/gui/widgetdemo/WidgetDemo.lpr b/examples/gui/widgetdemo/WidgetDemo.lpr new file mode 100644 index 00000000..391a412f --- /dev/null +++ b/examples/gui/widgetdemo/WidgetDemo.lpr @@ -0,0 +1,360 @@ +program WidgetDemo; + +{$mode objfpc}{$H+} + +uses + {$IFDEF UNIX}{$IFDEF UseCThreads} + cthreads, + {$ENDIF}{$ENDIF} + Classes + ,SysUtils + ,fpgui + ,OpenSoftStyle + ,gfxbase + ; + +type + + { TWidgetDemoForm } + + TWidgetDemoForm = class(TForm) + topLayout: TBoxLayout; + mainLayout: TGridLayout; + MainMenu: TMenuBar; + + topStyleComboLayout: TBoxLayout; + lblStyle: TLabel; + cbStyle: TComboBox; + + topCheckboxLayout: TBoxLayout; + chkStdPalette: TCheckBox; + chkDisable: TCheckBox; + + topLeftGroupBox: TGroupBox; + topLeftGroupBoxLayout: TBoxLayout; + Radio1: TRadioButton; + Radio2: TRadioButton; + Radio3: TRadioButton; + + topRightGroupBox: TGroupBox; + topRightGroupBoxLayout: TBoxLayout; + Button1: TButton; + Button2: TButton; + + StringGrid: TStringGrid; + + bottomRightGroupBox: TGroupBox; + bottomRightGroupBoxLayout: TBoxLayout; + Edit1: TEdit; + Edit2: TEdit; + + bottomButtonLayout: TBoxLayout; + btnExit: TButton; + btnHelp: TButton; + + procedure btnExitClick(Sender: TObject); + procedure Radio1Click(Sender: TObject); + procedure Radio2Click(Sender: TObject); + procedure cbStyleChanged(Sender: TObject); + procedure TranslateToAfrikaans; + procedure TranslateToEnglish; + procedure chkDisableClick(Sender: TObject); + private + procedure CreateTopMenu; + procedure CreateStyleCombo; + procedure CreateTopCheckboxLine; + procedure CreateTopLeftGroupBox; + procedure CreateTopRightGroupBox; + procedure CreateBottomLeftStringGrid; + procedure CreateBottomRightGroupBox; + procedure CreateBottomButtonLayout; + public + constructor Create(AOwner: TComponent); override; + end; + + +{ TWidgetDemoForm } + +procedure TWidgetDemoForm.btnExitClick(Sender: TObject); +begin + Close; +end; + +procedure TWidgetDemoForm.Radio1Click(Sender: TObject); +begin + TranslateToEnglish; +end; + +procedure TWidgetDemoForm.Radio2Click(Sender: TObject); +begin + TranslateToAfrikaans; +end; + +procedure TWidgetDemoForm.cbStyleChanged(Sender: TObject); +begin + if cbStyle.Text = 'OpenSoft' then + begin + if self.Style is TOpenSoftStyle then + exit //==> + else + begin + Style := TOpenSoftStyle.Create(Application.Display); + Redraw; + end; + end + else + begin + if self.Style is TDefaultStyle then + exit //==> + else + begin + Style := Application.DefaultStyle; + Redraw; + end; + end; +end; + +procedure TWidgetDemoForm.TranslateToAfrikaans; +begin + Text := 'Widget Demo - Afrikaans'; + lblStyle.Text := 'Venster Steil:'; + chkStdPalette.Text := 'Standaard kleur tablette'; + chkDisable.Text := 'Ge-deaktiveerde controles'; + topLeftGroupBox.Text := 'Groep Boks Een'; + Radio1.Text := 'Radio knoppie een'; + Radio2.Text := 'Radio knoppie twee'; + Radio3.Text := 'Radio knoppie drie'; + topLeftGroupBox.Text := 'Groep Boks Twee'; + Button1.Text := 'Normal Button'; + Button2.Text := 'Embedded Button'; + bottomRightGroupBox.Text := 'Group Boks Drie'; + Edit1.Text := 'Normale teks'; + Edit2.Text := 'Wagwoord teks'; + btnExit.Text := 'Verlaat Verlaat'; + btnHelp.Text := 'Hulp'; + Redraw; +end; + +procedure TWidgetDemoForm.TranslateToEnglish; +begin + Text := 'Widget Demo - English'; + lblStyle.Text := 'Style:'; + chkStdPalette.Text := 'Standard color palette'; + chkDisable.Text := 'Disable widgets'; + topLeftGroupBox.Text := 'Group Box 1'; + Radio1.Text := 'Radio button 1'; + Radio2.Text := 'Radio button 2'; + Radio3.Text := 'Radio button 3'; + topRightGroupBox.Text := 'Group Box 2'; + Button1.Text := 'Normal Button'; + Button2.Text := 'Embedded Button'; + bottomRightGroupBox.Text := 'Group Box 3'; + Edit1.Text := 'Normal Edit'; + Edit2.Text := 'Password Edit'; + btnExit.Text := 'Exit'; + btnHelp.Text := 'Help'; + Redraw; +end; + +procedure TWidgetDemoForm.chkDisableClick(Sender: TObject); +begin + lblStyle.Enabled := not chkDisable.Checked; + cbStyle.Enabled := not chkDisable.Checked; + chkStdPalette.Enabled := not chkDisable.Checked; + topLeftGroupBox.Enabled := not chkDisable.Checked; + topRightGroupBox.Enabled := not chkDisable.Checked; + StringGrid.Enabled := not chkDisable.Checked; + bottomRightGroupBox.Enabled := not chkDisable.Checked; +end; + +procedure TWidgetDemoForm.CreateTopMenu; +begin + MainMenu := TMenuBar.Create(self); + MainMenu.AddMenu('File'); + MainMenu.AddMenu('Edit'); + MainMenu.AddMenu('Options'); + MainMenu.AddMenu('Windows'); + MainMenu.AddMenu('Help'); +// MainMenu.CanExpandWidth := True; +end; + +procedure TWidgetDemoForm.CreateStyleCombo; +begin + topStyleComboLayout := TBoxLayout.Create(self); + + lblStyle := TLabel.Create('Style:', self); + + cbStyle := TComboBox.Create(self); + cbStyle.CanExpandWidth := True; + cbStyle.Items.Add('Windows'); + cbStyle.Items.Add('WindowsXP'); + cbStyle.Items.Add('Motif'); + cbStyle.Items.Add('ClearLooks'); + cbStyle.Items.Add('OpenSoft'); + cbStyle.OnChange := @cbStyleChanged; + cbStyle.ItemIndex := 0; + + topStyleComboLayout.InsertChild(lblStyle); + topStyleComboLayout.InsertChild(cbStyle); +end; + +procedure TWidgetDemoForm.CreateTopCheckboxLine; +begin + topCheckboxLayout := TBoxLayout.Create(self); + + chkStdPalette := TCheckBox.Create('Standard color palette', self); + chkStdPalette.CanExpandWidth := True; + chkStdPalette.Checked := True; + + chkDisable := TCheckBox.Create('Disable widgets', self); + chkDisable.OnClick :=@chkDisableClick; + + topCheckboxLayout.InsertChild(chkStdPalette); + topCheckboxLayout.InsertChild(chkDisable); +end; + +procedure TWidgetDemoForm.CreateTopLeftGroupBox; +begin + topLeftGroupBox := TGroupBox.Create('Group Box 1', self); + topLeftGroupBox.CanExpandWidth := True; + + topLeftGroupBoxLayout := TBoxLayout.Create(self); + topLeftGroupBoxLayout.Orientation := Vertical; + + Radio1 := TRadioButton.Create('Radio button 1', self); + Radio1.Checked := True; + Radio1.CanExpandWidth := True; + Radio1.OnClick := @Radio1Click; + + Radio2 := TRadioButton.Create('Radio button 2', self); + Radio2.CanExpandWidth := True; + Radio2.OnClick := @Radio2Click; + + Radio3 := TRadioButton.Create('Radio button 3', self); + Radio3.CanExpandWidth := True; + + topLeftGroupBox.InsertChild(topLeftGroupBoxLayout); + topLeftGroupBoxLayout.InsertChild(Radio1); + topLeftGroupBoxLayout.InsertChild(Radio2); + topLeftGroupBoxLayout.InsertChild(Radio3); +end; + +procedure TWidgetDemoForm.CreateTopRightGroupBox; +begin + topRightGroupBox := TGroupBox.Create('Group Box 2', self); + topRightGroupBox.CanExpandWidth := True; + topRightGroupBox.CanExpandHeight := True; + + topRightGroupBoxLayout := TBoxLayout.Create(self); + topRightGroupBoxLayout.Orientation := Vertical; + topRightGroupBoxLayout.VertAlign := vertCenter; + topRightGroupBoxLayout.Spacing := 8; + + Button1 := TButton.Create('Normal Button', self); + Button1.CanExpandWidth := True; + + Button2 := TButton.Create('Embedded Button', self); + Button2.CanExpandWidth := True; + Button2.Embedded := True; + + topRightGroupBox.InsertChild(topRightGroupBoxLayout); + topRightGroupBoxLayout.InsertChild(Button1); + topRightGroupBoxLayout.InsertChild(Button2); +end; + +procedure TWidgetDemoForm.CreateBottomLeftStringGrid; +var + x, y: integer; +begin + StringGrid := TStringGrid.Create(self); + StringGrid.ColCount := 10; + StringGrid.RowCount := 15; + for y := 0 to StringGrid.RowCount - 1 do + for x := 0 to StringGrid.ColCount - 1 do + StringGrid.Cells[x, y] := Format('%d, %d', [x, y]); +end; + +procedure TWidgetDemoForm.CreateBottomRightGroupBox; +begin + bottomRightGroupBox := TGroupBox.Create('Group Box 3', self); + bottomRightGroupBox.CanExpandHeight := True; + bottomRightGroupBox.CanExpandWidth := True; + + bottomRightGroupBoxLayout := TBoxLayout.Create(self); + bottomRightGroupBoxLayout.Orientation := Vertical; + + Edit1 := TEdit.Create('Normal Edit', self); + Edit2 := TEdit.Create('Password Edit', self); + Edit2.PasswordChar := '*'; + + bottomRightGroupBox.InsertChild(bottomRightGroupBoxLayout); + bottomRightGroupBoxLayout.InsertChild(Edit1); + bottomRightGroupBoxLayout.InsertChild(Edit2); +end; + +procedure TWidgetDemoForm.CreateBottomButtonLayout; +begin + bottomButtonLayout := TBoxLayout.Create(self); + bottomButtonLayout.HorzAlign := horzRight; + + btnHelp := TButton.Create('Help', self); + + btnExit := TButton.Create('Exit', self); + btnExit.OnClick := @btnExitClick; + + bottomButtonLayout.InsertChild(btnHelp); + bottomButtonLayout.InsertChild(btnExit); +end; + +constructor TWidgetDemoForm.Create(AOwner: TComponent); +begin + inherited Create(AOwner); + Text := 'Widget Demo'; + BorderWidth := 8; +// WindowType := wtWindow; + + topLayout := TBoxLayout.Create(self); + topLayout.Orientation := Vertical; + mainLayout := TGridLayout.Create(self); + mainLayout.RowCount := 2; + + CreateTopMenu; + topLayout.InsertChild(MainMenu); + + CreateStyleCombo; + topLayout.InsertChild(topStyleComboLayout); + + CreateTopCheckboxLine; + topLayout.InsertChild(topCheckboxLayout); + + CreateTopLeftGroupBox; + mainLayout.AddWidget(topLeftGroupBox, 0, 0, 1, 1); + + CreateTopRightGroupBox; + mainLayout.AddWidget(topRightGroupBox, 1, 0, 1, 1); + + CreateBottomLeftStringGrid; + mainLayout.AddWidget(StringGrid, 0, 1, 1, 1); + + CreateBottomRightGroupBox; + mainLayout.AddWidget(bottomRightGroupBox, 1, 1, 1, 1); + + topLayout.InsertChild(mainLayout); + + CreateBottomButtonLayout; + topLayout.InsertChild(bottomButtonLayout); + + Child := topLayout; +end; + + +var + WidgetDemoForm: TWidgetDemoForm; + +begin + WidgetDemoForm := TWidgetDemoForm.Create(nil); + Application.AddForm(WidgetDemoForm); + Application.Run; + WidgetDemoForm.Free; +end. + diff --git a/examples/gui/widgettest/Makefile b/examples/gui/widgettest/Makefile new file mode 100644 index 00000000..2c9fa63e --- /dev/null +++ b/examples/gui/widgettest/Makefile @@ -0,0 +1,1320 @@ +# +# Makefile generated by fpcmake v1.00 [2000/12/14] +# + +defaultrule: all + +##################################################################### +# Autodetect OS (Linux or Dos or Windows NT) +# define inUnix when running under Unix (Linux,FreeBSD) +# define inWinNT when running under WinNT +##################################################################### + +# We need only / in the path +override PATH:=$(subst \,/,$(PATH)) + +# Search for PWD and determine also if we are under linux +PWD:=$(strip $(wildcard $(addsuffix /pwd.exe,$(subst ;, ,$(PATH))))) +ifeq ($(PWD),) +PWD:=$(strip $(wildcard $(addsuffix /pwd,$(subst :, ,$(PATH))))) +ifeq ($(PWD),) +nopwd: + @echo You need the GNU utils package to use this Makefile! + @echo Get ftp://ftp.freepascal.org/pub/fpc/dist/go32v2/utilgo32.zip + @exit +else +inUnix=1 +endif +else +PWD:=$(firstword $(PWD)) +endif + +# Detect NT - NT sets OS to Windows_NT +# Detect OS/2 - OS/2 has OS2_SHELL defined +ifndef inUnix +ifeq ($(OS),Windows_NT) +inWinNT=1 +else +ifdef OS2_SHELL +inOS2=1 +endif +endif +endif + +# The extension of executables +ifdef inUnix +SRCEXEEXT= +else +SRCEXEEXT=.exe +endif + +# The path which is searched separated by spaces +ifdef inUnix +SEARCHPATH=$(subst :, ,$(PATH)) +else +SEARCHPATH=$(subst ;, ,$(PATH)) +endif + +# Base dir +ifdef PWD +BASEDIR:=$(shell $(PWD)) +else +BASEDIR=. +endif + +##################################################################### +# FPC version/target Detection +##################################################################### + +# What compiler to use ? +ifndef FPC +# Compatibility with old makefiles +ifdef PP +FPC=$(PP) +else +FPC=ppc386 +endif +endif +override FPC:=$(subst $(SRCEXEEXT),,$(FPC)) +override FPC:=$(subst \,/,$(FPC))$(SRCEXEEXT) + +# Target OS +ifndef OS_TARGET +OS_TARGET:=$(shell $(FPC) -iTO) +endif + +# Source OS +ifndef OS_SOURCE +OS_SOURCE:=$(shell $(FPC) -iSO) +endif + +# Target CPU +ifndef CPU_TARGET +CPU_TARGET:=$(shell $(FPC) -iTP) +endif + +# Source CPU +ifndef CPU_SOURCE +CPU_SOURCE:=$(shell $(FPC) -iSP) +endif + +# FPC version +ifndef FPC_VERSION +FPC_VERSION:=$(shell $(FPC) -iV) +endif + +export FPC OS_TARGET OS_SOURCE CPU_TARGET CPU_SOURCE FPC_VERSION FPCOPT + +##################################################################### +# FPCDIR Setting +##################################################################### + +# Test FPCDIR to look if the RTL dir exists +ifdef FPCDIR +override FPCDIR:=$(subst \,/,$(FPCDIR)) +ifeq ($(wildcard $(FPCDIR)/rtl),) +ifeq ($(wildcard $(FPCDIR)/units),) +override FPCDIR=wrong +endif +endif +else +override FPCDIR=wrong +endif + +# Detect FPCDIR +ifeq ($(FPCDIR),wrong) +ifdef inUnix +override FPCDIR=/usr/local/lib/fpc/$(FPC_VERSION) +ifeq ($(wildcard $(FPCDIR)/units),) +override FPCDIR=/usr/lib/fpc/$(FPC_VERSION) +endif +else +override FPCDIR:=$(subst /$(FPC),,$(firstword $(strip $(wildcard $(addsuffix /$(FPC),$(SEARCHPATH)))))) +override FPCDIR:=$(FPCDIR)/.. +ifeq ($(wildcard $(FPCDIR)/rtl),) +ifeq ($(wildcard $(FPCDIR)/units),) +override FPCDIR:=$(FPCDIR)/.. +ifeq ($(wildcard $(FPCDIR)/rtl),) +ifeq ($(wildcard $(FPCDIR)/units),) +override FPCDIR=c:/pp +endif +endif +endif +endif +endif +endif + +ifndef PACKAGESDIR +PACKAGESDIR=$(FPCDIR)/packages +endif +ifndef TOOLKITSDIR +TOOLKITSDIR= +endif +ifndef COMPONENTSDIR +COMPONENTSDIR= +endif + +# Create units dir +ifneq ($(FPCDIR),.) +UNITSDIR=$(FPCDIR)/units/$(OS_TARGET) +endif + +##################################################################### +# User Settings +##################################################################### + + +# Targets + +override EXEOBJECTS+=widgettest + +# Clean + + +# Install + +ZIPTARGET=install + +# Defaults + +override NEEDOPT=-S2h + +# Directories + + +# Packages + +override PACKAGES+=rtl fcl fpgfx fpgui + +# Libraries + + +# Info + +INFOTARGET=fpc_infocfg fpc_infoobjects fpc_infoinstall + +##################################################################### +# Shell tools +##################################################################### + +# echo +ifndef ECHO +ECHO:=$(strip $(wildcard $(addsuffix /gecho$(EXEEXT),$(SEARCHPATH)))) +ifeq ($(ECHO),) +ECHO:=$(strip $(wildcard $(addsuffix /echo$(SRCEXEEXT),$(SEARCHPATH)))) +ifeq ($(ECHO),) +ECHO:=echo +ECHOE:=echo +else +ECHO:=$(firstword $(ECHO)) +ECHOE=$(ECHO) -E +endif +else +ECHO:=$(firstword $(ECHO)) +ECHOE=$(ECHO) -E +endif +endif + +# To copy pograms +ifndef COPY +COPY:=cp -fp +endif + +# Copy a whole tree +ifndef COPYTREE +COPYTREE:=cp -rfp +endif + +# To move pograms +ifndef MOVE +MOVE:=mv -f +endif + +# Check delete program +ifndef DEL +DEL:=rm -f +endif + +# Check deltree program +ifndef DELTREE +DELTREE:=rm -rf +endif + +# To install files +ifndef INSTALL +ifdef inUnix +INSTALL:=install -c -m 644 +else +INSTALL:=$(COPY) +endif +endif + +# To install programs +ifndef INSTALLEXE +ifdef inUnix +INSTALLEXE:=install -c -m 755 +else +INSTALLEXE:=$(COPY) +endif +endif + +# To make a directory. +ifndef MKDIR +ifdef inUnix +MKDIR:=install -m 755 -d +else +MKDIR:=ginstall -m 755 -d +endif +endif + +export ECHO ECHOE COPY COPYTREE MOVE DEL DELTREE INSTALL INSTALLEXE MKDIR + +##################################################################### +# Default Tools +##################################################################### + +# assembler, redefine it if cross compiling +ifndef AS +AS=as +endif + +# linker, but probably not used +ifndef LD +LD=ld +endif + +# ppas.bat / ppas.sh +ifdef inUnix +PPAS=ppas.sh +else +ifdef inOS2 +PPAS=ppas.cmd +else +PPAS=ppas.bat +endif +endif + +# ldconfig to rebuild .so cache +ifdef inUnix +LDCONFIG=ldconfig +else +LDCONFIG= +endif + +# ppumove +ifndef PPUMOVE +PPUMOVE:=$(strip $(wildcard $(addsuffix /ppumove$(SRCEXEEXT),$(SEARCHPATH)))) +ifeq ($(PPUMOVE),) +PPUMOVE= +else +PPUMOVE:=$(firstword $(PPUMOVE)) +endif +endif +export PPUMOVE + +# ppufiles +ifndef PPUFILES +PPUFILES:=$(strip $(wildcard $(addsuffix /ppufiles$(SRCEXEEXT),$(SEARCHPATH)))) +ifeq ($(PPUFILES),) +PPUFILES= +else +PPUFILES:=$(firstword $(PPUFILES)) +endif +endif +export PPUFILES + +# Look if UPX is found for go32v2 and win32. We can't use $UPX becuase +# upx uses that one itself (PFV) +ifndef UPXPROG +ifeq ($(OS_TARGET),go32v2) +UPXPROG:=1 +endif +ifeq ($(OS_TARGET),win32) +UPXPROG:=1 +endif +ifdef UPXPROG +UPXPROG:=$(strip $(wildcard $(addsuffix /upx$(SRCEXEEXT),$(SEARCHPATH)))) +ifeq ($(UPXPROG),) +UPXPROG= +else +UPXPROG:=$(firstword $(UPXPROG)) +endif +else +UPXPROG= +endif +endif +export UPXPROG + +# ZipProg, you can't use Zip as the var name (PFV) +ifndef ZIPPROG +ZIPPROG:=$(strip $(wildcard $(addsuffix /zip$(SRCEXEEXT),$(SEARCHPATH)))) +ifeq ($(ZIPPROG),) +ZIPPROG= +else +ZIPPROG:=$(firstword $(ZIPPROG)) +endif +endif +export ZIPPROG + +ZIPOPT=-9 +ZIPEXT=.zip + +# Tar +ifndef TARPROG +TARPROG:=$(strip $(wildcard $(addsuffix /tar$(SRCEXEEXT),$(SEARCHPATH)))) +ifeq ($(TARPROG),) +TARPROG= +else +TARPROG:=$(firstword $(TARPROG)) +endif +endif +export TARPROG + +ifeq ($(USETAR),bz2) +TAROPT=vI +TAREXT=.tar.bz2 +else +TAROPT=vz +TAREXT=.tar.gz +endif + +##################################################################### +# Default extensions +##################################################################### + +# Default needed extensions (Go32v2,Linux) +LOADEREXT=.as +EXEEXT=.exe +PPLEXT=.ppl +PPUEXT=.ppu +OEXT=.o +ASMEXT=.s +SMARTEXT=.sl +STATICLIBEXT=.a +SHAREDLIBEXT=.so +RSTEXT=.rst +FPCMADE=fpcmade + +# Go32v1 +ifeq ($(OS_TARGET),go32v1) +PPUEXT=.pp1 +OEXT=.o1 +ASMEXT=.s1 +SMARTEXT=.sl1 +STATICLIBEXT=.a1 +SHAREDLIBEXT=.so1 +FPCMADE=fpcmade.v1 +endif + +# Go32v2 +ifeq ($(OS_TARGET),go32v2) +FPCMADE=fpcmade.dos +endif + +# Linux +ifeq ($(OS_TARGET),linux) +EXEEXT= +HASSHAREDLIB=1 +FPCMADE=fpcmade.lnx +endif + +# Linux +ifeq ($(OS_TARGET),freebsd) +EXEEXT= +HASSHAREDLIB=1 +FPCMADE=fpcmade.freebsd +endif + +# Win32 +ifeq ($(OS_TARGET),win32) +PPUEXT=.ppw +OEXT=.ow +ASMEXT=.sw +SMARTEXT=.slw +STATICLIBEXT=.aw +SHAREDLIBEXT=.dll +FPCMADE=fpcmade.w32 +endif + +# OS/2 +ifeq ($(OS_TARGET),os2) +PPUEXT=.ppo +ASMEXT=.so2 +OEXT=.oo2 +SMARTEXT=.so +STATICLIBEXT=.ao2 +SHAREDLIBEXT=.dll +FPCMADE=fpcmade.os2 +endif + +# library prefix +LIBPREFIX=lib +ifeq ($(OS_TARGET),go32v2) +LIBPREFIX= +endif +ifeq ($(OS_TARGET),go32v1) +LIBPREFIX= +endif + +# determine which .pas extension is used +ifndef PASEXT +ifdef EXEOBJECTS +override TESTPAS:=$(strip $(wildcard $(addsuffix .pas,$(firstword $(EXEOBJECTS))))) +else +override TESTPAS:=$(strip $(wildcard $(addsuffix .pas,$(firstword $(UNITOBJECTS))))) +endif +ifeq ($(TESTPAS),) +PASEXT=.pp +else +PASEXT=.pas +endif +endif + + +# Check if the dirs really exists, else turn it off +ifeq ($(wildcard $(UNITSDIR)),) +UNITSDIR= +endif +ifeq ($(wildcard $(TOOLKITSDIR)),) +TOOLKITSDIR= +endif +ifeq ($(wildcard $(PACKAGESDIR)),) +PACKAGESDIR= +endif +ifeq ($(wildcard $(COMPONENTSDIR)),) +COMPONENTSDIR= +endif + + +# PACKAGESDIR packages + +PACKAGERTL=1 +PACKAGEFCL=1 +PACKAGEFPGFX=1 +PACKAGEFPGUI=1 + +ifdef PACKAGERTL +ifneq ($(wildcard $(FPCDIR)/rtl),) +ifneq ($(wildcard $(FPCDIR)/rtl/$(OS_TARGET)),) +PACKAGEDIR_RTL=$(FPCDIR)/rtl/$(OS_TARGET) +else +PACKAGEDIR_RTL=$(FPCDIR)/rtl +endif +ifeq ($(wildcard $(PACKAGEDIR_RTL)/$(FPCMADE)),) +override COMPILEPACKAGES+=package_rtl +package_rtl: + $(MAKE) -C $(PACKAGEDIR_RTL) all +endif +UNITDIR_RTL=$(PACKAGEDIR_RTL) +else +PACKAGEDIR_RTL= +ifneq ($(wildcard $(UNITSDIR)/rtl),) +ifneq ($(wildcard $(UNITSDIR)/rtl/$(OS_TARGET)),) +UNITDIR_RTL=$(UNITSDIR)/rtl/$(OS_TARGET) +else +UNITDIR_RTL=$(UNITSDIR)/rtl +endif +else +UNITDIR_RTL= +endif +endif +ifdef UNITDIR_RTL +override NEEDUNITDIR+=$(UNITDIR_RTL) +endif +endif +ifdef PACKAGEFCL +ifneq ($(wildcard $(FPCDIR)/fcl),) +ifneq ($(wildcard $(FPCDIR)/fcl/$(OS_TARGET)),) +PACKAGEDIR_FCL=$(FPCDIR)/fcl/$(OS_TARGET) +else +PACKAGEDIR_FCL=$(FPCDIR)/fcl +endif +ifeq ($(wildcard $(PACKAGEDIR_FCL)/$(FPCMADE)),) +override COMPILEPACKAGES+=package_fcl +package_fcl: + $(MAKE) -C $(PACKAGEDIR_FCL) all +endif +UNITDIR_FCL=$(PACKAGEDIR_FCL) +else +PACKAGEDIR_FCL= +ifneq ($(wildcard $(UNITSDIR)/fcl),) +ifneq ($(wildcard $(UNITSDIR)/fcl/$(OS_TARGET)),) +UNITDIR_FCL=$(UNITSDIR)/fcl/$(OS_TARGET) +else +UNITDIR_FCL=$(UNITSDIR)/fcl +endif +else +UNITDIR_FCL= +endif +endif +ifdef UNITDIR_FCL +override NEEDUNITDIR+=$(UNITDIR_FCL) +endif +endif +ifdef PACKAGEFPGFX +ifneq ($(wildcard $(PACKAGESDIR)/fpgfx),) +ifneq ($(wildcard $(PACKAGESDIR)/fpgfx/$(OS_TARGET)),) +PACKAGEDIR_FPGFX=$(PACKAGESDIR)/fpgfx/$(OS_TARGET) +else +PACKAGEDIR_FPGFX=$(PACKAGESDIR)/fpgfx +endif +ifeq ($(wildcard $(PACKAGEDIR_FPGFX)/$(FPCMADE)),) +override COMPILEPACKAGES+=package_fpgfx +package_fpgfx: + $(MAKE) -C $(PACKAGEDIR_FPGFX) all +endif +UNITDIR_FPGFX=$(PACKAGEDIR_FPGFX) +else +PACKAGEDIR_FPGFX= +ifneq ($(wildcard $(UNITSDIR)/fpgfx),) +ifneq ($(wildcard $(UNITSDIR)/fpgfx/$(OS_TARGET)),) +UNITDIR_FPGFX=$(UNITSDIR)/fpgfx/$(OS_TARGET) +else +UNITDIR_FPGFX=$(UNITSDIR)/fpgfx +endif +else +UNITDIR_FPGFX= +endif +endif +ifdef UNITDIR_FPGFX +override NEEDUNITDIR+=$(UNITDIR_FPGFX) +endif +endif +ifdef PACKAGEFPGUI +ifneq ($(wildcard $(PACKAGESDIR)/fpgui),) +ifneq ($(wildcard $(PACKAGESDIR)/fpgui/$(OS_TARGET)),) +PACKAGEDIR_FPGUI=$(PACKAGESDIR)/fpgui/$(OS_TARGET) +else +PACKAGEDIR_FPGUI=$(PACKAGESDIR)/fpgui +endif +ifeq ($(wildcard $(PACKAGEDIR_FPGUI)/$(FPCMADE)),) +override COMPILEPACKAGES+=package_fpgui +package_fpgui: + $(MAKE) -C $(PACKAGEDIR_FPGUI) all +endif +UNITDIR_FPGUI=$(PACKAGEDIR_FPGUI) +else +PACKAGEDIR_FPGUI= +ifneq ($(wildcard $(UNITSDIR)/fpgui),) +ifneq ($(wildcard $(UNITSDIR)/fpgui/$(OS_TARGET)),) +UNITDIR_FPGUI=$(UNITSDIR)/fpgui/$(OS_TARGET) +else +UNITDIR_FPGUI=$(UNITSDIR)/fpgui +endif +else +UNITDIR_FPGUI= +endif +endif +ifdef UNITDIR_FPGUI +override NEEDUNITDIR+=$(UNITDIR_FPGUI) +endif +endif + + +##################################################################### +# Default Directories +##################################################################### + +# Linux and freebsd use unix dirs with /usr/bin, /usr/lib +# When zipping use the target as default, when normal install then +# use the source os as default +ifdef ZIPNAME +# Zipinstall +ifeq ($(OS_TARGET),linux) +UNIXINSTALLDIR=1 +endif +ifeq ($(OS_TARGET),freebsd) +UNIXINSTALLDIR=1 +endif +else +# Normal install +ifeq ($(OS_SOURCE),linux) +UNIXINSTALLDIR=1 +endif +ifeq ($(OS_SOURCE),freebsd) +UNIXINSTALLDIR=1 +endif +endif + +# set the prefix directory where to install everything +ifndef PREFIXINSTALLDIR +ifdef UNIXINSTALLDIR +PREFIXINSTALLDIR=/usr +else +PREFIXINSTALLDIR=/pp +endif +endif +export PREFIXINSTALLDIR + +# Where to place the resulting zip files +ifndef DESTZIPDIR +DESTZIPDIR:=$(BASEDIR) +endif +export DESTZIPDIR + +##################################################################### +# Install Directories +##################################################################### + +# set the base directory where to install everything +ifndef BASEINSTALLDIR +ifdef UNIXINSTALLDIR +BASEINSTALLDIR=$(PREFIXINSTALLDIR)/lib/fpc/$(FPC_VERSION) +else +BASEINSTALLDIR=$(PREFIXINSTALLDIR) +endif +endif + +# set the directory where to install the binaries +ifndef BININSTALLDIR +ifdef UNIXINSTALLDIR +BININSTALLDIR=$(PREFIXINSTALLDIR)/bin +else +BININSTALLDIR=$(BASEINSTALLDIR)/bin/$(OS_TARGET) +endif +endif + +# set the directory where to install the units. +ifndef UNITINSTALLDIR +UNITINSTALLDIR=$(BASEINSTALLDIR)/units/$(OS_TARGET) +ifdef UNITSUBDIR +UNITINSTALLDIR:=$(UNITINSTALLDIR)/$(UNITSUBDIR) +endif +endif + +# Where to install shared libraries +ifndef LIBINSTALLDIR +ifdef UNIXINSTALLDIR +LIBINSTALLDIR=$(PREFIXINSTALLDIR)/lib +else +LIBINSTALLDIR=$(UNITINSTALLDIR) +endif +endif + +# Where the source files will be stored +ifndef SOURCEINSTALLDIR +ifdef UNIXINSTALLDIR +SOURCEINSTALLDIR=$(PREFIXINSTALLDIR)/src/fpc-$(FPC_VERSION) +else +SOURCEINSTALLDIR=$(BASEINSTALLDIR)/source +endif +ifdef SOURCESUBDIR +SOURCEINSTALLDIR:=$(SOURCEINSTALLDIR)/$(SOURCESUBDIR) +endif +endif + +# Where the doc files will be stored +ifndef DOCINSTALLDIR +ifdef UNIXINSTALLDIR +DOCINSTALLDIR=$(PREFIXINSTALLDIR)/doc/fpc-$(FPC_VERSION) +else +DOCINSTALLDIR=$(BASEINSTALLDIR)/doc +endif +endif + +# Where to install the examples, under linux we use the doc dir +# because the copytree command will create a subdir itself +ifndef EXAMPLEINSTALLDIR +ifdef UNIXINSTALLDIR +EXAMPLEINSTALLDIR=$(DOCINSTALLDIR)/examples +else +EXAMPLEINSTALLDIR=$(BASEINSTALLDIR)/examples +endif +ifdef EXAMPLESUBDIR +EXAMPLEINSTALLDIR:=$(EXAMPLEINSTALLDIR)/$(EXAMPLESUBDIR) +endif +endif + +# Where the some extra (data)files will be stored +ifndef DATAINSTALLDIR +DATAINSTALLDIR=$(BASEINSTALLDIR) +endif + +##################################################################### +# Redirection +##################################################################### + +ifndef REDIRFILE +REDIRFILE=log +endif + +ifdef REDIR +ifndef inUnix +override FPC=redir -eo $(FPC) +endif +# set the verbosity to max +override FPCOPT+=-va +override REDIR:= >> $(REDIRFILE) +endif + + +##################################################################### +# Compiler Command Line +##################################################################### + +# Load commandline OPTDEF and add FPC_CPU define +override FPCOPTDEF:=-d$(CPU_TARGET) + +# Load commandline OPT and add target and unit dir to be sure +ifneq ($(OS_TARGET),$(OS_SOURCE)) +override FPCOPT+=-T$(OS_TARGET) +endif + +# User dirs should be first, so they are looked at first +ifdef UNITDIR +override FPCOPT+=$(addprefix -Fu,$(UNITDIR)) +endif +ifdef LIBDIR +override FPCOPT+=$(addprefix -Fl,$(LIBDIR)) +endif +ifdef OBJDIR +override FPCOPT+=$(addprefix -Fo,$(OBJDIR)) +endif +ifdef INCDIR +override FPCOPT+=$(addprefix -Fi,$(INCDIR)) +endif + +# Smartlinking +ifdef LINKSMART +override FPCOPT+=-XX +endif + +# Smartlinking creation +ifdef CREATESMART +override FPCOPT+=-CX +endif + +# Debug +ifdef DEBUG +override FPCOPT+=-gl -dDEBUG +endif + +# Release mode (strip, optimize and don't load ppc386.cfg) +# 0.99.12b has a bug in the optimizer so don't use it by default +ifdef RELEASE +ifeq ($(FPC_VERSION),0.99.12) +override FPCOPT+=-Xs -OGp3 -n +else +override FPCOPT+=-Xs -OG2p3 -n +endif +endif + +# Strip +ifdef STRIP +override FPCOPT+=-Xs +endif + +# Optimizer +ifdef OPTIMIZE +override FPCOPT+=-OG2p3 +endif + +# Verbose settings (warning,note,info) +ifdef VERBOSE +override FPCOPT+=-vwni +endif + +ifdef NEEDOPT +override FPCOPT+=$(NEEDOPT) +endif + +ifdef NEEDUNITDIR +override FPCOPT+=$(addprefix -Fu,$(NEEDUNITDIR)) +endif + +ifdef UNITSDIR +override FPCOPT+=-Fu$(UNITSDIR) +endif + +# Target dirs and the prefix to use for clean/install +ifdef TARGETDIR +override FPCOPT+=-FE$(TARGETDIR) +ifeq ($(TARGETDIR),.) +override TARGETDIRPREFIX= +else +override TARGETDIRPREFIX=$(TARGETDIR)/ +endif +endif +ifdef UNITTARGETDIR +override FPCOPT+=-FU$(UNITTARGETDIR) +ifeq ($(UNITTARGETDIR),.) +override UNITTARGETDIRPREFIX= +else +override UNITTARGETDIRPREFIX=$(TARGETDIR)/ +endif +else +ifdef TARGETDIR +override UNITTARGETDIR=$(TARGETDIR) +override UNITTARGETDIRPREFIX=$(TARGETDIRPREFIX) +endif +endif + +# Add commandline options last so they can override +ifdef OPT +override FPCOPT+=$(OPT) +endif + +# Add defines from FPCOPTDEF to FPCOPT +ifdef FPCOPTDEF +override FPCOPT+=$(FPCOPTDEF) +endif + +# Error file ? +ifdef ERRORFILE +override FPCOPT+=-Fr$(ERRORFILE) +endif + +# Was a config file specified ? +ifdef CFGFILE +override FPCOPT+=@$(CFGFILE) +endif + +# For win32 the options are passed using the environment FPCEXTCMD +ifeq ($(OS_SOURCE),win32) +override FPCEXTCMD:=$(FPCOPT) +override FPCOPT:=!FPCEXTCMD +export FPCEXTCMD +endif + +# Compiler commandline +override COMPILER:=$(FPC) $(FPCOPT) + +# also call ppas if with command option -s +# but only if the OS_SOURCE and OS_TARGE are equal +ifeq (,$(findstring -s ,$(COMPILER))) +EXECPPAS= +else +ifeq ($(OS_SOURCE),$(OS_TARGET)) +EXECPPAS:=@$(PPAS) +endif +endif + +##################################################################### +# Standard rules +##################################################################### + +all: fpc_all + +debug: fpc_debug + +smart: fpc_smart + +shared: fpc_shared + +showinstall: fpc_showinstall + +install: fpc_install + +sourceinstall: fpc_sourceinstall + +exampleinstall: fpc_exampleinstall + +zipinstall: fpc_zipinstall + +zipsourceinstall: fpc_zipsourceinstall + +zipexampleinstall: fpc_zipexampleinstall + +clean: fpc_clean + +distclean: fpc_distclean + +cleanall: fpc_cleanall + +info: fpc_info + +.PHONY: all debug smart shared showinstall install sourceinstall exampleinstall zipinstall zipsourceinstall zipexampleinstall clean distclean cleanall info + +##################################################################### +# Exes +##################################################################### + +.PHONY: fpc_exes + +ifdef EXEOBJECTS +override EXEFILES=$(addsuffix $(EXEEXT),$(EXEOBJECTS)) +override EXEOFILES:=$(addsuffix $(OEXT),$(EXEOBJECTS)) $(addprefix $(LIBPREFIX),$(addsuffix $(STATICLIBEXT),$(EXEOBJECTS))) + +override ALLTARGET+=fpc_exes +override INSTALLEXEFILES+=$(EXEFILES) +override CLEANEXEFILES+=$(EXEFILES) $(EXEOFILES) + +endif + +fpc_exes: $(EXEFILES) + +##################################################################### +# General compile rules +##################################################################### + +.PHONY: fpc_packages fpc_all fpc_debug + +$(FPCMADE): $(ALLTARGET) + @$(ECHO) Compiled > $(FPCMADE) + +fpc_packages: $(COMPILEPACKAGES) + +fpc_all: fpc_packages $(FPCMADE) + +fpc_debug: + $(MAKE) all DEBUG=1 + +# Search paths for .ppu if targetdir is set +ifdef UNITTARGETDIR +vpath %$(PPUEXT) $(UNITTARGETDIR) +endif + +# General compile rules, available for both possible PASEXT + +.SUFFIXES: $(EXEEXT) $(PPUEXT) $(OEXT) .pas .pp + +%$(PPUEXT): %.pp + $(COMPILER) $< $(REDIR) + $(EXECPPAS) + +%$(PPUEXT): %.pas + $(COMPILER) $< $(REDIR) + $(EXECPPAS) + +%$(EXEEXT): %.pp + $(COMPILER) $< $(REDIR) + $(EXECPPAS) + +%$(EXEEXT): %.pas + $(COMPILER) $< $(REDIR) + $(EXECPPAS) + +##################################################################### +# Library +##################################################################### + +.PHONY: fpc_smart fpc_shared + +ifdef LIBVERSION +LIBFULLNAME=$(LIBNAME).$(LIBVERSION) +else +LIBFULLNAME=$(LIBNAME) +endif + +# Default sharedlib units are all unit objects +ifndef SHAREDLIBUNITOBJECTS +SHAREDLIBUNITOBJECTS:=$(UNITOBJECTS) +endif + +fpc_smart: + $(MAKE) all LINKSMART=1 CREATESMART=1 + +fpc_shared: all +ifdef HASSHAREDLIB +ifndef LIBNAME + @$(ECHO) "LIBNAME not set" +else + $(PPUMOVE) $(SHAREDLIBUNITOBJECTS) -o$(LIBFULLNAME) +endif +else + @$(ECHO) "Shared Libraries not supported" +endif + +##################################################################### +# Install rules +##################################################################### + +.PHONY: fpc_showinstall fpc_install + +ifdef EXTRAINSTALLUNITS +override INSTALLPPUFILES+=$(addsuffix $(PPUEXT),$(EXTRAINSTALLUNITS)) +endif + +ifdef INSTALLPPUFILES +override INSTALLPPUFILES:=$(addprefix $(UNITTARGETDIRPREFIX),$(INSTALLPPUFILES)) +ifdef PPUFILES +INSTALLPPULINKFILES:=$(shell $(PPUFILES) -S -O $(INSTALLPPUFILES)) +else +INSTALLPPULINKFILES:=$(wildcard $(subst $(PPUEXT),$(OEXT),$(INSTALLPPUFILES)) $(addprefix $(LIBPREFIX),$(subst $(PPUEXT),$(STATICLIBEXT),$(INSTALLPPUFILES)))) +endif +override INSTALLPPULINKFILES:=$(addprefix $(UNITTARGETDIRPREFIX),$(INSTALLPPULINKFILES)) +endif + +ifdef INSTALLEXEFILES +override INSTALLEXEFILES:=$(addprefix $(TARGETDIRPREFIX),$(INSTALLEXEFILES)) +endif + +fpc_showinstall: $(SHOWINSTALLTARGET) +ifdef INSTALLEXEFILES + @$(ECHO) -e $(addprefix "\n"$(BININSTALLDIR)/,$(INSTALLEXEFILES)) +endif +ifdef INSTALLPPUFILES + @$(ECHO) -e $(addprefix "\n"$(UNITINSTALLDIR)/,$(INSTALLPPUFILES)) +ifneq ($(INSTALLPPULINKFILES),) + @$(ECHO) -e $(addprefix "\n"$(UNITINSTALLDIR)/,$(INSTALLPPULINKFILES)) +endif +ifneq ($(wildcard $(LIBFULLNAME)),) + @$(ECHO) $(LIBINSTALLDIR)/$(LIBFULLNAME) +ifdef HASSHAREDLIB + @$(ECHO) $(LIBINSTALLDIR)/$(LIBNAME) +endif +endif +endif +ifdef EXTRAINSTALLFILES + @$(ECHO) -e $(addprefix "\n"$(DATAINSTALLDIR)/,$(EXTRAINSTALLFILES)) +endif + +fpc_install: $(INSTALLTARGET) +# Create UnitInstallFiles +ifdef INSTALLEXEFILES + $(MKDIR) $(BININSTALLDIR) +# Compress the exes if upx is defined +ifdef UPXPROG + -$(UPXPROG) $(INSTALLEXEFILES) +endif + $(INSTALLEXE) $(INSTALLEXEFILES) $(BININSTALLDIR) +endif +ifdef INSTALLPPUFILES + $(MKDIR) $(UNITINSTALLDIR) + $(INSTALL) $(INSTALLPPUFILES) $(UNITINSTALLDIR) +ifneq ($(INSTALLPPULINKFILES),) + $(INSTALL) $(INSTALLPPULINKFILES) $(UNITINSTALLDIR) +endif +ifneq ($(wildcard $(LIBFULLNAME)),) + $(MKDIR) $(LIBINSTALLDIR) + $(INSTALL) $(LIBFULLNAME) $(LIBINSTALLDIR) +ifdef inUnix + ln -sf $(LIBFULLNAME) $(LIBINSTALLDIR)/$(LIBNAME) +endif +endif +endif +ifdef EXTRAINSTALLFILES + $(MKDIR) $(DATAINSTALLDIR) + $(INSTALL) $(EXTRAINSTALLFILES) $(DATAINSTALLDIR) +endif + +##################################################################### +# SourceInstall rules +##################################################################### + +.PHONY: fpc_sourceinstall + +ifndef SOURCETOPDIR +SOURCETOPDIR=$(BASEDIR) +endif + +fpc_sourceinstall: clean + $(MKDIR) $(SOURCEINSTALLDIR) + $(COPYTREE) $(SOURCETOPDIR) $(SOURCEINSTALLDIR) + +##################################################################### +# exampleinstall rules +##################################################################### + +.PHONY: fpc_exampleinstall + +fpc_exampleinstall: $(addsuffix _clean,$(EXAMPLEDIROBJECTS)) +ifdef EXAMPLESOURCEFILES + $(MKDIR) $(EXAMPLEINSTALLDIR) + $(COPY) $(EXAMPLESOURCEFILES) $(EXAMPLEINSTALLDIR) +endif +ifdef EXAMPLEDIROBJECTS +ifndef EXAMPLESOURCEFILES + $(MKDIR) $(EXAMPLEINSTALLDIR) +endif + $(COPYTREE) $(addsuffix /*,$(EXAMPLEDIROBJECTS)) $(EXAMPLEINSTALLDIR) +endif + +##################################################################### +# Zip +##################################################################### + +.PHONY: fpc_zipinstall + +# Create suffix to add +ifndef PACKAGESUFFIX +PACKAGESUFFIX=$(OS_TARGET) +ifeq ($(OS_TARGET),go32v2) +PACKAGESUFFIX=go32 +endif +ifeq ($(OS_TARGET),win32) +PACKAGESUFFIX=w32 +endif +endif + +# Temporary path to pack a file +ifndef PACKDIR +ifndef inUnix +PACKDIR=$(BASEDIR)/pack_tmp +else +PACKDIR=/tmp/fpc-pack +endif +endif + +# Maybe create default zipname from packagename +ifndef ZIPNAME +ifdef PACKAGENAME +ZIPNAME=$(PACKAGEPREFIX)$(PACKAGENAME)$(PACKAGESUFFIX) +endif +endif + +# Use tar by default under linux +ifndef USEZIP +ifdef inUnix +USETAR=1 +endif +endif + +fpc_zipinstall: +ifndef ZIPNAME + @$(ECHO) "Please specify ZIPNAME!" + @exit 1 +else + $(MAKE) $(ZIPTARGET) PREFIXINSTALLDIR=$(PACKDIR) +ifdef USETAR + $(DEL) $(DESTZIPDIR)/$(ZIPNAME)$(TAREXT) + cd $(PACKDIR) ; $(TARPROG) cf$(TAROPT) $(DESTZIPDIR)/$(ZIPNAME)$(TAREXT) * ; cd $(BASEDIR) +else + $(DEL) $(DESTZIPDIR)/$(ZIPNAME)$(ZIPEXT) + cd $(PACKDIR) ; $(ZIPPROG) -Dr $(ZIPOPT) $(DESTZIPDIR)/$(ZIPNAME)$(ZIPEXT) * ; cd $(BASEDIR) +endif + $(DELTREE) $(PACKDIR) +endif + +.PHONY: fpc_zipsourceinstall + +fpc_zipsourceinstall: + $(MAKE) fpc_zipinstall ZIPTARGET=sourceinstall PACKAGESUFFIX=src + +.PHONY: fpc_zipexampleinstall + +fpc_zipexampleinstall: + $(MAKE) fpc_zipinstall ZIPTARGET=exampleinstall PACKAGESUFFIX=exm + +##################################################################### +# Clean rules +##################################################################### + +.PHONY: fpc_clean fpc_cleanall fpc_distclean + +ifdef EXEFILES +override CLEANEXEFILES:=$(addprefix $(TARGETDIRPREFIX),$(CLEANEXEFILES)) +endif + +ifdef EXTRACLEANUNITS +override CLEANPPUFILES+=$(addsuffix $(PPUEXT),$(EXTRACLEANUNITS)) +endif + +ifdef CLEANPPUFILES +override CLEANPPUFILES:=$(addprefix $(UNITTARGETDIRPREFIX),$(CLEANPPUFILES)) +# Get the .o and .a files created for the units +ifdef PPUFILES +CLEANPPULINKFILES:=$(shell $(PPUFILES) $(CLEANPPUFILES)) +else +CLEANPPULINKFILES:=$(wildcard $(subst $(PPUEXT),$(OEXT),$(CLEANPPUFILES)) $(addprefix $(LIBPREFIX),$(subst $(PPUEXT),$(STATICLIBEXT),$(CLEANPPUFILES)))) +endif +override CLEANPPULINKFILES:=$(addprefix $(UNITTARGETDIRPREFIX),$(CLEANPPULINKFILES)) +endif + +fpc_clean: $(CLEANTARGET) +ifdef CLEANEXEFILES + -$(DEL) $(CLEANEXEFILES) +endif +ifdef CLEANPPUFILES + -$(DEL) $(CLEANPPUFILES) +endif +ifneq ($(CLEANPPULINKFILES),) + -$(DEL) $(CLEANPPULINKFILES) +endif +ifdef CLEANRSTFILES + -$(DEL) $(addprefix $(UNITTARGETDIRPREFIX),$(CLEANRSTFILES)) +endif +ifdef EXTRACLEANFILES + -$(DEL) $(EXTRACLEANFILES) +endif +ifdef LIBNAME + -$(DEL) $(LIBNAME) $(LIBFULLNAME) +endif + -$(DEL) $(FPCMADE) $(PPAS) link.res $(FPCEXTFILE) $(REDIRFILE) + +fpc_distclean: fpc_clean + +# Also run clean first if targetdir is set. Unittargetdir is always +# set if targetdir or unittargetdir is specified +ifdef UNITTARGETDIR +TARGETDIRCLEAN=fpc_clean +endif + +fpc_cleanall: $(CLEANTARGET) $(TARGETDIRCLEAN) +ifdef CLEANEXEFILES + -$(DEL) $(CLEANEXEFILES) +endif + -$(DEL) *$(OEXT) *$(PPUEXT) *$(RSTEXT) *$(ASMEXT) *$(STATICLIBEXT) *$(SHAREDLIBEXT) *$(PPLEXT) + -$(DELTREE) *$(SMARTEXT) + -$(DEL) $(FPCMADE) $(PPAS) link.res $(FPCEXTFILE) $(REDIRFILE) + +##################################################################### +# Info rules +##################################################################### + +.PHONY: fpc_info fpc_cfginfo fpc_objectinfo fpc_toolsinfo fpc_installinfo \ + fpc_dirinfo + +fpc_info: $(INFOTARGET) + +fpc_infocfg: + @$(ECHO) + @$(ECHO) == Configuration info == + @$(ECHO) + @$(ECHO) FPC....... $(FPC) + @$(ECHO) Version... $(FPC_VERSION) + @$(ECHO) CPU....... $(CPU_TARGET) + @$(ECHO) Source.... $(OS_SOURCE) + @$(ECHO) Target.... $(OS_TARGET) + @$(ECHO) + +fpc_infoobjects: + @$(ECHO) + @$(ECHO) == Object info == + @$(ECHO) + @$(ECHO) LoaderObjects..... $(LOADEROBJECTS) + @$(ECHO) UnitObjects....... $(UNITOBJECTS) + @$(ECHO) ExeObjects........ $(EXEOBJECTS) + @$(ECHO) + @$(ECHO) ExtraCleanUnits... $(EXTRACLEANUNITS) + @$(ECHO) ExtraCleanFiles... $(EXTRACLEANFILES) + @$(ECHO) + @$(ECHO) ExtraInstallUnits. $(EXTRAINSTALLUNITS) + @$(ECHO) ExtraInstallFiles. $(EXTRAINSTALLFILES) + @$(ECHO) + +fpc_infoinstall: + @$(ECHO) + @$(ECHO) == Install info == + @$(ECHO) +ifdef DATE + @$(ECHO) DateStr.............. $(DATESTR) +endif +ifdef PACKAGEPREFIX + @$(ECHO) PackagePrefix........ $(PACKAGEPREFIX) +endif +ifdef PACKAGENAME + @$(ECHO) PackageName.......... $(PACKAGENAME) +endif + @$(ECHO) PackageSuffix........ $(PACKAGESUFFIX) + @$(ECHO) + @$(ECHO) BaseInstallDir....... $(BASEINSTALLDIR) + @$(ECHO) BinInstallDir........ $(BININSTALLDIR) + @$(ECHO) LibInstallDir........ $(LIBINSTALLDIR) + @$(ECHO) UnitInstallDir....... $(UNITINSTALLDIR) + @$(ECHO) SourceInstallDir..... $(SOURCEINSTALLDIR) + @$(ECHO) DocInstallDir........ $(DOCINSTALLDIR) + @$(ECHO) DataInstallDir....... $(DATAINSTALLDIR) + @$(ECHO) + @$(ECHO) DestZipDir........... $(DESTZIPDIR) + @$(ECHO) ZipName.............. $(ZIPNAME) + @$(ECHO) + +##################################################################### +# Local Makefile +##################################################################### + +ifneq ($(wildcard fpcmake.loc),) +include fpcmake.loc +endif + diff --git a/examples/gui/widgettest/Makefile.fpc b/examples/gui/widgettest/Makefile.fpc new file mode 100644 index 00000000..57009620 --- /dev/null +++ b/examples/gui/widgettest/Makefile.fpc @@ -0,0 +1,10 @@ +# +# Makefile.fpc for fpGUI WidgetTest example +# + +[targets] +programs=widgettest + +[require] +options=-S2h +packages=fcl fpgfx fpgui diff --git a/examples/gui/widgettest/checkboxform.frm b/examples/gui/widgettest/checkboxform.frm new file mode 100644 index 00000000..cc03310d --- /dev/null +++ b/examples/gui/widgettest/checkboxform.frm @@ -0,0 +1,17 @@ +object CheckBoxForm: TCheckBoxForm + BorderWidth = 8 + Text = 'Check box test' + object Box: TBoxLayout + Orientation = Vertical + object GrayCheckBox: TCheckBox + Text = 'Gray other check boxes' + OnClick = GrayCheckBoxClick + end + object CheckBox1: TCheckBox + Text = 'First other check box' + end + object CheckBox2: TCheckBox + Text = 'Second other check box' + end + end +end diff --git a/examples/gui/widgettest/comboboxform.frm b/examples/gui/widgettest/comboboxform.frm new file mode 100644 index 00000000..23dd1f07 --- /dev/null +++ b/examples/gui/widgettest/comboboxform.frm @@ -0,0 +1,19 @@ +object ComboBoxForm: TComboBoxForm + BorderWidth = 8 + Text = 'Combo box test' + OnCreate = FormCreate + object VertBox: TBoxLayout + Orientation = Vertical + object GrayCheckBox: TCheckBox + Text = 'Gray combo boxes' + OnClick = GrayCheckBoxClick + end + object BetaLabel: TLabel + Text = '(the drop-down lists are work in progress)' + end + object ComboBox1: TComboBox + end + object ComboBox2: TComboBox + end + end +end diff --git a/examples/gui/widgettest/editform.frm b/examples/gui/widgettest/editform.frm new file mode 100644 index 00000000..51c2b888 --- /dev/null +++ b/examples/gui/widgettest/editform.frm @@ -0,0 +1,74 @@ +object EditForm: TEditForm + BorderWidth = 8 + Text = 'Edit field test' + object Grid: TGridLayout + ColCount = 3 + RowCount = 4 + GridPositions = < + item + Widget = Label1 + end + item + x = 1 + Widget = Edit1 + end + item + x = 2 + Widget = GrayCheckBox1 + end + item + y = 1 + width = 3 + Widget = Separator + end + item + y = 2 + Widget = Label2 + end + item + x = 1 + y = 2 + Widget = Edit2 + end + item + x = 2 + y = 2 + Widget = GrayCheckBox2 + end + item + x = 1 + y = 3 + Widget = PasswordDisplay + end> + object Label1: TLabel + Text = 'Normal edit field:' + CanExpandWidth = False + end + object Edit1: TEdit + Text = 'Edit1' + end + object GrayCheckBox1: TCheckBox + Text = 'Disabled' + OnClick = GrayCheckBox1Click + end + object Separator: TSeparator + end + object Label2: TLabel + Text = 'Password edit field:' + CanExpandWidth = False + end + object Edit2: TEdit + PasswordChar = '*' + Text = 'Edit2' + OnChange = Edit2Change + end + object GrayCheckBox2: TCheckBox + Text = 'Disabled' + OnClick = GrayCheckBox2Click + end + object PasswordDisplay: TLabel + Text = '(Password field)' + CanExpandWidth = False + end + end +end diff --git a/examples/gui/widgettest/gridform.frm b/examples/gui/widgettest/gridform.frm new file mode 100644 index 00000000..43d673fd --- /dev/null +++ b/examples/gui/widgettest/gridform.frm @@ -0,0 +1,9 @@ +object GridForm: TGridForm + BorderWidth = 8 + Text = 'Grid test' + OnCreate = FormCreate + object StringGrid: TStringGrid + ColCount = 10 + RowCount = 15 + end +end diff --git a/examples/gui/widgettest/groupboxform.frm b/examples/gui/widgettest/groupboxform.frm new file mode 100644 index 00000000..85ddff8f --- /dev/null +++ b/examples/gui/widgettest/groupboxform.frm @@ -0,0 +1,49 @@ +object GroupBoxForm: TGroupBoxForm + BorderWidth = 8 + Text = 'Group box test' + object HorzBox: TBoxLayout + VertAlign = vertTop + object GroupBox1: TGroupBox + Text = 'Group box #1' + object VertBox1: TBoxLayout + Orientation = Vertical + object GrayCheckBox: TCheckBox + Text = 'Gray other group box' + OnClick = GrayCheckBoxClick + end + object Button: TButton + Enabled = False + Text = 'Reset radio buttons' + OnClick = ButtonClick + end + end + end + object GroupBox2: TGroupBox + Text = 'Group box #2' + object VertBox2: TBoxLayout + Orientation = Vertical + object Radio1: TRadioButton + Checked = True + Text = 'Option 1' + OnClick = RadioButtonClick + end + object Radio2: TRadioButton + Text = 'Option 2' + OnClick = RadioButtonClick + end + object Radio3: TRadioButton + Text = 'Option 3' + OnClick = RadioButtonClick + end + object Radio4: TRadioButton + Text = 'Option 4' + OnClick = RadioButtonClick + end + object Radio5: TRadioButton + Text = 'Option 5' + OnClick = RadioButtonClick + end + end + end + end +end diff --git a/examples/gui/widgettest/listboxform.frm b/examples/gui/widgettest/listboxform.frm new file mode 100644 index 00000000..7d7c4f4c --- /dev/null +++ b/examples/gui/widgettest/listboxform.frm @@ -0,0 +1,23 @@ +object ListBoxForm: TListBoxForm + BorderWidth = 8 + Text = 'List box test' + object ListBox: TListBox + Items.Strings = ( + 'procedure KeyPressed(var Event: TXKeyPressedEvent); message X.KeyPress;' + 'procedure KeyReleased(var Event: TXKeyReleasedEvent); message X.KeyRelease;' + 'procedure ButtonPressed(var Event: TXButtonPressedEvent); message X.ButtonPress;' + 'procedure ButtonReleased(var Event: TXButtonReleasedEvent); message X.ButtonRelease;' + 'procedure EnterWindow(var Event :TXEnterWindowEvent); message X.EnterNotify;' + 'procedure LeaveWindow(var Event :TXLeaveWindowEvent); message X.LeaveNotify;' + 'procedure PointerMoved(var Event: TXPointerMovedEvent); message X.MotionNotify;' + 'procedure Expose(var Event: TXExposeEvent); message X.Expose;' + 'procedure FocusIn(var Event: TXFocusInEvent); message X.FocusIn;' + 'procedure FocusOut(var Event: TXFocusOutEvent); message X.FocusOut;' + 'procedure Map(var Event: TXMapEvent); message X.MapNotify;' + 'procedure Unmap(var Event: TXUnmapEvent); message X.UnmapNotify;' + 'procedure Reparent(var Event: TXReparentEvent); message X.ReparentNotify;' + 'procedure DestroyWindow(var Event: TXDestroyWindowEvent); message X.DestroyNotify;' + 'procedure Configure(var Event: TXConfigureEvent); message X.ConfigureNotify;' + 'procedure ClientMessage(var Event: TXClientMessageEvent); message X.ClientMessage;') + end +end diff --git a/examples/gui/widgettest/mainform.frm b/examples/gui/widgettest/mainform.frm new file mode 100644 index 00000000..d0e5f62f --- /dev/null +++ b/examples/gui/widgettest/mainform.frm @@ -0,0 +1,87 @@ +object MainForm: TMainForm
+ Text = 'Widget tests'
+ BorderWidth = 8
+ WindowOptions = [woWindow]
+ object Box: TBoxLayout
+ CanExpandWidth = False
+ Spacing = 8
+ Orientation = Vertical
+ object Label: TLabel
+ CanExpandWidth = True
+ Text = 'Choose a test form:'
+ end
+ object CheckboxBtn: TButton
+ CanExpandWidth = True
+ Text = 'Check boxes'
+ OnClick = CheckboxBtnClick
+ end
+ object RadioButtonBtn: TButton
+ CanExpandWidth = True
+ Text = 'Radio buttons'
+ OnClick = RadioButtonBtnClick
+ end
+ object GroupBoxBtn: TButton
+ CanExpandWidth = True
+ Text = 'Group boxes'
+ OnClick = GroupBoxBtnClick
+ end
+ object EditBtn: TButton
+ CanExpandWidth = True
+ Text = 'Edit fields'
+ OnClick = EditBtnClick
+ end
+ object ScrollBarBtn: TButton
+ CanExpandWidth = True
+ Text = 'Scroll bars'
+ OnClick = ScrollBarBtnClick
+ end
+ object ScrollBoxBtn: TButton
+ CanExpandWidth = True
+ Text = 'Scroll boxes'
+ OnClick = ScrollBoxBtnClick
+ end
+ object ListBoxBtn: TButton
+ CanExpandWidth = True
+ Text = 'List boxes'
+ OnClick = ListBoxBtnClick
+ end
+ object ComboBoxBtn: TButton
+ CanExpandWidth = True
+ Text = 'Combo boxes'
+ OnClick = ComboBoxBtnClick
+ end
+ object GridBtn: TButton
+ CanExpandWidth = True
+ Text = 'Grids'
+ OnClick = GridBtnClick
+ end
+ object MenuBtn: TButton
+ CanExpandWidth = True
+ Text = 'Menus'
+ OnClick = MenuBtnClick
+ end
+ object PanelBtn: TButton
+ CanExpandWidth = True
+ Text = 'Panel'
+ OnClick = PanelBtnClick
+ end
+ object ProgressBarBtn: TButton
+ CanExpandWidth = True
+ Text = 'Progress Bar'
+ OnClick = ProgressBarBtnClick
+ end
+ object StdDialogBtn: TButton
+ CanExpandWidth = True
+ Text = 'Std Dialog'
+ OnClick = StdDialogBtnClick
+ Enabled = False
+ end
+ object Separator: TSeparator
+ end
+ object ExitBtn: TButton
+ CanExpandWidth = True
+ Text = 'Exit'
+ OnClick = ExitBtnClick
+ end
+ end
+end
diff --git a/examples/gui/widgettest/radiobuttonform.frm b/examples/gui/widgettest/radiobuttonform.frm new file mode 100644 index 00000000..eac18c90 --- /dev/null +++ b/examples/gui/widgettest/radiobuttonform.frm @@ -0,0 +1,33 @@ +object RadioButtonForm: TRadioButtonForm + BorderWidth = 8 + Text = 'Radio button test' + object Box: TBoxLayout + Orientation = Vertical + object GrayCheckbox: TCheckbox + Text = 'Gray radio buttons' + OnClick = GrayCheckboxClick + end + object HorzBox: TBoxLayout + object ButtonBox1: TBoxLayout + Orientation = Vertical + object Radio1a: TRadioButton + Checked = True + Text = 'Button 1 a' + end + object Radio1b: TRadioButton + Text = 'Button 1 b' + end + end + object ButtonBox2: TBoxLayout + Orientation = Vertical + object Radio2a: TRadioButton + Text = 'Button 2 a' + end + object Radio2b: TRadioButton + Checked = True + Text = 'Button 2 b' + end + end + end + end +end diff --git a/examples/gui/widgettest/scrollbarform.frm b/examples/gui/widgettest/scrollbarform.frm new file mode 100644 index 00000000..5c238e23 --- /dev/null +++ b/examples/gui/widgettest/scrollbarform.frm @@ -0,0 +1,175 @@ +object ScrollBarForm: TScrollBarForm + BorderWidth = 8 + Text = 'Scroll bar test' + object VertBox: TBoxLayout + Orientation = Vertical + object GrayCheckBox: TCheckBox + Text = 'Gray everything' + OnClick = GrayCheckBoxClick + end + object HorzBox: TBoxLayout + object HorzGrid: TGridLayout + ColCount = 3 + RowCount = 6 + ColSpacing = 8 + GridPositions = < + item + x = 2 + Widget = Col3Label + end + item + y = 1 + Widget = Label1 + end + item + x = 1 + y = 1 + Widget = ScrollBar1 + end + item + x = 2 + y = 1 + Widget = PosLabel1 + end + item + y = 2 + Widget = Label2 + end + item + x = 1 + y = 2 + Widget = ScrollBar2 + end + item + x = 2 + y = 2 + Widget = PosLabel2 + end + item + y = 3 + Widget = Label3 + end + item + x = 1 + y = 3 + Widget = ScrollBar3 + end + item + x = 2 + y = 3 + Widget = PosLabel3 + end + item + y = 4 + Widget = Label4 + end + item + x = 1 + y = 4 + Widget = ScrollBar4 + end + item + x = 2 + y = 4 + Widget = PosLabel4 + end + item + y = 5 + Widget = Label5 + end + item + x = 1 + y = 5 + Widget = ScrollBar5 + end + item + x = 2 + y = 5 + Widget = PosLabel5 + end> + object Col3Label: TLabel + Alignment = taCenter + Text = 'Position' + end + object Label1: TLabel + Alignment = taRightJustify + Text = '0..1, PageSize=0:' + end + object ScrollBar1: TScrollBar + Min = 0 + Max = 1 + OnChange = ScrollBar1Change + end + object PosLabel1: TLabel + Alignment = taCenter + Text = '---' + end + object Label2: TLabel + Alignment = taRightJustify + Text = '0..1, PageSize=1:' + end + object ScrollBar2: TScrollBar + Max = 1 + PageSize = 1 + OnChange = ScrollBar2Change + end + object PosLabel2: TLabel + Alignment = taCenter + Text = '---' + end + object Label3: TLabel + Alignment = taRightJustify + Text = '-2..3, PageSize=0:' + end + object ScrollBar3: TScrollBar + Min = -2 + Max = 3 + OnChange = ScrollBar3Change + end + object PosLabel3: TLabel + Alignment = taCenter + Text = '---' + end + object Label4: TLabel + Alignment = taRightJustify + Text = '-5..9, PageSize=4:' + end + object ScrollBar4: TScrollBar + Min = -5 + Max = 9 + PageSize = 4 + OnChange = ScrollBar4Change + end + object PosLabel4: TLabel + Alignment = taCenter + Text = '---' + end + object Label5: TLabel + Alignment = taRightJustify + Text = '-100..200, PageSize=7:' + end + object ScrollBar5: TScrollBar + Min = -100 + Max = 200 + PageSize = 7 + OnChange = ScrollBar5Change + end + object PosLabel5: TLabel + Alignment = taCenter + Text = '---' + end + end + object VertBar: TSeparator + Orientation = Vertical + end + object VertLabel: TLabel + Text = 'Vertical:' + end + object VertScrollBar: TScrollBar + Orientation = Vertical + Min = -2 + Max = 3 + end + end + end +end diff --git a/examples/gui/widgettest/scrollboxform.frm b/examples/gui/widgettest/scrollboxform.frm new file mode 100644 index 00000000..b7e5412d --- /dev/null +++ b/examples/gui/widgettest/scrollboxform.frm @@ -0,0 +1,14 @@ +object ScrollBoxForm: TScrollBoxForm
+ BorderWidth = 8
+ Text = 'Scroll box test'
+ WindowOptions = [woWindow]
+ object VertLayout: TBoxLayout
+ Orientation = Vertical
+ object Label1: TLabel
+ CanExpandWidth = True
+ Text = 'ScrollBox should be transparent in this demo.'
+ end
+ object ScrollBox: TScrollBox
+ end
+ end
+end
diff --git a/examples/gui/widgettest/widgettest.lpi b/examples/gui/widgettest/widgettest.lpi new file mode 100644 index 00000000..68a02fd5 --- /dev/null +++ b/examples/gui/widgettest/widgettest.lpi @@ -0,0 +1,61 @@ +<?xml version="1.0"?> +<CONFIG> + <ProjectOptions> + <PathDelim Value="/"/> + <Version Value="5"/> + <General> + <Flags> + <SaveOnlyProjectUnits Value="True"/> + <AlwaysBuild Value="False"/> + </Flags> + <SessionStorage Value="InProjectDir"/> + <MainUnit Value="0"/> + <IconPath Value="./"/> + <TargetFileExt Value=""/> + </General> + <PublishOptions> + <Version Value="2"/> + <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="2"> + <Item1> + <PackageName Value="LCL"/> + <MinVersion Major="1" Valid="True"/> + </Item1> + <Item2> + <PackageName Value="fpGUI_laz"/> + </Item2> + </RequiredPackages> + <Units Count="1"> + <Unit0> + <Filename Value="widgettest.pas"/> + <IsPartOfProject Value="True"/> + <UnitName Value="WidgetTest"/> + </Unit0> + </Units> + </ProjectOptions> + <CompilerOptions> + <Version Value="5"/> + <Parsing> + <SyntaxOptions> + <IncludeAssertionCode Value="True"/> + <AllowLabel Value="False"/> + </SyntaxOptions> + </Parsing> + <CodeGeneration> + <Generate Value="Faster"/> + </CodeGeneration> + <Other> + <CustomOptions Value="-FUunits -dTraceEventsX -dDebugX +"/> + <CompilerPath Value="$(CompPath)"/> + </Other> + </CompilerOptions> +</CONFIG> diff --git a/examples/gui/widgettest/widgettest.pas b/examples/gui/widgettest/widgettest.pas new file mode 100644 index 00000000..1bc7654e --- /dev/null +++ b/examples/gui/widgettest/widgettest.pas @@ -0,0 +1,749 @@ +program WidgetTest; + +uses + SysUtils + ,Classes + ,gfxbase + ,fpgui + ; + +type + + // forward declarations + TCheckBoxForm = class; + TRadioButtonForm = class; + TGroupBoxForm = class; + TEditForm = class; + TScrollBarForm = class; + TScrollBoxForm = class; + TListBoxForm = class; + TComboBoxForm = class; + TGridForm = class; + TMenuForm = class; + TPanelForm = class; + TProgressBarForm = class; + + { TMainForm } + + TMainForm = class(TForm) + private + _frmCheckBox: TCheckBoxForm; + _frmRadioButton: TRadioButtonForm; + _frmGroupBox: TGroupBoxForm; + _frmEdit: TEditForm; + _frmScrollBar: TScrollBarForm; + _frmScrollBox: TScrollBoxForm; + _frmListBox: TListBoxForm; + _frmComboBox: TComboBoxForm; + _frmGrid: TGridForm; + _frmMenu: TMenuForm; + _frmPanel: TPanelForm; + _frmProgressBar: TProgressBarForm; + public + destructor Destroy; override; + published + Box: TBoxLayout; + Title: TLabel; + CheckboxBtn: TButton; + RadioButtonBtn: TButton; + GroupBoxBtn: TButton; + EditBtn: TButton; + ScrollBarBtn: TButton; + ScrollBoxBtn: TButton; + ListBoxBtn: TButton; + ComboBoxBtn: TButton; + GridBtn: TButton; + MenuBtn: TButton; + PanelBtn: TButton; + ProgressBarBtn: TButton; + StdDialogBtn: TButton; + Separator: TSeparator; + ExitBtn: TButton; + procedure CheckBoxBtnClick(Sender: TObject); + procedure RadioButtonBtnClick(Sender: TObject); + procedure GroupBoxBtnClick(Sender: TObject); + procedure EditBtnClick(Sender: TObject); + procedure ScrollBarBtnClick(Sender: TObject); + procedure ScrollBoxBtnClick(Sender: TObject); + procedure ListBoxBtnClick(Sender: TObject); + procedure ComboBoxBtnClick(Sender: TObject); + procedure GridBtnClick(Sender: TObject); + procedure ExitBtnClick(Sender: TObject); + procedure StdDialogBtnClick(Sender: TObject); + procedure MenuBtnClick(Sender: TObject); + procedure PanelBtnClick(Sender: TObject); + procedure ProgressBarBtnClick(Sender: TObject); + end; + + + TTestForm = class(TForm) + end; + + + TCheckBoxForm = class(TTestForm) + Box: TBoxLayout; + GrayCheckBox, CheckBox1, CheckBox2: TCheckBox; + procedure GrayCheckBoxClick(Sender: TObject); + end; + + + TRadioButtonForm = class(TTestForm) + Box, HorzBox, ButtonBox1, ButtonBox2: TBoxLayout; + GrayCheckBox: TCheckBox; + Radio1a, Radio1b, Radio2a, Radio2b: TRadioButton; + procedure GrayCheckBoxClick(Sender: TObject); + end; + + + TGroupBoxForm = class(TTestForm) + HorzBox, VertBox1, VertBox2: TBoxLayout; + GroupBox1, GroupBox2: TGroupBox; + GrayCheckBox: TCheckBox; + Button: TButton; + Radio1, Radio2, Radio3, Radio4, Radio5: TRadioButton; + procedure GrayCheckBoxClick(Sender: TObject); + procedure ButtonClick(Sender: TObject); + procedure RadioButtonClick(Sender: TObject); + end; + + + TEditForm = class(TTestForm) + Grid: TGridLayout; + VertBox, HorzBox1, HorzBox2: TBoxLayout; + Label1, Label2, PasswordDisplay: TLabel; + Edit1, Edit2: TEdit; + GrayCheckBox1, GrayCheckBox2: TCheckBox; + Separator: TSeparator; + procedure GrayCheckBox1Click(Sender: TObject); + procedure GrayCheckBox2Click(Sender: TObject); + procedure Edit2Change(Sender: TObject); + end; + + + TScrollBarForm = class(TTestForm) + VertLayout: TBoxLayout; + GrayCheckBox: TCheckBox; + HorzBox: TBoxLayout; + HorzGrid, VertGrid: TGridLayout; + VertBar: TSeparator; + VertLabel, Label1, Label2, Label3, Label4, Label5: TLabel; + PosLabel1, PosLabel2, PosLabel3, PosLabel4, PosLabel5: TLabel; + VertScrollBar, ScrollBar1, ScrollBar2, ScrollBar3, + ScrollBar4, ScrollBar5: TScrollBar; + procedure GrayCheckBoxClick(Sender: TObject); + procedure ScrollBar1Change(Sender: TObject); + procedure ScrollBar2Change(Sender: TObject); + procedure ScrollBar3Change(Sender: TObject); + procedure ScrollBar4Change(Sender: TObject); + procedure ScrollBar5Change(Sender: TObject); + end; + + + TScrollBoxForm = class(TTestForm) + VertLayout: TBoxLayout; + Label1: TLabel; + ScrollBox: TScrollBox; + end; + + + TListBoxForm = class(TTestForm) + ListBox: TListBox; + end; + + + TComboBoxForm = class(TTestForm) + published + VertLayout: TBoxLayout; + GrayCheckBox: TCheckBox; + BetaLabel: TLabel; + ComboBox1: TComboBox; + ComboBox2: TComboBox; + procedure GrayCheckBoxClick(Sender: TObject); + procedure FormCreate(Sender: TObject); + end; + + + TGridForm = class(TTestForm) + StringGrid: TStringGrid; + procedure FormCreate(Sender: TObject); + end; + + + TMenuForm = class(TTestForm) + private + FLayout: TBoxLayout; + public + constructor Create(AOwner: TComponent); override; + destructor Destroy; override; + published + BoxLayout: TBoxLayout; + MainMenu: TMenuBar; + Title: TLabel; + p1, p2, p3, p4, p5, p6: TPanel; + HBox: TBoxLayout; + end; + + + TPanelForm = class(TTestForm) + private + procedure RadioButtonClick(Sender: TObject); + public + constructor Create(AOwner: TComponent); override; + destructor Destroy; override; + published + MainLayout: TBoxLayout; + StyleGroup: TGroupBox; + rbPlain, rbLowered, rbRaised: TRadioButton; + VBox1: TBoxLayout; + Panel: TPanel; + Separator: TSeparator; + end; + + + TProgressBarForm = class(TTestForm) + private + procedure cbShowPercentClick(Sender: TObject); + procedure RadioButtonClick(Sender: TObject); + procedure GeneratePercentage(Sender: TObject); + public + constructor Create(AOwner: TComponent); override; + destructor Destroy; override; + published + MainLayout: TGridLayout; + VBox: TBoxLayout; + PB: TProgressBar; + cbShowPercent: TCheckBox; + gbColor: TGroupBox; + rbBlue: TRadioButton; + rbRed: TRadioButton; + rbGreen: TRadioButton; + Separator: TSeparator; + btnRandom: TButton; + end; + + +{ TMenuForm } + +constructor TMenuForm.Create(AOwner: TComponent); +begin + inherited Create(AOwner); + Name := 'MenuForm'; + Text := 'Menu Test'; + + BoxLayout := TBoxLayout.Create(self); + BoxLayout.Orientation := Vertical; + + MainMenu := TMenuBar.Create(self); + BoxLayout.InsertChild(MainMenu); + FLayout := TBoxLayout.Create(self); + FLayout.Spacing := 0; + FLayout.BorderSpacing := 6; + FLayout.HorzAlign := horzLeft; + MainMenu.InsertChild(FLayout); + +{ + MainMenu.AddMenu('File'); + MainMenu.AddMenu('Edit'); + MainMenu.AddMenu('Options'); + MainMenu.AddMenu('Windows'); + MainMenu.AddMenu('Help'); +} + + FLayout.InsertChild(TPanel.Create('File', self)); + FLayout.InsertChild(TPanel.Create('Edit', self)); + + HBox := TBoxLayout.Create(self); + HBox.HorzAlign := horzLeft; + HBox.Spacing := 0; + BoxLayout.InsertChild(HBox); + p1 := TPanel.Create('File', self); + p1.BevelStyle := bsPlain; + p2 := TPanel.Create('Edit', self); + p2.BevelStyle := bsPlain; + p3 := TPanel.Create('Options', self); + p3.BevelStyle := bsPlain; + p4 := TPanel.Create('Windows', self); + p4.BevelStyle := bsPlain; + p5 := TPanel.Create('Help', self); + p5.BevelStyle := bsPlain; +// HBox.InsertChild(p1); +// HBox.InsertChild(p2); + HBox.InsertChild(p3); + HBox.InsertChild(p4); + HBox.InsertChild(p5); + HBox.InsertChild(TPanel.Create('Testing', self)); + + + Title := TLabel.Create(self); + Title.CanExpandWidth := True; + Title.Alignment := taCenter; + Title.Text := 'This is work in progress...'; + Title.FontColor := clBlue; + BoxLayout.InsertChild(Title); + + Child := BoxLayout; +end; + +destructor TMenuForm.Destroy; +begin + inherited Destroy; +end; + +{ TPanelForm } + +procedure TPanelForm.RadioButtonClick(Sender: TObject); +begin + case TRadioButton(Sender).Tag of + 1: Panel.BevelStyle := bsPlain; + 2: Panel.BevelStyle := bsLowered; + 3: Panel.BevelStyle := bsRaised; + end; +end; + +constructor TPanelForm.Create(AOwner: TComponent); +begin + inherited Create(AOwner); + Name := 'PanelForm'; + Text := 'Panel Test'; + BorderWidth := 8; + + MainLayout := TBoxLayout.Create(self); + MainLayout.Orientation := Vertical; + + StyleGroup := TGroupBox.Create('Bevel Style:', self); + StyleGroup.CanExpandWidth := True; + MainLayout.InsertChild(StyleGroup); + + VBox1 := TBoxLayout.Create(self); + VBox1.Orientation := Vertical; + StyleGroup.InsertChild(VBox1); + + rbPlain := TRadioButton.Create('Plain', self); + rbPlain.Tag := 1; + rbPlain.OnClick := @RadioButtonClick; + rbLowered := TRadioButton.Create('Lowered', self); + rbLowered.Tag := 2; + rbLowered.OnClick := @RadioButtonClick; + rbRaised := TRadioButton.Create('Raised', self); + rbRaised.Tag := 3; + rbRaised.OnClick := @RadioButtonClick; + rbRaised.Checked := True; + VBox1.InsertChild(rbPlain); + VBox1.InsertChild(rbLowered); + VBox1.InsertChild(rbRaised); + + Separator := TSeparator.Create(self); + MainLayout.InsertChild(Separator); + + Panel := TPanel.Create('My Panel', self); + MainLayout.InsertChild(Panel); + + Child := MainLayout; +end; + +destructor TPanelForm.Destroy; +begin + inherited Destroy; +end; + + +{ TProgressBarForm } + +procedure TProgressBarForm.cbShowPercentClick(Sender: TObject); +begin + PB.ShowPercentage := cbShowPercent.Checked; +end; + +procedure TProgressBarForm.RadioButtonClick(Sender: TObject); +begin + case TRadioButton(Sender).Tag of + 1: PB.FillColor := clRed; + 2: PB.FillColor := clGreen; + 3: PB.FillColor := clBlue; + end; +end; + +procedure TProgressBarForm.GeneratePercentage(Sender: TObject); +begin + PB.Position := Random(100); +end; + +constructor TProgressBarForm.Create(AOwner: TComponent); +begin + inherited Create(AOwner); + Text := 'Progress Bar Demo'; + BorderWidth := 8; + + MainLayout := TGridLayout.Create(self); + MainLayout.RowCount := 4; + MainLayout.ColCount := 2; + + VBox := TBoxLayout.Create(self); + VBox.Orientation := Vertical; + + gbColor := TGroupBox.Create('Fill Color', self); + rbRed := TRadioButton.Create('Red', self); + rbRed.Tag := 1; + rbRed.OnClick := @RadioButtonClick; + rbRed.Checked := True; + + rbGreen := TRadioButton.Create('Green', self); + rbGreen.Tag := 2; + rbGreen.OnClick := @RadioButtonClick; + + rbBlue := TRadioButton.Create('Blue', self); + rbBlue.Tag := 3; + rbBlue.OnClick := @RadioButtonClick; + + VBox.InsertChild(rbRed); + VBox.InsertChild(rbGreen); + VBox.InsertChild(rbBlue); + gbColor.InsertChild(VBox); + MainLayout.AddWidget(gbColor, 0, 0, 1, 2); + + cbShowPercent := TCheckbox.Create('Show Percentage', self); + cbShowPercent.Checked := True; + cbShowPercent.OnClick := @cbShowPercentClick; + cbShowPercent.CanExpandWidth := True; + MainLayout.AddWidget(cbShowPercent, 1, 0, 1, 1); + + btnRandom := TButton.Create('Randomize', self); + btnRandom.OnClick := @GeneratePercentage; + MainLayout.AddWidget(btnRandom, 1, 1, 1, 1); + + Separator := TSeparator.Create(self); + MainLayout.AddWidget(Separator, 0, 2, 2, 1); + + PB := TProgressBar.Create('', self); + PB.Position := 75; + MainLayout.AddWidget(PB, 0, 3, 2, 1); + + Child := MainLayout; +end; + +destructor TProgressBarForm.Destroy; +begin + inherited Destroy; +end; + + +// ------------------------------------------------------------------- +// TMainForm +// ------------------------------------------------------------------- + +destructor TMainForm.Destroy; +begin + _frmCheckBox.Free; + _frmRadioButton.Free; + _frmGroupBox.Free; + _frmEdit.Free; + _frmScrollBar.Free; + _frmScrollBox.Free; + _frmListBox.Free; + _frmComboBox.Free; + _frmGrid.Free; + _frmMenu.Free; + _frmPanel.Free; + _frmProgressBar.Free; + inherited Destroy; +end; + + +procedure TMainForm.CheckBoxBtnClick(Sender: TObject); +begin + if Assigned(_frmCheckBox) then + _frmCheckBox.Show + else + Application.CreateForm(TCheckBoxForm, _frmCheckBox); +end; + + +procedure TMainForm.RadioButtonBtnClick(Sender: TObject); +begin + if Assigned(_frmRadioButton) then + _frmRadioButton.Show + else + Application.CreateForm(TRadioButtonForm, _frmRadioButton); +end; + + +procedure TMainForm.GroupBoxBtnClick(Sender: TObject); +begin + if Assigned(_frmGroupBox) then + _frmGroupBox.Show + else + Application.CreateForm(TGroupBoxForm, _frmGroupBox); +end; + + +procedure TMainForm.EditBtnClick(Sender: TObject); +begin + if Assigned(_frmEdit) then + _frmEdit.Show + else + Application.CreateForm(TEditForm, _frmEdit); +end; + + +procedure TMainForm.ScrollBarBtnClick(Sender: TObject); +begin + if Assigned(_frmScrollBar) then + _frmScrollBar.Show + else + Application.CreateForm(TScrollBarForm, _frmScrollBar); +end; + + +procedure TMainForm.ScrollBoxBtnClick(Sender: TObject); +begin + if Assigned(_frmScrollBox) then + _frmScrollBox.Show + else + Application.CreateForm(TScrollBoxForm, _frmScrollBox); +end; + + +procedure TMainForm.ListBoxBtnClick(Sender: TObject); +begin + if Assigned(_frmListBox) then + _frmListBox.Show + else + Application.CreateForm(TListBoxForm, _frmListBox); +end; + + +procedure TMainForm.ComboBoxBtnClick(Sender: TObject); +begin + if Assigned(_frmComboBox) then + _frmComboBox.Show + else + Application.CreateForm(TComboBoxForm, _frmComboBox); +end; + + +procedure TMainForm.GridBtnClick(Sender: TObject); +begin + if Assigned(_frmGrid) then + _frmGrid.Show + else + Application.CreateForm(TGridForm, _frmGrid); +end; + + +procedure TMainForm.ExitBtnClick(Sender: TObject); +begin + Close; +end; + + +procedure TMainForm.StdDialogBtnClick(Sender: TObject); +var + dlg: TStandardDialog; +begin + {$Note This needs to be reworked completely! } + if Assigned(dlg) then + dlg.Show + else + Application.CreateForm(TStandardDialog, dlg); +// dlg := TStandardDialog.Create(self); + +// dlg.Text := 'This is a single line of text.'; +// dlg.Show; +end; + + +procedure TMainForm.MenuBtnClick(Sender: TObject); +begin + if Assigned(_frmMenu) then + _frmMenu.Show + else + begin + _frmMenu := TMenuForm.Create(self); +// Application.AddForm(_frmMenu); + _frmMenu.Show; + end; + _frmMenu.SetPosition(Point(Left + Width + 5, FindForm.Top)); +end; + +procedure TMainForm.PanelBtnClick(Sender: TObject); +begin + if Assigned(_frmPanel) then + _frmPanel.Show + else + begin + _frmPanel := TPanelForm.Create(self); + _frmPanel.Show; + end; + _frmPanel.SetPosition(Point(Left + Width + 5, FindForm.Top)); +end; + +procedure TMainForm.ProgressBarBtnClick(Sender: TObject); +begin + if Assigned(_frmProgressBar) then + _frmProgressBar.Show + else + begin + _frmProgressBar := TProgressBarForm.Create(self); + _frmProgressBar.Show; + end; + _frmProgressBar.SetPosition(Point(Left + Width + 5, FindForm.Top)); +end; + + +// ------------------------------------------------------------------- +// TCheckBoxForm +// ------------------------------------------------------------------- + +procedure TCheckBoxForm.GrayCheckBoxClick(Sender: TObject); +begin + CheckBox1.Enabled := not GrayCheckBox.Checked; + CheckBox2.Enabled := not GrayCheckBox.Checked; +end; + + +// ------------------------------------------------------------------- +// TRadioButtonForm +// ------------------------------------------------------------------- + +procedure TRadioButtonForm.GrayCheckBoxClick(Sender: TObject); +begin + HorzBox.Enabled := not GrayCheckBox.Checked; +end; + + +// ------------------------------------------------------------------- +// TGroupBoxForm +// ------------------------------------------------------------------- + +procedure TGroupBoxForm.GrayCheckBoxClick(Sender: TObject); +begin + GroupBox2.Enabled := not GrayCheckBox.Checked; +end; + + +procedure TGroupBoxForm.ButtonClick(Sender: TObject); +begin + Radio1.Checked := True; + Button.Enabled := False; +end; + + +procedure TGroupBoxForm.RadioButtonClick(Sender: TObject); +begin + Button.Enabled := not Radio1.Checked; +end; + + +// ------------------------------------------------------------------- +// TEditForm +// ------------------------------------------------------------------- + +procedure TEditForm.GrayCheckBox1Click(Sender: TObject); +begin + Edit1.Enabled := not GrayCheckBox1.Checked; +end; + + +procedure TEditForm.GrayCheckBox2Click(Sender: TObject); +begin + Edit2.Enabled := not GrayCheckBox2.Checked; +end; + + +procedure TEditForm.Edit2Change(Sender: TObject); +begin + PasswordDisplay.Text := '(= ' + Edit2.Text + ')'; +end; + + +// ------------------------------------------------------------------- +// TScrollBarForm +// ------------------------------------------------------------------- + +procedure TScrollBarForm.GrayCheckBoxClick(Sender: TObject); +begin + HorzBox.Enabled := not GrayCheckBox.Checked; +end; + + +procedure TScrollBarForm.ScrollBar1Change(Sender: TObject); +begin + PosLabel1.Text := IntToStr(ScrollBar1.Position); +end; + + +procedure TScrollBarForm.ScrollBar2Change(Sender: TObject); +begin + PosLabel2.Text := IntToStr(ScrollBar2.Position); +end; + + +procedure TScrollBarForm.ScrollBar3Change(Sender: TObject); +begin + PosLabel3.Text := IntToStr(ScrollBar3.Position); +end; + + +procedure TScrollBarForm.ScrollBar4Change(Sender: TObject); +begin + PosLabel4.Text := IntToStr(ScrollBar4.Position); +end; + + +procedure TScrollBarForm.ScrollBar5Change(Sender: TObject); +begin + PosLabel5.Text := IntToStr(ScrollBar5.Position); +end; + + +// ------------------------------------------------------------------- +// TComboBoxForm +// ------------------------------------------------------------------- + +procedure TComboBoxForm.GrayCheckBoxClick(Sender: TObject); +begin + ComboBox1.Enabled := not GrayCheckBox.Checked; + ComboBox2.Enabled := not GrayCheckBox.Checked; +end; + + +procedure TComboBoxForm.FormCreate(Sender: TObject); +var + i: integer; +begin + for i := 1 to 20 do + begin + ComboBox1.Items.Add(Format('Item 1.%d...', [i])); + ComboBox2.Items.Add(Format('Item 2.%d...', [i])); + end; + BetaLabel.FontColor := clBlue; +end; + + +// ------------------------------------------------------------------- +// TGridForm +// ------------------------------------------------------------------- + +procedure TGridForm.FormCreate(Sender: TObject); +var + x, y: Integer; +begin + for y := 0 to StringGrid.RowCount - 1 do + for x := 0 to StringGrid.ColCount - 1 do + StringGrid.Cells[x, y] := Format('%d, %d', [x, y]); +end; + + +var + MainForm: TMainForm; +begin + MainForm := nil; + WriteLn('Version: ' + {$I %date%} + ' ' + {$I %time%}); + + Application.CreateForm(TMainForm, MainForm); + try + Application.Run; + finally + MainForm.Free; + end; +end. |