/******************************************************************************************** > TemplateAttribute::TemplateAttribute( const StringBase& InternalName, const StringBase& Question, const StringBase& Param) Author: Colin_Barfoot (Xara Group Ltd) <*****@*****.**> Created: 27/06/97 Purpose: Default constructor for TemplateAttribute Inputs: InternalName Question Param Notes: Currently forms a UserAttribute with a LongKey of WizOp\InternalName/Param ********************************************************************************************/ TemplateAttribute::TemplateAttribute( const StringBase& InternalName, const StringBase& Question, const StringBase& Param) { // Copy as much of the question as we can. SetWizOpNameAndParam(InternalName, Param); // Cache this test for faster Attribute gallery scans. m_fIsAnObjectName = (GetInternalName() == TA_NAME); if (Question.Length() > 0) { String_256 NewValue; INT32 LengthToCopy = (NewValue.MaxLength() < Question.Length()) ? TRACE( _T("TemplateAttribute::TemplateAttribute: Q truncated\n")), NewValue.MaxLength() : Question.Length(); if (LengthToCopy > 0) { String_256 TruncatedQuestion; Question.Left(&TruncatedQuestion, LengthToCopy); if (!Value.Value.Alloc(TruncatedQuestion.Length())) { ERROR1RAW(_R(IDE_NOMORE_MEMORY)); return; } Value.Value = TruncatedQuestion; } } }
SuperGallery *OpGalleryCommand::GetGalleryAndCommand(OpDescriptor *pOpDesc, String_32 *Command) { String_256 Temp = pOpDesc->Token; TCHAR *Str = (TCHAR *)Temp; *Command = TEXT(""); while (*Str != '\0' && *Str != ':') Str++; if (*Str == '\0') return(NULL); // Copy the right end of the string into Command for return *Command = (TCHAR *) (Str+1); // Find the gallery referenced by the left end of the string *Str = '\0'; // NULL Terminate the left end of the string String_32 Bob; Temp.Left(&Bob, 31); SuperGallery* pSuperGallery = SuperGallery::FindSuperGallery(Bob , GalleryBarNameLimitSize); if (pSuperGallery != NULL && pSuperGallery->IsKindOf(CC_RUNTIME_CLASS(SuperGallery))) return((SuperGallery *) pSuperGallery); // Not found, or isn't a gallery?! (eep!) return(NULL); }
void Chapter::GetDebugDetails(StringBase* Str) { NodeRenderablePaper::GetDebugDetails(Str); String_256 TempStr; TempStr._MakeMsg(TEXT("\r\nFoldLine X Coord = #1%ld\r\n"), FoldLineXCoord); (*Str)+=TempStr; }
String_256 LayerManager::CreateUniqueLayerID() { // We can't generate a unique id if there is no current spread ENSURE(CurrentSpread != NULL, "There is no current spread"); String_256 UniqueLayerID; INT32 NumLayers = 0; ListItem* Lyr = LyrDetList.GetHead(); // Calculate how many layers are on the current spread, we must ignore layers // which have been deleted. while (Lyr != NULL) { if (!((LyrDetails*)Lyr)->Deleted) // Don't count deleted layers { NumLayers++; } Lyr = LyrDetList.GetNext(Lyr); } ENSURE(NumLayers != 0, "The current spread has no layers"); INT32 NewLayerNum = NumLayers+1; BOOL Unique; // Flag used to indicate if the id generated is unique or not do { // Construct a first attempt at a unique layer id 'Layer n' // where n = the number of layers on the current spread + 1 UniqueLayerID.MakeMsg(_R(IDS_LAYERMGR_LAYERNAME),NewLayerNum); // Check that UniqueLayerID is indeed unique Unique = TRUE; // Until we know better Lyr = LyrDetList.GetHead(); while (Lyr != NULL) { if (!((LyrDetails*)Lyr)->Deleted) // Ignore deleted layers { if (UniqueLayerID == ((LyrDetails*)Lyr)->Status.StringLayerID) { Unique = FALSE; // UniqueLayerID is not unique so increment NewLayerNum and try again NewLayerNum++; break; } } Lyr = LyrDetList.GetNext(Lyr); // Get the next layer } } while (!Unique); return(UniqueLayerID); }
/******************************************************************************************** > INT32 HTMLExportFilter::Write(DocCoord dcToWrite, CCLexFile* pfileToWrite, TCHAR* pcBuffer) Author: Graham_Walmsley (Xara Group Ltd) <*****@*****.**> Created: 9/4/97 Inputs: pcToWrite The coordinate to write pfileToWrite The file to write to (may be NULL) pcBuffer The text buffer to write to (may be NULL) Returns: The number of TCHARs written Purpose: Writes the coordinate to the file, separated by a comma: 200,100 ********************************************************************************************/ INT32 HTMLExportFilter::Write(DocCoord dcToWrite, CCLexFile* pfileToWrite, TCHAR* pcBuffer) { //Format our coords String_256 strFormat; strFormat.MakeMsg(_R(IDS_HTMLEXPORT_COORDFORMAT), dcToWrite.x, dcToWrite.y); //And write it out return Write(strFormat, pfileToWrite, pcBuffer); }
/******************************************************************************************** > INT32 HTMLExportFilter::Write(INT32 lToWrite, CCLexFile* pfileToWrite, TCHAR* pcBuffer) Author: Graham_Walmsley (Xara Group Ltd) <*****@*****.**> Created: 9/4/97 Inputs: lToWrite The number to write pfileToWrite The file to write to (may be NULL) pcBuffer The text buffer to write to (may be NULL) Returns: The number of TCHARs written Purpose: Writes the number to the file ********************************************************************************************/ INT32 HTMLExportFilter::WriteNumber(INT32 lToWrite, CCLexFile* pfileToWrite, TCHAR* pcBuffer) { //Format our number String_256 strFormat; strFormat.MakeMsg(_R(IDS_HTMLEXPORT_NUMBERFORMAT), lToWrite); //And write it out return Write(strFormat, pfileToWrite, pcBuffer); }
/******************************************************************************************** > String_256 TemplateAttribute::GetQuestion() const Author: Colin_Barfoot (Xara Group Ltd) <*****@*****.**> Created: 09/06/97 Purpose: Retrieves the Question of this TemplateAttribute ********************************************************************************************/ String_256 TemplateAttribute::GetQuestion() const { String_256 Question; const StringBase& SourceString = Value.Value; UINT32 LengthToCopy = SourceString.Length() > Question.MaxLength() ? Question.MaxLength() : SourceString.Length(); SourceString.Left(&Question, LengthToCopy); return Question; }
BOOL PathNameEx::CreateLocation() { PORTNOTETRACE("other","PathNameEx::CreateLocation - do nothing"); #ifndef EXCLUDE_FROM_XARALX if (!IsValid()) return FALSE; // We'll walk the location string from left to right - if we come across non-existent directories, // we create them String_256 strLocation = GetLocation(FALSE); String_256 strDirPath = drivename; INT32 nPos = drivename.Length(); // start after the drivename while( nPos < strLocation.Length() ) { while( ( strLocation[nPos] != chPathSep ) && ( nPos < strLocation.Length() ) ) { strDirPath += strLocation[nPos]; nPos++; } // strDirPath has been added a directory, we check if it exists if (_access((TCHAR*) strDirPath, 0) == -1) // not found, try to create the directory { if (_mkdir((TCHAR*) strDirPath)) { #ifdef _DEBUG TCHAR szMsg[256]; TCHAR szError[128]; switch (errno) { case EACCES: camStrcpy(szError, "access denied (EACCES)"); break; case ENOENT: camStrcpy(szError, "path not found (ENOENT)"); break; default: wsprintf(szError, "errno = %d", errno); } wsprintf(szMsg, "Create directory %s failed, %s", strDirPath, szError); ERROR3(szMsg); #endif return FALSE; } } strDirPath += chPathSep; // add a backslash in case there are further subdirectories nPos++; // move to the next position } #endif return TRUE; }
void CDECL Error::XSetError( UINT32 errID, ...) { if ( (errID==FALSE) || (errID==TRUE) ) { // someone probably used the wrong macro parameters e.g. TRUE and FALSE instead of ID // This call will set an _R(IDE_INTERNAL_ERROR) for us ERROR2RAW( "ERROR1 macro used with invalid parameters" ); return; } TCHAR buf[256]; va_list marker; va_start( marker, errID ); String_256 result; // load the format string as a resoure (note no module ID yet) if (!SmartLoadString(0, errID, buf, sizeof(buf))) { camSnprintf( buf, 256, wxT("Error<%u>"), errID ); // keep inline } // now do _MakeMsg type formatting result.CCvsprintf(buf, marker); #if !defined(EXCLUDE_FROM_RALPH) && !defined(EXCLUDE_FROM_XARALX) // Set the help context. SetNextMsgHelpContext(errID); #endif // ralph needs this so that he can map the ID to a HRESULT before passing it // back to a harness TRACEUSER( "Chris", wxT("oOoOo Ralph Set Error %d \n"), RalphErrorID ); RalphErrorID =errID; // and copy result into ErrorString SetErrorSerious( result ); // trace output because SetErrorSerious doesn't bother TRACE( wxT("Setting error: ID = %d: \"%s\"\n"), errID, ErrorString); // then tidy up va_end( marker ); ResetWhere(); }
void NodeSimpleShape::GetDebugDetails( StringBase* Str ) { #ifdef _DEBUG // Call base class NodeRenderableInk::GetDebugDetails( Str ); InkPath.FindStartOfPath(); String_256 TempStr; (*Str) += TEXT( "\r\nEllipse Path Data Dump\r\n" ); TempStr._MakeMsg( TEXT( "Parallelogram :-\r\n\t#1%ld,\t#2%ld\r\n") TEXT("\t#3%ld,\t#4%ld\r\n") TEXT("\t#5%ld,\t#6%ld\r\n") TEXT("\t#7%ld,\t#8%ld\r\n"), Parallel[0].x, Parallel[0].y, Parallel[1].x, Parallel[1].y, Parallel[2].x, Parallel[2].y, Parallel[3].x, Parallel[3].y ); (*Str) += TempStr; DocRect BlobRect = GetBlobBoundingRect(); TempStr._MakeMsg( TEXT("Blob Bounding Rect :-\r\n\t#1%ld,\t#2%ld\r\n\t#3%ld,\t#4%ld\r\n"), BlobRect.lo.x, BlobRect.lo.y, BlobRect.hi.x, BlobRect.hi.y ); (*Str) += TempStr; if ( InkPath.IsFilled ) (*Str) += TEXT( "The Path is Filled\r\n" ); (*Str) += TEXT( "\r\nNum\tType\tX Coord\tY Coord\r\n" ); PathVerb* Verbs = InkPath.GetVerbArray(); DocCoord* Coords = InkPath.GetCoordArray(); // PathFlags* Flags = InkPath.GetFlagArray(); for (INT32 i=0; i<InkPath.GetNumCoords(); i++) { // Add the info to the string TempStr._MakeMsg( TEXT("#1%d.\t#2%d\t#3%ld,\t#4%ld\r\n"), i, Verbs[i], Coords[i].x, Coords[i].y ); (*Str) += TempStr; } #endif }
BOOL PrintPSRenderRegion::WriteSepFunctions(KernelDC *pDC) { PrintControl *pPrintCtl=NULL; View *pView = GetRenderView(); if (pView) pPrintCtl = pView->GetPrintControl(); if (!pPrintCtl) return TRUE; // Get a pointer to the typeset info structure TypesetInfo *pInfo = pPrintCtl->GetTypesetInfo(); // Is screening off? if (!pInfo->AreScreening()) return TRUE; // Get hold of our PostScript prolog resource... CCResTextFile ScreenFile; // Open the file if (!ScreenFile.open(_R(IDM_PS_SPOTFUNCS), _R(IDT_PS_RES))) { // Failed to open the file... ERROR2(FALSE, "Could not get at PostScript resource!"); } // Read each line from the file and output it to the DC. String_256 LineBuf; TCHAR *pBuf = (TCHAR *) LineBuf; while (!ScreenFile.eof()) { // Copy this line to output. ScreenFile.read(&LineBuf); pDC->OutputTCHARAsChar(pBuf, LineBuf.Length()); pDC->OutputNewLine(); } // All done ScreenFile.close(); return TRUE; }
void OpGenericDownload::OnDownloadFail() { //First get a pointer to the parameters GenericDownloadParam* pGenParam = (GenericDownloadParam*) pParam; if (pGenParam==NULL) { ERROR2RAW("OpBitmapDownload::OnDownloadFail - no download parameters"); return; } //Get the URL which the user typed String_256 strURL=pGenParam->strURL; //And put it up as a message String_256 strMessage; strMessage.MakeMsg(_R(IDS_HTML_DOWNLOADFAILED), &strURL); Error::SetError(0, strMessage, 0); InformError(); }
String_256 ArrowRec::GetStockArrowName(StockArrow ArrowType) { String_256 ArrowName = String_256(_R(IDS_K_ARROWS_DEFAULTARROW)); switch (ArrowType) { case SA_STRAIGHTARROW: ArrowName.Load(_R(IDS_K_ARROWS_STRAIGHTARROW)); break; case SA_ANGLEDARROW: ArrowName.Load(_R(IDS_K_ARROWS_ANGLEDARROW)); break; case SA_ROUNDEDARROW: ArrowName.Load(_R(IDS_K_ARROWS_ROUNDEDARROW)); break; case SA_SPOT: ArrowName.Load(_R(IDS_K_ARROWS_SPOT)); break; case SA_DIAMOND: ArrowName.Load(_R(IDS_K_ARROWS_DIAMOND)); break; case SA_ARROWFEATHER: ArrowName.Load(_R(IDS_K_ARROWS_ARROWFEATHER)); break; case SA_ARROWFEATHER2: ArrowName.Load(_R(IDS_K_ARROWS_ARROWFEATHER2)); break; case SA_HOLLOWDIAMOND: ArrowName.Load(_R(IDS_K_ARROWS_HOLLOWDIAMOND)); break; default: ArrowName = ""; break; } return ArrowName; }
void CTemplateManager::GetTemplateList( CTemplateList* pList, const String_256& strTemplatePath, bool fLocal ) { // Don't bother with any of this is directory is invalid if( !wxDir::Exists( (PCTSTR)strTemplatePath ) ) return; //Now search that path for templates //Start by setting the leaf name to *.xar String_256 strSearchFilename( _R(IDS_NEWTEMPLATES_DEFAULTTEMPLATEEXTENSION) ); // Get the default entry names String_256 strPathOfDrawingTemplate = CTemplateManager::GetDefaultDrawingTemplate().GetPath(FALSE); strPathOfDrawingTemplate.SwapChar( _T('_'), _T(' ') ); String_256 strPathOfAnimationTemplate = CTemplateManager::GetDefaultAnimationTemplate().GetPath(FALSE); strPathOfAnimationTemplate.SwapChar( _T('_'), _T(' ') ); String_256 strPathOfFile; TRACEUSER( "jlh92", _T("DefPath = %s, %s\n"), PCTSTR(strPathOfDrawingTemplate), PCTSTR(strPathOfAnimationTemplate) ); // Build system template path PathName pathTemplates( strTemplatePath ); pathTemplates.SetFileNameAndType( strSearchFilename ); PathName pathOfFile( pathTemplates ); String_256 strTemplates = pathTemplates.GetPath( FALSE ); //And search the path for xar files that are //NOT the default animation or drawing templates String_256 strNameOfFile; if( FileUtil::StartFindingFiles( &strTemplates ) ) { while( FileUtil::FindNextFile( &strNameOfFile ) ) { pathOfFile.SetFileNameAndType( strNameOfFile ); strPathOfFile = pathOfFile.GetFileName(TRUE); if( 0 != strPathOfFile.CompareTo( strPathOfDrawingTemplate, FALSE ) && 0 != strPathOfFile.CompareTo( strPathOfAnimationTemplate, FALSE ) ) { (*pList)[strPathOfFile] = fLocal; TRACEUSER( "jlh92", _T("Curr = %s\n"), PCTSTR(strPathOfFile) ); } } FileUtil::StopFindingFiles(); } // Don't allow any errors set while searching to propagate outside this scope Error::ClearError(); }
BOOL LibraryFile::CheckForSubIndexes(SuperGallery *ParentGal, PathName *Path, SGLibType Type, BOOL Updated) { // The directory given had no XaraInfo\index.txt file, maybe it's a sublib, check // For defaults... String_256 DefaultIndex; String_256 IndexDesc; BOOL CanGenerate; BOOL ok = TRUE; // Need to reset the Quiet status before a stream of Library::Init calls ParentLibraryGallery->SetQuietStatus(FALSE); if(GetSubIndexDetails(ParentLibraryGallery, &DefaultIndex, &IndexDesc, &CanGenerate)) { String_256 SubP(Path->GetPath(TRUE)); // "%s\\XaraInfo\\%s" SubP += String_16(_R(IDS_LIBRARIES_XARAINFO_DIRNAME)); SubP += TEXT("\\") + DefaultIndex; PathName SubPath(SubP); if(!SubPath.IsValid()) { ERROR3("LibraryFile::CheckForSubIndexes invalid subpath"); return FALSE; } BOOL Generate = FALSE; BOOL Found = FALSE; // Is there a default sub index ? Found = SGLibOil::FileExists(&SubPath); if(!Found && CanGenerate) { if(Library::RemoteIndexes && GenerateIndexFile::IsDirectoryReadOnly(Path)) { // Check whether there's a 'temporary' index for this directory, and // possibly use that instead of the read only directory... String_256 RemoteLocationOfIndex; BOOL Existing = GenerateIndexFile::CheckForRemote(Path, &RemoteLocationOfIndex); if(Existing) { String_256 SubP(RemoteLocationOfIndex); // %s\\XaraInfo\\%s SGLibOil::AppendSlashIfNotPresent(&SubP); SubP += String_16(_R(IDS_LIBRARIES_XARAINFO_DIRNAME)); SubP += TEXT("\\") + DefaultIndex; PathName TmpSubPath(SubP); Found = SGLibOil::FileExists(&TmpSubPath); // OK, so there's a remote index sitting pretty in the user's temporary // location... Use that and don't bother generating a new one... if(Found) { SubPath.SetPathName(SubP); Path->SetPathName(RemoteLocationOfIndex); } } } if(!Found) { // tell the user that there is no index file, and ask if they want one generating String_256 WarnMsg; String_256 TmpPath(SubPath.GetLocation(FALSE)); LibraryFile::TidyUpSubPath(&TmpPath); WarnMsg.MakeMsg(_R(IDS_LIBRARY_NO_INDEX_FILE_GEN), (TCHAR *)IndexDesc, (TCHAR *)TmpPath); Error::SetError(0, WarnMsg, 0); //INT32 ButtonPressed = InformMessage(0, _R(IDS_NOTHUMBNAILS), _R(IDS_THUMBNAILS), _R(IDS_CANCEL)/*, _R(IDS_HELP)*/); INT32 ButtonPressed = InformMessage(0, _R(IDS_CREATE), _R(IDS_CANCEL)); Error::ClearError(); if(ButtonPressed < 2) { // Generate an index... String_64 Author(PRODUCT_NAME); Generate = GenerateDefaultIndex(&SubPath, Path, &Author, Type, TRUE); ok = TRUE; } else { // Cancel or help clicked ok = FALSE; } } } if(!Found && !CanGenerate) { // tell the user that there is no index file, and give them a cancel... String_256 WarnMsg; String_256 TmpPath(SubPath.GetLocation(FALSE)); LibraryFile::TidyUpSubPath(&TmpPath); WarnMsg.MakeMsg(_R(IDS_LIBRARY_NO_INDEX_FILE), (TCHAR *)IndexDesc, (TCHAR *)TmpPath); Error::SetError(0, WarnMsg, 0); INT32 ButtonPressed = InformWarning(0, _R(IDS_CANCEL), NULL); Error::ClearError(); ok = FALSE; } // Check again... Found = SGLibOil::FileExists(&SubPath); if((Found && ok) || (!Found && Generate && ok)) { String_256 Description256 = Path->GetPath(); AbbreviateName(Description256, 60, TRUE); String_64 Description(Description256); BOOL DoAgain = TRUE; while (DoAgain) { DoAgain = FALSE; // Create the sub lib Library *NewSubLib = new Library; if (NewSubLib != NULL) { String_64 DefIndex64(DefaultIndex); String_256 PathToAdd256 = SubPath.GetLocation(FALSE); TidyUpSubPath(&PathToAdd256); PathName PathToAdd(PathToAdd256); Error::ClearError(); // Create the actual group itself if(NewSubLib->Init(ParentGal, &PathToAdd, &Description, &DefIndex64, Type, Updated)) { Libraries.AddTail(NewSubLib); ok = TRUE; // Keep track of libraries added for redraw purposes... AddNewFolderToScrollRedrawSystem(NewSubLib); } else { delete NewSubLib; NewSubLib = NULL; String_256 WarnMsg; String_256 SmallPath; PathToAdd256.Left(&SmallPath, 150); // "The index for '%s' seems to be invalid and requires updating." WarnMsg.MakeMsg(_R(IDS_LIBRARY_DODGY_INDEX), (TCHAR *)SmallPath); Error::SetError(0, WarnMsg, 0); INT32 Button = InformWarning(0, _R(IDS_GENERATE), _R(IDS_CANCEL)); Error::ClearError(); String_256 IPathToAdd256(PathToAdd256); SGLibOil::AppendSlashIfNotPresent(&IPathToAdd256); IPathToAdd256 += TEXT("indexfle.txt"); // This is just to check we can write ok... PathName IPathToAdd(IPathToAdd256); if(Button == 1) DoAgain = SGLibOil::GenerateClicked(ParentLibraryGallery, &IPathToAdd); if(!DoAgain) ok = FALSE; Error::ClearError(); } } } } } return ok; }
INT32 LibraryFile::Init(SuperGallery *ParentGal, PathName *APath, SGLibType Type, BOOL Updated, BOOL DoScroll) { #ifndef EXCLUDE_GALS if(ParentGal == NULL || APath == NULL || !Libraries.IsEmpty()) { ERROR3("LibraryFile::Init - NULL parameters are illegal OR Init called > 1 times"); if(!Libraries.IsEmpty()) return(Libraries.GetCount()); else return 0; } BOOL ok = TRUE; // Tidy up Path a bit String_256 OurPath(APath->GetPath()); LibraryFile::TidyUpSubPath(&OurPath); // Now point Path to the new pathname PathName ModifiedPath(OurPath); PathName *Path = &ModifiedPath; if(!ModifiedPath.IsValid()) { ERROR3("LibraryFile::Init -> Modified library path is invalid"); return 0; } // Remember the pathname and type MyPath = *Path; MyType = Type; ParentGallery = ParentGal; if(ParentGallery->IsKindOf(CC_RUNTIME_CLASS(LibraryGallery))) ParentLibraryGallery = (LibraryGallery *)ParentGal; else { ERROR3("LibraryFile::Init passed a non-library gallery - yikes..."); return 0; } // Need to reset the Quiet status before a stream of Library::Init calls ParentLibraryGallery->SetQuietStatus(FALSE); BOOL Retry = TRUE; while(Retry) { Retry = FALSE; // Would be nice to have a way of adding a file to a path in PathName... Is there one ? if(!SGLibOil::FileExists(Path)) { // We're opening the font gallery, but can't find the font library path - don't warn if(Type == SGLib_Font) return 0; // tell the user that the directory doesn't exist String_256 WarnMsg; String_256 DefaultIndex; String_256 IndexDesc; BOOL CanGenerate; ok = LibraryFile::GetSubIndexDetails(ParentLibraryGallery, &DefaultIndex, &IndexDesc, &CanGenerate); String_256 TmpPath(Path->GetLocation(FALSE)); LibraryFile::TidyUpSubPath(&TmpPath); // Taken out by Graham 30/10/97: If the gallery had no directory specified, //we used to throw a warning which said "do you want to specify another folder?" //We don't do this any more, because the default is to open all galleries empty and //then download stuff from the Xara web site #if 0 WarnMsg.MakeMsg(_R(IDS_BROWSE_OR_SCAN), (TCHAR *)IndexDesc, (TCHAR *)TmpPath); Error::SetError(0, WarnMsg, 0); INT32 ButtonPressed = InformWarning(0, _R(IDS_BROWSE), _R(IDS_RETRY), _R(IDS_CANCEL)/*, _R(IDS_HELP)*/); #else // WEBSTER INT32 ButtonPressed = 3; #endif // WEBSTER TRACEUSER( "Richard", _T("ButtonPressed: %d\n"), ButtonPressed); Error::ClearError(); switch(ButtonPressed) { case 1: { // Open the Browse dialog (or the Add.. dialog as it seems to be called now) PathName ThePath(*Path); // This returns FALSE if Cancel was hit, or an error occurred. if(!SGLibOil::GetLibPath(ParentLibraryGallery, &ThePath, CanGenerate, Type)) { ERROR3("GetLibPath returned FALSE in LF::Init"); return 0; } else { ModifiedPath = ThePath; if(!ModifiedPath.IsValid()) { ERROR3("LibraryFile::Init -> scanned library path is invalid"); return 0; } // Remember the pathname MyPath = ThePath; switch(Type) { case SGLib_ClipArt: case SGLib_Bitmap: LibClipartSGallery::DefaultLibraryPath = MyPath.GetPath(); LibClipartSGallery::ClipartPath = LibClipartSGallery::DefaultLibraryPath; break; case SGLib_ClipArt_WebThemes: LibClipartSGallery::DefaultLibraryPath = MyPath.GetPath(); LibClipartSGallery::WebThemePath = LibClipartSGallery::DefaultLibraryPath; break; #ifndef STANDALONE case SGLib_Texture: case SGLib_Fractal: LibFillsSGallery::DefaultLibraryPath = MyPath.GetPath(); break; case SGLib_Font: // WEBSTER-Martin-09/01/97 - Put back by Ranbir. //#ifndef WEBSTER FontsSGallery::DefaultLibraryPath = MyPath.GetPath(); break; // Not in webster so we get the error below //#endif // WEBSTER #endif default: ERROR2(FALSE,"Library::ScanForLocation Type not present!"); break; } } break; } case 2: Retry = TRUE; #if 0 { // Scan String_256 Result; if(!Library::ScanForLocation(Type, &Result)) { ERROR3("No libraries found..."); return 0; } if(!ModifiedPath.SetPathName(Result)) { ERROR3("LibraryFile::Init -> scanned library path is invalid"); return 0; } // Remember the pathname and type MyPath = *Path; } #endif break; case 3: // Cancel return 0; } } } // Wipe libraries added to gallery for scroll / redraw purposes... InitScrollRedrawSystem(); // Check the actual path exists if(SGLibOil::FileExists(Path)) { // Would be nice to have a way of adding a file to a path in PathName... Is there one ? String_256 IndexFile((const TCHAR *)Path->GetPath(TRUE)); // "%s\\XaraInfo\\index.txt" IndexFile += String_16(_R(IDS_LIBRARIES_XARAINFO_DIRNAME)); IndexFile += TEXT("\\") + String_16(_R(IDS_LIBRARIES_INDEX_FILENAME)); PathName IndexFilePath(IndexFile); if(!IndexFilePath.IsValid()) { ERROR3("LibraryFile::Init indexfilepath is invalid"); return 0; } CCDiskFile MainIndex; if (!MainIndex.InitLexer(FALSE)) { // SetError! ERROR3("LibraryFile::LibraryFile InitLexer failed"); return(0); } if(SGLibOil::FileExists(&IndexFilePath)) { // Count lines in index file INT32 Count = CountLines(&IndexFilePath); TRACEUSER( "Richard", _T("%d lines in index file\n"), Count); // Used for the percentage display INT32 CurrentGroupNumber = 0; // Just in case there's a slow job already going on... SmashSlowJob(); String_64 SlowJob(_R(IDS_LIBRARY_SCANNING)); BeginSlowJob(Count, FALSE, &SlowJob); // Now use the index file to create each group in turn if (MainIndex.open(IndexFilePath, ios::in)) { MainIndex.SetWhitespace(""); // Setting this to blank lets us read non-"'d strings MainIndex.SetDelimiters(","); // ,s delimit our fields MainIndex.SetCommentMarker('#'); // #'d lines are commented out MainIndex.SetStringDelimiters(""); // No string delimiters String_64 Directory; String_64 Description; String_64 SubIndex; String_64 Kind; LexTokenType TT; BOOL EscapePressed = FALSE; while(ok && !EscapePressed) { if(!MainIndex.GetToken()) break; // Get SubLib directory name // Keep reading tokens until we hit a normal one... (skips line ends and // comments for us TT = MainIndex.GetTokenType(); while (TT != TOKEN_NORMAL && ok) { ok = MainIndex.GetToken(); if(!ok) break; TT = MainIndex.GetTokenType(); ok = (TT != TOKEN_EOF); if(!ok) break; } if(!ok) break; Directory = MainIndex.GetTokenBuf(); KillLeadingSpaces(&Directory); if(!MainIndex.GetToken()) break; // Get ',' if(!MainIndex.GetToken()) break; // Get Description String_256 Description256; Description256 = MainIndex.GetTokenBuf(); KillLeadingSpaces(&Description256); Description256.Left(&Description, 60); if(!MainIndex.GetToken()) break; // Get ',' if(!MainIndex.GetToken()) break; // Get Sub Library Index name SubIndex = MainIndex.GetTokenBuf(); KillLeadingSpaces(&SubIndex); if(!MainIndex.GetToken()) break; // Get ',' if(!MainIndex.GetToken()) break; // Get type of files in sublib Kind = MainIndex.GetTokenBuf(); KillLeadingSpaces(&Kind); BOOL Match = FALSE; Match = ParentLibraryGallery->CheckForIndexMatch(&Kind); if(Match) { // Show status of additions EscapePressed = !ContinueSlowJob(CurrentGroupNumber++); // Sort pathname of sublib directory out String_256 SubP(Path->GetPath(TRUE)); SubP += Directory; PathName SubPath(SubP); if(!SubPath.IsValid()) { ERROR3("LibraryFile::Init - invalid subpath"); if(MainIndex.isOpen()) MainIndex.close(); EndSlowJob(); return 0; } // Go ahead and add the new group if(ok) { // Create the sub lib Library *NewSubLib = new Library; if (NewSubLib != NULL) { // Create the new group in the gallery (note the TRUE for create a virtualised one if // we can to save time / memory) if(NewSubLib->Init(ParentGal, &SubPath, &Description, &SubIndex, Type, Updated, TRUE)) { Libraries.AddTail(NewSubLib); // Keep track of libraries added for redraw purposes... AddNewFolderToScrollRedrawSystem(NewSubLib); } else { // This check is new, should be ok... delete NewSubLib; NewSubLib = NULL; ERROR3("Library::Init failed in LibraryFile::Init"); ok = FALSE; } } } } } } else { // Failed to open the index file... // SetError?! ERROR3("LibraryFile::LibraryFile couldn't open index file"); ok = FALSE; } EndSlowJob(); } else { // The directory given had no XaraInfo\index.txt file, maybe it's a sublib, check // For defaults... ok = CheckForSubIndexes(ParentGal, Path, Type, Updated); } // reclaim lexer-buffer memory MainIndex.DeinitLexer(); // And close the file if(MainIndex.isOpen()) MainIndex.close(); // Scroll / redraw the newly added groups... if(DoScroll) DoScrollRedraw(); } else { TRACEUSER( "Richard", _T("Path doesn't exist\n")); } // And return the number of items created return(Libraries.GetCount()); #endif return 0; }
void CBrushGadget::GetDialogTitle (String_256& DlgTitle) const { DlgTitle.Load (BubbleID_m); }
BOOL WebAddress::Parse(const String_256& InString) { //First set all the member strings to zero. Absolute=FALSE; Scheme.Empty(); NetLoc.Empty(); Path.Empty(); Parameters.Empty(); Query.Empty(); Fragment.Empty(); Scheme.Empty(); //If InString="", that's all we need to do... if (InString.IsEmpty()) return TRUE; //And set up a couple of strings we can play around with String_256 StringToParse=InString; //If the parse string is empty, we need do nothing, because all our fields are //already blank. Return TRUE. if (StringToParse.IsEmpty()) return TRUE; //Now set up some strings. These are all hard coded cos it reduces code size //This shouldn't matter for purposes of internationalisation, because URLs //are an international system. String_256 sNetloc="//"; INT32 iLowerCaseA=INT32 ('a'); INT32 iLowerCaseZ=INT32 ('z'); INT32 iUpperCaseA=INT32 ('A'); INT32 iUpperCaseZ=INT32 ('Z'); char cBackslash='\\'; char cSlash='/'; char cHash='#'; char cColon=':'; char cQuestionmark='?'; char cSemicolon=';'; //First we want to find the Fragment section of the URL. //This should start with a # INT32 iFound=StringToParse.FindNextChar(cHash); //If we've found a #, copy the whole identifier into the "fragment" member variable if(iFound>=0) StringToParse.Split(&StringToParse, &Fragment, iFound, FALSE); //Now search the parse string for a scheme (the bit at the start, //e.g. http:). To do this we search for a colon. iFound=StringToParse.FindNextChar(cColon); //Have we found a colon? if(iFound>=0) { BOOL IsAScheme=TRUE; //Yes. We now need to check that everything before that colon is a letter. for (INT32 iStringPtr=(iFound-1); iStringPtr>=0; iStringPtr--) { if (!StringBase::IsAlpha(StringToParse[iStringPtr])) { IsAScheme=FALSE; } } //Was everything before the colon a letter? if (IsAScheme) //Yes, so split the string after that colon StringToParse.Split(&Scheme, &StringToParse, iFound, TRUE); } //Now look for a network location iFound=StringToParse.Sub(sNetloc); //Have we found a //? if(iFound>=0) { //Yes. So find the next / (or the end of the string) //To do this, set up a string pointer that starts from two //characters after iFound INT32 iStringPtr=iFound+2; //And move that string pointer forwards until //either it points at a slash or it reaches the end of the //string while (iStringPtr<StringToParse.Length() && StringToParse[iStringPtr]!=cSlash) { iStringPtr++; } StringToParse.Split(&NetLoc, &StringToParse, iStringPtr, FALSE); } //Now look for query information. iFound=StringToParse.FindNextChar(cQuestionmark); //Have we found a question mark? if(iFound>=0) StringToParse.Split(&StringToParse, &Query, iFound,FALSE); //Now look for parameter information. iFound=StringToParse.FindNextChar(cSemicolon); //Have we found a semicolon? if(iFound>=0) StringToParse.Split(&StringToParse, &Parameters, iFound, FALSE); //And whatever is left is the path. Path=StringToParse; return TRUE; }
BOOL BitmapPreviewData::SetBackgroundFromPage(CCDiskFile &DiskFile, Spread * pSpread) { String_256 s; // to contain the generated html strings // If the user has not specified a spead then assume the selected spread in the current doc if (pSpread == NULL) { // get the current doc Document *pDoc = Document::GetCurrent(); ERROR3IF(pDoc == NULL, "No Current Document"); if (pDoc == NULL) return FALSE; pSpread = pDoc->GetSelectedSpread(); } // get the page colour, or bitmap fill KernelBitmap *pPageBmp = NULL; DocColour *pPageColour = NULL; OpBackground::GetPageColour(pSpread, &pPageBmp, &pPageColour); BOOL Ok = TRUE; // check for a bitmap page background first if (pPageBmp != NULL) // the page background was a bitmap { // check if we haven't exported that bitmap before if (pPagePath == NULL) { // alocate the path name pPagePath = new PathName; if (pPagePath) { // create a new temporary file Ok = FileUtil::GetTemporaryPathName( _T("gif"), pPagePath); } else Ok = FALSE; } // check if we have a valid path if (Ok) Ok = pPagePath->IsValid(); // export the background bitmap into the a file if (Ok && ExportBrowserTypeBitmap(pPageBmp, pPagePath)) { // everything went ok, so add the link in the html file s.MakeMsg(_R(IDS_HTML_BGIMAGE), (const TCHAR *)pPagePath->GetFileName()); DiskFile.write(s); } return Ok; } // If we recovered a page background colour then use that // otherwise Page is by default white so set this as a background BOOL AllocatedColour = FALSE; if (pPageColour == NULL) { // Neither colour nor bitmap. AllocatedColour = TRUE; pPageColour = new DocColour(COLOUR_WHITE); // default colour of a page (white) } // convert to a browser colour String_32 col; if (ComposeHTMLColour(pPageColour,col)) { // output the background colour s.MakeMsg(_R(IDS_HTML_BGCOLOUR), (TCHAR *)col); DiskFile.write(s); } else Ok = FALSE; if (AllocatedColour && pPageColour != NULL) delete pPageColour; return Ok; }
BOOL OpMenuLoad::LoadFile(CCLexFile* pFileToLoad, UINT32 nPrefFilter) { // Make sure we have a valid file to load. /* TRACEUSER( "JustinF", _T("In OpMenuLoad::LoadFile(%p, %u)\n"), (LPVOID) pFileToLoad, nPrefFilter); */ ERROR3IF(!pFileToLoad, "Null CCLexFile* in OpMenuLoad::LoadFile"); // Find out the position of the filter selected by the user in the open dialog INT32 SelectedPos = 0; #if !defined(EXCLUDE_FROM_RALPH) && !defined(EXCLUDE_FROM_XARALX) SelectedPos = BaseFileDialog::SelectedFilter; #endif // Go get the first filter in the list Filter* pFilter = Filter::GetFirst(); // Do we know which filter was used? (we know nothing about things in the recent file // list). If we don't, then use the preferred one, by default the generic filter. if (nPrefFilter != FILTERID_USERCHOICE || SelectedPos == 0) { // We know nothing. We will have to go and have a look at all the possibles // We will find the Filter Family and ask it to try and load the file. UINT32 nID = (nPrefFilter != FILTERID_USERCHOICE) ? nPrefFilter : FILTERID_GENERIC; while (pFilter != NULL && pFilter->FilterID != nID) { // Try the next filter pFilter = Filter::GetNext(pFilter); } } else { // We know which type of filter the user had selected in the file dialog // Find the filter that the user chose. while (pFilter != NULL) { // This is the filter? if (pFilter->GetFlags().CanImport && pFilter->pOILFilter->Position == SelectedPos) break; // Try the next filter pFilter = Filter::GetNext(pFilter); } } // Check that the Filter existed if (pFilter == NULL) { // It did not... InformError(_R(IDT_CANT_FIND_FILTER)); return FALSE; } // Get pointer to current doc 'cos we'll need it several times... Document* pCurDoc = Document::GetCurrent(); // If this is not a filter family, check for compatibility before asking // filter to load the file. // This means the user has chosen an explicit filter to handle the import PathName Path = pFileToLoad->GetPathName(); String_256 FilePath = Path.GetPath(); // FilePath will be null if a pathname is not valid if (!pFilter->IS_KIND_OF(FilterFamily) && !FilePath.IsEmpty()) { UINT32 Size = 1024; size_t FileSize; ADDR FilterBuf = pFilter->LoadInitialSegment(Path, &Size, &FileSize); // If there has been a problem in the load initial segment then fail now. if (FilterBuf == NULL) { // Tell the user about the problem and get out now while the goings good InformError(); return FALSE; } // Inform any filters that we are about to do a HowCompatible call. // This would allow a set of filters which have common functionality hidden in a // filter that cannot import and cannot export handle this call and hence set // itself up. This would allow it to maybe cache a result which should only be // checked by the first filter in the group. pFilter->PreHowCompatible(); // Change this to be less than 8 as the filters like the Accusoft forms return // 8 and 9 to make sure that they are last in the chain. if (pFilter->HowCompatible(Path, FilterBuf, Size, UINT32(FileSize)) < 8) { // Not 100% happy with this file - ask for confirmation. ErrorInfo Question; Question.ErrorMsg = _R(IDW_OPENQUERY_NOTSURE); Question.Button[0] = _R(IDB_OPENQUERY_OPEN); Question.Button[1] = _R(IDB_OPENQUERY_DONTOPEN); if ((ResourceID)AskQuestion(&Question) != _R(IDB_OPENQUERY_OPEN)) { // User asked for this to be cancelled. TRACEUSER( "Tim", _T("Filter compatibility was less than 10\n")); // Close the file, report the abort and finish. CCFree(FilterBuf); //InformMessage(_R(IDT_IMP_USERABORT)); return FALSE; } } // Get rid of initial file header CCFree(FilterBuf); } // we have to try and open the file try { // Found the Filter, so ask it to import the file please if (!pFilter->DoImport(this, pFileToLoad, pCurDoc)) { // Something went a bit wrong - tell the user what it was. // Only tell them if not special user cancelled error message if (Error::GetErrorNumber() != _R(IDN_USER_CANCELLED)) { // Only supress the error if not the special user abort error // ***** For now use the native EPS filter if (pFilter->FilterID == FILTERID_NATIVE_EPS && Error::GetErrorNumber() != _R(IDT_IMPORT_USERABORT)) { Error::ClearError(); InformError(_R(IDS_ERRORINARTFILE)); } else { // Tell the user what the problem was InformError(); wxMessageDialog dlg( NULL, _T( "Xara LX failed to load the design.\n\n") _T( "This is an early demonstration version of the program which does ") _T( "not yet support all of the data types that can appear in XAR designs."), _T("Load failed"), wxOK ); dlg.ShowModal() ; } } else { // otherwise remove the error so it won't get reported Error::ClearError(); } // and fail return FALSE; } } // See if there was a file io errir catch( CFileException ) { // Report the error if no one else did, otherwise clear it. if (Error::GetErrorNumber() != _R(IDN_USER_CANCELLED)) InformError(); else Error::ClearError(); // and fail return FALSE; } // Success. return TRUE; }
BOOL ScaleTab::CommitSection() { TRACEUSER( "Neville", _T("commit Scale section\n")); ERROR3IF(pPrefsDlg == NULL, "ScaleTab::CommitSection called with no dialog pointer"); BOOL ok = pPrefsDlg->TalkToPage(_R(IDD_OPTSTAB_SCALE)); // The Scale tab identifier if (!ok) return TRUE; // Talk to View failed to return now // Ok has been pressed so take the values from this section of the dialog box // Takes the values in the dialog and sets the DimScale object accordingly. BOOL Valid=TRUE; // Flag for validity of value // BOOL State=FALSE; // Flag for state of button/switch BOOL SetOk=TRUE; // Preference value set ok // Section = Scale settings // Now check that we have the selected view still, just in case it has switched // without us being told about it or even we have no current document/view. // This may be a valid state now, so do not complain about it. DocView* pCurrentView = DocView::GetSelected(); if (pCurrentView != NULL) { // Only if there is a current view do we read the values. String_256 DrawingStr; String_256 RealStr; //TCHAR* pDrawingStr = DrawingStr; //TCHAR* pRealStr = RealStr; BOOL Active; // Get the values from the dialog box Active = pPrefsDlg->GetLongGadgetValue(_R(IDC_OPTS_USESCALEFACTOR),0,1,0, &Valid); DrawingStr = pPrefsDlg->GetStringGadgetValue(_R(IDC_OPTS_DRAWINGSCALE), &Valid); RealStr = pPrefsDlg->GetStringGadgetValue(_R(IDC_OPTS_REALSCALE), &Valid); Spread* pSpread = pCurrentView->GetFirstSelectedSpread(); // If no selected spread then use the visible spread if (pSpread == NULL) pSpread = pCurrentView->GetVisibleSpread(); // Only do the chnage if we have a valid spread pointer and we have changed something. if ( (pSpread != NULL) && ( (OldActiveState != Active) || (OldDrawingStr != DrawingStr) || (OldRealStr != RealStr) ) ) { pDimScale = pSpread->GetPtrDimScale(); if (pDimScale != NULL) { // Only if active is set do we need to try and set new strings // and hence a new drawing scale if (Active) { // Dim Scales can only be 32 characters long String_32 DrawingStr32 = _T(""); String_32 RealStr32 = _T(""); // Check if read in strings are longer than this if (DrawingStr.Length() > DrawingStr32.MaxLength()) { InformError(_R(IDE_OPTS_INVALIDDRAWSCALE)); return FALSE; } if (RealStr.Length() > RealStr32.MaxLength()) { InformError(_R(IDE_OPTS_INVALIDREALSCALE)); return FALSE; } RealStr32 = RealStr; DrawingStr32 = DrawingStr; // Try and set these strings as new drawing and real scales strings SetOk = pDimScale->SetDrawingScaleStr(DrawingStr32); if (!SetOk) { InformError(_R(IDE_OPTS_INVALIDDRAWSCALE)); return FALSE; } SetOk = SetOk && pDimScale->SetRealScaleStr(RealStr32); if (!SetOk) { InformError(_R(IDE_OPTS_INVALIDREALSCALE)); return FALSE; } // Now try to convert these into a new scaling factor if (SetOk) SetOk = SetOk && pDimScale->SetScaleFactor(); // If we failed in any of the conversions then warn the user and fail if (!SetOk) { InformError(_R(IDE_OPTS_INVALIDSCALING)); return FALSE; } } // Set up a possibly new active state pDimScale->SetActiveState(Active); } // Now tell other users of units/scaling factors that there they are likely // to need to update any currently displayed units. Document *pCurrentDoc = (Document *)pSpread->FindOwnerDoc(); BROADCAST_TO_ALL(OptionsChangingMsg(pCurrentDoc, OptionsChangingMsg::NEWUNITS)); // unfortunately pScopeDoc is NULL!, and since pCurrentDoc is calulated I thought it ought to use! - Ed 17/10/95 // BROADCAST_TO_ALL(OptionsChangingMsg(pScopeDocument, OptionsChangingMsg::OptionsState::NEWUNITS)); // Make sure the document is marked as modified. pCurrentDoc->SetModified(TRUE); // And note the new states OldActiveState = Active; OldDrawingStr = DrawingStr; OldRealStr = RealStr; } } // else // ERROR2(FALSE,_R(IDE_OPTS_READPREF_SCALE)); return TRUE; }
BOOL CInformErrorDialog::OnInitDialog() { CDialog::OnInitDialog(); String_64 BoxTitle; BoxTitle = _R(IDS_ERROR_BOX_SERIOUS_ERROR); // "Serious error" String_256 VerySeriousError; VerySeriousError = _R(IDS_ERROR_BOX_VERY_SERIOUS_ERROR); // "A very serious error has occured - please consult your technical support." // Andy Hills, 22-11-00 // Store the help context. // We need to do this here, because the global help context variable // nNextMessageHelpContext may change before the user clicks the 'Help' // button. This fixes bug 6359. m_nHelpContext = Error::GetErrorNumber(); if (! m_nHelpContext) m_nHelpContext = GetNextMsgHelpContext(); // Find out how many buttons there are. for (INT32 NumButtons = ERRORDLG_MAXBUTTONS; NumButtons > 0; NumButtons--) { if (m_ButtonStr[NumButtons - 1] != 0) break; } // Adjust the OK and Cancel fields if necessary if (m_OK > (UINT32) NumButtons) { if (IsUserName("Tim")) { TRACE( _T("OK out of range, OK=%u, NumButtons=%d\n"), m_OK, NumButtons); } // Default to first button m_OK = 1; } if (m_Cancel > (UINT32) NumButtons) { if (IsUserName("Tim")) { TRACE( _T("Cancel out of range, Cancel=%u, NumButtons=%d\n"), m_Cancel, NumButtons); } // Default to be the same as OK (this means a box with a single OK box will // respond to Enter and Esc without the user having to specify a Cancel ID). m_Cancel = m_OK; } if (m_Help > (UINT32) NumButtons) { TRACEUSER( "JustinF", _T("Help button (%d) out of range (%d)\n"), (INT32) m_Help, (INT32) NumButtons); // The only really safe thing we can do is drop the help button. m_Help = 0; } // Make sure we have correct dialog information GetDialogInfo(); if (!ValidInfo) { // Serious error - fall back to to MessageBox(). goto SevereError; } // Get icon position IconPos = DefIconPos; // Get a DC for this dialog, so we can find out the size of text strings. // We'll also need to select in our font or else it'll base the width upon the // System font rather than the font we're using (MS Sans Serif at last check) CDC *pDC; CFont *OldFont; pDC = GetDC(); ENSURE(pDC != NULL, "Can't get DC for error box dialog"); // Check the DC if (pDC == NULL) goto SevereError; OldFont = pDC->SelectObject(GetFont()); // Set buttons text and move/resize buttons according to the number of them, // and their contents. BOOL Success; Success = SetupButtons(pDC->m_hDC, NumButtons); // Size the error message control, and put the message in it. Success = Success && SetupMessage(pDC->m_hDC); if (OldFont != NULL) pDC->SelectObject(OldFont); // We've finished with this DC now. ReleaseDC(pDC); // Check for failure in button/message setup. if (!Success) goto SevereError; // Play the appropriate sound and set the appropriate title bar text ID. UINT32 TitleID; TitleID = m_TitleStr; switch (m_ErrorBoxType) { case ERRORTYPE_NORMAL: // No sound for this one - it's just a message; nothing to shout about. if (TitleID == 0) TitleID = _R(IDS_ERRORBOX_NORMAL); break; case ERRORTYPE_QUESTION: MessageBeep(MB_ICONQUESTION); if (TitleID == 0) TitleID = _R(IDS_ERRORBOX_NORMAL); break; case ERRORTYPE_ERROR: MessageBeep(MB_ICONEXCLAMATION); if (TitleID == 0) TitleID = _R(IDS_ERRORBOX_ERROR); break; case ERRORTYPE_WARNING: MessageBeep(MB_ICONASTERISK); if (TitleID == 0) TitleID = _R(IDS_ERRORBOX_WARNING); break; case ERRORTYPE_SERIOUS: MessageBeep(MB_ICONHAND); if (TitleID == 0) TitleID = _R(IDS_ERRORBOX_SERIOUS); break; case ERRORTYPE_ENSURE: MessageBeep(MB_ICONHAND); if (TitleID == 0) TitleID = _R(IDS_ERRORBOX_ENSURE); break; default: ENSURE(FALSE, "Bad errortype in CInformErrorDialog::OnInitDialog()"); goto SevereError; break; } // Set the title bar text if necessary. if (TitleID != 0) { String_64 Title(TitleID); SetWindowText((TCHAR*) Title); } // Centre the dialog on the screen (Code stolen from splash.cpp) // Get the size of the screen INT32 ScreenWidth, ScreenHeight; ScreenWidth = GetSystemMetrics(SM_CXSCREEN); ScreenHeight = GetSystemMetrics(SM_CYSCREEN); // Get the size of the dialog box RECT DialogRect; GetWindowRect(&DialogRect); INT32 DialogWidth, DialogHeight; DialogWidth = DialogRect.right - DialogRect.left; DialogHeight = DialogRect.bottom - DialogRect.top; // Chicago M7 gives us crap values at this point if we are minimized so try and make them sane if (DialogWidth<=0) DialogWidth = ScreenWidth / 2; else if (DialogWidth > ScreenWidth) DialogWidth = ScreenWidth; if (DialogHeight<=0) DialogHeight = ScreenHeight / 2; else if (DialogHeight > ScreenHeight) DialogHeight = ScreenHeight; // Centre the dialog box and give it the 'top' style. INT32 Left, Top; Left = (ScreenWidth - DialogWidth) / 2; Top = (ScreenHeight - DialogHeight) / 2; SetWindowPos(&wndTop, Left, Top, DialogWidth, DialogHeight, SWP_SHOWWINDOW); // If we got this far, then we changed the keyboard focus, so return FALSE. return FALSE; SevereError: // Ooer - deeply catastrophic error...report to user and exit. String_256 Message; // First - check that this isn't just because of an empty error message. if (m_StaticTextStr == 0) { // Get the error message TCHAR *pMsg = Error::GetErrorString(); if ((pMsg == NULL) || (pMsg[0] == 0)) { // // There is no error message! // // In debug builds, give developer a chance to go into debugger to see who is not // setting an error message. #ifdef _DEBUG if (::MessageBox(ParentHwnd, "Somebody reported an error without an error message being set.\r" "Click OK to continue, or Cancel to go into debugger", "DEBUG Warning from Camelot", MB_OKCANCEL| MB_SYSTEMMODAL | MB_ICONHAND) == IDCANCEL) { // User wants to go into debugger DebugBreak(); } #endif // Tell the user a spurious error has occured, if (!Message.Load(_R(IDS_ERRORBOX_SPURIOUS))) // Can't load error message - panic. goto VerySevereError; // Try to get the string that says "Warning from Camelot" String_64 Title; if (!Title.Load(_R(IDS_ERRORBOX_WARNING))) goto VerySevereError; if (::MessageBox(ParentHwnd, (TCHAR *) Message, (TCHAR *) Title, MB_OK | MB_SYSTEMMODAL | MB_ICONHAND) == 0) // Could not create the message box - try our fallback one (probably won't // work but what the hell). goto VerySevereError; // Simulate user hitting default button. EndDialog((INT32) m_OK); return TRUE; // We haven't set the keyboard focus. } } // Inform the user that we've got a bit of a bad karma situation, and that the error // box might be not be completely accurate. if (!Message.Load(_R(IDS_ERRORBOX_SEVERE))) goto VerySevereError; if (::MessageBox(ParentHwnd, (TCHAR *) Message, (TCHAR *)BoxTitle, /*"Serious Error", */ MB_OK | MB_SYSTEMMODAL | MB_ICONHAND) == 0) // Could not create the message box - try our fallback one (probably won't // work but what the hell). goto VerySevereError; // Ok - try to report the error as best we can... // Work out what buttons to put on the dialog... // We use SYSTEMMODAL with ICONHAND because the SDK docs recommend this for low // memory/severe error situations. UINT32 MBFlags; MBFlags = MB_SYSTEMMODAL | MB_ICONHAND; // Do we need a cancel icon? if (m_Cancel != m_OK) MBFlags |= MB_OKCANCEL; else MBFlags |= MB_OK; if (m_StaticTextStr != 0) { if (Message.Load(m_StaticTextStr, m_OwnerModule)) { // Error message loaded ok - display it INT32 Result = ::MessageBox(ParentHwnd, (TCHAR *) Message, (TCHAR *)BoxTitle, MBFlags); if (Result == 0) // Could not create the message box - try our fallback one (probably won't // work but what the hell). goto VerySevereError; if (Result == IDCANCEL) { // Simulate user hitting cancel button. EndDialog((INT32) m_Cancel); } else { // Simulate user hitting default button. EndDialog((INT32) m_OK); } return TRUE; // We haven't set the keyboard focus. } else { // Can't load error message - bail out goto VerySevereError; } } else { // Get the error message TCHAR *pMsg = Error::GetErrorString(); if (pMsg == NULL) // No error message! goto VerySevereError; // Found error message ok - display it INT32 Result = ::MessageBox(ParentHwnd, pMsg, (TCHAR *)BoxTitle, MBFlags); if (Result == 0) // Could not create the message box - try our fallback one (probably won't // work but what the hell). goto VerySevereError; if (Result == IDCANCEL) { // Simulate user hitting cancel button. EndDialog((INT32) m_Cancel); } else { // Simulate user hitting default button. EndDialog((INT32) m_OK); } return TRUE; // We haven't set the keyboard focus. } VerySevereError: // Very bad - we can't even report the error - just let the user that something deeply // sad has happened, and pretend that the OK button was pressed. ::MessageBox(ParentHwnd, (TCHAR *)VerySeriousError, (TCHAR *)BoxTitle, MB_OK | MB_SYSTEMMODAL | MB_ICONHAND); // Simulate user hitting default button. EndDialog((INT32) m_OK); return TRUE; // We haven't set the keyboard focus. }
void PushTool::OnMouseMove(DocCoord dcPoint, Spread* pSpread, ClickModifiers mods) { #ifdef RALPH //Graham 20/9/96. //We need to check if the zoom tool's over a Hot Link. If it is, the cursor changes //to a pointing hand. //The one exception is if CTRL is pressed, in which case the cursor is the //normal Push tool cursor (Disabled at the moment) //First, try and find a node with a Hot Link AttrUser* pHotLinkNode= (AttrUser*) DocView::FindHotLinkNode(dcPoint); if (pHotLinkNode && !(mods.Constrain)) { //Yes. So change the cursor to a pointing hand ChangeCursor(Cursor::PointingHand); //And now to update the status bar of the browser //So first get a pointer to the document //And a pointer to the Ralph document... Document* ThisDoc=Document::GetSelected(); RalphDocument* ThisRalphDoc=ThisDoc->GetRalphDoc(); ERROR3IF(ThisRalphDoc==NULL, "DocView::OnMouseMoveWithNoTool has no Ralph Doc"); //Then get the base URL of this Ralph document as a Web Address WebAddress wBase(ThisRalphDoc->GetBaseURL()); //And get the URL of this node as a Web Address WebAddress wEmbedded(pHotLinkNode->GetWebAddress()); //This function makes wEmbedded into an absolute URL (if necessary) wEmbedded.Combine(wBase); //Make the Web Address into a normal string String_256 strEmbedded=wEmbedded.GetWebAddress(); //And put that URL into the status bar string String_256 sPushTool; sPushTool.MakeMsg(_R(IDS_PUSHTOOL_HOTLINK), (TCHAR*) strEmbedded); //And tell the Ralph document to show the string in the browser's status //bar ThisRalphDoc->SetStatusBar(&sPushTool); } else { //No, the cursor is not over a Hot Link or CTRL is pressed //Change the cursor to the standard Push tool cursor //and display a standard message in the browser status bar ChangeCursor(pcPushCursor); String_256 StringToPass(_R(IDS_RALPH_PUSHTOOLSTR)); DocView::SetBrowserStatusBar(&StringToPass); } #endif //RALPH #if !defined(EXCLUDE_FROM_RALPH) && !defined(EXCLUDE_FROM_XARALX) if (this!=NULL) { String_256 text(""); if (text.Load(_R(IDS_PUSHTOOL_STATUSHELP))) GetApplication()->UpdateStatusBarText(&text); } else ERROR3("PushTool::OnMouseMove() - this==NULL"); #endif }