diff options
author | Graeme Geldenhuys <graemeg@gmail.com> | 2009-10-11 20:12:19 +0200 |
---|---|---|
committer | Graeme Geldenhuys <graemeg@gmail.com> | 2009-10-11 20:12:19 +0200 |
commit | 4f936367835e0c4a405bb6b4a49303f1e85a746d (patch) | |
tree | 6defcdff54baa6734ae2ff5ef2689408b9cab78b | |
parent | f7424b70f7396019aef6152c73f4c5ef488fad45 (diff) | |
download | fpGUI-4f936367835e0c4a405bb6b4a49303f1e85a746d.tar.xz |
Completed the MRU and (re)store of window State.
-rw-r--r-- | src/frm_main.pas | 49 |
1 files changed, 47 insertions, 2 deletions
diff --git a/src/frm_main.pas b/src/frm_main.pas index d9481d60..17b9ddf4 100644 --- a/src/frm_main.pas +++ b/src/frm_main.pas @@ -118,11 +118,17 @@ const implementation uses - fpg_dialogs, fpg_constants, nvUtilities, HelpTopic + fpg_dialogs + ,fpg_constants + ,fpg_iniutils + ,nvUtilities + ,HelpTopic {$IFDEF Timing} ,EpikTimer {$ENDIF} - ,TextSearchQuery, SearchUnit; + ,TextSearchQuery + ,SearchUnit + ; {@VFD_NEWFORM_IMPL} @@ -152,6 +158,18 @@ begin writeln(t.ElapsedDHMS); {$ENDIF} end; + // restore previous window position and size + gINI.ReadFormState(self); + PageControl1.Width := gINI.ReadInteger('Options', 'SplitterLeft', 260); + UpdateWindowPosition; +end; + +procedure TMainForm.MainFormDestroy(Sender: TObject); +begin + // save splitter position + gINI.WriteInteger('Options', 'SplitterLeft', PageControl1.Width); + // save form size and position + gINI.WriteFormState(self); end; procedure TMainForm.miFileQuitClicked(Sender: TObject); @@ -211,6 +229,11 @@ begin DisplayTopic; end; +procedure TMainForm.miMRUClick(Sender: TObject; const FileName: String); +begin + OpenFile(FileName); +end; + procedure TMainForm.btnShowIndex(Sender: TObject); var Count: integer; @@ -349,6 +372,7 @@ begin if dlg.RunOpenFile then begin // FHelpFile := dlg.FileName; + mru.AddItem(dlg.Filename); OpenFile(dlg.Filename); { TODO -oGraeme : Add support for multiple files. } // OpenFile( ListToString( dlg.FileNames, '+' ) ); @@ -725,6 +749,7 @@ begin inherited Create(AOwner); fpgApplication.OnException := @MainFormException; OnShow := @MainFormShow; + OnDestroy :=@MainFormDestroy; Files := TList.Create; { TODO -oGraeme : Make Debug a menu option } Debug := False; @@ -871,6 +896,8 @@ begin AddMenuItem('Open...', '', @miFileOpenClicked); AddMenuItem('Close', '', @miFileCloseClicked); AddMenuitem('-', '', nil); + FFileOpenRecent := AddMenuItem('Open Recent...', '', nil); + AddMenuitem('-', '', nil); AddMenuItem('Quit', '', @miFileQuitClicked); end; @@ -906,6 +933,14 @@ begin AddMenuItem('Product Information...', '', @miHelpProdInfoClicked); end; + miOpenRecentMenu := TfpgPopupMenu.Create(self); + with miOpenRecentMenu do + begin + Name := 'miOpenRecentMenu'; + SetPosition(293, 124, 132, 20); + end; + + btnIndex := TfpgButton.Create(tsIndex); with btnIndex do begin @@ -1184,9 +1219,19 @@ begin MainMenu.AddMenuItem('&Settings', nil).SubMenu := miSettings; MainMenu.AddMenuItem('&Bookmarks', nil).SubMenu := miBookmarks; MainMenu.AddMenuItem('&Help', nil).SubMenu := miHelp; + FFileOpenRecent.SubMenu := miOpenRecentMenu; // correct default visible tabsheet PageControl1.ActivePageIndex := 0; + + // most recently used files + mru := TfpgMRU.Create(self); + mru.ParentMenuItem := miOpenRecentMenu; + mru.OnClick :=@miMRUClick; + mru.MaxItems := gINI.ReadInteger('Options', 'MRUFileCount', 8); + mru.ShowFullPath := gINI.ReadBool('Options', 'ShowFullPath', True); + mru.LoadMRU; + end; |