WIP: Prep for ViewManager. Make root canvas at Container level
git-svn-id: svn://10.0.0.236/trunk@10652 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
@@ -89,7 +89,7 @@ private:
|
||||
nsIMenuManager * mMenuManager;
|
||||
nsIToolbarManager * mToolbarManager;
|
||||
nsICalendarWidget * mCalendarWidget;
|
||||
nsIXPFCCanvas * mRootUI;
|
||||
nsIXPFCCanvas * mRootCanvas;
|
||||
nsICalToolkit * mToolkit;
|
||||
nsIViewManager* mViewManager;
|
||||
|
||||
|
||||
@@ -74,11 +74,8 @@ public:
|
||||
|
||||
NS_IMETHOD_(nsEventStatus) HandleEvent(nsGUIEvent *aEvent);
|
||||
|
||||
NS_IMETHOD GetRootCanvas(nsIXPFCCanvas ** aCanvas) ;
|
||||
|
||||
private:
|
||||
nsIWidget * mWindow;
|
||||
nsIXPFCCanvas * mRootCanvas ;
|
||||
nsIStreamListener * mStreamListener;
|
||||
|
||||
public:
|
||||
|
||||
@@ -64,8 +64,6 @@ public:
|
||||
nsIStreamObserver* aListener,
|
||||
nsIPostData* aPostData = 0) = 0;
|
||||
|
||||
NS_IMETHOD GetRootCanvas(nsIXPFCCanvas ** aCanvas) = 0;
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
||||
@@ -74,7 +74,7 @@ nsCalendarContainer::nsCalendarContainer()
|
||||
mMenuManager = nsnull;
|
||||
mCalendarWidget = nsnull;
|
||||
mCalendarShell = nsnull;
|
||||
mRootUI = nsnull;
|
||||
mRootCanvas = nsnull;
|
||||
mToolkit = nsnull;
|
||||
mToolbarManager = nsnull;
|
||||
mViewManager = nsnull;
|
||||
@@ -89,7 +89,7 @@ nsCalendarContainer::~nsCalendarContainer()
|
||||
NS_IF_RELEASE(mViewManager);
|
||||
NS_IF_RELEASE(mMenuManager);
|
||||
NS_IF_RELEASE(mCalendarWidget);
|
||||
NS_IF_RELEASE(mRootUI);
|
||||
NS_IF_RELEASE(mRootCanvas);
|
||||
NS_IF_RELEASE(mToolkit);
|
||||
NS_IF_RELEASE(mToolbarManager);
|
||||
}
|
||||
@@ -157,7 +157,7 @@ nsresult nsCalendarContainer::Init(nsIWidget * aParent,
|
||||
* Create the Root UI
|
||||
*/
|
||||
|
||||
if (mRootUI == nsnull)
|
||||
if (mRootCanvas == nsnull)
|
||||
{
|
||||
/*
|
||||
* Create a basic canvas with ybox. When a toolbar gets added to
|
||||
@@ -172,20 +172,22 @@ nsresult nsCalendarContainer::Init(nsIWidget * aParent,
|
||||
res = nsRepository::CreateInstance(kCXPFCCanvasCID,
|
||||
nsnull,
|
||||
kCXPFCCanvasCID,
|
||||
(void **)&mRootUI);
|
||||
(void **)&mRootCanvas);
|
||||
|
||||
if (NS_OK == res)
|
||||
{
|
||||
|
||||
mRootUI->Init();
|
||||
mRootCanvas->Init();
|
||||
}
|
||||
|
||||
mRootUI->Init(aParent, aBounds,(((nsCalendarShell *)aCalendarShell)->mShellInstance->GetShellEventCallback()));
|
||||
mRootCanvas->Init(aParent, aBounds,(((nsCalendarShell *)aCalendarShell)->mShellInstance->GetShellEventCallback()));
|
||||
|
||||
widget_parent = mRootUI->GetWidget();
|
||||
widget_parent = mRootCanvas->GetWidget();
|
||||
|
||||
mRootCanvas->SetVisibility(PR_FALSE);
|
||||
((nsBoxLayout *)(mRootCanvas->GetLayout()))->SetLayoutAlignment(eLayoutAlignment_vertical);
|
||||
gXPFCToolkit->GetCanvasManager()->SetRootCanvas(mRootCanvas);
|
||||
|
||||
mRootUI->SetVisibility(PR_FALSE);
|
||||
((nsBoxLayout *)(mRootUI->GetLayout()))->SetLayoutAlignment(eLayoutAlignment_vertical);
|
||||
|
||||
#if 0
|
||||
nsIView * view = nsnull ;
|
||||
@@ -213,7 +215,7 @@ nsresult nsCalendarContainer::Init(nsIWidget * aParent,
|
||||
|
||||
//view->GetWidget(widget_parent);
|
||||
|
||||
gXPFCToolkit->GetCanvasManager()->Register(mRootUI,view);
|
||||
gXPFCToolkit->GetCanvasManager()->Register(mRootCanvas,view);
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -238,15 +240,7 @@ nsresult nsCalendarContainer::Init(nsIWidget * aParent,
|
||||
|
||||
res = mCalendarWidget->Init(widget_parent, aBounds, aCalendarShell);
|
||||
|
||||
nsIXPFCCanvas * root ;
|
||||
|
||||
mCalendarWidget->GetRootCanvas(&root);
|
||||
|
||||
mRootUI->AddChildCanvas(root);
|
||||
|
||||
mRootUI->Layout();
|
||||
|
||||
NS_RELEASE(root);
|
||||
mRootCanvas->Layout();
|
||||
|
||||
return (res);
|
||||
}
|
||||
@@ -303,7 +297,7 @@ nsresult nsCalendarContainer::AddToolbar(nsIXPFCToolbar * aToolbar)
|
||||
|
||||
if (NS_OK == res)
|
||||
{
|
||||
mRootUI->AddChildCanvas(canvas,0);
|
||||
mRootCanvas->AddChildCanvas(canvas,0);
|
||||
|
||||
/*
|
||||
* Let's add a native widget here. This code should be in XPFC
|
||||
@@ -376,7 +370,7 @@ nsresult nsCalendarContainer::UpdateToolbars()
|
||||
if (w == nsnull)
|
||||
return NS_OK;
|
||||
|
||||
mRootUI->Layout();
|
||||
mRootCanvas->Layout();
|
||||
w->Invalidate(PR_FALSE);
|
||||
|
||||
return NS_OK;
|
||||
@@ -390,7 +384,7 @@ nsresult nsCalendarContainer::ShowDialog(nsIXPFCDialog * aDialog)
|
||||
|
||||
if (NS_OK == res)
|
||||
{
|
||||
//mRootUI->AddChildCanvas(canvas,0);
|
||||
//mRootCanvas->AddChildCanvas(canvas,0);
|
||||
|
||||
/*
|
||||
* Let's add a native widget here. This code should be in XPFC
|
||||
@@ -402,7 +396,7 @@ nsresult nsCalendarContainer::ShowDialog(nsIXPFCDialog * aDialog)
|
||||
*/
|
||||
static NS_DEFINE_IID(kCWidgetCID, NS_WINDOW_CID);
|
||||
|
||||
nsIWidget * parent = mRootUI->GetWidget();
|
||||
nsIWidget * parent = mRootCanvas->GetWidget();
|
||||
|
||||
res = canvas->LoadWidget(kCWidgetCID);
|
||||
|
||||
@@ -556,9 +550,9 @@ nsEventStatus nsCalendarContainer::HandleEvent(nsGUIEvent *aEvent)
|
||||
}
|
||||
|
||||
if (aEvent->message == NS_SIZE)
|
||||
mRootUI->SetBounds(*(((nsSizeEvent*)aEvent)->windowSize));
|
||||
mRootCanvas->SetBounds(*(((nsSizeEvent*)aEvent)->windowSize));
|
||||
|
||||
return (mRootUI->HandleEvent(aEvent));
|
||||
return (mRootCanvas->HandleEvent(aEvent));
|
||||
}
|
||||
|
||||
NS_CALENDAR nsresult NS_NewCalendarContainer(nsICalendarContainer** aInstancePtrResult)
|
||||
|
||||
@@ -43,6 +43,7 @@
|
||||
#include "nsCapiCIID.h"
|
||||
#include "nspr.h"
|
||||
#include "prcvar.h"
|
||||
#include "nsXPFCToolkit.h"
|
||||
#include "nsX400Parser.h"
|
||||
|
||||
#include "capi.h"
|
||||
@@ -777,7 +778,7 @@ nsresult nsCalendarShell::ReceiveCommand(nsString& aCommand, nsString& aReply)
|
||||
|
||||
nsString name("CommandCanvas");
|
||||
|
||||
mDocumentContainer->GetDocumentWidget()->GetRootCanvas(&root);
|
||||
gXPFCToolkit->GetRootCanvas(&root);
|
||||
|
||||
canvas = root->CanvasFromName(name);
|
||||
|
||||
|
||||
@@ -111,7 +111,6 @@ NS_IMPL_RELEASE(nsCalendarWidget)
|
||||
nsCalendarWidget::~nsCalendarWidget()
|
||||
{
|
||||
// Release windows and views
|
||||
NS_IF_RELEASE(mRootCanvas);
|
||||
NS_IF_RELEASE(mWindow);
|
||||
((nsIApplicationShell *)mCalendarShell)->Release();
|
||||
}
|
||||
@@ -135,6 +134,7 @@ nsresult nsCalendarWidget::Init(nsIWidget * aParent,
|
||||
nsresult res ;
|
||||
|
||||
mCalendarShell = aCalendarShell;
|
||||
nsIXPFCCanvas * root;
|
||||
|
||||
NS_ADDREF(((nsIApplicationShell *)mCalendarShell));
|
||||
|
||||
@@ -150,14 +150,23 @@ nsresult nsCalendarWidget::Init(nsIWidget * aParent,
|
||||
res = nsRepository::CreateInstance(kCXPFCCanvasCID,
|
||||
nsnull,
|
||||
kCXPFCCanvasCID,
|
||||
(void **)&mRootCanvas);
|
||||
(void **)&root);
|
||||
|
||||
if (NS_OK != res)
|
||||
return res ;
|
||||
|
||||
gXPFCToolkit->GetCanvasManager()->SetRootCanvas(mRootCanvas);
|
||||
//gXPFCToolkit->GetCanvasManager()->SetRootCanvas(root);
|
||||
root->Init();
|
||||
|
||||
mRootCanvas->Init(aParent, aBounds,(((nsCalendarShell *)mCalendarShell)->mShellInstance->GetShellEventCallback()));
|
||||
//root->Init(aParent, aBounds,(((nsCalendarShell *)mCalendarShell)->mShellInstance->GetShellEventCallback()));
|
||||
|
||||
nsIXPFCCanvas * root_canvas ;
|
||||
|
||||
gXPFCToolkit->GetRootCanvas(&root_canvas);
|
||||
|
||||
root_canvas->AddChildCanvas(root);
|
||||
|
||||
NS_RELEASE(root_canvas);
|
||||
|
||||
return res ;
|
||||
}
|
||||
@@ -165,9 +174,16 @@ nsresult nsCalendarWidget::Init(nsIWidget * aParent,
|
||||
nsRect nsCalendarWidget::GetBounds()
|
||||
{
|
||||
nsRect zr(0, 0, 0, 0);
|
||||
if (nsnull != mRootCanvas) {
|
||||
mRootCanvas->GetBounds(zr);
|
||||
|
||||
nsIXPFCCanvas * root = nsnull ;
|
||||
|
||||
gXPFCToolkit->GetRootCanvas(&root);
|
||||
|
||||
if (nsnull != root) {
|
||||
root->GetBounds(zr);
|
||||
NS_RELEASE(root);
|
||||
}
|
||||
|
||||
return zr;
|
||||
}
|
||||
|
||||
@@ -222,7 +238,15 @@ nsresult nsCalendarWidget::LoadURL(const nsString& aURLSpec, nsIStreamObserver*
|
||||
|
||||
iid_dtd = (nsIID *) &kCCalXMLDTD;
|
||||
iid_sink = (nsIID *) &kCCalXMLContentSinkCID;
|
||||
mRootCanvas->DeleteChildren();
|
||||
|
||||
nsIXPFCCanvas * root = nsnull ;
|
||||
|
||||
gXPFCToolkit->GetRootCanvas(&root);
|
||||
|
||||
root->DeleteChildren();
|
||||
|
||||
NS_RELEASE(root);
|
||||
|
||||
}
|
||||
|
||||
res = stream_manager->LoadURL(((nsCalendarShell*)mCalendarShell)->mDocumentContainer,
|
||||
@@ -257,12 +281,14 @@ nsIWidget* nsCalendarWidget::GetWWWindow()
|
||||
|
||||
nsEventStatus nsCalendarWidget::HandleEvent(nsGUIEvent *aEvent)
|
||||
{
|
||||
return (mRootCanvas->HandleEvent(aEvent));
|
||||
}
|
||||
|
||||
nsresult nsCalendarWidget::GetRootCanvas(nsIXPFCCanvas ** aCanvas)
|
||||
{
|
||||
|
||||
return (mRootCanvas->QueryInterface(kIXPFCCanvasIID, (void **)aCanvas));
|
||||
nsIXPFCCanvas * root = nsnull ;
|
||||
|
||||
gXPFCToolkit->GetRootCanvas(&root);
|
||||
|
||||
nsEventStatus st = root->HandleEvent(aEvent);
|
||||
|
||||
NS_RELEASE(root);
|
||||
|
||||
return (st);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user