summaryrefslogtreecommitdiff
path: root/examples/apps
diff options
context:
space:
mode:
Diffstat (limited to 'examples/apps')
-rw-r--r--examples/apps/docedit/docedit.lpi8
-rw-r--r--examples/apps/docedit/frm_main.pas112
2 files changed, 111 insertions, 9 deletions
diff --git a/examples/apps/docedit/docedit.lpi b/examples/apps/docedit/docedit.lpi
index 059210cb..b2d9eefc 100644
--- a/examples/apps/docedit/docedit.lpi
+++ b/examples/apps/docedit/docedit.lpi
@@ -9,6 +9,7 @@
</Flags>
<SessionStorage Value="InProjectDir"/>
<MainUnit Value="0"/>
+ <IconPath Value="./"/>
<TargetFileExt Value=""/>
</General>
<VersionInfo>
@@ -16,7 +17,6 @@
</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>
@@ -28,11 +28,11 @@
</RunParams>
<RequiredPackages Count="2">
<Item1>
- <PackageName Value="FCL"/>
- </Item1>
- <Item2>
<PackageName Value="fpgui_package"/>
<MinVersion Minor="5" Valid="True"/>
+ </Item1>
+ <Item2>
+ <PackageName Value="FCL"/>
</Item2>
</RequiredPackages>
<Units Count="2">
diff --git a/examples/apps/docedit/frm_main.pas b/examples/apps/docedit/frm_main.pas
index cae208bd..cd8fe01f 100644
--- a/examples/apps/docedit/frm_main.pas
+++ b/examples/apps/docedit/frm_main.pas
@@ -11,7 +11,8 @@ uses
gui_form,
gui_button,
gui_edit,
- gui_label;
+ gui_label,
+ gui_menu;
type
TMainForm = class(TfpgForm)
@@ -20,9 +21,19 @@ type
lblXMLFile: TfpgLabel;
edXMLFile: TfpgEdit;
btnOpen: TfpgButton;
+ menubar: TfpgMenuBar;
+ miFile: TfpgPopupMenu;
+ miInsert: TfpgPopupMenu;
+ miExtra: TfpgPopupMenu;
+ miHelp: TfpgPopupMenu;
procedure btnQuitClicked(Sender: TObject);
procedure btnOpenClicked(Sender: TObject);
procedure InitializeComponents;
+ procedure SetupMenuBar;
+ procedure miFileQuitClicked(Sender: TObject);
+ procedure miFileOpenClicked(Sender: TObject);
+ procedure miFileSaveAsClicked(Sender: TObject);
+ procedure miHelpAboutClicked(Sender: TObject);
public
constructor Create(AOwner: TComponent); override;
end;
@@ -30,6 +41,13 @@ type
implementation
+uses
+ gui_dialogs;
+
+
+const
+ cAppName = 'FPDoc Documentation Editor';
+
{ TMainForm }
procedure TMainForm.btnQuitClicked(Sender: TObject);
@@ -44,6 +62,8 @@ end;
procedure TMainForm.InitializeComponents;
begin
+ SetupMenuBar;
+
btnQuit := CreateButton(self, Width-88, Height-31, 80, 'Quit', @btnQuitClicked);
with btnQuit do
begin
@@ -52,9 +72,9 @@ begin
Anchors := [anRight, anBottom];
end;
- lblXMLFile := CreateLabel(self, 8, 8, 'XML File:');
- edXMLFile := CreateEdit(self, lblXMLFile.Right+8, lblXMLFile.Top-2, 485, 23);
- edXMLFile.Text := '/home/graemeg/programming/fpgui/docs/xml/corelib/gfx_clipboard.xml';
+ lblXMLFile := CreateLabel(self, 8, 38, 'XML File:');
+ edXMLFile := CreateEdit(self, lblXMLFile.Right+8, lblXMLFile.Top+36, 485, 23);
+ edXMLFile.Text := '';
btnOpen := CreateButton(self, edXMLFile.Right+10, edXMLFile.Top, 80, 'Open', @btnOpenClicked);
with btnOpen do
@@ -62,13 +82,95 @@ begin
ImageName := 'stdimg.Open';
ShowImage := True;
end;
+end;
+
+procedure TMainForm.SetupMenuBar;
+begin
+ // create top level menus.
+ miFile := TfpgPopupMenu.Create(self);
+ miFile.AddMenuItem('&New...', 'Ctrl-N', nil);
+ miFile.AddMenuItem('&Open..', 'Ctrl-O', @miFileOpenClicked);
+ miFile.AddMenuItem('&Save', 'Ctrl-S', nil);
+ miFile.AddMenuItem('S&ave As..', 'Ctrl+Shift+S', @miFileSaveAsClicked);
+ miFile.AddMenuItem('-', '', nil);
+ miFile.AddMenuItem('&Close', 'Ctrl-W', nil);
+ miFile.AddMenuItem('&Recent', '', nil);
+ miFile.AddMenuItem('-', '', nil);
+ miFile.AddMenuItem('&Quit', 'Ctrl-Q', @miFileQuitClicked);
+
+ miInsert := TfpgPopupMenu.Create(self);
+ miInsert.AddMenuItem('&Package', '', nil);
+ miInsert.AddMenuItem('&Module', '', nil);
+ miInsert.AddMenuItem('&Topic', '', nil);
+ miInsert.AddMenuItem('&Element', '', nil);
+ miInsert.AddMenuItem('&Link', '', nil);
+ miInsert.AddMenuItem('T&able', '', nil);
+ miInsert.AddMenuItem('&Short Desc Link', '', nil);
+
+ miExtra := TfpgPopupMenu.Create(self);
+ miExtra.AddMenuItem('&Options...', '', nil);
+ miExtra.AddMenuItem('&Build...', '', nil);
+
+ miHelp := TfpgPopupMenu.Create(self);
+ miHelp.AddMenuItem('About...', '', @miHelpAboutClicked);
+
+ // create main menu bar
+ menubar := TfpgMenuBar.Create(self);
+ menubar.SetPosition(0, 0, Width, menubar.Height);
+ menubar.Anchors := [anLeft, anTop, anRight];
+ menubar.AddMenuItem('&File', nil).SubMenu := miFile;
+ menubar.AddMenuItem('&Insert', nil).SubMenu := miInsert;
+ menubar.AddMenuItem('&Extra', nil).SubMenu := miExtra;
+ menubar.AddMenuItem('&Help', nil).SubMenu := miHelp;
+end;
+
+procedure TMainForm.miFileQuitClicked(Sender: TObject);
+begin
+ Close;
+end;
+
+procedure TMainForm.miFileOpenClicked(Sender: TObject);
+var
+ dlg: TfpgFileDialog;
+begin
+ dlg := TfpgFileDialog.Create(nil);
+ try
+ dlg.Filter := 'FPDoc Desc Files (*.xml)|*.xml|All Files (*)|*';
+ if dlg.RunOpenFile then
+ edXMLFile.Text := dlg.FileName;
+ finally
+ dlg.Free;
+ end;
+end;
+
+procedure TMainForm.miFileSaveAsClicked(Sender: TObject);
+var
+ dlg: TfpgFileDialog;
+begin
+ dlg := TfpgFileDialog.Create(nil);
+ try
+ dlg.Filter := 'FPDoc Desc Files (*.xml)|*.xml|All Files (*)|*';
+ dlg.FileName := edXMLFile.Text;
+ if dlg.RunSaveFile then
+ edXMLFile.Text := dlg.FileName;
+ finally
+ dlg.Free;
+ end;
+end;
+procedure TMainForm.miHelpAboutClicked(Sender: TObject);
+begin
+ ShowMessage(cAppName
+ + #10
+ + #10 + 'Written by Graeme Geldenhuys - 2007'
+ + #10 + 'Using the fpGUI toolkit'
+ ,'About');
end;
constructor TMainForm.Create(AOwner: TComponent);
begin
inherited Create(AOwner);
- WindowTitle := 'Documentation Editor';
+ WindowTitle := cAppName;
Sizeable := False;
// Golden ratio 1.618
Width := 650;