summaryrefslogtreecommitdiff
path: root/examples
diff options
context:
space:
mode:
authorgraemeg <graemeg@ae50a9b5-8222-0410-bf8d-8a13f76226bf>2007-11-06 20:50:26 +0000
committergraemeg <graemeg@ae50a9b5-8222-0410-bf8d-8a13f76226bf>2007-11-06 20:50:26 +0000
commit6b34d0d7654981ea7c9bfbc732df1fc1c6e12326 (patch)
treef3182ea936bd2b1c84090b89915f65ad099bcce7 /examples
parentab910baffbf9585f5376f6a40f70490a5c765257 (diff)
downloadfpGUI-6b34d0d7654981ea7c9bfbc732df1fc1c6e12326.tar.xz
* Added new TfpgGauge component. Thanks to Giuliano Colla.
* Added new Gauges demo program - thanks to Giuliano Colla.
Diffstat (limited to 'examples')
-rw-r--r--examples/gui/gauges/extrafpc.cfg5
-rw-r--r--examples/gui/gauges/gaugetest.lpi58
-rw-r--r--examples/gui/gauges/gaugetest.lpr296
3 files changed, 359 insertions, 0 deletions
diff --git a/examples/gui/gauges/extrafpc.cfg b/examples/gui/gauges/extrafpc.cfg
new file mode 100644
index 00000000..073dc4b6
--- /dev/null
+++ b/examples/gui/gauges/extrafpc.cfg
@@ -0,0 +1,5 @@
+-FUunits
+-Fu../../../lib
+-Xs
+-XX
+-CX
diff --git a/examples/gui/gauges/gaugetest.lpi b/examples/gui/gauges/gaugetest.lpi
new file mode 100644
index 00000000..d1063c28
--- /dev/null
+++ b/examples/gui/gauges/gaugetest.lpi
@@ -0,0 +1,58 @@
+<?xml version="1.0"?>
+<CONFIG>
+ <ProjectOptions>
+ <PathDelim Value="/"/>
+ <Version Value="6"/>
+ <General>
+ <Flags>
+ <SaveOnlyProjectUnits Value="True"/>
+ </Flags>
+ <SessionStorage Value="InProjectDir"/>
+ <MainUnit Value="0"/>
+ <IconPath Value="./"/>
+ <TargetFileExt Value=".exe"/>
+ </General>
+ <VersionInfo>
+ <ProjectVersion Value=""/>
+ </VersionInfo>
+ <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_package"/>
+ </Item1>
+ </RequiredPackages>
+ <Units Count="1">
+ <Unit0>
+ <Filename Value="gaugetest.lpr"/>
+ <IsPartOfProject Value="True"/>
+ </Unit0>
+ </Units>
+ </ProjectOptions>
+ <CompilerOptions>
+ <Version Value="5"/>
+ <Parsing>
+ <SyntaxOptions>
+ <AllowLabel Value="False"/>
+ <CPPInline Value="False"/>
+ </SyntaxOptions>
+ </Parsing>
+ <CodeGeneration>
+ <Generate Value="Faster"/>
+ </CodeGeneration>
+ <Other>
+ <CustomOptions Value="-FUunits"/>
+ <CompilerPath Value="$(CompPath)"/>
+ </Other>
+ </CompilerOptions>
+</CONFIG>
diff --git a/examples/gui/gauges/gaugetest.lpr b/examples/gui/gauges/gaugetest.lpr
new file mode 100644
index 00000000..1ab55c21
--- /dev/null
+++ b/examples/gui/gauges/gaugetest.lpr
@@ -0,0 +1,296 @@
+program gaugetest;
+
+{$mode objfpc}{$H+}
+
+uses
+ {$IFDEF UNIX}{$IFDEF UseCThreads}
+ cthreads,
+ {$ENDIF}{$ENDIF}
+ Classes, Sysutils
+ { you can add units after this },
+ fpgfx,
+ gfxbase,
+ gui_form,
+ gui_button,
+ gui_progressbar,
+ gui_trackbar,
+ gui_label,
+ gfx_imgfmt_bmp,
+ fpgui_package,
+ gui_edit,
+ gui_bevel,
+ gui_gauge;
+
+type
+
+ TGaugeTest = class(TfpgForm)
+ public
+ {@VFD_HEAD_BEGIN: GaugeTest}
+ CloseBtn: TfpgButton;
+ Gauge: TfpgGauge;
+ MinusBtn: TfpgButton;
+ PlusBtn: TfpgButton;
+ ProgressBar: TfpgProgressBar;
+ TrackBar: TfpgTrackBar;
+ VertGauge: TfpgGauge;
+ TextGauge: TfpgGauge;
+ lblName1: TfpgLabel;
+ lblName2: TfpgLabel;
+ lblName3: TfpgLabel;
+ lblName4: TfpgLabel;
+ NeedleGauge: TfpgGauge;
+ PieGauge: TfpgGauge;
+ DialGauge: TfpgGauge;
+ lblName5: TfpgLabel;
+ lblName6: TfpgLabel;
+ lblName7: TfpgLabel;
+ SmallNeedle: TfpgGauge;
+ {@VFD_HEAD_END: GaugeTest}
+ procedure AfterCreate; override;
+ procedure OnCloseClick (Sender:TObject);
+ procedure OnPlusClick (Sender:TObject);
+ procedure OnMinusClick (Sender:TObject);
+ procedure OnTrackBarChange (Sender: TObject; APosition: integer);
+ end;
+
+{@VFD_NEWFORM_DECL}
+
+
+procedure TGaugeTest.AfterCreate;
+begin
+ {@VFD_BODY_BEGIN: GaugeTest}
+ Name := 'GaugeTest';
+ SetPosition(83, 160, 595, 379);
+ WindowTitle := 'Gauge Test';
+ WindowPosition:= wpScreenCenter;
+ Sizeable := False;
+
+ CloseBtn := TfpgButton.Create(self);
+ with CloseBtn do
+ begin
+ Name := 'CloseBtn';
+ SetPosition(463, 329, 75, 24);
+ Anchors := [anRight,anBottom];
+ Text := 'Close';
+ FontDesc := '#Label1';
+ ImageName := 'stdimg.close';
+ ModalResult := 1;
+ OnClick:= @OnCloseClick;
+ end;
+
+ Gauge := TfpgGauge.Create(self);
+ with Gauge do
+ begin
+ Name := 'Gauge';
+ SetPosition(124, 104, 151, 25);
+ Kind := gkHorizontalBar;
+ end;
+
+ MinusBtn := TfpgButton.Create(self);
+ with MinusBtn do
+ begin
+ Name := 'MinusBtn';
+ SetPosition(116, 329, 24, 24);
+ Anchors := [anLeft,anBottom];
+ Text := '-';
+ FontDesc := '#Label1';
+ ImageName := '';
+ OnClick:= @OnMinusClick;
+ end;
+
+ PlusBtn := TfpgButton.Create(self);
+ with PlusBtn do
+ begin
+ Name := 'PlusBtn';
+ SetPosition(384, 329, 24, 24);
+ Anchors := [anLeft,anBottom];
+ Text := '+';
+ FontDesc := '#Label1';
+ ImageName := '';
+ OnClick:= @OnPlusClick;
+ end;
+
+ ProgressBar := TfpgProgressBar.Create(self);
+ with ProgressBar do
+ begin
+ Name := 'ProgressBar';
+ SetPosition(124, 16, 150, 22);
+ ShowCaption := True;
+ end;
+
+ TrackBar := TfpgTrackBar.Create(self);
+ with TrackBar do
+ begin
+ Name := 'TrackBar';
+ SetPosition(164, 325, 200, 30);
+ Anchors := [anLeft,anBottom];
+ OnChange := @OnTrackBarChange;
+ end;
+
+ VertGauge := TfpgGauge.Create(self);
+ with VertGauge do
+ begin
+ Name := 'VertGauge';
+ SetPosition(352, 32, 25, 100);
+ Kind := gkVerticalBar;
+ ShowText := False;
+ end;
+
+ TextGauge := TfpgGauge.Create(self);
+ with TextGauge do
+ begin
+ Name := 'TextGauge';
+ SetPosition(124, 60, 75, 25);
+ Kind := gkText;
+ end;
+
+ lblName1 := TfpgLabel.Create(self);
+ with lblName1 do
+ begin
+ Name := 'lblName1';
+ SetPosition(16, 20, 92, 16);
+ Text := 'Progress Bar';
+ FontDesc := '#Label1';
+ end;
+
+ lblName2 := TfpgLabel.Create(self);
+ with lblName2 do
+ begin
+ Name := 'lblName2';
+ SetPosition(16, 64, 80, 16);
+ Text := 'Text Gauge';
+ FontDesc := '#Label1';
+ end;
+
+ lblName3 := TfpgLabel.Create(self);
+ with lblName3 do
+ begin
+ Name := 'lblName3';
+ SetPosition(16, 108, 108, 16);
+ Text := 'Horizontal Gauge';
+ FontDesc := '#Label1';
+ end;
+
+ lblName4 := TfpgLabel.Create(self);
+ with lblName4 do
+ begin
+ Name := 'lblName4';
+ SetPosition(324, 12, 96, 16);
+ Text := 'Vertical Gauge';
+ FontDesc := '#Label1';
+ end;
+
+ NeedleGauge := TfpgGauge.Create(self);
+ with NeedleGauge do
+ begin
+ Name := 'NeedleGauge';
+ SetPosition(472, 40, 100, 50);
+ Kind := gkNeedle;
+ end;
+
+ PieGauge := TfpgGauge.Create(self);
+ with PieGauge do
+ begin
+ Name := 'PieGauge';
+ SetPosition(124, 156, 120, 120);
+ Kind := gkPie;
+ end;
+
+ DialGauge := TfpgGauge.Create(self);
+ with DialGauge do
+ begin
+ Name := 'DialGauge';
+ SetPosition(356, 156, 120, 120);
+ Kind := gkDial;
+ end;
+
+ lblName5 := TfpgLabel.Create(self);
+ with lblName5 do
+ begin
+ Name := 'lblName5';
+ SetPosition(152, 288, 80, 16);
+ Text := 'Pie Gauge';
+ FontDesc := '#Label1';
+ end;
+
+ lblName6 := TfpgLabel.Create(self);
+ with lblName6 do
+ begin
+ Name := 'lblName6';
+ SetPosition(384, 288, 80, 16);
+ Text := 'Dial Gauge';
+ FontDesc := '#Label1';
+ end;
+
+ lblName7 := TfpgLabel.Create(self);
+ with lblName7 do
+ begin
+ Name := 'lblName7';
+ SetPosition(476, 100, 100, 16);
+ Text := 'Needle Gauge';
+ FontDesc := '#Label1';
+ end;
+
+ SmallNeedle := TfpgGauge.Create(self);
+ with SmallNeedle do
+ begin
+ Name := 'SmallNeedle';
+ SetPosition(504, 160, 64, 32);
+ Kind := gkNeedle;
+ end;
+
+ {@VFD_BODY_END: GaugeTest}
+end;
+
+procedure TGaugeTest.OnCloseClick(Sender: TObject);
+begin
+ Close;
+end;
+
+procedure TGaugeTest.OnPlusClick(Sender: TObject);
+begin
+ TrackBar.Position:= TrackBar.Position + 5;
+ TrackBar.Invalidate;
+ OnTrackBarChange(self,TrackBar.Position);
+end;
+
+procedure TGaugeTest.OnMinusClick(Sender: TObject);
+begin
+ TrackBar.Position:= TrackBar.Position - 5;
+ TrackBar.Invalidate;
+ OnTrackBarChange(self,TrackBar.Position);
+end;
+
+procedure TGaugeTest.OnTrackBarChange(Sender: TObject; APosition: integer);
+begin
+ Gauge.Progress := APosition;
+ ProgressBar.Position := APosition;
+ VertGauge.Progress := APosition;
+ TextGauge.Progress := APosition;
+ NeedleGauge.Progress := APosition;
+ PieGauge.Progress := APosition;
+ DialGauge.Progress := APosition;
+ SmallNeedle.Progress := APosition;
+end;
+
+
+procedure MainProc;
+var
+ frm: TGaugeTest;
+begin
+ fpgApplication.Initialize;
+ frm := TGaugeTest.Create(nil);
+ try
+ frm.Show;
+ fpgApplication.Run;
+ finally
+ frm.Free;
+ end;
+end;
+
+
+begin
+ MainProc
+end.
+
+