зеркало из https://github.com/mozilla/gecko-dev.git
Have View look at their Model for deciding how to render
content
This commit is contained in:
Родитель
a7c2bc1be9
Коммит
2cf061c5a9
|
@ -24,7 +24,8 @@
|
|||
#include "nsICalendarModel.h"
|
||||
#include "nsICalendarUser.h"
|
||||
|
||||
class nsCalendarModel : public nsICalendarModel
|
||||
class nsCalendarModel : public nsICalendarModel,
|
||||
public nsIModel
|
||||
{
|
||||
|
||||
public:
|
||||
|
|
|
@ -51,6 +51,11 @@ nsresult nsCalendarModel::QueryInterface(REFNSIID aIID, void** aInstancePtr)
|
|||
AddRef();
|
||||
return NS_OK;
|
||||
}
|
||||
if (aIID.Equals(kIModelIID)) {
|
||||
*aInstancePtr = (void*) (this);
|
||||
AddRef();
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
return (NS_NOINTERFACE);
|
||||
|
||||
|
|
|
@ -123,7 +123,7 @@ nsresult nsCoreFactory::CreateInstance(nsISupports *aOuter,
|
|||
} else if (mClassID.Equals(kCCalendarUserCID)) {
|
||||
inst = (nsISupports *)new nsCalendarUser(aOuter);
|
||||
} else if (mClassID.Equals(kCCalendarModelCID)) {
|
||||
inst = (nsISupports *)new nsCalendarModel(aOuter);
|
||||
inst = (nsISupports *)(nsICalendarModel*)new nsCalendarModel(aOuter);
|
||||
}
|
||||
|
||||
if (inst == NULL) {
|
||||
|
|
|
@ -32,6 +32,9 @@
|
|||
#include "nsIViewManager.h"
|
||||
#include "nsXPFCToolkit.h"
|
||||
#include "nsXPFCActionCommand.h"
|
||||
#include "nsICalendarUser.h"
|
||||
#include "nsICalendarModel.h"
|
||||
#include "nsCoreCIID.h"
|
||||
|
||||
// XXX: This code should use XML for defining the Root UI. We need to
|
||||
// implement the stream manager first to do this, then lots of
|
||||
|
@ -55,6 +58,11 @@ static NS_DEFINE_IID(kWidgetCID, NS_CHILD_CID);
|
|||
|
||||
static NS_DEFINE_IID(kCCalCanvasCID, NS_CAL_CANVAS_CID);
|
||||
|
||||
static NS_DEFINE_IID(kIModelIID, NS_IMODEL_IID);
|
||||
static NS_DEFINE_IID(kICalendarModelIID, NS_ICALENDAR_MODEL_IID);
|
||||
static NS_DEFINE_IID(kCCalendarModelCID, NS_CALENDAR_MODEL_CID);
|
||||
|
||||
|
||||
// hardcode names of dll's
|
||||
#ifdef NS_WIN32
|
||||
#define CALUI_DLL "calui10.dll"
|
||||
|
@ -177,6 +185,34 @@ nsresult nsCalendarContainer::Init(nsIWidget * aParent,
|
|||
|
||||
gXPFCToolkit->GetCanvasManager()->SetRootCanvas(mRootCanvas);
|
||||
|
||||
/*
|
||||
* Associate the Logged In User's content model with the canvas
|
||||
*/
|
||||
|
||||
nsICalendarModel * calmodel = nsnull;
|
||||
nsIModel * model = nsnull;
|
||||
|
||||
res = nsRepository::CreateInstance(kCCalendarModelCID,
|
||||
nsnull,
|
||||
kICalendarModelIID,
|
||||
(void **)&calmodel);
|
||||
|
||||
if (NS_OK != res)
|
||||
return res;
|
||||
|
||||
calmodel->Init();
|
||||
|
||||
calmodel->SetCalendarUser(((nsCalendarShell *)aCalendarShell)->mpLoggedInUser);
|
||||
|
||||
calmodel->QueryInterface(kIModelIID, (void**)&model);
|
||||
|
||||
if (NS_OK != res)
|
||||
return res;
|
||||
|
||||
mRootCanvas->SetModel(model);
|
||||
|
||||
NS_RELEASE(model);
|
||||
|
||||
nsNativeWidget native = aParent->GetNativeData(NS_NATIVE_WIDGET);
|
||||
|
||||
mRootCanvas->Init(native,
|
||||
|
|
|
@ -309,6 +309,7 @@ nsresult nsCalendarShell::Logon()
|
|||
NS_ASSERTION(0 != pLayer,"null pLayer");
|
||||
pLayer->SetShell(this);
|
||||
pLayer->FetchEventsByRange(&d,&d1,&EventList);
|
||||
pLayer->SetCal(mpCalendar);
|
||||
mpCalendar->addEventList(&EventList);
|
||||
}
|
||||
break;
|
||||
|
|
|
@ -35,6 +35,10 @@ public:
|
|||
NS_IMETHOD GetUser(nsICalendarUser *& aUser);
|
||||
NS_IMETHOD SetUser(nsICalendarUser * aUser);
|
||||
|
||||
NS_IMETHOD_(nsIModel *) GetModel();
|
||||
NS_IMETHOD GetModelInterface(const nsIID &aModelIID, nsISupports * aInterface) ;
|
||||
NS_IMETHOD SetModel(nsIModel * aModel);
|
||||
|
||||
protected:
|
||||
~nsCalCanvas();
|
||||
|
||||
|
|
|
@ -73,3 +73,19 @@ nsresult nsCalCanvas :: SetUser(nsICalendarUser * aUser)
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
nsIModel * nsCalCanvas :: GetModel()
|
||||
{
|
||||
return (nsXPFCCanvas::GetModel());
|
||||
}
|
||||
|
||||
nsresult nsCalCanvas :: GetModelInterface(const nsIID &aModelIID, nsISupports * aInterface)
|
||||
{
|
||||
return (nsXPFCCanvas::GetModelInterface(aModelIID,aInterface));
|
||||
}
|
||||
|
||||
|
||||
nsresult nsCalCanvas :: SetModel(nsIModel * aModel)
|
||||
{
|
||||
return (nsXPFCCanvas::SetModel(aModel));
|
||||
}
|
||||
|
|
|
@ -25,6 +25,8 @@
|
|||
#include "nsIRenderingContext.h"
|
||||
#include "nsIFontMetrics.h"
|
||||
#include "nsIDeviceContext.h"
|
||||
#include "nsICalendarUser.h"
|
||||
#include "nsICalendarModel.h"
|
||||
|
||||
#include "datetime.h"
|
||||
#include "ptrarray.h"
|
||||
|
@ -42,6 +44,8 @@ typedef struct
|
|||
static NS_DEFINE_IID(kISupportsIID, NS_ISUPPORTS_IID);
|
||||
static NS_DEFINE_IID(kCalDayViewCanvasCID, NS_CAL_DAYVIEWCANVAS_CID);
|
||||
static NS_DEFINE_IID(kIXPFCCanvasIID, NS_IXPFC_CANVAS_IID);
|
||||
static NS_DEFINE_IID(kICalendarUserIID, NS_ICALENDAR_USER_IID);
|
||||
static NS_DEFINE_IID(kICalendarModelIID, NS_ICALENDAR_MODEL_IID);
|
||||
|
||||
nsCalDayViewCanvas :: nsCalDayViewCanvas(nsISupports* outer) : nsCalTimebarComponentCanvas(outer)
|
||||
{
|
||||
|
@ -213,12 +217,37 @@ nsEventStatus nsCalDayViewCanvas :: PaintForeground(nsIRenderingContext& aRender
|
|||
DateTime * dStart = ((nsDateTime *)GetTimeContext()->GetDTStart())->GetDateTime();
|
||||
DateTime * dEnd = ((nsDateTime *)GetTimeContext()->GetDTEnd())->GetDateTime();
|
||||
|
||||
/*
|
||||
* XXX. This looks wrong. I think we need to store some sort of
|
||||
* pointer to an associated calendar with this canvas. It
|
||||
* appears to always get the logged in user's canvas.
|
||||
*/
|
||||
gCalToolkit->GetNSCalendar()->getEventsByRange(evtVctr, *dStart, *dEnd);
|
||||
nsIModel * model = GetModel();
|
||||
nsICalendarModel * calmodel = nsnull;
|
||||
|
||||
if (nsnull == model)
|
||||
return nsEventStatus_eConsumeNoDefault;
|
||||
|
||||
nsICalendarUser * user = nsnull;
|
||||
|
||||
nsresult res = model->QueryInterface(kICalendarModelIID, (void**)&calmodel);
|
||||
if (NS_OK != res)
|
||||
return nsEventStatus_eConsumeNoDefault;
|
||||
|
||||
calmodel->GetCalendarUser(user);
|
||||
|
||||
if (NS_OK != res)
|
||||
return nsEventStatus_eConsumeNoDefault;
|
||||
|
||||
nsILayer * layer;
|
||||
|
||||
user->GetLayer(layer);
|
||||
|
||||
NSCalendar * nscal;
|
||||
|
||||
layer->GetCal(nscal);
|
||||
|
||||
if (0)
|
||||
{
|
||||
gCalToolkit->GetNSCalendar()->getEventsByRange(evtVctr, *dStart, *dEnd);
|
||||
}
|
||||
nscal->getEventsByRange(evtVctr, *dStart, *dEnd);
|
||||
|
||||
PRUint32 vis_start_min = GetTimeContext()->GetFirstVisibleTime(nsCalPeriodFormat_kHour) * 60 + GetTimeContext()->GetFirstVisibleTime(nsCalPeriodFormat_kMinute);
|
||||
PRUint32 vis_end_min = GetTimeContext()->GetLastVisibleTime(nsCalPeriodFormat_kHour) * 60 + GetTimeContext()->GetLastVisibleTime(nsCalPeriodFormat_kMinute);
|
||||
PRFloat64 div_ratio = ((PRFloat64)(1)) / (PRFloat64)(vis_end_min - vis_start_min) ;
|
||||
|
@ -314,5 +343,8 @@ nsEventStatus nsCalDayViewCanvas :: PaintForeground(nsIRenderingContext& aRender
|
|||
}
|
||||
|
||||
delete evtVctr;
|
||||
|
||||
NS_RELEASE(calmodel);
|
||||
|
||||
return nsEventStatus_eConsumeNoDefault;
|
||||
}
|
||||
|
|
|
@ -72,6 +72,7 @@ public:
|
|||
NS_IMETHOD SetLabel(nsString& aString);
|
||||
|
||||
NS_IMETHOD_(nsIModel *) GetModel();
|
||||
NS_IMETHOD GetModelInterface(const nsIID &aModelIID, nsISupports * aInterface) ;
|
||||
NS_IMETHOD SetModel(nsIModel * aModel);
|
||||
|
||||
NS_IMETHOD SetBounds(const nsRect& aBounds);
|
||||
|
|
|
@ -114,6 +114,7 @@ public:
|
|||
* @result nsIModel pointer, nsnull if no model object assigned, else a pointer to the model object
|
||||
*/
|
||||
NS_IMETHOD_(nsIModel *) GetModel() = 0;
|
||||
NS_IMETHOD GetModelInterface(const nsIID &aModelIID, nsISupports * aInterface) = 0;
|
||||
NS_IMETHOD SetModel(nsIModel * aModel) = 0;
|
||||
|
||||
/**
|
||||
|
|
|
@ -126,6 +126,7 @@ nsXPFCCanvas :: ~nsXPFCCanvas()
|
|||
|
||||
NS_IF_RELEASE(mLayout);
|
||||
NS_IF_RELEASE(mChildWidgets);
|
||||
NS_IF_RELEASE(mModel);
|
||||
|
||||
if (mImageGroup != nsnull)
|
||||
{
|
||||
|
@ -707,12 +708,33 @@ nsresult nsXPFCCanvas :: SetLayout(nsILayout * aLayout)
|
|||
|
||||
nsIModel * nsXPFCCanvas :: GetModel()
|
||||
{
|
||||
if (nsnull != mModel)
|
||||
return mModel;
|
||||
|
||||
if (nsnull != GetParent())
|
||||
return (GetParent()->GetModel());
|
||||
|
||||
return nsnull;
|
||||
}
|
||||
|
||||
nsresult nsXPFCCanvas :: GetModelInterface(const nsIID &aModelIID, nsISupports * aInterface)
|
||||
{
|
||||
nsIModel * model = GetModel();
|
||||
|
||||
if (nsnull == model)
|
||||
return (NS_NOINTERFACE);
|
||||
|
||||
nsresult res = model->QueryInterface(aModelIID, (void**) &aInterface);
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
|
||||
nsresult nsXPFCCanvas :: SetModel(nsIModel * aModel)
|
||||
{
|
||||
NS_IF_RELEASE(mModel);
|
||||
mModel = aModel;
|
||||
NS_ADDREF(mModel);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче