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

RE: [XaraXtreme-dev] Re: MDI style



I have made some changes to the CCamView class so that it calls SetFrame
rather than keeping its own member variable (and got rid of
GetParentFrame()).  This still seems to run perfectly happily on linux
so could one of you with a Mac apply this patch to your local copy and
see if it improves things...?

Cheers,
  Gerry

-----Original Message-----
From: owner-dev@xxxxxxxxxxxxxxxx [mailto:owner-dev@xxxxxxxxxxxxxxxx] On
Behalf Of Ben Fowler
Sent: 01 September 2006 12:16
To: dev@xxxxxxxxxxxxxx
Subject: [XaraXtreme-dev] Re: MDI style

On 01/09/06, Gerry Iles <GerryI@xxxxxxxx> wrote:
> It looks to me like we are not actually handling the wxView/frame
> connection as wx intends.
>
> CCamView::OnCreate is creating a frame with
wxGetApp().CreateChildFrame(
> pDoc, this ) but storing the pointer in its own member variable rather
> than in the wxView baseclass member (presumably via wxView::SetFrame).
> Why it works better in wxGTK than in wxMac is presumably down to the
> underlying implementation but "fixing" this may get it working well
> enough for now...

I agree on all counts.

I am not quite sure what is the simplest fix at this stage - I would
be tempted to eliminate the "own member variable" (or carefully
document what is going on), and use the SetFrame/GetFrame mechanism.
Indeed depending on what the "frame" constructor does, we might not
even need to call SetFrame(); however, it would be unwise to take all
this action for the sake of one platform.

Ben

> From: owner-dev@xxxxxxxxxxxxxxxx [mailto:owner-dev@xxxxxxxxxxxxxxxx]
On
> On 01/09/06, Phil Martin <phil@xxxxxxxx> wrote:
> > Phil Martin wrote:
> > Did I say "MFC-style"? I meant "MDI-style".
> >
> > In the long run we probably don't really want XaraLX to have
MDI-style
> > windows on the Mac because that's not the Mac way of doing things.
So
> > the question is, should we persist with trying to get the MDI-style
> > working for now, so that we can make other parts of the program more
> > stable or should we change to a different window layout now, which
> > will undoubtedly introduce a new layer of Mac-only bugs.
>
> I fear that MFC does have a certain amount to do with it. Speaking
> concisely, I think that we should only try to get MDI working if you
> want one parent window/many independent document windows; in other
> words a "Tools" palette or panel. Chlor
> http://sourceforge.net/projects/chlor/ does this, and it is an
> effective way of using Cocoa.
>
> We don't have many users at the moment, but I suspect that when we do,
> they will request a tabbed interface, once that will probably be not
> dissimilar to the wxGTK document handing. It might be an idea to leap
> frog over the other possibilities and either move to, or bolt-on, that
> interface.
>
> If this is impractical (or not what you want) then we will probably
> have to eliminate the Parent-Child coupling and have the document
> windows all Parents (or all Children, I am not sure which is the
> better way) in which each has a full set of toolbars and tools, and
> does drawing in a client area. There aren't many precedents for such a
> Mac application, and Xara Xtreme (to give it its new name) might even
> have a claim to be the first commercial quality one, when it is
> finished; but you might want to have a look at wxMud - though I have
> not been able to get it to link on the Mac.
>
> I can't really propose a roadmap here, and I will re-iterate that now
> we have a build system we should be thinking about getting the Xara
> Xtreme (Mac) in front of artists, and would  tentatively propose
> therefore, doing the least (smallest) thing that could plausibly work
> http://c2.com/xp/DoTheSimplestThingThatCouldPossiblyWork.html , which
> may well be to press on with the Mac style (Parent/Child) MDI in the
> short term with a view to replacing it, after some thought, with an
> interface style determined by Gaddesden Place. I suspect that this
> will need an architectural decision at some point and it might be good
> at this point to concentrate on collecting information to help that.
Index: wxOil/camview.h
===================================================================
--- wxOil/camview.h	(revision 1729)
+++ wxOil/camview.h	(working copy)
@@ -167,10 +167,10 @@
 	virtual bool OnCreate( wxDocument* doc, /* TYPENOTE: Correct */ long flags );
 	bool OnClose( bool deleteWindow = TRUE );
 
-	wxMDIChildFrame *GetParentFrame() const
-	{
-		return m_pFrame;
-	}
+//	wxMDIChildFrame *GetParentFrame() const
+//	{
+//		return m_pFrame;
+//	}
 
 	static BOOL ReadViewPrefs();
 
@@ -344,7 +344,7 @@
 
 // Member variables
 protected:
