OWLNext    7.0
Borland's Object Windows Library for the modern age
Loading...
Searching...
No Matches
owl::TRecentFiles Class Reference

TRecentFiles implements a most-recent files list, designed to be mixed in with TApplication. More...

#include <owl/rcntfile.h>

Inheritance diagram for owl::TRecentFiles:
owl::TEventHandler

Public Types

enum  { MaxMenuItems = 10 }
 
- Public Types inherited from owl::TEventHandler
typedef bool(* TEqualOperator) (const TGenericTableEntry &, const TEventInfo &)
 

Public Member Functions

 TRecentFiles (const tstring &iniOrKeyName, int numSavedFiles=MaxMenuItems, int namelen=30, bool useRegistry=false, bool keepFullNameInMenu=true)
 Constructor to initialize the external storage and the maximum number of items to save in the most-recently-used (MRU) list.
 
virtual ~TRecentFiles ()
 Deletes the allocated profile.
 
void SaveMenuChoice (LPCTSTR text)
 Saves the menu choice into the profile.
 
void SaveMenuChoice (const tstring &text)
 
void RemoveMenuChoice (LPCTSTR text)
 
void RemoveMenuChoice (const tstring &text)
 
bool GetMenuText (int id, TCHAR *text, int maxTextLen)
 Retrieves the text of the choice based on the ID.
 
tstring GetMenuText (int id)
 Retrieves the text of the choice based on the ID.
 
void SetMaxMruItems (int maxValue)
 Sets the maximum number of items that can be saved with this MRU.
 
void SetDispLength (const int)
 
void EnableRegistry (bool enable=true)
 
int GetMruCount ()
 Returns the number of files that are currently in the MRU list.
 
- Public Member Functions inherited from owl::TEventHandler
virtual bool Find (TEventInfo &info, TEqualOperator op=0)
 Searches the list of response table entries looking for a match.
 
TResult Dispatch (TEventInfo &info, TParam1, TParam2=0)
 Takes the message data from TEventInfo's Msg data member and dispatches it to the correct event-handling function.
 
TResult DispatchMsg (TMsgId, uint id, TParam1, TParam2)
 Search for the event given the message and it and dispatch to the event handler if found.
 

Protected Member Functions

void CeExit (TCommandEnabler &ce)
 Reads information in the TProfile to display the menu choices.
 
void CmFile (uint id)
 Responds to a menu item selection.
 
bool MruItemsInsertedIntoMenu (HMENU hMenu)
 Returns true if the menu has any MRU items in it.
 
void RemoveMruItemsFromMenu (HMENU hMenu)
 Removes the MRU items from the menu.
 
void InsertMruItemsToMenu (HMENU hMenu)
 Reads external information and adds the MRU items into the menu.
 
int GetMenuPos (HMENU hMenu, uint id)
 Searches the menu to find the position of a menu item.
 
int GetExitMenuPos (HMENU hMenu)
 Retrieves the menu position of the CM_EXIT menu item. Returns -1 if not found.
 
void RemoveMruIndex (int index)
 Removes the MRU item at index. Shuffles the items below index up.
 
void AddMruItem (LPCTSTR text)
 Adds an item to the top of the MRU list.
 
void AddMruItem (const tstring &text)
 
bool ExistMruItem (LPCTSTR text)
 Returns true if there are any items in the MRU list that match the text.
 
bool ExistMruItem (const tstring &text)
 
int GetMruItemIndex (LPCTSTR text)
 Returns the index of the MRU item containing text. Returns -1 if not found.
 
int GetMruItemIndex (const tstring &text)
 
- Protected Member Functions inherited from owl::TEventHandler
bool SearchEntries (const TGenericTableEntry *entries, TEventInfo &info, TEqualOperator op)
 Low-level response table search function.
 

Detailed Description

TRecentFiles implements a most-recent files list, designed to be mixed in with TApplication.

The list is appended to the menu with CM_FILEOPEN and CM_FILECLOSE options.

Definition at line 38 of file rcntfile.h.

Member Enumeration Documentation

◆ anonymous enum

Enumerator
MaxMenuItems 

Definition at line 41 of file rcntfile.h.

Constructor & Destructor Documentation

◆ TRecentFiles()

owl::TRecentFiles::TRecentFiles ( const tstring & iniOrKeyName,
int numSavedFiles = MaxMenuItems,
int namelen = 30,
bool useRegistry = false,
bool keepFullNameInMenu = true )

Constructor to initialize the external storage and the maximum number of items to save in the most-recently-used (MRU) list.

Definition at line 95 of file rcntfile.cpp.

References _T, owl::TFileName::Canonical(), MaxMenuItems, MruFileMessage, owl::Section, and SetMaxMruItems().

◆ ~TRecentFiles()

owl::TRecentFiles::~TRecentFiles ( )
virtual

Deletes the allocated profile.

Definition at line 127 of file rcntfile.cpp.

Member Function Documentation

◆ AddMruItem() [1/2]

void owl::TRecentFiles::AddMruItem ( const tstring & text)
inlineprotected

Definition at line 75 of file rcntfile.h.

References AddMruItem().

◆ AddMruItem() [2/2]

void owl::TRecentFiles::AddMruItem ( LPCTSTR text)
protected

Adds an item to the top of the MRU list.

If there is a duplicate, the item is moved from its current position to the top of the list.

Definition at line 362 of file rcntfile.cpp.

References owl::TFileName::Canonical().

◆ CeExit()

void owl::TRecentFiles::CeExit ( TCommandEnabler & ce)
protected

Reads information in the TProfile to display the menu choices.

Definition at line 271 of file rcntfile.cpp.

