OWLNext
7.0
Borland's Object Windows Library for the modern age
Toggle main menu visibility
Loading...
Searching...
No Matches
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
21
namespace
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
//
38
class
_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);
48
void
SaveMenuChoice
(
const
tstring
& text) {
SaveMenuChoice
(text.c_str());}
49
void
RemoveMenuChoice(LPCTSTR text);
50
void
RemoveMenuChoice
(
const
tstring
& text) {
RemoveMenuChoice
(text.c_str());}
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
101
DECLARE_RESPONSE_TABLE
(
TRecentFiles
);
102
DECLARE_CASTABLE
;
103
};
104
#include <
owl/posclass.h
>
105
106
107
//-------------------
108
// inlines
109
inline
void
TRecentFiles::SetDispLength
(
const
int
newLen){
110
MaxDispLen = newLen;
111
}
112
113
inline
void
TRecentFiles::EnableRegistry
(
bool
enable){
114
UseRegistry = enable;
115
}
116
117
/// Returns the number of files that are currently in the MRU list.
118
inline
int
TRecentFiles::GetMruCount
(){
119
return
MruCount;
120
}
121
122
}
// OWL namespace
123
124
125
#endif
// OWL_RECENTFILE_H
owl::TAPointer
Pointer to an array of type T.
Definition
pointer.h:103
owl::TCommandEnabler
Base class for an extensible interface for auto enabling/disabling of commands (menu items,...
Definition
window.h:209
owl::TEventHandler
TEventHandler is a base class from which you can derive classes that handle messages.
Definition
eventhan.h:162
owl::TRecentFiles
TRecentFiles implements a most-recent files list, designed to be mixed in with TApplication.
Definition
rcntfile.h:39
owl::TRecentFiles::EnableRegistry
void EnableRegistry(bool enable=true)
Definition
rcntfile.h:113
owl::TRecentFiles::RemoveMenuChoice
void RemoveMenuChoice(const tstring &text)
Definition
rcntfile.h:50
owl::TRecentFiles::GetMruCount
int GetMruCount()
Returns the number of files that are currently in the MRU list.
Definition
rcntfile.h:118
owl::TRecentFiles::AddMruItem
void AddMruItem(const tstring &text)
Definition
rcntfile.h:75
owl::TRecentFiles::GetMruItemIndex
int GetMruItemIndex(const tstring &text)
Definition
rcntfile.h:79
owl::TRecentFiles::MaxMenuItems
@ MaxMenuItems
Definition
rcntfile.h:41
owl::TRecentFiles::ExistMruItem
bool ExistMruItem(const tstring &text)
Definition
rcntfile.h:77
owl::TRecentFiles::SaveMenuChoice
void SaveMenuChoice(const tstring &text)
Definition
rcntfile.h:48
owl::TRecentFiles::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-re...
Definition
rcntfile.cpp:95
owl::TRecentFiles::SetDispLength
void SetDispLength(const int)
Definition
rcntfile.h:109
eventhan.h
Definition of TEventHandler and related classes & macros.
DECLARE_RESPONSE_TABLE
#define DECLARE_RESPONSE_TABLE(cls)
Definition
eventhan.h:436
filename.h
DECLARE_CASTABLE
#define DECLARE_CASTABLE
Definition
objstrm.h:1440
owl
Object Windows Library (OWLNext Core).
Definition
animctrl.h:22
owl::tstring
std::string tstring
Definition
defs.h:79
owl::uint
unsigned int uint
Definition
number.h:25
defs.h
_OWLCLASS
#define _OWLCLASS
Definition
defs.h:338
posclass.h
preclass.h
include
owl
rcntfile.h
Generated by
1.18.0