summaryrefslogtreecommitdiff
path: root/examples/gui
diff options
context:
space:
mode:
Diffstat (limited to 'examples/gui')
-rw-r--r--examples/gui/colorwheel/colorwheel_test.lpi4
-rw-r--r--examples/gui/colorwheel/frm_main.pas235
-rw-r--r--examples/gui/customwindow/close.bmpbin0 -> 338 bytes
-rw-r--r--examples/gui/customwindow/custom_window.lpi65
-rw-r--r--examples/gui/customwindow/custom_window.lpr352
-rw-r--r--examples/gui/customwindow/extrafpc.cfg10
-rw-r--r--examples/gui/customwindow/images.inc57
-rw-r--r--examples/gui/customwindow/resize.bmpbin0 -> 474 bytes
-rw-r--r--examples/gui/customwindow/units/.gitignore1
-rw-r--r--examples/gui/drag_n_drop/dndexample.lpr6
-rw-r--r--examples/gui/filedialog/filedialog.lpi2
-rw-r--r--examples/gui/filedialog/filedialog.lpr2
-rw-r--r--examples/gui/gridtest/gridtest.lpr11
-rw-r--r--examples/gui/listviewtest/listviewtest.lpi7
-rw-r--r--examples/gui/listviewtest/listviewtest.lpr20
-rw-r--r--examples/gui/modalforms/modalforms.lpi2
-rw-r--r--examples/gui/modalforms/modalforms.lpr5
-rw-r--r--examples/gui/reporting/u_demo.pas3
-rw-r--r--examples/gui/togglebox/ToggleBoxTest.lpi77
-rw-r--r--examples/gui/togglebox/ToggleBoxTest.lpr30
-rw-r--r--examples/gui/togglebox/mainfrm.pas44
-rw-r--r--examples/gui/video_vlc/frmvlcplayer.pas34
-rw-r--r--examples/gui/video_vlc/testfpguivlc.lpi13
23 files changed, 920 insertions, 60 deletions
diff --git a/examples/gui/colorwheel/colorwheel_test.lpi b/examples/gui/colorwheel/colorwheel_test.lpi
index 3ad6b196..a0be0fc2 100644
--- a/examples/gui/colorwheel/colorwheel_test.lpi
+++ b/examples/gui/colorwheel/colorwheel_test.lpi
@@ -38,7 +38,6 @@
<Unit0>
<Filename Value="colorwheel_test.lpr"/>
<IsPartOfProject Value="True"/>
- <UnitName Value="colorwheel_test"/>
</Unit0>
<Unit1>
<Filename Value="frm_main.pas"/>
@@ -64,8 +63,5 @@
<UseAnsiStrings Value="False"/>
</SyntaxOptions>
</Parsing>
- <Other>
- <CompilerPath Value="$(CompPath)"/>
- </Other>
</CompilerOptions>
</CONFIG>
diff --git a/examples/gui/colorwheel/frm_main.pas b/examples/gui/colorwheel/frm_main.pas
index 3633b740..612ea6c1 100644
--- a/examples/gui/colorwheel/frm_main.pas
+++ b/examples/gui/colorwheel/frm_main.pas
@@ -8,10 +8,34 @@ uses
SysUtils, Classes, fpg_base, fpg_main, fpg_widget,
fpg_edit, fpg_form, fpg_label, fpg_button,
fpg_dialogs, fpg_menu, fpg_checkbox,
- fpg_panel, fpg_ColorWheel;
+ fpg_panel, fpg_ColorWheel, fpg_spinedit;
type
+ TColorPickedEvent = procedure(Sender: TObject; const AMousePos: TPoint; const AColor: TfpgColor) of object;
+
+
+ TPickerButton = class(TfpgButton)
+ private
+ FContinuousResults: Boolean;
+ FOnColorPicked: TColorPickedEvent;
+ FColorPos: TPoint;
+ FColor: TfpgColor;
+ FColorPicking: Boolean;
+ private
+ procedure DoColorPicked;
+ protected
+ procedure HandleLMouseDown(X, Y: integer; ShiftState: TShiftState); override;
+ procedure HandleLMouseUp(x, y: integer; shiftstate: TShiftState); override;
+ procedure HandleMouseMove(x, y: integer; btnstate: word; shiftstate: TShiftState); override;
+ public
+ constructor Create(AOwner: TComponent); override;
+ published
+ property ContinuousResults: Boolean read FContinuousResults write FContinuousResults;
+ property OnColorPicked: TColorPickedEvent read FOnColorPicked write FOnColorPicked;
+ end;
+
+
TMainForm = class(TfpgForm)
private
{@VFD_HEAD_BEGIN: MainForm}
@@ -28,36 +52,134 @@ type
Label4: TfpgLabel;
Label5: TfpgLabel;
Label6: TfpgLabel;
- edR: TfpgEdit;
- edG: TfpgEdit;
- edB: TfpgEdit;
+ edR: TfpgSpinEdit;
+ edG: TfpgSpinEdit;
+ edB: TfpgSpinEdit;
+ lblHex: TfpgLabel;
Label7: TfpgLabel;
Label8: TfpgLabel;
Bevel2: TfpgBevel;
Label9: TfpgLabel;
chkCrossHair: TfpgCheckBox;
chkBGColor: TfpgCheckBox;
+ btnPicker: TPickerButton;
+ chkContinuous: TfpgCheckBox;
{@VFD_HEAD_END: MainForm}
FViaRGB: Boolean; // to prevent recursive changes
- procedure btnQuitClicked(Sender: TObject);
- procedure chkCrossHairChange(Sender: TObject);
- procedure chkBGColorChange(Sender: TObject);
- procedure UpdateHSVComponents;
- procedure UpdateRGBComponents;
- procedure ColorChanged(Sender: TObject);
- procedure RGBChanged(Sender: TObject);
+ FColorPicking: Boolean;
+ procedure btnColorPicked(Sender: TObject; const AMousePos: TPoint; const AColor: TfpgColor);
+ procedure chkContinuousChanged(Sender: TObject);
+ procedure btnQuitClicked(Sender: TObject);
+ procedure chkCrossHairChange(Sender: TObject);
+ procedure chkBGColorChange(Sender: TObject);
+ procedure UpdateHSVComponents;
+ procedure UpdateRGBComponents;
+ procedure ColorChanged(Sender: TObject);
+ procedure RGBChanged(Sender: TObject);
public
constructor Create(AOwner: TComponent); override;
- procedure AfterCreate; override;
+ procedure AfterCreate; override;
end;
{@VFD_NEWFORM_DECL}
implementation
-
{@VFD_NEWFORM_IMPL}
+function ConvertToHexa(Value: Integer): string;
+var
+ ValH,ValL: Integer;
+begin
+ValH:= Value div 16;
+ValL:= Value mod 16;
+case ValH of
+ 15:
+ Result:= 'F';
+ 14:
+ Result:= 'E';
+ 13:
+ Result:= 'D';
+ 12:
+ Result:= 'C';
+ 11:
+ Result:= 'B';
+ 10:
+ Result:= 'A';
+ else
+ Result:= IntToStr(ValH);
+ end;
+case ValL of
+ 15:
+ Result:= Result+'F';
+ 14:
+ Result:= Result+'E';
+ 13:
+ Result:= Result+'D';
+ 12:
+ Result:= Result+'C';
+ 11:
+ Result:= Result+'B';
+ 10:
+ Result:= Result+'A';
+ else
+ Result:= Result+IntToStr(ValL);
+ end;
+end;
+
+function Hexa(Red,Green,Blue: Integer): string;
+begin
+Result:= '$'+ConvertToHexa(Red)+ConvertToHexa(Green)+ConvertToHexa(Blue);
+end;
+
+{ TPickerButton }
+
+procedure TPickerButton.DoColorPicked;
+var
+ pt: TPoint;
+begin
+ pt := WindowToScreen(self, FColorPos);
+ FColor := fpgApplication.GetScreenPixelColor(pt);
+ if Assigned(FOnColorPicked) then
+ FOnColorPicked(self, FColorPos, FColor);
+end;
+
+procedure TPickerButton.HandleLMouseDown(X, Y: integer; ShiftState: TShiftState);
+begin
+ inherited HandleLMouseDown(X, Y, ShiftState);
+ MouseCursor := mcCross;
+ FColorPicking := True;
+ CaptureMouse;
+end;
+
+procedure TPickerButton.HandleLMouseUp(x, y: integer; shiftstate: TShiftState);
+begin
+ inherited HandleLMouseUp(x, y, shiftstate);
+ ReleaseMouse;
+ FColorPicking := False;
+ MouseCursor := mcDefault;
+ DoColorPicked;
+end;
+
+procedure TPickerButton.HandleMouseMove(x, y: integer; btnstate: word;
+ shiftstate: TShiftState);
+begin
+ //inherited HandleMouseMove(x, y, btnstate, shiftstate);
+ if not FColorPicking then
+ Exit;
+ FColorPos.x := x;
+ FColorPos.y := y;
+ if FContinuousResults then
+ DoColorPicked;
+end;
+
+constructor TPickerButton.Create(AOwner: TComponent);
+begin
+ inherited Create(AOwner);
+ FColorPicking := False;
+ FContinuousResults := False;
+end;
+
procedure TMainForm.ColorChanged(Sender: TObject);
begin
UpdateHSVComponents;
@@ -71,18 +193,30 @@ var
c: TfpgColor;
begin
FViaRGB := True; // revent recursive updates
- rgb.Red := StrToInt(edR.Text);
- rgb.Green := StrToInt(edG.Text);
- rgb.Blue := StrToInt(edB.Text);
+ rgb.Red := edR.Value;
+ rgb.Green := edG.Value;
+ rgb.Blue := edB.Value;
c := RGBTripleTofpgColor(rgb);
ColorWheel1.SetSelectedColor(c); // This will trigger ColorWheel and ValueBar OnChange event
FViaRGB := False;
+ lblHex.Text:= 'Hex = '+ Hexa(rgb.Red,rgb.Green,rgb.Blue);
end;
constructor TMainForm.Create(AOwner: TComponent);
begin
inherited Create(AOwner);
FViaRGB := False;
+ FColorPicking := False;
+end;
+
+procedure TMainForm.btnColorPicked(Sender: TObject; const AMousePos: TPoint; const AColor: TfpgColor);
+begin
+ ColorWheel1.SetSelectedColor(AColor);
+end;
+
+procedure TMainForm.chkContinuousChanged(Sender: TObject);
+begin
+ btnPicker.ContinuousResults := chkContinuous.Checked;
end;
procedure TMainForm.btnQuitClicked(Sender: TObject);
@@ -127,9 +261,10 @@ var
begin
c := ValueBar1.SelectedColor;
rgb := fpgColorToRGBTriple(c);
- edR.Text := IntToStr(rgb.Red);
- edG.Text := IntToStr(rgb.Green);
- edB.Text := IntToStr(rgb.Blue);
+ edR.Value := rgb.Red;
+ edG.Value := rgb.Green;
+ edB.Value := rgb.Blue;
+ lblHex.Text:= 'Hex = '+ Hexa(rgb.Red,rgb.Green,rgb.Blue);
end;
procedure TMainForm.AfterCreate;
@@ -138,6 +273,7 @@ begin
Name := 'MainForm';
SetPosition(349, 242, 537, 411);
WindowTitle := 'ColorWheel test app';
+ Hint := '';
WindowPosition := wpUser;
Button1 := TfpgButton.Create(self);
@@ -166,6 +302,7 @@ begin
begin
Name := 'ValueBar1';
SetPosition(304, 20, 52, 244);
+ Value := 1;
OnChange := @ColorChanged;
end;
@@ -174,6 +311,7 @@ begin
begin
Name := 'Bevel1';
SetPosition(20, 288, 76, 56);
+ Hint := '';
end;
Label1 := TfpgLabel.Create(self);
@@ -275,39 +413,55 @@ begin
Text := 'Blue';
end;
- edR := TfpgEdit.Create(self);
+ edR := TfpgSpinEdit.Create(self);
with edR do
begin
Name := 'edR';
SetPosition(296, 280, 44, 26);
TabOrder := 13;
- Text := '255';
+ MinValue := 0;
+ MaxValue := 255;
+ Value := 255;
FontDesc := '#Edit1';
OnExit := @RGBChanged;
end;
- edG := TfpgEdit.Create(self);
+ edG := TfpgSpinEdit.Create(self);
with edG do
begin
Name := 'edG';
SetPosition(296, 308, 44, 26);
TabOrder := 14;
- Text := '255';
+ MinValue := 0;
+ MaxValue := 255;
+ Value := 255;
FontDesc := '#Edit1';
OnExit := @RGBChanged;
end;
- edB := TfpgEdit.Create(self);
+ edB := TfpgSpinEdit.Create(self);
with edB do
begin
Name := 'edB';
SetPosition(296, 336, 44, 26);
TabOrder := 15;
- Text := '255';
+ MinValue := 0;
+ MaxValue := 255;
+ Value := 255;
FontDesc := '#Edit1';
OnExit := @RGBChanged;
end;
+ lblHex := TfpgLabel.Create(self);
+ with lblHex do
+ begin
+ Name := 'lblHex';
+ SetPosition(380, 316, 120, 16);
+ FontDesc := '#Label2';
+ Hint := '';
+ Text := 'Hex = ';
+ end;
+
Label7 := TfpgLabel.Create(self);
with Label7 do
begin
@@ -333,6 +487,7 @@ begin
begin
Name := 'Bevel2';
SetPosition(388, 8, 2, 260);
+ Hint := '';
Style := bsLowered;
end;
@@ -353,6 +508,7 @@ begin
Name := 'chkCrossHair';
SetPosition(396, 32, 128, 20);
FontDesc := '#Label1';
+ Hint := '';
TabOrder := 20;
Text := 'Large CrossHair';
OnChange := @chkCrossHairChange;
@@ -364,11 +520,37 @@ begin
Name := 'chkBGColor';
SetPosition(396, 56, 132, 20);
FontDesc := '#Label1';
+ Hint := '';
TabOrder := 21;
Text := 'New BG Color';
OnChange := @chkBGColorChange;
end;
+ btnPicker := TPickerButton.Create(self);
+ with btnPicker do
+ begin
+ Name := 'btnPicker';
+ SetPosition(116, 372, 80, 23);
+ Text := 'Picker';
+ FontDesc := '#Label1';
+ Hint := '';
+ ImageName := '';
+ TabOrder := 24;
+ OnColorPicked := @btnColorPicked;
+ end;
+
+ chkContinuous := TfpgCheckBox.Create(self);
+ with chkContinuous do
+ begin
+ Name := 'chkContinous';
+ SetPosition(205, 375, 90, 19);
+ FontDesc := '#Label1';
+ Hint := '';
+ TabOrder := 25;
+ Text := 'Continous';
+ OnChange := @chkContinuousChanged;
+ end;
+
{@VFD_BODY_END: MainForm}
// link the two components
@@ -376,6 +558,9 @@ begin
// ColorWheel1.BackgroundColor := clFuchsia;
// ValueBar1.BackgroundColor := clFuchsia;
// ColorWheel1.CursorSize := 400;
+ UpdateHSVComponents;
+ if not FViaRGB then
+ UpdateRGBComponents;
end;
diff --git a/examples/gui/customwindow/close.bmp b/examples/gui/customwindow/close.bmp
new file mode 100644
index 00000000..af6745a5
--- /dev/null
+++ b/examples/gui/customwindow/close.bmp
Binary files differ
diff --git a/examples/gui/customwindow/custom_window.lpi b/examples/gui/customwindow/custom_window.lpi
new file mode 100644
index 00000000..2059fa29
--- /dev/null
+++ b/examples/gui/customwindow/custom_window.lpi
@@ -0,0 +1,65 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<CONFIG>
+ <ProjectOptions>
+ <Version Value="9"/>
+ <General>
+ <SessionStorage Value="InProjectDir"/>
+ <MainUnit Value="0"/>
+ <Title Value="custom_window"/>
+ <UseAppBundle Value="False"/>
+ <ResourceType Value="res"/>
+ </General>
+ <i18n>
+ <EnableI18N LFM="False"/>
+ </i18n>
+ <VersionInfo>
+ <StringTable ProductVersion=""/>
+ </VersionInfo>
+ <BuildModes Count="1">
+ <Item1 Name="Default" Default="True"/>
+ </BuildModes>
+ <PublishOptions>
+ <Version Value="2"/>
+ </PublishOptions>
+ <RunParams>
+ <local>
+ <FormatVersion Value="1"/>
+ </local>
+ </RunParams>
+ <RequiredPackages Count="1">
+ <Item1>
+ <PackageName Value="fpgui_toolkit"/>
+ </Item1>
+ </RequiredPackages>
+ <Units Count="2">
+ <Unit0>
+ <Filename Value="custom_window.lpr"/>
+ <IsPartOfProject Value="True"/>
+ <UnitName Value="custom_window"/>
+ </Unit0>
+ <Unit1>
+ <Filename Value="images.inc"/>
+ <IsPartOfProject Value="True"/>
+ </Unit1>
+ </Units>
+ </ProjectOptions>
+ <CompilerOptions>
+ <Version Value="11"/>
+ <SearchPaths>
+ <IncludeFiles Value="$(ProjOutDir)"/>
+ </SearchPaths>
+ </CompilerOptions>
+ <Debugging>
+ <Exceptions Count="3">
+ <Item1>
+ <Name Value="EAbort"/>
+ </Item1>
+ <Item2>
+ <Name Value="ECodetoolError"/>
+ </Item2>
+ <Item3>
+ <Name Value="EFOpenError"/>
+ </Item3>
+ </Exceptions>
+ </Debugging>
+</CONFIG>
diff --git a/examples/gui/customwindow/custom_window.lpr b/examples/gui/customwindow/custom_window.lpr
new file mode 100644
index 00000000..eab06e5d
--- /dev/null
+++ b/examples/gui/customwindow/custom_window.lpr
@@ -0,0 +1,352 @@
+{ This was a very quick and dirty demo to show how custom windows with your
+ own style of borders (eg: like Chrome or elementryOS) can be implement.
+ There is obviously lots of scope for improving this code and creating
+ custom widgets to make better use of code reuse and abstraction. }
+program custom_window;
+
+{$mode objfpc}{$H+}
+
+uses
+ {$IFDEF UNIX}{$IFDEF UseCThreads}
+ cthreads,
+ {$ENDIF}{$ENDIF}
+ Classes, SysUtils,
+ fpg_base, fpg_main, fpg_form, fpg_button,
+ fpg_stylemanager, fpg_cmdlineparams, fpg_grid,
+ fpg_StringGridBuilder, fpg_editbtn, fpg_checkbox,
+ fpg_panel, fpg_dialogs;
+
+type
+
+ TMainForm = class(TfpgForm)
+ procedure ResizeClicked(Sender: TObject);
+ private
+ {@VFD_HEAD_BEGIN: MainForm}
+ btnQuit: TfpgButton;
+ Grid1: TfpgStringGrid;
+ FilenameEdit1: TfpgFileNameEdit;
+ btnGo: TfpgButton;
+ CheckBox1: TfpgCheckBox;
+ bvlTitle: TfpgBevel;
+ btnClose: TfpgImagePanel;
+ btnResize: TfpgImagePanel;
+ bvlTasks: TfpgBevel;
+ {@VFD_HEAD_END: MainForm}
+ FLastPos: TPoint;
+ FMouseTracked: Boolean;
+ procedure TitleMouseDown(Sender: TObject; AButton: TMouseButton; AShift: TShiftState; const AMousePos: TPoint);
+ procedure TitleMouseUp(Sender: TObject; AButton: TMouseButton; AShift: TShiftState; const AMousePos: TPoint);
+ procedure TitleMouseMoved(Sender: TObject; AShift: TShiftState; const AMousePos: TPoint);
+ procedure btnCloseClicked(Sender: TObject);
+ procedure PaintTasksPanel(Sender: TObject);
+ procedure PaintTitle(Sender: TObject);
+ procedure FormPaint(Sender: TObject);
+ procedure btnQuitClicked(Sender: TObject);
+ procedure btnGoClicked(Sender: TObject);
+ public
+ constructor Create(AOwner: TComponent); override;
+ procedure AfterCreate; override;
+ end;
+
+{@VFD_NEWFORM_DECL}
+
+const
+ cBackground = TfpgColor($FFf5f5f5);
+ cGradientTop = TfpgColor($FFe5e5e5);
+ cGradientBottom = TfpgColor($FFbcbcbc);
+ cBorder = TfpgColor($FF7c7c7c);
+ cGrayPanel = TfpgColor($FFdedede);
+
+ { tip: probably best to use specific fonts for specific OSes }
+ cHeader1 = 'Arial-11:bold:antialias=true';
+ cHeader2 = 'Arial-10:antialias=true';
+
+{$I images.inc}
+
+{@VFD_NEWFORM_IMPL}
+
+procedure TMainForm.ResizeClicked(Sender: TObject);
+begin
+ ShowMessage('I''ll leave this one up to you to implement and experiment with. ;-)', 'Hint');
+end;
+
+procedure TMainForm.TitleMouseDown(Sender: TObject; AButton: TMouseButton;
+ AShift: TShiftState; const AMousePos: TPoint);
+begin
+ FMouseTracked := True;
+ FLastPos := bvlTitle.WindowToScreen(self, AMousePos);
+ bvlTitle.CaptureMouse;
+end;
+
+procedure TMainForm.TitleMouseUp(Sender: TObject; AButton: TMouseButton;
+ AShift: TShiftState; const AMousePos: TPoint);
+begin
+ FMouseTracked := False;
+ bvlTitle.ReleaseMouse;
+end;
+
+procedure TMainForm.TitleMouseMoved(Sender: TObject; AShift: TShiftState;
+ const AMousePos: TPoint);
+var
+ dx, dy: integer;
+ pt: TPoint;
+begin
+ pt := WindowToScreen(self, AMousePos);
+ if not FMouseTracked then
+ begin
+ FLastPos := pt;
+ Exit;
+ end;
+
+ dx := pt.X - FLastPos.X;
+ dy := pt.Y - FLastPos.Y;
+ Left := Left + dx;
+ Top := Top + dy;
+ FLastPos := pt;
+ UpdateWindowPosition;
+end;
+
+procedure TMainForm.btnCloseClicked(Sender: TObject);
+begin
+ btnQuit.Click;
+end;
+
+procedure TMainForm.PaintTasksPanel(Sender: TObject);
+begin
+ with bvlTasks do
+ begin
+ Canvas.Clear(cGrayPanel);
+
+ Canvas.Color := cBorder;
+ Canvas.DrawRectangle(0, 0, Width, Height);
+
+ Canvas.TextColor := cBorder;
+ // Output some sample text
+ Canvas.Font := fpgGetFont(cHeader1);
+ Canvas.DrawText(8, 10, 'Personal');
+ Canvas.Font := fpgGetFont(cHeader2);
+ Canvas.DrawText(20, 30, 'Home');
+ Canvas.DrawText(20, 50, 'Documents');
+ Canvas.DrawText(20, 70, 'Music');
+ Canvas.DrawText(20, 90, 'Pictures');
+ Canvas.Font := fpgGetFont(cHeader1);
+ Canvas.DrawText(8, 110, 'Network');
+ Canvas.Font := fpgGetFont(cHeader2);
+ Canvas.DrawText(20, 130, 'Entire network');
+ end;
+end;
+
+procedure TMainForm.PaintTitle(Sender: TObject);
+var
+ r: TfpgRect;
+begin
+ r.SetRect(0, 1, Width, 46);
+ with bvlTitle do
+ begin
+ Canvas.GradientFill(r, cGradientTop, cGradientBottom, gdVertical);
+
+ Canvas.Color := TfpgColor($FFc9c9c9);
+ Canvas.DrawLine(0, Height-2, Width, Height-2);
+
+ Canvas.Color := cBorder;
+ Canvas.DrawRectangle(0, 0, Width, Height);
+
+ Canvas.TextColor := cBorder;
+ Canvas.Font := fpgGetFont(cHeader1);
+ Canvas.DrawText(30, 8, Width-60, 20, WindowTitle, [txtHCenter, txtTop]);
+ end;
+end;
+
+procedure TMainForm.FormPaint(Sender: TObject);
+begin
+ Canvas.Color := cBorder;
+ Canvas.DrawRectangle(0, 0, Width, Height);
+end;
+
+procedure TMainForm.btnQuitClicked(Sender: TObject);
+begin
+ Close;
+end;
+
+procedure TMainForm.btnGoClicked(Sender: TObject);
+var
+ sgb: TStringGridBuilder;
+begin
+ try
+ sgb := TStringGridBuilder.CreateCustom(Grid1, FilenameEdit1.FileName, CheckBox1.Checked);
+ sgb.Run;
+ finally
+ sgb.Free;
+ end;
+end;
+
+constructor TMainForm.Create(AOwner: TComponent);
+begin
+ inherited Create(AOwner);
+ Include(FWindowAttributes, waBorderLess); // borderless and steals focus like a normal form
+ FMouseTracked := False;
+
+ fpgSetNamedColor(clWindowBackground, cBackground);
+
+ fpgImages.AddBMP( // 8x9 pixels.
+ 'my.close',
+ @img_close,
+ sizeof(img_close));
+
+ fpgImages.AddBMP( // 10x11 pixels.
+ 'my.resize',
+ @img_resize,
+ sizeof(img_resize));
+end;
+
+procedure TMainForm.AfterCreate;
+begin
+ {%region 'Auto-generated GUI code' -fold}
+ {@VFD_BODY_BEGIN: MainForm}
+ Name := 'MainForm';
+ SetPosition(464, 271, 866, 473);
+ WindowTitle := 'fpGUI Custom Window Demo';
+ Hint := '';
+ OnPaint := @FormPaint;
+
+ btnQuit := TfpgButton.Create(self);
+ with btnQuit do
+ begin
+ Name := 'btnQuit';
+ SetPosition(772, 436, 80, 23);
+ Text := 'Quit';
+ FontDesc := '#Label1';
+ Hint := '';
+ ImageName := '';
+ TabOrder := 1;
+ OnClick := @btnQuitClicked;
+ end;
+
+ Grid1 := TfpgStringGrid.Create(self);
+ with Grid1 do
+ begin
+ Name := 'Grid1';
+ SetPosition(182, 120, 666, 276);
+ BackgroundColor := TfpgColor($80000002);
+ FontDesc := '#Grid';
+ HeaderFontDesc := '#GridHeader';
+ Hint := '';
+ RowCount := 0;
+ RowSelect := False;
+ TabOrder := 2;
+ end;
+
+ FilenameEdit1 := TfpgFileNameEdit.Create(self);
+ with FilenameEdit1 do
+ begin
+ Name := 'FilenameEdit1';
+ SetPosition(182, 92, 510, 24);
+ ExtraHint := '';
+ FileName := '';
+ Filter := 'CSV Files (*.csv)|*.csv';
+ InitialDir := '';
+ TabOrder := 3;
+ end;
+
+ btnGo := TfpgButton.Create(self);
+ with btnGo do
+ begin
+ Name := 'btnGo';
+ SetPosition(768, 92, 80, 23);
+ Text := 'GO';
+ FontDesc := '#Label1';
+ Hint := '';
+ ImageName := '';
+ TabOrder := 4;
+ OnClick := @btnGoClicked;
+ end;
+
+ CheckBox1 := TfpgCheckBox.Create(self);
+ with CheckBox1 do
+ begin
+ Name := 'CheckBox1';
+ SetPosition(184, 68, 120, 19);
+ FontDesc := '#Label1';
+ Hint := '';
+ TabOrder := 5;
+ Text := 'Has Header';
+ end;
+
+ bvlTitle := TfpgBevel.Create(self);
+ with bvlTitle do
+ begin
+ Name := 'bvlTitle';
+ SetPosition(0, 0, 866, 48);
+ Anchors := [anLeft,anRight,anTop];
+ Hint := '';
+ Shape := bsSpacer;
+ OnPaint := @PaintTitle;
+ OnMouseMove := @TitleMouseMoved;
+ OnMouseDown := @TitleMouseDown;
+ OnMouseUp := @TitleMouseUp;
+ end;
+
+ btnClose := TfpgImagePanel.Create(bvlTitle);
+ with btnClose do
+ begin
+ Name := 'btnClose';
+ SetPosition(9, 8, 8, 9);
+ OwnsImage := False;
+ OnClick := @btnCloseClicked;
+ end;
+
+ btnResize := TfpgImagePanel.Create(bvlTitle);
+ with btnResize do
+ begin
+ Name := 'btnResize';
+ SetPosition(849, 8, 10, 11);
+ OwnsImage := False;
+ OnClick := @ResizeClicked;
+ end;
+
+ bvlTasks := TfpgBevel.Create(self);
+ with bvlTasks do
+ begin
+ Name := 'bvlTasks';
+ SetPosition(0, 47, 170, 426);
+ Anchors := [anLeft,anTop,anBottom];
+ Hint := '';
+ Shape := bsSpacer;
+ OnPaint := @PaintTasksPanel;
+ end;
+
+ {@VFD_BODY_END: MainForm}
+ {%endregion}
+
+ btnClose.Image := fpgImages.GetImage('my.close');
+ btnResize.Image := fpgImages.GetImage('my.resize');
+end;
+
+
+procedure MainProc;
+var
+ frm: TMainForm;
+begin
+ fpgApplication.Initialize;
+
+ { Set our new style as the default (before we create any forms), unless
+ a the end-user specified a different style via the command line. }
+ if not gCommandLineParams.IsParam('style') then
+ begin
+ if fpgStyleManager.SetStyle('Plastic Light Gray') then
+ fpgStyle := fpgStyleManager.Style;
+ end;
+
+ frm := TMainForm.Create(nil);
+ try
+ frm.Show;
+ fpgApplication.Run;
+ finally
+ frm.Free;
+ end;
+end;
+
+begin
+ MainProc;
+end.
+
diff --git a/examples/gui/customwindow/extrafpc.cfg b/examples/gui/customwindow/extrafpc.cfg
new file mode 100644
index 00000000..89eafa99
--- /dev/null
+++ b/examples/gui/customwindow/extrafpc.cfg
@@ -0,0 +1,10 @@
+-FUunits
+-Fu../../../lib/$fpctarget
+-Fu../common/
+-Xs
+-XX
+-CX
+#ifdef mswindows
+-WG
+#endif
+
diff --git a/examples/gui/customwindow/images.inc b/examples/gui/customwindow/images.inc
new file mode 100644
index 00000000..79663a24
--- /dev/null
+++ b/examples/gui/customwindow/images.inc
@@ -0,0 +1,57 @@
+
+const
+ img_close: array[0..337] of byte = (
+ 66, 77, 82, 1, 0, 0, 0, 0, 0, 0,122, 0, 0, 0,108, 0, 0,
+ 0, 8, 0, 0, 0, 9, 0, 0, 0, 1, 0, 24, 0, 0, 0, 0, 0,
+ 216, 0, 0, 0,196, 14, 0, 0,196, 14, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 66, 71, 82,115, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0,226,226,226,238,238,238,225,225,225,223,223,223,223,223,
+ 223,226,226,226,238,238,238,226,226,226,228,228,228,184,184,184,231,
+ 231,231,226,226,226,226,226,226,230,230,230,184,184,184,228,228,228,
+ 172,172,172,160,160,160,173,173,173,231,231,231,231,231,231,173,173,
+ 173,160,160,160,172,172,172,216,216,216,159,159,159,153,153,153,170,
+ 170,170,168,168,168,153,153,153,157,157,157,215,215,215,225,225,225,
+ 219,219,219,165,165,165,149,149,149,149,149,149,162,162,162,218,218,
+ 218,225,225,225,227,227,227,229,229,229,158,158,158,141,141,141,142,
+ 142,142,163,163,163,232,232,232,227,227,227,227,227,227,152,152,152,
+ 136,136,136,146,146,146,144,144,144,136,136,136,154,154,154,228,228,
+ 228,149,149,149,128,128,128,140,140,140,217,217,217,215,215,215,138,
+ 138,138,128,128,128,150,150,150,213,213,213,147,147,147,214,214,214,
+ 226,226,226,226,226,226,214,214,214,146,146,146,213,213,213);
+
+
+const
+ img_resize: array[0..473] of byte = (
+ 66, 77,218, 1, 0, 0, 0, 0, 0, 0,122, 0, 0, 0,108, 0, 0,
+ 0, 10, 0, 0, 0, 11, 0, 0, 0, 1, 0, 24, 0, 0, 0, 0, 0,
+ 96, 1, 0, 0,196, 14, 0, 0,196, 14, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 66, 71, 82,115, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0,242,242,242,242,242,242,242,242,242,242,242,242,233,233,
+ 233,223,223,223,223,223,223,223,223,223,223,223,223,223,223,223, 0,
+ 0,167,167,167,167,167,167,167,167,167,162,162,162,189,189,189,223,
+ 223,223,223,223,223,223,223,223,223,223,223,223,223,223, 0, 0,157,
+ 157,157,157,157,157,157,157,157,193,193,193,226,226,226,224,224,224,
+ 224,224,224,224,224,224,224,224,224,224,224,224, 0, 0,146,146,146,
+ 141,141,141,144,144,144,164,164,164,229,229,229,224,224,224,224,224,
+ 224,224,224,224,224,224,224,224,224,224, 0, 0,131,131,131,175,175,
+ 175,146,146,146,133,133,133,153,153,153,224,224,224,224,224,224,224,
+ 224,224,224,224,224,224,224,224, 0, 0,174,174,174,225,225,225,215,
+ 215,215,146,146,146,208,208,208,228,228,228,239,239,239,227,227,227,
+ 225,225,225,235,235,235, 0, 0,225,225,225,225,225,225,225,225,225,
+ 225,225,225,225,225,225,225,225,225,183,183,183,232,232,232,235,235,
+ 235,201,201,201, 0, 0,226,226,226,226,226,226,226,226,226,226,226,
+ 226,226,226,226,167,167,167,153,153,153,167,167,167,193,193,193,154,
+ 154,154, 0, 0,226,226,226,226,226,226,226,226,226,226,226,226,226,
+ 226,226,215,215,215,152,152,152,144,144,144,144,144,144,144,144,144,
+ 0, 0,226,226,226,226,226,226,226,226,226,226,226,226,226,226,226,
+ 235,235,235,184,184,184,134,134,134,134,134,134,134,134,134, 0, 0,
+ 227,227,227,227,227,227,227,227,227,227,227,227,227,227,227,168,168,
+ 168,115,115,115,115,115,115,115,115,115,115,115,115, 0, 0);
+
+
diff --git a/examples/gui/customwindow/resize.bmp b/examples/gui/customwindow/resize.bmp
new file mode 100644
index 00000000..8bb264cf
--- /dev/null
+++ b/examples/gui/customwindow/resize.bmp
Binary files differ
diff --git a/examples/gui/customwindow/units/.gitignore b/examples/gui/customwindow/units/.gitignore
new file mode 100644
index 00000000..72e8ffc0
--- /dev/null
+++ b/examples/gui/customwindow/units/.gitignore
@@ -0,0 +1 @@
+*
diff --git a/examples/gui/drag_n_drop/dndexample.lpr b/examples/gui/drag_n_drop/dndexample.lpr
index c95b97d0..46c5a1f6 100644
--- a/examples/gui/drag_n_drop/dndexample.lpr
+++ b/examples/gui/drag_n_drop/dndexample.lpr
@@ -64,6 +64,7 @@ procedure TMainForm.Edit1DragEnter(Sender, Source: TObject;
var
s: string;
begin
+ ShowMimeList(AMimeList);
s := 'text/plain';
if chkAccept.Checked then
Accept := False
@@ -73,7 +74,6 @@ begin
begin
if AMimeChoice <> s then
AMimeChoice := s;
- ShowMimeList(AMimeList);
end;
end;
@@ -83,6 +83,7 @@ procedure TMainForm.Bevel1DragEnter(Sender, Source: TObject;
var
s: string;
begin
+ ShowMimeList(AMimeList);
{ the mime type we want to accept }
s := 'text/html';
{ if we wil accept the drop, set Accept to True }
@@ -93,7 +94,6 @@ begin
if AMimeChoice <> s then
AMimeChoice := s;
- ShowMimeList(AMimeList);
Bevel1.BackgroundColor := clRed;
end;
end;
@@ -121,6 +121,8 @@ end;
procedure TMainForm.btnClearClicked(Sender: TObject);
begin
Grid1.RowCount := 0;
+ Edit1.Text := '';
+ Bevel1.Text := '';
end;
procedure TMainForm.LabelDragStartDetected(Sender: TObject);
diff --git a/examples/gui/filedialog/filedialog.lpi b/examples/gui/filedialog/filedialog.lpi
index 872cf6e3..f6efbd83 100644
--- a/examples/gui/filedialog/filedialog.lpi
+++ b/examples/gui/filedialog/filedialog.lpi
@@ -36,7 +36,6 @@
<Unit0>
<Filename Value="filedialog.lpr"/>
<IsPartOfProject Value="True"/>
- <UnitName Value="filedialog"/>
</Unit0>
</Units>
</ProjectOptions>
@@ -54,6 +53,7 @@
</SyntaxOptions>
</Parsing>
<Other>
+ <CustomOptions Value="-FUunits"/>
<CompilerPath Value="$(CompPath)"/>
</Other>
</CompilerOptions>
diff --git a/examples/gui/filedialog/filedialog.lpr b/examples/gui/filedialog/filedialog.lpr
index 315b7885..1294ac06 100644
--- a/examples/gui/filedialog/filedialog.lpr
+++ b/examples/gui/filedialog/filedialog.lpr
@@ -119,7 +119,7 @@ procedure TMainForm.btnOpenFileClick(Sender: TObject);
var
dlg: TfpgFileDialog;
begin
- dlg := TfpgFileDialog.Create(nil);
+ dlg := TfpgFileDialog.Create(Self);
try
// defines 3 filters (All Files, Object Pascal and Lazarus Project)
dlg.Filter := 'All Files (*)|*|Object Pascal (*.pas;*.lpr;*.pp)|*.pas;*.lpr;*.pp|Lazarus Project (*.lpi)|*.lpi';
diff --git a/examples/gui/gridtest/gridtest.lpr b/examples/gui/gridtest/gridtest.lpr
index 173806e9..4b53f260 100644
--- a/examples/gui/gridtest/gridtest.lpr
+++ b/examples/gui/gridtest/gridtest.lpr
@@ -17,7 +17,8 @@ uses
fpg_checkbox,
fpg_tab,
fpg_edit,
- fpg_dialogs;
+ fpg_dialogs,
+ fpg_scrollbar;
type
@@ -256,6 +257,14 @@ begin
OnDrawCell := @StringGridDrawCell;
OnDoubleClick := @StringGridDoubleClicked;
OnHeaderClick := @StringGridHeaderClicked;
+ // Testing various scrollbar styles
+// ScrollBarStyle:= ssNone;
+// ScrollBarStyle:= ssHorizontal;
+// ScrollBarStyle:= ssVertical;
+ ScrollBarStyle:= ssAutoBoth;
+// ScrollBarStyle:= ssHorizVisible;
+// ScrollBarStyle:= ssVertiVisible;
+// ScrollBarStyle:= ssBothVisible;
end;
chkShowHeader := TfpgCheckBox.Create(self);
diff --git a/examples/gui/listviewtest/listviewtest.lpi b/examples/gui/listviewtest/listviewtest.lpi
index 50579565..595a5353 100644
--- a/examples/gui/listviewtest/listviewtest.lpi
+++ b/examples/gui/listviewtest/listviewtest.lpi
@@ -36,7 +36,6 @@
<Unit0>
<Filename Value="listviewtest.lpr"/>
<IsPartOfProject Value="True"/>
- <UnitName Value="listviewtest"/>
</Unit0>
</Units>
</ProjectOptions>
@@ -53,11 +52,5 @@
<UseAnsiStrings Value="False"/>
</SyntaxOptions>
</Parsing>
- <Other>
- <CompilerMessages>
- <UseMsgFile Value="True"/>
- </CompilerMessages>
- <CompilerPath Value="$(CompPath)"/>
- </Other>
</CompilerOptions>
</CONFIG>
diff --git a/examples/gui/listviewtest/listviewtest.lpr b/examples/gui/listviewtest/listviewtest.lpr
index 38bb6c83..57ab27b6 100644
--- a/examples/gui/listviewtest/listviewtest.lpr
+++ b/examples/gui/listviewtest/listviewtest.lpr
@@ -9,7 +9,10 @@ uses
type
+ { TMainForm }
+
TMainForm = class(TfpgForm)
+ procedure ShowFocusItemChange(Sender: TObject);
private
FEdit: TfpgEdit;
FAddButton: TfpgButton;
@@ -18,6 +21,7 @@ type
FTmpListView: TfpgListView;
FQuitButton: TfpgButton;
FCheck: TfpgCheckBox;
+ FShowFocus: TfpgCheckBox;
procedure LVColumnClicked(Listview: TfpgListView; Column: TfpgLVColumn; Button: Integer);
procedure CloseBttn(Sender: TObject);
procedure AddBttn(Sender: TObject);
@@ -35,6 +39,11 @@ type
{ TMainForm }
+procedure TMainForm.ShowFocusItemChange(Sender: TObject);
+begin
+ FListView.ShowFocusRect:=TfpgCheckBox(Sender).Checked;
+end;
+
procedure TMainForm.LVColumnClicked(Listview: TfpgListView; Column: TfpgLVColumn;
Button: Integer);
begin
@@ -260,6 +269,17 @@ begin
OnChange := @ShowHeadersChange;
end;
+ FShowFocus := TfpgCheckBox.Create(BottomPanel);
+ with FShowFocus do begin
+ Parent := BottomPanel;
+ Top := 10;
+ Left := 320;
+ Width := 130;
+ Checked := True;
+ Text := 'Show Item Focus';
+ OnChange:=@ShowFocusItemChange;
+ end;
+
end;
begin
diff --git a/examples/gui/modalforms/modalforms.lpi b/examples/gui/modalforms/modalforms.lpi
index cc8137c8..2f25e23a 100644
--- a/examples/gui/modalforms/modalforms.lpi
+++ b/examples/gui/modalforms/modalforms.lpi
@@ -36,7 +36,6 @@
<Unit0>
<Filename Value="modalforms.lpr"/>
<IsPartOfProject Value="True"/>
- <UnitName Value="modalforms"/>
</Unit0>
</Units>
</ProjectOptions>
@@ -54,6 +53,7 @@
</SyntaxOptions>
</Parsing>
<Other>
+ <CustomOptions Value="-FUunits"/>
<CompilerPath Value="$(CompPath)"/>
</Other>
</CompilerOptions>
diff --git a/examples/gui/modalforms/modalforms.lpr b/examples/gui/modalforms/modalforms.lpr
index 99f53ab3..bac0af81 100644
--- a/examples/gui/modalforms/modalforms.lpr
+++ b/examples/gui/modalforms/modalforms.lpr
@@ -99,7 +99,7 @@ procedure TForm1.btnOpenForm2Click(Sender: TObject);
var
frm: TForm2;
begin
- frm := TForm2.Create(nil);
+ frm := TForm2.Create(Self);
try
frm.ShowModal;
writeln('Form2: This should only appear after the form closes.');
@@ -113,6 +113,7 @@ end;
constructor TForm1.Create(AOwner: TComponent);
begin
inherited Create(AOwner);
+ Visible:=False;
WindowTitle := 'Form1';
Sizeable := False;
SetPosition(150, 150, 200, 200);
@@ -144,7 +145,7 @@ procedure TMainForm.btnOpenForm1Click(Sender: TObject);
var
frm: TForm1;
begin
- frm := TForm1.Create(nil);
+ frm := TForm1.Create(Self);
try
frm.ShowModal;
writeln('Form1: This should only appear after the form closes.');
diff --git a/examples/gui/reporting/u_demo.pas b/examples/gui/reporting/u_demo.pas
index 349b0ad1..adad8515 100644
--- a/examples/gui/reporting/u_demo.pas
+++ b/examples/gui/reporting/u_demo.pas
@@ -1279,12 +1279,10 @@ begin
Ckb_Preferences := CreateCheckBox(Self, 650, 30, 'FitWindow preference');
Ckb_Preferences.OnChange := @Ckb_PreferencesChange;
P_Zoom := CreatePanel(Self, 650, 60, 200, 60, 'Zoom', bsRaised, taCenter, tlTop, 5);
- P_Zoom.BackgroundColor := clPaleGreen;
SE_Zoom := CreateSpinEdit(P_Zoom, 10, 25, 55, 20, 20, 200, 1, 5, 100);
SE_Zoom.OnChange := @SE_ZoomChange;
L_Zoom := CreateLabel(P_Zoom, 70, 25, '%');
P_Layout := CreatePanel(Self, 650, 130, 200, 110, 'Layout', bsRaised, taCenter, tlTop, 5);
- P_Layout.BackgroundColor := clPaleGreen;
RB_Single := CreateRadiobutton(P_Layout, 10, 25, 'Single');
RB_Single.OnChange := @P_LayoutRBChange;
RB_Two := CreateRadiobutton(P_Layout, 10, 50, 'Two pages');
@@ -1295,7 +1293,6 @@ begin
Ckb_Preferences.Checked := True;
RB_Single.Checked := True;
Bt_Exit := CreateButton(Self, 375, 550, 150, 'Exit', @Bt_ExitClick, 'stdimg.exit');
- Bt_Exit.BackgroundColor := clTomato;
ZoomValue := '100';
Randomize;
for Cpt := 0 to 18 do
diff --git a/examples/gui/togglebox/ToggleBoxTest.lpi b/examples/gui/togglebox/ToggleBoxTest.lpi
new file mode 100644
index 00000000..327b4258
--- /dev/null
+++ b/examples/gui/togglebox/ToggleBoxTest.lpi
@@ -0,0 +1,77 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<CONFIG>
+ <ProjectOptions>
+ <Version Value="9"/>
+ <General>
+ <Flags>
+ <MainUnitHasCreateFormStatements Value="False"/>
+ <MainUnitHasTitleStatement Value="False"/>
+ </Flags>
+ <SessionStorage Value="InProjectDir"/>
+ <MainUnit Value="0"/>
+ <Title Value="ToggleBoxTest"/>
+ <UseAppBundle Value="False"/>
+ <ResourceType Value="res"/>
+ </General>
+ <i18n>
+ <EnableI18N LFM="False"/>
+ </i18n>
+ <VersionInfo>
+ <StringTable ProductVersion=""/>
+ </VersionInfo>
+ <BuildModes Count="1">
+ <Item1 Name="Default" Default="True"/>
+ </BuildModes>
+ <PublishOptions>
+ <Version Value="2"/>
+ </PublishOptions>
+ <RunParams>
+ <local>
+ <FormatVersion Value="1"/>
+ <LaunchingApplication Use="True" PathPlusParams="/usr/bin/gnome-terminal -t 'Lazarus Run Output' -e '$(LazarusDir)/tools/runwait.sh $(TargetCmdLine)'"/>
+ </local>
+ </RunParams>
+ <RequiredPackages Count="1">
+ <Item1>
+ <PackageName Value="fpgui_toolkit"/>
+ </Item1>
+ </RequiredPackages>
+ <Units Count="2">
+ <Unit0>
+ <Filename Value="ToggleBoxTest.lpr"/>
+ <IsPartOfProject Value="True"/>
+ </Unit0>
+ <Unit1>
+ <Filename Value="mainfrm.pas"/>
+ <IsPartOfProject Value="True"/>
+ <UnitName Value="mainfrm"/>
+ </Unit1>
+ </Units>
+ </ProjectOptions>
+ <CompilerOptions>
+ <Version Value="11"/>
+ <Target>
+ <Filename Value="ToggleBoxTest"/>
+ </Target>
+ <SearchPaths>
+ <IncludeFiles Value="$(ProjOutDir)"/>
+ <UnitOutputDirectory Value="units/$(TargetCPU)-$(TargetOS)"/>
+ </SearchPaths>
+ <Other>
+ <CompilerPath Value="$(CompPath)"/>
+ </Other>
+ </CompilerOptions>
+ <Debugging>
+ <Exceptions Count="3">
+ <Item1>
+ <Name Value="EAbort"/>
+ </Item1>
+ <Item2>
+ <Name Value="ECodetoolError"/>
+ </Item2>
+ <Item3>
+ <Name Value="EFOpenError"/>
+ </Item3>
+ </Exceptions>
+ </Debugging>
+</CONFIG>
diff --git a/examples/gui/togglebox/ToggleBoxTest.lpr b/examples/gui/togglebox/ToggleBoxTest.lpr
new file mode 100644
index 00000000..8866f9c5
--- /dev/null
+++ b/examples/gui/togglebox/ToggleBoxTest.lpr
@@ -0,0 +1,30 @@
+program ToggleBoxTest;
+
+{$mode objfpc}{$H+}
+
+uses
+ {$IFDEF UNIX}
+ cthreads,
+ {$ENDIF}
+ Classes,
+ fpg_main,
+ mainfrm;
+
+procedure MainProc;
+var
+ frmMain: TfrmMain;
+begin
+ fpgApplication.Initialize;
+ frmMain:= TfrmMain.Create(nil);
+ try
+ frmMain.Show;
+ fpgApplication.Run;
+ finally
+ frmMain.Free;
+ end;
+end;
+
+begin
+ MainProc;
+end.
+
diff --git a/examples/gui/togglebox/mainfrm.pas b/examples/gui/togglebox/mainfrm.pas
new file mode 100644
index 00000000..ff9a43da
--- /dev/null
+++ b/examples/gui/togglebox/mainfrm.pas
@@ -0,0 +1,44 @@
+unit mainfrm;
+
+{$mode objfpc}{$H+}
+
+interface
+
+uses
+ Classes, SysUtils, fpg_base, fpg_form, fpg_toggle;
+
+type
+
+ { TfrmMain }
+
+ TfrmMain = class(TfpgForm)
+ private
+ FToggle: TfpgToggle;
+ public
+ constructor Create(AOwner: TComponent); override;
+ end;
+
+
+implementation
+
+{ TfrmMain }
+
+constructor TfrmMain.Create(AOwner: TComponent);
+begin
+ inherited Create(AOwner);
+ WindowTitle:='Yay a toggle!';
+ SetWidth(300);
+ SetHeight(200);
+
+ FToggle := TfpgToggle.Create(Self);
+ FToggle.SetPosition(10, 10, 200, 20);
+// FToggle.Width:=200;
+
+ //FToggle.ToggleSide:=tsLeft;
+ //FToggle.ToggleWidth:=100;
+ //FToggle.UseAnimation:=False;
+
+end;
+
+end.
+
diff --git a/examples/gui/video_vlc/frmvlcplayer.pas b/examples/gui/video_vlc/frmvlcplayer.pas
index 7b44c1e1..456ac202 100644
--- a/examples/gui/video_vlc/frmvlcplayer.pas
+++ b/examples/gui/video_vlc/frmvlcplayer.pas
@@ -6,7 +6,7 @@ interface
uses
SysUtils, Classes, fpg_base, fpg_panel, fpg_button, fpg_main, fpg_form,
- fpg_editbtn, fpg_memo, fpg_label, libvlc, vlc, fpg_vlc;
+ fpg_editbtn, fpg_memo, fpg_label, vlc, fpg_vlc;
type
@@ -23,14 +23,17 @@ type
Button3: TfpgButton;
Button4: TfpgButton;
Memo1: TfpgMemo;
- procedure Sync;
+ lblTimeLapse: TfpgLabel;
{@VFD_HEAD_END: VLCPlayerDemo}
+ procedure Sync;
+ procedure DoGUIUpdateTimeLapse;
public
P : TFpgVLCPlayer;
FMsg: String;
procedure AfterCreate; override;
Procedure InitPlayer;
Procedure Log(Const Msg : String);
+ Procedure UpdateTimeLapse(const Msg: String);
Procedure DoPlay(sender : TObject);
Procedure DoPause(sender : TObject);
Procedure DoResume(sender : TObject);
@@ -145,6 +148,7 @@ procedure TVLCPlayerDemoForm.DoOnTimeChanged(Sender: TObject;
const time: TDateTime);
begin
Log('Time changed : '+TimeToStr(Time));
+ UpdateTimeLapse(TimeToStr(time));
end;
procedure TVLCPlayerDemoForm.DoOnSnapshot(Sender: TObject;
@@ -167,6 +171,7 @@ begin
SetPosition(424, 319, 813, 574);
WindowTitle := 'VLCPlayerDemo';
Hint := '';
+ IconName := '';
Panel1 := TfpgPanel.Create(self);
with Panel1 do
@@ -187,7 +192,7 @@ begin
Anchors := [anLeft,anRight,anTop];
ExtraHint := '';
FileName := '';
- Filter := 'Video files|*.avi;*.flv;*.mp4';
+ Filter := 'Video files|*.avi;*.flv;*.mp4;*.mkv|Audio files|*.mp3;*.acc;*.flac;*.ogg';
InitialDir := '';
TabOrder := 2;
end;
@@ -269,6 +274,16 @@ begin
TabOrder := 8;
end;
+ lblTimeLapse := TfpgLabel.Create(self);
+ with lblTimeLapse do
+ begin
+ Name := 'lblTimeLapse';
+ SetPosition(30, 510, 105, 15);
+ FontDesc := 'Liberation Sans-12:bold:antialias=true';
+ Hint := '';
+ Text := 'Label';
+ end;
+
{@VFD_BODY_END: VLCPlayerDemo}
{%endregion}
end;
@@ -306,12 +321,25 @@ begin
Memo1.Lines.Add(FMsg);
end;
+procedure TVLCPlayerDemoForm.DoGUIUpdateTimeLapse;
+begin
+ lblTimeLapse.Text := FMsg;
+end;
+
procedure TVLCPlayerDemoForm.Log(const Msg: String);
begin
FMsg:=Msg;
TThread.Synchronize(Nil,@Self.Sync);
end;
+procedure TVLCPlayerDemoForm.UpdateTimeLapse(const Msg: String);
+begin
+ FMsg := Msg;
+ TThread.Synchronize(nil, @self.DoGUIUpdateTimeLapse);
+// This could also be used in FPC 3.0+
+// TThread.Queue(nil, @DoGUIUpdateTimeLapse);
+end;
+
procedure TVLCPlayerDemoForm.DoPlay(sender: TObject);
begin
InitPlayer;
diff --git a/examples/gui/video_vlc/testfpguivlc.lpi b/examples/gui/video_vlc/testfpguivlc.lpi
index d7a4ad2a..5a13551b 100644
--- a/examples/gui/video_vlc/testfpguivlc.lpi
+++ b/examples/gui/video_vlc/testfpguivlc.lpi
@@ -42,7 +42,6 @@
<Unit0>
<Filename Value="testfpguivlc.lpr"/>
<IsPartOfProject Value="True"/>
- <UnitName Value="testfpguivlc"/>
</Unit0>
<Unit1>
<Filename Value="frmvlcplayer.pas"/>
@@ -50,17 +49,17 @@
<UnitName Value="frmvlcplayer"/>
</Unit1>
<Unit2>
- <Filename Value="../fpg_vlc.pas"/>
+ <Filename Value="../../../src/3rdparty/libvlc/fpg_vlc.pas"/>
<IsPartOfProject Value="True"/>
<UnitName Value="fpg_vlc"/>
</Unit2>
<Unit3>
- <Filename Value="../../libvlc/libvlc.pp"/>
+ <Filename Value="../../../src/3rdparty/libvlc/libvlc.pas"/>
<IsPartOfProject Value="True"/>
<UnitName Value="libvlc"/>
</Unit3>
<Unit4>
- <Filename Value="../../libvlc/vlc.pas"/>
+ <Filename Value="../../../src/3rdparty/libvlc/vlc.pas"/>
<IsPartOfProject Value="True"/>
<UnitName Value="vlc"/>
</Unit4>
@@ -76,12 +75,6 @@
<OtherUnitFiles Value="../../../src/3rdparty/libvlc"/>
<UnitOutputDirectory Value="units/$(TargetCPU)-$(TargetOS)"/>
</SearchPaths>
- <Other>
- <CompilerMessages>
- <MsgFileName Value=""/>
- </CompilerMessages>
- <CompilerPath Value="$(CompPath)"/>
- </Other>
</CompilerOptions>
<Debugging>
<Exceptions Count="3">