References InsertMruItemsToMenu(), RemoveMruItemsFromMenu(), and TYPESAFE_DOWNCAST.

◆ CmFile()

void owl::TRecentFiles::CmFile ( uint id)
protected

Responds to a menu item selection.

Definition at line 151 of file rcntfile.cpp.

References owl::TWindow::SendMessage(), and TYPESAFE_DOWNCAST.

◆ EnableRegistry()

void owl::TRecentFiles::EnableRegistry ( bool enable = true)
inline

Definition at line 113 of file rcntfile.h.

◆ ExistMruItem() [1/2]

bool owl::TRecentFiles::ExistMruItem ( const tstring & text)
inlineprotected

Definition at line 77 of file rcntfile.h.

References ExistMruItem().

◆ ExistMruItem() [2/2]

bool owl::TRecentFiles::ExistMruItem ( LPCTSTR text)
protected

Returns true if there are any items in the MRU list that match the text.

Definition at line 387 of file rcntfile.cpp.

References GetMruItemIndex().

◆ GetExitMenuPos()

int owl::TRecentFiles::GetExitMenuPos ( HMENU hMenu)
protected

Retrieves the menu position of the CM_EXIT menu item. Returns -1 if not found.

Definition at line 179 of file rcntfile.cpp.

References GetMenuPos().

◆ GetMenuPos()

int owl::TRecentFiles::GetMenuPos ( HMENU hMenu,
uint id )
protected

Searches the menu to find the position of a menu item.

Definition at line 167 of file rcntfile.cpp.

◆ GetMenuText() [1/2]

tstring owl::TRecentFiles::GetMenuText ( int id)

Retrieves the text of the choice based on the ID.

Definition at line 286 of file rcntfile.cpp.

References _T, and owl::FullFileName.

◆ GetMenuText() [2/2]

bool owl::TRecentFiles::GetMenuText ( int id,
TCHAR * text,
int maxTextLen )

Retrieves the text of the choice based on the ID.

Definition at line 298 of file rcntfile.cpp.

References _T, _tcslen, _tcsncpy, and owl::FullFileName.

◆ GetMruCount()

int owl::TRecentFiles::GetMruCount ( )
inline

Returns the number of files that are currently in the MRU list.

Definition at line 118 of file rcntfile.h.

◆ GetMruItemIndex() [1/2]

int owl::TRecentFiles::GetMruItemIndex ( const tstring & text)
inlineprotected

Definition at line 79 of file rcntfile.h.

References GetMruItemIndex().

◆ GetMruItemIndex() [2/2]

int owl::TRecentFiles::GetMruItemIndex ( LPCTSTR text)
protected

Returns the index of the MRU item containing text. Returns -1 if not found.

Definition at line 396 of file rcntfile.cpp.

◆ InsertMruItemsToMenu()

void owl::TRecentFiles::InsertMruItemsToMenu ( HMENU hMenu)
protected

Reads external information and adds the MRU items into the menu.

Adds a separator between the MRU items and the exit menu item.

Definition at line 226 of file rcntfile.cpp.

References _T, owl::TFileName::CurrentDir, owl::TFileName::Ext, owl::TFileName::File, owl::FullFileName, owl::FullPathName, GetExitMenuPos(), owl::TFileName::GetParts(), owl::TMenu::InsertMenu(), owl::MaxMenuItemLen, and owl::TFileName::Squeezed().

◆ MruItemsInsertedIntoMenu()

bool owl::TRecentFiles::MruItemsInsertedIntoMenu ( HMENU hMenu)
protected

Returns true if the menu has any MRU items in it.

Definition at line 189 of file rcntfile.cpp.

References GetMenuPos().

◆ RemoveMenuChoice() [1/2]

void owl::TRecentFiles::RemoveMenuChoice ( const tstring & text)
inline

Definition at line 50 of file rcntfile.h.

References RemoveMenuChoice().

◆ RemoveMenuChoice() [2/2]

void owl::TRecentFiles::RemoveMenuChoice ( LPCTSTR text)

Definition at line 329 of file rcntfile.cpp.

References GetMruItemIndex(), and RemoveMruIndex().

◆ RemoveMruIndex()

void owl::TRecentFiles::RemoveMruIndex ( int index)
protected

Removes the MRU item at index. Shuffles the items below index up.

Definition at line 338 of file rcntfile.cpp.

References _T.

◆ RemoveMruItemsFromMenu()

void owl::TRecentFiles::RemoveMruItemsFromMenu ( HMENU hMenu)
protected

Removes the MRU items from the menu.

Definition at line 199 of file rcntfile.cpp.

References owl::CM_MRU_LAST, GetExitMenuPos(), GetMenuPos(), and MruItemsInsertedIntoMenu().

◆ SaveMenuChoice() [1/2]

void owl::TRecentFiles::SaveMenuChoice ( const tstring & text)
inline

Definition at line 48 of file rcntfile.h.

References SaveMenuChoice().

◆ SaveMenuChoice() [2/2]

void owl::TRecentFiles::SaveMenuChoice ( LPCTSTR text)

Saves the menu choice into the profile.

Definition at line 318 of file rcntfile.cpp.

References AddMruItem(), GetMruItemIndex(), and RemoveMruIndex().

◆ SetDispLength()

void owl::TRecentFiles::SetDispLength ( const int newLen)
inline

Definition at line 109 of file rcntfile.h.

◆ SetMaxMruItems()

void owl::TRecentFiles::SetMaxMruItems ( int maxValue)

Sets the maximum number of items that can be saved with this MRU.

Definition at line 136 of file rcntfile.cpp.


The documentation for this class was generated from the following files: