#include <filelist.h>
Inheritance diagram for FileListOp:
Public Member Functions | |
FileListOp () | |
Constructor for the File List Operation. | |
void | Do (OpDescriptor *) |
Attempts to load a file that was in the Recent file list. | |
Static Public Member Functions | |
static BOOL | Init () |
Initialises the FileList Operation. It tries to create several OpDescriptors that will be associated with each of the menu items on the recent file list. They will all invoke this operation and the operation will try to work out which one invoked it. | |
static OpState | GetState (String_256 *, OpDescriptor *) |
Descides if this operation shold be available or not. | |
Static Public Attributes | |
static INT32 | MaxFileListSize = 4 |
Describes how many files will be displayed in the Recent file list. |
Definition at line 127 of file filelist.h.
|
Constructor for the File List Operation.
Definition at line 153 of file filelist.cpp.
|
|
Attempts to load a file that was in the Recent file list.
Reimplemented from Operation. Definition at line 287 of file filelist.cpp. 00288 { 00289 // Get the first 2 chars of the opdescriptors description as this holds the 00290 // file number of the recent file. 00291 TCHAR FileNum[3]; 00292 BOOL WorkedOK = FALSE; 00293 camStrncpy(FileNum, pOpDesc->Token, 2); 00294 FileNum[2] = 0; 00295 00296 TRACEUSER( "jlh92", _T("Op = %s\n"), FileNum ); 00297 00298 // make sure that it contains digits. 00299 if (isdigit(FileNum[0]) && isdigit(FileNum[1])) 00300 { 00301 // Find out which number was chosen 00302 TCHAR *pszMark; 00303 INT32 RecentFileNum = camStrtol( FileNum, &pszMark, 10 ); 00304 00305 TRACEUSER( "jlh92", _T("Recent = %d\n"), RecentFileNum ); 00306 00307 // Ask the app to load the file specified (it will look up the file name etc) 00308 WorkedOK = AfxGetApp().OnRecentFile(RecentFileNum-1); 00309 CCamDoc::EnableRemoveUntouchedDocs(); 00310 } 00311 00312 // See if it worked 00313 if (!WorkedOK) 00314 { 00315 // At this point Current is NULL, so we should put it back 00316 // we have to do this as the creation of a new document went wrong, leaving the pointers upset 00317 Document* pDoc = Document::GetSelected(); 00318 if (pDoc==NULL) 00319 Document::SetNoCurrent(); 00320 else 00321 pDoc->SetCurrent(); 00322 00323 // Same for the view 00324 DocView* pView = DocView::GetSelected(); 00325 if (pView==NULL) 00326 DocView::SetNoCurrent(); 00327 else 00328 pView->SetCurrent(); 00329 00330 // and fail 00331 FailAndExecute(); 00332 } 00333 00334 // End the operations. 00335 End(); 00336 }
|
|
Descides if this operation shold be available or not.
Definition at line 236 of file filelist.cpp. 00237 { 00238 OpState State; 00239 00240 // Get the first 2 chars of the opdescriptors description as this holds the 00241 // file number of the recent file. 00242 TCHAR FileNum[3]; 00243 camStrncpy(FileNum, pOp->Token, 2); 00244 FileNum[2] = 0; 00245 00246 // make sure that it contains digits. 00247 if (isdigit(FileNum[0]) && isdigit(FileNum[1])) 00248 { 00249 // Find out which number was chosen 00250 TCHAR *pszMark; 00251 INT32 Index = camStrtol( FileNum, &pszMark, 10 ); 00252 00253 // Only the first 'MaxFileListSize' items will appear 00254 if (Index > MaxFileListSize) 00255 State.RemoveFromMenu = TRUE; 00256 else 00257 { 00258 // Change the menu string to whatever it needs to be 00259 CCamApp* pApp = (CCamApp*)&AfxGetApp(); 00260 if (!pApp->GetRecentFileText(Index-1, Title)) 00261 { 00262 State.Greyed = TRUE; 00263 00264 // if this is the first item in the list, then it wants to stay in the menu, only greyed 00265 if (Index!=1) 00266 State.RemoveFromMenu = TRUE; 00267 } 00268 } 00269 } 00270 00271 return State; 00272 }
|
|
Initialises the FileList Operation. It tries to create several OpDescriptors that will be associated with each of the menu items on the recent file list. They will all invoke this operation and the operation will try to work out which one invoked it.
Reimplemented from SimpleCCObject. Definition at line 172 of file filelist.cpp. 00173 { 00174 // Register some preferences 00175 if (Camelot.DeclareSection(TEXT("Recent File List"), 3)) 00176 { 00177 Camelot.DeclarePref(NULL, TEXT("FileListSize"), &MaxFileListSize, 1, 9); 00178 } 00179 00180 // Try and create an OpDescriptor. This uses a macro that is define at the top of this file. 00181 BOOL Worked = REG_FILELISTOP(OPTOKEN_MRU_FILE1); 00182 00183 // See if it worked 00184 ERROR1IF(!Worked, FALSE, _R(IDE_NOMORE_MEMORY)); 00185 00186 // And do the same for all the others 00187 Worked = REG_FILELISTOP(OPTOKEN_MRU_FILE2); 00188 ERROR1IF(!Worked, FALSE, _R(IDE_NOMORE_MEMORY)); 00189 00190 // File 3 00191 Worked = REG_FILELISTOP(OPTOKEN_MRU_FILE3); 00192 ERROR1IF(!Worked, FALSE, _R(IDE_NOMORE_MEMORY)); 00193 00194 // File 4 00195 Worked = REG_FILELISTOP(OPTOKEN_MRU_FILE4); 00196 ERROR1IF(!Worked, FALSE, _R(IDE_NOMORE_MEMORY)); 00197 00198 // File 5 00199 Worked = REG_FILELISTOP(OPTOKEN_MRU_FILE5); 00200 ERROR1IF(!Worked, FALSE, _R(IDE_NOMORE_MEMORY)); 00201 00202 // File 6 00203 Worked = REG_FILELISTOP(OPTOKEN_MRU_FILE6); 00204 ERROR1IF(!Worked, FALSE, _R(IDE_NOMORE_MEMORY)); 00205 00206 // File 7 00207 Worked = REG_FILELISTOP(OPTOKEN_MRU_FILE7); 00208 ERROR1IF(!Worked, FALSE, _R(IDE_NOMORE_MEMORY)); 00209 00210 // File 8 00211 Worked = REG_FILELISTOP(OPTOKEN_MRU_FILE8); 00212 ERROR1IF(!Worked, FALSE, _R(IDE_NOMORE_MEMORY)); 00213 00214 // File 9 00215 Worked = REG_FILELISTOP(OPTOKEN_MRU_FILE9); 00216 ERROR1IF(!Worked, FALSE, _R(IDE_NOMORE_MEMORY)); 00217 00218 // All worked 00219 return TRUE; 00220 }
|
|
Describes how many files will be displayed in the Recent file list. Preference: MaxFileListSize Section: Recent File List Range: 1-9 Definition at line 144 of file filelist.h. |