[Date Prev][Date Next][Thread Prev][Thread Next][Thread Index]

[XaraXtreme-commits] Commit Complete



Commit by  : alex
Repository : xara
Revision   : 831
Date       : Mon Apr 17 20:02:15 BST 2006

Changed paths:
   M /Trunk/XaraLX/Kernel/bars.cpp
   M /Trunk/XaraLX/Kernel/bars.h
   M /Trunk/XaraLX/Kernel/dialogop.cpp
   M /Trunk/XaraLX/Kernel/dialogop.h
   M /Trunk/XaraLX/Kernel/layergal.cpp
   M /Trunk/XaraLX/Kernel/sgallery.cpp
   M /Trunk/XaraLX/Kernel/sgallery.h
   M /Trunk/XaraLX/Kernel/sglayer.cpp
   M /Trunk/XaraLX/Kernel/sgtree.cpp

Made SuperGallery derive directly from DialogOp (rather than DialogBarOp). This appears to sort out lots of memory leak problems, bad dialog closing etc.


Diff:
Index: Trunk/XaraLX/Kernel/bars.h
===================================================================
--- Trunk/XaraLX/Kernel/bars.h	(revision 830)
+++ Trunk/XaraLX/Kernel/bars.h	(revision 831)
@@ -668,9 +668,6 @@
 	virtual BOOL	Read(LoadRegistryEntries& Loader);
 	virtual BOOL	Write(SaveRegistryEntries& Saver);
 
-	BOOL			IsVisible();
-	virtual void	SetVisibility(BOOL Open);
-
 	DockBarType		GetDockBarType() 						{ return Dock; }
 	void			SetDockBarType(DockBarType DockValue) 	{ Dock = DockValue; }
 	UINT32			GetSlot() 								{ return Slot; }
Index: Trunk/XaraLX/Kernel/bars.cpp
===================================================================
--- Trunk/XaraLX/Kernel/bars.cpp	(revision 830)
+++ Trunk/XaraLX/Kernel/bars.cpp	(revision 831)
@@ -1318,6 +1318,8 @@
 BOOL SuperGallery::Write(CCLexFile& file)
 {
 	BOOL ok = TRUE;
+#ifndef EXCLUDE_FROM_XARALX
+PORTNOTE("galleries", "Disable Lexfile writing")
 	String_256 str;
 	if (ok) ok = file.PutToken(TokenTable[TOKEN_GALLERY].Token);
 	
@@ -1350,7 +1352,7 @@
 
 	if (ok) ok = file.PutNewLine();
 	if (ok) ok = file.PutNewLine();
-
+#endif
 	return ok;
 }
 