-	wxMDIChildFrame* m_pFrame;
+//	wxMDIChildFrame* m_pFrame;
 	CRenderWnd* RenderWindow;
 	CWinScroller* HScrollBar;				// proportional scroll bars
 	CWinScroller* VScrollBar;
Index: wxOil/camview.cpp
===================================================================
--- wxOil/camview.cpp	(revision 1729)
+++ wxOil/camview.cpp	(working copy)
@@ -326,18 +326,21 @@
 		return false;
 	} 
 
-    m_pFrame = wxGetApp().CreateChildFrame( pDoc, this );
-    m_pFrame->SetTitle(_T("DrawingView"));
+    wxMDIChildFrame* pFrame = wxGetApp().CreateChildFrame( pDoc, this );
 
+	SetFrame(pFrame);
+
+    pFrame->SetTitle(_T("DrawingView"));
+
 	INT32 width, height;
-	m_pFrame->GetClientSize( &width, &height );
+	pFrame->GetClientSize( &width, &height );
 
 	// Now do the other half of the construction.  The stated sizes and
 	// positions of the windows here will be changed very soon.
 	const WinRect rcARect(-100,-100,-90,-90);
-	if (!RenderWindow->Create(rcARect, m_pFrame, WID_RENDERWINDOW)
-		|| !HScrollBar->Create(m_pFrame, WID_HSCROLLBAR, wxPoint(-100, -100))
-		|| !VScrollBar->Create(m_pFrame, WID_VSCROLLBAR, wxPoint(-100, -100))
+	if (!RenderWindow->Create(rcARect, pFrame, WID_RENDERWINDOW)
+		|| !HScrollBar->Create(pFrame, WID_HSCROLLBAR, wxPoint(-100, -100))
+		|| !VScrollBar->Create(pFrame, WID_VSCROLLBAR, wxPoint(-100, -100))
 //		|| !Corner->Create("", "", 0, rcARect, this, WID_SIZECORNER)
 		|| !HRuler->Create(this, WID_HRULER)
 		|| !VRuler->Create(this, WID_VRULER)
@@ -408,9 +411,9 @@
 
 #ifdef __X__
     // X seems to require a forced resize
-    m_pFrame->SetSize(wxDefaultCoord, wxDefaultCoord, width, height);
+    pFrame->SetSize(wxDefaultCoord, wxDefaultCoord, width, height);
 #endif
-    m_pFrame->Show(true);
+    pFrame->Show(true);
 
 	// This has been removed as it causes the problem where loaded documents
 	// don't render correctly if a wxYield happens before the document has 
@@ -436,17 +439,18 @@
 	if( !GetDocument()->Close() )
 		return false;
 	
+	wxWindow* pFrame = GetFrame();
+
 	SetFrame( (wxFrame *)NULL );
 	
 	Activate( false );
 
-	if( fDeleteWindow )
+	if (fDeleteWindow && pFrame != NULL)
 	{
-		TRACEUSER("Gerry", _T("CCamView::OnClose deleting frame at 0x%08x\n"), m_pFrame);
-		m_pFrame->Show( false );
+		TRACEUSER("Gerry", _T("CCamView::OnClose deleting frame at 0x%08x\n"), pFrame);
+		pFrame->Show( false );
 		
-		delete m_pFrame;
-		m_pFrame = NULL;
+		delete pFrame;
 
 		// This will also have deleted the child windows of the frame making our
 		// pointers invalid so vape them here
@@ -460,7 +464,6 @@
 		HRuler = NULL;
 		VRuler = NULL;
 		OGadget = NULL;
-
 	}
 
 	return true;
@@ -2479,12 +2482,12 @@
 	GetScrollOffset(&temp);
 	Status->SetScrollPos(temp);
 
-	if( NULL != GetParentFrame() )
+	if( NULL != GetFrame() )
 	{
 		// Record the top-most attribute of the frame window.
 PORTNOTE("other","Removed WM_TOPMOSTENQUIRY usage - is this really needed?")
 #ifndef EXCLUDE_FROM_XARALX
-		Status->AlwaysOnTop = m_pFrame->SendMessage( WM_TOPMOSTENQUIRY );
+		Status->AlwaysOnTop = GetFrame()->SendMessage( WM_TOPMOSTENQUIRY );
 #endif
 	}
 }
@@ -2597,7 +2600,7 @@
 	ENSURE(Status != NULL, "No ViewState object in CCamView::UpdateViewPosition!");
 
 	wxRect rc;
-	wxFrame* pFrame = GetParentFrame();
+	wxWindow* pFrame = GetFrame();
 	if(pFrame)
 	{
 		// Get the rectangle of the parent's MDICLIENT window.  All child window sizes and
@@ -2605,10 +2608,9 @@
 		// taking the size of the main frame window as a whole, including menus, title bar etc.
 		GetMainFrame()->GetClientSize( &rc.width, &rc.height );
 		wxRect2Rect(rc, &Status->ParentRect);
-	}
 
-	if(pFrame)
 		rc = pFrame->GetRect();
+	}
 
 	// Fill in the ViewState with the position of the normal and iconised
 	// window.  The maximised position of the window does not need to be
