diff options
Diffstat (limited to 'examples')
-rw-r--r-- | examples/gui/menutest/menutest.lpi | 53 | ||||
-rw-r--r-- | examples/gui/menutest/menutest.lpr | 93 |
2 files changed, 146 insertions, 0 deletions
diff --git a/examples/gui/menutest/menutest.lpi b/examples/gui/menutest/menutest.lpi new file mode 100644 index 00000000..0385d9f4 --- /dev/null +++ b/examples/gui/menutest/menutest.lpi @@ -0,0 +1,53 @@ +<?xml version="1.0"?> +<CONFIG> + <ProjectOptions> + <PathDelim Value="/"/> + <Version Value="5"/> + <General> + <Flags> + <SaveOnlyProjectUnits Value="True"/> + </Flags> + <SessionStorage Value="InProjectDir"/> + <MainUnit Value="0"/> + <TargetFileExt Value=""/> + </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"/> + <MinVersion Minor="5" Valid="True"/> + </Item1> + </RequiredPackages> + <Units Count="1"> + <Unit0> + <Filename Value="menutest.lpr"/> + <IsPartOfProject Value="True"/> + <UnitName Value="menutest"/> + </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/menutest/menutest.lpr b/examples/gui/menutest/menutest.lpr new file mode 100644 index 00000000..87283051 --- /dev/null +++ b/examples/gui/menutest/menutest.lpr @@ -0,0 +1,93 @@ +program menutest; + +{$mode objfpc}{$H+} + +uses + {$IFDEF UNIX}{$IFDEF UseCThreads} + cthreads, + {$ENDIF}{$ENDIF} + Classes, + fpgfx, + gui_form, + gui_menu; + +type + TMainForm = class(TfpgForm) + private + FMenuBar: TfpgMenuBar; + FFileSubMenu: TfpgPopupMenu; + FEditSubMenu: TfpgPopupMenu; + FEditSelectSubMenu: TfpgPopupMenu; + FHelpSubMenu: TfpgPopupMenu; + procedure miExitClicked(Sender: TObject); + public + constructor Create(AOwner: TComponent); override; + end; + +{ TMainForm } + +procedure TMainForm.miExitClicked(Sender: TObject); +begin + Close; +end; + +constructor TMainForm.Create(AOwner: TComponent); +var + mi: TfpgMenuItem; +begin + inherited Create(AOwner); + WindowTitle := 'Menu Test'; + WindowPosition := wpUser; + SetPosition(100, 100, 300, 200); + + // Create top level sub-menus + FFileSubMenu := TfpgPopupMenu.Create(self); + FFileSubMenu.AddMenuItem('&Open', 'Ctrl-O', nil); + FFileSubMenu.AddMenuItem('&Save', 'Ctrl-S', nil); + FFileSubMenu.AddMenuItem('S&ave As', 'Ctrl+Shift+S', nil); + FFileSubMenu.AddMenuItem('-', '', nil); + FFileSubMenu.AddMenuItem('Save && Reload', '', nil); + FFileSubMenu.AddMenuItem('-', '', nil); + FFileSubMenu.AddMenuItem('&Quit', 'Ctrl-Q', @miExitClicked); + + FEditSubMenu := TfpgPopupMenu.Create(self); + FEditSubMenu.AddMenuItem('&Cut', 'Ctrl-X', nil); + FEditSubMenu.AddMenuItem('C&opy', 'Ctrl-C', nil); + FEditSubMenu.AddMenuItem('&Paste', 'Ctrl-V', nil); + FEditSubMenu.AddMenuItem('-', '', nil); + FEditSubMenu.AddMenuItem('&Spell check', 'F4', nil).Enabled := False; + FEditSelectSubMenu := TfpgPopupMenu.Create(self); + FEditSubMenu.AddMenuItem('Selec&t', '', nil).SubMenu := FEditSelectSubMenu; + FEditSelectSubMenu.AddMenuItem('Select All', '', nil); + FEditSelectSubMenu.AddMenuItem('Select Word', '', nil); + FEditSelectSubMenu.AddMenuItem('Select Line', '', nil); + + FHelpSubMenu := TfpgPopupMenu.Create(self); + FHelpSubMenu.AddMenuItem('&About', 'F12', nil); + + // Create main menu bar + FMenuBar := TfpgMenuBar.Create(self); + FMenuBar.SetPosition(0, 0, Width, 20); + FMenuBar.AddMenuItem('File', nil).SubMenu := FFileSubMenu; + FMenuBar.AddMenuItem('Edit', nil).SubMenu := FEditSubMenu; + FMenuBar.AddMenuItem('Windows', nil); + FMenuBar.AddMenuItem('Help', nil).SubMenu := FHelpSubMenu; + +end; + + +procedure MainProc; +var + frm: TMainForm; +begin + fpgApplication.Initialize; + frm := TMainForm.Create(nil); + frm.Show; + fpgApplication.Run; +end; + +begin + MainProc; +end. + + |