@@ -5668,59 +5670,6 @@
 
 /********************************************************************************************
 
->	BOOL DialogBarOp::IsVisible()
-
-	Author:		Mark_Neves (Xara Group Ltd) <camelotdev@xxxxxxxx>
-	Created:	29/4/94
-	Inputs:		-
-	Outputs:	-
-	Returns:	TRUE if this DialogBarOp is on screen
-	Purpose:	Used by the tool bar customize system to find out if a tool bar is
-				visible or not. 
-	Errors:		-
-	SeeAlso:	-
-
-********************************************************************************************/
-
-BOOL DialogBarOp::IsVisible()
-{
-	return (WindowID != NULL);
-}
-
-/********************************************************************************************
-
->	virtual void DialogBarOp::SetVisibility(BOOL Open)
-
-	Author:		Mark_Neves (Xara Group Ltd) <camelotdev@xxxxxxxx>
-	Created:	29/4/94
-	Inputs:		Open - 	if TRUE then open DialogBarOp in its last pos if it is
-						currently closed.
-						if FALSE, it is closed
-	Outputs:	-
-	Returns:	-
-	Purpose:	Used by the tool bar customize system to open and close a tool bar.
-	Errors:		-
-	SeeAlso:	-
-
-********************************************************************************************/
-
-void DialogBarOp::SetVisibility(BOOL Open)
-{
-	if (Open)
-	{
-		if (!IsVisible())
-			Create();
-			DialogOp::Open();
-	}
-	else
-	{
-		if (IsVisible())
-			Delete();
-	}
-}
-
-/********************************************************************************************
-
 >	BOOL DialogBarOp::AllowMulSelInListBox()
 
 	Author:		Mark_Neves (Xara Group Ltd) <camelotdev@xxxxxxxx>
Index: Trunk/XaraLX/Kernel/sgallery.cpp
===================================================================
--- Trunk/XaraLX/Kernel/sgallery.cpp	(revision 830)
+++ Trunk/XaraLX/Kernel/sgallery.cpp	(revision 831)
@@ -133,7 +133,7 @@
 #include "brushmsg.h"   // for the screen change message
 
 // Implement the dynamic class bits...
-CC_IMPLEMENT_DYNCREATE(SuperGallery, DialogBarOp)
+CC_IMPLEMENT_DYNCREATE(SuperGallery, DialogOp)
 CC_IMPLEMENT_DYNCREATE(SGalleryOptionsDlg, DialogOp)
 CC_IMPLEMENT_DYNCREATE(SGallerySortDlg, DialogOp)
 CC_IMPLEMENT_DYNCREATE(SGallerySearchDlg, DialogOp)
@@ -217,7 +217,7 @@
 
 /********************************************************************************************
 
->	SuperGallery::SuperGallery(CCRuntimeClass *Class = CC_RUNTIME_CLASS(DialogBarOp)): DialogBarOp(Class) 
+>	SuperGallery::SuperGallery(CCRuntimeClass *Class = CC_RUNTIME_CLASS(DialogOp)): DialogOp(_R(IDD_BLANKBAR), MODELESS,0,SAFECLASS(Class))
 												 
 	Author:		Jason_Williams (Xara Group Ltd) <camelotdev@xxxxxxxx>
 	Created:	21/10/94
@@ -225,9 +225,10 @@
 
 ********************************************************************************************/
 
-SuperGallery::SuperGallery(CCRuntimeClass *Class): DialogBarOp(Class) 
+SuperGallery::SuperGallery(CCRuntimeClass *Class): DialogOp(_R(IDD_BLANKBAR), MODELESS,0,SAFECLASS(Class)) 
 {
-	DlgResID = _R(IDD_LAYERSGALLERY);
+	String_32 str = String_32(_R(IDS_K_BARS_NONAME));
+	Name=str;
 	InitData();
 } 
 
@@ -235,8 +236,8 @@
 
 /********************************************************************************************
 
->	SuperGallery::SuperGallery(String_32 &NewName,CCRuntimeClass *Class = CC_RUNTIME_CLASS(DialogBarOp): 
-	DialogBarOp(NewName, Class) 
+>	SuperGallery::SuperGallery(String_32 &NewName,CCRuntimeClass *Class = CC_RUNTIME_CLASS(DialogOp): 
+	DialogOp(NewName, Class) 
 
 	Author:		Jason_Williams (Xara Group Ltd) <camelotdev@xxxxxxxx>
 	Created:	21/10/94
@@ -245,8 +246,10 @@
 ********************************************************************************************/
 
 SuperGallery::SuperGallery(String_32 &NewName,CCRuntimeClass *Class)
-		: DialogBarOp(NewName, Class) 
+		: DialogOp(_R(IDD_BLANKBAR), MODELESS,0,SAFECLASS(Class))
 {
+	String_32 str = String_32(_R(IDS_K_BARS_NONAME));
+	Name=str;
 	InitData();
 } 
 
@@ -402,7 +405,7 @@
 	if ( Message->IsKindOf(CC_RUNTIME_CLASS(DialogMsg)) &&
 			((DialogMsg*)Message)->DlgMsg == DIM_BAR_DEATH )
 	{
-		DialogBarOp::Message(Message);
+		DialogOp::Message(Message);
 		return(OK);
 	}
 
@@ -673,7 +676,7 @@
 	}
 	
 	// Pass the call down to the base class
-	return(DialogBarOp::Message(Message));
+	return(DialogOp::Message(Message));
 
 	return OK;
 }    
@@ -689,7 +692,7 @@
 	Returns:	TRUE if the window was successfully created
 				FALSE => ERROR2
 	Purpose:	The SuperGallery Create method
