OWLNext    7.0
Borland's Object Windows Library for the modern age
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
rcntfile.h
Go to the documentation of this file.
1//----------------------------------------------------------------------------
2// ObjectWindows
3// Copyright (c) 1995, 1996 by Borland International, All Rights Reserved
4//
5/// \file
6/// Definition of TRecentFiles class
7//----------------------------------------------------------------------------
8
9#if !defined(OWL_RECENTFILE_H)
10#define OWL_RECENTFILE_H
11
12#include <owl/private/defs.h>
13#if defined(BI_HAS_PRAGMA_ONCE)
14# pragma once
15#endif
16
17#include <owl/eventhan.h>
18#include <owl/filename.h>
19
20
21namespace owl {
22
23//
24/// Derived classes should catch the following registered message to know
25/// when an item in the recent list has been selected.
26//
27#define MruFileMessage _T("MRUFILEMESSAGE") ///< String that OWL uses to register the message used by the MRU classes.
28
29#include <owl/preclass.h>
30
31//
32/// \class TRecentFiles
33// ~~~~~ ~~~~~~~~~~~~
34/// TRecentFiles implements a most-recent files list, designed to be mixed in with
35/// TApplication. The list is appended to the menu with CM_FILEOPEN and CM_FILECLOSE
36/// options.
37//
38class _OWLCLASS TRecentFiles : virtual public TEventHandler
39{
40 public:
41 enum { MaxMenuItems = 10 };
42
43 TRecentFiles(const tstring& iniOrKeyName, int numSavedFiles = MaxMenuItems,
44 int namelen = 30, bool useRegistry=false, bool keepFullNameInMenu = true);
45 virtual ~TRecentFiles();
46
47 void SaveMenuChoice(LPCTSTR text);
49 void RemoveMenuChoice(LPCTSTR text);
51 bool GetMenuText(int id, LPTSTR text, int maxTextLen);
52 tstring GetMenuText(int id);
53 void SetMaxMruItems(int maxValue);
54 void SetDispLength(const int);
55 void EnableRegistry(bool enable = true);
56 int GetMruCount();
57
58 protected:
59 void CeExit(TCommandEnabler& ce);
60 void CmFile(uint id);
61
62 // Do the MRU items already exists in the menu?
63 //
64 bool MruItemsInsertedIntoMenu(HMENU hMenu);
65 void RemoveMruItemsFromMenu(HMENU hMenu);
66 void InsertMruItemsToMenu(HMENU hMenu);
67 int GetMenuPos(HMENU hMenu, uint id);
68 int GetExitMenuPos(HMENU hMenu);
69
70 // Profile methods
71 //
72 //int GetMruCount();
73 void RemoveMruIndex(int index);
74 void AddMruItem(LPCTSTR text);
75 void AddMruItem(const tstring& text) {AddMruItem(text.c_str());}
76 bool ExistMruItem(LPCTSTR text);
77 bool ExistMruItem(const tstring& text) {return ExistMruItem(text.c_str());}
78 int GetMruItemIndex(LPCTSTR text);
79 int GetMruItemIndex(const tstring& text) {return GetMruItemIndex(text.c_str());}
80
81 private:
82 // Read information from the .INI file or Registry
83 //
84 void Read();
85 // Write information from the .INI file or Registry
86 //
87 void Write();
88
89 static uint MruMessage;
90 int MaxFilesToSave;
91 int MaxDispLen;
92 bool AddedSeparator;
93 bool UseRegistry;
94 tstring MruName;
95 HMENU LastHMenu;
96 TAPointer<TFileName> MruNames;
97 int MruCount;
98 bool keepFullNameInMenu; //when true (default), the name of the file is kept full.
99 //when false, the name is condensed, if it is too big
100
103};
104#include <owl/posclass.h>
105
106
107//-------------------
108// inlines
109inline void TRecentFiles::SetDispLength(const int newLen){
110 MaxDispLen = newLen;
111}
112
114 UseRegistry = enable;
115}
116
117/// Returns the number of files that are currently in the MRU list.
119 return MruCount;
120}
121
122} // OWL namespace
123
124
125#endif // OWL_RECENTFILE_H
Base class for an extensible interface for auto enabling/disabling of commands (menu items,...
Definition window.h:209
TEventHandler is a base class from which you can derive classes that handle messages.
Definition eventhan.h:162
TRecentFiles implements a most-recent files list, designed to be mixed in with TApplication.
Definition rcntfile.h:39
void EnableRegistry(bool enable=true)
Definition rcntfile.h:113
void RemoveMenuChoice(const tstring &text)
Definition rcntfile.h:50
int GetMruCount()
Returns the number of files that are currently in the MRU list.
Definition rcntfile.h:118
void AddMruItem(const tstring &text)
Definition rcntfile.h:75
int GetMruItemIndex(const tstring &text)
Definition rcntfile.h:79
bool ExistMruItem(const tstring &text)
Definition rcntfile.h:77
void SaveMenuChoice(const tstring &text)
Definition rcntfile.h:48
void SetDispLength(const int)
Definition rcntfile.h:109
Definition of TEventHandler and related classes & macros.
#define DECLARE_RESPONSE_TABLE(cls)
Definition eventhan.h:436
#define DECLARE_CASTABLE
Definition objstrm.h:1440
Object Windows Library (OWLNext Core)
Definition animctrl.h:22
std::string tstring
Definition defs.h:79
unsigned int uint
Definition number.h:25
#define _OWLCLASS
Definition defs.h:338