コード例 #1
0
ファイル: sgscanf.cpp プロジェクト: vata/xarino
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;
}
コード例 #2
0
ファイル: opnudge.cpp プロジェクト: vata/xarino
/********************************************************************************************

>	void OpNudge::Do(OpDescriptor* pOpDesc)

	Author:		Mark_Neves (Xara Group Ltd) <*****@*****.**>
	Created:	7/9/94
	Inputs:		pOpDesc = ptr to the op descriptor
	Outputs:	-
	Returns:	-
	Purpose:	The nudge op's Do() function.
	Errors:		-
	SeeAlso:	-

********************************************************************************************/
void OpNudge::Do(OpDescriptor* pOpDesc)
{
// Determine the nudge factors based on the OpDescriptor used to invoke the nudge operation
    String OpToken = pOpDesc->Token;

//Get scaled pixel size
    FIXED16 ScaledPixelWidth, ScaledPixelHeight;
    GetWorkingView()->GetScaledPixelSize(&ScaledPixelWidth, &ScaledPixelHeight) ;
    PixelNudge=ScaledPixelWidth.MakeDouble() ;


    if		(OpToken == String(OPTOKEN_NUDGEUP1))				{
        X_NudgeFactor = 0;
        Y_NudgeFactor = 1;
        flag=TRUE;
    }
    else if (OpToken == String(OPTOKEN_NUDGEUP5))				{
        X_NudgeFactor = 0;
        Y_NudgeFactor = 5;
        flag=TRUE;
    }
    else if (OpToken == String(OPTOKEN_NUDGEUP10))				{
        X_NudgeFactor = 0;
        Y_NudgeFactor = 10;
        flag=TRUE;
    }
    else if (OpToken == String(OPTOKEN_NUDGEUPFIFTH))			{
        X_NudgeFactor = 0;
        Y_NudgeFactor = 0.2;
        flag=TRUE;
    }
    else if (OpToken == String(OPTOKEN_NUDGEDOWN1))				{
        X_NudgeFactor = 0;
        Y_NudgeFactor = -1;
        flag=TRUE;
    }
    else if (OpToken == String(OPTOKEN_NUDGEDOWN5))				{
        X_NudgeFactor = 0;
        Y_NudgeFactor = -5;
        flag=TRUE;
    }
    else if (OpToken == String(OPTOKEN_NUDGEDOWN10))			{
        X_NudgeFactor = 0;
        Y_NudgeFactor = -10;
        flag=TRUE;
    }
    else if (OpToken == String(OPTOKEN_NUDGEDOWNFIFTH))			{
        X_NudgeFactor = 0;
        Y_NudgeFactor = -0.2;
        flag=TRUE;
    }
    else if (OpToken == String(OPTOKEN_NUDGELEFT1))				{
        X_NudgeFactor = -1;
        Y_NudgeFactor = 0;
        flag=TRUE;
    }
    else if (OpToken == String(OPTOKEN_NUDGELEFT5))				{
        X_NudgeFactor = -5;
        Y_NudgeFactor = 0;
        flag=TRUE;
    }
    else if (OpToken == String(OPTOKEN_NUDGELEFT10))			{
        X_NudgeFactor = -10;
        Y_NudgeFactor = 0;
        flag=TRUE;
    }
    else if (OpToken == String(OPTOKEN_NUDGELEFTFIFTH))			{
        X_NudgeFactor = -0.2;
        Y_NudgeFactor = 0;
        flag=TRUE;
    }
    else if (OpToken == String(OPTOKEN_NUDGERIGHT1))			{
        X_NudgeFactor = 1;
        Y_NudgeFactor = 0;
        flag=TRUE;
    }
    else if (OpToken == String(OPTOKEN_NUDGERIGHT5))	 		{
        X_NudgeFactor = 5;
        Y_NudgeFactor = 0;
        flag=TRUE;
    }
    else if (OpToken == String(OPTOKEN_NUDGERIGHT10))			{
        X_NudgeFactor = 10;
        Y_NudgeFactor = 0;
        flag=TRUE;
    }
    else if (OpToken == String(OPTOKEN_NUDGERIGHTFIFTH))		{
        X_NudgeFactor = 0.2;
        Y_NudgeFactor = 0;
        flag=TRUE;
    }

    else if (OpToken == String(OPTOKEN_NUDGEUPPIXEL1)) 			{
        X_NudgeFactor = 0;
        Y_NudgeFactor = 1;
        flag=FALSE;
    }
    else if (OpToken == String(OPTOKEN_NUDGEUPPIXEL10))			{
        X_NudgeFactor = 0;
        Y_NudgeFactor = 10;
        flag=FALSE;
    }
    else if (OpToken == String(OPTOKEN_NUDGEDOWNPIXEL1))		{
        X_NudgeFactor = 0;
        Y_NudgeFactor = -1;
        flag=FALSE;
    }
    else if (OpToken == String(OPTOKEN_NUDGEDOWNPIXEL10))		{
        X_NudgeFactor = 0;
        Y_NudgeFactor = -10;
        flag=FALSE;
    }
    else if (OpToken == String(OPTOKEN_NUDGELEFTPIXEL1))		{
        X_NudgeFactor = -1;
        Y_NudgeFactor = 0;
        flag=FALSE;
    }
    else if (OpToken == String(OPTOKEN_NUDGELEFTPIXEL10))		{
        X_NudgeFactor = -10;
        Y_NudgeFactor =	0;
        flag=FALSE;
    }
    else if (OpToken == String(OPTOKEN_NUDGERIGHTPIXEL1))		{
        X_NudgeFactor = 1;
        Y_NudgeFactor = 0;
        flag=FALSE;
    }
    else if (OpToken == String(OPTOKEN_NUDGERIGHTPIXEL10))		{
        X_NudgeFactor = 10;
        Y_NudgeFactor = 0;
        flag=FALSE;
    }

    else
    {
        ERROR3("Unknown type of nudge");
    }



    Range* Selection = GetApplication()->FindSelection();
    RangeControl TransFlags = Selection->GetRangeControlFlags();
    TransFlags.IgnoreNoneRenderable=TRUE;
    TransFlags.IgnoreInvisibleLayers = TRUE;
    Selection->SetRangeControl(TransFlags);
    SliceHelper::ModifySelectionToContainWholeButtonElements();



// Setup the Offset DocCoord to contain the X and Y translation values
    DocCoord Offset;

    if	(flag)
    {
        (Offset.x) = (INT32) GetXNudgeDisplacement();
        (Offset.y) = (INT32) GetYNudgeDisplacement();
    }
    else if	(!flag)
    {
        (Offset.x) = (INT32)GetXPixelDisplacement();
        (Offset.y) = (INT32)GetYPixelDisplacement();
    }

    // Will the nudge send the selection beyond the spread bounds?
    // If so, fail and return now
    if (!IsNudgeOK(Offset.x,Offset.y))
    {
        SliceHelper::RestoreSelection();
        InformWarning(_R(IDS_NUDGE_OUTOFBOUNDS));
        FailAndExecute();
        End();
        return;
    }

    TransformData 	TransData;

    // Set up the transform data
    TransData.CentreOfTrans.x 	= 0;
    TransData.CentreOfTrans.y 	= 0;
    TransData.StartBlob 	  	= 0;
    TransData.LockAspect 		= TRUE;
    TransData.LeaveCopy  		= FALSE;
    TransData.ScaleLines 		= FALSE;
    TransData.TransFills 		= TRUE;
    TransData.pRange = 0;

    // Call OpTranslateTrans::DoWithParams() with a ptr to the transform data and a ptr to a DocCoord
    // that specs the X and Y offsets of the translation
    OpParam param( &TransData, &Offset );
    DoWithParam( pOpDesc, &param );

    SliceHelper::RestoreSelection();
}
コード例 #3
0
ファイル: sgscanf.cpp プロジェクト: vata/xarino
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;
}
コード例 #4
0
ファイル: tooldlg.cpp プロジェクト: Amadiro/xara-cairo
MsgResult ToolbarDlg::Message(Msg* Message)
{
	if (IS_OUR_DIALOG_MSG(Message))
	{
		DialogMsg* Msg = (DialogMsg*)Message;
		BOOL EndDialog = FALSE;

		switch (Msg->DlgMsg)
		{
			case DIM_CANCEL:
			case DIM_COMMIT:
 				// Cancel all changes the user wants to make to toolbars...
 				EndDialog = TRUE;
 			break;
	
 		 	case DIM_SELECTION_CHANGED:
 		 	case DIM_SELECTION_CHANGED_COMMIT:
				TakeToolbarDetails();
				break;
	
			case DIM_LFT_BN_CLICKED:
			{	// A control in the Toolbars... dialog has been clicked...
			 	CMainFrame* pFrame = GetMainFrame();
				BOOL	check;
				BOOL	VV;
				switch (Msg->GadgetID)
				{
					case _R(IDC_BIGALL):
						// Select all the large buttons...
						SetLongGadgetValue(_R(IDC_BIGTOP),1);
						SetLongGadgetValue(_R(IDC_BIGLEFT),1);
						SetLongGadgetValue(_R(IDC_BIGRIGHT),1);
						SetLongGadgetValue(_R(IDC_BIGBOTTOM),1);
						SetLongGadgetValue(_R(IDC_BIGFLOAT),1);
						TakeToolbarDetails();
					break;

					case _R(IDC_BIGNONE):
						// Deselect all the large buttons...
						SetLongGadgetValue(_R(IDC_BIGTOP),0);
						SetLongGadgetValue(_R(IDC_BIGLEFT),0);
						SetLongGadgetValue(_R(IDC_BIGRIGHT),0);
						SetLongGadgetValue(_R(IDC_BIGBOTTOM),0);
						SetLongGadgetValue(_R(IDC_BIGFLOAT),0);
						TakeToolbarDetails();
					break;

					case _R(IDC_NEWBAR):
						NewToolbar();
						break;

					case _R(IDC_BIGTOP):
						check = (BOOL)GetLongGadgetValue(_R(IDC_BIGTOP),0,1,_R(IDS_PHILS_EXAMPLE),&VV);
						pFrame->GetDockBar(DOCKBAR_TOP)->SetBigControlState(check);
						break;
					case _R(IDC_BIGLEFT):
						check = (BOOL)GetLongGadgetValue(_R(IDC_BIGLEFT),0,1,_R(IDS_PHILS_EXAMPLE),&VV);
						pFrame->GetDockBar(DOCKBAR_LEFT)->SetBigControlState(check);
						break;
					case _R(IDC_BIGRIGHT):
						check = (BOOL)GetLongGadgetValue(_R(IDC_BIGRIGHT),0,1,_R(IDS_PHILS_EXAMPLE),&VV);
						pFrame->GetDockBar(DOCKBAR_RIGHT)->SetBigControlState(check);
						break;
					case _R(IDC_BIGBOTTOM):
						check = (BOOL)GetLongGadgetValue(_R(IDC_BIGBOTTOM),0,1,_R(IDS_PHILS_EXAMPLE),&VV);
						pFrame->GetDockBar(DOCKBAR_BOTTOM)->SetBigControlState(check);
						break;
					case _R(IDC_BIGFLOAT):	
						check = (BOOL)GetLongGadgetValue(_R(IDC_BIGFLOAT),0,1,_R(IDS_PHILS_EXAMPLE),&VV);
						pFrame->GetDockBar(DOCKBAR_FLOAT)->SetBigControlState(check);
						break;
					
				
					case _R(IDC_DELETEBAR):		
					{	
						String_32 BarName;
						GetSelectedBarName(&BarName);

						if (BarName != String_8(TEXT("")))
						{
		 					// we can't delete the infoobar
							if(BarName == String_32(TEXT("Infobar")))
							{
								InformWarning(_R(IDS_CANTDELETEINFOBAR),_R(IDS_OK));
								break;
							}

							INT32 ButtonPressed = 1;
							ButtonPressed = InformWarning(_R(IDS_WARNDELETEBAR), _R(IDS_OK),_R(IDS_CANCEL));
							Error::ClearError();
							if (ButtonPressed ==  1)
								DeleteSelectedBar();
						}
						break;	
					}

					case _R(IDC_RESETBARS):		
					{	
						INT32 ButtonPressed = 1;						
						ButtonPressed = InformWarning(_R(IDS_WARNRESETBARS), _R(IDS_OK),_R(IDS_CANCEL));
						Error::ClearError();

						if(ButtonPressed ==  1)
						{
					  		Progress::Start(FALSE);
							// lock the window to avoid untidy layout recalcs
							::LockWindowUpdate(GetMainFrame()->GetSafeHwnd());

							// tell the mainframe we are changing modes - this prevents
							// some unnecessary work
							GetMainFrame()->SetChangingMode(TRUE);

							// kill all bars ( except infobar at the mo..)
							BROADCAST_TO_CLASS(DialogMsg(NULL, DIM_BAR_DEATH, NULL ),DialogBarOp);
							// hide the info bar
							InformationBarOp::SetVisibility(FALSE,TRUE);

							DialogBarOp::WipeBarFiles();

							DialogBarOp::LoadDefaultBars();
							
							// force the info bar to the correct visible state
							InformationBarOp::SetVisibility(InformationBarOp::IsVisible(),TRUE);
							// All clear to Mainframe
							GetMainFrame()->SetChangingMode(FALSE);

							// Make sure everything is positioned correctly
							GetMainFrame()->RecalcLayout();

							// Now handle the toolbar ....
							GetMainFrame ()->SetToolbarCreated (TRUE);
							GetMainFrame ()->RelocateToolbar ();

							// and unlock and show the window
							::LockWindowUpdate(NULL);
							ShowToolbarList();
							ShowToolbarSizes();
							Progress::Stop();
						}
						break;			
					}
				}
				break;
			}
		}

		if (EndDialog)	// Dialog communication over
		{

			Close();	// Close the dialog
			End();		// Destroy dialog
			return(OK);	// After destroying this object, it's very dangerous to call base class!
	   	}
	}
	else if ( MESSAGE_IS_A(Message,BarMsg) )
	{
		switch ( ((BarMsg*)Message)->Reason )
		{
			case BAR_CHANGESTATE:
				// A bar simply became horizontal, vertical or floating and we don't care
				// about that so do nothing.
				break;

			default:
				// In most cases of BarMsg we want to show the user what happened...
				ShowToolbarList();		// Show changes in bars to user
										// Note: it would be more optimal to use the pointer
										// to the bar that comes with this message to just
										// alter that item in the list.
				break;
		}
	}

	return DialogOp::Message(Message);
}