summaryrefslogtreecommitdiff
path: root/examples
diff options
context:
space:
mode:
authorgraemeg <graemeg@ae50a9b5-8222-0410-bf8d-8a13f76226bf>2007-10-07 18:21:03 +0000
committergraemeg <graemeg@ae50a9b5-8222-0410-bf8d-8a13f76226bf>2007-10-07 18:21:03 +0000
commit1e3f35e0e48523772b1ef4cad8baa404cc152c7d (patch)
treec7deef0a753ec694f3fb09246759c67c21f24029 /examples
parent6c72999051b20a306d7e40a55f5df5a48253799f (diff)
downloadfpGUI-1e3f35e0e48523772b1ef4cad8baa404cc152c7d.tar.xz
GUI Designer: Implement a boolean property editor.
GUI Designer: Enabled the Boolean properties of the supported widgets
Diffstat (limited to 'examples')
-rw-r--r--examples/apps/uidesigner/vfdformparser.pas22
-rw-r--r--examples/apps/uidesigner/vfdprops.pas88
-rw-r--r--examples/apps/uidesigner/vfdwidgets.pas14
3 files changed, 118 insertions, 6 deletions
diff --git a/examples/apps/uidesigner/vfdformparser.pas b/examples/apps/uidesigner/vfdformparser.pas
index 9aba3587..1acaed31 100644
--- a/examples/apps/uidesigner/vfdformparser.pas
+++ b/examples/apps/uidesigner/vfdformparser.pas
@@ -57,6 +57,7 @@ function GetStringValue(var s: string): string;
procedure SkipSpaces(var s: string);
function CheckSymbol(var s: string; const sym: string): boolean;
function GetIntValue(var s: string): integer;
+function GetBoolValue(var s: string): boolean;
implementation
@@ -137,6 +138,27 @@ begin
Delete(s, 1, length(ns));
end;
+function GetBoolValue(var s: string): boolean;
+var
+ ts: string;
+ fs: string;
+begin
+ SkipSpaces(s);
+ ts := copy(s, 1, 4); // true string
+ fs := copy(s, 1, 5); // false string
+ if UpperCase(ts) = 'TRUE' then
+ Result := True
+ else if UpperCase(fs) = 'FALSE' then
+ Result := False
+ else
+ raise exception.Create('Failed to parse Boolean value <' + s + '>');
+
+ if Result then
+ Delete(s, 1, 4)
+ else
+ Delete(s, 1, 5);
+end;
+
function GetStringValue(var s: string): string;
var
n: integer;
diff --git a/examples/apps/uidesigner/vfdprops.pas b/examples/apps/uidesigner/vfdprops.pas
index d84c1c47..6d47764b 100644
--- a/examples/apps/uidesigner/vfdprops.pas
+++ b/examples/apps/uidesigner/vfdprops.pas
@@ -70,6 +70,15 @@ type
end;
+ TPropertyBoolean = class(TVFDWidgetProperty)
+ public
+ function ParseSourceLine(wg: TfpgWidget; const line: string): boolean; override;
+ function GetPropertySource(wg: TfpgWidget; const ident: string): string; override;
+ function GetValueText(wg: TfpgWidget): string; override;
+ function CreateEditor(AOwner: TComponent): TVFDPropertyEditor; override;
+ end;
+
+
TGPEType = (gptInteger, gptString);
@@ -94,6 +103,13 @@ type
procedure LoadValue(wg: TfpgWidget); override;
procedure StoreValue(wg: TfpgWidget); override;
end;
+
+
+ TBooleanPropertyEditor = class(TChoicePropertyEditor)
+ public
+ procedure LoadValue(wg: TfpgWidget); override;
+ procedure StoreValue(wg: TfpgWidget); override;
+ end;
TExternalPropertyEditor = class(TVFDPropertyEditor)
@@ -369,6 +385,58 @@ begin
end;
end;
+{ TPropertyBoolean }
+
+
+function TPropertyBoolean.ParseSourceLine(wg: TfpgWidget; const line: string): boolean;
+var
+ s: string;
+ bval: boolean;
+begin
+ s := line;
+ Result := False;
+ if UpperCase(GetIdentifier(s)) <> UpperCase(Name) then
+ Exit;
+
+ Result := CheckSymbol(s, ':=');
+ if Result then
+ begin
+ bval := GetBoolValue(s);
+ Result := CheckSymbol(s, ';');
+ end
+ else
+ bval := False;
+
+ if Result then
+ SetOrdProp(wg, Name, Ord(bval));
+end;
+
+function TPropertyBoolean.GetPropertySource(wg: TfpgWidget; const ident: string): string;
+var
+ i: integer;
+ s: string;
+begin
+ i := GetOrdProp(wg, Name);
+ if i = 1 then
+ s := 'True'
+ else
+ s := 'False';
+ Result := ident + Name + ' := ' + s + ';' + LineEnding;
+end;
+
+function TPropertyBoolean.GetValueText(wg: TfpgWidget): string;
+begin
+ if GetOrdProp(wg, Name) = 1 then
+ Result := 'True'
+ else
+ Result := 'False';
+end;
+
+function TPropertyBoolean.CreateEditor(AOwner: TComponent): TVFDPropertyEditor;
+begin
+ Result := TBooleanPropertyEditor.Create(AOwner, self);
+end;
+
{ TExternalPropertyEditor }
procedure TExternalPropertyEditor.HandlePaint;
@@ -507,5 +575,25 @@ begin
SetEnumProp(wg, prop.Name, chl.Text);
end;
+{ TBooleanPropertyEditor }
+
+procedure TBooleanPropertyEditor.LoadValue(wg: TfpgWidget);
+var
+ b: integer;
+begin
+ b := GetOrdProp(wg, prop.Name);
+ chl.Items.Add('True');
+ chl.Items.Add('False');
+ if b = 1 then
+ chl.FocusItem := 1
+ else
+ chl.FocusItem := 2;
+end;
+
+procedure TBooleanPropertyEditor.StoreValue(wg: TfpgWidget);
+begin
+ SetOrdProp(wg, prop.Name, Ord(StrToBool(chl.Text)));
+end;
+
end.
diff --git a/examples/apps/uidesigner/vfdwidgets.pas b/examples/apps/uidesigner/vfdwidgets.pas
index 547f6540..2e78c20c 100644
--- a/examples/apps/uidesigner/vfdwidgets.pas
+++ b/examples/apps/uidesigner/vfdwidgets.pas
@@ -245,7 +245,7 @@ begin
wc.AddProperty('Text', TPropertyString, 'Initial text');
wc.AddProperty('FontDesc', TPropertyString, 'The font used for displaying the text');
wc.AddProperty('ImageName', TPropertyString, '');
-// wc.AddProperty('ShowImage', TPropertyInteger, 'Boolean value');
+ wc.AddProperty('ShowImage', TPropertyBoolean, 'Boolean value');
wc.AddProperty('ModalResult', TPropertyInteger, '');
wc.WidgetIconName := 'vfd.button';
RegisterVFDWidget(wc);
@@ -255,7 +255,7 @@ begin
wc.NameBase := 'cbName';
wc.AddProperty('Text', TPropertyString, 'Initial text');
wc.AddProperty('FontDesc', TPropertyString, 'The font used for displaying the text');
-// wc.AddProperty('Checked', TPropertyInteger, 'Boolean value');
+ wc.AddProperty('Checked', TPropertyBoolean, 'Boolean value');
// wc.AddProperty('BackgroundColor', TPropertyString, '');
wc.WidgetIconName := 'vfd.checkbox';
RegisterVFDWidget(wc);
@@ -266,7 +266,7 @@ begin
wc.AddProperty('Text', TPropertyString, 'Initial text');
wc.AddProperty('FontDesc', TPropertyString, 'The font used for displaying the text');
wc.AddProperty('GroupIndex', TPropertyInteger, '');
-// wc.AddProperty('Checked', TPropertyInteger, 'Boolean value');
+ wc.AddProperty('Checked', TPropertyBoolean, 'Boolean value');
// wc.AddProperty('BackgroundColor', TPropertyString, '');
wc.WidgetIconName := 'vfd.radiobutton';
RegisterVFDWidget(wc);
@@ -294,6 +294,8 @@ begin
wc.AddProperty('FontDesc', TPropertyString, '');
wc.AddProperty('HeaderFontDesc', TPropertyString, '');
wc.AddProperty('RowCount', TPropertyInteger, '');
+ wc.AddProperty('ShowHeader', TPropertyBoolean, '');
+ wc.AddProperty('ShowGrid', TPropertyBoolean, '');
wc.WidgetIconName := 'vfd.stringgrid';
RegisterVFDWidget(wc);
@@ -343,8 +345,8 @@ begin
wc := TVFDWidgetClass.Create(TfpgTreeView);
wc.NameBase := 'tvName';
wc.AddProperty('FontDesc',TPropertyString, '');
-// wc.AddProperty('ShowImages',TPropertyInteger, 'Boolean value');
-// wc.AddProperty('ShowColumns',TPropertyInteger, 'Boolean value');
+ wc.AddProperty('ShowImages',TPropertyBoolean, 'Boolean value');
+ wc.AddProperty('ShowColumns',TPropertyBoolean, 'Boolean value');
wc.AddProperty('DefaultColumnWidth',TPropertyInteger, '');
wc.AddProperty('TreeLineStyle', TPropertyEnum, '');
// wc.AddProperty('TreeLineColor', TPropertyString, '');
@@ -358,7 +360,7 @@ begin
// wc.AddProperty('ActivePageIndex', TPropertyInteger, '');
// wc.AddProperty('BackgroundColor', TPropertyString, '');
wc.AddProperty('FixedTabWidth', TPropertyInteger, '');
-// wc.AddProperty('SortPages', TPropertyInteger, 'Boolean value');
+ wc.AddProperty('SortPages', TPropertyBoolean, 'Boolean value');
wc.AddProperty('Style', TPropertyEnum, '');
wc.AddProperty('TabPosition', TPropertyEnum, '');
wc.WidgetIconName := 'vfd.pagecontrol';