diff options
author | graemeg <graemeg@ae50a9b5-8222-0410-bf8d-8a13f76226bf> | 2007-08-17 14:35:33 +0000 |
---|---|---|
committer | graemeg <graemeg@ae50a9b5-8222-0410-bf8d-8a13f76226bf> | 2007-08-17 14:35:33 +0000 |
commit | 003a991ccc0b05ce9a939d27313dd5ee0d9f4390 (patch) | |
tree | 551a6dfc94dfff01f77b84f19d5a255ce66f5606 /examples/gui | |
parent | 76df5b245da72230e5491c51e049c19337884ac1 (diff) | |
download | fpGUI-003a991ccc0b05ce9a939d27313dd5ee0d9f4390.tar.xz |
* Implemented a FileOpen and FileSave dialog. Both are the same class. It's
not 100% yet. See ToDo list in header of gui_dialogs unit.
* Minor bug fix in ComboBox component and added missing (required) properties.
* Fixed a bug in TfpgCustomGrid.Destroy. Creating a decendant of TfpgCustomGrid
caused a crash in the destructor.
* Fixed bug in ListBox where scrollbar did not move with mouse wheel input.
* Added a new FileDialog example project.
Diffstat (limited to 'examples/gui')
-rw-r--r-- | examples/gui/filedialog/filedialog.lpi | 54 | ||||
-rw-r--r-- | examples/gui/filedialog/filedialog.lpr | 98 |
2 files changed, 152 insertions, 0 deletions
diff --git a/examples/gui/filedialog/filedialog.lpi b/examples/gui/filedialog/filedialog.lpi new file mode 100644 index 00000000..224f5a46 --- /dev/null +++ b/examples/gui/filedialog/filedialog.lpi @@ -0,0 +1,54 @@ +<?xml version="1.0"?> +<CONFIG> + <ProjectOptions> + <PathDelim Value="/"/> + <Version Value="5"/> + <General> + <Flags> + <SaveOnlyProjectUnits Value="True"/> + </Flags> + <SessionStorage Value="InProjectDir"/> + <MainUnit Value="0"/> + <IconPath Value="./"/> + <TargetFileExt Value=""/> + <UseAppBundle Value="False"/> + </General> + <VersionInfo> + <ProjectVersion Value=""/> + </VersionInfo> + <PublishOptions> + <Version Value="2"/> + <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"/> + <MinVersion Minor="5" Valid="True"/> + </Item1> + </RequiredPackages> + <Units Count="1"> + <Unit0> + <Filename Value="filedialog.lpr"/> + <IsPartOfProject Value="True"/> + <UnitName Value="filedialog"/> + </Unit0> + </Units> + </ProjectOptions> + <CompilerOptions> + <Version Value="5"/> + <CodeGeneration> + <Generate Value="Faster"/> + </CodeGeneration> + <Other> + <CustomOptions Value="-FUunits"/> + <CompilerPath Value="$(CompPath)"/> + </Other> + </CompilerOptions> +</CONFIG> diff --git a/examples/gui/filedialog/filedialog.lpr b/examples/gui/filedialog/filedialog.lpr new file mode 100644 index 00000000..a5ff4d2a --- /dev/null +++ b/examples/gui/filedialog/filedialog.lpr @@ -0,0 +1,98 @@ +program filedialog; + +{$mode objfpc}{$H+} + +uses + {$IFDEF UNIX}{$IFDEF UseCThreads} + cthreads, + {$ENDIF}{$ENDIF} + Classes, + fpgfx, + gui_form, + gui_dialogs, + gui_button, + gui_edit, + gui_label; + + +type + TMainForm = class(TfpgForm) + private + btnQuit: TfpgButton; + btnOpenFile: TfpgButton; + btnSaveFile: TfpgButton; + edFilename: TfpgEdit; + procedure btnQuitClick(Sender: TObject); + procedure btnOpenFileClick(Sender: TObject); + procedure btnSaveFileClick(Sender: TObject); + public + constructor Create(AOwner: TComponent); override; + end; + +{ TMainForm } + +procedure TMainForm.btnQuitClick(Sender: TObject); +begin + Close; +end; + +procedure TMainForm.btnOpenFileClick(Sender: TObject); +var + dlg: TfpgFileDialog; +begin + dlg := TfpgFileDialog.Create(nil); + try + if dlg.RunOpenFile then + edFilename.Text := dlg.FileName; + finally + dlg.Free; + end; +end; + +procedure TMainForm.btnSaveFileClick(Sender: TObject); +var + dlg: TfpgFileDialog; +begin + dlg := TfpgFileDialog.Create(nil); + try + if dlg.RunSaveFile then + edFilename.Text := dlg.FileName; + finally + dlg.Free; + end; +end; + +constructor TMainForm.Create(AOwner: TComponent); +begin + inherited Create(AOwner); + WindowTitle := 'File dialog test'; + SetPosition(100, 100, 500, 400); + + btnOpenFile := CreateButton(self, 10, 10, 110, 'Open File...', @btnOpenFileClick); + btnSaveFile := CreateButton(self, 10, btnOpenFile.Bottom + 8, 110, 'Save File...', @btnSaveFileClick); + + edFilename := CreateEdit(self, 10, btnSaveFile.Bottom + 15, Width - 20, 24); + edFilename.Text := ''; + + btnQuit := CreateButton(self, 415, 370, 80, 'Quit', @btnQuitClick); + btnQuit.ImageName := 'stdimg.Quit'; + btnQuit.ShowImage := True; + btnQuit.Anchors := [anRight, anBottom]; + + btnOpenFile.TabOrder := 0; +end; + +procedure MainProc; +var + frm: TMainForm; +begin + fpgApplication.Initialize; + frm := TMainForm.Create(nil); + frm.Show; + fpgApplication.Run; +end; + +begin + MainProc; +end. + |