@@ -2699,7 +2701,7 @@
 
 	// call OnSize directly to force new layout	
 	wxSize Size;
-	m_pFrame->GetSize(&Size.x, &Size.y);
+	GetFrame()->GetSize(&Size.x, &Size.y);
 	TRACEUSER("Gerry", _T("Force an OnSize here (%d, %d)\n"), Size.x, Size.y);
 
 	wxSizeEvent evSize(Size, 0);
@@ -2744,7 +2746,7 @@
 
 	// call OnSize directly to force new layout	
 	wxSize Size=wxDefaultSize;
-	m_pFrame->GetSize(&Size.x, &Size.y);
+	GetFrame()->GetSize(&Size.x, &Size.y);
 	wxSizeEvent evSize(Size, 0);
 	OnSize(evSize);
 #endif
@@ -3722,7 +3724,7 @@
 	wxSize NewSize( event.GetSize() );
 //	TRACEUSER("Gerry", _T("CCamView::OnSize Size = (%d, %d)\n"), NewSize.x, NewSize.y);
 
-	wxRect ClientRect = m_pFrame->GetClientRect();
+	wxRect ClientRect = GetFrame()->GetClientRect();
 	wxRect RenderRect = ClientRect;
 
 	// Check for irrelevant or potty messages.
Index: wxOil/oilruler.cpp
===================================================================
--- wxOil/oilruler.cpp	(revision 1729)
+++ wxOil/oilruler.cpp	(working copy)
@@ -322,7 +322,7 @@
 	
 	m_pOwnerView = pOwnerView;
 
-	if (!wxWindow::Create(pOwnerView->GetParentFrame(), id, wxDefaultPosition, wxSize(RulerWidth, RulerWidth), wxNO_BORDER))
+	if (!wxWindow::Create(pOwnerView->GetFrame(), id, wxDefaultPosition, wxSize(RulerWidth, RulerWidth), wxNO_BORDER))
 		return(FALSE);
 
 	PostCreate();
@@ -1618,7 +1618,7 @@
 		return FALSE;
 
 //	pLegend->Create(this, -1);
-	pLegend->Create(this, m_pOwnerView->GetParentFrame(), -1);
+	pLegend->Create(this, m_pOwnerView->GetFrame(), -1);
 
 	return TRUE;
 }
@@ -1683,7 +1683,7 @@
 void OILHorizontalRuler::CalcPosFromParentClient(WinRect* lpRect)
 {
 	WinRect parentRect;
-	parentRect = m_pOwnerView->GetParentFrame()->GetClientRect();
+	parentRect = m_pOwnerView->GetFrame()->GetClientRect();
 	
 	lpRect->x   = parentRect.x + RulerWidth;
 	lpRect->y    = parentRect.y;
@@ -1890,7 +1890,7 @@
 void OILVerticalRuler::CalcPosFromParentClient(WinRect* lpRect)
 {
 	WinRect parentRect;
-	parentRect = m_pOwnerView->GetParentFrame()->GetClientRect();
+	parentRect = m_pOwnerView->GetFrame()->GetClientRect();
 
 	lpRect->x   = parentRect.x;
 	lpRect->y    = parentRect.y  + RulerWidth;
@@ -2092,7 +2092,7 @@
 void OriginGadget::CalcPosFromParentClient(WinRect* lpRect)
 {
 	wxRect parentRect;
-	parentRect = m_pOwnerView->GetParentFrame()->GetClientRect();
+	parentRect = m_pOwnerView->GetFrame()->GetClientRect();
 
 	lpRect->x   = parentRect.x ;
 	lpRect->y    = parentRect.y;
@@ -2157,7 +2157,7 @@
 
 	m_pOwnerView = pOwnerView;
 
-	if (!wxWindow::Create(pOwnerView->GetParentFrame(), id, wxDefaultPosition, wxSize(OILRuler::GetWidth(), OILRuler::GetWidth()), wxNO_BORDER))
+	if (!wxWindow::Create(pOwnerView->GetFrame(), id, wxDefaultPosition, wxSize(OILRuler::GetWidth(), OILRuler::GetWidth()), wxNO_BORDER))
 		return(FALSE);
 
 	return TRUE;