-				This method has been overridden to de-specialize the DialogBarOp. 
+				This method has been overridden to de-specialize the DialogOp. 
 
 	Notes:		Before doing anything else, the PreCreate handler is called.
 				Secondly, the InitMenuCommands() method is called to init any
@@ -719,11 +722,14 @@
 	// Ensure any items pending background-redraws are 'flushed'
 	FlushBackgroundRedraws();
 
+#ifndef EXCLUDE_FROM_XARALX
+PORTNOTE("galleries", "Removed docking stuff")
 	// Bar initialisation and creation
 	SetDockBarType(Dock);
 	SetSlot(Slot);
 	SetOffset(Offset);
 	SetFloatingCPoint(FloatPos);
+#endif
 
 //	if (!DialogOp::Create())
 //		return(FALSE);
@@ -770,7 +776,7 @@
 	}	
 
 	// Now call the base class to show/hide ourselves
-	DialogBarOp::SetVisibility(Open);
+	DialogOp::SetVisibility(Open);
 }
 
 
@@ -3531,12 +3537,54 @@
 }
 
 
+/********************************************************************************************
 
+>	static SuperGallery* SuperGallery::FindSuperGallery(String_32& SuperGalleryName, INT32 limit = -1)
 
+	Author:		Mark_Neves (Xara Group Ltd) <camelotdev@xxxxxxxx>
+	Created:	26/4/94
+	Inputs:		SuperGalleryName = Name of op to find
+				limit	if -1 then it means use the whole name for the check (default)
+						if > 0 then limit the check to the limit number of characters
+	Outputs:	-
+	Returns:	ptr to SuperGallery
+				NULL is returned if not found
+	Purpose:	Looks for a given SuperGallery by using its name 
+	Errors:		-
+	SeeAlso:	-
 
+********************************************************************************************/
 
+SuperGallery* SuperGallery::FindSuperGallery(String_32& SuperGalleryName, INT32 limit)
+{
+	List*       	pList = MessageHandler::GetClassList(CC_RUNTIME_CLASS(DialogOp));
+	SuperGallery*	pSuperGallery = (SuperGallery*)pList->GetHead();
+	
+	String_32		OpName;
+	while (pSuperGallery != NULL)
+	{
+		if (pSuperGallery->IsKindOf(CC_RUNTIME_CLASS(SuperGallery)))
+		{
+			if (limit > 0)
+				pSuperGallery->Name.Left(&OpName, limit);
+			else
+				OpName = pSuperGallery->Name;
+			
+			if (OpName == SuperGalleryName)
+				return (pSuperGallery);
+		}
 
+		pSuperGallery = (SuperGallery*)pList->GetNext(pSuperGallery);
+	}
 
+	return NULL;
+}
+
+
+
+
+
+
 const CDlgMode SGalleryOptionsDlg::Mode = MODELESS; // Mode of the dialog  
 
 const UINT32 SGalleryOptionsDlg::IDD = _R(IDD_SGDISPLAY);
Index: Trunk/XaraLX/Kernel/sglayer.cpp
===================================================================
--- Trunk/XaraLX/Kernel/sglayer.cpp	(revision 830)
+++ Trunk/XaraLX/Kernel/sglayer.cpp	(revision 831)
@@ -1290,6 +1290,7 @@
 LayerSGallery::LayerSGallery()
 {
 #ifndef EXCLUDE_GALS
+	DlgResID = _R(IDD_LAYERSGALLERY);
 	pSpread = NULL;
 	pDoc = NULL;
 	DisplayForeground = NULL;	// Group of foreground layers
Index: Trunk/XaraLX/Kernel/sgtree.cpp
===================================================================
--- Trunk/XaraLX/Kernel/sgtree.cpp	(revision 830)
+++ Trunk/XaraLX/Kernel/sgtree.cpp	(revision 831)
@@ -2758,7 +2758,7 @@
 				// auto closes the gallery (just like RISC OS and Win95)
 				ParentGallery->SetVisibility(FALSE);
 
-				ParentGallery->SetSystemStateChanged();	// Ensure toolbar button pops out again
+				DialogBarOp::SetSystemStateChanged();	// Ensure toolbar button pops out again
 			}
 		}
 PORTNOTE("galleries", "Disabled clipart gallery")
