зеркало из https://github.com/mozilla/gecko-dev.git
WIP: MultiUser View
This commit is contained in:
Родитель
186c55bec0
Коммит
a1eadc81c7
|
@ -24,7 +24,7 @@
|
|||
|
||||
<!-- This is the MultiDayView and Command Bar -->
|
||||
<panel name="MultiDayViewRule">
|
||||
<multiuserviewcanvas name="MultiCalendarEventWeekView" control="MiniCalendar" repeatable="DayContext" minrepeat="1" maxrepeat="5" count="5">
|
||||
<multiuserviewcanvas layout="xbox" name="MultiCalendarEventWeekView" control="MiniCalendar" repeatable="DayContext">
|
||||
<commandcanvas name="CommandCanvas" weightmajor="0" weightminor="0">
|
||||
</panel>
|
||||
|
||||
|
|
|
@ -24,7 +24,7 @@
|
|||
|
||||
<!-- This is the MultiDayView and Command Bar -->
|
||||
<panel name="MultiDayViewRule">
|
||||
<multidayviewcanvas name="MultiCalendarEventWeekView" control="MiniCalendar" repeatable="DayContext" minrepeat="1" maxrepeat="5" count="5">
|
||||
<multidayviewcanvas layout="xbox" name="MultiCalendarEventWeekView" control="MiniCalendar" repeatable="DayContext" minrepeat="1" maxrepeat="5" count="5">
|
||||
<commandcanvas name="CommandCanvas" weightmajor="0" weightminor="0">
|
||||
</panel>
|
||||
|
||||
|
|
|
@ -40,24 +40,12 @@ public:
|
|||
NS_IMETHOD_(PRUint32) GetNumberViewableDays();
|
||||
NS_IMETHOD SetNumberViewableDays(PRUint32 aNumberViewableDays);
|
||||
|
||||
NS_IMETHOD SetTimeContext(nsICalTimeContext * aContext);
|
||||
|
||||
NS_IMETHOD SetParameter(nsString& aKey, nsString& aValue) ;
|
||||
NS_IMETHOD SetTimeContext(nsICalTimeContext * aContext);
|
||||
|
||||
// nsIXPFCCommandReceiver methods
|
||||
NS_IMETHOD Action(nsIXPFCCommand * aCommand);
|
||||
|
||||
|
||||
NS_IMETHOD SetChildTimeContext(nsCalTimebarCanvas * aCanvas,
|
||||
nsICalTimeContext * aContext,
|
||||
PRUint32 increment);
|
||||
NS_IMETHOD ChangeChildDateTime(nsCalTimebarCanvas * aCanvas,
|
||||
nsDateTime * aDateTime);
|
||||
NS_IMETHOD ChangeChildDateTime(PRUint32 aIndex, nsDateTime * aDateTime);
|
||||
|
||||
|
||||
|
||||
|
||||
protected:
|
||||
~nsCalMultiDayViewCanvas();
|
||||
|
||||
|
|
|
@ -32,6 +32,7 @@ public:
|
|||
NS_DECL_ISUPPORTS
|
||||
|
||||
NS_IMETHOD Init();
|
||||
NS_IMETHOD SetParameter(nsString& aKey, nsString& aValue) ;
|
||||
|
||||
protected:
|
||||
~nsCalMultiUserViewCanvas();
|
||||
|
|
|
@ -34,9 +34,14 @@ public:
|
|||
NS_IMETHOD Init();
|
||||
|
||||
NS_IMETHOD SetShowHeaders(PRBool aShowHeaders);
|
||||
NS_IMETHOD SetShowStatus(PRBool aShowHeaders);
|
||||
NS_IMETHOD_(PRBool) GetShowHeaders();
|
||||
|
||||
NS_IMETHOD SetShowStatus(PRBool aShowHeaders);
|
||||
NS_IMETHOD_(PRBool) GetShowStatus();
|
||||
|
||||
NS_IMETHOD SetShowTimeScale(PRBool aShowTimeScale);
|
||||
NS_IMETHOD_(PRBool) GetShowTimeScale();
|
||||
|
||||
NS_IMETHOD SetParameter(nsString& aKey, nsString& aValue) ;
|
||||
NS_IMETHOD Action(nsIXPFCCommand * aCommand);
|
||||
|
||||
|
@ -49,6 +54,7 @@ protected:
|
|||
private:
|
||||
PRBool mShowHeaders;
|
||||
PRBool mShowStatus;
|
||||
PRBool mShowTimeScale;
|
||||
|
||||
};
|
||||
|
||||
|
|
|
@ -24,6 +24,7 @@
|
|||
#include "nsXPFCCanvas.h"
|
||||
#include "nsICalTimeContext.h"
|
||||
#include "nsCalCanvas.h"
|
||||
#include "nsDateTime.h"
|
||||
|
||||
class nsCalTimebarCanvas : public nsCalCanvas
|
||||
|
||||
|
@ -44,6 +45,13 @@ public:
|
|||
const nsRect& aDirtyRect);
|
||||
NS_IMETHOD SetParameter(nsString& aKey, nsString& aValue) ;
|
||||
|
||||
NS_IMETHOD SetChildTimeContext(nsCalTimebarCanvas * aCanvas,
|
||||
nsICalTimeContext * aContext,
|
||||
PRUint32 increment);
|
||||
NS_IMETHOD ChangeChildDateTime(nsCalTimebarCanvas * aCanvas,
|
||||
nsDateTime * aDateTime);
|
||||
NS_IMETHOD ChangeChildDateTime(PRUint32 aIndex, nsDateTime * aDateTime);
|
||||
|
||||
|
||||
protected:
|
||||
|
||||
|
|
|
@ -177,7 +177,13 @@ nsIXPFCCanvas * nsCalMultiDayViewCanvas :: AddDayViewCanvas()
|
|||
AddChildCanvas(canvas);
|
||||
|
||||
canvas->SetBackgroundColor(GetBackgroundColor());
|
||||
((nsBoxLayout *)(canvas->GetLayout()))->SetLayoutAlignment(eLayoutAlignment_vertical);
|
||||
|
||||
nsLayoutAlignment la = ((nsBoxLayout *)(GetLayout()))->GetLayoutAlignment();
|
||||
|
||||
if (eLayoutAlignment_horizontal == la)
|
||||
((nsBoxLayout *)(canvas->GetLayout()))->SetLayoutAlignment(eLayoutAlignment_vertical);
|
||||
else
|
||||
((nsBoxLayout *)(canvas->GetLayout()))->SetLayoutAlignment(eLayoutAlignment_horizontal);
|
||||
|
||||
parent = canvas;
|
||||
|
||||
|
@ -256,226 +262,6 @@ nsIXPFCCanvas * nsCalMultiDayViewCanvas :: AddDayViewCanvas()
|
|||
return (parent);
|
||||
}
|
||||
|
||||
nsresult nsCalMultiDayViewCanvas :: ChangeChildDateTime(PRUint32 aIndex, nsDateTime * aDateTime)
|
||||
{
|
||||
nsresult res = NS_OK;
|
||||
nsIIterator * iterator ;
|
||||
nsCalTimebarCanvas * canvas ;
|
||||
PRUint32 index = 0;
|
||||
|
||||
res = CreateIterator(&iterator);
|
||||
|
||||
if (NS_OK != res)
|
||||
return res;
|
||||
|
||||
iterator->Init();
|
||||
|
||||
while((!(iterator->IsDone())))
|
||||
{
|
||||
|
||||
if ((index == aIndex)) {
|
||||
|
||||
/*
|
||||
* Iterate through these children til we find the right one
|
||||
*/
|
||||
|
||||
canvas = (nsCalTimebarCanvas *) iterator->CurrentItem();
|
||||
|
||||
nsresult res2 = NS_OK;
|
||||
nsIIterator * iterator2 ;
|
||||
nsCalTimebarCanvas * canvas2 ;
|
||||
|
||||
res2 = canvas->CreateIterator(&iterator2);
|
||||
|
||||
if (NS_OK != res2)
|
||||
return res2;
|
||||
|
||||
iterator2->Init();
|
||||
|
||||
while(!(iterator2->IsDone()))
|
||||
{
|
||||
|
||||
canvas2 = (nsCalTimebarCanvas *) iterator2->CurrentItem();
|
||||
|
||||
nsCalTimebarCanvas * canvas_iface = nsnull;;
|
||||
|
||||
canvas2->QueryInterface(kCalTimebarCanvasCID, (void**) &canvas_iface);
|
||||
|
||||
if ((canvas_iface != nsnull)) {
|
||||
|
||||
ChangeChildDateTime(canvas_iface, aDateTime);
|
||||
|
||||
NS_RELEASE(canvas_iface);
|
||||
}
|
||||
|
||||
iterator2->Next();
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
index++;
|
||||
iterator->Next();
|
||||
}
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
/*
|
||||
* Call SetContext on all child canvas that support the
|
||||
* nsCalTimebarCanvas interface. This routine is recursive.
|
||||
*
|
||||
* We need to store this TimeContext for ourselves also in case
|
||||
* we get asked to add new DayView Canvas's, we'll ask the DayView
|
||||
* to copy our context to start with.
|
||||
*/
|
||||
|
||||
nsresult nsCalMultiDayViewCanvas :: SetTimeContext(nsICalTimeContext * aContext)
|
||||
{
|
||||
|
||||
nsresult res = NS_OK;
|
||||
nsIIterator * iterator ;
|
||||
nsCalTimebarCanvas * canvas ;
|
||||
PRUint32 index = 0;
|
||||
|
||||
res = CreateIterator(&iterator);
|
||||
|
||||
if (NS_OK != res)
|
||||
return res;
|
||||
|
||||
iterator->Init();
|
||||
|
||||
while(!(iterator->IsDone()))
|
||||
{
|
||||
|
||||
/*
|
||||
* Iterate through these children til we find the right one
|
||||
*/
|
||||
|
||||
canvas = (nsCalTimebarCanvas *) iterator->CurrentItem();
|
||||
|
||||
nsresult res2 = NS_OK;
|
||||
nsIIterator * iterator2 ;
|
||||
nsCalTimebarCanvas * canvas2 ;
|
||||
|
||||
res2 = canvas->CreateIterator(&iterator2);
|
||||
|
||||
if (NS_OK != res2)
|
||||
return res2;
|
||||
|
||||
iterator2->Init();
|
||||
|
||||
while(!(iterator2->IsDone()))
|
||||
{
|
||||
|
||||
canvas2 = (nsCalTimebarCanvas *) iterator2->CurrentItem();
|
||||
|
||||
nsCalTimebarCanvas * canvas_iface = nsnull;;
|
||||
|
||||
canvas2->QueryInterface(kCalTimebarCanvasCID, (void**) &canvas_iface);
|
||||
|
||||
if (canvas_iface) {
|
||||
|
||||
SetChildTimeContext(canvas_iface, aContext, index);
|
||||
|
||||
NS_RELEASE(canvas_iface);
|
||||
}
|
||||
|
||||
iterator2->Next();
|
||||
|
||||
}
|
||||
|
||||
index++;
|
||||
iterator->Next();
|
||||
}
|
||||
|
||||
return (nsCalTimebarComponentCanvas::SetTimeContext(aContext));
|
||||
}
|
||||
|
||||
nsresult nsCalMultiDayViewCanvas :: ChangeChildDateTime(nsCalTimebarCanvas * aCanvas,
|
||||
nsDateTime * aDateTime)
|
||||
{
|
||||
|
||||
nsIDateTime * datetime;
|
||||
nsICalTimeContext * context = aCanvas->GetTimeContext();
|
||||
|
||||
if (context == nsnull)
|
||||
return NS_OK;
|
||||
|
||||
context->SetDate(aDateTime);
|
||||
|
||||
datetime = context->GetDTStart() ;
|
||||
datetime->SetYear(aDateTime->GetYear());
|
||||
datetime->SetMonth(aDateTime->GetMonth());
|
||||
datetime->SetDay(aDateTime->GetDay());
|
||||
|
||||
datetime = context->GetDTEnd() ;
|
||||
datetime->SetYear(aDateTime->GetYear());
|
||||
datetime->SetMonth(aDateTime->GetMonth());
|
||||
datetime->SetDay(aDateTime->GetDay()+1);
|
||||
|
||||
datetime = context->GetDTFirstVisible() ;
|
||||
datetime->SetYear(aDateTime->GetYear());
|
||||
datetime->SetMonth(aDateTime->GetMonth());
|
||||
datetime->SetDay(aDateTime->GetDay());
|
||||
|
||||
datetime = context->GetDTLastVisible() ;
|
||||
datetime->SetYear(aDateTime->GetYear());
|
||||
datetime->SetMonth(aDateTime->GetMonth());
|
||||
datetime->SetDay(aDateTime->GetDay());
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult nsCalMultiDayViewCanvas :: SetChildTimeContext(nsCalTimebarCanvas * aCanvas,
|
||||
nsICalTimeContext * aContext,
|
||||
PRUint32 increment)
|
||||
{
|
||||
nsICalTimeContext * context;
|
||||
|
||||
static NS_DEFINE_IID(kCCalTimeContextCID, NS_CAL_TIME_CONTEXT_CID);
|
||||
static NS_DEFINE_IID(kCCalTimeContextIID, NS_ICAL_TIME_CONTEXT_IID);
|
||||
|
||||
nsresult res = nsRepository::CreateInstance(kCCalTimeContextCID,
|
||||
nsnull,
|
||||
kCCalTimeContextIID,
|
||||
(void **)&context);
|
||||
|
||||
if (NS_OK != res)
|
||||
return res ;
|
||||
|
||||
context->Init();
|
||||
|
||||
context->Copy(aContext);
|
||||
|
||||
/*
|
||||
* Register this context to observe the copied context. We'll
|
||||
* need to deal with context mgmt if these things get frivolously
|
||||
* destroyed/created.
|
||||
*/
|
||||
static NS_DEFINE_IID(kXPFCObserverIID, NS_IXPFC_OBSERVER_IID);
|
||||
static NS_DEFINE_IID(kXPFCSubjectIID, NS_IXPFC_SUBJECT_IID);
|
||||
|
||||
nsIXPFCSubject * context_subject;
|
||||
nsIXPFCObserver * context_observer;
|
||||
|
||||
aContext->QueryInterface(kXPFCSubjectIID, (void **)&context_subject);
|
||||
context->QueryInterface(kXPFCObserverIID, (void **)&context_observer);
|
||||
|
||||
gXPFCToolkit->GetObserverManager()->Register(context_subject, context_observer);
|
||||
|
||||
|
||||
/*
|
||||
* TODO: Add the increment here for the appropriate period
|
||||
*/
|
||||
|
||||
aCanvas->SetTimeContext(context);
|
||||
|
||||
|
||||
context->AddPeriod(nsCalPeriodFormat_kDay,increment);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult nsCalMultiDayViewCanvas::Action(nsIXPFCCommand * aCommand)
|
||||
{
|
||||
|
@ -683,3 +469,74 @@ nsresult nsCalMultiDayViewCanvas :: SetParameter(nsString& aKey, nsString& aValu
|
|||
|
||||
return (nsCalMultiViewCanvas::SetParameter(aKey, aValue));
|
||||
}
|
||||
|
||||
/*
|
||||
* Call SetContext on all child canvas that support the
|
||||
* nsCalTimebarCanvas interface. This routine is recursive.
|
||||
*
|
||||
* We need to store this TimeContext for ourselves also in case
|
||||
* we get asked to add new DayView Canvas's, we'll ask the DayView
|
||||
* to copy our context to start with.
|
||||
*/
|
||||
|
||||
nsresult nsCalMultiDayViewCanvas :: SetTimeContext(nsICalTimeContext * aContext)
|
||||
{
|
||||
|
||||
nsresult res = NS_OK;
|
||||
nsIIterator * iterator ;
|
||||
nsCalTimebarCanvas * canvas ;
|
||||
PRUint32 index = 0;
|
||||
|
||||
res = CreateIterator(&iterator);
|
||||
|
||||
if (NS_OK != res)
|
||||
return res;
|
||||
|
||||
iterator->Init();
|
||||
|
||||
while(!(iterator->IsDone()))
|
||||
{
|
||||
|
||||
/*
|
||||
* Iterate through these children til we find the right one
|
||||
*/
|
||||
|
||||
canvas = (nsCalTimebarCanvas *) iterator->CurrentItem();
|
||||
|
||||
nsresult res2 = NS_OK;
|
||||
nsIIterator * iterator2 ;
|
||||
nsCalTimebarCanvas * canvas2 ;
|
||||
|
||||
res2 = canvas->CreateIterator(&iterator2);
|
||||
|
||||
if (NS_OK != res2)
|
||||
return res2;
|
||||
|
||||
iterator2->Init();
|
||||
|
||||
while(!(iterator2->IsDone()))
|
||||
{
|
||||
|
||||
canvas2 = (nsCalTimebarCanvas *) iterator2->CurrentItem();
|
||||
|
||||
nsCalTimebarCanvas * canvas_iface = nsnull;;
|
||||
|
||||
canvas2->QueryInterface(kCalTimebarCanvasCID, (void**) &canvas_iface);
|
||||
|
||||
if (canvas_iface) {
|
||||
|
||||
SetChildTimeContext(canvas_iface, aContext, index);
|
||||
|
||||
NS_RELEASE(canvas_iface);
|
||||
}
|
||||
|
||||
iterator2->Next();
|
||||
|
||||
}
|
||||
|
||||
index++;
|
||||
iterator->Next();
|
||||
}
|
||||
|
||||
return (nsCalMultiViewCanvas :: SetTimeContext(aContext));
|
||||
}
|
||||
|
|
|
@ -16,6 +16,7 @@
|
|||
* Reserved.
|
||||
*/
|
||||
|
||||
#include "nsCalMultiDayViewCanvas.h"
|
||||
#include "nsCalMultiUserViewCanvas.h"
|
||||
#include "nsCalTimebarTimeHeading.h"
|
||||
#include "nsBoxLayout.h"
|
||||
|
@ -26,6 +27,7 @@
|
|||
#include "nsCalDayListCommand.h"
|
||||
#include "nsCalNewModelCommand.h"
|
||||
#include "nscalstrings.h"
|
||||
#include "nsxpfcstrings.h"
|
||||
|
||||
|
||||
static NS_DEFINE_IID(kISupportsIID, NS_ISUPPORTS_IID);
|
||||
|
@ -71,11 +73,130 @@ NS_IMPL_ADDREF(nsCalMultiUserViewCanvas)
|
|||
NS_IMPL_RELEASE(nsCalMultiUserViewCanvas)
|
||||
|
||||
/*
|
||||
* A MultiUser Canvas has 1 or more MultiDay Canvas's, one for each user
|
||||
*
|
||||
* So, let's create the default of 1 MuiltiDay for this canvas and give it
|
||||
* a week's worth of views.
|
||||
*
|
||||
* Ideally, we should probably figure out an XML syntax to specify this stuff
|
||||
*
|
||||
*/
|
||||
|
||||
nsresult nsCalMultiUserViewCanvas :: Init()
|
||||
{
|
||||
return (nsCalMultiViewCanvas::Init());
|
||||
|
||||
/*
|
||||
* create a multiday as a child of us
|
||||
*/
|
||||
|
||||
static NS_DEFINE_IID(kCalMultiDayViewCanvasCID, NS_CAL_MULTIDAYVIEWCANVAS_CID);
|
||||
static NS_DEFINE_IID(kIXPFCCanvasIID, NS_IXPFC_CANVAS_IID);
|
||||
|
||||
nsCalMultiDayViewCanvas * multi;
|
||||
|
||||
nsresult rv = nsCalMultiViewCanvas::Init();
|
||||
|
||||
nsresult res = nsRepository::CreateInstance(kCalMultiDayViewCanvasCID,
|
||||
nsnull,
|
||||
kIXPFCCanvasIID,
|
||||
(void **)&multi);
|
||||
|
||||
if (NS_OK == res)
|
||||
{
|
||||
|
||||
multi->Init();
|
||||
|
||||
AddChildCanvas(multi);
|
||||
|
||||
multi->SetShowTimeScale(PR_TRUE);
|
||||
|
||||
nsLayoutAlignment la = ((nsBoxLayout *)(GetLayout()))->GetLayoutAlignment();
|
||||
((nsBoxLayout *)(multi->GetLayout()))->SetLayoutAlignment(la);
|
||||
|
||||
multi->SetNumberViewableDays(1); // XXX
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
return (rv);
|
||||
}
|
||||
|
||||
|
||||
|
||||
nsresult nsCalMultiUserViewCanvas :: SetParameter(nsString& aKey, nsString& aValue)
|
||||
{
|
||||
PRInt32 error = 0;
|
||||
|
||||
if (aKey.EqualsIgnoreCase(XPFC_STRING_LAYOUT))
|
||||
{
|
||||
// XXX: Layout should implement this interface.
|
||||
// Then, put functionality in the core layout class
|
||||
// to identify the type of layout object needed.
|
||||
|
||||
if (aValue.EqualsIgnoreCase(XPFC_STRING_XBOX)) {
|
||||
((nsBoxLayout *)GetLayout())->SetLayoutAlignment(eLayoutAlignment_horizontal);
|
||||
} else if (aValue.EqualsIgnoreCase(XPFC_STRING_YBOX)) {
|
||||
((nsBoxLayout *)GetLayout())->SetLayoutAlignment(eLayoutAlignment_vertical);
|
||||
}
|
||||
|
||||
// XXX: We need to separate layout from the content model ... arghh...
|
||||
//
|
||||
// If someone changes our layout, pass it on to any MultiDay canvas
|
||||
// that are our children.
|
||||
|
||||
nsresult res ;
|
||||
nsIIterator * iterator ;
|
||||
nsIXPFCCanvas * canvas ;
|
||||
|
||||
res = CreateIterator(&iterator);
|
||||
|
||||
nsLayoutAlignment la = ((nsBoxLayout *)(GetLayout()))->GetLayoutAlignment();
|
||||
|
||||
if (NS_OK == res)
|
||||
{
|
||||
|
||||
iterator->Init();
|
||||
|
||||
while(!(iterator->IsDone()))
|
||||
{
|
||||
canvas = (nsIXPFCCanvas *) iterator->CurrentItem();
|
||||
|
||||
((nsBoxLayout *)(canvas->GetLayout()))->SetLayoutAlignment(la);
|
||||
|
||||
/*
|
||||
* Now, iterate thru its children and set the layout alignment
|
||||
*/
|
||||
|
||||
{
|
||||
nsIIterator * iterator2 ;
|
||||
|
||||
res = canvas->CreateIterator(&iterator2);
|
||||
|
||||
if (NS_OK == res)
|
||||
{
|
||||
|
||||
iterator2->Init();
|
||||
|
||||
|
||||
while(!(iterator2->IsDone()))
|
||||
{
|
||||
canvas = (nsIXPFCCanvas *) iterator2->CurrentItem();
|
||||
((nsBoxLayout *)(canvas->GetLayout()))->SetLayoutAlignment(la);
|
||||
iterator2->Next();
|
||||
}
|
||||
|
||||
NS_RELEASE(iterator2);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
iterator->Next();
|
||||
}
|
||||
|
||||
NS_RELEASE(iterator);
|
||||
}
|
||||
}
|
||||
|
||||
return (nsXPFCCanvas :: SetParameter(aKey, aValue));
|
||||
}
|
||||
|
|
|
@ -36,8 +36,10 @@ static NS_DEFINE_IID(kCalTimebarCanvasCID, NS_CAL_TIMEBARCANVAS_CID);
|
|||
nsCalMultiViewCanvas :: nsCalMultiViewCanvas(nsISupports* outer) : nsCalTimebarComponentCanvas(outer)
|
||||
{
|
||||
NS_INIT_REFCNT();
|
||||
mShowHeaders = PR_TRUE;
|
||||
mShowStatus = PR_FALSE;
|
||||
|
||||
mShowHeaders = PR_TRUE;
|
||||
mShowStatus = PR_FALSE;
|
||||
mShowTimeScale = PR_FALSE;
|
||||
}
|
||||
|
||||
nsCalMultiViewCanvas :: ~nsCalMultiViewCanvas()
|
||||
|
@ -93,23 +95,34 @@ PRBool nsCalMultiViewCanvas :: GetShowHeaders()
|
|||
return (mShowHeaders);
|
||||
}
|
||||
|
||||
PRBool nsCalMultiViewCanvas :: GetShowStatus()
|
||||
{
|
||||
return (mShowStatus);
|
||||
}
|
||||
|
||||
nsresult nsCalMultiViewCanvas :: SetShowHeaders(PRBool aShowHeaders)
|
||||
{
|
||||
mShowHeaders = aShowHeaders;
|
||||
return (NS_OK);
|
||||
}
|
||||
|
||||
|
||||
PRBool nsCalMultiViewCanvas :: GetShowStatus()
|
||||
{
|
||||
return (mShowStatus);
|
||||
}
|
||||
|
||||
nsresult nsCalMultiViewCanvas :: SetShowStatus(PRBool aShowStatus)
|
||||
{
|
||||
mShowStatus = aShowStatus;
|
||||
return (NS_OK);
|
||||
}
|
||||
|
||||
PRBool nsCalMultiViewCanvas :: GetShowTimeScale()
|
||||
{
|
||||
return (mShowTimeScale);
|
||||
}
|
||||
|
||||
nsresult nsCalMultiViewCanvas :: SetShowTimeScale(PRBool aShowTimeScale)
|
||||
{
|
||||
mShowTimeScale = aShowTimeScale;
|
||||
return (NS_OK);
|
||||
}
|
||||
|
||||
|
||||
nsresult nsCalMultiViewCanvas::Action(nsIXPFCCommand * aCommand)
|
||||
|
|
|
@ -18,6 +18,7 @@
|
|||
|
||||
#include "nsCalTimebarCanvas.h"
|
||||
#include "nsCalUICIID.h"
|
||||
#include "nsXPFCToolkit.h"
|
||||
|
||||
static NS_DEFINE_IID(kISupportsIID, NS_ISUPPORTS_IID);
|
||||
static NS_DEFINE_IID(kCalTimebarCanvasCID, NS_CAL_TIMEBARCANVAS_CID);
|
||||
|
@ -94,14 +95,6 @@ PRUint32 nsCalTimebarCanvas::GetVisibleMinorIntervals()
|
|||
return (mTimeContext->GetMinorIncrementInterval()) ;
|
||||
}
|
||||
|
||||
nsresult nsCalTimebarCanvas :: SetTimeContext(nsICalTimeContext * aContext)
|
||||
{
|
||||
NS_IF_RELEASE(mTimeContext);
|
||||
mTimeContext = aContext;
|
||||
NS_ADDREF(mTimeContext);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsICalTimeContext * nsCalTimebarCanvas :: GetTimeContext()
|
||||
{
|
||||
/*
|
||||
|
@ -233,3 +226,174 @@ nsresult nsCalTimebarCanvas :: SetParameter(nsString& aKey, nsString& aValue)
|
|||
return (nsCalCanvas::SetParameter(aKey, aValue));
|
||||
}
|
||||
|
||||
/*
|
||||
* Call SetContext on all child canvas that support the
|
||||
* nsCalTimebarCanvas interface. This routine is recursive.
|
||||
*
|
||||
* We need to store this TimeContext for ourselves also in case
|
||||
* we get asked to add new DayView Canvas's, we'll ask the DayView
|
||||
* to copy our context to start with.
|
||||
*/
|
||||
|
||||
nsresult nsCalTimebarCanvas :: SetTimeContext(nsICalTimeContext * aContext)
|
||||
{
|
||||
|
||||
NS_IF_RELEASE(mTimeContext);
|
||||
mTimeContext = aContext;
|
||||
NS_ADDREF(mTimeContext);
|
||||
|
||||
return (NS_OK);
|
||||
}
|
||||
|
||||
nsresult nsCalTimebarCanvas :: ChangeChildDateTime(nsCalTimebarCanvas * aCanvas,
|
||||
nsDateTime * aDateTime)
|
||||
{
|
||||
|
||||
nsIDateTime * datetime;
|
||||
nsICalTimeContext * context = aCanvas->GetTimeContext();
|
||||
|
||||
if (context == nsnull)
|
||||
return NS_OK;
|
||||
|
||||
context->SetDate(aDateTime);
|
||||
|
||||
datetime = context->GetDTStart() ;
|
||||
datetime->SetYear(aDateTime->GetYear());
|
||||
datetime->SetMonth(aDateTime->GetMonth());
|
||||
datetime->SetDay(aDateTime->GetDay());
|
||||
|
||||
datetime = context->GetDTEnd() ;
|
||||
datetime->SetYear(aDateTime->GetYear());
|
||||
datetime->SetMonth(aDateTime->GetMonth());
|
||||
datetime->SetDay(aDateTime->GetDay()+1);
|
||||
|
||||
datetime = context->GetDTFirstVisible() ;
|
||||
datetime->SetYear(aDateTime->GetYear());
|
||||
datetime->SetMonth(aDateTime->GetMonth());
|
||||
datetime->SetDay(aDateTime->GetDay());
|
||||
|
||||
datetime = context->GetDTLastVisible() ;
|
||||
datetime->SetYear(aDateTime->GetYear());
|
||||
datetime->SetMonth(aDateTime->GetMonth());
|
||||
datetime->SetDay(aDateTime->GetDay());
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult nsCalTimebarCanvas :: SetChildTimeContext(nsCalTimebarCanvas * aCanvas,
|
||||
nsICalTimeContext * aContext,
|
||||
PRUint32 increment)
|
||||
{
|
||||
nsICalTimeContext * context;
|
||||
|
||||
static NS_DEFINE_IID(kCCalTimeContextCID, NS_CAL_TIME_CONTEXT_CID);
|
||||
static NS_DEFINE_IID(kCCalTimeContextIID, NS_ICAL_TIME_CONTEXT_IID);
|
||||
|
||||
nsresult res = nsRepository::CreateInstance(kCCalTimeContextCID,
|
||||
nsnull,
|
||||
kCCalTimeContextIID,
|
||||
(void **)&context);
|
||||
|
||||
if (NS_OK != res)
|
||||
return res ;
|
||||
|
||||
context->Init();
|
||||
|
||||
context->Copy(aContext);
|
||||
|
||||
/*
|
||||
* Register this context to observe the copied context. We'll
|
||||
* need to deal with context mgmt if these things get frivolously
|
||||
* destroyed/created.
|
||||
*/
|
||||
static NS_DEFINE_IID(kXPFCObserverIID, NS_IXPFC_OBSERVER_IID);
|
||||
static NS_DEFINE_IID(kXPFCSubjectIID, NS_IXPFC_SUBJECT_IID);
|
||||
|
||||
nsIXPFCSubject * context_subject;
|
||||
nsIXPFCObserver * context_observer;
|
||||
|
||||
aContext->QueryInterface(kXPFCSubjectIID, (void **)&context_subject);
|
||||
context->QueryInterface(kXPFCObserverIID, (void **)&context_observer);
|
||||
|
||||
gXPFCToolkit->GetObserverManager()->Register(context_subject, context_observer);
|
||||
|
||||
|
||||
/*
|
||||
* TODO: Add the increment here for the appropriate period
|
||||
*/
|
||||
|
||||
aCanvas->SetTimeContext(context);
|
||||
|
||||
|
||||
context->AddPeriod(nsCalPeriodFormat_kDay,increment);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
|
||||
nsresult nsCalTimebarCanvas :: ChangeChildDateTime(PRUint32 aIndex, nsDateTime * aDateTime)
|
||||
{
|
||||
nsresult res = NS_OK;
|
||||
nsIIterator * iterator ;
|
||||
nsCalTimebarCanvas * canvas ;
|
||||
PRUint32 index = 0;
|
||||
|
||||
res = CreateIterator(&iterator);
|
||||
|
||||
if (NS_OK != res)
|
||||
return res;
|
||||
|
||||
iterator->Init();
|
||||
|
||||
while((!(iterator->IsDone())))
|
||||
{
|
||||
|
||||
if ((index == aIndex)) {
|
||||
|
||||
/*
|
||||
* Iterate through these children til we find the right one
|
||||
*/
|
||||
|
||||
canvas = (nsCalTimebarCanvas *) iterator->CurrentItem();
|
||||
|
||||
nsresult res2 = NS_OK;
|
||||
nsIIterator * iterator2 ;
|
||||
nsCalTimebarCanvas * canvas2 ;
|
||||
|
||||
res2 = canvas->CreateIterator(&iterator2);
|
||||
|
||||
if (NS_OK != res2)
|
||||
return res2;
|
||||
|
||||
iterator2->Init();
|
||||
|
||||
while(!(iterator2->IsDone()))
|
||||
{
|
||||
|
||||
canvas2 = (nsCalTimebarCanvas *) iterator2->CurrentItem();
|
||||
|
||||
nsCalTimebarCanvas * canvas_iface = nsnull;;
|
||||
|
||||
canvas2->QueryInterface(kCalTimebarCanvasCID, (void**) &canvas_iface);
|
||||
|
||||
if ((canvas_iface != nsnull)) {
|
||||
|
||||
ChangeChildDateTime(canvas_iface, aDateTime);
|
||||
|
||||
NS_RELEASE(canvas_iface);
|
||||
}
|
||||
|
||||
iterator2->Next();
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
index++;
|
||||
iterator->Next();
|
||||
}
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче