#include <menuops.h>
Inheritance diagram for DocOps:
Public Member Functions | |
DocOps () | |
Constructs a new DocOps object: setting default operation flags, and adding it to the Live list. | |
void | Do (OpDescriptor *) |
Actually "DO" a Exit Application operation. | |
Static Public Member Functions | |
static BOOL | Init () |
Create OpDescriptors for the each file operation. | |
static OpState | GetState (String_256 *, OpDescriptor *) |
Find the state of the various DocOps operations. |
Definition at line 397 of file menuops.h.
|
Constructs a new DocOps object: setting default operation flags, and adding it to the Live list.
Definition at line 1093 of file menuops.cpp. 01093 : Operation() 01094 { 01095 }
|
|
Actually "DO" a Exit Application operation.
Reimplemented from Operation. Definition at line 1115 of file menuops.cpp. 01116 { 01117 if ((WhichOp->Token) == String(OPTOKEN_FILEOPEN)) 01118 FileOpenAction(); 01119 else if ((WhichOp->Token) == String(OPTOKEN_FILENEW)) 01120 FileNewAction(); 01121 else if ((WhichOp->Token) == String(OPTOKEN_FILENEW_DRAWING)) 01122 FileNewAction(); 01123 else if ((WhichOp->Token) == String(OPTOKEN_FILENEW_ANIMATION)) 01124 FileNewAnimationAction(); 01125 else if ((WhichOp->Token) == String(OPTOKEN_FILENEW_TEMPLATE1)) 01126 FileNewTemplateAction(1); 01127 else if ((WhichOp->Token) == String(OPTOKEN_FILENEW_TEMPLATE2)) 01128 FileNewTemplateAction(2); 01129 else if ((WhichOp->Token) == String(OPTOKEN_FILENEW_TEMPLATE3)) 01130 FileNewTemplateAction(3); 01131 else if ((WhichOp->Token) == String(OPTOKEN_FILENEW_TEMPLATE4)) 01132 FileNewTemplateAction(4); 01133 else if ((WhichOp->Token) == String(OPTOKEN_FILENEW_TEMPLATE5)) 01134 FileNewTemplateAction(5); 01135 else if ((WhichOp->Token) == String(OPTOKEN_FILENEW_TEMPLATE6)) 01136 FileNewTemplateAction(6); 01137 else if ((WhichOp->Token) == String(OPTOKEN_FILENEW_TEMPLATE7)) 01138 FileNewTemplateAction(7); 01139 else if ((WhichOp->Token) == String(OPTOKEN_FILENEW_TEMPLATE8)) 01140 FileNewTemplateAction(8); 01141 else if ((WhichOp->Token) == String(OPTOKEN_FILENEW_TEMPLATE9)) 01142 FileNewTemplateAction(9); 01143 else if ((WhichOp->Token) == String(OPTOKEN_FILENEW_TEMPLATE10)) 01144 FileNewTemplateAction(10); 01145 else if ((WhichOp->Token) == String(OPTOKEN_FILECLOSE)) 01146 { 01147 // Close the file 01148 FileCloseAction(); 01149 01150 // Always set the working doc to NULL, otherwise we try to indirect it in End(). 01151 // (This is safe even if the document doesn't close (e.g. modified) because we 01152 // don't do much clean-up after a successful or failed document close op - we 01153 // basically just delete the operation. 01154 pOurDoc = NULL; 01155 } 01156 else if ((WhichOp->Token) == String(OPTOKEN_FILESAVE)) 01157 FileSaveAction(); 01158 else if ((WhichOp->Token) == String(OPTOKEN_FILESAVEAS)) 01159 FileSaveAsAction(); 01160 else if ((WhichOp->Token) == String(OPTOKEN_FILESAVEALL)) 01161 { 01162 // Save all modified documents 01163 FileSaveAllAction(); 01164 } 01165 End(); 01166 }
|
|
Find the state of the various DocOps operations.
Definition at line 458 of file menuops.cpp. 00459 { 00460 // File/New and File/Open are always available. 00461 if (pOp->Token == String(OPTOKEN_FILENEW) || 00462 pOp->Token == String(OPTOKEN_FILEOPEN)) 00463 { 00464 return OpState(FALSE, FALSE); 00465 } 00466 00467 //Graham 20/10/97: New template commands 00468 if (pOp->Token == String(OPTOKEN_FILENEW_DRAWING)) 00469 { 00470 //We need to change the name of the command to the name of the 00471 //default template file, converted so the first character 00472 //is upper case and the rest is lower 00473 PathName pathDefaultDrawingTemplate = CTemplateManager::GetDefaultDrawingTemplate(); 00474 00475 String_256 strToReturn=pathDefaultDrawingTemplate.GetFileName(FALSE); 00476 00477 if (strToReturn.IsEmpty()) 00478 strToReturn.Load(_R(IDS_NEWTEMPLATES_DEFAULTNAMEFORDRAWINGMENUITEM)); 00479 00480 strToReturn.toTitle(); 00481 00482 PORTNOTE("other", "Mangle file name to replace _'s with spaces") 00483 strToReturn.SwapChar( _T('_'), _T(' ') ); 00484 00485 *UIDescription=strToReturn; 00486 00487 return OpState(FALSE, FALSE); 00488 } 00489 00490 if (pOp->Token == String(OPTOKEN_FILENEW_ANIMATION)) 00491 { 00492 PORTNOTE("other", "Remove template existance check - too annoying while it's not there!") 00493 #ifndef EXCLUDE_FROM_XARALX 00494 //Does the default animation template exist? 00495 PathName pathDefaultAnimationTemplate=GetDefaultAnimationTemplate(); 00496 BOOL fFileExists=SGLibOil::FileExists(&pathDefaultAnimationTemplate); 00497 00498 TRACEUSER( "jlh92", _T("Template Anim = %s, %d\n"), PCTSTR(pathDefaultAnimationTemplate.GetPath()), fFileExists ); 00499 00500 String_256 strToReturn=pathDefaultAnimationTemplate.GetFileName(FALSE); 00501 00502 if (strToReturn.IsEmpty()) 00503 strToReturn.Load(_R(IDS_NEWTEMPLATES_DEFAULTNAMEFORANIMATIONMENUITEM)); 00504 00505 strToReturn.toTitle(); 00506 00507 *UIDescription=strToReturn; 00508 #else 00509 BOOL fFileExists = FALSE; 00510 #endif 00511 00512 //If not, grey the menu item 00513 return OpState(FALSE, !fFileExists, TRUE); 00514 } 00515 00516 if (pOp->Token == String(OPTOKEN_FILENEW_TEMPLATE1) || 00517 pOp->Token == String(OPTOKEN_FILENEW_TEMPLATE2) || 00518 pOp->Token == String(OPTOKEN_FILENEW_TEMPLATE3) || 00519 pOp->Token == String(OPTOKEN_FILENEW_TEMPLATE4) || 00520 pOp->Token == String(OPTOKEN_FILENEW_TEMPLATE5) || 00521 pOp->Token == String(OPTOKEN_FILENEW_TEMPLATE6) || 00522 pOp->Token == String(OPTOKEN_FILENEW_TEMPLATE7) || 00523 pOp->Token == String(OPTOKEN_FILENEW_TEMPLATE8) || 00524 pOp->Token == String(OPTOKEN_FILENEW_TEMPLATE9) || 00525 pOp->Token == String(OPTOKEN_FILENEW_TEMPLATE10)) 00526 { 00527 //Now find out which template in that path we want 00528 //(This code isn't particularly pleasant) 00529 INT32 iPositionOfFCharacter = pOp->Token.FindNextChar( 'F', 0 ); 00530 TRACEUSER( "jlh92", _T("Token = %s(%d)\n"), PCTSTR(pOp->Token), iPositionOfFCharacter ); 00531 String_256 strNumberOfTemplate; 00532 pOp->Token.Left( &strNumberOfTemplate, iPositionOfFCharacter ); 00533 00534 // Convert the template ordinal into the template name 00535 TCHAR* pszTmp; 00536 INT32 iNumberOfTemplate = camStrtol( (TCHAR *)strNumberOfTemplate, &pszTmp, 10 ); 00537 String_256 strNameOfFile; 00538 CTemplateManager& TemplateManager( GetApplication()->GetTemplateManager() ); 00539 bool fSuccess = TemplateManager.GetTemplateFilename( iNumberOfTemplate, &strNameOfFile ); 00540 00541 // Don't allow any errors set while searching to propagate outside this scope 00542 Error::ClearError(); 00543 00544 // Tell the menu item to remove itsled if we don't have the template 00545 if( !fSuccess ) 00546 return OpState(FALSE, FALSE, TRUE); 00547 00548 //We've found a file. So strip the .xar from the name and capitalize, as follows... 00549 PathName pathTemplates; 00550 pathTemplates.SetFileNameAndType( strNameOfFile ); 00551 *UIDescription = pathTemplates.GetFileName(FALSE); 00552 UIDescription->toTitle(); 00553 00554 return OpState(FALSE, FALSE, FALSE); 00555 } 00556 00557 // File/SaveAll is only available if there is a document that is "dirty". 00558 if (pOp->Token == String(OPTOKEN_FILESAVEALL)) 00559 { 00560 // Are any open non-embedded document's modified? 00561 wxDocManager *pDocManager = AfxGetApp().GetDocumentManager(); 00562 wxList &lstDocuemnt = pDocManager->GetDocuments(); 00563 wxNode *pNode = lstDocuemnt.GetFirst(); 00564 while( NULL != pNode ) 00565 { 00566 CCamDoc *pDoc = (CCamDoc *)pNode->GetData(); 00567 00568 PORTNOTE("other","Removed OLE usage") 00569 #ifndef EXCLUDE_FROM_XARALX 00570 #if (_OLE_VER >= 0x200) 00571 // Don't consider embedded documents for file-saving commands. 00572 if (pDoc->IsEmbedded()) continue; 00573 #endif 00574 #endif 00575 00576 // Is this document "dirty" (and not embedded)? 00577 if( pDoc->IsModified() ) 00578 return OpState(FALSE, FALSE); 00579 00580 // Get the next document template. 00581 pNode = pNode->GetNext(); 00582 } 00583 00584 // If we get here there are no dirty documents. 00585 UIDescription->Load(_R(IDS_FILE_SAVE_ALL_NONE_CHANGED_GREYED)); 00586 return OpState(FALSE, TRUE); 00587 } 00588 00589 // Get the selected document(s). 00590 Document* pKernelDoc = Document::GetSelected(); 00591 CCamDoc* pOilDoc = (pKernelDoc) ? pKernelDoc->GetOilDoc() : 0; 00592 00593 // If there isn't one then none of the other File options are available. 00594 if (!pOilDoc) 00595 { 00596 // This knocks out the rest when there are no docs open. 00597 UIDescription->Load(_R(IDS_FILE_NO_DOC_GREYED)); 00598 return OpState(FALSE, TRUE); 00599 } 00600 00601 // Work out the state of File/Save. 00602 if (pOp->Token == String(OPTOKEN_FILESAVE)) 00603 { 00604 // By default this is available. 00605 BOOL fGreyed = FALSE; 00606 pOp->EnableHotKey(); 00607 #if (_OLE_VER >= 0x200) 00608 // If we're embedding a document, replace "Save..." with "Update..." and disable that HotKey 00609 if (pOilDoc->IsEmbedded()) 00610 { 00611 UIDescription->MakeMsg(_R(IDS_FILE_UPDATE), (LPCTSTR) pOilDoc->GetContainerName()); 00612 pOp->DisableHotKey(); 00613 } 00614 else 00615 #endif 00616 // Disabled because we're not modified? 00617 if (!pOilDoc->IsModified()) 00618 { 00619 fGreyed = TRUE; 00620 UIDescription->Load(_R(IDS_FILE_SAVE_NOT_CHANGED_GREYED)); 00621 } 00622 00623 // Return state. 00624 return OpState(FALSE, fGreyed); 00625 } 00626 00627 // Work out the state of File/Close. 00628 if (pOp->Token == String(OPTOKEN_FILECLOSE)) 00629 { 00630 // By default this is available. 00631 BOOL fGreyed = FALSE; 00632 00633 #if (_OLE_VER >= 0x200) 00634 // Work out what to show for OLE server File/Close. 00635 if (pOilDoc->IsEmbedded()) 00636 { 00637 // The doc is embedded. If we are in server mode then the Close 00638 // option should be greyed. If we aren't in server mode then 00639 // change the text to "Close And Return To ...". 00640 if (!AfxOleGetUserCtrl()) 00641 { 00642 // In server mode. Disable the menu option. 00643 fGreyed = TRUE; 00644 UIDescription->Load(_R(IDS_FILE_CLOSE_SERVER_MODE_GREYED)); 00645 } 00646 else 00647 { 00648 // User control. Enable the option and change the text of the 00649 // Close option to show return. 00650 UIDescription->MakeMsg(_R(IDS_FILE_CLOSE_AND_RETURN), 00651 (LPCTSTR) pOilDoc->GetContainerName()); 00652 } 00653 } 00654 #endif 00655 00656 // Not embeddding - use the default text for the menu option. 00657 return OpState(FALSE, fGreyed); 00658 } 00659 00660 // Work out File/SaveAs (SaveCopyAs), which is always available (if there's a 00661 // selected document). 00662 #if (_OLE_VER >= 0x200) 00663 if (pOp->Token == String(OPTOKEN_FILESAVEAS)) 00664 { 00665 // If we are enabled and embedding then change the menu to Save Copy As. 00666 if (pOilDoc->IsEmbedded()) UIDescription->Load(_R(IDS_FILE_SAVE_COPY_AS)); 00667 } 00668 #endif 00669 00670 // If we get here we're available. 00671 return OpState(FALSE, FALSE); 00672 }
|
|
Create OpDescriptors for the each file operation.
Reimplemented from SimpleCCObject. Definition at line 1185 of file menuops.cpp. 01186 { 01187 REGOP(FILE,OPEN,DocOps) 01188 REGOP(FILE,CLOSE,DocOps) 01189 REGOP(FILE,NEW,DocOps) 01190 REGOP(FILE,SAVE,DocOps) 01191 REGOP(FILE,SAVEAS,DocOps) 01192 01193 REGOP(FILE,NEW_DRAWING,DocOps) 01194 REGOP(FILE,NEW_ANIMATION,DocOps) 01195 REGOP(FILE,NEW_TEMPLATE1,DocOps) 01196 REGOP(FILE,NEW_TEMPLATE2,DocOps) 01197 REGOP(FILE,NEW_TEMPLATE3,DocOps) 01198 REGOP(FILE,NEW_TEMPLATE4,DocOps) 01199 REGOP(FILE,NEW_TEMPLATE5,DocOps) 01200 REGOP(FILE,NEW_TEMPLATE6,DocOps) 01201 REGOP(FILE,NEW_TEMPLATE7,DocOps) 01202 REGOP(FILE,NEW_TEMPLATE8,DocOps) 01203 REGOP(FILE,NEW_TEMPLATE9,DocOps) 01204 REGOP(FILE,NEW_TEMPLATE10,DocOps) 01205 01206 BOOL ok = RegisterOpDescriptor( 01207 0, 01208 _R(IDS_FILE_SAVEALL), 01209 CC_RUNTIME_CLASS(DocOps), 01210 OPTOKEN_FILESAVEALL, 01211 DocOps::GetState, 01212 0, // Help 01213 _R(IDBBL_FILESAVEALL), // Bubble ID 01214 _R(IDD_BARCONTROLSTORE), 01215 _R(IDC_FILESAVEALL), // Button ID 01216 SYSTEMBAR_FILE, // Bar ID 01217 TRUE // Recieve system messages 01218 ); 01219 ERRORIF(!ok, _R(IDE_NOMORE_MEMORY), FALSE); 01220 01221 return TRUE; 01222 }
|