Index: Trunk/XaraLX/Kernel/dialogop.cpp
===================================================================
--- Trunk/XaraLX/Kernel/dialogop.cpp	(revision 830)
+++ Trunk/XaraLX/Kernel/dialogop.cpp	(revision 831)
@@ -2859,8 +2859,97 @@
 	return ReadWritePage;
 }
 
+/********************************************************************************************
 
+>	static DialogOp* DialogOp::FindDialogOp(CDlgResID ResID)
 
+	Author:		Alex Bligh <alex@xxxxxxxxxxx>
+	Created:	17/4/2006
+	Inputs:		ResID - The resource ID of the dialog to find
+	Outputs:	-
+	Returns:	ptr to DialogOp
+				NULL is returned if not found
+	Purpose:	Looks for a given DialogOp by using its ResourceID
+	Errors:		-
+	SeeAlso:	-
+
+********************************************************************************************/
+
+DialogOp* DialogOp::FindDialogOp(CDlgResID ResID)
+{
+	List*		pList = MessageHandler::GetClassList(CC_RUNTIME_CLASS(DialogOp));
+	DialogOp*	pDialogOp = (DialogOp*)pList->GetHead();
+	
+	while (pDialogOp != NULL)
+	{
+		if (pDialogOp->DlgResID == ResID)
+			return (pDialogOp);
+
+		pDialogOp = (DialogOp*)pList->GetNext(pDialogOp);
+	}
+
+	return NULL;
+}
+
+/********************************************************************************************
+
+>	BOOL DialogOp::IsVisible()
+
+	Author:		Mark_Neves (Xara Group Ltd) <camelotdev@xxxxxxxx>
+	Created:	29/4/94
+	Inputs:		-
+	Outputs:	-
+	Returns:	TRUE if this DialogOp is on screen
+	Purpose:	Used by the tool bar customize system to find out if a tool bar is
+				visible or not. 
+	Errors:		-
+	SeeAlso:	-
+
+This function is a hangover from old bar days. You probably don't want to use it.
+Use Show() etc. which are orthogonal to this. This merely tells you whether there
+is a window ID there... FOR COMPATIBILITY ONLY
+
+********************************************************************************************/
+
+BOOL DialogOp::IsVisible()
+{
+	return (WindowID != NULL);
+}
+
+/********************************************************************************************
+
+>	virtual void DialogOp::SetVisibility(BOOL Visible)
+
+	Author:		Mark_Neves (Xara Group Ltd) <camelotdev@xxxxxxxx>
+	Created:	29/4/94
+	Inputs:		Open - 	if TRUE then open DialogOp in its last pos if it is
+						currently closed.
+						if FALSE, it is closed
+	Outputs:	-
+	Returns:	-
+	Purpose:	Used by the tool bar customize system to open and close a tool bar.
+	Errors:		-
+	SeeAlso:	-
+
+********************************************************************************************/
+
+void DialogOp::SetVisibility(BOOL Visible)
+{
+	if (Visible)
+	{
+		if (!WindowID)
+		{
+			Create();
+		}
+		Open();
+	}
+	else
+	{
+		Close();
+	}
+}
+
+
 // -----------------------------------------------------------------------------------------
 // DialogTabOp functions 
  
