From 2294374b3cc195e8803cbed93e94071074c12e22 Mon Sep 17 00:00:00 2001 From: Graeme Geldenhuys Date: Wed, 13 Mar 2013 17:07:32 +0000 Subject: nanoedit: Implements a statusbar to show current file name being edited --- examples/apps/nanoedit/mainfrm.pas | 40 ++++++++++++++++++++++++++++++++++--- examples/apps/nanoedit/nanoedit.lpi | 2 +- 2 files changed, 38 insertions(+), 4 deletions(-) (limited to 'examples') diff --git a/examples/apps/nanoedit/mainfrm.pas b/examples/apps/nanoedit/mainfrm.pas index 6de386ce..5cece909 100644 --- a/examples/apps/nanoedit/mainfrm.pas +++ b/examples/apps/nanoedit/mainfrm.pas @@ -6,7 +6,8 @@ interface uses SysUtils, Classes, fpg_base, fpg_main, - fpg_form, fpg_button, fpg_menu, fpg_textedit; + fpg_form, fpg_button, fpg_menu, fpg_textedit, fpg_panel, + fpg_label; type @@ -15,14 +16,17 @@ type {@VFD_HEAD_BEGIN: MainFrom} menu: TfpgMenuBar; mnuFile: TfpgPopupMenu; + mnuEdit: TfpgPopupMenu; mnuSearch: TfpgPopupMenu; memEditor: TfpgTextEdit; btnGO: TfpgButton; - mnuEdit: TfpgPopupMenu; + bevStatusBar: TfpgBevel; + lblStatusText: TfpgLabel; {@VFD_HEAD_END: MainFrom} FTextToFind: TfpgString; FFindOptions: TfpgFindOptions; FIsForward: boolean; + FFilename: TfpgString; procedure FormShow(Sender: TObject); procedure miOpenClick(Sender: TObject); procedure miSaveClick(Sender: TObject); @@ -62,6 +66,8 @@ begin if Pos('file://', s) > 0 then s := StringReplace(s, 'file://', '', []); memEditor.LoadFromFile(s); + FFilename := s; + lblStatusText.Text := FFilename; end; end; @@ -74,6 +80,7 @@ begin if dlg.RunOpenFile then begin memEditor.Lines.LoadFromFile(dlg.FileName); + FFileName := dlg.FileName; end; finally dlg.Free; @@ -86,6 +93,8 @@ var begin dlg := TfpgFileDialog.Create(nil); try + if FFilename <> '' then + dlg.FileName := FFilename; if dlg.RunSaveFile then begin memEditor.Lines.SaveToFile(dlg.FileName); @@ -101,9 +110,13 @@ var begin dlg := TfpgFileDialog.Create(nil); try + if FFilename <> '' then + dlg.FileName := FFilename; if dlg.RunSaveFile then begin memEditor.Lines.SaveToFile(dlg.FileName); + FFilename := dlg.FileName; + lblStatusText.Text := FFilename; end; finally dlg.Free; @@ -266,7 +279,7 @@ begin with memEditor do begin Name := 'memEditor'; - SetPosition(0, 52, 717, 358); + SetPosition(0, 52, 717, 332); Anchors := [anLeft,anRight,anTop,anBottom]; FontDesc := '#edit2'; GutterVisible := True; @@ -286,6 +299,27 @@ begin OnClick := @btnGOClick; end; + bevStatusBar := TfpgBevel.Create(self); + with bevStatusBar do + begin + Name := 'bevStatusBar'; + SetPosition(1, 387, 715, 22); + Anchors := [anLeft,anRight,anBottom]; + Hint := ''; + Style := bsLowered; + end; + + lblStatusText := TfpgLabel.Create(bevStatusBar); + with lblStatusText do + begin + Name := 'lblStatusText'; + SetPosition(4, 4, 704, 15); + Anchors := [anLeft,anRight,anTop]; + FontDesc := '#Label1'; + Hint := ''; + Text := ''; + end; + {@VFD_BODY_END: MainFrom} menu.AddMenuItem('&File', nil).SubMenu := mnuFile; diff --git a/examples/apps/nanoedit/nanoedit.lpi b/examples/apps/nanoedit/nanoedit.lpi index 8a70af1f..7211172c 100644 --- a/examples/apps/nanoedit/nanoedit.lpi +++ b/examples/apps/nanoedit/nanoedit.lpi @@ -63,7 +63,7 @@ - + -- cgit v1.2.3-70-g09d2