summaryrefslogtreecommitdiff
path: root/uidesigner
diff options
context:
space:
mode:
authorGraeme Geldenhuys <graeme@mastermaths.co.za>2011-09-16 15:16:34 +0200
committerGraeme Geldenhuys <graeme@mastermaths.co.za>2011-09-16 15:18:38 +0200
commit751fe1b12205fc70a31511be6914394f7800df2f (patch)
treeb127bb2beab765edfc94ba1329919043ab4aef38 /uidesigner
parent7f3062c239ffdd81b4c1bb124a1f62c51a5938fe (diff)
downloadfpGUI-751fe1b12205fc70a31511be6914394f7800df2f.tar.xz
uidesigner: new option to specify Indentation Style preference.
The developer can now choose between a Spaces or Tab indentation style for any UI Designer managed code.
Diffstat (limited to 'uidesigner')
-rw-r--r--uidesigner/vfddesigner.pas23
-rw-r--r--uidesigner/vfdfile.pas32
-rw-r--r--uidesigner/vfdforms.pas74
-rw-r--r--uidesigner/vfdutils.pas17
4 files changed, 79 insertions, 67 deletions
diff --git a/uidesigner/vfddesigner.pas b/uidesigner/vfddesigner.pas
index 2aa08248..db548784 100644
--- a/uidesigner/vfddesigner.pas
+++ b/uidesigner/vfddesigner.pas
@@ -143,6 +143,7 @@ implementation
uses
vfdmain,
+ vfdutils,
TypInfo,
fpg_tree;
@@ -1123,7 +1124,7 @@ begin
wgclass := TOtherWidget(wd.Widget).wgClassName
else
wgclass := wd.Widget.ClassName;
- Result := Result + ' ' + wd.Widget.Name + ': ' + wgclass + ';' + LineEnding;
+ Result := Result + Ind(2) + wd.Widget.Name + ': ' + wgclass + ';' + LineEnding;
end;
end;
@@ -1143,9 +1144,9 @@ begin
s := '';
if maindsgn.SaveComponentNames then
- s := s + ' Name := ' + QuotedStr(FForm.Name) + ';' + LineEnding;
+ s := s + Ind(1) + 'Name := ' + QuotedStr(FForm.Name) + ';' + LineEnding;
- s := s + ' SetPosition('
+ s := s + Ind(1) + 'SetPosition('
+ IntToStr(FForm.Left) + ', '
+ IntToStr(FForm.Top) + ', '
+ IntToStr(FForm.Width) + ', '
@@ -1170,14 +1171,14 @@ begin
end;
end;
}
- s := s + ' WindowTitle := ' + QuotedStr(FForm.WindowTitle) + ';' + LineEnding;
+ s := s + Ind(1) + 'WindowTitle := ' + QuotedStr(FForm.WindowTitle) + ';' + LineEnding;
// Hint property - This is ugly, Form's properties are not handled well!!
PropInfo := GetPropInfo(FForm.ClassType, 'Hint');
t := GetStrProp(FForm, 'Hint');
if IsStoredProp(FForm, PropInfo) then
begin
- s := s + ' Hint := ' + QuotedStr(t) + ';' + LineEnding;
+ s := s + Ind(1) + 'Hint := ' + QuotedStr(t) + ';' + LineEnding;
end;
// ShowHint property - This is ugly, Form's properties are not handled well!!
@@ -1191,7 +1192,7 @@ begin
t := 'True'
else
t := 'False';
- s := s + ' ShowHint := ' + t + ';' + LineEnding;
+ s := s + Ind(1) + 'ShowHint := ' + t + ';' + LineEnding;
end;
end;
@@ -1199,7 +1200,7 @@ begin
sl := TStringList.Create;
sl.Text := FFormOther;
for n := 0 to sl.Count - 1 do
- s := s + ' ' + sl.Strings[n] + LineEnding;
+ s := s + Ind(1) + sl.Strings[n] + LineEnding;
sl.Free;
s := s + LineEnding;
@@ -1219,9 +1220,11 @@ begin
else
wgclass := wg.ClassName;
- s := s + ' ' + wg.Name + ' := ' + wgclass + '.Create(' + pwgname + ');' + LineEnding +
- ' with ' + wg.Name + ' do' + LineEnding + ' begin' + LineEnding + GetWidgetSourceImpl(wd, ' ') +
- ' end;' + LineEnding + LineEnding;
+ s := s + Ind(1) + wg.Name + ' := ' + wgclass + '.Create(' + pwgname + ');' + LineEnding +
+ Ind(1) + 'with ' + wg.Name + ' do' + LineEnding +
+ Ind(1) + 'begin' + LineEnding +
+ GetWidgetSourceImpl(wd, Ind(2)) +
+ Ind(1) + 'end;' + LineEnding + LineEnding;
end;
Result := s;
diff --git a/uidesigner/vfdfile.pas b/uidesigner/vfdfile.pas
index 0644fb78..3db2ae31 100644
--- a/uidesigner/vfdfile.pas
+++ b/uidesigner/vfdfile.pas
@@ -25,6 +25,7 @@ interface
uses
SysUtils,
Classes,
+ fpg_base,
fpg_utils;
type
@@ -65,7 +66,8 @@ type
implementation
uses
- fpg_iniutils;
+ fpg_iniutils,
+ vfdutils;
const
cBlockPrefix = '{@VFD_';
@@ -89,14 +91,14 @@ var
s: string;
begin
s :=
- ' T' + formname + ' = class(TfpgForm)' + LineEnding +
- ' private' + LineEnding +
- ' {@VFD_HEAD_BEGIN: ' + formname + '}' + LineEnding
+ Ind(1) + 'T' + formname + ' = class(TfpgForm)' + LineEnding +
+ Ind(1) + 'private' + LineEnding +
+ Ind(2) + '{@VFD_HEAD_BEGIN: ' + formname + '}' + LineEnding
+ formheadblock +
- ' {@VFD_HEAD_END: ' + formname + '}' + LineEnding +
- ' public' + LineEnding +
- ' procedure AfterCreate; override;' + LineEnding
- + ' end;' + LineEnding + LineEnding;
+ Ind(2) + '{@VFD_HEAD_END: ' + formname + '}' + LineEnding +
+ Ind(1) + 'public' + LineEnding +
+ Ind(2) + 'procedure AfterCreate; override;' + LineEnding
+ + Ind(1) + 'end;' + LineEnding + LineEnding;
NewFormsDecl := NewFormsDecl + s;
end;
@@ -110,8 +112,8 @@ begin
lUseRegions := gINI.ReadBool('Options', 'UseCodeRegions', True);
if lUseRegions then
begin
- lRegionTop := ' {%region ''Auto-generated GUI code'' -fold}' + LineEnding;
- lRegionBottom := ' {%endregion}' + LineEnding;
+ lRegionTop := Ind(1) + '{%region ''Auto-generated GUI code'' -fold}' + LineEnding;
+ lRegionBottom := Ind(1) + '{%endregion}' + LineEnding;
end
else
begin
@@ -123,9 +125,9 @@ begin
'procedure T' + formname + '.AfterCreate;' + LineEnding +
'begin' + LineEnding +
lRegionTop +
- ' {@VFD_BODY_BEGIN: ' + formname + '}' + LineEnding +
+ Ind(1) + '{@VFD_BODY_BEGIN: ' + formname + '}' + LineEnding +
formbody +
- ' {@VFD_BODY_END: ' + formname + '}' + LineEnding +
+ Ind(1) + '{@VFD_BODY_END: ' + formname + '}' + LineEnding +
lRegionBottom +
'end;' + LineEnding;
NewFormsImpl := NewFormsImpl + s;
@@ -312,9 +314,9 @@ begin
startmarker := startmarker + ': ' + fb.FormName;
startmarker := startmarker + '}';
if fb.BlockID = 'VFD_HEAD_BEGIN' then
- endmarker := ' {@VFD_HEAD_END: ' + fb.FormName + '}'
+ endmarker := Ind(2) + '{@VFD_HEAD_END: ' + fb.FormName + '}'
else if fb.BlockID = 'VFD_BODY_BEGIN' then
- endmarker := ' {@VFD_BODY_END: ' + fb.FormName + '}'
+ endmarker := Ind(1) + '{@VFD_BODY_END: ' + fb.FormName + '}'
else
endmarker := '';
@@ -348,7 +350,7 @@ begin
'{$mode objfpc}{$H+}' + LineEnding + LineEnding +
'interface' + LineEnding + LineEnding +
'uses' + LineEnding +
- ' SysUtils, Classes, fpg_base, fpg_main, fpg_form;' + LineEnding + LineEnding +
+ Ind(1) + 'SysUtils, Classes, fpg_base, fpg_main, fpg_form;' + LineEnding + LineEnding +
'type' + LineEnding + LineEnding +
'{@VFD_NEWFORM_DECL}' + LineEnding + LineEnding +
'implementation' + LineEnding + LineEnding +
diff --git a/uidesigner/vfdforms.pas b/uidesigner/vfdforms.pas
index 1cb0017b..d1557fbc 100644
--- a/uidesigner/vfdforms.pas
+++ b/uidesigner/vfdforms.pas
@@ -127,11 +127,10 @@ type
lblName3: TfpgLabel;
chkUndoOnExit: TfpgCheckBox;
chkOneClick: TfpgCheckBox;
- Bevel1: TfpgBevel;
- Bevel2: TfpgBevel;
- Bevel3: TfpgBevel;
Label1: TfpgLabel;
chkCodeRegions: TfpgCheckBox;
+ cbIndentationType: TfpgComboBox;
+ lblIndentType: TfpgLabel;
{@VFD_HEAD_END: frmVFDSetup}
constructor Create(AOwner: TComponent); override;
procedure AfterCreate; override;
@@ -357,7 +356,7 @@ begin
TabOrder := 7;
end;
- {@VFD_BODY_END: WidgetOrderForm}
+ {@VFD_BODY_END: WidgetOrderForm}
end;
procedure TWidgetOrderForm.OnButtonClick(Sender: TObject);
@@ -419,6 +418,7 @@ begin
chkUndoOnExit.Checked := gINI.ReadBool('Options', 'UndoOnExit', UndoOnPropExit);
chkOneClick.Checked := gINI.ReadBool('Options', 'OneClickMove', True);
chkCodeRegions.Checked := gINI.ReadBool('Options', 'UseCodeRegions', True);
+ cbIndentationType.FocusItem := gINI.ReadInteger('Options', 'IndentationType', 0);
end;
procedure TfrmVFDSetup.SaveSettings;
@@ -431,6 +431,7 @@ begin
gINI.WriteBool('Options', 'UndoOnExit', chkUndoOnExit.Checked);
gINI.WriteBool('Options', 'OneClickMove', chkOneClick.Checked);
gINI.WriteBool('Options', 'UseCodeRegions', chkCodeRegions.Checked);
+ gINI.WriteInteger('Options', 'IndentationType', cbIndentationType.FocusItem);
end;
procedure TfrmVFDSetup.btnOKClick(Sender: TObject);
@@ -449,7 +450,7 @@ procedure TfrmVFDSetup.AfterCreate;
begin
{@VFD_BODY_BEGIN: frmVFDSetup}
Name := 'frmVFDSetup';
- SetPosition(392, 386, 398, 306);
+ SetPosition(392, 386, 398, 346);
WindowTitle := 'General settings';
Hint := '';
ShowHint := True;
@@ -473,12 +474,12 @@ begin
Name := 'chlGrid';
SetPosition(144, 28, 88, 24);
ExtraHint := '';
- FocusItem := -1;
FontDesc := '#List';
Hint := '';
Items.Add('1');
Items.Add('4');
Items.Add('8');
+ FocusItem := -1;
TabOrder := 1;
end;
@@ -486,7 +487,7 @@ begin
with btnOK do
begin
Name := 'btnOK';
- SetPosition(238, 276, 75, 24);
+ SetPosition(238, 316, 75, 24);
Anchors := [anRight,anBottom];
Text := 'OK';
FontDesc := '#Label1';
@@ -500,7 +501,7 @@ begin
with btnCancel do
begin
Name := 'btnCancel';
- SetPosition(317, 276, 75, 24);
+ SetPosition(317, 316, 75, 24);
Anchors := [anRight,anBottom];
Text := 'Cancel';
FontDesc := '#Label1';
@@ -609,39 +610,6 @@ begin
Text := 'One click select and move';
end;
- Bevel1 := TfpgBevel.Create(self);
- with Bevel1 do
- begin
- Name := 'Bevel1';
- SetPosition(108, 4, 280, 14);
- Anchors := [anLeft,anRight,anTop];
- Hint := '';
- Shape := bsBottomLine;
- Style := bsLowered;
- end;
-
- Bevel2 := TfpgBevel.Create(self);
- with Bevel2 do
- begin
- Name := 'Bevel2';
- SetPosition(192, 104, 196, 14);
- Anchors := [anLeft,anRight,anTop];
- Hint := '';
- Shape := bsBottomLine;
- Style := bsLowered;
- end;
-
- Bevel3 := TfpgBevel.Create(self);
- with Bevel3 do
- begin
- Name := 'Bevel3';
- SetPosition(72, 188, 316, 14);
- Anchors := [anLeft,anRight,anTop];
- Hint := '';
- Shape := bsBottomLine;
- Style := bsLowered;
- end;
-
Label1 := TfpgLabel.Create(self);
with Label1 do
begin
@@ -663,6 +631,30 @@ begin
Text := 'Use code-folding regions in auto-generated code';
end;
+ cbIndentationType := TfpgComboBox.Create(self);
+ with cbIndentationType do
+ begin
+ Name := 'cbIndentationType';
+ SetPosition(216, 264, 152, 24);
+ ExtraHint := '';
+ FontDesc := '#List';
+ Hint := '';
+ Items.Add('Space characters');
+ Items.Add('Tab characters');
+ FocusItem := 0;
+ TabOrder := 16;
+ end;
+
+ lblIndentType := TfpgLabel.Create(self);
+ with lblIndentType do
+ begin
+ Name := 'lblIndentType';
+ SetPosition(24, 268, 192, 16);
+ FontDesc := '#Label1';
+ Hint := '';
+ Text := 'Indent Type for generated code:';
+ end;
+
{@VFD_BODY_END: frmVFDSetup}
LoadSettings;
diff --git a/uidesigner/vfdutils.pas b/uidesigner/vfdutils.pas
index 14b1c561..1fef3792 100644
--- a/uidesigner/vfdutils.pas
+++ b/uidesigner/vfdutils.pas
@@ -34,11 +34,22 @@ uses
procedure SetWidgetText(wg: TfpgWidget; txt: string);
-function GetWidgetText(wg: TfpgWidget; out txt: string): boolean;
+function GetWidgetText(wg: TfpgWidget; out txt: string): boolean;
+{ generates a string based on Indentation Style specified in UI Designer }
+function Ind(const ACount: integer): string;
implementation
+uses
+ fpg_base,
+ fpg_iniutils,
+ strutils;
+
+var
+ IndentCharacters: array[0..1] of TfpgString = (' ', #9);
+
+
procedure SetWidgetText(wg: TfpgWidget; txt: string);
begin
if wg is TfpgForm then
@@ -77,6 +88,10 @@ begin
end;
end;
+function Ind(const ACount: integer): string;
+begin
+ Result := DupeString(IndentCharacters[gINI.ReadInteger('Options', 'IndentationType', 0)], ACount);
+end;
end.