Index: Trunk/XaraLX/Kernel/sgallery.h
===================================================================
--- Trunk/XaraLX/Kernel/sgallery.h	(revision 830)
+++ Trunk/XaraLX/Kernel/sgallery.h	(revision 831)
@@ -216,7 +216,7 @@
 
 /***********************************************************************************************
 
->	class SuperGallery : public DialogBarOp
+>	class SuperGallery : public DialogOp
 
 	Author:		Jason_Williams (Xara Group Ltd) <camelotdev@xxxxxxxx>
 	Created:	19/10/94
@@ -239,7 +239,7 @@
 class SGallerySortDlg;				// Defined below
 class SGalleryLinePropertiesDlg;	// Defined in sglinepr.h
 
-class SuperGallery : public DialogBarOp
+class SuperGallery : public DialogOp
 {
 friend class SGalleryOptionsDlg;
 friend class SGallerySortDlg;
@@ -640,6 +640,12 @@
 public:
 	virtual BOOL IsABar() {return FALSE; } 		// We are not a bar
 	virtual BOOL IsAGallery() {return TRUE; }	// We are a gallery
+	static SuperGallery*		FindSuperGallery(String_32& SuperGalleryName, INT32 limit = -1);
+
+	String_32		Name;
+	String_32&		GetName()								{ return Name; }
+	void			SetName(String_32& str)					{ Name = str; }
+
 };
 
 
Index: Trunk/XaraLX/Kernel/layergal.cpp
===================================================================
--- Trunk/XaraLX/Kernel/layergal.cpp	(revision 830)
+++ Trunk/XaraLX/Kernel/layergal.cpp	(revision 831)
@@ -1832,12 +1832,12 @@
 	{
 		// If the gallery is currenty open, then the menu item should be ticked
 		String_32 Name(_R(IDS_LAYERGAL_GALLNAME));
-		DialogBarOp* pDialogBarOp = DialogBarOp::FindDialogBarOp(Name);
+		SuperGallery* pSuperGallery = SuperGallery::FindSuperGallery(Name);
 
-		if (pDialogBarOp != NULL)
+		if (pSuperGallery != NULL)
 		{
-			if (pDialogBarOp->GetRuntimeClass() == CC_RUNTIME_CLASS(LayerSGallery))
-			OpSt.Ticked = pDialogBarOp->IsVisible();
+			if (pSuperGallery->GetRuntimeClass() == CC_RUNTIME_CLASS(LayerSGallery))
+			OpSt.Ticked = pSuperGallery->IsVisible();
 		}
 
 		// If there are no open documents, you can't toggle the gallery
@@ -1872,26 +1872,26 @@
 void OpDisplayLayerGallery::Do(OpDescriptor*)
 {
 	String_32 Name(_R(IDS_LAYERGAL_GALLNAME));
-	DialogBarOp* pDialogBarOp = DialogBarOp::FindDialogBarOp(Name);
+	SuperGallery* pSuperGallery = SuperGallery::FindSuperGallery(Name);
 
-	if (!pDialogBarOp) pDialogBarOp = new LayerSGallery;
+	if (!pSuperGallery) pSuperGallery = new LayerSGallery;
 
-	if (pDialogBarOp != NULL)
+	if (pSuperGallery != NULL)
 	{
-		if (pDialogBarOp->GetRuntimeClass() == CC_RUNTIME_CLASS(LayerSGallery))
+		if (pSuperGallery->GetRuntimeClass() == CC_RUNTIME_CLASS(LayerSGallery))
 		{
 			// Toggle the visible state of the gallery window
-			pDialogBarOp->SetVisibility( !pDialogBarOp->IsVisible() );
+			pSuperGallery->SetVisibility( !pSuperGallery->IsVisible() );
 		}
 		else
 		{
 			ERROR3("Got the layer gallery but it's not of the LayerSGallery class");
 		}
 
-		SGInit::UpdateGalleryButton(_R(OPTOKEN_DISPLAYLAYERGALLERY), pDialogBarOp->IsVisible());
+		SGInit::UpdateGalleryButton(_R(OPTOKEN_DISPLAYLAYERGALLERY), pSuperGallery->IsVisible());
 	}
 
-	ERROR3IF(pDialogBarOp == NULL,"Couldn't find the layer gallery bar");
+	ERROR3IF(pSuperGallery == NULL,"Couldn't find the layer gallery bar");
 
 	End();
 }
@@ -1962,12 +1962,12 @@
 		
 	// If the gallery is currenty open, then the menu item should be ticked
 	String_32 Name(_R(IDS_FRAMEGAL_GALLNAME));
-	DialogBarOp* pDialogBarOp = DialogBarOp::FindDialogBarOp(Name);
+	SuperGallery* pSuperGallery = SuperGallery::FindSuperGallery(Name);
 
-	if (pDialogBarOp != NULL)
+	if (pSuperGallery != NULL)
 	{
-		if (pDialogBarOp->GetRuntimeClass() == CC_RUNTIME_CLASS(FrameSGallery))
-			OpSt.Ticked = pDialogBarOp->IsVisible();
+		if (pSuperGallery->GetRuntimeClass() == CC_RUNTIME_CLASS(FrameSGallery))
+			OpSt.Ticked = pSuperGallery->IsVisible();
 	}
 
 	// If there are no open documents, you can't toggle the gallery
@@ -1997,12 +1997,12 @@
 	{
 		// If the gallery is currenty open, then the menu item should be ticked
 		String_32 Name(_R(IDS_FRAMEGAL_GALLNAME));
-		DialogBarOp* pDialogBarOp = DialogBarOp::FindDialogBarOp(Name);
+		SuperGallery* pSuperGallery = SuperGallery::FindSuperGallery(Name);
 
-		if (pDialogBarOp != NULL)
+		if (pSuperGallery != NULL)
 		{
-			if (pDialogBarOp->GetRuntimeClass() == CC_RUNTIME_CLASS(FrameSGallery))
-				OpSt.Ticked = pDialogBarOp->IsVisible();
+			if (pSuperGallery->GetRuntimeClass() == CC_RUNTIME_CLASS(FrameSGallery))
+				OpSt.Ticked = pSuperGallery->IsVisible();
 		}
 
 		// If there are no open documents, you can't toggle the gallery
@@ -2041,28 +2041,28 @@
 void OpDisplayFrameGallery::Do(OpDescriptor*)
 {
 	String_32 Name(_R(IDS_FRAMEGAL_GALLNAME));
-	DialogBarOp* pDialogBarOp = DialogBarOp::FindDialogBarOp(Name);
+	SuperGallery* pSuperGallery = SuperGallery::FindSuperGallery(Name);
 
-	if (pDialogBarOp != NULL)
+	if (pSuperGallery != NULL)
 	{
-		if (pDialogBarOp->GetRuntimeClass() == CC_RUNTIME_CLASS(FrameSGallery))
+		if (pSuperGallery->GetRuntimeClass() == CC_RUNTIME_CLASS(FrameSGallery))
 		{
 			GIFAnimationPropertyTabs::SetFrameGalleryOpen(FALSE);
 
 			// Toggle the visible state of the gallery window
-			pDialogBarOp->SetVisibility( !pDialogBarOp->IsVisible() );
+			pSuperGallery->SetVisibility( !pSuperGallery->IsVisible() );
 		}
 		else
 		{
 			ERROR3("Got the frame gallery but it's not of the LayerSGallery class");
 		}
 
-		SGInit::UpdateGalleryButton(_R(OPTOKEN_DISPLAYFRAMEGALLERY), pDialogBarOp->IsVisible());
+		SGInit::UpdateGalleryButton(_R(OPTOKEN_DISPLAYFRAMEGALLERY), pSuperGallery->IsVisible());
 
 		GIFAnimationPropertyTabs::SetFrameGalleryOpen(TRUE);
 	}
 
-	ERROR3IF(pDialogBarOp == NULL,"Couldn't find the frame gallery bar");
+	ERROR3IF(pSuperGallery == NULL,"Couldn't find the frame gallery bar");
 
 	End();
 }
Index: Trunk/XaraLX/Kernel/dialogop.h
===================================================================
--- Trunk/XaraLX/Kernel/dialogop.h	(revision 830)
+++ Trunk/XaraLX/Kernel/dialogop.h	(revision 831)
@@ -506,6 +506,11 @@
 	INT32 GetScreenDpi();
 	BOOL GetScreenSize(INT32 * pWidth, INT32 * pHeight);
 
+	static DialogOp*	FindDialogOp(CDlgResID ResID);
+
+	BOOL			IsVisible();
+	virtual void	SetVisibility(BOOL Visible);
+
 protected:
 	// Need to subclass your dialog controls? Override this to do so
 	virtual BOOL AddControlsToHelper();


Xara