summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--extras/tiopf/gui/tiDialogs.pas146
-rw-r--r--extras/tiopf/gui/tiGUIINI.pas131
-rw-r--r--extras/tiopf/gui/tiGUIUtils.pas18
-rw-r--r--extras/tiopf/readme.txt12
-rw-r--r--extras/tiopf/tiOPFfpGUI.lpk61
-rw-r--r--extras/tiopf/tiOPFfpGUI.pas14
6 files changed, 382 insertions, 0 deletions
diff --git a/extras/tiopf/gui/tiDialogs.pas b/extras/tiopf/gui/tiDialogs.pas
new file mode 100644
index 00000000..5458820b
--- /dev/null
+++ b/extras/tiopf/gui/tiDialogs.pas
@@ -0,0 +1,146 @@
+unit tiDialogs;
+
+{$mode objfpc}{$H+}
+
+{
+ TODO:
+ * Port tiProcessing and tiEndProcessing
+}
+
+interface
+
+uses
+ Classes
+ ,SysUtils
+ ,Variants
+ ;
+
+
+ // Call showMessage, but accepts a variant. Good for debugging.
+ procedure tiShowMessage(const AArray: Array of Const); overload;
+ procedure tiShowMessage(const AValue: variant); overload;
+
+
+ // Show the contents of a TStringList - for debugging
+ procedure tiShowStringList(const pStringList: TStringList; const pHeading: string = 'Show string list');
+ // Show the contents of a TStrings - for debugging
+ procedure tiShowStrings(const AStrings: TStrings; const pHeading: string = 'Show strings');
+ // Show a long string - for debugging
+ procedure tiShowString(const AStr: string; const pHeading: string = 'Show string');
+ // Show a variant array of variants - for debugging
+ procedure tiShowVariant(AValue: Variant; pHeading: string = 'Show variant');
+ // Show the contents of a stream
+ procedure tiShowStream(const AValue: TStream; const pHeading: string = 'Show stream');
+
+
+implementation
+
+uses
+ fpgfx
+ ,gui_form
+ ,gui_memo
+ ,tiGUIINI
+ ,tiUtils
+ ,gui_dialogs
+ ;
+
+procedure tiShowMessage(const AArray: array of const);
+const
+ BoolChars: array[Boolean] of Char = ('F', 'T');
+var
+ i: Integer;
+ lsLine: string;
+begin
+ lsLine := '';
+ for I := 0 to High(AArray) do begin
+ if lsLine <> '' then
+ lsLine := lsLine + Cr;
+ with AArray[i] do
+ case VType of
+ vtInteger: lsLine := lsLine + IntToStr(VInteger);
+ vtBoolean: lsLine := lsLine + BoolChars[VBoolean];
+ vtChar: lsLine := lsLine + VChar;
+ vtExtended: lsLine := lsLine + FloatToStr(VExtended^);
+ vtString: lsLine := lsLine + VString^;
+ vtPChar: lsLine := lsLine + VPChar;
+ vtObject: lsLine := lsLine + VObject.ClassName;
+ vtClass: lsLine := lsLine + VClass.ClassName;
+ vtAnsiString: lsLine := lsLine + string(VAnsiString);
+ vtCurrency: lsLine := lsLine + CurrToStr(VCurrency^);
+ vtVariant: lsLine := lsLine + string(VVariant^);
+ vtInt64: lsLine := lsLine + IntToStr(VInt64^);
+ end;
+ end;
+ tiShowMessage(lsLine);
+end;
+
+procedure tiShowMessage(const AValue: variant);
+begin
+ ShowMessage(VarToStr(AValue));
+end;
+
+procedure tiShowStringList(const pStringList: TStringList; const pHeading: string);
+begin
+ tiShowStrings(pStringList, pHeading);
+end;
+
+procedure tiShowStrings(const AStrings: TStrings; const pHeading: string);
+var
+ lForm: TfpgForm;
+ lMemo: TfpgMemo;
+begin
+ lForm := TfpgForm.Create(nil);
+ lMemo := TfpgMemo.Create(lForm);
+ try
+ lForm.WindowTitle := pHeading;
+ lForm.WindowPosition := wpScreenCenter;
+ lForm.Name := 'FormShowStrings';
+// lMemo.Parent := lForm;
+ lMemo.Align := alClient;
+ lMemo.Lines.Assign(AStrings);
+ lMemo.FontDesc := 'Courier New-10';
+ gGUIINI.ReadFormState(lForm);
+ lForm.ShowModal;
+ gGUIINI.WriteFormState(lForm);
+ finally
+ lForm.free;
+ end;
+end;
+
+procedure tiShowString(const AStr: string; const pHeading: string);
+var
+ lSL: TStringList;
+begin
+ lSL := TStringList.Create;
+ try
+ lSL.Text := AStr;
+ tiShowStringList(lSL, pHeading);
+ finally
+ lSL.Free;
+ end;
+end;
+
+procedure tiShowVariant(AValue: Variant; pHeading: string);
+var
+ ls: string;
+begin
+ ls := tiVariantArrayToString(AValue);
+ tiShowString(ls, pHeading);
+end;
+
+procedure tiShowStream(const AValue: TStream; const pHeading: string);
+var
+ lStringStream: TStringStream;
+begin
+ lStringStream := TStringStream.Create('');
+ try
+ AValue.Position := 0;
+ lStringStream.CopyFrom(AValue, AValue.Size);
+ tiShowString(lStringStream.DataString, pHeading);
+ finally
+ lStringStream.Free;
+ end;
+end;
+
+end.
+
diff --git a/extras/tiopf/gui/tiGUIINI.pas b/extras/tiopf/gui/tiGUIINI.pas
new file mode 100644
index 00000000..6d1ff723
--- /dev/null
+++ b/extras/tiopf/gui/tiGUIINI.pas
@@ -0,0 +1,131 @@
+unit tiGUIINI;
+
+{$mode objfpc}{$H+}
+
+{
+ TODO:
+ * When TfpgForm supports FormState property, implement the remaining functions
+}
+
+interface
+uses
+ tiINI
+ ,gui_form
+ ;
+
+type
+
+ TtiGUIINIFile = class(TtiINIFile)
+ public
+ procedure ReadFormState(AForm: TfpgForm; AHeight: integer = -1; AWidth: integer = -1);
+ procedure WriteFormState(AForm : TfpgForm);
+ end;
+
+function GGUIINI(const AFileName: string = ''): TtiGUIINIFile;
+
+implementation
+uses
+ fpgfx
+ ;
+
+var
+ uGUIINI : TtiGUIINIFile;
+
+
+function GGUIINI(const AFileName: string = ''): TtiGUIINIFile;
+begin
+ if UGUIINI = nil then
+ UGUIINI := TtiGUIINIFile.CreateExt(AFileName);
+ result := UGUIINI;
+end;
+
+procedure TtiGUIINIFile.ReadFormState(AForm: TfpgForm; AHeight : integer = -1; AWidth : integer = -1);
+var
+ LINISection : string;
+ LTop : integer;
+ LLeft : integer;
+ LHeight : integer;
+ LWidth : integer;
+begin
+ Assert(AForm <> nil, 'pForm not assigned');
+ LINISection := AForm.Name + 'State';
+ // Read form position, -1 if not stored in registry
+ LTop := readInteger(LINISection, 'Top', -1);
+ LLeft := readInteger(LINISection, 'Left', -1);
+ // The form pos was found in the registr
+ if (LTop <> -1) and (LLeft <> -1) then
+ begin
+ AForm.Top := readInteger(LINISection, 'Top', AForm.Top);
+ AForm.Left := readInteger(LINISection, 'Left', AForm.Left);
+ AForm.WindowPosition := wpUser;
+ // No form pos in the registry, so default to screen center
+ end
+ else
+ begin
+ if Assigned(fpgApplication.MainForm) and (fpgApplication.MainForm <> AForm) then
+ AForm.WindowPosition := wpAuto
+ else
+ AForm.WindowPosition := wpScreenCenter;
+ end;
+ // Only set the form size if a bsSizable window
+ if AForm.Sizeable then
+ begin
+ if AHeight = -1 then
+ LHeight := AForm.Height
+ else
+ LHeight := AHeight;
+ if AWidth = -1 then
+ LWidth := AForm.Width
+ else
+ LWidth := AWidth;
+ AForm.Height := readInteger(LINISection, 'Height', LHeight);
+ AForm.Width := readInteger(LINISection, 'Width', LWidth);
+ end;
+// AForm.WindowState := TWindowState(ReadInteger(LINISection, 'WindowState', ord(wsNormal)));
+
+ // If the form is off screen (positioned outside all monitor screens) then
+ // center the form on screen.
+ //{$IFDEF MSWINDOWS}
+ //if (AForm.FormStyle <> fsMDIChild) {$IFNDEF FPC} and tiFormOffScreen(AForm) {$ENDIF} then
+ //begin
+ //if Assigned(Application.MainForm) and (Application.MainForm <> AForm) then
+ //AForm.Position := poMainFormCenter
+ //else
+ //AForm.Position:= poScreenCenter;
+ //end;
+ //{$ENDIF MSWINDOWS}
+end;
+
+procedure TtiGUIINIFile.WriteFormState(AForm: TfpgForm);
+var
+ LINISection: string;
+begin
+ LINISection := AForm.Name + 'State';
+// writeInteger(LINISection, 'WindowState', ord(AForm.WindowState));
+// if AForm.WindowState = wsNormal then
+// begin
+ writeInteger(LINISection, 'Top', AForm.Top);
+ writeInteger(LINISection, 'Left', AForm.Left);
+ if AForm.Sizeable then
+ begin
+ writeInteger(LINISection, 'Height', AForm.Height);
+ WriteInteger(LINISection, 'Width', AForm.Width);
+ end;
+// end;
+end;
+
+initialization
+ uGUIINI := nil;
+
+finalization
+ uGUIINI.Free;
+
+end.
+
+
+
+
+
+
+
+
diff --git a/extras/tiopf/gui/tiGUIUtils.pas b/extras/tiopf/gui/tiGUIUtils.pas
new file mode 100644
index 00000000..86653304
--- /dev/null
+++ b/extras/tiopf/gui/tiGUIUtils.pas
@@ -0,0 +1,18 @@
+unit tiGUIUtils;
+
+{$mode objfpc}{$H+}
+
+interface
+
+uses
+ Classes
+ ;
+
+ // Mouse cursor routines
+// function tiAutoWaitCursor: IUnknown;
+// function tiAutoCursor(ACursor: TCursor = crHourglass): IUnknown;
+
+implementation
+
+end.
+
diff --git a/extras/tiopf/readme.txt b/extras/tiopf/readme.txt
new file mode 100644
index 00000000..c42ea0d9
--- /dev/null
+++ b/extras/tiopf/readme.txt
@@ -0,0 +1,12 @@
+
+ tiOPF2 support units
+ ====================
+
+This directory is for all the GUI related units required for tiOPF to work
+with fpGUI based applications. tiOPF is a Object Persistent Framework handling
+all persistance of Objects to databases or flat files.
+
+For more details on tiOPF go to the project home page at:
+ http://www.tiopf.com
+
+
diff --git a/extras/tiopf/tiOPFfpGUI.lpk b/extras/tiopf/tiOPFfpGUI.lpk
new file mode 100644
index 00000000..854b0a0e
--- /dev/null
+++ b/extras/tiopf/tiOPFfpGUI.lpk
@@ -0,0 +1,61 @@
+<?xml version="1.0"?>
+<CONFIG>
+ <Package Version="2">
+ <Name Value="tiOPFfpGUI"/>
+ <Author Value="Graeme Geldenhuys"/>
+ <AutoUpdate Value="OnRebuildingAll"/>
+ <CompilerOptions>
+ <Version Value="5"/>
+ <SearchPaths>
+ <OtherUnitFiles Value="gui/"/>
+ <UnitOutputDirectory Value="lib/$(TargetCPU)-$(TargetOS)"/>
+ </SearchPaths>
+ <CodeGeneration>
+ <Generate Value="Faster"/>
+ </CodeGeneration>
+ <Other>
+ <CompilerPath Value="$(CompPath)"/>
+ </Other>
+ </CompilerOptions>
+ <Description Value="tiOPF GUI layer - visual units
+"/>
+ <License Value="Mozilla Public License v1.1
+"/>
+ <Version Major="2" Release="3"/>
+ <Files Count="3">
+ <Item1>
+ <Filename Value="gui/tiGUIUtils.pas"/>
+ <UnitName Value="tiGUIUtils"/>
+ </Item1>
+ <Item2>
+ <Filename Value="gui/tiDialogs.pas"/>
+ <UnitName Value="tiDialogs"/>
+ </Item2>
+ <Item3>
+ <Filename Value="gui/tiGUIINI.pas"/>
+ <UnitName Value="tiGUIINI"/>
+ </Item3>
+ </Files>
+ <RequiredPkgs Count="3">
+ <Item1>
+ <PackageName Value="FCL"/>
+ <MinVersion Major="1" Valid="True"/>
+ </Item1>
+ <Item2>
+ <PackageName Value="tiOPF"/>
+ <MinVersion Major="2" Release="3" Valid="True"/>
+ </Item2>
+ <Item3>
+ <PackageName Value="fpgui_package"/>
+ <MinVersion Minor="5" Valid="True"/>
+ </Item3>
+ </RequiredPkgs>
+ <UsageOptions>
+ <UnitPath Value="$(PkgOutDir)/"/>
+ </UsageOptions>
+ <PublishOptions>
+ <Version Value="2"/>
+ <IgnoreBinaries Value="False"/>
+ </PublishOptions>
+ </Package>
+</CONFIG>
diff --git a/extras/tiopf/tiOPFfpGUI.pas b/extras/tiopf/tiOPFfpGUI.pas
new file mode 100644
index 00000000..80f74737
--- /dev/null
+++ b/extras/tiopf/tiOPFfpGUI.pas
@@ -0,0 +1,14 @@
+{ This file was automatically created by Lazarus. Do not edit!
+This source is only used to compile and install the package.
+ }
+
+unit tiOPFfpGUI;
+
+interface
+
+uses
+ tiGUIUtils, tiDialogs, tiGUIINI;
+
+implementation
+
+end.