From b39b7546ad0ed029f19ca839986b1d35adb53ada Mon Sep 17 00:00:00 2001 From: "spider%netscape.com" Date: Wed, 7 Oct 1998 20:50:12 +0000 Subject: [PATCH] Multi-User View support. Add dynamic layout support in Multi User and Day Views --- .../ui/canvas/inc/nsCalMultiDayViewCanvas.h | 1 - .../ui/canvas/src/nsCalMultiDayViewCanvas.cpp | 80 +++++++++++++++++-- .../canvas/src/nsCalMultiUserViewCanvas.cpp | 44 +++------- calendar/modules/ui/res/trex.ui | 2 +- 4 files changed, 89 insertions(+), 38 deletions(-) diff --git a/calendar/modules/ui/canvas/inc/nsCalMultiDayViewCanvas.h b/calendar/modules/ui/canvas/inc/nsCalMultiDayViewCanvas.h index 02c1e5a141fc..cfec29586b77 100644 --- a/calendar/modules/ui/canvas/inc/nsCalMultiDayViewCanvas.h +++ b/calendar/modules/ui/canvas/inc/nsCalMultiDayViewCanvas.h @@ -47,7 +47,6 @@ public: // nsIXPFCCommandReceiver methods NS_IMETHOD_(nsEventStatus) Action(nsIXPFCCommand * aCommand); -private: NS_IMETHOD SetMultiDayLayout(nsLayoutAlignment aLayoutAlignment); protected: diff --git a/calendar/modules/ui/canvas/src/nsCalMultiDayViewCanvas.cpp b/calendar/modules/ui/canvas/src/nsCalMultiDayViewCanvas.cpp index ceede13decee..8f915ba9c6d3 100644 --- a/calendar/modules/ui/canvas/src/nsCalMultiDayViewCanvas.cpp +++ b/calendar/modules/ui/canvas/src/nsCalMultiDayViewCanvas.cpp @@ -35,10 +35,11 @@ #define DEFAULT_NUMBER_VIEWABLE_DAYS 5 -static NS_DEFINE_IID(kISupportsIID, NS_ISUPPORTS_IID); +static NS_DEFINE_IID(kISupportsIID, NS_ISUPPORTS_IID); static NS_DEFINE_IID(kCalMultiDayViewCanvasCID, NS_CAL_MULTIDAYVIEWCANVAS_CID); -static NS_DEFINE_IID(kIXPFCCanvasIID, NS_IXPFC_CANVAS_IID); -static NS_DEFINE_IID(kCalTimebarCanvasCID, NS_CAL_TIMEBARCANVAS_CID); +static NS_DEFINE_IID(kIXPFCCanvasIID, NS_IXPFC_CANVAS_IID); +static NS_DEFINE_IID(kCalTimebarCanvasCID, NS_CAL_TIMEBARCANVAS_CID); +static NS_DEFINE_IID(kCCalDayViewCID, NS_CAL_DAYVIEWCANVAS_CID); nsCalMultiDayViewCanvas :: nsCalMultiDayViewCanvas(nsISupports* outer) : nsCalMultiViewCanvas(outer) { @@ -151,7 +152,6 @@ PRUint32 nsCalMultiDayViewCanvas :: GetNumberViewableDays() nsIXPFCCanvas * nsCalMultiDayViewCanvas :: AddDayViewCanvas() { - static NS_DEFINE_IID(kCCalDayViewCID, NS_CAL_DAYVIEWCANVAS_CID); static NS_DEFINE_IID(kIXPFCCanvasIID, NS_IXPFC_CANVAS_IID); nsCalDayViewCanvas * canvas; @@ -493,7 +493,77 @@ nsresult nsCalMultiDayViewCanvas :: SetParameter(nsString& aKey, nsString& aValu nsresult nsCalMultiDayViewCanvas :: SetMultiDayLayout(nsLayoutAlignment aLayoutAlignment) { - return NS_OK; + nsresult res = NS_OK; + nsIXPFCCanvas * canvas; + nsIIterator * iterator ; + + /* + * Enumarate the child canvas + */ + + nsLayoutAlignment la = ((nsBoxLayout *)(GetLayout()))->GetLayoutAlignment(); + + if (eLayoutAlignment_horizontal == la) + la = eLayoutAlignment_vertical; + else + la = eLayoutAlignment_horizontal; + + res = CreateIterator(&iterator); + + if (NS_OK != res) + return res; + + iterator->Init(); + + while(!(iterator->IsDone())) + { + canvas = (nsIXPFCCanvas *) iterator->CurrentItem(); + + ((nsBoxLayout *)(canvas->GetLayout()))->SetLayoutAlignment(la); + + /* + * Enumarate children looking for DayView and set its alignment + */ + + nsresult res2 = NS_OK; + nsIIterator * iterator2 ; + nsIXPFCCanvas * canvas2 ; + + res2 = canvas->CreateIterator(&iterator2); + + if (NS_OK == res2) + { + + iterator2->Init(); + + while(!(iterator2->IsDone())) + { + + canvas2 = (nsIXPFCCanvas *) iterator2->CurrentItem(); + + nsCalDayViewCanvas * canvas_iface = nsnull;; + + canvas2->QueryInterface(kCCalDayViewCID, (void**) &canvas_iface); + + if (canvas_iface) + { + + ((nsBoxLayout *)(canvas_iface->GetLayout()))->SetLayoutAlignment(la); + + NS_RELEASE(canvas_iface); + } + + iterator2->Next(); + + } + } + + + + iterator->Next(); + } + + return res; } /* diff --git a/calendar/modules/ui/canvas/src/nsCalMultiUserViewCanvas.cpp b/calendar/modules/ui/canvas/src/nsCalMultiUserViewCanvas.cpp index 095822d258fb..16b05389c47d 100644 --- a/calendar/modules/ui/canvas/src/nsCalMultiUserViewCanvas.cpp +++ b/calendar/modules/ui/canvas/src/nsCalMultiUserViewCanvas.cpp @@ -31,10 +31,11 @@ #include "nsCalNewModelCommand.h" -static NS_DEFINE_IID(kISupportsIID, NS_ISUPPORTS_IID); -static NS_DEFINE_IID(kCalMultiViewCanvasCID, NS_CAL_MULTIVIEWCANVAS_CID); -static NS_DEFINE_IID(kIXPFCCanvasIID, NS_IXPFC_CANVAS_IID); -static NS_DEFINE_IID(kCalTimebarCanvasCID, NS_CAL_TIMEBARCANVAS_CID); +static NS_DEFINE_IID(kISupportsIID, NS_ISUPPORTS_IID); +static NS_DEFINE_IID(kCalMultiViewCanvasCID, NS_CAL_MULTIVIEWCANVAS_CID); +static NS_DEFINE_IID(kIXPFCCanvasIID, NS_IXPFC_CANVAS_IID); +static NS_DEFINE_IID(kCalTimebarCanvasCID, NS_CAL_TIMEBARCANVAS_CID); +static NS_DEFINE_IID(kCalMultiDayViewCanvasCID, NS_CAL_MULTIDAYVIEWCANVAS_CID); nsCalMultiUserViewCanvas :: nsCalMultiUserViewCanvas(nsISupports* outer) : nsCalMultiViewCanvas(outer) { @@ -97,7 +98,6 @@ nsresult nsCalMultiUserViewCanvas :: Init() nsresult nsCalMultiUserViewCanvas :: AddMultiDayView(nsIModel * aModel) { - static NS_DEFINE_IID(kCalMultiDayViewCanvasCID, NS_CAL_MULTIDAYVIEWCANVAS_CID); static NS_DEFINE_IID(kIXPFCCanvasIID, NS_IXPFC_CANVAS_IID); nsCalMultiDayViewCanvas * multi; @@ -182,34 +182,16 @@ nsresult nsCalMultiUserViewCanvas :: SetMultiUserLayout(nsLayoutAlignment aLayou { canvas = (nsIXPFCCanvas *) iterator->CurrentItem(); - ((nsBoxLayout *)(canvas->GetLayout()))->SetLayoutAlignment(la); + nsCalMultiDayViewCanvas * md = nsnull; - /* - * Now, iterate thru its children and set the layout alignment - */ + res = canvas->QueryInterface(kCalMultiDayViewCanvasCID, (void**)&md); - { - 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); - } - - } + if (NS_OK == res) + { + ((nsBoxLayout *)(canvas->GetLayout()))->SetLayoutAlignment(la); + md->SetMultiDayLayout(la); + NS_RELEASE(md); + } iterator->Next(); } diff --git a/calendar/modules/ui/res/trex.ui b/calendar/modules/ui/res/trex.ui index 814bddb08091..ab484e70620d 100644 --- a/calendar/modules/ui/res/trex.ui +++ b/calendar/modules/ui/res/trex.ui @@ -17,7 +17,7 @@ - +